From 0c2b414969badafdd634edcd941c868449cc9fd0 Mon Sep 17 00:00:00 2001 From: mogami Date: Sun, 23 Jun 2002 07:14:32 +0000 Subject: [PATCH] =?utf8?q?=E8=87=AA=E5=8B=95=E6=8B=BE=E3=81=84=E3=82=A8?= =?utf8?q?=E3=83=87=E3=82=A3=E3=82=BF=E6=94=B9=E8=89=AF=E3=80=82=20-=20?= =?utf8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=83=A2=E3=83=BC=E3=83=89?= =?utf8?q?=E3=81=A7=E3=80=81'!'=E3=80=81'~'=E3=80=81'('=E3=82=AD=E3=83=BC?= =?utf8?q?=E3=81=8C=E4=BE=BF=E5=88=A9=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F?= =?utf8?q?=E3=80=82=20=20=20=E7=B6=9A=E3=81=91=E3=81=A6=E6=8A=BC=E3=81=99?= =?utf8?q?=E3=81=A8=E8=A4=87=E6=95=B0=E3=81=AE=E8=A1=8C=E3=82=92=E4=B8=80?= =?utf8?q?=E5=BA=A6=E3=81=AB=E5=88=87=E3=82=8A=E6=8F=9B=E3=81=88=E3=82=89?= =?utf8?q?=E3=82=8C=E3=82=8B=E3=80=82=20-=20^K=E3=81=A7=E7=A9=BA=E8=A1=8C?= =?utf8?q?=E3=82=92=E5=90=AB=E3=82=80=E8=A4=87=E6=95=B0=E8=A1=8C=E3=82=92?= =?utf8?q?=E3=82=AB=E3=83=83=E3=83=88=E3=81=97=E3=81=9F=E5=BE=8C=E3=81=A7?= =?utf8?q?=E3=80=81=E3=83=9A=E3=83=BC=E3=82=B9=E3=83=88=E3=81=97=E3=81=9F?= =?utf8?q?=E3=81=A8=E3=81=8D=E3=81=A1=E3=82=83=E3=82=93=E3=81=A8=E7=A9=BA?= =?utf8?q?=E8=A1=8C=E3=82=82=20=20=20=E5=90=AB=E3=82=81=E3=81=A6=E5=BC=B5?= =?utf8?q?=E3=82=8A=E4=BB=98=E3=81=91=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?utf8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/autopick.c | 172 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 135 insertions(+), 37 deletions(-) diff --git a/src/autopick.c b/src/autopick.c index 51330320e..e588f3b98 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -2463,7 +2463,7 @@ void do_cmd_edit_autopick(void) int old_upper = -1, old_left = -1; int old_cy = -1; int key = -1, old_key; - + bool repeated_clearing = FALSE; bool edit_mode = FALSE; byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE; @@ -2833,11 +2833,26 @@ void do_cmd_edit_autopick(void) break; case '~': if (!autopick_new_entry(entry, lines_list[cy])) + { + if (old_key != key) repeated_clearing = FALSE; + + /* Next line */ + if (lines_list[cy + 1]) cy++; + cx = 0; break; + } string_free(lines_list[cy]); + if (old_key != key) + { + if (entry->action & DONT_AUTOPICK) + repeated_clearing = TRUE; + else + repeated_clearing = FALSE; + } + entry->action &= ~DO_AUTODESTROY; - if (entry->action & DO_AUTOPICK) + if (!repeated_clearing) { entry->action &= ~DO_AUTOPICK; entry->action |= DONT_AUTOPICK; @@ -2852,14 +2867,33 @@ void do_cmd_edit_autopick(void) /* Now dirty */ dirty_line = cy; + + /* Next line */ + if (lines_list[cy + 1]) cy++; + cx = 0; break; case '!': if (!autopick_new_entry(entry, lines_list[cy])) + { + if (old_key != key) repeated_clearing = FALSE; + + /* Next line */ + if (lines_list[cy + 1]) cy++; + cx = 0; break; + } string_free(lines_list[cy]); + if (old_key != key) + { + if (entry->action & DO_AUTODESTROY) + repeated_clearing = TRUE; + else + repeated_clearing = FALSE; + } + entry->action &= ~DONT_AUTOPICK; - if (entry->action & DO_AUTOPICK) + if (!repeated_clearing) { entry->action &= ~DO_AUTOPICK; entry->action |= DO_AUTODESTROY; @@ -2874,9 +2908,45 @@ void do_cmd_edit_autopick(void) /* Now dirty */ dirty_line = cy; + + /* Next line */ + if (lines_list[cy + 1]) cy++; + cx = 0; break; case '(': - key = KTRL('g'); + /* Toggle display on the 'M'ap */ + if (!autopick_new_entry(entry, lines_list[cy])) + { + if (old_key != key) repeated_clearing = FALSE; + + /* Next line */ + if (lines_list[cy + 1]) cy++; + cx = 0; + break; + } + string_free(lines_list[cy]); + + if (old_key != key) + { + if (entry->action & DO_DISPLAY) + repeated_clearing = TRUE; + else + repeated_clearing = FALSE; + } + + if (!repeated_clearing) + entry->action |= DO_DISPLAY; + else + entry->action &= ~DO_DISPLAY; + + lines_list[cy] = autopick_line_from_entry(entry); + + /* Now dirty */ + dirty_line = cy; + + /* Next line */ + if (lines_list[cy + 1]) cy++; + cx = 0; break; case '#': case '{': @@ -3289,18 +3359,32 @@ void do_cmd_edit_autopick(void) /* Paste killed text */ if (strlen(yank_buf)) { + bool ret = FALSE; + for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1) { - int k = j; + if (ret && '\n' == yank_buf[j]) + { + ret = FALSE; + continue; + } /* Split current line */ insert_return_code(lines_list, cx, cy); - /* Paste yank buffer */ + /* Save preceding string */ for(i = 0; lines_list[cy][i]; i++) buf[i] = lines_list[cy][i]; - while (yank_buf[k] && i < MAX_LINELEN) - buf[i++] = yank_buf[k++]; + + /* Paste yank buffer */ + if ('\n' != yank_buf[j]) + { + int k = j; + while (yank_buf[k] && i < MAX_LINELEN-1) + buf[i++] = yank_buf[k++]; + ret = TRUE; + } + buf[i] = '\0'; string_free(lines_list[cy]); @@ -3324,41 +3408,55 @@ void do_cmd_edit_autopick(void) case KTRL('k'): /* Kill rest of line */ - if (lines_list[cy][0] != '\0' && (uint)cx < strlen(lines_list[cy])) - { - /* Save preceding string */ - for (i = 0; lines_list[cy][i] && i < cx; i++) - { + if ((uint)cx > strlen(lines_list[cy])) + cx = (int)strlen(lines_list[cy]); + + /* Save preceding string */ + for (i = 0; lines_list[cy][i] && i < cx; i++) + { #ifdef JP - if (iskanji(lines_list[cy][i])) - { - buf[i] = lines_list[cy][i]; - i++; - } + if (iskanji(lines_list[cy][i])) + { + buf[i] = lines_list[cy][i]; + i++; + } #endif - buf[i] = lines_list[cy][i]; - } - buf[i] = '\0'; + buf[i] = lines_list[cy][i]; + } + buf[i] = '\0'; - j = 0; - if (old_key == KTRL('k')) - while (yank_buf[j]) - j += strlen(yank_buf + j) + 1; + j = 0; + if (old_key == key) + while (yank_buf[j]) + j += strlen(yank_buf + j) + 1; - /* Copy following to yank buffer */ - while (lines_list[cy][i] && j < MAX_YANK - 2) - yank_buf[j++] = lines_list[cy][i++]; - yank_buf[j++] = '\0'; - yank_buf[j] = '\0'; + /* Copy following to yank buffer */ + if (lines_list[cy][i]) + { + while (lines_list[cy][i] && j < MAX_YANK - 2) + yank_buf[j++] = lines_list[cy][i++]; + i = TRUE; + } + else + { + if (j < MAX_YANK - 2) + yank_buf[j++] = '\n'; + i = FALSE; + } + yank_buf[j++] = '\0'; + yank_buf[j] = '\0'; - /* Replace current line with 'preceding string' */ - string_free(lines_list[cy]); - lines_list[cy] = string_make(buf); + /* Replace current line with 'preceding string' */ + string_free(lines_list[cy]); + lines_list[cy] = string_make(buf); + + if (i) + { + /* Now dirty */ + dirty_line = cy; + break; + } - /* Now dirty */ - dirty_line = cy; - break; - } /* fall through */ case KTRL('d'): case 0x7F: -- 2.11.0