From f4c3a09fc09eb01616e66aa7871d9b97d02b235d Mon Sep 17 00:00:00 2001 From: mogami Date: Thu, 18 Sep 2003 16:40:33 +0000 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=AD=A32=E3=81=A4=E3=80=82=E6=9C=80?= =?utf8?q?=E4=B8=8B=E8=A1=8C=E3=82=92=E3=82=AB=E3=83=83=E3=83=88=E3=81=99?= =?utf8?q?=E3=82=8B=E3=81=A8=E3=82=AF=E3=83=A9=E3=83=83=E3=82=B7=E3=83=A5?= =?utf8?q?=E3=80=82=E8=A1=8C=E6=9C=AB=E3=82=88=E3=82=8A=E5=8F=B3=E3=81=AB?= =?utf8?q?=E3=82=AB=E3=83=BC=E3=82=BD=E3=83=AB=E3=81=8C(=E8=A1=A8=E7=A4=BA?= =?utf8?q?=E4=B8=8A=E3=81=A7)=E4=BD=8D=E7=BD=AE=E3=81=99=E3=82=8B=E6=99=82?= =?utf8?q?=E3=81=AB=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88=E9=81=B8=E6=8A=9E?= =?utf8?q?=E3=82=92=E5=A7=8B=E3=82=81=E3=82=8B=E3=81=A8=E8=A1=A8=E7=A4=BA?= =?utf8?q?=E3=81=8C=E3=83=90=E3=82=B0=E3=82=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/autopick.c | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/autopick.c b/src/autopick.c index 36caa5f9e..c6468d12c 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -2928,8 +2928,8 @@ static bool search_for_string(cptr *lines_list, cptr search_str, int *cxp, int * #define MN_BOTTOM "ºÇ²¼¹Ô¤Ø°ÜÆ°" #define MN_EDIT "ÊÔ½¸" -#define MN_CUT "ÁªÂòÈϰϤò¥«¥Ã¥È" -#define MN_COPY "ÁªÂòÈϰϤò¥³¥Ô¡¼" +#define MN_CUT "¥«¥Ã¥È" +#define MN_COPY "¥³¥Ô¡¼" #define MN_PASTE "¥Ú¡¼¥¹¥È" #define MN_BLOCK "ÁªÂòÈϰϤλØÄê" #define MN_KILL_LINE "¹Ô¤Î»Ä¤ê¤òºï½ü" @@ -3464,8 +3464,11 @@ static void draw_text_editor(text_body_type *tb) if (tb->mark) { + int tmp_cx = tb->cx; + int len = strlen(tb->lines_list[tb->cy]); + /* Correct cursor location */ - int tmp_cx = MIN(tb->cx, (int)strlen(tb->lines_list[tb->cy])); + if (tb->cx > len) tmp_cx = len; tb->dirty_flags |= DIRTY_ALL; @@ -3665,7 +3668,7 @@ static void kill_line_segment(text_body_type *tb, int y, int x0, int x1) if (x0 == x1) return; /* Kill whole line? */ - if (x0 == 0 && s[x1] == '\0') + if (x0 == 0 && s[x1] == '\0' && tb->lines_list[y+1]) { int i; @@ -3703,9 +3706,10 @@ static bool kill_text_in_selection(text_body_type *tb) int by1, bx1, by2, bx2; int y; + int len = strlen(tb->lines_list[tb->cy]); + /* Correct cursor location */ - if ((uint)tb->cx > strlen(tb->lines_list[tb->cy])) - tb->cx = (int)strlen(tb->lines_list[tb->cy]); + if (tb->cx > len) tb->cx = len; if (tb->my < tb->cy || (tb->my == tb->cy && tb->mx < tb->cx)) @@ -4030,29 +4034,29 @@ static bool do_editor_command(text_body_type *tb, int com_id) { int by1, bx1, by2, bx2; int y; + int len = strlen(tb->lines_list[tb->cy]); + + /* Correct cursor location */ + if (tb->cx > len) tb->cx = len; /* Use single line? */ if (!tb->mark) { tb->my = tb->cy; tb->mx = 0; - if (!tb->lines_list[tb->cy]) - { - /* Select bottom line */ - tb->cx = strlen(tb->lines_list[tb->cy]); - } - else + if (tb->lines_list[tb->cy + 1]) { /* Select a single line */ tb->cx = 0; tb->cy++; } + else + { + /* Select bottom line */ + tb->cx = len; + } } - /* Correct cursor location */ - if ((uint)tb->cx > strlen(tb->lines_list[tb->cy])) - tb->cx = (int)strlen(tb->lines_list[tb->cy]); - if (tb->my < tb->cy || (tb->my == tb->cy && tb->mx < tb->cx)) { @@ -4106,13 +4110,13 @@ static bool do_editor_command(text_body_type *tb, int com_id) /* Paste killed text */ chain_str_type *chain = tb->yank; + int len = strlen(tb->lines_list[tb->cy]); /* Nothing to do? */ if (!chain) break; /* Correct cursor location */ - if ((uint)tb->cx > strlen(tb->lines_list[tb->cy])) - tb->cx = (int)strlen(tb->lines_list[tb->cy]); + if (tb->cx > len) tb->cx = len; /* * If there is a selection, kill text, and @@ -4219,9 +4223,14 @@ static bool do_editor_command(text_body_type *tb, int com_id) } else { + int len = strlen(tb->lines_list[tb->cy]); + /* Mark the point 1 */ tb->my = tb->cy; tb->mx = tb->cx; + + /* Correct cursor location */ + if (tb->cx > len) tb->mx = len; } } break; @@ -4870,9 +4879,14 @@ void do_cmd_edit_autopick(void) /* Start selection */ if (!tb->mark) { + int len = strlen(tb->lines_list[tb->cy]); + tb->mark = MARK_MARK | MARK_BY_SHIFT; tb->my = tb->cy; tb->mx = tb->cx; + + /* Correct cursor location */ + if (tb->cx > len) tb->mx = len; /* Need to redraw text */ if (com_id == EC_UP || com_id == EC_DOWN) -- 2.11.0