From 9dead93de998d3f7bba53a79da2560c803a9d498 Mon Sep 17 00:00:00 2001 From: mogami Date: Mon, 13 Oct 2003 02:18:46 +0000 Subject: [PATCH] =?utf8?q?=E6=96=87=E5=AD=97=E5=88=97=E5=85=A5=E5=8A=9B?= =?utf8?q?=E4=B8=AD=E3=81=AB=E3=80=81=E6=8C=BF=E5=85=A5=E3=83=A2=E3=83=BC?= =?utf8?q?=E3=83=89=E3=81=B8=E7=A7=BB=E8=A1=8C=E3=81=99=E3=82=8B=E6=9D=A1?= =?utf8?q?=E4=BB=B6=E3=82=92=E5=BE=AE=E8=AA=BF=E6=95=B4=E3=80=82delete?= =?utf8?q?=E3=82=84backspace=E7=AD=89=E3=82=92=E6=8A=BC=E3=81=97=E3=81=9F?= =?utf8?q?=E6=99=82=E3=82=82=E7=A7=BB=E8=A1=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/autopick.c | 35 ++++++++++++++++++++++++----------- src/util.c | 53 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 60 insertions(+), 28 deletions(-) diff --git a/src/autopick.c b/src/autopick.c index de6dd9bec..a865c275e 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -3098,6 +3098,12 @@ static byte get_destroyed_object_for_search(object_type **o_handle, cptr *search static byte get_string_for_search(object_type **o_handle, cptr *search_strp) { int pos = 0; + + /* + * Text color + * TERM_YELLOW : Overwrite mode + * TERM_WHITE : Insert mode + */ byte color = TERM_YELLOW; char buf[MAX_NLEN+20]; const size_t len = 80; @@ -3140,7 +3146,10 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) { int i = 0; - /* No effect at biggining of line */ + /* Now on insert mode */ + color = TERM_WHITE; + + /* No move at biggining of line */ if (0 == pos) break; while (TRUE) @@ -3161,15 +3170,15 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) /* Get previous position */ pos = i; - /* Now on insert mode */ - color = TERM_WHITE; - break; } case SKEY_RIGHT: case KTRL('f'): - /* No effect at end of line */ + /* Now on insert mode */ + color = TERM_WHITE; + + /* No move at end of line */ if ('\0' == buf[pos]) break; #ifdef JP @@ -3180,9 +3189,6 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) pos++; #endif - /* Now on insert mode */ - color = TERM_WHITE; - break; case ESCAPE: @@ -3214,7 +3220,10 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) case '\010': /* Backspace */ - /* No effect at biggining of line */ + /* Now on insert mode */ + color = TERM_WHITE; + + /* No move at biggining of line */ if (!pos) break; /* Go left 1 unit */ @@ -3226,17 +3235,21 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) case KTRL('d'): /* Delete key */ { + int dst, src; - int dst = pos; + /* Now on insert mode */ + color = TERM_WHITE; /* Position of next character */ - int src = pos + 1; + src = pos + 1; #ifdef JP /* Next character is one more byte away */ if (iskanji(src)) src++; #endif + dst = pos; + /* Move characters at src to dst */ while ('\0' != (buf[dst++] = buf[src++])) /* loop */; diff --git a/src/util.c b/src/util.c index f167b92a4..09f9fd7fd 100644 --- a/src/util.c +++ b/src/util.c @@ -3138,13 +3138,19 @@ void clear_from(int row) /* - * Get some input at the cursor location. + * Get some string input at the cursor location. * Assume the buffer is initialized to a default string. - * Note that this string is often "empty" (see below). - * The default buffer is displayed in yellow until cleared. - * Pressing RETURN right away accepts the default entry. - * Normal chars clear the default and append the char. - * Backspace clears the default or deletes the final char. + * + * The default buffer is in Overwrite mode and displayed in yellow at + * first. Normal chars clear the yellow text and append the char in + * white text. + * + * LEFT (^B) and RIGHT (^F) movement keys move the cursor position. + * If the text is still displayed in yellow (Overwite mode), it will + * turns into white (Insert mode) when cursor moves. + * + * DELETE (^D) deletes a char at the cursor position. + * BACKSPACE (^H) deletes a char at the left of cursor position. * ESCAPE clears the buffer and the window and returns FALSE. * RETURN accepts the current buffer contents and returns TRUE. */ @@ -3152,6 +3158,12 @@ bool askfor_aux(char *buf, int len) { int y, x; int pos = 0; + + /* + * Text color + * TERM_YELLOW : Overwrite mode + * TERM_WHITE : Insert mode + */ byte color = TERM_YELLOW; /* Locate the cursor position */ @@ -3193,7 +3205,10 @@ bool askfor_aux(char *buf, int len) { int i = 0; - /* No effect at biggining of line */ + /* Now on insert mode */ + color = TERM_WHITE; + + /* No move at biggining of line */ if (0 == pos) break; while (TRUE) @@ -3214,15 +3229,15 @@ bool askfor_aux(char *buf, int len) /* Get previous position */ pos = i; - /* Now on insert mode */ - color = TERM_WHITE; - break; } case SKEY_RIGHT: case KTRL('f'): - /* No effect at end of line */ + /* Now on insert mode */ + color = TERM_WHITE; + + /* No move at end of line */ if ('\0' == buf[pos]) break; #ifdef JP @@ -3233,9 +3248,6 @@ bool askfor_aux(char *buf, int len) pos++; #endif - /* Now on insert mode */ - color = TERM_WHITE; - break; case ESCAPE: @@ -3251,7 +3263,10 @@ bool askfor_aux(char *buf, int len) case '\010': /* Backspace */ - /* No effect at biggining of line */ + /* Now on insert mode */ + color = TERM_WHITE; + + /* No move at biggining of line */ if (!pos) break; /* Go left 1 unit */ @@ -3263,17 +3278,21 @@ bool askfor_aux(char *buf, int len) case KTRL('d'): /* Delete key */ { + int dst, src; - int dst = pos; + /* Now on insert mode */ + color = TERM_WHITE; /* Position of next character */ - int src = pos + 1; + src = pos + 1; #ifdef JP /* Next character is one more byte away */ if (iskanji(src)) src++; #endif + dst = pos; + /* Move characters at src to dst */ while ('\0' != (buf[dst++] = buf[src++])) /* loop */; -- 2.11.0