diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-03-06 23:38:09 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-03-06 23:38:09 +0000 |
commit | bc7aa85d8a1c3e5c74b68225702bd5b83b4a8f56 (patch) | |
tree | 993a2daa7cf60fa89f354763694f96f2ece63859 /src | |
parent | 19a09a189379659b917cf5ccff78f3e5ec061015 (diff) |
updated for version 7.0056
Diffstat (limited to 'src')
-rw-r--r-- | src/edit.c | 32 | ||||
-rw-r--r-- | src/ex_getln.c | 43 | ||||
-rw-r--r-- | src/getchar.c | 6 | ||||
-rw-r--r-- | src/globals.h | 2 | ||||
-rw-r--r-- | src/keymap.h | 10 | ||||
-rw-r--r-- | src/message.c | 2 | ||||
-rw-r--r-- | src/misc2.c | 50 | ||||
-rw-r--r-- | src/normal.c | 75 | ||||
-rw-r--r-- | src/os_mswin.c | 2 | ||||
-rw-r--r-- | src/os_unix.c | 25 | ||||
-rw-r--r-- | src/quickfix.c | 4 | ||||
-rw-r--r-- | src/regexp.c | 1296 | ||||
-rw-r--r-- | src/term.c | 238 | ||||
-rw-r--r-- | src/testdir/test24.in | bin | 975 -> 1156 bytes | |||
-rw-r--r-- | src/testdir/test24.ok | 5 | ||||
-rw-r--r-- | src/version.h | 4 | ||||
-rw-r--r-- | src/window.c | 4 |
17 files changed, 1175 insertions, 623 deletions
diff --git a/src/edit.c b/src/edit.c index ae00c2aba8..3a3e865969 100644 --- a/src/edit.c +++ b/src/edit.c @@ -710,9 +710,11 @@ edit(cmdchar, startln, count) switch (c) { case K_LEFT: c = K_RIGHT; break; + case K_XLEFT: c = K_XRIGHT; break; case K_S_LEFT: c = K_S_RIGHT; break; case K_C_LEFT: c = K_C_RIGHT; break; case K_RIGHT: c = K_LEFT; break; + case K_XRIGHT: c = K_XLEFT; break; case K_S_RIGHT: c = K_S_LEFT; break; case K_C_RIGHT: c = K_C_LEFT; break; } @@ -1105,7 +1107,11 @@ doESCkey: break; case K_LEFT: - ins_left(); + case K_XLEFT: + if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) + ins_s_left(); + else + ins_left(); break; case K_S_LEFT: @@ -1114,7 +1120,11 @@ doESCkey: break; case K_RIGHT: - ins_right(); + case K_XRIGHT: + if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) + ins_s_right(); + else + ins_right(); break; case K_S_RIGHT: @@ -1123,7 +1133,11 @@ doESCkey: break; case K_UP: - ins_up(FALSE); + case K_XUP: + if (mod_mask & MOD_MASK_SHIFT) + ins_pageup(); + else + ins_up(FALSE); break; case K_S_UP: @@ -1133,7 +1147,11 @@ doESCkey: break; case K_DOWN: - ins_down(FALSE); + case K_XDOWN: + if (mod_mask & MOD_MASK_SHIFT) + ins_pagedown(); + else + ins_down(FALSE); break; case K_S_DOWN: @@ -6193,12 +6211,14 @@ ins_ctrl_g() { /* CTRL-G k and CTRL-G <Up>: cursor up to Insstart.col */ case K_UP: + case K_XUP: case Ctrl_K: case 'k': ins_up(TRUE); break; /* CTRL-G j and CTRL-G <Down>: cursor down to Insstart.col */ case K_DOWN: + case K_XDOWN: case Ctrl_J: case 'j': ins_down(TRUE); break; @@ -6428,6 +6448,10 @@ ins_start_select(c) case K_KPAGEUP: case K_PAGEDOWN: case K_KPAGEDOWN: + case K_XLEFT: + case K_XRIGHT: + case K_XUP: + case K_XDOWN: # ifdef MACOS case K_LEFT: case K_RIGHT: diff --git a/src/ex_getln.c b/src/ex_getln.c index 4c9d17d78f..4c6175b6fb 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -320,9 +320,11 @@ getcmdline(firstc, count, indent) switch (c) { case K_RIGHT: c = K_LEFT; break; + case K_XRIGHT: c = K_XLEFT; break; case K_S_RIGHT: c = K_S_LEFT; break; case K_C_RIGHT: c = K_C_LEFT; break; case K_LEFT: c = K_RIGHT; break; + case K_XLEFT: c = K_XRIGHT; break; case K_S_LEFT: c = K_S_RIGHT; break; case K_C_LEFT: c = K_C_RIGHT; break; } @@ -354,10 +356,11 @@ getcmdline(firstc, count, indent) /* free old command line when finished moving around in the history * list */ if (lookfor != NULL - && c != K_S_DOWN && c != K_S_UP && c != K_DOWN && c != K_UP + && c != K_S_DOWN && c != K_S_UP + && c != K_DOWN && c != K_UP && c != K_XDOWN && c != K_XUP && c != K_PAGEDOWN && c != K_PAGEUP && c != K_KPAGEDOWN && c != K_KPAGEUP - && c != K_LEFT && c != K_RIGHT + && c != K_LEFT && c != K_RIGHT && c != K_XLEFT && c != K_XRIGHT && (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N))) { vim_free(lookfor); @@ -375,9 +378,9 @@ getcmdline(firstc, count, indent) /* Special translations for 'wildmenu' */ if (did_wild_list && p_wmnu) { - if (c == K_LEFT) + if (c == K_LEFT || c == K_XLEFT) c = Ctrl_P; - else if (c == K_RIGHT) + else if (c == K_RIGHT || c == K_XRIGHT) c = Ctrl_N; } /* Hitting CR after "emenu Name.": complete submenu */ @@ -398,7 +401,8 @@ getcmdline(firstc, count, indent) (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE); did_wild_list = FALSE; #ifdef FEAT_WILDMENU - if (!p_wmnu || (c != K_UP && c != K_DOWN)) + if (!p_wmnu || (c != K_UP && c != K_DOWN + && c != K_XUP && c != K_XDOWN)) #endif xpc.xp_context = EXPAND_NOTHING; wim_index = 0; @@ -443,9 +447,10 @@ getcmdline(firstc, count, indent) if (xpc.xp_context == EXPAND_MENUNAMES && p_wmnu) { /* Hitting <Down> after "emenu Name.": complete submenu */ - if (ccline.cmdbuff[ccline.cmdpos - 1] == '.' && c == K_DOWN) + if (ccline.cmdbuff[ccline.cmdpos - 1] == '.' + && (c == K_DOWN || c == K_XDOWN)) c = p_wc; - else if (c == K_UP) + else if (c == K_UP || c == K_XUP) { /* Hitting <Up>: Remove one submenu name in front of the * cursor */ @@ -492,14 +497,15 @@ getcmdline(firstc, count, indent) upseg[4] = NUL; if (ccline.cmdbuff[ccline.cmdpos - 1] == PATHSEP - && c == K_DOWN + && (c == K_DOWN || c == K_XDOWN) && (ccline.cmdbuff[ccline.cmdpos - 2] != '.' || ccline.cmdbuff[ccline.cmdpos - 3] != '.')) { /* go down a directory */ c = p_wc; } - else if (STRNCMP(xpc.xp_pattern, upseg + 1, 3) == 0 && c == K_DOWN) + else if (STRNCMP(xpc.xp_pattern, upseg + 1, 3) == 0 + && (c == K_DOWN || c == K_XDOWN)) { /* If in a direct ancestor, strip off one ../ to go down */ int found = FALSE; @@ -527,7 +533,7 @@ getcmdline(firstc, count, indent) c = p_wc; } } - else if (c == K_UP) + else if (c == K_UP || c == K_XUP) { /* go up a directory */ int found = FALSE; @@ -1096,6 +1102,7 @@ getcmdline(firstc, count, indent) continue; /* don't do incremental search now */ case K_RIGHT: + case K_XRIGHT: case K_S_RIGHT: case K_C_RIGHT: do @@ -1114,7 +1121,8 @@ getcmdline(firstc, count, indent) #endif ++ccline.cmdpos; } - while ((c == K_S_RIGHT || c == K_C_RIGHT) + while ((c == K_S_RIGHT || c == K_C_RIGHT + || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) && ccline.cmdbuff[ccline.cmdpos] != ' '); #ifdef FEAT_MBYTE if (has_mbyte) @@ -1123,6 +1131,7 @@ getcmdline(firstc, count, indent) goto cmdline_not_changed; case K_LEFT: + case K_XLEFT: case K_S_LEFT: case K_C_LEFT: do @@ -1137,7 +1146,8 @@ getcmdline(firstc, count, indent) #endif ccline.cmdspos -= cmdline_charsize(ccline.cmdpos); } - while ((c == K_S_LEFT || c == K_C_LEFT) + while ((c == K_S_LEFT || c == K_C_LEFT + || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) && ccline.cmdbuff[ccline.cmdpos - 1] != ' '); #ifdef FEAT_MBYTE if (has_mbyte) @@ -1320,7 +1330,9 @@ getcmdline(firstc, count, indent) #ifdef FEAT_CMDHIST case K_UP: + case K_XUP: case K_DOWN: + case K_XDOWN: case K_S_UP: case K_S_DOWN: case K_PAGEUP: @@ -1344,8 +1356,8 @@ getcmdline(firstc, count, indent) for (;;) { /* one step backwards */ - if (c == K_UP || c == K_S_UP || c == Ctrl_P || - c == K_PAGEUP || c == K_KPAGEUP) + if (c == K_UP || c == K_XUP || c == K_S_UP || c == Ctrl_P + || c == K_PAGEUP || c == K_KPAGEUP) { if (hiscnt == hislen) /* first time */ hiscnt = hisidx[histype]; @@ -1381,7 +1393,8 @@ getcmdline(firstc, count, indent) hiscnt = i; break; } - if ((c != K_UP && c != K_DOWN) || hiscnt == i + if ((c != K_UP && c != K_DOWN && c != K_XUP && c != K_XDOWN) + || hiscnt == i || STRNCMP(history[histype][hiscnt].hisstr, lookfor, (size_t)j) == 0) break; diff --git a/src/getchar.c b/src/getchar.c index e93ce05290..c06b600768 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -4530,6 +4530,7 @@ check_map(keys, mode, exact) } #endif +#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) /* * Default mappings for some often used keys. */ @@ -4609,6 +4610,7 @@ static struct initmap {(char_u *)"<Backspace> \"-d", VISUAL}, #endif +#if 0 /* Map extra keys to their normal equivalents. */ {(char_u *)"<xF1> <F1>", NORMAL+VISUAL+OP_PENDING}, {(char_u *)"<xF1> <F1>", INSERT+CMDLINE}, @@ -4630,7 +4632,9 @@ static struct initmap {(char_u *)"<xEND> <END>", INSERT+CMDLINE}, {(char_u *)"<xHOME> <HOME>", NORMAL+VISUAL+OP_PENDING}, {(char_u *)"<xHOME> <HOME>", INSERT+CMDLINE}, +#endif }; +#endif /* * Set up default mappings. @@ -4638,10 +4642,12 @@ static struct initmap void init_mappings() { +#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) int i; for (i = 0; i < sizeof(initmappings) / sizeof(struct initmap); ++i) add_map(initmappings[i].arg, initmappings[i].mode); +#endif } /* diff --git a/src/globals.h b/src/globals.h index 445b453fc5..8251f18312 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1412,9 +1412,11 @@ EXTERN char_u e_nbreadonly[] INIT(=N_("E744: NetBeans does not allow changes in #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) || defined(PROTO) EXTERN char_u e_intern2[] INIT(=N_("E685: Internal error: %s")); #endif +#if 0 #if defined(HAVE_SETJMP_H) || defined(HAVE_TRY_EXCEPT) || defined(__MINGW32__) EXTERN char_u e_complex[] INIT(=N_("E361: Crash intercepted; regexp too complex?")); #endif +#endif EXTERN char_u e_outofstack[] INIT(=N_("E363: pattern caused out-of-stack error")); EXTERN char_u e_emptybuf[] INIT(=N_("E749: empty buffer")); diff --git a/src/keymap.h b/src/keymap.h index 5babdf4af8..e0e46b7732 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -207,6 +207,10 @@ enum key_extra , KE_XF4 , KE_XEND /* extra (vt100) end key for xterm */ , KE_XHOME /* extra (vt100) home key for xterm */ + , KE_XUP /* extra vt100 cursor keys for xterm */ + , KE_XDOWN + , KE_XLEFT + , KE_XRIGHT , KE_LEFTMOUSE_NM /* non-mappable Left mouse button click */ , KE_LEFTRELEASE_NM /* non-mappable left mouse button release */ @@ -270,6 +274,12 @@ enum key_extra #define K_XF3 TERMCAP2KEY(KS_EXTRA, KE_XF3) #define K_XF4 TERMCAP2KEY(KS_EXTRA, KE_XF4) +/* extra set of cursor keys for vt100 compatible xterm */ +#define K_XUP TERMCAP2KEY(KS_EXTRA, KE_XUP) +#define K_XDOWN TERMCAP2KEY(KS_EXTRA, KE_XDOWN) +#define K_XLEFT TERMCAP2KEY(KS_EXTRA, KE_XLEFT) +#define K_XRIGHT TERMCAP2KEY(KS_EXTRA, KE_XRIGHT) + #define K_F1 TERMCAP2KEY('k', '1') /* function keys */ #define K_F2 TERMCAP2KEY('k', '2') #define K_F3 TERMCAP2KEY('k', '3') diff --git a/src/message.c b/src/message.c index f6494847f5..9b0045d14e 100644 --- a/src/message.c +++ b/src/message.c @@ -1953,6 +1953,7 @@ msg_puts_attr_len(str, maxlen, attr) case BS: case 'k': case K_UP: + case K_XUP: if (!more_back_used) { msg_moremsg(TRUE); @@ -1965,6 +1966,7 @@ msg_puts_attr_len(str, maxlen, attr) case NL: case 'j': case K_DOWN: + case K_XDOWN: lines_left = 1; break; case ':': /* start new command line */ diff --git a/src/misc2.c b/src/misc2.c index 9b21168d84..d4d975dda8 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -1784,6 +1784,10 @@ static struct key_name_entry {K_DOWN, (char_u *)"Down"}, {K_LEFT, (char_u *)"Left"}, {K_RIGHT, (char_u *)"Right"}, + {K_XUP, (char_u *)"xUp"}, + {K_XDOWN, (char_u *)"xDown"}, + {K_XLEFT, (char_u *)"xLeft"}, + {K_XRIGHT, (char_u *)"xRight"}, {K_F1, (char_u *)"F1"}, {K_F2, (char_u *)"F2"}, @@ -1957,20 +1961,6 @@ name_to_mod_mask(c) return 0; } -#if 0 /* not used */ -/* - * Decide whether the given key code (K_*) is a shifted special - * key (by looking at mod_mask). If it is, then return the appropriate shifted - * key code, otherwise just return the character as is. - */ - int -check_shifted_spec_key(c) - int c; -{ - return simplify_key(c, &mod_mask); -} -#endif - /* * Check if if there is a special key code for "key" that includes the * modifiers specified. @@ -2008,6 +1998,35 @@ simplify_key(key, modifiers) } /* + * Change <xHome> to <Home>, <xUp> to <Up>, etc. + * "kp" must point to an array that holds the two characters that represent a + * special key. + */ + int +handle_x_keys(key) + int key; +{ + switch (key) + { + case K_XUP: return K_UP; + case K_XDOWN: return K_DOWN; + case K_XLEFT: return K_LEFT; + case K_XRIGHT: return K_RIGHT; + case K_XHOME: return K_HOME; + case K_XEND: return K_END; + case K_XF1: return K_F1; + case K_XF2: return K_F2; + case K_XF3: return K_F3; + case K_XF4: return K_F4; + case K_S_XF1: return K_S_F1; + case K_S_XF2: return K_S_F2; + case K_S_XF3: return K_S_F3; + case K_S_XF4: return K_S_F4; + } + return key; +} + +/* * Return a string which contains the name of the given key when the given * modifiers are down. */ @@ -2246,7 +2265,10 @@ find_special_key(srcp, modp, keycode) if (modifiers != 0 && last_dash[2] == '>') key = last_dash[1]; else + { key = get_special_key_code(last_dash + 1); + key = handle_x_keys(key); + } /* * get_special_key_code() may return NUL for invalid diff --git a/src/normal.c b/src/normal.c index 9bf2e66b7c..df914b5f39 100644 --- a/src/normal.c +++ b/src/normal.c @@ -381,13 +381,17 @@ static const struct nv_cmd {K_KINS, nv_edit, 0, 0}, {K_BS, nv_ctrlh, 0, 0}, {K_UP, nv_up, NV_SSS|NV_STS, FALSE}, + {K_XUP, nv_up, NV_SSS|NV_STS, FALSE}, {K_S_UP, nv_page, NV_SS, BACKWARD}, {K_DOWN, nv_down, NV_SSS|NV_STS, FALSE}, + {K_XDOWN, nv_down, NV_SSS|NV_STS, FALSE}, {K_S_DOWN, nv_page, NV_SS, FORWARD}, {K_LEFT, nv_left, NV_SSS|NV_STS|NV_RL, 0}, + {K_XLEFT, nv_left, NV_SSS|NV_STS|NV_RL, 0}, {K_S_LEFT, nv_bck_word, NV_SS|NV_RL, 0}, {K_C_LEFT, nv_bck_word, NV_SSS|NV_RL|NV_STS, 1}, {K_RIGHT, nv_right, NV_SSS|NV_STS|NV_RL, 0}, + {K_XRIGHT, nv_right, NV_SSS|NV_STS|NV_RL, 0}, {K_S_RIGHT, nv_wordcmd, NV_SS|NV_RL, FALSE}, {K_C_RIGHT, nv_wordcmd, NV_SSS|NV_RL|NV_STS, TRUE}, {K_PAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD}, @@ -832,10 +836,12 @@ getcount: { case 'l': ca.cmdchar = 'h'; break; case K_RIGHT: ca.cmdchar = K_LEFT; break; + case K_XRIGHT: ca.cmdchar = K_XLEFT; break; case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break; case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break; case 'h': ca.cmdchar = 'l'; break; case K_LEFT: ca.cmdchar = K_RIGHT; break; + case K_XLEFT: ca.cmdchar = K_XRIGHT; break; case K_S_LEFT: ca.cmdchar = K_S_RIGHT; break; case K_C_LEFT: ca.cmdchar = K_C_RIGHT; break; case '>': ca.cmdchar = '<'; break; @@ -4316,7 +4322,9 @@ nv_zet(cap) else if (nchar == 'l' || nchar == 'h' || nchar == K_LEFT - || nchar == K_RIGHT) + || nchar == K_XLEFT + || nchar == K_RIGHT + || nchar == K_XRIGHT) { cap->count1 = n ? n * cap->count1 : cap->count1; goto dozet; @@ -4423,6 +4431,7 @@ dozet: /* "zh" - scroll screen to the right */ case 'h': case K_LEFT: + case K_XLEFT: if (!curwin->w_p_wrap) { if ((colnr_T)cap->count1 > curwin->w_leftcol) @@ -4440,6 +4449,7 @@ dozet: /* "zl" - scroll screen to the left */ case 'l': case K_RIGHT: + case K_XRIGHT: if (!curwin->w_p_wrap) { /* scroll the window left */ @@ -5294,6 +5304,15 @@ nv_right(cap) # define PAST_LINE 0 #endif + if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) + { + /* <C-Right> and <S-Right> move a word or WORD right */ + if (mod_mask & MOD_MASK_CTRL) + cap->arg = TRUE; + nv_wordcmd(cap); + return; + } + cap->oap->motion_type = MCHAR; cap->oap->inclusive = FALSE; #ifdef FEAT_VISUAL @@ -5323,7 +5342,7 @@ nv_right(cap) && vim_strchr(p_ww, 's') != NULL) || (cap->cmdchar == 'l' && vim_strchr(p_ww, 'l') != NULL) - || (cap->cmdchar == K_RIGHT + || ((cap->cmdchar == K_RIGHT || cap->cmdchar == K_XRIGHT) && vim_strchr(p_ww, '>') != NULL)) && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { @@ -5399,6 +5418,15 @@ nv_left(cap) { long n; + if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) + { + /* <C-Left> and <S-Left> move a word or WORD left */ + if (mod_mask & MOD_MASK_CTRL) + cap->arg = 1; + nv_bck_word(cap); + return; + } + cap->oap->motion_type = MCHAR; cap->oap->inclusive = FALSE; for (n = cap->count1; n > 0; --n) @@ -5414,7 +5442,7 @@ nv_left(cap) && vim_strchr(p_ww, 'b') != NULL) || (cap->cmdchar == 'h' && vim_strchr(p_ww, 'h') != NULL) - || (cap->cmdchar == K_LEFT + || ((cap->cmdchar == K_LEFT || cap->cmdchar == K_XLEFT) && vim_strchr(p_ww, '<') != NULL)) && curwin->w_cursor.lnum > 1) { @@ -5456,11 +5484,20 @@ nv_left(cap) nv_up(cap) cmdarg_T *cap; { - cap->oap->motion_type = MLINE; - if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) - clearopbeep(cap->oap); - else if (cap->arg) - beginline(BL_WHITE | BL_FIX); + if (mod_mask & MOD_MASK_SHIFT) + { + /* <S-Up> is page up */ + cap->arg = BACKWARD; + nv_page(cap); + } + else + { + cap->oap->motion_type = MLINE; + if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) + clearopbeep(cap->oap); + else if (cap->arg) + beginline(BL_WHITE | BL_FIX); + } } /* @@ -5471,6 +5508,13 @@ nv_up(cap) nv_down(cap) cmdarg_T *cap; { + if (mod_mask & MOD_MASK_SHIFT) + { + /* <S-Down> is page down */ + cap->arg = FORWARD; + nv_page(cap); + } + else #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) /* In a quickfix window a <CR> jumps to the error under the cursor. */ if (bt_quickfix(curbuf) && cap->cmdchar == CAR) @@ -5553,8 +5597,9 @@ nv_gotofile(cap) nv_end(cap) cmdarg_T *cap; { - if (cap->arg) /* CTRL-END = goto last line */ + if (cap->arg || (mod_mask & MOD_MASK_CTRL)) /* CTRL-END = goto last line */ { + cap->arg = TRUE; nv_goto(cap); cap->count1 = 1; /* to end of current line */ } @@ -7205,6 +7250,7 @@ nv_g_cmd(cap) */ case 'j': case K_DOWN: + case K_XDOWN: /* with 'nowrap' it works just like the normal "j" command; also when * in a closed fold */ if (!curwin->w_p_wrap @@ -7224,6 +7270,7 @@ nv_g_cmd(cap) case 'k': case K_UP: + case K_XUP: /* with 'nowrap' it works just like the normal "k" command; also when * in a closed fold */ if (!curwin->w_p_wrap @@ -7761,8 +7808,14 @@ nv_lineop(cap) nv_home(cap) cmdarg_T *cap; { - cap->count0 = 1; - nv_pipe(cap); + /* CTRL-HOME is like "gg" */ + if (mod_mask & MOD_MASK_CTRL) + nv_goto(cap); + else + { + cap->count0 = 1; + nv_pipe(cap); + } } /* diff --git a/src/os_mswin.c b/src/os_mswin.c index 5e96da8afe..a5e10be498 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -2564,9 +2564,11 @@ Messaging_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) switch (data->dwData) { case COPYDATA_ENCODING: +# ifdef FEAT_MBYTE /* Remember the encoding that the client uses. */ vim_free(client_enc); client_enc = enc_canonize((char_u *)data->lpData); +# endif return 1; case COPYDATA_KEYS: diff --git a/src/os_unix.c b/src/os_unix.c index c64a39e027..5df0d35f23 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -610,7 +610,13 @@ mch_delay(msec, ignoreinput) WaitForChar(msec); } -#if defined(HAVE_GETRLIMIT) \ +#if 0 /* disabled, no longer needed now that regmatch() is not recursive */ +# if defined(HAVE_GETRLIMIT) +# define HAVE_STACK_LIMIT +# endif +#endif + +#if defined(HAVE_STACK_LIMIT) \ || (!defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGSTACK)) # define HAVE_CHECK_STACK_GROWTH /* @@ -638,7 +644,7 @@ check_stack_growth(p) } #endif -#if defined(HAVE_GETRLIMIT) || defined(PROTO) +#if defined(HAVE_STACK_LIMIT) || defined(PROTO) static char *stack_limit = NULL; #if defined(_THREAD_SAFE) && defined(HAVE_PTHREAD_NP_H) @@ -951,7 +957,7 @@ deathtrap SIGDEFARG(sigarg) set_vim_var_nr(VV_DYING, (long)entered); #endif -#ifdef HAVE_GETRLIMIT +#ifdef HAVE_STACK_LIMIT /* Since we are now using the signal stack, need to reset the stack * limit. Otherwise using a regexp will fail. */ get_stack_limit(); @@ -2683,12 +2689,10 @@ mch_early_init() { #ifdef HAVE_CHECK_STACK_GROWTH int i; -#endif -#ifdef HAVE_CHECK_STACK_GROWTH check_stack_growth((char *)&i); -# ifdef HAVE_GETRLIMIT +# ifdef HAVE_STACK_LIMIT get_stack_limit(); # endif @@ -3092,7 +3096,8 @@ check_mouse_termcode() ) { set_mouse_termcode(KS_MOUSE, (char_u *)(term_is_8bit(T_NAME) - ? IF_EB("\233M", CSI_STR "M") : IF_EB("\033[M", ESC_STR "[M"))); + ? IF_EB("\233M", CSI_STR "M") + : IF_EB("\033[M", ESC_STR "[M"))); if (*p_mouse != NUL) { /* force mouse off and maybe on to send possibly new mouse @@ -3128,7 +3133,7 @@ check_mouse_termcode() # endif # ifdef FEAT_MOUSE_NET - /* There is no conflict, but one may type ESC } from Insert mode. Don't + /* There is no conflict, but one may type "ESC }" from Insert mode. Don't * define it in the GUI or when using an xterm. */ if (!use_xterm_mouse() # ifdef FEAT_GUI @@ -3148,8 +3153,8 @@ check_mouse_termcode() && !gui.in_use # endif ) - set_mouse_termcode(KS_DEC_MOUSE, - (char_u *)IF_EB("\033[", ESC_STR "[")); + set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME) + ? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "["))); else del_mouse_termcode(KS_DEC_MOUSE); # endif diff --git a/src/quickfix.c b/src/quickfix.c index 8d76e28613..d9ce186cf8 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -2418,6 +2418,7 @@ ex_vimgrep(eap) else { found_match = FALSE; +#if 0 #ifdef HAVE_SETJMP_H /* * Matching with a regexp may cause a very deep recursive call of @@ -2437,6 +2438,7 @@ ex_vimgrep(eap) goto jumpend; } #endif +#endif /* Try for a match in all lines of the buffer. */ for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum) { @@ -2475,10 +2477,12 @@ ex_vimgrep(eap) if (got_int) break; } +#if 0 #ifdef HAVE_SETJMP_H jumpend: mch_endjmp(); #endif +#endif if (using_dummy) { diff --git a/src/regexp.c b/src/regexp.c index 36f5bb4566..79d3e2a573 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -2962,8 +2962,6 @@ static int need_clear_zsubexpr = FALSE; /* extmatch subexpressions * still need to be cleared */ #endif -static int out_of_stack; /* TRUE when ran out of stack space */ - /* * Structure used to save the current input state, when it needs to be * restored after trying a match. Used by reg_save() and reg_restore(). @@ -3013,7 +3011,7 @@ static void save_se_one __ARGS((save_se_T *savep, char_u **pp)); *(pp) = (savep)->se_u.ptr; } static int re_num_cmp __ARGS((long_u val, char_u *scan)); -static int regmatch __ARGS((char_u *prog, regsave_T *startp)); +static int regmatch __ARGS((char_u *prog)); static int regrepeat __ARGS((char_u *p, long maxcount)); #ifdef DEBUG @@ -3186,41 +3184,20 @@ vim_regexec_multi(rmp, win, buf, lnum, col) return r; } -#if 0 /* this does not appear to work... */ -# ifdef __MINGW32__ -# define MINGW_TRY +#if 0 /* disabled, no longer needed now that regmatch() is not recursive */ +# ifdef HAVE_SETJMP_H +# define USE_SETJMP +# endif +# ifdef HAVE_TRY_EXCEPT +# define USE_TRY_EXCEPT # endif -#endif - -#ifdef MINGW_TRY -/* - * Special assembly code for MingW to simulate __try / __except. - * Does not work with the optimizer! - */ -# include <excpt.h> - -static void *ESP_save; /* used as _ESP below */ -static void *EBP_save; /* used as _EBP below */ - -__attribute__ ((cdecl)) - EXCEPTION_DISPOSITION - _except_regexec_handler( - struct _EXCEPTION_RECORD *ExceptionRecord, - void *EstablisherFrame, - struct _CONTEXT *ContextRecord, - void *DispatcherContext) -{ - __asm__ __volatile__ ( - "jmp regexec_reentry"); - return 0; /* Function does not return */ -} #endif /* * Match a regexp against a string ("line" points to the string) or multiple * lines ("line" is NULL, use reg_getline()). */ -#ifdef HAVE_SETJMP_H +#ifdef USE_SETJMP static long vim_regexec_both(line_arg, col_arg) char_u *line_arg; @@ -3235,7 +3212,7 @@ vim_regexec_both(line, col) regprog_T *prog; char_u *s; long retval; -#ifdef HAVE_SETJMP_H +#ifdef USE_SETJMP char_u *line; colnr_T col; int did_mch_startjmp = FALSE; @@ -3243,7 +3220,7 @@ vim_regexec_both(line, col) reg_tofree = NULL; -#ifdef HAVE_SETJMP_H +#ifdef USE_SETJMP /* Trick to avoid "might be clobbered by `longjmp'" warning from gcc. */ line = line_arg; col = col_arg; @@ -3335,23 +3312,12 @@ vim_regexec_both(line, col) goto theend; } -#ifdef MINGW_TRY - /* Ugly assembly code that is necessary to simulate "__try". */ - __asm__ __volatile__ ( - "movl %esp, _ESP_save" "\n\t" - "movl %ebp, _EBP_save"); - - __asm__ __volatile__ ( - "pushl $__except_regexec_handler" "\n\t" - "pushl %fs:0" "\n\t" - "mov %esp, %fs:0"); -#endif -#ifdef HAVE_TRY_EXCEPT +#ifdef USE_TRY_EXCEPT __try { #endif -#ifdef HAVE_SETJMP_H +#ifdef USE_SETJMP /* * Matching with a regexp may cause a very deep recursive call of * regmatch(). Vim will crash when running out of stack space. Catch @@ -3378,7 +3344,6 @@ vim_regexec_both(line, col) regline = line; reglnum = 0; - out_of_stack = FALSE; /* Simplest case: Anchored match need be tried only once. */ if (prog->reganch) @@ -3406,7 +3371,7 @@ vim_regexec_both(line, col) else { /* Messy cases: unanchored match. */ - while (!got_int && !out_of_stack) + while (!got_int) { if (prog->regstart != NUL) { @@ -3449,15 +3414,12 @@ vim_regexec_both(line, col) } } - if (out_of_stack) - EMSG(_(e_outofstack)); - -#ifdef HAVE_SETJMP_H +#ifdef USE_SETJMP inner_end: if (did_mch_startjmp) mch_endjmp(); #endif -#ifdef HAVE_TRY_EXCEPT +#ifdef USE_TRY_EXCEPT } __except(EXCEPTION_EXECUTE_HANDLER) { @@ -3471,22 +3433,6 @@ inner_end: retval = 0L; } #endif -#ifdef MINGW_TRY - __asm__ __volatile__ ( - "jmp regexec_pop" "\n" - "regexec_reentry:" "\n\t" - "movl _ESP_save, %esp" "\n\t" - "movl _EBP_save, %ebp"); - - EMSG(_(e_complex)); - retval = 0L; - - __asm__ __volatile__ ( - "regexec_pop:" "\n\t" - "mov (%esp), %eax" "\n\t" - "mov %eax, %fs:0" "\n\t" - "add $8, %esp"); -#endif theend: /* Didn't find a match. */ @@ -3559,7 +3505,7 @@ regtry(prog, col) need_clear_zsubexpr = TRUE; #endif - if (regmatch(prog->program + 1, NULL)) + if (regmatch(prog->program + 1)) { cleanup_subexpr(); if (REG_MULTI) @@ -3649,15 +3595,75 @@ reg_prev_class() static long bl_minval; static long bl_maxval; +/* Values for rs_state. */ +typedef enum regstate_E +{ + RS_NOPEN = 0 /* NOPEN and NCLOSE */ + , RS_MOPEN /* MOPEN + [0-9] */ + , RS_MCLOSE /* MCLOSE + [0-9] */ +#ifdef FEAT_SYN_HL + , RS_ZOPEN /* ZOPEN + [0-9] */ + , RS_ZCLOSE /* ZCLOSE + [0-9] */ +#endif + , RS_BRANCH /* BRANCH */ + , RS_BRCPLX_MORE /* BRACE_COMPLEX and trying one more match */ + , RS_BRCPLX_LONG /* BRACE_COMPLEX and trying longest match */ + , RS_BRCPLX_SHORT /* BRACE_COMPLEX and trying shortest match */ + , RS_NOMATCH /* NOMATCH */ + , RS_BEHIND1 /* BEHIND / NOBEHIND matching rest */ + , RS_BEHIND2 /* BEHIND / NOBEHIND matching behind part */ + , RS_STAR_LONG /* STAR/PLUS/BRACE_SIMPLE longest match */ + , RS_STAR_SHORT /* STAR/PLUS/BRACE_SIMPLE shortest match */ +} regstate_T; + +/* + * When there are alternatives a regstate_T is put on the regstack to remember + * what we are doing. + * Before it may be another type of item, depending on rs_state, to remember + * more things. + */ +typedef struct regitem_S +{ + regstate_T rs_state; /* what we are doing, on of RS_ below */ + char_u *rs_scan; /* current node in program */ + long rs_startp; /* start position for BACK (offset) */ + union + { + save_se_T sesave; + regsave_T regsave; + } rs_un; /* room for saving reginput */ + short rs_no; /* submatch nr */ +} regitem_T; + +static regitem_T *regstack_push __ARGS((garray_T *regstack, regstate_T state, char_u *scan, long startp)); +static void regstack_pop __ARGS((garray_T *regstack, char_u **scan, long *startp)); + +/* used for BEHIND and NOBEHIND matching */ +typedef struct regbehind_S +{ + regsave_T save_after; + regsave_T save_behind; +} regbehind_T; + +/* used |