if (!s) return (-1);
/* Format to length */
+#ifndef WIN32
(void)strnfmt(buf, max, "%s", s);
+#else
+ (void)strnfmt(buf, max, ".%s", s);
+#endif
/* Success */
return (0);
/* 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 */
else
{
/* Increase "wait" */
- w += 10;
+ w += 1;
/* Excessive delay */
- if (w >= 100) break;
+ if (w >= 10) break;
/* Delay */
Term_xtra(TERM_XTRA_DELAY, w);
}
/* Limit the multiplier to 1000 */
- if (buf && streq(buf, str) && (j < 1000))
+ if (streq(buf, str) && (j < 1000))
{
j++;
prt(prompt, 0, 0);
/* Get a key */
- *command = inkey();
+ if (get_com_no_macros)
+ *command = inkey_special(FALSE);
+ else
+ *command = inkey();
/* Clear the prompt */
prt("", 0, 0);
{
tag_type temp;
- temp.tag = a->tag;
- temp.pointer = a->pointer;
-
- a->tag = b->tag;
- a->pointer = b->pointer;
-
- b->tag = temp.tag;
- b->pointer = temp.pointer;
+ temp = *a;
+ *a = *b;
+ *b = temp;
}
const char *s = src;
size_t len = 0;
- /* reserve for NUL termination */
- bufsize--;
+ if (bufsize > 0) {
+ /* reserve for NUL termination */
+ bufsize--;
- /* Copy as many bytes as will fit */
- while (len < bufsize)
- {
- if (iskanji(*s))
- {
- if (len + 1 >= bufsize || !*(s+1)) break;
- *d++ = *s++;
- *d++ = *s++;
- len += 2;
- }
- else
+ /* Copy as many bytes as will fit */
+ while (*s && (len < bufsize))
{
- *d++ = *s++;
- len++;
+ if (iskanji(*s))
+ {
+ if (len + 1 >= bufsize || !*(s+1)) break;
+ *d++ = *s++;
+ *d++ = *s++;
+ len += 2;
+ }
+ else
+ {
+ *d++ = *s++;
+ len++;
+ }
}
+ *d = '\0';
}
- *d = '\0';
+
while(*s++) len++;
return len;
{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;
}
}
+ 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 */