From: mogami Date: Mon, 13 Oct 2003 02:18:46 +0000 (+0000) Subject: 文字列入力中に、挿入モードへ移行する条件を微調整。deleteやbackspace等を押した時も移行。 X-Git-Tag: v2.1.2~1015 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9dead93de998d3f7bba53a79da2560c803a9d498;p=hengband%2Fhengband.git 文字列入力中に、挿入モードへ移行する条件を微調整。deleteやbackspace等を押した時も移行。 --- 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 */;