OSDN Git Service

Add a monster, Young quicksilver dragon.
[hengband/hengband.git] / src / util.c
index d6547b8..8935a34 100644 (file)
@@ -661,7 +661,19 @@ errr fd_copy(cptr file, cptr what)
        /* Copy */
        while ((read_num = read(src_fd, buf, 1024)) > 0)
        {
-               write(dst_fd, buf, read_num);
+               int write_num = 0;
+               while (write_num < read_num)
+               {
+                       int ret = write(dst_fd, buf + write_num, read_num - write_num);
+                       if (ret < 0) {
+                               /* Close files */
+                               fd_close(src_fd);
+                               fd_close(dst_fd);
+
+                               return ret;
+                       }
+                       write_num += ret;
+               }
        }
 
        /* Close files */
@@ -5411,6 +5423,22 @@ int inkey_special(bool numpad_cursor)
                {TRUE, "KP_1]", SKEY_BOTTOM},
                {FALSE, NULL, 0},
        };
+
+       static const struct {
+               cptr keyname;
+               int keycode;
+       } gcu_special_key_list[] = {
+               {"A", SKEY_UP},
+               {"B", SKEY_DOWN},
+               {"C", SKEY_RIGHT},
+               {"D", SKEY_LEFT},
+               {"1~", SKEY_TOP},
+               {"4~", SKEY_BOTTOM},
+               {"5~", SKEY_PGUP},
+               {"6~", SKEY_PGDOWN},
+               {NULL, 0},
+       };
+
        char buf[1024];
        cptr str = buf;
        char key;
@@ -5499,6 +5527,19 @@ int inkey_special(bool numpad_cursor)
                }
        }
 
+       if (prefix(str, "\\e["))
+       {
+               str += 3;
+
+               for (i = 0; gcu_special_key_list[i].keyname; i++)
+               {
+                       if (streq(str, gcu_special_key_list[i].keyname))
+                       {
+                               return gcu_special_key_list[i].keycode;
+                       }
+               }
+       }
+
        /* No special key found? */
 
        /* Don't bother with this trigger no more */