変愚蛮怒のメインリポジトリです
Revision | 9dead93de998d3f7bba53a79da2560c803a9d498 (tree) |
---|---|
Time | 2003-10-13 11:18:46 |
Author | mogami <mogami@0568...> |
Commiter | mogami |
文字列入力中に、挿入モードへ移行する条件を微調整。deleteやbackspace等を押した時も移行。
@@ -3098,6 +3098,12 @@ static byte get_destroyed_object_for_search(object_type **o_handle, cptr *search | ||
3098 | 3098 | static byte get_string_for_search(object_type **o_handle, cptr *search_strp) |
3099 | 3099 | { |
3100 | 3100 | int pos = 0; |
3101 | + | |
3102 | + /* | |
3103 | + * Text color | |
3104 | + * TERM_YELLOW : Overwrite mode | |
3105 | + * TERM_WHITE : Insert mode | |
3106 | + */ | |
3101 | 3107 | byte color = TERM_YELLOW; |
3102 | 3108 | char buf[MAX_NLEN+20]; |
3103 | 3109 | const size_t len = 80; |
@@ -3140,7 +3146,10 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) | ||
3140 | 3146 | { |
3141 | 3147 | int i = 0; |
3142 | 3148 | |
3143 | - /* No effect at biggining of line */ | |
3149 | + /* Now on insert mode */ | |
3150 | + color = TERM_WHITE; | |
3151 | + | |
3152 | + /* No move at biggining of line */ | |
3144 | 3153 | if (0 == pos) break; |
3145 | 3154 | |
3146 | 3155 | while (TRUE) |
@@ -3161,15 +3170,15 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) | ||
3161 | 3170 | /* Get previous position */ |
3162 | 3171 | pos = i; |
3163 | 3172 | |
3164 | - /* Now on insert mode */ | |
3165 | - color = TERM_WHITE; | |
3166 | - | |
3167 | 3173 | break; |
3168 | 3174 | } |
3169 | 3175 | |
3170 | 3176 | case SKEY_RIGHT: |
3171 | 3177 | case KTRL('f'): |
3172 | - /* No effect at end of line */ | |
3178 | + /* Now on insert mode */ | |
3179 | + color = TERM_WHITE; | |
3180 | + | |
3181 | + /* No move at end of line */ | |
3173 | 3182 | if ('\0' == buf[pos]) break; |
3174 | 3183 | |
3175 | 3184 | #ifdef JP |
@@ -3180,9 +3189,6 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) | ||
3180 | 3189 | pos++; |
3181 | 3190 | #endif |
3182 | 3191 | |
3183 | - /* Now on insert mode */ | |
3184 | - color = TERM_WHITE; | |
3185 | - | |
3186 | 3192 | break; |
3187 | 3193 | |
3188 | 3194 | case ESCAPE: |
@@ -3214,7 +3220,10 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) | ||
3214 | 3220 | case '\010': |
3215 | 3221 | /* Backspace */ |
3216 | 3222 | |
3217 | - /* No effect at biggining of line */ | |
3223 | + /* Now on insert mode */ | |
3224 | + color = TERM_WHITE; | |
3225 | + | |
3226 | + /* No move at biggining of line */ | |
3218 | 3227 | if (!pos) break; |
3219 | 3228 | |
3220 | 3229 | /* Go left 1 unit */ |
@@ -3226,17 +3235,21 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) | ||
3226 | 3235 | case KTRL('d'): |
3227 | 3236 | /* Delete key */ |
3228 | 3237 | { |
3238 | + int dst, src; | |
3229 | 3239 | |
3230 | - int dst = pos; | |
3240 | + /* Now on insert mode */ | |
3241 | + color = TERM_WHITE; | |
3231 | 3242 | |
3232 | 3243 | /* Position of next character */ |
3233 | - int src = pos + 1; | |
3244 | + src = pos + 1; | |
3234 | 3245 | |
3235 | 3246 | #ifdef JP |
3236 | 3247 | /* Next character is one more byte away */ |
3237 | 3248 | if (iskanji(src)) src++; |
3238 | 3249 | #endif |
3239 | 3250 | |
3251 | + dst = pos; | |
3252 | + | |
3240 | 3253 | /* Move characters at src to dst */ |
3241 | 3254 | while ('\0' != (buf[dst++] = buf[src++])) |
3242 | 3255 | /* loop */; |
@@ -3138,13 +3138,19 @@ void clear_from(int row) | ||
3138 | 3138 | |
3139 | 3139 | |
3140 | 3140 | /* |
3141 | - * Get some input at the cursor location. | |
3141 | + * Get some string input at the cursor location. | |
3142 | 3142 | * Assume the buffer is initialized to a default string. |
3143 | - * Note that this string is often "empty" (see below). | |
3144 | - * The default buffer is displayed in yellow until cleared. | |
3145 | - * Pressing RETURN right away accepts the default entry. | |
3146 | - * Normal chars clear the default and append the char. | |
3147 | - * Backspace clears the default or deletes the final char. | |
3143 | + * | |
3144 | + * The default buffer is in Overwrite mode and displayed in yellow at | |
3145 | + * first. Normal chars clear the yellow text and append the char in | |
3146 | + * white text. | |
3147 | + * | |
3148 | + * LEFT (^B) and RIGHT (^F) movement keys move the cursor position. | |
3149 | + * If the text is still displayed in yellow (Overwite mode), it will | |
3150 | + * turns into white (Insert mode) when cursor moves. | |
3151 | + * | |
3152 | + * DELETE (^D) deletes a char at the cursor position. | |
3153 | + * BACKSPACE (^H) deletes a char at the left of cursor position. | |
3148 | 3154 | * ESCAPE clears the buffer and the window and returns FALSE. |
3149 | 3155 | * RETURN accepts the current buffer contents and returns TRUE. |
3150 | 3156 | */ |
@@ -3152,6 +3158,12 @@ bool askfor_aux(char *buf, int len) | ||
3152 | 3158 | { |
3153 | 3159 | int y, x; |
3154 | 3160 | int pos = 0; |
3161 | + | |
3162 | + /* | |
3163 | + * Text color | |
3164 | + * TERM_YELLOW : Overwrite mode | |
3165 | + * TERM_WHITE : Insert mode | |
3166 | + */ | |
3155 | 3167 | byte color = TERM_YELLOW; |
3156 | 3168 | |
3157 | 3169 | /* Locate the cursor position */ |
@@ -3193,7 +3205,10 @@ bool askfor_aux(char *buf, int len) | ||
3193 | 3205 | { |
3194 | 3206 | int i = 0; |
3195 | 3207 | |
3196 | - /* No effect at biggining of line */ | |
3208 | + /* Now on insert mode */ | |
3209 | + color = TERM_WHITE; | |
3210 | + | |
3211 | + /* No move at biggining of line */ | |
3197 | 3212 | if (0 == pos) break; |
3198 | 3213 | |
3199 | 3214 | while (TRUE) |
@@ -3214,15 +3229,15 @@ bool askfor_aux(char *buf, int len) | ||
3214 | 3229 | /* Get previous position */ |
3215 | 3230 | pos = i; |
3216 | 3231 | |
3217 | - /* Now on insert mode */ | |
3218 | - color = TERM_WHITE; | |
3219 | - | |
3220 | 3232 | break; |
3221 | 3233 | } |
3222 | 3234 | |
3223 | 3235 | case SKEY_RIGHT: |
3224 | 3236 | case KTRL('f'): |
3225 | - /* No effect at end of line */ | |
3237 | + /* Now on insert mode */ | |
3238 | + color = TERM_WHITE; | |
3239 | + | |
3240 | + /* No move at end of line */ | |
3226 | 3241 | if ('\0' == buf[pos]) break; |
3227 | 3242 | |
3228 | 3243 | #ifdef JP |
@@ -3233,9 +3248,6 @@ bool askfor_aux(char *buf, int len) | ||
3233 | 3248 | pos++; |
3234 | 3249 | #endif |
3235 | 3250 | |
3236 | - /* Now on insert mode */ | |
3237 | - color = TERM_WHITE; | |
3238 | - | |
3239 | 3251 | break; |
3240 | 3252 | |
3241 | 3253 | case ESCAPE: |
@@ -3251,7 +3263,10 @@ bool askfor_aux(char *buf, int len) | ||
3251 | 3263 | case '\010': |
3252 | 3264 | /* Backspace */ |
3253 | 3265 | |
3254 | - /* No effect at biggining of line */ | |
3266 | + /* Now on insert mode */ | |
3267 | + color = TERM_WHITE; | |
3268 | + | |
3269 | + /* No move at biggining of line */ | |
3255 | 3270 | if (!pos) break; |
3256 | 3271 | |
3257 | 3272 | /* Go left 1 unit */ |
@@ -3263,17 +3278,21 @@ bool askfor_aux(char *buf, int len) | ||
3263 | 3278 | case KTRL('d'): |
3264 | 3279 | /* Delete key */ |
3265 | 3280 | { |
3281 | + int dst, src; | |
3266 | 3282 | |
3267 | - int dst = pos; | |
3283 | + /* Now on insert mode */ | |
3284 | + color = TERM_WHITE; | |
3268 | 3285 | |
3269 | 3286 | /* Position of next character */ |
3270 | - int src = pos + 1; | |
3287 | + src = pos + 1; | |
3271 | 3288 | |
3272 | 3289 | #ifdef JP |
3273 | 3290 | /* Next character is one more byte away */ |
3274 | 3291 | if (iskanji(src)) src++; |
3275 | 3292 | #endif |
3276 | 3293 | |
3294 | + dst = pos; | |
3295 | + | |
3277 | 3296 | /* Move characters at src to dst */ |
3278 | 3297 | while ('\0' != (buf[dst++] = buf[src++])) |
3279 | 3298 | /* loop */; |