OSDN Git Service

askfor_aux()にて、漢字を含む文字列を編集中。左カーソル移動とバックスペースがバグっていたので修正。
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 13 Oct 2003 07:17:39 +0000 (07:17 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 13 Oct 2003 07:17:39 +0000 (07:17 +0000)
src/util.c

index 2ff7ba5..63a5d82 100644 (file)
@@ -3216,7 +3216,7 @@ bool askfor_aux(char *buf, int len)
                                int next_pos = i + 1;
 
 #ifdef JP
-                               if (iskanji(buf[next_pos])) next_pos++;
+                               if (iskanji(buf[i])) next_pos++;
 #endif
 
                                /* Is there the cursor at next position? */ 
@@ -3262,17 +3262,35 @@ bool askfor_aux(char *buf, int len)
 
                case '\010':
                        /* Backspace */
+               {
+                       int i = 0;
 
                        /* Now on insert mode */
                        color = TERM_WHITE;
 
                        /* No move at biggining of line */
-                       if (!pos) break;
+                       if (0 == pos) break;
+
+                       while (TRUE)
+                       {
+                               int next_pos = i + 1;
+
+#ifdef JP
+                               if (iskanji(buf[i])) next_pos++;
+#endif
 
-                       /* Go left 1 unit */
-                       pos--;
+                               /* Is there the cursor at next position? */ 
+                               if (next_pos >= pos) break;
+
+                               /* Move to next */
+                               i = next_pos;
+                       }
+
+                       /* Get previous position */
+                       pos = i;
 
                        /* Fall through to 'Delete key' */
+               }
 
                case 0x7F:
                case KTRL('d'):
@@ -3288,7 +3306,7 @@ bool askfor_aux(char *buf, int len)
 
 #ifdef JP
                        /* Next character is one more byte away */
-                       if (iskanji(src)) src++;
+                       if (iskanji(buf[pos])) src++;
 #endif
 
                        dst = pos;