Mercurial > vim
annotate src/normal.c @ 27991:e8cad604c218
Added tag v8.2.4520 for changeset 27ae8ea82d7ab9e0e4f8f894394dad7fd6344a5a
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 06 Mar 2022 21:00:07 +0100 |
parents | c1d1639b52dd |
children | 7976d709c963 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
27484
ee1019e59bef
patch 8.2.4270: generating nv_cmdidxs.h requires building Vim twice
Bram Moolenaar <Bram@vim.org>
parents:
27447
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar et al. |
7 | 4 * |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 /* | |
10 * normal.c: Contains the main routine for processing characters in command | |
11 * mode. Communicates closely with the code in ops.c to handle | |
12 * the operators. | |
13 */ | |
14 | |
15 #include "vim.h" | |
16 | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
17 static int VIsual_mode_orig = NUL; // saved Visual mode |
7 | 18 |
2667 | 19 #ifdef FEAT_EVAL |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
20 static void set_vcount_ca(cmdarg_T *cap, int *set_prevcount); |
2667 | 21 #endif |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
22 static void unshift_special(cmdarg_T *cap); |
7 | 23 #ifdef FEAT_CMDL_INFO |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
24 static void del_from_showcmd(int); |
7 | 25 #endif |
26 | |
27 /* | |
28 * nv_*(): functions called to handle Normal and Visual mode commands. | |
29 * n_*(): functions called to handle Normal mode commands. | |
30 * v_*(): functions called to handle Visual mode commands. | |
31 */ | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
32 static void nv_ignore(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
33 static void nv_nop(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
34 static void nv_error(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
35 static void nv_help(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
36 static void nv_addsub(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
37 static void nv_page(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
38 static void nv_zet(cmdarg_T *cap); |
7 | 39 #ifdef FEAT_GUI |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
40 static void nv_ver_scrollbar(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
41 static void nv_hor_scrollbar(cmdarg_T *cap); |
7 | 42 #endif |
685 | 43 #ifdef FEAT_GUI_TABLINE |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
44 static void nv_tabline(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
45 static void nv_tabmenu(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
46 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
47 static void nv_exmode(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
48 static void nv_colon(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
49 static void nv_ctrlg(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
50 static void nv_ctrlh(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
51 static void nv_clear(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
52 static void nv_ctrlo(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
53 static void nv_hat(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
54 static void nv_Zet(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
55 static void nv_ident(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
56 static void nv_tagpop(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
57 static void nv_scroll(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
58 static void nv_right(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
59 static void nv_left(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
60 static void nv_up(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
61 static void nv_down(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
62 static void nv_end(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
63 static void nv_dollar(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
64 static void nv_search(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
65 static void nv_next(cmdarg_T *cap); |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
66 static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrapped); |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
67 static void nv_csearch(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
68 static void nv_brackets(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
69 static void nv_percent(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
70 static void nv_brace(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
71 static void nv_mark(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
72 static void nv_findpar(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
73 static void nv_undo(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
74 static void nv_kundo(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
75 static void nv_Replace(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
76 static void nv_replace(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
77 static void nv_cursormark(cmdarg_T *cap, int flag, pos_T *pos); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
78 static void v_visop(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
79 static void nv_subst(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
80 static void nv_abbrev(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
81 static void nv_optrans(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
82 static void nv_gomark(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
83 static void nv_pcmark(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
84 static void nv_regname(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
85 static void nv_visual(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
86 static void n_start_visual_mode(int c); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
87 static void nv_window(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
88 static void nv_suspend(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
89 static void nv_g_cmd(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
90 static void nv_dot(cmdarg_T *cap); |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
91 static void nv_redo_or_register(cmdarg_T *cap); |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
92 static void nv_Undo(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
93 static void nv_tilde(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
94 static void nv_operator(cmdarg_T *cap); |
1490 | 95 #ifdef FEAT_EVAL |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
96 static void set_op_var(int optype); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
97 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
98 static void nv_lineop(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
99 static void nv_home(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
100 static void nv_pipe(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
101 static void nv_bck_word(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
102 static void nv_wordcmd(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
103 static void nv_beginline(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
104 static void adjust_cursor(oparg_T *oap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
105 static void adjust_for_sel(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
106 static void nv_select(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
107 static void nv_goto(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
108 static void nv_normal(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
109 static void nv_esc(cmdarg_T *oap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
110 static void nv_edit(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
111 static void invoke_edit(cmdarg_T *cap, int repl, int cmd, int startln); |
7 | 112 #ifdef FEAT_TEXTOBJ |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
113 static void nv_object(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
114 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
115 static void nv_record(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
116 static void nv_at(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
117 static void nv_halfpage(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
118 static void nv_join(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
119 static void nv_put(cmdarg_T *cap); |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
120 static void nv_put_opt(cmdarg_T *cap, int fix_indent); |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
121 static void nv_open(cmdarg_T *cap); |
7 | 122 #ifdef FEAT_NETBEANS_INTG |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
123 static void nv_nbcmd(cmdarg_T *cap); |
7 | 124 #endif |
125 #ifdef FEAT_DND | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
126 static void nv_drop(cmdarg_T *cap); |
7 | 127 #endif |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
128 static void nv_cursorhold(cmdarg_T *cap); |
7 | 129 |
27484
ee1019e59bef
patch 8.2.4270: generating nv_cmdidxs.h requires building Vim twice
Bram Moolenaar <Bram@vim.org>
parents:
27447
diff
changeset
|
130 // Declare nv_cmds[]. |
ee1019e59bef
patch 8.2.4270: generating nv_cmdidxs.h requires building Vim twice
Bram Moolenaar <Bram@vim.org>
parents:
27447
diff
changeset
|
131 #define DO_DECLARE_NVCMD |
ee1019e59bef
patch 8.2.4270: generating nv_cmdidxs.h requires building Vim twice
Bram Moolenaar <Bram@vim.org>
parents:
27447
diff
changeset
|
132 #include "nv_cmds.h" |
7 | 133 |
27447
4050f0554902
patch 8.2.4252: generating the normal command table at runtime is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
27428
diff
changeset
|
134 // Include the lookuptable generated by create_nvcmdidx.vim. |
4050f0554902
patch 8.2.4252: generating the normal command table at runtime is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
27428
diff
changeset
|
135 #include "nv_cmdidxs.h" |
4050f0554902
patch 8.2.4252: generating the normal command table at runtime is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
27428
diff
changeset
|
136 |
7 | 137 /* |
138 * Search for a command in the commands table. | |
139 * Returns -1 for invalid command. | |
140 */ | |
141 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
142 find_command(int cmdchar) |
7 | 143 { |
144 int i; | |
145 int idx; | |
146 int top, bot; | |
147 int c; | |
148 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
149 // A multi-byte character is never a command. |
7 | 150 if (cmdchar >= 0x100) |
151 return -1; | |
152 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
153 // We use the absolute value of the character. Special keys have a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
154 // negative value, but are sorted on their absolute value. |
7 | 155 if (cmdchar < 0) |
156 cmdchar = -cmdchar; | |
157 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
158 // If the character is in the first part: The character is the index into |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
159 // nv_cmd_idx[]. |
7 | 160 if (cmdchar <= nv_max_linear) |
161 return nv_cmd_idx[cmdchar]; | |
162 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
163 // Perform a binary search. |
7 | 164 bot = nv_max_linear + 1; |
165 top = NV_CMDS_SIZE - 1; | |
166 idx = -1; | |
167 while (bot <= top) | |
168 { | |
169 i = (top + bot) / 2; | |
170 c = nv_cmds[nv_cmd_idx[i]].cmd_char; | |
171 if (c < 0) | |
172 c = -c; | |
173 if (cmdchar == c) | |
174 { | |
175 idx = nv_cmd_idx[i]; | |
176 break; | |
177 } | |
178 if (cmdchar > c) | |
179 bot = i + 1; | |
180 else | |
181 top = i - 1; | |
182 } | |
183 return idx; | |
184 } | |
185 | |
186 /* | |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
187 * Handle the count before a normal command and set cap->count0. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
188 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
189 static int |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
190 normal_cmd_get_count( |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
191 cmdarg_T *cap, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
192 int c, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
193 int toplevel UNUSED, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
194 int set_prevcount UNUSED, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
195 int *ctrl_w, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
196 int *need_flushbuf UNUSED) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
197 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
198 getcount: |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
199 if (!(VIsual_active && VIsual_select)) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
200 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
201 // Handle a count before a command and compute ca.count0. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
202 // Note that '0' is a command and not the start of a count, but it's |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
203 // part of a count after other digits. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
204 while ((c >= '1' && c <= '9') |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
205 || (cap->count0 != 0 && (c == K_DEL || c == K_KDEL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
206 || c == '0'))) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
207 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
208 if (c == K_DEL || c == K_KDEL) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
209 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
210 cap->count0 /= 10; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
211 #ifdef FEAT_CMDL_INFO |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
212 del_from_showcmd(4); // delete the digit and ~@% |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
213 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
214 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
215 else if (cap->count0 > 99999999L) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
216 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
217 cap->count0 = 999999999L; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
218 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
219 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
220 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
221 cap->count0 = cap->count0 * 10 + (c - '0'); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
222 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
223 #ifdef FEAT_EVAL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
224 // Set v:count here, when called from main() and not a stuffed |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
225 // command, so that v:count can be used in an expression mapping |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
226 // right after the count. Do set it for redo. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
227 if (toplevel && readbuf1_empty()) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
228 set_vcount_ca(cap, &set_prevcount); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
229 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
230 if (*ctrl_w) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
231 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
232 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
233 ++allow_keys; // no mapping for nchar, but keys |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
234 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
235 ++no_zero_mapping; // don't map zero here |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
236 c = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
237 LANGMAP_ADJUST(c, TRUE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
238 --no_zero_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
239 if (*ctrl_w) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
240 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
241 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
242 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
243 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
244 #ifdef FEAT_CMDL_INFO |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
245 *need_flushbuf |= add_to_showcmd(c); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
246 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
247 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
248 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
249 // If we got CTRL-W there may be a/another count |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
250 if (c == Ctrl_W && !*ctrl_w && cap->oap->op_type == OP_NOP) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
251 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
252 *ctrl_w = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
253 cap->opcount = cap->count0; // remember first count |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
254 cap->count0 = 0; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
255 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
256 ++allow_keys; // no mapping for nchar, but keys |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
257 c = plain_vgetc(); // get next character |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
258 LANGMAP_ADJUST(c, TRUE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
259 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
260 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
261 #ifdef FEAT_CMDL_INFO |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
262 *need_flushbuf |= add_to_showcmd(c); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
263 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
264 goto getcount; // jump back |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
265 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
266 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
267 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
268 if (c == K_CURSORHOLD) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
269 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
270 // Save the count values so that ca.opcount and ca.count0 are exactly |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
271 // the same when coming back here after handling K_CURSORHOLD. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
272 cap->oap->prev_opcount = cap->opcount; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
273 cap->oap->prev_count0 = cap->count0; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
274 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
275 else if (cap->opcount != 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
276 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
277 // If we're in the middle of an operator (including after entering a |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
278 // yank buffer with '"') AND we had a count before the operator, then |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
279 // that count overrides the current value of ca.count0. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
280 // What this means effectively, is that commands like "3dw" get turned |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
281 // into "d3w" which makes things fall into place pretty neatly. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
282 // If you give a count before AND after the operator, they are |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
283 // multiplied. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
284 if (cap->count0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
285 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
286 if (cap->opcount >= 999999999L / cap->count0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
287 cap->count0 = 999999999L; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
288 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
289 cap->count0 *= cap->opcount; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
290 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
291 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
292 cap->count0 = cap->opcount; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
293 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
294 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
295 // Always remember the count. It will be set to zero (on the next call, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
296 // above) when there is no pending operator. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
297 // When called from main(), save the count for use by the "count" built-in |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
298 // variable. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
299 cap->opcount = cap->count0; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
300 cap->count1 = (cap->count0 == 0 ? 1 : cap->count0); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
301 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
302 #ifdef FEAT_EVAL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
303 // Only set v:count when called from main() and not a stuffed command. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
304 // Do set it for redo. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
305 if (toplevel && readbuf1_empty()) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
306 set_vcount(cap->count0, cap->count1, set_prevcount); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
307 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
308 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
309 return c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
310 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
311 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
312 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
313 * Returns TRUE if the normal command (cap) needs a second character. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
314 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
315 static int |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
316 normal_cmd_needs_more_chars(cmdarg_T *cap, short_u cmd_flags) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
317 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
318 return ((cmd_flags & NV_NCH) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
319 && (((cmd_flags & NV_NCH_NOP) == NV_NCH_NOP |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
320 && cap->oap->op_type == OP_NOP) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
321 || (cmd_flags & NV_NCH_ALW) == NV_NCH_ALW |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
322 || (cap->cmdchar == 'q' |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
323 && cap->oap->op_type == OP_NOP |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
324 && reg_recording == 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
325 && reg_executing == 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
326 || ((cap->cmdchar == 'a' || cap->cmdchar == 'i') |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
327 && (cap->oap->op_type != OP_NOP || VIsual_active)))); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
328 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
329 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
330 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
331 * Get one or more additional characters for a normal command. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
332 * Return the updated command index (if changed). |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
333 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
334 static int |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
335 normal_cmd_get_more_chars( |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
336 int idx_arg, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
337 cmdarg_T *cap, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
338 int *need_flushbuf UNUSED) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
339 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
340 int idx = idx_arg; |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
341 int c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
342 int *cp; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
343 int repl = FALSE; // get character for replace mode |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
344 int lit = FALSE; // get extra character literally |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
345 int langmap_active = FALSE; // using :lmap mappings |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
346 int lang; // getting a text character |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
347 #ifdef HAVE_INPUT_METHOD |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
348 int save_smd; // saved value of p_smd |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
349 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
350 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
351 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
352 ++allow_keys; // no mapping for nchar, but allow key codes |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
353 // Don't generate a CursorHold event here, most commands can't handle |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
354 // it, e.g., nv_replace(), nv_csearch(). |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
355 did_cursorhold = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
356 if (cap->cmdchar == 'g') |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
357 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
358 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
359 * For 'g' get the next character now, so that we can check for |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
360 * "gr", "g'" and "g`". |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
361 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
362 cap->nchar = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
363 LANGMAP_ADJUST(cap->nchar, TRUE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
364 #ifdef FEAT_CMDL_INFO |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
365 *need_flushbuf |= add_to_showcmd(cap->nchar); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
366 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
367 if (cap->nchar == 'r' || cap->nchar == '\'' || cap->nchar == '`' |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
368 || cap->nchar == Ctrl_BSL) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
369 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
370 cp = &cap->extra_char; // need to get a third character |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
371 if (cap->nchar != 'r') |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
372 lit = TRUE; // get it literally |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
373 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
374 repl = TRUE; // get it in replace mode |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
375 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
376 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
377 cp = NULL; // no third character needed |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
378 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
379 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
380 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
381 if (cap->cmdchar == 'r') // get it in replace mode |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
382 repl = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
383 cp = &cap->nchar; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
384 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
385 lang = (repl || (nv_cmds[idx].cmd_flags & NV_LANG)); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
386 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
387 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
388 * Get a second or third character. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
389 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
390 if (cp != NULL) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
391 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
392 if (repl) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
393 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
394 State = REPLACE; // pretend Replace mode |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
395 #ifdef CURSOR_SHAPE |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
396 ui_cursor_shape(); // show different cursor shape |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
397 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
398 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
399 if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
400 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
401 // Allow mappings defined with ":lmap". |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
402 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
403 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
404 if (repl) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
405 State = LREPLACE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
406 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
407 State = LANGMAP; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
408 langmap_active = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
409 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
410 #ifdef HAVE_INPUT_METHOD |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
411 save_smd = p_smd; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
412 p_smd = FALSE; // Don't let the IM code show the mode here |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
413 if (lang && curbuf->b_p_iminsert == B_IMODE_IM) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
414 im_set_active(TRUE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
415 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
416 if ((State & INSERT) && !p_ek) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
417 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
418 #ifdef FEAT_JOB_CHANNEL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
419 ch_log_output = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
420 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
421 // Disable bracketed paste and modifyOtherKeys here, we won't |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
422 // recognize the escape sequences with 'esckeys' off. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
423 out_str(T_BD); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
424 out_str(T_CTE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
425 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
426 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
427 *cp = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
428 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
429 if ((State & INSERT) && !p_ek) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
430 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
431 #ifdef FEAT_JOB_CHANNEL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
432 ch_log_output = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
433 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
434 // Re-enable bracketed paste mode and modifyOtherKeys |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
435 out_str(T_BE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
436 out_str(T_CTI); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
437 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
438 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
439 if (langmap_active) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
440 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
441 // Undo the decrement done above |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
442 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
443 ++allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
444 State = NORMAL_BUSY; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
445 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
446 #ifdef HAVE_INPUT_METHOD |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
447 if (lang) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
448 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
449 if (curbuf->b_p_iminsert != B_IMODE_LMAP) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
450 im_save_status(&curbuf->b_p_iminsert); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
451 im_set_active(FALSE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
452 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
453 p_smd = save_smd; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
454 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
455 State = NORMAL_BUSY; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
456 #ifdef FEAT_CMDL_INFO |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
457 *need_flushbuf |= add_to_showcmd(*cp); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
458 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
459 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
460 if (!lit) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
461 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
462 #ifdef FEAT_DIGRAPHS |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
463 // Typing CTRL-K gets a digraph. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
464 if (*cp == Ctrl_K |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
465 && ((nv_cmds[idx].cmd_flags & NV_LANG) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
466 || cp == &cap->extra_char) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
467 && vim_strchr(p_cpo, CPO_DIGRAPH) == NULL) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
468 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
469 c = get_digraph(FALSE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
470 if (c > 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
471 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
472 *cp = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
473 # ifdef FEAT_CMDL_INFO |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
474 // Guessing how to update showcmd here... |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
475 del_from_showcmd(3); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
476 *need_flushbuf |= add_to_showcmd(*cp); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
477 # endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
478 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
479 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
480 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
481 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
482 // adjust chars > 127, except after "tTfFr" commands |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
483 LANGMAP_ADJUST(*cp, !lang); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
484 #ifdef FEAT_RIGHTLEFT |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
485 // adjust Hebrew mapped char |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
486 if (p_hkmap && lang && KeyTyped) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
487 *cp = hkmap(*cp); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
488 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
489 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
490 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
491 // When the next character is CTRL-\ a following CTRL-N means the |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
492 // command is aborted and we go to Normal mode. |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
493 if (cp == &cap->extra_char |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
494 && cap->nchar == Ctrl_BSL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
495 && (cap->extra_char == Ctrl_N || cap->extra_char == Ctrl_G)) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
496 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
497 cap->cmdchar = Ctrl_BSL; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
498 cap->nchar = cap->extra_char; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
499 idx = find_command(cap->cmdchar); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
500 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
501 else if ((cap->nchar == 'n' || cap->nchar == 'N') && cap->cmdchar == 'g') |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
502 cap->oap->op_type = get_op_type(*cp, NUL); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
503 else if (*cp == Ctrl_BSL) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
504 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
505 long towait = (p_ttm >= 0 ? p_ttm : p_tm); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
506 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
507 // There is a busy wait here when typing "f<C-\>" and then |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
508 // something different from CTRL-N. Can't be avoided. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
509 while ((c = vpeekc()) <= 0 && towait > 0L) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
510 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
511 do_sleep(towait > 50L ? 50L : towait, FALSE); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
512 towait -= 50L; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
513 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
514 if (c > 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
515 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
516 c = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
517 if (c != Ctrl_N && c != Ctrl_G) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
518 vungetc(c); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
519 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
520 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
521 cap->cmdchar = Ctrl_BSL; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
522 cap->nchar = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
523 idx = find_command(cap->cmdchar); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
524 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
525 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
526 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
527 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
528 // When getting a text character and the next character is a |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
529 // multi-byte character, it could be a composing character. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
530 // However, don't wait for it to arrive. Also, do enable mapping, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
531 // because if it's put back with vungetc() it's too late to apply |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
532 // mapping. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
533 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
534 while (enc_utf8 && lang && (c = vpeekc()) > 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
535 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
536 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
537 c = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
538 if (!utf_iscomposing(c)) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
539 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
540 vungetc(c); // it wasn't, put it back |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
541 break; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
542 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
543 else if (cap->ncharC1 == 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
544 cap->ncharC1 = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
545 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
546 cap->ncharC2 = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
547 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
548 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
549 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
550 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
551 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
552 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
553 return idx; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
554 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
555 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
556 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
557 * Returns TRUE if after processing a normal mode command, need to wait for a |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
558 * moment when a message is displayed that will be overwritten by the mode |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
559 * message. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
560 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
561 static int |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
562 normal_cmd_need_to_wait_for_msg(cmdarg_T *cap, pos_T *old_pos) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
563 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
564 // In Visual mode and with "^O" in Insert mode, a short message will be |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
565 // overwritten by the mode message. Wait a bit, until a key is hit. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
566 // In Visual mode, it's more important to keep the Visual area updated |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
567 // than keeping a message (e.g. from a /pat search). |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
568 // Only do this if the command was typed, not from a mapping. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
569 // Don't wait when emsg_silent is non-zero. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
570 // Also wait a bit after an error message, e.g. for "^O:". |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
571 // Don't redraw the screen, it would remove the message. |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
572 return ( ((p_smd |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
573 && msg_silent == 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
574 && (restart_edit != 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
575 || (VIsual_active |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
576 && old_pos->lnum == curwin->w_cursor.lnum |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
577 && old_pos->col == curwin->w_cursor.col) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
578 ) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
579 && (clear_cmdline |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
580 || redraw_cmdline) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
581 && (msg_didout || (msg_didany && msg_scroll)) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
582 && !msg_nowait |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
583 && KeyTyped) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
584 || (restart_edit != 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
585 && !VIsual_active |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
586 && (msg_scroll |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
587 || emsg_on_display))) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
588 && cap->oap->regname == 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
589 && !(cap->retval & CA_COMMAND_BUSY) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
590 && stuff_empty() |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
591 && typebuf_typed() |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
592 && emsg_silent == 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
593 && !in_assert_fails |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
594 && !did_wait_return |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
595 && cap->oap->op_type == OP_NOP); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
596 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
597 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
598 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
599 * After processing a normal mode command, wait for a moment when a message is |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
600 * displayed that will be overwritten by the mode message. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
601 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
602 static void |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
603 normal_cmd_wait_for_msg(void) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
604 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
605 int save_State = State; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
606 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
607 // Draw the cursor with the right shape here |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
608 if (restart_edit != 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
609 State = INSERT; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
610 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
611 // If need to redraw, and there is a "keep_msg", redraw before the |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
612 // delay |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
613 if (must_redraw && keep_msg != NULL && !emsg_on_display) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
614 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
615 char_u *kmsg; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
616 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
617 kmsg = keep_msg; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
618 keep_msg = NULL; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
619 // Showmode() will clear keep_msg, but we want to use it anyway. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
620 // First update w_topline. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
621 setcursor(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
622 update_screen(0); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
623 // now reset it, otherwise it's put in the history again |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
624 keep_msg = kmsg; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
625 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
626 kmsg = vim_strsave(keep_msg); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
627 if (kmsg != NULL) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
628 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
629 msg_attr((char *)kmsg, keep_msg_attr); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
630 vim_free(kmsg); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
631 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
632 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
633 setcursor(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
634 #ifdef CURSOR_SHAPE |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
635 ui_cursor_shape(); // may show different cursor shape |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
636 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
637 cursor_on(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
638 out_flush(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
639 if (msg_scroll || emsg_on_display) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
640 ui_delay(1003L, TRUE); // wait at least one second |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
641 ui_delay(3003L, FALSE); // wait up to three seconds |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
642 State = save_State; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
643 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
644 msg_scroll = FALSE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
645 emsg_on_display = FALSE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
646 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
647 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
648 /* |
7 | 649 * Execute a command in Normal mode. |
650 */ | |
651 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
652 normal_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
653 oparg_T *oap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
654 int toplevel UNUSED) // TRUE when called from main() |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
655 { |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
656 cmdarg_T ca; // command arguments |
7 | 657 int c; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
658 int ctrl_w = FALSE; // got CTRL-W command |
7 | 659 int old_col = curwin->w_curswant; |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
660 int need_flushbuf = FALSE; // need to call out_flush() |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
661 pos_T old_pos; // cursor position before command |
7 | 662 int mapped_len; |
663 static int old_mapped_len = 0; | |
664 int idx; | |
1751 | 665 int set_prevcount = FALSE; |
21405
5324acb43fea
patch 8.2.1253: CTRL-K in Insert mode gets <CursorHold> inserted
Bram Moolenaar <Bram@vim.org>
parents:
20754
diff
changeset
|
666 int save_did_cursorhold = did_cursorhold; |
7 | 667 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
668 CLEAR_FIELD(ca); // also resets ca.retval |
7 | 669 ca.oap = oap; |
1692 | 670 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
671 // Use a count remembered from before entering an operator. After typing |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
672 // "3d" we return from normal_cmd() and come back here, the "3" is |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
673 // remembered in "opcount". |
7 | 674 ca.opcount = opcount; |
675 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
676 // If there is an operator pending, then the command we take this time |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
677 // will terminate it. Finish_op tells us to finish the operation before |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
678 // returning this time (unless the operation was cancelled). |
7 | 679 #ifdef CURSOR_SHAPE |
680 c = finish_op; | |
681 #endif | |
682 finish_op = (oap->op_type != OP_NOP); | |
683 #ifdef CURSOR_SHAPE | |
684 if (finish_op != c) | |
685 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
686 ui_cursor_shape(); // may show different cursor shape |
7 | 687 # ifdef FEAT_MOUSESHAPE |
688 update_mouseshape(-1); | |
689 # endif | |
690 } | |
691 #endif | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
692 trigger_modechanged(); |
7 | 693 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
694 // When not finishing an operator and no register name typed, reset the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
695 // count. |
7 | 696 if (!finish_op && !oap->regname) |
1751 | 697 { |
7 | 698 ca.opcount = 0; |
1751 | 699 #ifdef FEAT_EVAL |
700 set_prevcount = TRUE; | |
701 #endif | |
702 } | |
7 | 703 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
704 // Restore counts from before receiving K_CURSORHOLD. This means after |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
705 // typing "3", handling K_CURSORHOLD and then typing "2" we get "32", not |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
706 // "3 * 2". |
1692 | 707 if (oap->prev_opcount > 0 || oap->prev_count0 > 0) |
708 { | |
709 ca.opcount = oap->prev_opcount; | |
710 ca.count0 = oap->prev_count0; | |
711 oap->prev_opcount = 0; | |
712 oap->prev_count0 = 0; | |
713 } | |
714 | |
7 | 715 mapped_len = typebuf_maplen(); |
716 | |
717 State = NORMAL_BUSY; | |
718 #ifdef USE_ON_FLY_SCROLL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
719 dont_scroll = FALSE; // allow scrolling here |
7 | 720 #endif |
721 | |
2667 | 722 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
723 // Set v:count here, when called from main() and not a stuffed |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
724 // command, so that v:count can be used in an expression mapping |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
725 // when there is no count. Do set it for redo. |
5649 | 726 if (toplevel && readbuf1_empty()) |
2667 | 727 set_vcount_ca(&ca, &set_prevcount); |
728 #endif | |
729 | |
7 | 730 /* |
731 * Get the command character from the user. | |
732 */ | |
733 c = safe_vgetc(); | |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7578
diff
changeset
|
734 LANGMAP_ADJUST(c, get_real_state() != SELECTMODE); |
7 | 735 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
736 // If a mapping was started in Visual or Select mode, remember the length |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
737 // of the mapping. This is used below to not return to Insert mode for as |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
738 // long as the mapping is being executed. |
7 | 739 if (restart_edit == 0) |
740 old_mapped_len = 0; | |
741 else if (old_mapped_len | |
819 | 742 || (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0)) |
7 | 743 old_mapped_len = typebuf_maplen(); |
744 | |
745 if (c == NUL) | |
746 c = K_ZERO; | |
747 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
748 // In Select mode, typed text replaces the selection. |
7 | 749 if (VIsual_active |
750 && VIsual_select | |
751 && (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER)) | |
752 { | |
26929
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
753 int len; |
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
754 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
755 // Fake a "c"hange command. When "restart_edit" is set (e.g., because |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
756 // 'insertmode' is set) fake a "d"elete command, Insert mode will |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
757 // restart automatically. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
758 // Insert the typed character in the typeahead buffer, so that it can |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
759 // be mapped in Insert mode. Required for ":lmap" to work. |
26929
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
760 len = ins_char_typebuf(vgetc_char, vgetc_mod_mask); |
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
761 |
27418
6ecfb8d99353
patch 8.2.4237: record buffer wrong if character in Select mode was not typed
Bram Moolenaar <Bram@vim.org>
parents:
27400
diff
changeset
|
762 // When recording and gotchars() was called the character will be |
6ecfb8d99353
patch 8.2.4237: record buffer wrong if character in Select mode was not typed
Bram Moolenaar <Bram@vim.org>
parents:
27400
diff
changeset
|
763 // recorded again, remove the previous recording. |
6ecfb8d99353
patch 8.2.4237: record buffer wrong if character in Select mode was not typed
Bram Moolenaar <Bram@vim.org>
parents:
27400
diff
changeset
|
764 if (KeyTyped) |
6ecfb8d99353
patch 8.2.4237: record buffer wrong if character in Select mode was not typed
Bram Moolenaar <Bram@vim.org>
parents:
27400
diff
changeset
|
765 ungetchars(len); |
26929
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
766 |
275 | 767 if (restart_edit != 0) |
768 c = 'd'; | |
769 else | |
770 c = 'c'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
771 msg_nowait = TRUE; // don't delay going to insert mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
772 old_mapped_len = 0; // do go to Insert mode |
7 | 773 } |
774 | |
26468
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
775 // If the window was made so small that nothing shows, make it at least one |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
776 // line and one column when typing a command. |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
777 if (KeyTyped && !KeyStuffed) |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
778 win_ensure_size(); |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
779 |
7 | 780 #ifdef FEAT_CMDL_INFO |
781 need_flushbuf = add_to_showcmd(c); | |
782 #endif | |
783 | |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
784 // Get the command count |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
785 c = normal_cmd_get_count(&ca, c, toplevel, set_prevcount, &ctrl_w, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
786 &need_flushbuf); |
7 | 787 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
788 // Find the command character in the table of commands. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
789 // For CTRL-W we already got nchar when looking for a count. |
7 | 790 if (ctrl_w) |
791 { | |
792 ca.nchar = c; | |
793 ca.cmdchar = Ctrl_W; | |
794 } | |
795 else | |
796 ca.cmdchar = c; | |
797 idx = find_command(ca.cmdchar); | |
798 if (idx < 0) | |
799 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
800 // Not a known command: beep. |
7 | 801 clearopbeep(oap); |
802 goto normal_end; | |
803 } | |
631 | 804 |
633 | 805 if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW)) |
631 | 806 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
807 // This command is not allowed while editing a cmdline: beep. |
7 | 808 clearopbeep(oap); |
633 | 809 text_locked_msg(); |
7 | 810 goto normal_end; |
811 } | |
819 | 812 if ((nv_cmds[idx].cmd_flags & NV_NCW) && curbuf_locked()) |
813 goto normal_end; | |
7 | 814 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
815 // In Visual/Select mode, a few keys are handled in a special way. |
7 | 816 if (VIsual_active) |
817 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
818 // when 'keymodel' contains "stopsel" may stop Select/Visual mode |
7 | 819 if (km_stopsel |
820 && (nv_cmds[idx].cmd_flags & NV_STS) | |
821 && !(mod_mask & MOD_MASK_SHIFT)) | |
822 { | |
823 end_visual_mode(); | |
824 redraw_curbuf_later(INVERTED); | |
825 } | |
826 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
827 // Keys that work different when 'keymodel' contains "startsel" |
7 | 828 if (km_startsel) |
829 { | |
830 if (nv_cmds[idx].cmd_flags & NV_SS) | |
831 { | |
832 unshift_special(&ca); | |
833 idx = find_command(ca.cmdchar); | |
840 | 834 if (idx < 0) |
835 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
836 // Just in case |
840 | 837 clearopbeep(oap); |
838 goto normal_end; | |
839 } | |
7 | 840 } |
841 else if ((nv_cmds[idx].cmd_flags & NV_SSS) | |
842 && (mod_mask & MOD_MASK_SHIFT)) | |
843 mod_mask &= ~MOD_MASK_SHIFT; | |
844 } | |
845 } | |
846 | |
847 #ifdef FEAT_RIGHTLEFT | |
848 if (curwin->w_p_rl && KeyTyped && !KeyStuffed | |
849 && (nv_cmds[idx].cmd_flags & NV_RL)) | |
850 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
851 // Invert horizontal movements and operations. Only when typed by the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
852 // user directly, not when the result of a mapping or "x" translated |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
853 // to "dl". |
7 | 854 switch (ca.cmdchar) |
855 { | |
856 case 'l': ca.cmdchar = 'h'; break; | |
857 case K_RIGHT: ca.cmdchar = K_LEFT; break; | |
858 case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break; | |
859 case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break; | |
860 case 'h': ca.cmdchar = 'l'; break; | |
861 case K_LEFT: ca.cmdchar = K_RIGHT; break; | |
862 case K_S_LEFT: ca.cmdchar = K_S_RIGHT; break; | |
863 case K_C_LEFT: ca.cmdchar = K_C_RIGHT; break; | |
864 case '>': ca.cmdchar = '<'; break; | |
865 case '<': ca.cmdchar = '>'; break; | |
866 } | |
867 idx = find_command(ca.cmdchar); | |
868 } | |
869 #endif | |
870 | |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
871 // Get additional characters if we need them. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
872 if (normal_cmd_needs_more_chars(&ca, nv_cmds[idx].cmd_flags)) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
873 idx = normal_cmd_get_more_chars(idx, &ca, &need_flushbuf); |
7 | 874 |
875 #ifdef FEAT_CMDL_INFO | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
876 // Flush the showcmd characters onto the screen so we can see them while |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
877 // the command is being executed. Only do this when the shown command was |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
878 // actually displayed, otherwise this will slow down a lot when executing |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
879 // mappings. |
7 | 880 if (need_flushbuf) |
881 out_flush(); | |
882 #endif | |
1727 | 883 if (ca.cmdchar != K_IGNORE) |
21415
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
884 { |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
885 if (ex_normal_busy) |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
886 did_cursorhold = save_did_cursorhold; |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
887 else |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
888 did_cursorhold = FALSE; |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
889 } |
7 | 890 |
891 State = NORMAL; | |
892 | |
893 if (ca.nchar == ESC) | |
894 { | |
895 clearop(oap); | |
896 if (restart_edit == 0 && goto_im()) | |
897 restart_edit = 'a'; | |
898 goto normal_end; | |
899 } | |
900 | |
24 | 901 if (ca.cmdchar != K_IGNORE) |
902 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
903 msg_didout = FALSE; // don't scroll screen up for normal command |
24 | 904 msg_col = 0; |
905 } | |
7 | 906 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
907 old_pos = curwin->w_cursor; // remember where cursor was |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
908 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
909 // When 'keymodel' contains "startsel" some keys start Select/Visual |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
910 // mode. |
7 | 911 if (!VIsual_active && km_startsel) |
912 { | |
913 if (nv_cmds[idx].cmd_flags & NV_SS) | |
914 { | |
915 start_selection(); | |
916 unshift_special(&ca); | |
917 idx = find_command(ca.cmdchar); | |
918 } | |
919 else if ((nv_cmds[idx].cmd_flags & NV_SSS) | |
920 && (mod_mask & MOD_MASK_SHIFT)) | |
921 { | |
922 start_selection(); | |
923 mod_mask &= ~MOD_MASK_SHIFT; | |
924 } | |
925 } | |
926 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
927 // Execute the command! |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
928 // Call the command function found in the commands table. |
7 | 929 ca.arg = nv_cmds[idx].cmd_arg; |
930 (nv_cmds[idx].cmd_func)(&ca); | |
931 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
932 // If we didn't start or finish an operator, reset oap->regname, unless we |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
933 // need it later. |
7 | 934 if (!finish_op |
935 && !oap->op_type | |
936 && (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG))) | |
937 { | |
938 clearop(oap); | |
939 #ifdef FEAT_EVAL | |
20721
70d561931721
patch 8.2.0913: code for resetting v:register is duplicated
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
940 reset_reg_var(); |
7 | 941 #endif |
942 } | |
943 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
944 // Get the length of mapped chars again after typing a count, second |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
945 // character or "z333<cr>". |
36 | 946 if (old_mapped_len > 0) |
947 old_mapped_len = typebuf_maplen(); | |
948 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
949 // If an operation is pending, handle it. But not for K_IGNORE or |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
950 // K_MOUSEMOVE. |
24586
b7f58be68c02
patch 8.2.2832: operator cancelled by moving mouse when using popup
Bram Moolenaar <Bram@vim.org>
parents:
24341
diff
changeset
|
951 if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE) |
18775
5da1ad9165f0
patch 8.1.2377: GUI: when losing focus a pending operator is executed
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
952 do_pending_operator(&ca, old_col, FALSE); |
7 | 953 |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
954 // Wait for a moment when a message is displayed that will be overwritten |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
955 // by the mode message. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
956 if (normal_cmd_need_to_wait_for_msg(&ca, &old_pos)) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
957 normal_cmd_wait_for_msg(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
958 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
959 // Finish up after executing a Normal mode command. |
7 | 960 normal_end: |
961 | |
962 msg_nowait = FALSE; | |
963 | |
20754
e6a5a5ef4034
patch 8.2.0929: v:register is not cleared after an operator was executed
Bram Moolenaar <Bram@vim.org>
parents:
20721
diff
changeset
|
964 #ifdef FEAT_EVAL |
e6a5a5ef4034
patch 8.2.0929: v:register is not cleared after an operator was executed
Bram Moolenaar <Bram@vim.org>
parents:
20721
diff
changeset
|
965 if (finish_op) |
e6a5a5ef4034
patch 8.2.0929: v:register is not cleared after an operator was executed
Bram Moolenaar <Bram@vim.org>
parents:
20721
diff
changeset
|
966 reset_reg_var(); |
e6a5a5ef4034
patch 8.2.0929: v:register is not cleared after an operator was executed
Bram Moolenaar <Bram@vim.org>
parents:
20721
diff
changeset
|
967 #endif |
e6a5a5ef4034
patch 8.2.0929: v:register is not cleared after an operator was executed
Bram Moolenaar <Bram@vim.org>
parents:
20721
diff
changeset
|
968 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
969 // Reset finish_op, in case it was set |
7 | 970 #ifdef CURSOR_SHAPE |
971 c = finish_op; | |
972 #endif | |
973 finish_op = FALSE; | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
974 trigger_modechanged(); |
7 | 975 #ifdef CURSOR_SHAPE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
976 // Redraw the cursor with another shape, if we were in Operator-pending |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
977 // mode or did a replace command. |
7 | 978 if (c || ca.cmdchar == 'r') |
979 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
980 ui_cursor_shape(); // may show different cursor shape |
7 | 981 # ifdef FEAT_MOUSESHAPE |
982 update_mouseshape(-1); | |
983 # endif | |
984 } | |
985 #endif | |
986 | |
987 #ifdef FEAT_CMDL_INFO | |
1692 | 988 if (oap->op_type == OP_NOP && oap->regname == 0 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
989 && ca.cmdchar != K_CURSORHOLD) |
7 | 990 clear_showcmd(); |
991 #endif | |
992 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
993 checkpcmark(); // check if we moved since setting pcmark |
7 | 994 vim_free(ca.searchbuf); |
995 | |
996 if (has_mbyte) | |
997 mb_adjust_cursor(); | |
998 | |
999 if (curwin->w_p_scb && toplevel) | |
1000 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1001 validate_cursor(); // may need to update w_leftcol |
7 | 1002 do_check_scrollbind(TRUE); |
1003 } | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
1004 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1005 if (curwin->w_p_crb && toplevel) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1006 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1007 validate_cursor(); // may need to update w_leftcol |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1008 do_check_cursorbind(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1009 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1010 |
12134
e83c6c10320c
patch 8.0.0947: entering terminal using C-O C-W C-W goes to Insert mode
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
1011 #ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1012 // don't go to Insert mode if a terminal has a running job |
12467
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
1013 if (term_job_running(curbuf->b_term)) |
12134
e83c6c10320c
patch 8.0.0947: entering terminal using C-O C-W C-W goes to Insert mode
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
1014 restart_edit = 0; |
e83c6c10320c
patch 8.0.0947: entering terminal using C-O C-W C-W goes to Insert mode
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
1015 #endif |
e83c6c10320c
patch 8.0.0947: entering terminal using C-O C-W C-W goes to Insert mode
Christian Brabandt <cb@256bit.org>
parents:
11993
diff
changeset
|
1016 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1017 // May restart edit(), if we got here with CTRL-O in Insert mode (but not |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1018 // if still inside a mapping that started in Visual mode). |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1019 // May switch from Visual to Select mode after CTRL-O command. |
7 | 1020 if ( oap->op_type == OP_NOP |
1021 && ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0) | |
1022 || restart_VIsual_select == 1) | |
1023 && !(ca.retval & CA_COMMAND_BUSY) | |
1024 && stuff_empty() | |
1025 && oap->regname == 0) | |
1026 { | |
1027 if (restart_VIsual_select == 1) | |
1028 { | |
1029 VIsual_select = TRUE; | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
1030 trigger_modechanged(); |
7 | 1031 showmode(); |
1032 restart_VIsual_select = 0; | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
1033 VIsual_select_reg = 0; |
7 | 1034 } |
5735 | 1035 if (restart_edit != 0 && !VIsual_active && old_mapped_len == 0) |
7 | 1036 (void)edit(restart_edit, FALSE, 1L); |
1037 } | |
1038 | |
1039 if (restart_VIsual_select == 2) | |
1040 restart_VIsual_select = 1; | |
1041 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1042 // Save count before an operator for next time. |
7 | 1043 opcount = ca.opcount; |
1044 } | |
1045 | |
2667 | 1046 #ifdef FEAT_EVAL |
1047 /* | |
1048 * Set v:count and v:count1 according to "cap". | |
1049 * Set v:prevcount only when "set_prevcount" is TRUE. | |
1050 */ | |
1051 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1052 set_vcount_ca(cmdarg_T *cap, int *set_prevcount) |
2667 | 1053 { |
1054 long count = cap->count0; | |
1055 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1056 // multiply with cap->opcount the same way as above |
2667 | 1057 if (cap->opcount != 0) |
1058 count = cap->opcount * (count == 0 ? 1 : count); | |
1059 set_vcount(count, count == 0 ? 1 : count, *set_prevcount); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1060 *set_prevcount = FALSE; // only set v:prevcount once |
2667 | 1061 } |
1062 #endif | |
1063 | |
7 | 1064 /* |
19681
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1065 * Check if highlighting for Visual mode is possible, give a warning message |
7 | 1066 * if not. |
1067 */ | |
1068 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1069 check_visual_highlight(void) |
7 | 1070 { |
1071 static int did_check = FALSE; | |
1072 | |
1073 if (full_screen) | |
1074 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
1075 if (!did_check && HL_ATTR(HLF_V) == 0) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1076 msg(_("Warning: terminal cannot highlight")); |
7 | 1077 did_check = TRUE; |
1078 } | |
1079 } | |
1080 | |
23021
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1081 #if defined(FEAT_CLIPBOARD) && defined(FEAT_EVAL) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1082 /* |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1083 * Call yank_do_autocmd() for "regname". |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1084 */ |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1085 static void |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1086 call_yank_do_autocmd(int regname) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1087 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1088 oparg_T oa; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1089 yankreg_T *reg; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1090 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1091 clear_oparg(&oa); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1092 oa.regname = regname; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1093 oa.op_type = OP_YANK; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1094 oa.is_VIsual = TRUE; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1095 reg = get_register(regname, TRUE); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1096 yank_do_autocmd(&oa, reg); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1097 free_register(reg); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1098 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1099 #endif |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1100 |
7 | 1101 /* |
638 | 1102 * End Visual mode. |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1103 * This function or the next should ALWAYS be called to end Visual mode, except |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1104 * from do_pending_operator(). |
7 | 1105 */ |
1106 void | |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1107 end_visual_mode() |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1108 { |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1109 end_visual_mode_keep_button(); |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1110 reset_held_button(); |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1111 } |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1112 |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1113 void |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1114 end_visual_mode_keep_button() |
7 | 1115 { |
1116 #ifdef FEAT_CLIPBOARD | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1117 // If we are using the clipboard, then remember what was selected in case |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1118 // we need to paste it somewhere while we still own the selection. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1119 // Only do this when the clipboard is already owned. Don't want to grab |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1120 // the selection when hitting ESC. |
7 | 1121 if (clip_star.available && clip_star.owned) |
1122 clip_auto_select(); | |
23021
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1123 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1124 # if defined(FEAT_EVAL) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1125 // Emit a TextYankPost for the automatic copy of the selection into the |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1126 // star and/or plus register. |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1127 if (has_textyankpost()) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1128 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1129 if (clip_isautosel_star()) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1130 call_yank_do_autocmd('*'); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1131 if (clip_isautosel_plus()) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1132 call_yank_do_autocmd('+'); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1133 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1134 # endif |
7 | 1135 #endif |
1136 | |
1137 VIsual_active = FALSE; | |
1138 setmouse(); | |
1139 mouse_dragging = 0; | |
1140 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1141 // Save the current VIsual area for '< and '> marks, and "gv" |
690 | 1142 curbuf->b_visual.vi_mode = VIsual_mode; |
1143 curbuf->b_visual.vi_start = VIsual; | |
1144 curbuf->b_visual.vi_end = curwin->w_cursor; | |
1145 curbuf->b_visual.vi_curswant = curwin->w_curswant; | |
7 | 1146 #ifdef FEAT_EVAL |
1147 curbuf->b_visual_mode_eval = VIsual_mode; | |
1148 #endif | |
1149 if (!virtual_active()) | |
1150 curwin->w_cursor.coladd = 0; | |
6979 | 1151 may_clear_cmdline(); |
7 | 1152 |
844 | 1153 adjust_cursor_eol(); |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
1154 trigger_modechanged(); |
7 | 1155 } |
1156 | |
1157 /* | |
1158 * Reset VIsual_active and VIsual_reselect. | |
1159 */ | |
1160 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1161 reset_VIsual_and_resel(void) |
7 | 1162 { |
1163 if (VIsual_active) | |
1164 { | |
1165 end_visual_mode(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1166 redraw_curbuf_later(INVERTED); // delete the inversion later |
7 | 1167 } |
1168 VIsual_reselect = FALSE; | |
1169 } | |
1170 | |
1171 /* | |
1172 * Reset VIsual_active and VIsual_reselect if it's set. | |
1173 */ | |
1174 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1175 reset_VIsual(void) |
7 | 1176 { |
1177 if (VIsual_active) | |
1178 { | |
1179 end_visual_mode(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1180 redraw_curbuf_later(INVERTED); // delete the inversion later |
7 | 1181 VIsual_reselect = FALSE; |
1182 } | |
1183 } | |
1184 | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1185 void |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1186 restore_visual_mode(void) |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1187 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1188 if (VIsual_mode_orig != NUL) |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1189 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1190 curbuf->b_visual.vi_mode = VIsual_mode_orig; |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1191 VIsual_mode_orig = NUL; |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1192 } |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1193 } |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1194 |
7 | 1195 /* |
1196 * Check for a balloon-eval special item to include when searching for an | |
1197 * identifier. When "dir" is BACKWARD "ptr[-1]" must be valid! | |
1198 * Returns TRUE if the character at "*ptr" should be included. | |
1199 * "dir" is FORWARD or BACKWARD, the direction of searching. | |
1200 * "*colp" is in/decremented if "ptr[-dir]" should also be included. | |
1201 * "bnp" points to a counter for square brackets. | |
1202 */ | |
1203 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1204 find_is_eval_item( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1205 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1206 int *colp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1207 int *bnp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1208 int dir) |
7 | 1209 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1210 // Accept everything inside []. |
7 | 1211 if ((*ptr == ']' && dir == BACKWARD) || (*ptr == '[' && dir == FORWARD)) |
1212 ++*bnp; | |
1213 if (*bnp > 0) | |
1214 { | |
1215 if ((*ptr == '[' && dir == BACKWARD) || (*ptr == ']' && dir == FORWARD)) | |
1216 --*bnp; | |
1217 return TRUE; | |
1218 } | |
1219 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1220 // skip over "s.var" |
7 | 1221 if (*ptr == '.') |
1222 return TRUE; | |
1223 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1224 // two-character item: s->var |
7 | 1225 if (ptr[dir == BACKWARD ? 0 : 1] == '>' |
1226 && ptr[dir == BACKWARD ? -1 : 0] == '-') | |
1227 { | |
1228 *colp += dir; | |
1229 return TRUE; | |
1230 } | |
1231 return FALSE; | |
1232 } | |
1233 | |
1234 /* | |
1235 * Find the identifier under or to the right of the cursor. | |
1236 * "find_type" can have one of three values: | |
1237 * FIND_IDENT: find an identifier (keyword) | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1238 * FIND_STRING: find any non-white text |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1239 * FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred. |
184 | 1240 * FIND_EVAL: find text useful for C program debugging |
7 | 1241 * |
1242 * There are three steps: | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1243 * 1. Search forward for the start of an identifier/text. Doesn't move if |
7 | 1244 * already on one. |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1245 * 2. Search backward for the start of this identifier/text. |
7 | 1246 * This doesn't match the real Vi but I like it a little better and it |
1247 * shouldn't bother anyone. | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1248 * 3. Search forward to the end of this identifier/text. |
7 | 1249 * When FIND_IDENT isn't defined, we backup until a blank. |
1250 * | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1251 * Returns the length of the text, or zero if no text is found. |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1252 * If text is found, a pointer to the text is put in "*text". This |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1253 * points into the current buffer line and is not always NUL terminated. |
7 | 1254 */ |
1255 int | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1256 find_ident_under_cursor(char_u **text, int find_type) |
7 | 1257 { |
1258 return find_ident_at_pos(curwin, curwin->w_cursor.lnum, | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1259 curwin->w_cursor.col, text, NULL, find_type); |
7 | 1260 } |
1261 | |
1262 /* | |
1263 * Like find_ident_under_cursor(), but for any window and any position. | |
1264 * However: Uses 'iskeyword' from the current window!. | |
1265 */ | |
1266 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1267 find_ident_at_pos( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1268 win_T *wp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1269 linenr_T lnum, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1270 colnr_T startcol, |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1271 char_u **text, |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1272 int *textcol, // column where "text" starts, can be NULL |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1273 int find_type) |
7 | 1274 { |
1275 char_u *ptr; | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1276 int col = 0; // init to shut up GCC |
7 | 1277 int i; |
1278 int this_class = 0; | |
1279 int prev_class; | |
1280 int prevcol; | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1281 int bn = 0; // bracket nesting |
7 | 1282 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1283 // if i == 0: try to find an identifier |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1284 // if i == 1: try to find any non-white text |
7 | 1285 ptr = ml_get_buf(wp->w_buffer, lnum, FALSE); |
1286 for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i) | |
1287 { | |
1288 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1289 * 1. skip to start of identifier/text |
7 | 1290 */ |
1291 col = startcol; | |
1292 if (has_mbyte) | |
1293 { | |
1294 while (ptr[col] != NUL) | |
1295 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1296 // Stop at a ']' to evaluate "a[x]". |
7 | 1297 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1298 break; | |
1299 this_class = mb_get_class(ptr + col); | |
1300 if (this_class != 0 && (i == 1 || this_class != 1)) | |
1301 break; | |
474 | 1302 col += (*mb_ptr2len)(ptr + col); |
7 | 1303 } |
1304 } | |
1305 else | |
1306 while (ptr[col] != NUL | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
1307 && (i == 0 ? !vim_iswordc(ptr[col]) : VIM_ISWHITE(ptr[col])) |
7 | 1308 && (!(find_type & FIND_EVAL) || ptr[col] != ']') |
1309 ) | |
1310 ++col; | |
1311 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1312 // When starting on a ']' count it, so that we include the '['. |
7 | 1313 bn = ptr[col] == ']'; |
1314 | |
1315 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1316 * 2. Back up to start of identifier/text. |
7 | 1317 */ |
1318 if (has_mbyte) | |
1319 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1320 // Remember class of character under cursor. |
7 | 1321 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1322 this_class = mb_get_class((char_u *)"a"); | |
1323 else | |
1324 this_class = mb_get_class(ptr + col); | |
835 | 1325 while (col > 0 && this_class != 0) |
7 | 1326 { |
1327 prevcol = col - 1 - (*mb_head_off)(ptr, ptr + col - 1); | |
1328 prev_class = mb_get_class(ptr + prevcol); | |
1329 if (this_class != prev_class | |
1330 && (i == 0 | |
1331 || prev_class == 0 | |
1332 || (find_type & FIND_IDENT)) | |
1333 && (!(find_type & FIND_EVAL) | |
1334 || prevcol == 0 | |
1335 || !find_is_eval_item(ptr + prevcol, &prevcol, | |
1336 &bn, BACKWARD)) | |
1337 ) | |
1338 break; | |
1339 col = prevcol; | |
1340 } | |
1341 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1342 // If we don't want just any old text, or we've found an |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1343 // identifier, stop searching. |
7 | 1344 if (this_class > 2) |
1345 this_class = 2; | |
1346 if (!(find_type & FIND_STRING) || this_class == 2) | |
1347 break; | |
1348 } | |
1349 else | |
1350 { | |
1351 while (col > 0 | |
1352 && ((i == 0 | |
1353 ? vim_iswordc(ptr[col - 1]) | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
1354 : (!VIM_ISWHITE(ptr[col - 1]) |
7 | 1355 && (!(find_type & FIND_IDENT) |
1356 || !vim_iswordc(ptr[col - 1])))) | |
1357 || ((find_type & FIND_EVAL) | |
1358 && col > 1 | |
1359 && find_is_eval_item(ptr + col - 1, &col, | |
1360 &bn, BACKWARD)) | |
1361 )) | |
1362 --col; | |
1363 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1364 // If we don't want just any old text, or we've found an |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1365 // identifier, stop searching. |
7 | 1366 if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col])) |
1367 break; | |
1368 } | |
1369 } | |
1370 | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1371 if (ptr[col] == NUL || (i == 0 |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1372 && (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col])))) |
7 | 1373 { |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1374 // didn't find an identifier or text |
16908
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1375 if ((find_type & FIND_NOERROR) == 0) |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1376 { |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1377 if (find_type & FIND_STRING) |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
1378 emsg(_(e_no_string_under_cursor)); |
16908
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1379 else |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
1380 emsg(_(e_no_identifier_under_cursor)); |
16908
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1381 } |
7 | 1382 return 0; |
1383 } | |
1384 ptr += col; | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1385 *text = ptr; |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1386 if (textcol != NULL) |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1387 *textcol = col; |
7 | 1388 |
1389 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1390 * 3. Find the end if the identifier/text. |
7 | 1391 */ |
1392 bn = 0; | |
1393 startcol -= col; | |
1394 col = 0; | |
1395 if (has_mbyte) | |
1396 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1397 // Search for point of changing multibyte character class. |
7 | 1398 this_class = mb_get_class(ptr); |
1399 while (ptr[col] != NUL | |
1400 && ((i == 0 ? mb_get_class(ptr + col) == this_class | |
1401 : mb_get_class(ptr + col) != 0) | |
1402 || ((find_type & FIND_EVAL) | |
1403 && col <= (int)startcol | |
1404 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1405 )) | |
474 | 1406 col += (*mb_ptr2len)(ptr + col); |
7 | 1407 } |
1408 else | |
1409 while ((i == 0 ? vim_iswordc(ptr[col]) | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
1410 : (ptr[col] != NUL && !VIM_ISWHITE(ptr[col]))) |
7 | 1411 || ((find_type & FIND_EVAL) |
1412 && col <= (int)startcol | |
1413 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1414 ) | |
1415 ++col; | |
1416 | |
1417 return col; | |
1418 } | |
1419 | |
1420 /* | |
1421 * Prepare for redo of a normal command. | |
1422 */ | |
1423 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1424 prep_redo_cmd(cmdarg_T *cap) |
7 | 1425 { |
1426 prep_redo(cap->oap->regname, cap->count0, | |
1427 NUL, cap->cmdchar, NUL, NUL, cap->nchar); | |
1428 } | |
1429 | |
1430 /* | |
1431 * Prepare for redo of any command. | |
1432 * Note that only the last argument can be a multi-byte char. | |
1433 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1434 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1435 prep_redo( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1436 int regname, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1437 long num, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1438 int cmd1, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1439 int cmd2, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1440 int cmd3, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1441 int cmd4, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1442 int cmd5) |
7 | 1443 { |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1444 prep_redo_num2(regname, num, cmd1, cmd2, 0L, cmd3, cmd4, cmd5); |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1445 } |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1446 |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1447 /* |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1448 * Prepare for redo of any command with extra count after "cmd2". |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1449 */ |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1450 void |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1451 prep_redo_num2( |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1452 int regname, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1453 long num1, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1454 int cmd1, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1455 int cmd2, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1456 long num2, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1457 int cmd3, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1458 int cmd4, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1459 int cmd5) |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1460 { |
7 | 1461 ResetRedobuff(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1462 if (regname != 0) // yank from specified buffer |
7 | 1463 { |
1464 AppendCharToRedobuff('"'); | |
1465 AppendCharToRedobuff(regname); | |
1466 } | |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1467 if (num1 != 0) |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1468 AppendNumberToRedobuff(num1); |
7 | 1469 if (cmd1 != NUL) |
1470 AppendCharToRedobuff(cmd1); | |
1471 if (cmd2 != NUL) | |
1472 AppendCharToRedobuff(cmd2); | |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1473 if (num2 != 0) |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1474 AppendNumberToRedobuff(num2); |
7 | 1475 if (cmd3 != NUL) |
1476 AppendCharToRedobuff(cmd3); | |
1477 if (cmd4 != NUL) | |
1478 AppendCharToRedobuff(cmd4); | |
1479 if (cmd5 != NUL) | |
1480 AppendCharToRedobuff(cmd5); | |
1481 } | |
1482 | |
1483 /* | |
1484 * check for operator active and clear it | |
1485 * | |
1486 * return TRUE if operator was active | |
1487 */ | |
1488 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1489 checkclearop(oparg_T *oap) |
7 | 1490 { |
1491 if (oap->op_type == OP_NOP) | |
1492 return FALSE; | |
1493 clearopbeep(oap); | |
1494 return TRUE; | |
1495 } | |
1496 | |
1497 /* | |
1131 | 1498 * Check for operator or Visual active. Clear active operator. |
7 | 1499 * |
1131 | 1500 * Return TRUE if operator or Visual was active. |
7 | 1501 */ |
1502 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1503 checkclearopq(oparg_T *oap) |
7 | 1504 { |
5735 | 1505 if (oap->op_type == OP_NOP && !VIsual_active) |
7 | 1506 return FALSE; |
1507 clearopbeep(oap); | |
1508 return TRUE; | |
1509 } | |
1510 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1511 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1512 clearop(oparg_T *oap) |
7 | 1513 { |
1514 oap->op_type = OP_NOP; | |
1515 oap->regname = 0; | |
1516 oap->motion_force = NUL; | |
1517 oap->use_reg_one = FALSE; | |
24800
b032da736676
patch 8.2.2938: after using motion force from feedkeys() it sticks
Bram Moolenaar <Bram@vim.org>
parents:
24788
diff
changeset
|
1518 motion_force = NUL; |
7 | 1519 } |
1520 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1521 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1522 clearopbeep(oparg_T *oap) |
7 | 1523 { |
1524 clearop(oap); | |
1525 beep_flush(); | |
1526 } | |
1527 | |
1528 /* | |
1529 * Remove the shift modifier from a special key. | |
1530 */ | |
1531 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1532 unshift_special(cmdarg_T *cap) |
7 | 1533 { |
1534 switch (cap->cmdchar) | |
1535 { | |
1536 case K_S_RIGHT: cap->cmdchar = K_RIGHT; break; | |
1537 case K_S_LEFT: cap->cmdchar = K_LEFT; break; | |
1538 case K_S_UP: cap->cmdchar = K_UP; break; | |
1539 case K_S_DOWN: cap->cmdchar = K_DOWN; break; | |
1540 case K_S_HOME: cap->cmdchar = K_HOME; break; | |
1541 case K_S_END: cap->cmdchar = K_END; break; | |
1542 } | |
1543 cap->cmdchar = simplify_key(cap->cmdchar, &mod_mask); | |
1544 } | |
1545 | |
6979 | 1546 /* |
1547 * If the mode is currently displayed clear the command line or update the | |
1548 * command displayed. | |
1549 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1550 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1551 may_clear_cmdline(void) |
6979 | 1552 { |
1553 if (mode_displayed) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1554 clear_cmdline = TRUE; // unshow visual mode later |
6979 | 1555 #ifdef FEAT_CMDL_INFO |
1556 else | |
1557 clear_showcmd(); | |
1558 #endif | |
1559 } | |
1560 | |
7 | 1561 #if defined(FEAT_CMDL_INFO) || defined(PROTO) |
1562 /* | |
1563 * Routines for displaying a partly typed command | |
1564 */ | |
1565 | |
27752
c1d1639b52dd
patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1566 #define SHOWCMD_BUFLEN (SHOWCMD_COLS + 1 + 30) |
7 | 1567 static char_u showcmd_buf[SHOWCMD_BUFLEN]; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1568 static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd() |
7 | 1569 static int showcmd_is_clear = TRUE; |
1570 static int showcmd_visual = FALSE; | |
1571 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
1572 static void display_showcmd(void); |
7 | 1573 |
1574 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1575 clear_showcmd(void) |
7 | 1576 { |
1577 if (!p_sc) | |
1578 return; | |
1579 | |
1580 if (VIsual_active && !char_avail()) | |
1581 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
1582 int cursor_bot = LT_POS(VIsual, curwin->w_cursor); |
7 | 1583 long lines; |
1584 colnr_T leftcol, rightcol; | |
1585 linenr_T top, bot; | |
1586 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1587 // Show the size of the Visual area. |
1866 | 1588 if (cursor_bot) |
7 | 1589 { |
1590 top = VIsual.lnum; | |
1591 bot = curwin->w_cursor.lnum; | |
1592 } | |
1593 else | |
1594 { | |
1595 top = curwin->w_cursor.lnum; | |
1596 bot = VIsual.lnum; | |
1597 } | |
1598 # ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1599 // Include closed folds as a whole. |
7009 | 1600 (void)hasFolding(top, &top, NULL); |
1601 (void)hasFolding(bot, NULL, &bot); | |
7 | 1602 # endif |
1603 lines = bot - top + 1; | |
1604 | |
1605 if (VIsual_mode == Ctrl_V) | |
1606 { | |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1607 # ifdef FEAT_LINEBREAK |
1866 | 1608 char_u *saved_sbr = p_sbr; |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18485
diff
changeset
|
1609 char_u *saved_w_sbr = curwin->w_p_sbr; |
1866 | 1610 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1611 // Make 'sbr' empty for a moment to get the correct size. |
1866 | 1612 p_sbr = empty_option; |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18485
diff
changeset
|
1613 curwin->w_p_sbr = empty_option; |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1614 # endif |
7 | 1615 getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol); |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1616 # ifdef FEAT_LINEBREAK |
1866 | 1617 p_sbr = saved_sbr; |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18485
diff
changeset
|
1618 curwin->w_p_sbr = saved_w_sbr; |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1619 # endif |
7 | 1620 sprintf((char *)showcmd_buf, "%ldx%ld", lines, |
1621 (long)(rightcol - leftcol + 1)); | |
1622 } | |
1623 else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) | |
1624 sprintf((char *)showcmd_buf, "%ld", lines); | |
1625 else | |
2324
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1626 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1627 char_u *s, *e; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1628 int l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1629 int bytes = 0; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1630 int chars = 0; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1631 |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1632 if (cursor_bot) |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1633 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1634 s = ml_get_pos(&VIsual); |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1635 e = ml_get_cursor(); |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1636 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1637 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1638 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1639 s = ml_get_cursor(); |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1640 e = ml_get_pos(&VIsual); |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1641 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1642 while ((*p_sel != 'e') ? s <= e : s < e) |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1643 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1644 l = (*mb_ptr2len)(s); |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1645 if (l == 0) |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1646 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1647 ++bytes; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1648 ++chars; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1649 break; // end of line |
2324
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1650 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1651 bytes += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1652 ++chars; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1653 s += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1654 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1655 if (bytes == chars) |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1656 sprintf((char *)showcmd_buf, "%d", chars); |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1657 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1658 sprintf((char *)showcmd_buf, "%d-%d", chars, bytes); |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1659 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1660 showcmd_buf[SHOWCMD_COLS] = NUL; // truncate |
7 | 1661 showcmd_visual = TRUE; |
1662 } | |
1663 else | |
1664 { | |
1665 showcmd_buf[0] = NUL; | |
1666 showcmd_visual = FALSE; | |
1667 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1668 // Don't actually display something if there is nothing to clear. |
7 | 1669 if (showcmd_is_clear) |
1670 return; | |
1671 } | |
1672 | |
1673 display_showcmd(); | |
1674 } | |
1675 | |
1676 /* | |
1677 * Add 'c' to string of shown command chars. | |
1678 * Return TRUE if output has been written (and setcursor() has been called). | |
1679 */ | |
1680 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1681 add_to_showcmd(int c) |
7 | 1682 { |
1683 char_u *p; | |
1684 int old_len; | |
1685 int extra_len; | |
1686 int overflow; | |
1687 int i; | |
1688 static int ignore[] = | |
1689 { | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18291
diff
changeset
|
1690 #ifdef FEAT_GUI |
7 | 1691 K_VER_SCROLLBAR, K_HOR_SCROLLBAR, |
1692 K_LEFTMOUSE_NM, K_LEFTRELEASE_NM, | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18291
diff
changeset
|
1693 #endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
1694 K_IGNORE, K_PS, |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
1695 K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE, |
7 | 1696 K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE, |
1697 K_RIGHTMOUSE, K_RIGHTDRAG, K_RIGHTRELEASE, | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
1698 K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT, |
7 | 1699 K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE, |
631 | 1700 K_CURSORHOLD, |
7 | 1701 0 |
1702 }; | |
1703 | |
641 | 1704 if (!p_sc || msg_silent != 0) |
7 | 1705 return FALSE; |
1706 | |
1707 if (showcmd_visual) | |
1708 { | |
1709 showcmd_buf[0] = NUL; | |
1710 showcmd_visual = FALSE; | |
1711 } | |
1712 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1713 // Ignore keys that are scrollbar updates and mouse clicks |
7 | 1714 if (IS_SPECIAL(c)) |
1715 for (i = 0; ignore[i] != 0; ++i) | |
1716 if (ignore[i] == c) | |
1717 return FALSE; | |
1718 | |
1719 p = transchar(c); | |
5535 | 1720 if (*p == ' ') |
1721 STRCPY(p, "<20>"); | |
7 | 1722 old_len = (int)STRLEN(showcmd_buf); |
1723 extra_len = (int)STRLEN(p); | |
1724 overflow = old_len + extra_len - SHOWCMD_COLS; | |
1725 if (overflow > 0) | |
1362 | 1726 mch_memmove(showcmd_buf, showcmd_buf + overflow, |
1727 old_len - overflow + 1); | |
7 | 1728 STRCAT(showcmd_buf, p); |
1729 | |
1730 if (char_avail()) | |
1731 return FALSE; | |
1732 | |
1733 display_showcmd(); | |
1734 | |
1735 return TRUE; | |
1736 } | |
1737 | |
1738 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1739 add_to_showcmd_c(int c) |
7 | 1740 { |
1741 if (!add_to_showcmd(c)) | |
1742 setcursor(); | |
1743 } | |
1744 | |
1745 /* | |
1746 * Delete 'len' characters from the end of the shown command. | |
1747 */ | |
1748 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1749 del_from_showcmd(int len) |
7 | 1750 { |
1751 int old_len; | |
1752 | |
1753 if (!p_sc) | |
1754 return; | |
1755 | |
1756 old_len = (int)STRLEN(showcmd_buf); | |
1757 if (len > old_len) | |
1758 len = old_len; | |
1759 showcmd_buf[old_len - len] = NUL; | |
1760 | |
1761 if (!char_avail()) | |
1762 display_showcmd(); | |
1763 } | |
1764 | |
1765 /* | |
1766 * push_showcmd() and pop_showcmd() are used when waiting for the user to type | |
1767 * something and there is a partial mapping. | |
1768 */ | |
1769 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1770 push_showcmd(void) |
7 | 1771 { |
1772 if (p_sc) | |
1773 STRCPY(old_showcmd_buf, showcmd_buf); | |
1774 } | |
1775 | |
1776 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1777 pop_showcmd(void) |
7 | 1778 { |
1779 if (!p_sc) | |
1780 return; | |
1781 | |
1782 STRCPY(showcmd_buf, old_showcmd_buf); | |
1783 | |
1784 display_showcmd(); | |
1785 } | |
1786 | |
1787 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1788 display_showcmd(void) |
7 | 1789 { |
1790 int len; | |
1791 | |
1792 cursor_off(); | |
1793 | |
1794 len = (int)STRLEN(showcmd_buf); | |
1795 if (len == 0) | |
1796 showcmd_is_clear = TRUE; | |
1797 else | |
1798 { | |
1799 screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0); | |
1800 showcmd_is_clear = FALSE; | |
1801 } | |
1802 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1803 // clear the rest of an old message by outputting up to SHOWCMD_COLS |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1804 // spaces |
7 | 1805 screen_puts((char_u *)" " + len, (int)Rows - 1, sc_col + len, 0); |
1806 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1807 setcursor(); // put cursor back where it belongs |
7 | 1808 } |
1809 #endif | |
1810 | |
1811 /* | |
1812 * When "check" is FALSE, prepare for commands that scroll the window. | |
1813 * When "check" is TRUE, take care of scroll-binding after the window has | |
1814 * scrolled. Called from normal_cmd() and edit(). | |
1815 */ | |
1816 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1817 do_check_scrollbind(int check) |
7 | 1818 { |
1819 static win_T *old_curwin = NULL; | |
1820 static linenr_T old_topline = 0; | |
1821 #ifdef FEAT_DIFF | |
1822 static int old_topfill = 0; | |
1823 #endif | |
1824 static buf_T *old_buf = NULL; | |
1825 static colnr_T old_leftcol = 0; | |
1826 | |
1827 if (check && curwin->w_p_scb) | |
1828 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1829 // If a ":syncbind" command was just used, don't scroll, only reset |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1830 // the values. |
7 | 1831 if (did_syncbind) |
1832 did_syncbind = FALSE; | |
1833 else if (curwin == old_curwin) | |
1834 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1835 // Synchronize other windows, as necessary according to |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1836 // 'scrollbind'. Don't do this after an ":edit" command, except |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1837 // when 'diff' is set. |
7 | 1838 if ((curwin->w_buffer == old_buf |
1839 #ifdef FEAT_DIFF | |
1840 || curwin->w_p_diff | |
1841 #endif | |
1842 ) | |
1843 && (curwin->w_topline != old_topline | |
1844 #ifdef FEAT_DIFF | |
1845 || curwin->w_topfill != old_topfill | |
1846 #endif | |
1847 || curwin->w_leftcol != old_leftcol)) | |
1848 { | |
1849 check_scrollbind(curwin->w_topline - old_topline, | |
1850 (long)(curwin->w_leftcol - old_leftcol)); | |
1851 } | |
1852 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1853 else if (vim_strchr(p_sbo, 'j')) // jump flag set in 'scrollopt' |
7 | 1854 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1855 // When switching between windows, make sure that the relative |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1856 // vertical offset is valid for the new window. The relative |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1857 // offset is invalid whenever another 'scrollbind' window has |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1858 // scrolled to a point that would force the current window to |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1859 // scroll past the beginning or end of its buffer. When the |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1860 // resync is performed, some of the other 'scrollbind' windows may |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1861 // need to jump so that the current window's relative position is |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1862 // visible on-screen. |
7 | 1863 check_scrollbind(curwin->w_topline - curwin->w_scbind_pos, 0L); |
1864 } | |
1865 curwin->w_scbind_pos = curwin->w_topline; | |
1866 } | |
1867 | |
1868 old_curwin = curwin; | |
1869 old_topline = curwin->w_topline; | |
1870 #ifdef FEAT_DIFF | |
1871 old_topfill = curwin->w_topfill; | |
1872 #endif | |
1873 old_buf = curwin->w_buffer; | |
1874 old_leftcol = curwin->w_leftcol; | |
1875 } | |
1876 | |
1877 /* | |
1878 * Synchronize any windows that have "scrollbind" set, based on the | |
1879 * number of rows by which the current window has changed | |
1880 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
1881 */ | |
1882 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1883 check_scrollbind(linenr_T topline_diff, long leftcol_diff) |
7 | 1884 { |
1885 int want_ver; | |
1886 int want_hor; | |
1887 win_T *old_curwin = curwin; | |
1888 buf_T *old_curbuf = curbuf; | |
1889 int old_VIsual_select = VIsual_select; | |
1890 int old_VIsual_active = VIsual_active; | |
1891 colnr_T tgt_leftcol = curwin->w_leftcol; | |
1892 long topline; | |
1893 long y; | |
1894 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1895 // check 'scrollopt' string for vertical and horizontal scroll options |
7 | 1896 want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0); |
1897 #ifdef FEAT_DIFF | |
1898 want_ver |= old_curwin->w_p_diff; | |
1899 #endif | |
1900 want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0)); | |
1901 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1902 // loop through the scrollbound windows and scroll accordingly |
7 | 1903 VIsual_select = VIsual_active = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
1904 FOR_ALL_WINDOWS(curwin) |
7 | 1905 { |
1906 curbuf = curwin->w_buffer; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1907 // skip original window and windows with 'noscrollbind' |
7 | 1908 if (curwin != old_curwin && curwin->w_p_scb) |
1909 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1910 // do the vertical scroll |
7 | 1911 if (want_ver) |
1912 { | |
1913 #ifdef FEAT_DIFF | |
1914 if (old_curwin->w_p_diff && curwin->w_p_diff) | |
1915 { | |
1916 diff_set_topline(old_curwin, curwin); | |
1917 } | |
1918 else | |
1919 #endif | |
1920 { | |
1921 curwin->w_scbind_pos += topline_diff; | |
1922 topline = curwin->w_scbind_pos; | |
1923 if (topline > curbuf->b_ml.ml_line_count) | |
1924 topline = curbuf->b_ml.ml_line_count; | |
1925 if (topline < 1) | |
1926 topline = 1; | |
1927 | |
1928 y = topline - curwin->w_topline; | |
1929 if (y > 0) | |
1930 scrollup(y, FALSE); | |
1931 else | |
1932 scrolldown(-y, FALSE); | |
1933 } | |
1934 | |
1935 redraw_later(VALID); | |
1936 cursor_correct(); | |
1937 curwin->w_redr_status = TRUE; | |
1938 } | |
1939 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1940 // do the horizontal scroll |
7 | 1941 if (want_hor && curwin->w_leftcol != tgt_leftcol) |
1942 { | |
1943 curwin->w_leftcol = tgt_leftcol; | |
1944 leftcol_changed(); | |
1945 } | |
1946 } | |
1947 } | |
1948 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1949 // reset current-window |
7 | 1950 VIsual_select = old_VIsual_select; |
1951 VIsual_active = old_VIsual_active; | |
1952 curwin = old_curwin; | |
1953 curbuf = old_curbuf; | |
1954 } | |
1955 | |
1956 /* | |
1957 * Command character that's ignored. | |
1958 * Used for CTRL-Q and CTRL-S to avoid problems with terminals that use | |
2130
279380a812ad
updated for version 7.2.412
Bram Moolenaar <bram@zimbu.org>
parents:
2112
diff
changeset
|
1959 * xon/xoff. |
7 | 1960 */ |
1961 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1962 nv_ignore(cmdarg_T *cap) |
7 | 1963 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1964 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
7 | 1965 } |
1966 | |
1967 /* | |
620 | 1968 * Command character that doesn't do anything, but unlike nv_ignore() does |
1969 * start edit(). Used for "startinsert" executed while starting up. | |
1970 */ | |
1971 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1972 nv_nop(cmdarg_T *cap UNUSED) |
620 | 1973 { |
1974 } | |
1975 | |
1976 /* | |
7 | 1977 * Command character doesn't exist. |
1978 */ | |
1979 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1980 nv_error(cmdarg_T *cap) |
7 | 1981 { |
1982 clearopbeep(cap->oap); | |
1983 } | |
1984 | |
1985 /* | |
1986 * <Help> and <F1> commands. | |
1987 */ | |
1988 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1989 nv_help(cmdarg_T *cap) |
7 | 1990 { |
1991 if (!checkclearopq(cap->oap)) | |
1992 ex_help(NULL); | |
1993 } | |
1994 | |
1995 /* | |
1996 * CTRL-A and CTRL-X: Add or subtract from letter or number under cursor. | |
1997 */ | |
1998 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1999 nv_addsub(cmdarg_T *cap) |
7 | 2000 { |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2001 #ifdef FEAT_JOB_CHANNEL |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2002 if (bt_prompt(curbuf) && !prompt_curpos_editable()) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2003 clearopbeep(cap->oap); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2004 else |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
2005 #endif |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2006 if (!VIsual_active && cap->oap->op_type == OP_NOP) |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2007 { |
7578
fdae4c496775
commit https://github.com/vim/vim/commit/ef2b5036b3005f1ce15d146dce72379a9834c56d
Christian Brabandt <cb@256bit.org>
parents:
7574
diff
changeset
|
2008 prep_redo_cmd(cap); |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2009 cap->oap->op_type = cap->cmdchar == Ctrl_A ? OP_NR_ADD : OP_NR_SUB; |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2010 op_addsub(cap->oap, cap->count1, cap->arg); |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2011 cap->oap->op_type = OP_NOP; |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2012 } |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2013 else if (VIsual_active) |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2014 nv_operator(cap); |
6868 | 2015 else |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2016 clearop(cap->oap); |
7 | 2017 } |
2018 | |
2019 /* | |
2020 * CTRL-F, CTRL-B, etc: Scroll page up or down. | |
2021 */ | |
2022 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2023 nv_page(cmdarg_T *cap) |
7 | 2024 { |
2025 if (!checkclearop(cap->oap)) | |
819 | 2026 { |
2027 if (mod_mask & MOD_MASK_CTRL) | |
2028 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2029 // <C-PageUp>: tab page back; <C-PageDown>: tab page forward |
819 | 2030 if (cap->arg == BACKWARD) |
2031 goto_tabpage(-(int)cap->count1); | |
2032 else | |
2033 goto_tabpage((int)cap->count0); | |
2034 } | |
2035 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12467
diff
changeset
|
2036 (void)onepage(cap->arg, cap->count1); |
819 | 2037 } |
7 | 2038 } |
2039 | |
2040 /* | |
2041 * Implementation of "gd" and "gD" command. | |
2042 */ | |
2043 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2044 nv_gd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2045 oparg_T *oap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2046 int nchar, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2047 int thisblock) // 1 for "1gd" and "1gD" |
7 | 2048 { |
2049 int len; | |
503 | 2050 char_u *ptr; |
2051 | |
2052 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0 | |
8923
face93b02af4
commit https://github.com/vim/vim/commit/1538fc34fae3fae39773ca43f6ff52401fce61d8
Christian Brabandt <cb@256bit.org>
parents:
8651
diff
changeset
|
2053 || find_decl(ptr, len, nchar == 'd', thisblock, SEARCH_START) |
26101
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2054 == FAIL) |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2055 { |
503 | 2056 clearopbeep(oap); |
26101
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2057 } |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2058 else |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2059 { |
503 | 2060 #ifdef FEAT_FOLDING |
26101
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2061 if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2062 foldOpenCursor(); |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2063 #endif |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2064 // clear any search statistics |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2065 if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT)) |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2066 clear_cmdline = TRUE; |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2067 } |
503 | 2068 } |
2069 | |
2070 /* | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2071 * Return TRUE if line[offset] is not inside a C-style comment or string, FALSE |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2072 * otherwise. |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2073 */ |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2074 static int |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2075 is_ident(char_u *line, int offset) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2076 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2077 int i; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2078 int incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2079 int instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2080 int prev = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2081 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2082 for (i = 0; i < offset && line[i] != NUL; i++) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2083 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2084 if (instring != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2085 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2086 if (prev != '\\' && line[i] == instring) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2087 instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2088 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2089 else if ((line[i] == '"' || line[i] == '\'') && !incomment) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2090 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2091 instring = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2092 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2093 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2094 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2095 if (incomment) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2096 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2097 if (prev == '*' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2098 incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2099 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2100 else if (prev == '/' && line[i] == '*') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2101 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2102 incomment = TRUE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2103 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2104 else if (prev == '/' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2105 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2106 return FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2107 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2108 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2109 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2110 prev = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2111 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2112 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2113 return incomment == FALSE && instring == 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2114 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2115 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2116 /* |
523 | 2117 * Search for variable declaration of "ptr[len]". |
2118 * When "locally" is TRUE in the current function ("gd"), otherwise in the | |
2119 * current file ("gD"). | |
2120 * When "thisblock" is TRUE check the {} block scope. | |
503 | 2121 * Return FAIL when not found. |
2122 */ | |
2123 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2124 find_decl( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2125 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2126 int len, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2127 int locally, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2128 int thisblock, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2129 int flags_arg) // flags passed to searchit() |
503 | 2130 { |
7 | 2131 char_u *pat; |
2132 pos_T old_pos; | |
503 | 2133 pos_T par_pos; |
2134 pos_T found_pos; | |
7 | 2135 int t; |
2136 int save_p_ws; | |
2137 int save_p_scs; | |
503 | 2138 int retval = OK; |
944 | 2139 int incll; |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2140 int searchflags = flags_arg; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2141 int valid; |
503 | 2142 |
2143 if ((pat = alloc(len + 7)) == NULL) | |
2144 return FAIL; | |
268 | 2145 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2146 // Put "\V" before the pattern to avoid that the special meaning of "." |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2147 // and "~" causes trouble. |
268 | 2148 sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", |
2149 len, ptr); | |
7 | 2150 old_pos = curwin->w_cursor; |
2151 save_p_ws = p_ws; | |
2152 save_p_scs = p_scs; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2153 p_ws = FALSE; // don't wrap around end of file now |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2154 p_scs = FALSE; // don't switch ignorecase off now |
7 | 2155 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2156 // With "gD" go to line 1. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2157 // With "gd" Search back for the start of the current function, then go |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2158 // back until a blank line. If this fails go to line 1. |
944 | 2159 if (!locally || !findpar(&incll, BACKWARD, 1L, '{', FALSE)) |
7 | 2160 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2161 setpcmark(); // Set in findpar() otherwise |
7 | 2162 curwin->w_cursor.lnum = 1; |
539 | 2163 par_pos = curwin->w_cursor; |
7 | 2164 } |
2165 else | |
2166 { | |
539 | 2167 par_pos = curwin->w_cursor; |
7 | 2168 while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL) |
2169 --curwin->w_cursor.lnum; | |
2170 } | |
2171 curwin->w_cursor.col = 0; | |
2172 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2173 // Search forward for the identifier, ignore comment lines. |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
2174 CLEAR_POS(&found_pos); |
503 | 2175 for (;;) |
2176 { | |
15239
db5d2429bda3
patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents:
15062
diff
changeset
|
2177 t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
2178 pat, 1L, searchflags, RE_LAST, NULL); |
503 | 2179 if (curwin->w_cursor.lnum >= old_pos.lnum) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2180 t = FAIL; // match after start is failure too |
523 | 2181 |
718 | 2182 if (thisblock && t != FAIL) |
523 | 2183 { |
2184 pos_T *pos; | |
2185 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2186 // Check that the block the match is in doesn't end before the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2187 // position where we started the search from. |
523 | 2188 if ((pos = findmatchlimit(NULL, '}', FM_FORWARD, |
2189 (int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL | |
2190 && pos->lnum < old_pos.lnum) | |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2191 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2192 // There can't be a useful match before the end of this block. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2193 // Skip to the end. |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2194 curwin->w_cursor = *pos; |
523 | 2195 continue; |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2196 } |
523 | 2197 } |
2198 | |
503 | 2199 if (t == FAIL) |
2200 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2201 // If we previously found a valid position, use it. |
503 | 2202 if (found_pos.lnum != 0) |
2203 { | |
2204 curwin->w_cursor = found_pos; | |
2205 t = OK; | |
2206 } | |
2207 break; | |
2208 } | |
3562 | 2209 if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0) |
503 | 2210 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2211 // Ignore this line, continue at start of next line. |
503 | 2212 ++curwin->w_cursor.lnum; |
2213 curwin->w_cursor.col = 0; | |
2214 continue; | |
2215 } | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2216 valid = is_ident(ml_get_curline(), curwin->w_cursor.col); |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2217 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2218 // If the current position is not a valid identifier and a previous |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2219 // match is present, favor that one instead. |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2220 if (!valid && found_pos.lnum != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2221 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2222 curwin->w_cursor = found_pos; |
503 | 2223 break; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2224 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2225 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2226 // Global search: use first valid match found |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2227 if (valid && !locally) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2228 break; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2229 if (valid && curwin->w_cursor.lnum >= par_pos.lnum) |
503 | 2230 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2231 // If we previously found a valid position, use it. |
503 | 2232 if (found_pos.lnum != 0) |
2233 curwin->w_cursor = found_pos; | |
2234 break; | |
2235 } | |
2236 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2237 // For finding a local variable and the match is before the "{" or |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2238 // inside a comment, continue searching. For K&R style function |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2239 // declarations this skips the function header without types. |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2240 if (!valid) |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
2241 CLEAR_POS(&found_pos); |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2242 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2243 found_pos = curwin->w_cursor; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2244 // Remove SEARCH_START from flags to avoid getting stuck at one |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2245 // position. |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2246 searchflags &= ~SEARCH_START; |
503 | 2247 } |
2248 | |
2249 if (t == FAIL) | |
2250 { | |
2251 retval = FAIL; | |
7 | 2252 curwin->w_cursor = old_pos; |
2253 } | |
2254 else | |
2255 { | |
2256 curwin->w_set_curswant = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2257 // "n" searches forward now |
7 | 2258 reset_search_dir(); |
2259 } | |
2260 | |
2261 vim_free(pat); | |
2262 p_ws = save_p_ws; | |
2263 p_scs = save_p_scs; | |
503 | 2264 |
2265 return retval; | |
7 | 2266 } |
2267 | |
2268 /* | |
2269 * Move 'dist' lines in direction 'dir', counting lines by *screen* | |
2270 * lines rather than lines in the file. | |
2271 * 'dist' must be positive. | |
2272 * | |
2273 * Return OK if able to move cursor, FAIL otherwise. | |
2274 */ | |
2275 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2276 nv_screengo(oparg_T *oap, int dir, long dist) |
7 | 2277 { |
2278 int linelen = linetabsize(ml_get_curline()); | |
2279 int retval = OK; | |
2280 int atend = FALSE; | |
2281 int n; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2282 int col_off1; // margin offset for first screen line |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2283 int col_off2; // margin offset for wrapped screen line |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2284 int width1; // text width for first screen line |
26094
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2285 int width2; // text width for wrapped screen line |
7 | 2286 |
2287 oap->motion_type = MCHAR; | |
5192
c28202427d71
updated for version 7.4a.022
Bram Moolenaar <bram@vim.org>
parents:
5162
diff
changeset
|
2288 oap->inclusive = (curwin->w_curswant == MAXCOL); |
7 | 2289 |
2290 col_off1 = curwin_col_off(); | |
2291 col_off2 = col_off1 - curwin_col_off2(); | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2292 width1 = curwin->w_width - col_off1; |
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2293 width2 = curwin->w_width - col_off2; |
6559 | 2294 if (width2 == 0) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2295 width2 = 1; // avoid divide by zero |
7 | 2296 |
2297 if (curwin->w_width != 0) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2298 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2299 // Instead of sticking at the last character of the buffer line we |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2300 // try to stick in the last column of the screen. |
7 | 2301 if (curwin->w_curswant == MAXCOL) |
2302 { | |
2303 atend = TRUE; | |
2304 validate_virtcol(); | |
2305 if (width1 <= 0) | |
2306 curwin->w_curswant = 0; | |
2307 else | |
2308 { | |
2309 curwin->w_curswant = width1 - 1; | |
2310 if (curwin->w_virtcol > curwin->w_curswant) | |
2311 curwin->w_curswant += ((curwin->w_virtcol | |
2312 - curwin->w_curswant - 1) / width2 + 1) * width2; | |
2313 } | |
2314 } | |
2315 else | |
2316 { | |
2317 if (linelen > width1) | |
2318 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2319 else | |
2320 n = width1; | |
18291
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2321 if (curwin->w_curswant >= (colnr_T)n) |
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2322 curwin->w_curswant = n - 1; |
7 | 2323 } |
2324 | |
2325 while (dist--) | |
2326 { | |
2327 if (dir == BACKWARD) | |
2328 { | |
24341
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2329 if ((long)curwin->w_curswant >= width1 |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2330 #ifdef FEAT_FOLDING |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2331 && !hasFolding(curwin->w_cursor.lnum, NULL, NULL) |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2332 #endif |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2333 ) |
18291
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2334 // Move back within the line. This can give a negative value |
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2335 // for w_curswant if width1 < width2 (with cpoptions+=n), |
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2336 // which will get clipped to column 0. |
7 | 2337 curwin->w_curswant -= width2; |
2338 else | |
2339 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2340 // to previous line |
23687
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2341 #ifdef FEAT_FOLDING |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2342 // Move to the start of a closed fold. Don't do that when |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2343 // 'foldopen' contains "all": it will open in a moment. |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2344 if (!(fdo_flags & FDO_ALL)) |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2345 (void)hasFolding(curwin->w_cursor.lnum, |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2346 &curwin->w_cursor.lnum, NULL); |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2347 #endif |
7 | 2348 if (curwin->w_cursor.lnum == 1) |
2349 { | |
2350 retval = FAIL; | |
2351 break; | |
2352 } | |
2353 --curwin->w_cursor.lnum; | |
23687
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2354 |
7 | 2355 linelen = linetabsize(ml_get_curline()); |
2356 if (linelen > width1) | |
2357 curwin->w_curswant += (((linelen - width1 - 1) / width2) | |
2358 + 1) * width2; | |
2359 } | |
2360 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2361 else // dir == FORWARD |
7 | 2362 { |
2363 if (linelen > width1) | |
2364 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2365 else | |
2366 n = width1; | |
24341
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2367 if (curwin->w_curswant + width2 < (colnr_T)n |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2368 #ifdef FEAT_FOLDING |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2369 && !hasFolding(curwin->w_cursor.lnum, NULL, NULL) |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2370 #endif |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2371 ) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2372 // move forward within line |
7 | 2373 curwin->w_curswant += width2; |
2374 else | |
2375 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2376 // to next line |
7 | 2377 #ifdef FEAT_FOLDING |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2378 // Move to the end of a closed fold. |
7 | 2379 (void)hasFolding(curwin->w_cursor.lnum, NULL, |
2380 &curwin->w_cursor.lnum); | |
2381 #endif | |
2382 if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) | |
2383 { | |
2384 retval = FAIL; | |
2385 break; | |
2386 } | |
2387 curwin->w_cursor.lnum++; | |
2388 curwin->w_curswant %= width2; | |
18291
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2389 // Check if the cursor has moved below the number display |
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2390 // when width1 < width2 (with cpoptions+=n). Subtract width2 |
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2391 // to get a negative value for w_curswant, which will get |
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2392 // clipped to column 0. |
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2393 if (curwin->w_curswant >= width1) |
11f68eb58fda
patch 8.1.2140: "gk" and "gj" do not work correctly in number column
Bram Moolenaar <Bram@vim.org>
parents:
18219
diff
changeset
|
2394 curwin->w_curswant -= width2; |
2911 | 2395 linelen = linetabsize(ml_get_curline()); |
7 | 2396 } |
2397 } | |
2398 } | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2399 } |
7 | 2400 |
5600 | 2401 if (virtual_active() && atend) |
2402 coladvance(MAXCOL); | |
2403 else | |
2404 coladvance(curwin->w_curswant); | |
7 | 2405 |
2406 if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) | |
2407 { | |
6178 | 2408 colnr_T virtcol; |
26094
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2409 int c; |
6178 | 2410 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2411 // Check for landing on a character that got split at the end of the |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2412 // last line. We want to advance a screenline, not end up in the same |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2413 // screenline or move two screenlines. |
7 | 2414 validate_virtcol(); |
6178 | 2415 virtcol = curwin->w_virtcol; |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2416 #if defined(FEAT_LINEBREAK) |
18574
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18485
diff
changeset
|
2417 if (virtcol > (colnr_T)width1 && *get_showbreak_value(curwin) != NUL) |
8b0114ffde2b
patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents:
18485
diff
changeset
|
2418 virtcol -= vim_strsize(get_showbreak_value(curwin)); |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2419 #endif |
6178 | 2420 |
26094
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2421 c = (*mb_ptr2char)(ml_get_cursor()); |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2422 if (dir == FORWARD && virtcol < curwin->w_curswant |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2423 && (curwin->w_curswant <= (colnr_T)width1) |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2424 && !vim_isprintc(c) && c > 255) |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2425 oneright(); |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2426 |
6178 | 2427 if (virtcol > curwin->w_curswant |
7 | 2428 && (curwin->w_curswant < (colnr_T)width1 |
2429 ? (curwin->w_curswant > (colnr_T)width1 / 2) | |
2430 : ((curwin->w_curswant - width1) % width2 | |
2431 > (colnr_T)width2 / 2))) | |
2432 --curwin->w_cursor.col; | |
2433 } | |
2434 | |
2435 if (atend) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2436 curwin->w_curswant = MAXCOL; // stick in the last column |
7 | 2437 |
2438 return retval; | |
2439 } | |
2440 | |
2441 /* | |
2442 * Handle CTRL-E and CTRL-Y commands: scroll a line up or down. | |
2443 * cap->arg must be TRUE for CTRL-E. | |
2444 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
2445 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2446 nv_scroll_line(cmdarg_T *cap) |
7 | 2447 { |
2448 if (!checkclearop(cap->oap)) | |
2449 scroll_redraw(cap->arg, cap->count1); | |
2450 } | |
2451 | |
2452 /* | |
2453 * Scroll "count" lines up or down, and redraw. | |
2454 */ | |
2455 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2456 scroll_redraw(int up, long count) |
7 | 2457 { |
2458 linenr_T prev_topline = curwin->w_topline; | |
2459 #ifdef FEAT_DIFF | |
2460 int prev_topfill = curwin->w_topfill; | |
2461 #endif | |
2462 linenr_T prev_lnum = curwin->w_cursor.lnum; | |
2463 | |
2464 if (up) | |
2465 scrollup(count, TRUE); | |
2466 else | |
2467 scrolldown(count, TRUE); | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2468 if (get_scrolloff_value()) |
7 | 2469 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2470 // Adjust the cursor position for 'scrolloff'. Mark w_topline as |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2471 // valid, otherwise the screen jumps back at the end of the file. |
7 | 2472 cursor_correct(); |
2473 check_cursor_moved(curwin); | |
2474 curwin->w_valid |= VALID_TOPLINE; | |
2475 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2476 // If moved back to where we were, at least move the cursor, otherwise |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2477 // we get stuck at one position. Don't move the cursor up if the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2478 // first line of the buffer is already on the screen |
7 | 2479 while (curwin->w_topline == prev_topline |
2480 #ifdef FEAT_DIFF | |
2481 && curwin->w_topfill == prev_topfill | |
2482 #endif | |
2483 ) | |
2484 { | |
2485 if (up) | |
2486 { | |
2487 if (curwin->w_cursor.lnum > prev_lnum | |
2488 || cursor_down(1L, FALSE) == FAIL) | |
2489 break; | |
2490 } | |
2491 else | |
2492 { | |
2493 if (curwin->w_cursor.lnum < prev_lnum | |
2494 || prev_topline == 1L | |
2495 || cursor_up(1L, FALSE) == FAIL) | |
2496 break; | |
2497 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2498 // Mark w_topline as valid, otherwise the screen jumps back at the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2499 // end of the file. |
7 | 2500 check_cursor_moved(curwin); |
2501 curwin->w_valid |= VALID_TOPLINE; | |
2502 } | |
2503 } | |
2504 if (curwin->w_cursor.lnum != prev_lnum) | |
2505 coladvance(curwin->w_curswant); | |
2506 redraw_later(VALID); | |
2507 } | |
2508 | |
2509 /* | |
27400
722db0819111
patch 8.2.4228: no tests for clicking in the GUI tabline
Bram Moolenaar <Bram@vim.org>
parents:
27386
diff
changeset
|
2510 * Get the count specified after a 'z' command. Only the 'z<CR>', 'zl', 'zh', |
722db0819111
patch 8.2.4228: no tests for clicking in the GUI tabline
Bram Moolenaar <Bram@vim.org>
parents:
27386
diff
changeset
|
2511 * 'z<Left>', and 'z<Right>' commands accept a count after 'z'. |
722db0819111
patch 8.2.4228: no tests for clicking in the GUI tabline
Bram Moolenaar <Bram@vim.org>
parents:
27386
diff
changeset
|
2512 * Returns TRUE to process the 'z' command and FALSE to skip it. |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2513 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2514 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2515 nv_z_get_count(cmdarg_T *cap, int *nchar_arg) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2516 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2517 int nchar = *nchar_arg; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2518 long n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2519 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2520 // "z123{nchar}": edit the count before obtaining {nchar} |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2521 if (checkclearop(cap->oap)) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2522 return FALSE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2523 n = nchar - '0'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2524 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2525 for (;;) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2526 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2527 #ifdef USE_ON_FLY_SCROLL |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2528 dont_scroll = TRUE; // disallow scrolling here |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2529 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2530 ++no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2531 ++allow_keys; // no mapping for nchar, but allow key codes |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2532 nchar = plain_vgetc(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2533 LANGMAP_ADJUST(nchar, TRUE); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2534 --no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2535 --allow_keys; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2536 #ifdef FEAT_CMDL_INFO |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2537 (void)add_to_showcmd(nchar); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2538 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2539 if (nchar == K_DEL || nchar == K_KDEL) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2540 n /= 10; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2541 else if (VIM_ISDIGIT(nchar)) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2542 n = n * 10 + (nchar - '0'); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2543 else if (nchar == CAR) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2544 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2545 #ifdef FEAT_GUI |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2546 need_mouse_correct = TRUE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2547 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2548 win_setheight((int)n); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2549 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2550 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2551 else if (nchar == 'l' |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2552 || nchar == 'h' |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2553 || nchar == K_LEFT |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2554 || nchar == K_RIGHT) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2555 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2556 cap->count1 = n ? n * cap->count1 : cap->count1; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2557 *nchar_arg = nchar; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2558 return TRUE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2559 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2560 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2561 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2562 clearopbeep(cap->oap); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2563 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2564 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2565 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2566 cap->oap->op_type = OP_NOP; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2567 return FALSE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2568 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2569 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2570 #ifdef FEAT_SPELL |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2571 /* |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2572 * "zug" and "zuw": undo "zg" and "zw" |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2573 * "zg": add good word to word list |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2574 * "zw": add wrong word to word list |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2575 * "zG": add good word to temp word list |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2576 * "zW": add wrong word to temp word list |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2577 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2578 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2579 nv_zg_zw(cmdarg_T *cap, int nchar) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2580 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2581 char_u *ptr = NULL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2582 int len; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2583 int undo = FALSE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2584 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2585 if (nchar == 'u') |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2586 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2587 ++no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2588 ++allow_keys; // no mapping for nchar, but allow key codes |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2589 nchar = plain_vgetc(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2590 LANGMAP_ADJUST(nchar, TRUE); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2591 --no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2592 --allow_keys; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2593 #ifdef FEAT_CMDL_INFO |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2594 (void)add_to_showcmd(nchar); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2595 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2596 if (vim_strchr((char_u *)"gGwW", nchar) == NULL) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2597 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2598 clearopbeep(cap->oap); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2599 return OK; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2600 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2601 undo = TRUE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2602 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2603 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2604 if (checkclearop(cap->oap)) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2605 return OK; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2606 if (VIsual_active && get_visual_text(cap, &ptr, &len) == FAIL) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2607 return FAIL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2608 if (ptr == NULL) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2609 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2610 pos_T pos = curwin->w_cursor; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2611 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2612 // Find bad word under the cursor. When 'spell' is |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2613 // off this fails and find_ident_under_cursor() is |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2614 // used below. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2615 emsg_off++; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2616 len = spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2617 emsg_off--; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2618 if (len != 0 && curwin->w_cursor.col <= pos.col) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2619 ptr = ml_get_pos(&curwin->w_cursor); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2620 curwin->w_cursor = pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2621 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2622 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2623 if (ptr == NULL |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2624 && (len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2625 return FAIL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2626 spell_add_word(ptr, len, nchar == 'w' || nchar == 'W' |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2627 ? SPELL_ADD_BAD : SPELL_ADD_GOOD, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2628 (nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1, undo); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2629 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2630 return OK; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2631 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2632 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2633 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2634 /* |
7 | 2635 * Commands that start with "z". |
2636 */ | |
2637 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2638 nv_zet(cmdarg_T *cap) |
7 | 2639 { |
2640 long n; | |
2641 colnr_T col; | |
2642 int nchar = cap->nchar; | |
2643 #ifdef FEAT_FOLDING | |
2644 long old_fdl = curwin->w_p_fdl; | |
2645 int old_fen = curwin->w_p_fen; | |
2646 #endif | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2647 long siso = get_sidescrolloff_value(); |
7 | 2648 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2649 if (VIM_ISDIGIT(nchar) && !nv_z_get_count(cap, &nchar)) |
7 | 2650 return; |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2651 |
7 | 2652 if ( |
2653 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2654 // "zf" and "zF" are always an operator, "zd", "zo", "zO", "zc" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2655 // and "zC" only in Visual mode. "zj" and "zk" are motion |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2656 // commands. |
7 | 2657 cap->nchar != 'f' && cap->nchar != 'F' |
2658 && !(VIsual_active && vim_strchr((char_u *)"dcCoO", cap->nchar)) | |
2659 && cap->nchar != 'j' && cap->nchar != 'k' | |
2660 && | |
2661 #endif | |
2662 checkclearop(cap->oap)) | |
2663 return; | |
2664 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2665 // For "z+", "z<CR>", "zt", "z.", "zz", "z^", "z-", "zb": |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2666 // If line number given, set cursor. |
7 | 2667 if ((vim_strchr((char_u *)"+\r\nt.z^-b", nchar) != NULL) |
2668 && cap->count0 | |
2669 && cap->count0 != curwin->w_cursor.lnum) | |
2670 { | |
2671 setpcmark(); | |
2672 if (cap->count0 > curbuf->b_ml.ml_line_count) | |
2673 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2674 else | |
2675 curwin->w_cursor.lnum = cap->count0; | |
22 | 2676 check_cursor_col(); |
7 | 2677 } |
2678 | |
2679 switch (nchar) | |
2680 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2681 // "z+", "z<CR>" and "zt": put cursor at top of screen |
7 | 2682 case '+': |
2683 if (cap->count0 == 0) | |
2684 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2685 // No count given: put cursor at the line below screen |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2686 validate_botline(); // make sure w_botline is valid |
7 | 2687 if (curwin->w_botline > curbuf->b_ml.ml_line_count) |
2688 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2689 else | |
2690 curwin->w_cursor.lnum = curwin->w_botline; | |
2691 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2692 // FALLTHROUGH |
7 | 2693 case NL: |
2694 case CAR: | |
2695 case K_KENTER: | |
2696 beginline(BL_WHITE | BL_FIX); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2697 // FALLTHROUGH |
7 | 2698 |
2699 case 't': scroll_cursor_top(0, TRUE); | |
2700 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2701 set_fraction(curwin); |
7 | 2702 break; |
2703 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2704 // "z." and "zz": put cursor in middle of screen |
7 | 2705 case '.': beginline(BL_WHITE | BL_FIX); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2706 // FALLTHROUGH |
7 | 2707 |
2708 case 'z': scroll_cursor_halfway(TRUE); | |
2709 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2710 set_fraction(curwin); |
7 | 2711 break; |
2712 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2713 // "z^", "z-" and "zb": put cursor at bottom of screen |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2714 case '^': // Strange Vi behavior: <count>z^ finds line at top of window |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2715 // when <count> is at bottom of window, and puts that one at |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2716 // bottom of window. |
7 | 2717 if (cap->count0 != 0) |
2718 { | |
2719 scroll_cursor_bot(0, TRUE); | |
2720 curwin->w_cursor.lnum = curwin->w_topline; | |
2721 } | |
2722 else if (curwin->w_topline == 1) | |
2723 curwin->w_cursor.lnum = 1; | |
2724 else | |
2725 curwin->w_cursor.lnum = curwin->w_topline - 1; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2726 // FALLTHROUGH |
7 | 2727 case '-': |
2728 beginline(BL_WHITE | BL_FIX); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2729 // FALLTHROUGH |
7 | 2730 |
2731 case 'b': scroll_cursor_bot(0, TRUE); | |
2732 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2733 set_fraction(curwin); |
7 | 2734 break; |
2735 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2736 // "zH" - scroll screen right half-page |
7 | 2737 case 'H': |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2738 cap->count1 *= curwin->w_width / 2; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2739 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2740 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2741 // "zh" - scroll screen to the right |
7 | 2742 case 'h': |
2743 case K_LEFT: | |
2744 if (!curwin->w_p_wrap) | |
2745 { | |
2746 if ((colnr_T)cap->count1 > curwin->w_leftcol) | |
2747 curwin->w_leftcol = 0; | |
2748 else | |
2749 curwin->w_leftcol -= (colnr_T)cap->count1; | |
2750 leftcol_changed(); | |
2751 } | |
2752 break; | |
2753 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2754 // "zL" - scroll screen left half-page |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2755 case 'L': cap->count1 *= curwin->w_width / 2; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2756 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2757 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2758 // "zl" - scroll screen to the left |
7 | 2759 case 'l': |
2760 case K_RIGHT: | |
2761 if (!curwin->w_p_wrap) | |
2762 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2763 // scroll the window left |
7 | 2764 curwin->w_leftcol += (colnr_T)cap->count1; |
2765 leftcol_changed(); | |
2766 } | |
2767 break; | |
2768 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2769 // "zs" - scroll screen, cursor at the start |
7 | 2770 case 's': if (!curwin->w_p_wrap) |
2771 { | |
2772 #ifdef FEAT_FOLDING | |
2773 if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2774 col = 0; // like the cursor is in col 0 |
7 | 2775 else |
2776 #endif | |
2777 getvcol(curwin, &curwin->w_cursor, &col, NULL, NULL); | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2778 if ((long)col > siso) |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2779 col -= siso; |
7 | 2780 else |
2781 col = 0; | |
2782 if (curwin->w_leftcol != col) | |
2783 { | |
2784 curwin->w_leftcol = col; | |
2785 redraw_later(NOT_VALID); | |
2786 } | |
2787 } | |
2788 break; | |
2789 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2790 // "ze" - scroll screen, cursor at the end |
7 | 2791 case 'e': if (!curwin->w_p_wrap) |
2792 { | |
2793 #ifdef FEAT_FOLDING | |
2794 if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2795 col = 0; // like the cursor is in col 0 |
7 | 2796 else |
2797 #endif | |
2798 getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col); | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2799 n = curwin->w_width - curwin_col_off(); |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2800 if ((long)col + siso < n) |
7 | 2801 col = 0; |
2802 else | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2803 col = col + siso - n + 1; |
7 | 2804 if (curwin->w_leftcol != col) |
2805 { | |
2806 curwin->w_leftcol = col; | |
2807 redraw_later(NOT_VALID); | |
2808 } | |
2809 } | |
2810 break; | |
2811 | |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
2812 // "zp", "zP" in block mode put without addind trailing spaces |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
2813 case 'P': |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
2814 case 'p': nv_put(cap); |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
2815 break; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24800
diff
changeset
|
2816 // "zy" Yank without trailing spaces |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24800
diff
changeset
|
2817 case 'y': nv_operator(cap); |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24800
diff
changeset
|
2818 break; |
7 | 2819 #ifdef FEAT_FOLDING |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2820 // "zF": create fold command |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2821 // "zf": create fold operator |
7 | 2822 case 'F': |
2823 case 'f': if (foldManualAllowed(TRUE)) | |
2824 { | |
2825 cap->nchar = 'f'; | |
2826 nv_operator(cap); | |
2827 curwin->w_p_fen = TRUE; | |
2828 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2829 // "zF" is like "zfzf" |
7 | 2830 if (nchar == 'F' && cap->oap->op_type == OP_FOLD) |
2831 { | |
2832 nv_operator(cap); | |
2833 finish_op = TRUE; | |
2834 } | |
2835 } | |
2836 else | |
2837 clearopbeep(cap->oap); | |
2838 break; | |
2839 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2840 // "zd": delete fold at cursor |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2841 // "zD": delete fold at cursor recursively |
7 | 2842 case 'd': |
2843 case 'D': if (foldManualAllowed(FALSE)) | |
2844 { | |
2845 if (VIsual_active) | |
2846 nv_operator(cap); | |
2847 else | |
2848 deleteFold(curwin->w_cursor.lnum, | |
2849 curwin->w_cursor.lnum, nchar == 'D', FALSE); | |
2850 } | |
2851 break; | |
2852 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2853 // "zE": erase all folds |
7 | 2854 case 'E': if (foldmethodIsManual(curwin)) |
2855 { | |
2856 clearFolding(curwin); | |
2857 changed_window_setting(); | |
2858 } | |
2859 else if (foldmethodIsMarker(curwin)) | |
2860 deleteFold((linenr_T)1, curbuf->b_ml.ml_line_count, | |
2861 TRUE, FALSE); | |
2862 else | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26909
diff
changeset
|
2863 emsg(_(e_cannot_erase_folds_with_current_foldmethod)); |
7 | 2864 break; |
2865 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2866 // "zn": fold none: reset 'foldenable' |
7 | 2867 case 'n': curwin->w_p_fen = FALSE; |
2868 break; | |
2869 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2870 // "zN": fold Normal: set 'foldenable' |
7 | 2871 case 'N': curwin->w_p_fen = TRUE; |
2872 break; | |
2873 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2874 // "zi": invert folding: toggle 'foldenable' |
7 | 2875 case 'i': curwin->w_p_fen = !curwin->w_p_fen; |
2876 break; | |
2877 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2878 // "za": open closed fold or close open fold at cursor |
7 | 2879 case 'a': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
2880 openFold(curwin->w_cursor.lnum, cap->count1); | |
2881 else | |
2882 { | |
2883 closeFold(curwin->w_cursor.lnum, cap->count1); | |
2884 curwin->w_p_fen = TRUE; | |
2885 } | |
2886 break; | |
2887 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2888 // "zA": open fold at cursor recursively |
7 | 2889 case 'A': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
2890 openFoldRecurse(curwin->w_cursor.lnum); | |
2891 else | |
2892 { | |
2893 closeFoldRecurse(curwin->w_cursor.lnum); | |
2894 curwin->w_p_fen = TRUE; | |
2895 } | |
2896 break; | |
2897 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2898 // "zo": open fold at cursor or Visual area |
7 | 2899 case 'o': if (VIsual_active) |
2900 nv_operator(cap); | |
2901 else | |
2902 openFold(curwin->w_cursor.lnum, cap->count1); | |
2903 break; | |
2904 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2905 // "zO": open fold recursively |
7 | 2906 case 'O': if (VIsual_active) |
2907 nv_operator(cap); | |
2908 else | |
2909 openFoldRecurse(curwin->w_cursor.lnum); | |
2910 break; | |
2911 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2912 // "zc": close fold at cursor or Visual area |
7 | 2913 case 'c': if (VIsual_active) |
2914 nv_operator(cap); | |
2915 else | |
2916 closeFold(curwin->w_cursor.lnum, cap->count1); | |
2917 curwin->w_p_fen = TRUE; | |
2918 break; | |
2919 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2920 // "zC": close fold recursively |
7 | 2921 case 'C': if (VIsual_active) |
2922 nv_operator(cap); | |
2923 else | |
2924 closeFoldRecurse(curwin->w_cursor.lnum); | |
2925 curwin->w_p_fen = TRUE; | |
2926 break; | |
2927 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2928 // "zv": open folds at the cursor |
7 | 2929 case 'v': foldOpenCursor(); |
2930 break; | |
2931 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2932 // "zx": re-apply 'foldlevel' and open folds at the cursor |
7 | 2933 case 'x': curwin->w_p_fen = TRUE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2934 curwin->w_foldinvalid = TRUE; // recompute folds |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2935 newFoldLevel(); // update right now |
7 | 2936 foldOpenCursor(); |
2937 break; | |
2938 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2939 // "zX": undo manual opens/closes, re-apply 'foldlevel' |
7 | 2940 case 'X': curwin->w_p_fen = TRUE; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2941 curwin->w_foldinvalid = TRUE; // recompute folds |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2942 old_fdl = -1; // force an update |
7 | 2943 break; |
2944 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2945 // "zm": fold more |
7 | 2946 case 'm': if (curwin->w_p_fdl > 0) |
6725 | 2947 { |
2948 curwin->w_p_fdl -= cap->count1; | |
2949 if (curwin->w_p_fdl < 0) | |
2950 curwin->w_p_fdl = 0; | |
2951 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2952 old_fdl = -1; // force an update |
7 | 2953 curwin->w_p_fen = TRUE; |
2954 break; | |
2955 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2956 // "zM": close all folds |
7 | 2957 case 'M': curwin->w_p_fdl = 0; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2958 old_fdl = -1; // force an update |
7 | 2959 curwin->w_p_fen = TRUE; |
2960 break; | |
2961 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2962 // "zr": reduce folding |
6725 | 2963 case 'r': curwin->w_p_fdl += cap->count1; |
2964 { | |
2965 int d = getDeepestNesting(); | |
2966 | |
2967 if (curwin->w_p_fdl >= d) | |
2968 curwin->w_p_fdl = d; | |
2969 } | |
7 | 2970 break; |
2971 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2972 // "zR": open all folds |
7 | 2973 case 'R': curwin->w_p_fdl = getDeepestNesting(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2974 old_fdl = -1; // force an update |
7 | 2975 break; |
2976 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2977 case 'j': // "zj" move to next fold downwards |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2978 case 'k': // "zk" move to next fold upwards |
7 | 2979 if (foldMoveTo(TRUE, nchar == 'j' ? FORWARD : BACKWARD, |
2980 cap->count1) == FAIL) | |
2981 clearopbeep(cap->oap); | |
2982 break; | |
2983 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2984 #endif // FEAT_FOLDING |
7 | 2985 |
737 | 2986 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2987 case 'u': // "zug" and "zuw": undo "zg" and "zw" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2988 case 'g': // "zg": add good word to word list |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2989 case 'w': // "zw": add wrong word to word list |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2990 case 'G': // "zG": add good word to temp word list |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2991 case 'W': // "zW": add wrong word to temp word list |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2992 if (nv_zg_zw(cap, nchar) == FAIL) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2993 return; |
316 | 2994 break; |
323 | 2995 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2996 case '=': // "z=": suggestions for a badly spelled word |
638 | 2997 if (!checkclearop(cap->oap)) |
485 | 2998 spell_suggest((int)cap->count0); |
323 | 2999 break; |
310 | 3000 #endif |
3001 | |
7 | 3002 default: clearopbeep(cap->oap); |
3003 } | |
3004 | |
3005 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3006 // Redraw when 'foldenable' changed |
7 | 3007 if (old_fen != curwin->w_p_fen) |
3008 { | |
3009 # ifdef FEAT_DIFF | |
3010 win_T *wp; | |
3011 | |
3012 if (foldmethodIsDiff(curwin) && curwin->w_p_scb) | |
3013 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3014 // Adjust 'foldenable' in diff-synced windows. |
7 | 3015 FOR_ALL_WINDOWS(wp) |
3016 { | |
3017 if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) | |
3018 { | |
3019 wp->w_p_fen = curwin->w_p_fen; | |
3020 changed_window_setting_win(wp); | |
3021 } | |
3022 } | |
3023 } | |
3024 # endif | |
3025 changed_window_setting(); | |
3026 } | |
3027 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3028 // Redraw when 'foldlevel' changed. |
7 | 3029 if (old_fdl != curwin->w_p_fdl) |
3030 newFoldLevel(); | |
3031 #endif | |
3032 } | |
3033 | |
3034 #ifdef FEAT_GUI | |
3035 /* | |
3036 * Vertical scrollbar movement. | |
3037 */ | |
3038 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3039 nv_ver_scrollbar(cmdarg_T *cap) |
7 | 3040 { |
3041 if (cap->oap->op_type != OP_NOP) | |
3042 clearopbeep(cap->oap); | |
3043 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3044 // Even if an operator was pending, we still want to scroll |
7 | 3045 gui_do_scroll(); |
3046 } | |
3047 | |
3048 /* | |
3049 * Horizontal scrollbar movement. | |
3050 */ | |
3051 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3052 nv_hor_scrollbar(cmdarg_T *cap) |
7 | 3053 { |
3054 if (cap->oap->op_type != OP_NOP) | |
3055 clearopbeep(cap->oap); | |
3056 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3057 // Even if an operator was pending, we still want to scroll |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3058 gui_do_horiz_scroll(scrollbar_value, FALSE); |
7 | 3059 } |
3060 #endif | |
3061 | |
690 | 3062 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
685 | 3063 /* |
3064 * Click in GUI tab. | |
3065 */ | |
3066 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3067 nv_tabline(cmdarg_T *cap) |
685 | 3068 { |
3069 if (cap->oap->op_type != OP_NOP) | |
3070 clearopbeep(cap->oap); | |
3071 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3072 // Even if an operator was pending, we still want to jump tabs. |
685 | 3073 goto_tabpage(current_tab); |
3074 } | |
686 | 3075 |
3076 /* | |
3077 * Selected item in tab line menu. | |
3078 */ | |
3079 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3080 nv_tabmenu(cmdarg_T *cap) |
686 | 3081 { |
3082 if (cap->oap->op_type != OP_NOP) | |
3083 clearopbeep(cap->oap); | |
3084 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3085 // Even if an operator was pending, we still want to jump tabs. |
690 | 3086 handle_tabmenu(); |
3087 } | |
3088 | |
3089 /* | |
3090 * Handle selecting an item of the GUI tab line menu. | |
3091 * Used in Normal and Insert mode. | |
3092 */ | |
3093 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3094 handle_tabmenu(void) |
690 | 3095 { |
686 | 3096 switch (current_tabmenu) |
3097 { | |
3098 case TABLINE_MENU_CLOSE: | |
3099 if (current_tab == 0) | |
3100 do_cmdline_cmd((char_u *)"tabclose"); | |
3101 else | |
3102 { | |
3103 vim_snprintf((char *)IObuff, IOSIZE, "tabclose %d", | |
3104 current_tab); | |
3105 do_cmdline_cmd(IObuff); | |
3106 } | |
3107 break; | |
3108 | |
3109 case TABLINE_MENU_NEW: | |
6631 | 3110 if (current_tab == 0) |
3111 do_cmdline_cmd((char_u *)"$tabnew"); | |
3112 else | |
3113 { | |
3114 vim_snprintf((char *)IObuff, IOSIZE, "%dtabnew", | |
3115 current_tab - 1); | |
3116 do_cmdline_cmd(IObuff); | |
3117 } | |
686 | 3118 break; |
3119 | |
3120 case TABLINE_MENU_OPEN: | |
6631 | 3121 if (current_tab == 0) |
3122 do_cmdline_cmd((char_u *)"browse $tabnew"); | |
3123 else | |
3124 { | |
3125 vim_snprintf((char *)IObuff, IOSIZE, "browse %dtabnew", | |
3126 current_tab - 1); | |
3127 do_cmdline_cmd(IObuff); | |
3128 } | |
686 | 3129 break; |
3130 } | |
3131 } | |
685 | 3132 #endif |
3133 | |
7 | 3134 /* |
3135 * "Q" command. | |
3136 */ | |
3137 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3138 nv_exmode(cmdarg_T *cap) |
7 | 3139 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3140 // Ignore 'Q' in Visual mode, just give a beep. |
7 | 3141 if (VIsual_active) |
6949 | 3142 vim_beep(BO_EX); |
5735 | 3143 else if (!checkclearop(cap->oap)) |
7 | 3144 do_exmode(FALSE); |
3145 } | |
3146 | |
3147 /* | |
3148 * Handle a ":" command. | |
3149 */ | |
3150 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3151 nv_colon(cmdarg_T *cap) |
7 | 3152 { |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3153 int old_p_im; |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3154 int cmd_result; |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3155 int is_cmdkey = cap->cmdchar == K_COMMAND |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3156 || cap->cmdchar == K_SCRIPT_COMMAND; |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3157 int flags; |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3158 |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3159 if (VIsual_active && !is_cmdkey) |
7 | 3160 nv_operator(cap); |
3161 else | |
3162 { | |
3163 if (cap->oap->op_type != OP_NOP) | |
3164 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3165 // Using ":" as a movement is characterwise exclusive. |
7 | 3166 cap->oap->motion_type = MCHAR; |
3167 cap->oap->inclusive = FALSE; | |
3168 } | |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3169 else if (cap->count0 && !is_cmdkey) |
7 | 3170 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3171 // translate "count:" into ":.,.+(count - 1)" |
7 | 3172 stuffcharReadbuff('.'); |
3173 if (cap->count0 > 1) | |
3174 { | |
3175 stuffReadbuff((char_u *)",.+"); | |
3176 stuffnumReadbuff((long)cap->count0 - 1L); | |
3177 } | |
3178 } | |
3179 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3180 // When typing, don't type below an old message |
7 | 3181 if (KeyTyped) |
3182 compute_cmdrow(); | |
3183 | |
3184 old_p_im = p_im; | |
3185 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3186 // get a command line and execute it |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3187 flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0; |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3188 if (is_cmdkey) |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3189 cmd_result = do_cmdkey_command(cap->cmdchar, flags); |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3190 else |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3191 cmd_result = do_cmdline(NULL, getexline, NULL, flags); |
7 | 3192 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3193 // If 'insertmode' changed, enter or exit Insert mode |
7 | 3194 if (p_im != old_p_im) |
3195 { | |
3196 if (p_im) | |
3197 restart_edit = 'i'; | |
3198 else | |
3199 restart_edit = 0; | |
3200 } | |
3201 | |
4256 | 3202 if (cmd_result == FAIL) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3203 // The Ex command failed, do not execute the operator. |
4256 | 3204 clearop(cap->oap); |
3205 else if (cap->oap->op_type != OP_NOP | |
7 | 3206 && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count |
3207 || cap->oap->start.col > | |
4256 | 3208 (colnr_T)STRLEN(ml_get(cap->oap->start.lnum)) |
3209 || did_emsg | |
3210 )) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3211 // The start of the operator has become invalid by the Ex command. |
7 | 3212 clearopbeep(cap->oap); |
3213 } | |
3214 } | |
3215 | |
3216 /* | |
3217 * Handle CTRL-G command. | |
3218 */ | |
3219 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3220 nv_ctrlg(cmdarg_T *cap) |
7 | 3221 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3222 if (VIsual_active) // toggle Selection/Visual mode |
7 | 3223 { |
3224 VIsual_select = !VIsual_select; | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
3225 trigger_modechanged(); |
7 | 3226 showmode(); |
3227 } | |
5735 | 3228 else if (!checkclearop(cap->oap)) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3229 // print full name if count given or :cd used |
7 | 3230 fileinfo((int)cap->count0, FALSE, TRUE); |
3231 } | |
3232 | |
3233 /* | |
3234 * Handle CTRL-H <Backspace> command. | |
3235 */ | |
3236 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3237 nv_ctrlh(cmdarg_T *cap) |
7 | 3238 { |
3239 if (VIsual_active && VIsual_select) | |
3240 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3241 cap->cmdchar = 'x'; // BS key behaves like 'x' in Select mode |
7 | 3242 v_visop(cap); |
3243 } | |
3244 else | |
3245 nv_left(cap); | |
3246 } | |
3247 | |
3248 /* | |
3249 * CTRL-L: clear screen and redraw. | |
3250 */ | |
3251 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3252 nv_clear(cmdarg_T *cap) |
7 | 3253 { |
3254 if (!checkclearop(cap->oap)) | |
3255 { | |
3256 #ifdef FEAT_SYN_HL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3257 // Clear all syntax states to force resyncing. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3258 syn_stack_free_all(curwin->w_s); |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3259 # ifdef FEAT_RELTIME |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3260 { |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3261 win_T *wp; |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3262 |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3263 FOR_ALL_WINDOWS(wp) |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3264 wp->w_s->b_syn_slow = FALSE; |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3265 } |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3266 # endif |
7 | 3267 #endif |
3268 redraw_later(CLEAR); | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3269 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3270 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3271 if (!gui.in_use) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3272 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3273 resize_console_buf(); |
15866
6ddcd10aa7af
patch 8.1.0940: MS-Windows console resizing not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3274 #endif |
7 | 3275 } |
3276 } | |
3277 | |
3278 /* | |
3279 * CTRL-O: In Select mode: switch to Visual mode for one command. | |
3280 * Otherwise: Go to older pcmark. | |
3281 */ | |
3282 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3283 nv_ctrlo(cmdarg_T *cap) |
7 | 3284 { |
3285 if (VIsual_active && VIsual_select) | |
3286 { | |
3287 VIsual_select = FALSE; | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
3288 trigger_modechanged(); |
7 | 3289 showmode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3290 restart_VIsual_select = 2; // restart Select mode later |
7 | 3291 } |
3292 else | |
3293 { | |
3294 cap->count1 = -cap->count1; | |
3295 nv_pcmark(cap); | |
3296 } | |
3297 } | |
3298 | |
3299 /* | |
15006
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
3300 * CTRL-^ command, short for ":e #". Works even when the alternate buffer is |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
3301 * not named. |
7 | 3302 */ |
3303 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3304 nv_hat(cmdarg_T *cap) |
7 | 3305 { |
3306 if (!checkclearopq(cap->oap)) | |
3307 (void)buflist_getfile((int)cap->count0, (linenr_T)0, | |
3308 GETF_SETMARK|GETF_ALT, FALSE); | |
3309 } | |
3310 | |
3311 /* | |
3312 * "Z" commands. | |
3313 */ | |
3314 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3315 nv_Zet(cmdarg_T *cap) |
7 | 3316 { |
3317 if (!checkclearopq(cap->oap)) | |
3318 { | |
3319 switch (cap->nchar) | |
3320 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3321 // "ZZ": equivalent to ":x". |
7 | 3322 case 'Z': do_cmdline_cmd((char_u *)"x"); |
3323 break; | |
3324 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3325 // "ZQ": equivalent to ":q!" (Elvis compatible). |
7 | 3326 case 'Q': do_cmdline_cmd((char_u *)"q!"); |
3327 break; | |
3328 | |
3329 default: clearopbeep(cap->oap); | |
3330 } | |
3331 } | |
3332 } | |
3333 | |
3334 /* | |
3335 * Call nv_ident() as if "c1" was used, with "c2" as next character. | |
3336 */ | |
3337 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3338 do_nv_ident(int c1, int c2) |
7 | 3339 { |
3340 oparg_T oa; | |
3341 cmdarg_T ca; | |
3342 | |
3343 clear_oparg(&oa); | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
3344 CLEAR_FIELD(ca); |
7 | 3345 ca.oap = &oa; |
3346 ca.cmdchar = c1; | |
3347 ca.nchar = c2; | |
3348 nv_ident(&ca); | |
3349 } | |
3350 | |
3351 /* | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3352 * 'K' normal-mode command. Get the command to lookup the keyword under the |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3353 * cursor. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3354 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3355 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3356 nv_K_getcmd( |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3357 cmdarg_T *cap, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3358 char_u *kp, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3359 int kp_help, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3360 int kp_ex, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3361 char_u **ptr_arg, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3362 int n, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3363 char_u *buf, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3364 unsigned buflen) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3365 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3366 char_u *ptr = *ptr_arg; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3367 int isman; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3368 int isman_s; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3369 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3370 if (kp_help) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3371 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3372 // in the help buffer |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3373 STRCPY(buf, "he! "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3374 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3375 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3376 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3377 if (kp_ex) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3378 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3379 // 'keywordprog' is an ex command |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3380 if (cap->count0 != 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3381 vim_snprintf((char *)buf, buflen, "%s %ld", kp, cap->count0); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3382 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3383 STRCPY(buf, kp); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3384 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3385 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3386 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3387 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3388 // An external command will probably use an argument starting |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3389 // with "-" as an option. To avoid trouble we skip the "-". |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3390 while (*ptr == '-' && n > 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3391 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3392 ++ptr; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3393 --n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3394 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3395 if (n == 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3396 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3397 // found dashes only |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3398 emsg(_(e_no_identifier_under_cursor)); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3399 vim_free(buf); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3400 *ptr_arg = ptr; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3401 return 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3402 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3403 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3404 // When a count is given, turn it into a range. Is this |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3405 // really what we want? |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3406 isman = (STRCMP(kp, "man") == 0); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3407 isman_s = (STRCMP(kp, "man -s") == 0); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3408 if (cap->count0 != 0 && !(isman || isman_s)) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3409 sprintf((char *)buf, ".,.+%ld", cap->count0 - 1); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3410 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3411 STRCAT(buf, "! "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3412 if (cap->count0 == 0 && isman_s) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3413 STRCAT(buf, "man"); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3414 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3415 STRCAT(buf, kp); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3416 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3417 if (cap->count0 != 0 && (isman || isman_s)) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3418 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3419 sprintf((char *)buf + STRLEN(buf), "%ld", cap->count0); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3420 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3421 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3422 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3423 *ptr_arg = ptr; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3424 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3425 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3426 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3427 /* |
7 | 3428 * Handle the commands that use the word under the cursor. |
3429 * [g] CTRL-] :ta to current identifier | |
3430 * [g] 'K' run program for current identifier | |
3431 * [g] '*' / to current identifier or string | |
3432 * [g] '#' ? to current identifier or string | |
3433 * g ']' :tselect for current identifier | |
3434 */ | |
3435 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3436 nv_ident(cmdarg_T *cap) |
7 | 3437 { |
3438 char_u *ptr = NULL; | |
3439 char_u *buf; | |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3440 unsigned buflen; |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3441 char_u *newbuf; |
7 | 3442 char_u *p; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3443 char_u *kp; // value of 'keywordprg' |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3444 int kp_help; // 'keywordprg' is ":he" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3445 int kp_ex; // 'keywordprg' starts with ":" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3446 int n = 0; // init for GCC |
7 | 3447 int cmdchar; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3448 int g_cmd; // "g" command |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3449 int tag_cmd = FALSE; |
7 | 3450 char_u *aux_ptr; |
3451 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3452 if (cap->cmdchar == 'g') // "g*", "g#", "g]" and "gCTRL-]" |
7 | 3453 { |
3454 cmdchar = cap->nchar; | |
3455 g_cmd = TRUE; | |
3456 } | |
3457 else | |
3458 { | |
3459 cmdchar = cap->cmdchar; | |
3460 g_cmd = FALSE; | |
3461 } | |
3462 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3463 if (cmdchar == POUND) // the pound sign, '#' for English keyboards |
7 | 3464 cmdchar = '#'; |
3465 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3466 // The "]", "CTRL-]" and "K" commands accept an argument in Visual mode. |
7 | 3467 if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K') |
3468 { | |
3469 if (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL) | |
3470 return; | |
3471 if (checkclearopq(cap->oap)) | |
3472 return; | |
3473 } | |
3474 | |
3475 if (ptr == NULL && (n = find_ident_under_cursor(&ptr, | |
3476 (cmdchar == '*' || cmdchar == '#') | |
3477 ? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0) | |
3478 { | |
3479 clearop(cap->oap); | |
3480 return; | |
3481 } | |
3482 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3483 // Allocate buffer to put the command in. Inserting backslashes can |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3484 // double the length of the word. p_kp / curbuf->b_p_kp could be added |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3485 // and some numbers. |
7 | 3486 kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp); |
3487 kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 | |
3488 || STRCMP(kp, ":help") == 0); | |
12236
55cf556d8ce1
patch 8.0.0998: strange error when using K while only spaces are selected
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
3489 if (kp_help && *skipwhite(ptr) == NUL) |
55cf556d8ce1
patch 8.0.0998: strange error when using K while only spaces are selected
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
3490 { |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
3491 emsg(_(e_no_identifier_under_cursor)); // found white space only |
12236
55cf556d8ce1
patch 8.0.0998: strange error when using K while only spaces are selected
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
3492 return; |
55cf556d8ce1
patch 8.0.0998: strange error when using K while only spaces are selected
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
3493 } |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3494 kp_ex = (*kp == ':'); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3495 buflen = (unsigned)(n * 2 + 30 + STRLEN(kp)); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3496 buf = alloc(buflen); |
7 | 3497 if (buf == NULL) |
3498 return; | |
3499 buf[0] = NUL; | |
3500 | |
3501 switch (cmdchar) | |
3502 { | |
3503 case '*': | |
3504 case '#': | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3505 // Put cursor at start of word, makes search skip the word |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3506 // under the cursor. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3507 // Call setpcmark() first, so "*``" puts the cursor back where |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3508 // it was. |
7 | 3509 setpcmark(); |
3510 curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline()); | |
3511 | |
3512 if (!g_cmd && vim_iswordp(ptr)) | |
3513 STRCPY(buf, "\\<"); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3514 no_smartcase = TRUE; // don't use 'smartcase' now |
7 | 3515 break; |
3516 | |
3517 case 'K': | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3518 n = nv_K_getcmd(cap, kp, kp_help, kp_ex, &ptr, n, buf, buflen); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3519 if (n == 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3520 return; |
7 | 3521 break; |
3522 | |
3523 case ']': | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3524 tag_cmd = TRUE; |
7 | 3525 #ifdef FEAT_CSCOPE |
3526 if (p_cst) | |
3527 STRCPY(buf, "cstag "); | |
3528 else | |
3529 #endif | |
3530 STRCPY(buf, "ts "); | |
3531 break; | |
3532 | |
3533 default: | |
2112
6b5d641bcdd4
updated for version 7.2.395
Bram Moolenaar <bram@zimbu.org>
parents:
2049
diff
changeset
|
3534 tag_cmd = TRUE; |
7 | 3535 if (curbuf->b_help) |
3536 STRCPY(buf, "he! "); | |
3537 else | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3538 { |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3539 if (g_cmd) |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3540 STRCPY(buf, "tj "); |
21941
f65e76638eb5
patch 8.2.1520: Vim9: CTRL-] used in :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
21703
diff
changeset
|
3541 else if (cap->count0 == 0) |
f65e76638eb5
patch 8.2.1520: Vim9: CTRL-] used in :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
21703
diff
changeset
|
3542 STRCPY(buf, "ta "); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3543 else |
21941
f65e76638eb5
patch 8.2.1520: Vim9: CTRL-] used in :def function does not work
Bram Moolenaar <Bram@vim.org>
parents:
21703
diff
changeset
|
3544 sprintf((char *)buf, ":%ldta ", cap->count0); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3545 } |
7 | 3546 } |
3547 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3548 // Now grab the chars in the identifier |
1712 | 3549 if (cmdchar == 'K' && !kp_help) |
3550 { | |
1728 | 3551 ptr = vim_strnsave(ptr, n); |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3552 if (kp_ex) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3553 // Escape the argument properly for an Ex command |
25994
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25921
diff
changeset
|
3554 p = vim_strsave_fnameescape(ptr, VSE_NONE); |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3555 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3556 // Escape the argument properly for a shell command |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3557 p = vim_strsave_shellescape(ptr, TRUE, TRUE); |
1728 | 3558 vim_free(ptr); |
1712 | 3559 if (p == NULL) |
3560 { | |
3561 vim_free(buf); | |
3562 return; | |
3563 } | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16742
diff
changeset
|
3564 newbuf = vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1); |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3565 if (newbuf == NULL) |
1712 | 3566 { |
3567 vim_free(buf); | |
3568 vim_free(p); | |
3569 return; | |
3570 } | |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3571 buf = newbuf; |
1712 | 3572 STRCAT(buf, p); |
3573 vim_free(p); | |
3574 } | |
7 | 3575 else |
1712 | 3576 { |
3577 if (cmdchar == '*') | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3578 aux_ptr = (char_u *)(magic_isset() ? "/.*~[^$\\" : "/^$\\"); |
1712 | 3579 else if (cmdchar == '#') |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3580 aux_ptr = (char_u *)(magic_isset() ? "/?.*~[^$\\" : "/?^$\\"); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3581 else if (tag_cmd) |
2603 | 3582 { |
3583 if (curbuf->b_help) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3584 // ":help" handles unescaped argument |
2603 | 3585 aux_ptr = (char_u *)""; |
3586 else | |
3587 aux_ptr = (char_u *)"\\|\"\n["; | |
3588 } | |
1712 | 3589 else |
3590 aux_ptr = (char_u *)"\\|\"\n*?["; | |
3591 | |
3592 p = buf + STRLEN(buf); | |
3593 while (n-- > 0) | |
3594 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3595 // put a backslash before \ and some others |
1712 | 3596 if (vim_strchr(aux_ptr, *ptr) != NULL) |
3597 *p++ = '\\'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3598 // When current byte is a part of multibyte character, copy all |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3599 // bytes of that character. |
1712 | 3600 if (has_mbyte) |
3601 { | |
3602 int i; | |
3603 int len = (*mb_ptr2len)(ptr) - 1; | |
3604 | |
3605 for (i = 0; i < len && n >= 1; ++i, --n) | |
3606 *p++ = *ptr++; | |
3607 } | |
3608 *p++ = *ptr++; | |
3609 } | |
3610 *p = NUL; | |
3611 } | |
7 | 3612 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3613 // Execute the command. |
7 | 3614 if (cmdchar == '*' || cmdchar == '#') |
3615 { | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3616 if (!g_cmd && (has_mbyte |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3617 ? vim_iswordp(mb_prevptr(ml_get_curline(), ptr)) |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3618 : vim_iswordc(ptr[-1]))) |
7 | 3619 STRCAT(buf, "\\>"); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3620 |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3621 // put pattern in search history |
2024 | 3622 init_history(); |
7 | 3623 add_to_history(HIST_SEARCH, buf, TRUE, NUL); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3624 |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
3625 (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); |
7 | 3626 } |
3627 else | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3628 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3629 g_tag_at_cursor = TRUE; |
7 | 3630 do_cmdline_cmd(buf); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3631 g_tag_at_cursor = FALSE; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3632 } |
7 | 3633 |
3634 vim_free(buf); | |
3635 } | |
3636 | |
3637 /* | |
3638 * Get visually selected text, within one line only. | |
3639 * Returns FAIL if more than one line selected. | |
3640 */ | |
344 | 3641 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3642 get_visual_text( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3643 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3644 char_u **pp, // return: start of selected text |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3645 int *lenp) // return: length of selected text |
7 | 3646 { |
3647 if (VIsual_mode != 'V') | |
3648 unadjust_for_sel(); | |
3649 if (VIsual.lnum != curwin->w_cursor.lnum) | |
3650 { | |
344 | 3651 if (cap != NULL) |
3652 clearopbeep(cap->oap); | |
7 | 3653 return FAIL; |
3654 } | |
3655 if (VIsual_mode == 'V') | |
3656 { | |
3657 *pp = ml_get_curline(); | |
3658 *lenp = (int)STRLEN(*pp); | |
3659 } | |
3660 else | |
3661 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3662 if (LT_POS(curwin->w_cursor, VIsual)) |
7 | 3663 { |
3664 *pp = ml_get_pos(&curwin->w_cursor); | |
3665 *lenp = VIsual.col - curwin->w_cursor.col + 1; | |
3666 } | |
3667 else | |
3668 { | |
3669 *pp = ml_get_pos(&VIsual); | |
3670 *lenp = curwin->w_cursor.col - VIsual.col + 1; | |
3671 } | |
26159
34606aec52b3
patch 8.2.3611: crash when using CTRL-W f without finding a file name
Bram Moolenaar <Bram@vim.org>
parents:
26157
diff
changeset
|
3672 if (**pp == NUL) |
34606aec52b3
patch 8.2.3611: crash when using CTRL-W f without finding a file name
Bram Moolenaar <Bram@vim.org>
parents:
26157
diff
changeset
|
3673 *lenp = 0; |
34606aec52b3
patch 8.2.3611: crash when using CTRL-W f without finding a file name
Bram Moolenaar <Bram@vim.org>
parents:
26157
diff
changeset
|
3674 if (has_mbyte && *lenp > 0) |
34606aec52b3
patch 8.2.3611: crash when using CTRL-W f without finding a file name
Bram Moolenaar <Bram@vim.org>
parents:
26157
diff
changeset
|
3675 // Correct the length to include all bytes of the last character. |
474 | 3676 *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1; |
7 | 3677 } |
3678 reset_VIsual_and_resel(); | |
3679 return OK; | |
3680 } | |
3681 | |
3682 /* | |
3683 * CTRL-T: backwards in tag stack | |
3684 */ | |
3685 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3686 nv_tagpop(cmdarg_T *cap) |
7 | 3687 { |
3688 if (!checkclearopq(cap->oap)) | |
3689 do_tag((char_u *)"", DT_POP, (int)cap->count1, FALSE, TRUE); | |
3690 } | |
3691 | |
3692 /* | |
3693 * Handle scrolling command 'H', 'L' and 'M'. | |
3694 */ | |
3695 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3696 nv_scroll(cmdarg_T *cap) |
7 | 3697 { |
3698 int used = 0; | |
3699 long n; | |
3700 #ifdef FEAT_FOLDING | |
3701 linenr_T lnum; | |
3702 #endif | |
3703 int half; | |
3704 | |
3705 cap->oap->motion_type = MLINE; | |
3706 setpcmark(); | |
3707 | |
3708 if (cap->cmdchar == 'L') | |
3709 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3710 validate_botline(); // make sure curwin->w_botline is valid |
7 | 3711 curwin->w_cursor.lnum = curwin->w_botline - 1; |
3712 if (cap->count1 - 1 >= curwin->w_cursor.lnum) | |
3713 curwin->w_cursor.lnum = 1; | |
3714 else | |
9 | 3715 { |
3716 #ifdef FEAT_FOLDING | |
3717 if (hasAnyFolding(curwin)) | |
3718 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3719 // Count a fold for one screen line. |
9 | 3720 for (n = cap->count1 - 1; n > 0 |
3721 && curwin->w_cursor.lnum > curwin->w_topline; --n) | |
3722 { | |
3723 (void)hasFolding(curwin->w_cursor.lnum, | |
3724 &curwin->w_cursor.lnum, NULL); | |
3725 --curwin->w_cursor.lnum; | |
3726 } | |
3727 } | |
3728 else | |
3729 #endif | |
3730 curwin->w_cursor.lnum -= cap->count1 - 1; | |
3731 } | |
7 | 3732 } |
3733 else | |
3734 { | |
3735 if (cap->cmdchar == 'M') | |
3736 { | |
3737 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3738 // Don't count filler lines above the window. |
7 | 3739 used -= diff_check_fill(curwin, curwin->w_topline) |
3740 - curwin->w_topfill; | |
3741 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3742 validate_botline(); // make sure w_empty_rows is valid |
7 | 3743 half = (curwin->w_height - curwin->w_empty_rows + 1) / 2; |
3744 for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; ++n) | |
3745 { | |
3746 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3747 // Count half he number of filler lines to be "below this |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3748 // line" and half to be "above the next line". |
7 | 3749 if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline |
3750 + n) / 2 >= half) | |
3751 { | |
3752 --n; | |
3753 break; | |
3754 } | |
3755 #endif | |
3756 used += plines(curwin->w_topline + n); | |
3757 if (used >= half) | |
3758 break; | |
3759 #ifdef FEAT_FOLDING | |
3760 if (hasFolding(curwin->w_topline + n, NULL, &lnum)) | |
3761 n = lnum - curwin->w_topline; | |
3762 #endif | |
3763 } | |
3764 if (n > 0 && used > curwin->w_height) | |
3765 --n; | |
3766 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3767 else // (cap->cmdchar == 'H') |
9 | 3768 { |
7 | 3769 n = cap->count1 - 1; |
9 | 3770 #ifdef FEAT_FOLDING |
3771 if (hasAnyFolding(curwin)) | |
3772 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3773 // Count a fold for one screen line. |
9 | 3774 lnum = curwin->w_topline; |
3775 while (n-- > 0 && lnum < curwin->w_botline - 1) | |
3776 { | |
7009 | 3777 (void)hasFolding(lnum, NULL, &lnum); |
9 | 3778 ++lnum; |
3779 } | |
3780 n = lnum - curwin->w_topline; | |
3781 } | |
3782 #endif | |
3783 } | |
7 | 3784 curwin->w_cursor.lnum = curwin->w_topline + n; |
3785 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
3786 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
3787 } | |
3788 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3789 // Correct for 'so', except when an operator is pending. |
12646
b908a3682f6e
patch 8.0.1201: "yL" is affected by 'scrolloff'
Christian Brabandt <cb@256bit.org>
parents:
12519
diff
changeset
|
3790 if (cap->oap->op_type == OP_NOP) |
b908a3682f6e
patch 8.0.1201: "yL" is affected by 'scrolloff'
Christian Brabandt <cb@256bit.org>
parents:
12519
diff
changeset
|
3791 cursor_correct(); |
7 | 3792 beginline(BL_SOL | BL_FIX); |
3793 } | |
3794 | |
3795 /* | |
3796 * Cursor right commands. | |
3797 */ | |
3798 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3799 nv_right(cmdarg_T *cap) |
7 | 3800 { |
3801 long n; | |
5735 | 3802 int past_line; |
7 | 3803 |
180 | 3804 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
3805 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3806 // <C-Right> and <S-Right> move a word or WORD right |
180 | 3807 if (mod_mask & MOD_MASK_CTRL) |
3808 cap->arg = TRUE; | |
3809 nv_wordcmd(cap); | |
3810 return; | |
3811 } | |
3812 | |
7 | 3813 cap->oap->motion_type = MCHAR; |
3814 cap->oap->inclusive = FALSE; | |
5735 | 3815 past_line = (VIsual_active && *p_sel != 'o'); |
3816 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3817 // In virtual edit mode, there's no such thing as "past_line", as lines |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3818 // are (theoretically) infinitely long. |
7 | 3819 if (virtual_active()) |
5735 | 3820 past_line = 0; |
7 | 3821 |
3822 for (n = cap->count1; n > 0; --n) | |
3823 { | |
5735 | 3824 if ((!past_line && oneright() == FAIL) |
3825 || (past_line && *ml_get_cursor() == NUL) | |
1877 | 3826 ) |
7 | 3827 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3828 // <Space> wraps to next line if 'whichwrap' has 's'. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3829 // 'l' wraps to next line if 'whichwrap' has 'l'. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3830 // CURS_RIGHT wraps to next line if 'whichwrap' has '>'. |
7 | 3831 if ( ((cap->cmdchar == ' ' |
3832 && vim_strchr(p_ww, 's') != NULL) | |
3833 || (cap->cmdchar == 'l' | |
3834 && vim_strchr(p_ww, 'l') != NULL) | |
229 | 3835 || (cap->cmdchar == K_RIGHT |
7 | 3836 && vim_strchr(p_ww, '>') != NULL)) |
3837 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
3838 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3839 // When deleting we also count the NL as a character. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3840 // Set cap->oap->inclusive when last char in the line is |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3841 // included, move to next line after that |
714 | 3842 if ( cap->oap->op_type != OP_NOP |
7 | 3843 && !cap->oap->inclusive |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3844 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3845 cap->oap->inclusive = TRUE; |
3846 else | |
3847 { | |
3848 ++curwin->w_cursor.lnum; | |
3849 curwin->w_cursor.col = 0; | |
3850 curwin->w_cursor.coladd = 0; | |
3851 curwin->w_set_curswant = TRUE; | |
3852 cap->oap->inclusive = FALSE; | |
3853 } | |
3854 continue; | |
3855 } | |
3856 if (cap->oap->op_type == OP_NOP) | |
3857 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3858 // Only beep and flush if not moved at all |
7 | 3859 if (n == cap->count1) |
3860 beep_flush(); | |
3861 } | |
3862 else | |
3863 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3864 if (!LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3865 cap->oap->inclusive = TRUE; |
3866 } | |
3867 break; | |
3868 } | |
5735 | 3869 else if (past_line) |
7 | 3870 { |
3871 curwin->w_set_curswant = TRUE; | |
3872 if (virtual_active()) | |
3873 oneright(); | |
3874 else | |
5735 | 3875 { |
7 | 3876 if (has_mbyte) |
18128
aeabc666a119
patch 8.1.2059: fix for "x" deleting a fold has side effects
Bram Moolenaar <Bram@vim.org>
parents:
18114
diff
changeset
|
3877 curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); |
7 | 3878 else |
3879 ++curwin->w_cursor.col; | |
3880 } | |
3881 } | |
3882 } | |
3883 #ifdef FEAT_FOLDING | |
3884 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
3885 && cap->oap->op_type == OP_NOP) | |
3886 foldOpenCursor(); | |
3887 #endif | |
3888 } | |
3889 | |
3890 /* | |
3891 * Cursor left commands. | |
3892 * | |
3893 * Returns TRUE when operator end should not be adjusted. | |
3894 */ | |
3895 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3896 nv_left(cmdarg_T *cap) |
7 | 3897 { |
3898 long n; | |
3899 | |
180 | 3900 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
3901 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3902 // <C-Left> and <S-Left> move a word or WORD left |
180 | 3903 if (mod_mask & MOD_MASK_CTRL) |
3904 cap->arg = 1; | |
3905 nv_bck_word(cap); | |
3906 return; | |
3907 } | |
3908 | |
7 | 3909 cap->oap->motion_type = MCHAR; |
3910 cap->oap->inclusive = FALSE; | |
3911 for (n = cap->count1; n > 0; --n) | |
3912 { | |
3913 if (oneleft() == FAIL) | |
3914 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3915 // <BS> and <Del> wrap to previous line if 'whichwrap' has 'b'. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3916 // 'h' wraps to previous line if 'whichwrap' has 'h'. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3917 // CURS_LEFT wraps to previous line if 'whichwrap' has '<'. |
7 | 3918 if ( (((cap->cmdchar == K_BS |
3919 || cap->cmdchar == Ctrl_H) | |
3920 && vim_strchr(p_ww, 'b') != NULL) | |
3921 || (cap->cmdchar == 'h' | |
3922 && vim_strchr(p_ww, 'h') != NULL) | |
229 | 3923 || (cap->cmdchar == K_LEFT |
7 | 3924 && vim_strchr(p_ww, '<') != NULL)) |
3925 && curwin->w_cursor.lnum > 1) | |
3926 { | |
3927 --(curwin->w_cursor.lnum); | |
3928 coladvance((colnr_T)MAXCOL); | |
3929 curwin->w_set_curswant = TRUE; | |
3930 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3931 // When the NL before the first char has to be deleted we |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3932 // put the cursor on the NUL after the previous line. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3933 // This is a very special case, be careful! |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3934 // Don't adjust op_end now, otherwise it won't work. |
7 | 3935 if ( (cap->oap->op_type == OP_DELETE |
3936 || cap->oap->op_type == OP_CHANGE) | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3937 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3938 { |
5682 | 3939 char_u *cp = ml_get_cursor(); |
3940 | |
3941 if (*cp != NUL) | |
3942 { | |
3943 if (has_mbyte) | |
3944 curwin->w_cursor.col += (*mb_ptr2len)(cp); | |
3945 else | |
3946 ++curwin->w_cursor.col; | |
3947 } | |
7 | 3948 cap->retval |= CA_NO_ADJ_OP_END; |
3949 } | |
3950 continue; | |
3951 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3952 // Only beep and flush if not moved at all |
7 | 3953 else if (cap->oap->op_type == OP_NOP && n == cap->count1) |
3954 beep_flush(); | |
3955 break; | |
3956 } | |
3957 } | |
3958 #ifdef FEAT_FOLDING | |
3959 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
3960 && cap->oap->op_type == OP_NOP) | |
3961 foldOpenCursor(); | |
3962 #endif | |
3963 } | |
3964 | |
3965 /* | |
3966 * Cursor up commands. | |
3967 * cap->arg is TRUE for "-": Move cursor to first non-blank. | |
3968 */ | |
3969 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3970 nv_up(cmdarg_T *cap) |
7 | 3971 { |
180 | 3972 if (mod_mask & MOD_MASK_SHIFT) |
3973 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3974 // <S-Up> is page up |
180 | 3975 cap->arg = BACKWARD; |
3976 nv_page(cap); | |
3977 } | |
3978 else | |
3979 { | |
3980 cap->oap->motion_type = MLINE; | |
3981 if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
3982 clearopbeep(cap->oap); | |
3983 else if (cap->arg) | |
3984 beginline(BL_WHITE | BL_FIX); | |
3985 } | |
7 | 3986 } |
3987 | |
3988 /* | |
3989 * Cursor down commands. | |
3990 * cap->arg is TRUE for CR and "+": Move cursor to first non-blank. | |
3991 */ | |
3992 static void | |
10192
758f3d5a463d
commit https://github.com/vim/vim/commit/1b010058235fb803c1d4f42a02d2883921be8ef4
Christian Brabandt <cb@256bit.org>
parents:
10154
diff
changeset
|
3993 nv_down(cmdarg_T *cap) |
7 | 3994 { |
180 | 3995 if (mod_mask & MOD_MASK_SHIFT) |
3996 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3997 // <S-Down> is page down |
180 | 3998 cap->arg = FORWARD; |
3999 nv_page(cap); | |
4000 } | |
14397
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14071
diff
changeset
|
4001 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4002 // Quickfix window only: view the result under the cursor. |
14397
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14071
diff
changeset
|
4003 else if (bt_quickfix(curbuf) && cap->cmdchar == CAR) |
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14071
diff
changeset
|
4004 qf_view_result(FALSE); |
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14071
diff
changeset
|
4005 #endif |
180 | 4006 else |
7 | 4007 { |
4008 #ifdef FEAT_CMDWIN | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4009 // In the cmdline window a <CR> executes the command. |
170 | 4010 if (cmdwin_type != 0 && cap->cmdchar == CAR) |
7 | 4011 cmdwin_result = CAR; |
4012 else | |
4013 #endif | |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4014 #ifdef FEAT_JOB_CHANNEL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4015 // In a prompt buffer a <CR> in the last line invokes the callback. |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4016 if (bt_prompt(curbuf) && cap->cmdchar == CAR |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4017 && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4018 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4019 invoke_prompt_callback(); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4020 if (restart_edit == 0) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4021 restart_edit = 'a'; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4022 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4023 else |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4024 #endif |
7 | 4025 { |
4026 cap->oap->motion_type = MLINE; | |
4027 if (cursor_down(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
4028 clearopbeep(cap->oap); | |
4029 else if (cap->arg) | |
4030 beginline(BL_WHITE | BL_FIX); | |
4031 } | |
4032 } | |
4033 } | |
4034 | |
4035 #ifdef FEAT_SEARCHPATH | |
4036 /* | |
4037 * Grab the file name under the cursor and edit it. | |
4038 */ | |
4039 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4040 nv_gotofile(cmdarg_T *cap) |
7 | 4041 { |
4042 char_u *ptr; | |
681 | 4043 linenr_T lnum = -1; |
7 | 4044 |
633 | 4045 if (text_locked()) |
7 | 4046 { |
4047 clearopbeep(cap->oap); | |
633 | 4048 text_locked_msg(); |
7 | 4049 return; |
4050 } | |
819 | 4051 if (curbuf_locked()) |
4052 { | |
4053 clearop(cap->oap); | |
4054 return; | |
4055 } | |
20375
b790d00d5ccb
patch 8.2.0743: can move to another buffer from a terminal in popup window
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4056 #ifdef FEAT_PROP_POPUP |
b790d00d5ccb
patch 8.2.0743: can move to another buffer from a terminal in popup window
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4057 if (ERROR_IF_TERM_POPUP_WINDOW) |
b790d00d5ccb
patch 8.2.0743: can move to another buffer from a terminal in popup window
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4058 return; |
b790d00d5ccb
patch 8.2.0743: can move to another buffer from a terminal in popup window
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4059 #endif |
7 | 4060 |
681 | 4061 ptr = grab_file_name(cap->count1, &lnum); |
7 | 4062 |
4063 if (ptr != NULL) | |
4064 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4065 // do autowrite if necessary |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11892
diff
changeset
|
4066 if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !buf_hide(curbuf)) |
7009 | 4067 (void)autowrite(curbuf, FALSE); |
7 | 4068 setpcmark(); |
11436
69b52a770b29
patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents:
11366
diff
changeset
|
4069 if (do_ecmd(0, ptr, NULL, NULL, ECMD_LAST, |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11892
diff
changeset
|
4070 buf_hide(curbuf) ? ECMD_HIDE : 0, curwin) == OK |
11436
69b52a770b29
patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents:
11366
diff
changeset
|
4071 && cap->nchar == 'F' && lnum >= 0) |
681 | 4072 { |
4073 curwin->w_cursor.lnum = lnum; | |
4074 check_cursor_lnum(); | |
4075 beginline(BL_SOL | BL_FIX); | |
4076 } | |
7 | 4077 vim_free(ptr); |
4078 } | |
4079 else | |
4080 clearop(cap->oap); | |
4081 } | |
4082 #endif | |
4083 | |
4084 /* | |
4085 * <End> command: to end of current line or last line. | |
4086 */ | |
4087 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4088 nv_end(cmdarg_T *cap) |
7 | 4089 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4090 if (cap->arg || (mod_mask & MOD_MASK_CTRL)) // CTRL-END = goto last line |
180 | 4091 { |
4092 cap->arg = TRUE; | |
7 | 4093 nv_goto(cap); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4094 cap->count1 = 1; // to end of current line |
7 | 4095 } |
4096 nv_dollar(cap); | |
4097 } | |
4098 | |
4099 /* | |
4100 * Handle the "$" command. | |
4101 */ | |
4102 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4103 nv_dollar(cmdarg_T *cap) |
7 | 4104 { |
4105 cap->oap->motion_type = MCHAR; | |
4106 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4107 // In virtual mode when off the edge of a line and an operator |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4108 // is pending (whew!) keep the cursor where it is. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4109 // Otherwise, send it to the end of the line. |
7 | 4110 if (!virtual_active() || gchar_cursor() != NUL |
4111 || cap->oap->op_type == OP_NOP) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4112 curwin->w_curswant = MAXCOL; // so we stay at the end |
7 | 4113 if (cursor_down((long)(cap->count1 - 1), |
4114 cap->oap->op_type == OP_NOP) == FAIL) | |
4115 clearopbeep(cap->oap); | |
4116 #ifdef FEAT_FOLDING | |
4117 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4118 foldOpenCursor(); | |
4119 #endif | |
4120 } | |
4121 | |
4122 /* | |
4123 * Implementation of '?' and '/' commands. | |
4124 * If cap->arg is TRUE don't set PC mark. | |
4125 */ | |
4126 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4127 nv_search(cmdarg_T *cap) |
7 | 4128 { |
4129 oparg_T *oap = cap->oap; | |
10098
72e4b7f90465
commit https://github.com/vim/vim/commit/dda933d06c06c2792bd686d059f6ad19191ad30b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4130 pos_T save_cursor = curwin->w_cursor; |
7 | 4131 |
4132 if (cap->cmdchar == '?' && cap->oap->op_type == OP_ROT13) | |
4133 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4134 // Translate "g??" to "g?g?" |
7 | 4135 cap->cmdchar = 'g'; |
4136 cap->nchar = '?'; | |
4137 nv_operator(cap); | |
4138 return; | |
4139 } | |
4140 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4141 // When using 'incsearch' the cursor may be moved to set a different search |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4142 // start position. |
26804
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26749
diff
changeset
|
4143 cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, 0); |
7 | 4144 |
4145 if (cap->searchbuf == NULL) | |
4146 { | |
4147 clearop(oap); | |
4148 return; | |
4149 } | |
4150 | |
6620 | 4151 (void)normal_search(cap, cap->cmdchar, cap->searchbuf, |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
4152 (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor)) |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4153 ? 0 : SEARCH_MARK, NULL); |
7 | 4154 } |
4155 | |
4156 /* | |
4157 * Handle "N" and "n" commands. | |
4158 * cap->arg is SEARCH_REV for "N", 0 for "n". | |
4159 */ | |
4160 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4161 nv_next(cmdarg_T *cap) |
7 | 4162 { |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4163 pos_T old = curwin->w_cursor; |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4164 int wrapped = FALSE; |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4165 int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, &wrapped); |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4166 |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4167 if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor)) |
6620 | 4168 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4169 // Avoid getting stuck on the current cursor position, which can |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4170 // happen when an offset is given and the cursor is on the last char |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4171 // in the buffer: Repeat with count + 1. |
6620 | 4172 cap->count1 += 1; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4173 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); |
6620 | 4174 cap->count1 -= 1; |
4175 } | |
7 | 4176 } |
4177 | |
4178 /* | |
4179 * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat). | |
4180 * Uses only cap->count1 and cap->oap from "cap". | |
6620 | 4181 * Return 0 for failure, 1 for found, 2 for found and line offset added. |
4182 */ | |
4183 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4184 normal_search( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4185 cmdarg_T *cap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4186 int dir, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4187 char_u *pat, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4188 int opt, // extra flags for do_search() |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4189 int *wrapped) |
7 | 4190 { |
4191 int i; | |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4192 searchit_arg_T sia; |
7 | 4193 |
4194 cap->oap->motion_type = MCHAR; | |
4195 cap->oap->inclusive = FALSE; | |
4196 cap->oap->use_reg_one = TRUE; | |
4197 curwin->w_set_curswant = TRUE; | |
4198 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
4199 CLEAR_FIELD(sia); |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
4200 i = do_search(cap->oap, dir, dir, pat, cap->count1, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4201 opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia); |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4202 if (wrapped != NULL) |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4203 *wrapped = sia.sa_wrapped; |
7 | 4204 if (i == 0) |
4205 clearop(cap->oap); | |
4206 else | |
4207 { | |
4208 if (i == 2) | |
4209 cap->oap->motion_type = MLINE; | |
4210 curwin->w_cursor.coladd = 0; | |
4211 #ifdef FEAT_FOLDING | |
4212 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4213 foldOpenCursor(); | |
4214 #endif | |
4215 } | |
4216 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4217 // "/$" will put the cursor after the end of the line, may need to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4218 // correct that here |
7 | 4219 check_cursor(); |
6620 | 4220 return i; |
7 | 4221 } |
4222 | |
4223 /* | |
4224 * Character search commands. | |
4225 * cap->arg is BACKWARD for 'F' and 'T', FORWARD for 'f' and 't', TRUE for | |
4226 * ',' and FALSE for ';'. | |
4227 * cap->nchar is NUL for ',' and ';' (repeat the search) | |
4228 */ | |
4229 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4230 nv_csearch(cmdarg_T *cap) |
7 | 4231 { |
4232 int t_cmd; | |
4233 | |
4234 if (cap->cmdchar == 't' || cap->cmdchar == 'T') | |
4235 t_cmd = TRUE; | |
4236 else | |
4237 t_cmd = FALSE; | |
4238 | |
4239 cap->oap->motion_type = MCHAR; | |
4240 if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL) | |
4241 clearopbeep(cap->oap); | |
4242 else | |
4243 { | |
4244 curwin->w_set_curswant = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4245 // Include a Tab for "tx" and for "dfx". |
7 | 4246 if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD |
4247 && (t_cmd || cap->oap->op_type != OP_NOP)) | |
4248 { | |
4249 colnr_T scol, ecol; | |
4250 | |
4251 getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); | |
4252 curwin->w_cursor.coladd = ecol - scol; | |
4253 } | |
4254 else | |
4255 curwin->w_cursor.coladd = 0; | |
4256 adjust_for_sel(cap); | |
4257 #ifdef FEAT_FOLDING | |
4258 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4259 foldOpenCursor(); | |
4260 #endif | |
4261 } | |
4262 } | |
4263 | |
4264 /* | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4265 * "[{", "[(", "]}" or "])": go to Nth unclosed '{', '(', '}' or ')' |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4266 * "[#", "]#": go to start/end of Nth innermost #if..#endif construct. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4267 * "[/", "[*", "]/", "]*": go to Nth comment start/end. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4268 * "[m" or "]m" search for prev/next start of (Java) method. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4269 * "[M" or "]M" search for prev/next end of (Java) method. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4270 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4271 static void |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4272 nv_bracket_block(cmdarg_T *cap, pos_T *old_pos) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4273 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4274 pos_T new_pos = {0, 0, 0}; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4275 pos_T *pos = NULL; // init for GCC |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4276 pos_T prev_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4277 long n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4278 int findc; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4279 int c; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4280 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4281 if (cap->nchar == '*') |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4282 cap->nchar = '/'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4283 prev_pos.lnum = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4284 if (cap->nchar == 'm' || cap->nchar == 'M') |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4285 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4286 if (cap->cmdchar == '[') |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4287 findc = '{'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4288 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4289 findc = '}'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4290 n = 9999; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4291 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4292 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4293 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4294 findc = cap->nchar; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4295 n = cap->count1; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4296 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4297 for ( ; n > 0; --n) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4298 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4299 if ((pos = findmatchlimit(cap->oap, findc, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4300 (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, 0)) == NULL) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4301 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4302 if (new_pos.lnum == 0) // nothing found |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4303 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4304 if (cap->nchar != 'm' && cap->nchar != 'M') |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4305 clearopbeep(cap->oap); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4306 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4307 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4308 pos = &new_pos; // use last one found |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4309 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4310 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4311 prev_pos = new_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4312 curwin->w_cursor = *pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4313 new_pos = *pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4314 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4315 curwin->w_cursor = *old_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4316 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4317 // Handle "[m", "]m", "[M" and "[M". The findmatchlimit() only |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4318 // brought us to the match for "[m" and "]M" when inside a method. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4319 // Try finding the '{' or '}' we want to be at. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4320 // Also repeat for the given count. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4321 if (cap->nchar == 'm' || cap->nchar == 'M') |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4322 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4323 // norm is TRUE for "]M" and "[m" |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4324 int norm = ((findc == '{') == (cap->nchar == 'm')); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4325 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4326 n = cap->count1; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4327 // found a match: we were inside a method |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4328 if (prev_pos.lnum != 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4329 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4330 pos = &prev_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4331 curwin->w_cursor = prev_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4332 if (norm) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4333 --n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4334 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4335 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4336 pos = NULL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4337 while (n > 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4338 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4339 for (;;) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4340 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4341 if ((findc == '{' ? dec_cursor() : inc_cursor()) < 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4342 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4343 // if not found anything, that's an error |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4344 if (pos == NULL) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4345 clearopbeep(cap->oap); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4346 n = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4347 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4348 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4349 c = gchar_cursor(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4350 if (c == '{' || c == '}') |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4351 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4352 // Must have found end/start of class: use it. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4353 // Or found the place to be at. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4354 if ((c == findc && norm) || (n == 1 && !norm)) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4355 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4356 new_pos = curwin->w_cursor; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4357 pos = &new_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4358 n = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4359 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4360 // if no match found at all, we started outside of the |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4361 // class and we're inside now. Just go on. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4362 else if (new_pos.lnum == 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4363 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4364 new_pos = curwin->w_cursor; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4365 pos = &new_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4366 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4367 // found start/end of other method: go to match |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4368 else if ((pos = findmatchlimit(cap->oap, findc, |
27428
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
4369 (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
4370 0)) == NULL) |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4371 n = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4372 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4373 curwin->w_cursor = *pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4374 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4375 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4376 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4377 --n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4378 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4379 curwin->w_cursor = *old_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4380 if (pos == NULL && new_pos.lnum != 0) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4381 clearopbeep(cap->oap); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4382 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4383 if (pos != NULL) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4384 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4385 setpcmark(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4386 curwin->w_cursor = *pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4387 curwin->w_set_curswant = TRUE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4388 #ifdef FEAT_FOLDING |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4389 if ((fdo_flags & FDO_BLOCK) && KeyTyped |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4390 && cap->oap->op_type == OP_NOP) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4391 foldOpenCursor(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4392 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4393 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4394 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4395 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4396 /* |
7 | 4397 * "[" and "]" commands. |
4398 * cap->arg is BACKWARD for "[" and FORWARD for "]". | |
4399 */ | |
4400 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4401 nv_brackets(cmdarg_T *cap) |
7 | 4402 { |
4403 pos_T prev_pos; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4404 pos_T *pos = NULL; // init for GCC |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4405 pos_T old_pos; // cursor position before command |
7 | 4406 int flag; |
4407 long n; | |
4408 | |
4409 cap->oap->motion_type = MCHAR; | |
4410 cap->oap->inclusive = FALSE; | |
4411 old_pos = curwin->w_cursor; | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4412 curwin->w_cursor.coladd = 0; // TODO: don't do this for an error. |
7 | 4413 |
4414 #ifdef FEAT_SEARCHPATH | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4415 // "[f" or "]f" : Edit file under the cursor (same as "gf") |
7 | 4416 if (cap->nchar == 'f') |
4417 nv_gotofile(cap); | |
4418 else | |
4419 #endif | |
4420 | |
4421 #ifdef FEAT_FIND_ID | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4422 // Find the occurrence(s) of the identifier or define under cursor |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4423 // in current and included files or jump to the first occurrence. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4424 // |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4425 // search list jump |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4426 // fwd bwd fwd bwd fwd bwd |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4427 // identifier "]i" "[i" "]I" "[I" "]^I" "[^I" |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4428 // define "]d" "[d" "]D" "[D" "]^D" "[^D" |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27484
diff
changeset
|
4429 if (vim_strchr((char_u *)"iI\011dD\004", cap->nchar) != NULL) |
7 | 4430 { |
4431 char_u *ptr; | |
4432 int len; | |
4433 | |
4434 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) | |
4435 clearop(cap->oap); | |
4436 else | |
4437 { | |
4438 find_pattern_in_path(ptr, 0, len, TRUE, | |
4439 cap->count0 == 0 ? !isupper(cap->nchar) : FALSE, | |
4440 ((cap->nchar & 0xf) == ('d' & 0xf)) ? FIND_DEFINE : FIND_ANY, | |
4441 cap->count1, | |
4442 isupper(cap->nchar) ? ACTION_SHOW_ALL : | |
4443 islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO, | |
4444 cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1, | |
4445 (linenr_T)MAXLNUM); | |
4446 curwin->w_set_curswant = TRUE; | |
4447 } | |
4448 } | |
4449 else | |
4450 #endif | |
4451 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4452 // "[{", "[(", "]}" or "])": go to Nth unclosed '{', '(', '}' or ')' |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4453 // "[#", "]#": go to start/end of Nth innermost #if..#endif construct. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4454 // "[/", "[*", "]/", "]*": go to Nth comment start/end. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4455 // "[m" or "]m" search for prev/next start of (Java) method. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4456 // "[M" or "]M" search for prev/next end of (Java) method. |
7 | 4457 if ( (cap->cmdchar == '[' |
4458 && vim_strchr((char_u *)"{(*/#mM", cap->nchar) != NULL) | |
4459 || (cap->cmdchar == ']' | |
4460 && vim_strchr((char_u *)"})*/#mM", cap->nchar) != NULL)) | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4461 nv_bracket_block(cap, &old_pos); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4462 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4463 // "[[", "[]", "]]" and "][": move to start or end of function |
7 | 4464 else if (cap->nchar == '[' || cap->nchar == ']') |
4465 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4466 if (cap->nchar == cap->cmdchar) // "]]" or "[[" |
7 | 4467 flag = '{'; |
4468 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4469 flag = '}'; // "][" or "[]" |
7 | 4470 |
4471 curwin->w_set_curswant = TRUE; | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4472 // Imitate strange Vi behaviour: When using "]]" with an operator |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4473 // we also stop at '}'. |
503 | 4474 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, flag, |
7 | 4475 (cap->oap->op_type != OP_NOP |
4476 && cap->arg == FORWARD && flag == '{'))) | |
4477 clearopbeep(cap->oap); | |
4478 else | |
4479 { | |
4480 if (cap->oap->op_type == OP_NOP) | |
4481 beginline(BL_WHITE | BL_FIX); | |
4482 #ifdef FEAT_FOLDING | |
4483 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4484 foldOpenCursor(); | |
4485 #endif | |
4486 } | |
4487 } | |
4488 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4489 // "[p", "[P", "]P" and "]p": put with indent adjustment |
7 | 4490 else if (cap->nchar == 'p' || cap->nchar == 'P') |
4491 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
4492 nv_put_opt(cap, TRUE); |
7 | 4493 } |
4494 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4495 // "['", "[`", "]'" and "]`": jump to next mark |
7 | 4496 else if (cap->nchar == '\'' || cap->nchar == '`') |
4497 { | |
4498 pos = &curwin->w_cursor; | |
4499 for (n = cap->count1; n > 0; --n) | |
4500 { | |
4501 prev_pos = *pos; | |
4502 pos = getnextmark(pos, cap->cmdchar == '[' ? BACKWARD : FORWARD, | |
4503 cap->nchar == '\''); | |
4504 if (pos == NULL) | |
4505 break; | |
4506 } | |
4507 if (pos == NULL) | |
4508 pos = &prev_pos; | |
4509 nv_cursormark(cap, cap->nchar == '\'', pos); | |
4510 } | |
4511 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4512 // [ or ] followed by a middle mouse click: put selected text with |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4513 // indent adjustment. Any other button just does as usual. |
2130
279380a812ad
updated for version 7.2.412
Bram Moolenaar <bram@zimbu.org>
parents:
2112
diff
changeset
|
4514 else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) |
7 | 4515 { |
4516 (void)do_mouse(cap->oap, cap->nchar, | |
4517 (cap->cmdchar == ']') ? FORWARD : BACKWARD, | |
4518 cap->count1, PUT_FIXINDENT); | |
4519 } | |
4520 | |
4521 #ifdef FEAT_FOLDING | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4522 // "[z" and "]z": move to start or end of open fold. |
7 | 4523 else if (cap->nchar == 'z') |
4524 { | |
4525 if (foldMoveTo(FALSE, cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4526 cap->count1) == FAIL) | |
4527 clearopbeep(cap->oap); | |
4528 } | |
4529 #endif | |
4530 | |
4531 #ifdef FEAT_DIFF | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4532 // "[c" and "]c": move to next or previous diff-change. |
7 | 4533 else if (cap->nchar == 'c') |
4534 { | |
4535 if (diff_move_to(cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4536 cap->count1) == FAIL) | |
4537 clearopbeep(cap->oap); | |
4538 } | |
4539 #endif | |
4540 | |
737 | 4541 #ifdef FEAT_SPELL |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4542 // "[s", "[S", "]s" and "]S": move to next spell error. |
236 | 4543 else if (cap->nchar == 's' || cap->nchar == 'S') |
4544 { | |
249 | 4545 setpcmark(); |
4546 for (n = 0; n < cap->count1; ++n) | |
498 | 4547 if (spell_move_to(curwin, cap->cmdchar == ']' ? FORWARD : BACKWARD, |
4548 cap->nchar == 's' ? TRUE : FALSE, FALSE, NULL) == 0) | |
249 | 4549 { |
4550 clearopbeep(cap->oap); | |
4551 break; | |
4552 } | |
13088
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4553 else |
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4554 curwin->w_set_curswant = TRUE; |
819 | 4555 # ifdef FEAT_FOLDING |
4556 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4557 foldOpenCursor(); | |
4558 # endif | |
236 | 4559 } |
4560 #endif | |
4561 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4562 // Not a valid cap->nchar. |
7 | 4563 else |
4564 clearopbeep(cap->oap); | |
4565 } | |
4566 | |
4567 /* | |
4568 * Handle Normal mode "%" command. | |
4569 */ | |
4570 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4571 nv_percent(cmdarg_T *cap) |
7 | 4572 { |
4573 pos_T *pos; | |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2281
diff
changeset
|
4574 #if defined(FEAT_FOLDING) |
7 | 4575 linenr_T lnum = curwin->w_cursor.lnum; |
4576 #endif | |
4577 | |
4578 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4579 if (cap->count0) // {cnt}% : goto {cnt} percentage in file |
7 | 4580 { |
4581 if (cap->count0 > 100) | |
4582 clearopbeep(cap->oap); | |
4583 else | |
4584 { | |
4585 cap->oap->motion_type = MLINE; | |
4586 setpcmark(); | |
24010
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4587 // Round up, so 'normal 100%' always jumps at the line line. |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4588 // Beyond 21474836 lines, (ml_line_count * 100 + 99) would |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4589 // overflow on 32-bits, so use a formula with less accuracy |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4590 // to avoid overflows. |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4591 if (curbuf->b_ml.ml_line_count >= 21474836) |
7 | 4592 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L) |
4593 / 100L * cap->count0; | |
4594 else | |
4595 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count * | |
4596 cap->count0 + 99L) / 100L; | |
23762
0f89d58eb3e3
patch 8.2.2422: crash when deleting with line number out of range
Bram Moolenaar <Bram@vim.org>
parents:
23687
diff
changeset
|
4597 if (curwin->w_cursor.lnum < 1) |
0f89d58eb3e3
patch 8.2.2422: crash when deleting with line number out of range
Bram Moolenaar <Bram@vim.org>
parents:
23687
diff
changeset
|
4598 curwin->w_cursor.lnum = 1; |
7 | 4599 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
4600 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
4601 beginline(BL_SOL | BL_FIX); | |
4602 } | |
4603 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4604 else // "%" : go to matching paren |
7 | 4605 { |
4606 cap->oap->motion_type = MCHAR; | |
4607 cap->oap->use_reg_one = TRUE; | |
4608 if ((pos = findmatch(cap->oap, NUL)) == NULL) | |
4609 clearopbeep(cap->oap); | |
4610 else | |
4611 { | |
4612 setpcmark(); | |
4613 curwin->w_cursor = *pos; | |
4614 curwin->w_set_curswant = TRUE; | |
4615 curwin->w_cursor.coladd = 0; | |
4616 adjust_for_sel(cap); | |
4617 } | |
4618 } | |
4619 #ifdef FEAT_FOLDING | |
4620 if (cap->oap->op_type == OP_NOP | |
4621 && lnum != curwin->w_cursor.lnum | |
4622 && (fdo_flags & FDO_PERCENT) | |
4623 && KeyTyped) | |
4624 foldOpenCursor(); | |
4625 #endif | |
4626 } | |
4627 | |
4628 /* | |
4629 * Handle "(" and ")" commands. | |
4630 * cap->arg is BACKWARD for "(" and FORWARD for ")". | |
4631 */ | |
4632 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4633 nv_brace(cmdarg_T *cap) |
7 | 4634 { |
4635 cap->oap->motion_type = MCHAR; | |
4636 cap->oap->use_reg_one = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4637 // The motion used to be inclusive for "(", but that is not what Vi does. |
620 | 4638 cap->oap->inclusive = FALSE; |
7 | 4639 curwin->w_set_curswant = TRUE; |
4640 | |
4641 if (findsent(cap->arg, cap->count1) == FAIL) | |
4642 clearopbeep(cap->oap); | |
4643 else | |
4644 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4645 // Don't leave the cursor on the NUL past end of line. |
1505 | 4646 adjust_cursor(cap->oap); |
7 | 4647 curwin->w_cursor.coladd = 0; |
4648 #ifdef FEAT_FOLDING | |
4649 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4650 foldOpenCursor(); | |
4651 #endif | |
4652 } | |
4653 } | |
4654 | |
4655 /* | |
4656 * "m" command: Mark a position. | |
4657 */ | |
4658 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4659 nv_mark(cmdarg_T *cap) |
7 | 4660 { |
4661 if (!checkclearop(cap->oap)) | |
4662 { | |
4663 if (setmark(cap->nchar) == FAIL) | |
4664 clearopbeep(cap->oap); | |
4665 } | |
4666 } | |
4667 | |
4668 /* | |
4669 * "{" and "}" commands. | |
4670 * cmd->arg is BACKWARD for "{" and FORWARD for "}". | |
4671 */ | |
4672 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4673 nv_findpar(cmdarg_T *cap) |
7 | 4674 { |
4675 cap->oap->motion_type = MCHAR; | |
4676 cap->oap->inclusive = FALSE; | |
4677 cap->oap->use_reg_one = TRUE; | |
4678 curwin->w_set_curswant = TRUE; | |
503 | 4679 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE)) |
7 | 4680 clearopbeep(cap->oap); |
4681 else | |
4682 { | |
4683 curwin->w_cursor.coladd = 0; | |
4684 #ifdef FEAT_FOLDING | |
4685 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4686 foldOpenCursor(); | |
4687 #endif | |
4688 } | |
4689 } | |
4690 | |
4691 /* | |
4692 * "u" command: Undo or make lower case. | |
4693 */ | |
4694 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4695 nv_undo(cmdarg_T *cap) |
7 | 4696 { |
5735 | 4697 if (cap->oap->op_type == OP_LOWER || VIsual_active) |
7 | 4698 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4699 // translate "<Visual>u" to "<Visual>gu" and "guu" to "gugu" |
7 | 4700 cap->cmdchar = 'g'; |
4701 cap->nchar = 'u'; | |
4702 nv_operator(cap); | |
4703 } | |
4704 else | |
4705 nv_kundo(cap); | |
4706 } | |
4707 | |
4708 /* | |
4709 * <Undo> command. | |
4710 */ | |
4711 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4712 nv_kundo(cmdarg_T *cap) |
7 | 4713 { |
4714 if (!checkclearopq(cap->oap)) | |
4715 { | |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4716 #ifdef FEAT_JOB_CHANNEL |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4717 if (bt_prompt(curbuf)) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4718 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4719 clearopbeep(cap->oap); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4720 return; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4721 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4722 #endif |
7 | 4723 u_undo((int)cap->count1); |
4724 curwin->w_set_curswant = TRUE; | |
4725 } | |
4726 } | |
4727 | |
4728 /* | |
4729 * Handle the "r" command. | |
4730 */ | |
4731 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4732 nv_replace(cmdarg_T *cap) |
7 | 4733 { |
4734 char_u *ptr; | |
4735 int had_ctrl_v; | |
4736 long n; | |
4737 | |
4738 if (checkclearop(cap->oap)) | |
4739 return; | |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4740 #ifdef FEAT_JOB_CHANNEL |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4741 if (bt_prompt(curbuf) && !prompt_curpos_editable()) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4742 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4743 clearopbeep(cap->oap); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4744 return; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4745 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4746 #endif |
7 | 4747 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4748 // get another character |
7 | 4749 if (cap->nchar == Ctrl_V) |
4750 { | |
4751 had_ctrl_v = Ctrl_V; | |
23076
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
4752 cap->nchar = get_literal(FALSE); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4753 // Don't redo a multibyte character with CTRL-V. |
7 | 4754 if (cap->nchar > DEL) |
4755 had_ctrl_v = NUL; | |
4756 } | |
4757 else | |
4758 had_ctrl_v = NUL; | |
4759 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4760 // Abort if the character is a special key. |
1343 | 4761 if (IS_SPECIAL(cap->nchar)) |
4762 { | |
4763 clearopbeep(cap->oap); | |
4764 return; | |
4765 } | |
4766 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4767 // Visual mode "r" |
7 | 4768 if (VIsual_active) |
4769 { | |
1797 | 4770 if (got_int) |
4771 reset_VIsual(); | |
5428 | 4772 if (had_ctrl_v) |
4773 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4774 // Use a special (negative) number to make a difference between a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4775 // literal CR or NL and a line break. |
13202
2941a86f8aaa
patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents:
13088
diff
changeset
|
4776 if (cap->nchar == CAR) |
2941a86f8aaa
patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents:
13088
diff
changeset
|
4777 cap->nchar = REPLACE_CR_NCHAR; |
2941a86f8aaa
patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents:
13088
diff
changeset
|
4778 else if (cap->nchar == NL) |
2941a86f8aaa
patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents:
13088
diff
changeset
|
4779 cap->nchar = REPLACE_NL_NCHAR; |
5428 | 4780 } |
7 | 4781 nv_operator(cap); |
4782 return; | |
4783 } | |
4784 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4785 // Break tabs, etc. |
7 | 4786 if (virtual_active()) |
4787 { | |
4788 if (u_save_cursor() == FAIL) | |
4789 return; | |
4790 if (gchar_cursor() == NUL) | |
4791 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4792 // Add extra space and put the cursor on the first one. |
7 | 4793 coladvance_force((colnr_T)(getviscol() + cap->count1)); |
4794 curwin->w_cursor.col -= cap->count1; | |
4795 } | |
4796 else if (gchar_cursor() == TAB) | |
4797 coladvance_force(getviscol()); | |
4798 } | |
4799 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4800 // Abort if not enough characters to replace. |
7 | 4801 ptr = ml_get_cursor(); |
1343 | 4802 if (STRLEN(ptr) < (unsigned)cap->count1 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4803 || (has_mbyte && mb_charlen(ptr) < cap->count1)) |
7 | 4804 { |
4805 clearopbeep(cap->oap); | |
4806 return; | |
4807 } | |
4808 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4809 // Replacing with a TAB is done by edit() when it is complicated because |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4810 // 'expandtab' or 'smarttab' is set. CTRL-V TAB inserts a literal TAB. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4811 // Other characters are done below to avoid problems with things like |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4812 // CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC). |
7 | 4813 if (had_ctrl_v != Ctrl_V && cap->nchar == '\t' && (curbuf->b_p_et || p_sta)) |
4814 { | |
4815 stuffnumReadbuff(cap->count1); | |
4816 stuffcharReadbuff('R'); | |
4817 stuffcharReadbuff('\t'); | |
4818 stuffcharReadbuff(ESC); | |
4819 return; | |
4820 } | |
4821 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4822 // save line for undo |
7 | 4823 if (u_save_cursor() == FAIL) |
4824 return; | |
4825 | |
4826 if (had_ctrl_v != Ctrl_V && (cap->nchar == '\r' || cap->nchar == '\n')) | |
4827 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4828 // Replace character(s) by a single newline. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4829 // Strange vi behaviour: Only one newline is inserted. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4830 // Delete the characters here. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4831 // Insert the newline with an insert command, takes care of |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4832 // autoindent. The insert command depends on being on the last |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4833 // character of a line or not. |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4834 (void)del_chars(cap->count1, FALSE); // delete the characters |
7 | 4835 stuffcharReadbuff('\r'); |
4836 stuffcharReadbuff(ESC); | |
4837 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4838 // Give 'r' to edit(), to get the redo command right. |
7 | 4839 invoke_edit(cap, TRUE, 'r', FALSE); |
4840 } | |
4841 else | |
4842 { | |
4843 prep_redo(cap->oap->regname, cap->count1, | |
4844 NUL, 'r', NUL, had_ctrl_v, cap->nchar); | |
4845 | |
4846 curbuf->b_op_start = curwin->w_cursor; | |
4847 if (has_mbyte) | |
4848 { | |
4849 int old_State = State; | |
4850 | |
4851 if (cap->ncharC1 != 0) | |
4852 AppendCharToRedobuff(cap->ncharC1); | |
4853 if (cap->ncharC2 != 0) | |
4854 AppendCharToRedobuff(cap->ncharC2); | |
4855 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4856 // This is slow, but it handles replacing a single-byte with a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4857 // multi-byte and the other way around. Also handles adding |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4858 // composing characters for utf-8. |
7 | 4859 for (n = cap->count1; n > 0; --n) |
4860 { | |
4861 State = REPLACE; | |
3501 | 4862 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
4863 { | |
4864 int c = ins_copychar(curwin->w_cursor.lnum | |
4865 + (cap->nchar == Ctrl_Y ? -1 : 1)); | |
4866 if (c != NUL) | |
4867 ins_char(c); | |
4868 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4869 // will be decremented further down |
3501 | 4870 ++curwin->w_cursor.col; |
4871 } | |
4872 else | |
4873 ins_char(cap->nchar); | |
7 | 4874 State = old_State; |
4875 if (cap->ncharC1 != 0) | |
4876 ins_char(cap->ncharC1); | |
4877 if (cap->ncharC2 != 0) | |
4878 ins_char(cap->ncharC2); | |
4879 } | |
4880 } | |
4881 else | |
4882 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4883 // Replace the characters within one line. |
7 | 4884 for (n = cap->count1; n > 0; --n) |
4885 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4886 // Get ptr again, because u_save and/or showmatch() will have |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4887 // released the line. This may also happen in ins_copychar(). |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4888 // At the same time we let know that the line will be changed. |
3501 | 4889 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
4890 { | |
4891 int c = ins_copychar(curwin->w_cursor.lnum | |
4892 + (cap->nchar == Ctrl_Y ? -1 : 1)); | |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4893 |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4894 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); |
3501 | 4895 if (c != NUL) |
4896 ptr[curwin->w_cursor.col] = c; | |
4897 } | |
4898 else | |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4899 { |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4900 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); |
3501 | 4901 ptr[curwin->w_cursor.col] = cap->nchar; |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4902 } |
7 | 4903 if (p_sm && msg_silent == 0) |
4904 showmatch(cap->nchar); | |
4905 ++curwin->w_cursor.col; | |
4906 } | |
4907 #ifdef FEAT_NETBEANS_INTG | |
2210 | 4908 if (netbeans_active()) |
7 | 4909 { |
2210 | 4910 colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1); |
7 | 4911 |
33 | 4912 netbeans_removed(curbuf, curwin->w_cursor.lnum, start, |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27418
diff
changeset
|
4913 cap->count1); |
7 | 4914 netbeans_inserted(curbuf, curwin->w_cursor.lnum, start, |
33 | 4915 &ptr[start], (int)cap->count1); |
7 | 4916 } |
4917 #endif | |
4918 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4919 // mark the buffer as changed and prepare for displaying |
7 | 4920 changed_bytes(curwin->w_cursor.lnum, |
4921 (colnr_T)(curwin->w_cursor.col - cap->count1)); | |
4922 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4923 --curwin->w_cursor.col; // cursor on the last replaced char |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4924 // if the character on the left of the current cursor is a multi-byte |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4925 // character, move two characters left |
7 | 4926 if (has_mbyte) |
4927 mb_adjust_cursor(); | |
4928 curbuf->b_op_end = curwin->w_cursor; | |
4929 curwin->w_set_curswant = TRUE; | |
4930 set_last_insert(cap->nchar); | |
4931 } | |
4932 } | |
4933 | |
4934 /* | |
4935 * 'o': Exchange start and end of Visual area. | |
4936 * 'O': same, but in block mode exchange left and right corners. | |
4937 */ | |
4938 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4939 v_swap_corners(int cmdchar) |
7 | 4940 { |
4941 pos_T old_cursor; | |
4942 colnr_T left, right; | |
4943 | |
4944 if (cmdchar == 'O' && VIsual_mode == Ctrl_V) | |
4945 { | |
4946 old_cursor = curwin->w_cursor; | |
4947 getvcols(curwin, &old_cursor, &VIsual, &left, &right); | |
4948 curwin->w_cursor.lnum = VIsual.lnum; | |
4949 coladvance(left); | |
4950 VIsual = curwin->w_cursor; | |
4951 | |
4952 curwin->w_cursor.lnum = old_cursor.lnum; | |
4953 curwin->w_curswant = right; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4954 // 'selection "exclusive" and cursor at right-bottom corner: move it |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4955 // right one column |
7 | 4956 if (old_cursor.lnum >= VIsual.lnum && *p_sel == 'e') |
4957 ++curwin->w_curswant; | |
4958 coladvance(curwin->w_curswant); | |
4959 if (curwin->w_cursor.col == old_cursor.col | |
4960 && (!virtual_active() | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4961 || curwin->w_cursor.coladd == old_cursor.coladd)) |
7 | 4962 { |
4963 curwin->w_cursor.lnum = VIsual.lnum; | |
4964 if (old_cursor.lnum <= VIsual.lnum && *p_sel == 'e') | |
4965 ++right; | |
4966 coladvance(right); | |
4967 VIsual = curwin->w_cursor; | |
4968 | |
4969 curwin->w_cursor.lnum = old_cursor.lnum; | |
4970 coladvance(left); | |
4971 curwin->w_curswant = left; | |
4972 } | |
4973 } | |
4974 else | |
4975 { | |
4976 old_cursor = curwin->w_cursor; | |
4977 curwin->w_cursor = VIsual; | |
4978 VIsual = old_cursor; | |
4979 curwin->w_set_curswant = TRUE; | |
4980 } | |
4981 } | |
4982 | |
4983 /* | |
4984 * "R" (cap->arg is FALSE) and "gR" (cap->arg is TRUE). | |
4985 */ | |
4986 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4987 nv_Replace(cmdarg_T *cap) |
7 | 4988 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4989 if (VIsual_active) // "R" is replace lines |
7 | 4990 { |
4991 cap->cmdchar = 'c'; | |
4992 cap->nchar = NUL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4993 VIsual_mode_orig = VIsual_mode; // remember original area for gv |
7 | 4994 VIsual_mode = 'V'; |
4995 nv_operator(cap); | |
4996 } | |
5735 | 4997 else if (!checkclearopq(cap->oap)) |
7 | 4998 { |
4999 if (!curbuf->b_p_ma) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
5000 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 5001 else |
5002 { | |
5003 if (virtual_active()) | |
5004 coladvance(getviscol()); | |
5005 invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE); | |
5006 } | |
5007 } | |
5008 } | |
5009 | |
5010 /* | |
5011 * "gr". | |
5012 */ | |
5013 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5014 nv_vreplace(cmdarg_T *cap) |
7 | 5015 { |
5016 if (VIsual_active) | |
5017 { | |
5018 cap->cmdchar = 'r'; | |
5019 cap->nchar = cap->extra_char; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5020 nv_replace(cap); // Do same as "r" in Visual mode for now |
7 | 5021 } |
5735 | 5022 else if (!checkclearopq(cap->oap)) |
7 | 5023 { |
5024 if (!curbuf->b_p_ma) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
5025 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 5026 else |
5027 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5028 if (cap->extra_char == Ctrl_V) // get another character |
23076
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
5029 cap->extra_char = get_literal(FALSE); |
7 | 5030 stuffcharReadbuff(cap->extra_char); |
5031 stuffcharReadbuff(ESC); | |
5032 if (virtual_active()) | |
5033 coladvance(getviscol()); | |
5034 invoke_edit(cap, TRUE, 'v', FALSE); | |
5035 } | |
5036 } | |
5037 } | |
5038 | |
5039 /* | |
5040 * Swap case for "~" command, when it does not work like an operator. | |
5041 */ | |
5042 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5043 n_swapchar(cmdarg_T *cap) |
7 | 5044 { |
5045 long n; | |
5046 pos_T startpos; | |
5047 int did_change = 0; | |
5048 #ifdef FEAT_NETBEANS_INTG | |
5049 pos_T pos; | |
5050 char_u *ptr; | |
5051 int count; | |
5052 #endif | |
5053 | |
5054 if (checkclearopq(cap->oap)) | |
5055 return; | |
5056 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5057 if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) |
7 | 5058 { |
5059 clearopbeep(cap->oap); | |
5060 return; | |
5061 } | |
5062 | |
5063 prep_redo_cmd(cap); | |
5064 | |
5065 if (u_save_cursor() == FAIL) | |
5066 return; | |
5067 | |
5068 startpos = curwin->w_cursor; | |
5069 #ifdef FEAT_NETBEANS_INTG | |
5070 pos = startpos; | |
5071 #endif | |
5072 for (n = cap->count1; n > 0; --n) | |
5073 { | |
5074 did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); | |
5075 inc_cursor(); | |
5076 if (gchar_cursor() == NUL) | |
5077 { | |
5078 if (vim_strchr(p_ww, '~') != NULL | |
5079 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
5080 { | |
5081 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5082 if (netbeans_active()) |
7 | 5083 { |
5084 if (did_change) | |
5085 { | |
5086 ptr = ml_get(pos.lnum); | |
835 | 5087 count = (int)STRLEN(ptr) - pos.col; |
33 | 5088 netbeans_removed(curbuf, pos.lnum, pos.col, |
5089 (long)count); | |
7 | 5090 netbeans_inserted(curbuf, pos.lnum, pos.col, |
33 | 5091 &ptr[pos.col], count); |
7 | 5092 } |
5093 pos.col = 0; | |
5094 pos.lnum++; | |
5095 } | |
5096 #endif | |
5097 ++curwin->w_cursor.lnum; | |
5098 curwin->w_cursor.col = 0; | |
5099 if (n > 1) | |
5100 { | |
5101 if (u_savesub(curwin->w_cursor.lnum) == FAIL) | |
5102 break; | |
5103 u_clearline(); | |
5104 } | |
5105 } | |
5106 else | |
5107 break; | |
5108 } | |
5109 } | |
5110 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5111 if (did_change && netbeans_active()) |
7 | 5112 { |
5113 ptr = ml_get(pos.lnum); | |
5114 count = curwin->w_cursor.col - pos.col; | |
33 | 5115 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count); |
5116 netbeans_inserted(curbuf, pos.lnum, pos.col, &ptr[pos.col], count); | |
7 | 5117 } |
5118 #endif | |
5119 | |
5120 | |
5121 check_cursor(); | |
5122 curwin->w_set_curswant = TRUE; | |
5123 if (did_change) | |
5124 { | |
5125 changed_lines(startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1, | |
5126 0L); | |
5127 curbuf->b_op_start = startpos; | |
5128 curbuf->b_op_end = curwin->w_cursor; | |
5129 if (curbuf->b_op_end.col > 0) | |
5130 --curbuf->b_op_end.col; | |
5131 } | |
5132 } | |
5133 | |
5134 /* | |
5135 * Move cursor to mark. | |
5136 */ | |
5137 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5138 nv_cursormark(cmdarg_T *cap, int flag, pos_T *pos) |
7 | 5139 { |
5140 if (check_mark(pos) == FAIL) | |
5141 clearop(cap->oap); | |
5142 else | |
5143 { | |
5144 if (cap->cmdchar == '\'' | |
5145 || cap->cmdchar == '`' | |
5146 || cap->cmdchar == '[' | |
5147 || cap->cmdchar == ']') | |
5148 setpcmark(); | |
5149 curwin->w_cursor = *pos; | |
5150 if (flag) | |
5151 beginline(BL_WHITE | BL_FIX); | |
5152 else | |
5153 check_cursor(); | |
5154 } | |
5155 cap->oap->motion_type = flag ? MLINE : MCHAR; | |
5156 if (cap->cmdchar == '`') | |
5157 cap->oap->use_reg_one = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5158 cap->oap->inclusive = FALSE; // ignored if not MCHAR |
7 | 5159 curwin->w_set_curswant = TRUE; |
5160 } | |
5161 | |
5162 /* | |
5163 * Handle commands that are operators in Visual mode. | |
5164 */ | |
5165 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5166 v_visop(cmdarg_T *cap) |
7 | 5167 { |
5168 static char_u trans[] = "YyDdCcxdXdAAIIrr"; | |
5169 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5170 // Uppercase means linewise, except in block mode, then "D" deletes till |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5171 // the end of the line, and "C" replaces till EOL |
7 | 5172 if (isupper(cap->cmdchar)) |
5173 { | |
5174 if (VIsual_mode != Ctrl_V) | |
4213 | 5175 { |
5176 VIsual_mode_orig = VIsual_mode; | |
7 | 5177 VIsual_mode = 'V'; |
4213 | 5178 } |
7 | 5179 else if (cap->cmdchar == 'C' || cap->cmdchar == 'D') |
5180 curwin->w_curswant = MAXCOL; | |
5181 } | |
5182 cap->cmdchar = *(vim_strchr(trans, cap->cmdchar) + 1); | |
5183 nv_operator(cap); | |
5184 } | |
5185 | |
5186 /* | |
5187 * "s" and "S" commands. | |
5188 */ | |
5189 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5190 nv_subst(cmdarg_T *cap) |
7 | 5191 { |
13298
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5192 #ifdef FEAT_TERMINAL |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
23165
diff
changeset
|
5193 // When showing output of term_dumpdiff() swap the top and bottom. |
13298
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5194 if (term_swap_diff() == OK) |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5195 return; |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5196 #endif |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
5197 #ifdef FEAT_JOB_CHANNEL |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
5198 if (bt_prompt(curbuf) && !prompt_curpos_editable()) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
5199 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
5200 clearopbeep(cap->oap); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
5201 return; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
5202 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
5203 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5204 if (VIsual_active) // "vs" and "vS" are the same as "vc" |
7 | 5205 { |
5206 if (cap->cmdchar == 'S') | |
4213 | 5207 { |
5208 VIsual_mode_orig = VIsual_mode; | |
7 | 5209 VIsual_mode = 'V'; |
4213 | 5210 } |
7 | 5211 cap->cmdchar = 'c'; |
5212 nv_operator(cap); | |
5213 } | |
5214 else | |
5215 nv_optrans(cap); | |
5216 } | |
5217 | |
5218 /* | |
5219 * Abbreviated commands. | |
5220 */ | |
5221 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5222 nv_abbrev(cmdarg_T *cap) |
7 | 5223 { |
5224 if (cap->cmdchar == K_DEL || cap->cmdchar == K_KDEL) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5225 cap->cmdchar = 'x'; // DEL key behaves like 'x' |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5226 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5227 // in Visual mode these commands are operators |
7 | 5228 if (VIsual_active) |
5229 v_visop(cap); | |
5230 else | |
5231 nv_optrans(cap); | |
5232 } | |
5233 | |
5234 /* | |
5235 * Translate a command into another command. | |
5236 */ | |
5237 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5238 nv_optrans(cmdarg_T *cap) |
7 | 5239 { |
5240 static char_u *(ar[8]) = {(char_u *)"dl", (char_u *)"dh", | |
5241 (char_u *)"d$", (char_u *)"c$", | |
5242 (char_u *)"cl", (char_u *)"cc", | |
5243 (char_u *)"yy", (char_u *)":s\r"}; | |
5244 static char_u *str = (char_u *)"xXDCsSY&"; | |
5245 | |
5246 if (!checkclearopq(cap->oap)) | |
5247 { | |
18114
90b0af9ba4ff
patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents:
18045
diff
changeset
|
5248 // In Vi "2D" doesn't delete the next line. Can't translate it |
90b0af9ba4ff
patch 8.1.2052: using "x" before a closed fold may delete that fold
Bram Moolenaar <Bram@vim.org>
parents:
18045
diff
changeset
|
5249 // either, because "2." should also not use the count. |
164 | 5250 if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL) |
5251 { | |
5252 cap->oap->start = curwin->w_cursor; | |
5253 cap->oap->op_type = OP_DELETE; | |
1490 | 5254 #ifdef FEAT_EVAL |
5255 set_op_var(OP_DELETE); | |
5256 #endif | |
164 | 5257 cap->count1 = 1; |
5258 nv_dollar(cap); | |
5259 finish_op = TRUE; | |
5260 ResetRedobuff(); | |
5261 AppendCharToRedobuff('D'); | |
5262 } | |
5263 else | |
5264 { | |
5265 if (cap->count0) | |
5266 stuffnumReadbuff(cap->count0); | |
18128
aeabc666a119
patch 8.1.2059: fix for "x" deleting a fold has side effects
Bram Moolenaar <Bram@vim.org>
parents:
18114
diff
changeset
|
5267 stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]); |
164 | 5268 } |
7 | 5269 } |
5270 cap->opcount = 0; | |
5271 } | |
5272 | |
5273 /* | |
5274 * "'" and "`" commands. Also for "g'" and "g`". | |
5275 * cap->arg is TRUE for "'" and "g'". | |
5276 */ | |
5277 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5278 nv_gomark(cmdarg_T *cap) |
7 | 5279 { |
5280 pos_T *pos; | |
5281 int c; | |
5282 #ifdef FEAT_FOLDING | |
4017 | 5283 pos_T old_cursor = curwin->w_cursor; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5284 int old_KeyTyped = KeyTyped; // getting file may reset it |
7 | 5285 #endif |
5286 | |
5287 if (cap->cmdchar == 'g') | |
5288 c = cap->extra_char; | |
5289 else | |
5290 c = cap->nchar; | |
5291 pos = getmark(c, (cap->oap->op_type == OP_NOP)); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5292 if (pos == (pos_T *)-1) // jumped to other file |
7 | 5293 { |
5294 if (cap->arg) | |
5295 { | |
5296 check_cursor_lnum(); | |
5297 beginline(BL_WHITE | BL_FIX); | |
5298 } | |
5299 else | |
5300 check_cursor(); | |
5301 } | |
5302 else | |
5303 nv_cursormark(cap, cap->arg, pos); | |
5304 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5305 // May need to clear the coladd that a mark includes. |
7 | 5306 if (!virtual_active()) |
5307 curwin->w_cursor.coladd = 0; | |
12164
5d82470552ce
patch 8.0.0962: crash with virtualedit and joining lines
Christian Brabandt <cb@256bit.org>
parents:
12136
diff
changeset
|
5308 check_cursor_col(); |
7 | 5309 #ifdef FEAT_FOLDING |
5310 if (cap->oap->op_type == OP_NOP | |
4057 | 5311 && pos != NULL |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5312 && (pos == (pos_T *)-1 || !EQUAL_POS(old_cursor, *pos)) |
7 | 5313 && (fdo_flags & FDO_MARK) |
5314 && old_KeyTyped) | |
5315 foldOpenCursor(); | |
5316 #endif | |
5317 } | |
5318 | |
5319 /* | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5320 * Handle CTRL-O, CTRL-I, "g;", "g," and "CTRL-Tab" commands. |
7 | 5321 */ |
5322 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5323 nv_pcmark(cmdarg_T *cap) |
7 | 5324 { |
5325 pos_T *pos; | |
26532
255bc9a08e58
patch 8.2.3795: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
26516
diff
changeset
|
5326 #ifdef FEAT_FOLDING |
7 | 5327 linenr_T lnum = curwin->w_cursor.lnum; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5328 int old_KeyTyped = KeyTyped; // getting file may reset it |
26532
255bc9a08e58
patch 8.2.3795: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
26516
diff
changeset
|
5329 #endif |
7 | 5330 |
5331 if (!checkclearopq(cap->oap)) | |
5332 { | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5333 if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5334 { |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5335 if (goto_tabpage_lastused() == FAIL) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5336 clearopbeep(cap->oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5337 return; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5338 } |
7 | 5339 if (cap->cmdchar == 'g') |
5340 pos = movechangelist((int)cap->count1); | |
5341 else | |
5342 pos = movemark((int)cap->count1); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5343 if (pos == (pos_T *)-1) // jump to other file |
7 | 5344 { |
5345 curwin->w_set_curswant = TRUE; | |
5346 check_cursor(); | |
5347 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5348 else if (pos != NULL) // can jump |
7 | 5349 nv_cursormark(cap, FALSE, pos); |
5350 else if (cap->cmdchar == 'g') | |
5351 { | |
5352 if (curbuf->b_changelistlen == 0) | |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5353 emsg(_(e_changelist_is_empty)); |
7 | 5354 else if (cap->count1 < 0) |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5355 emsg(_(e_at_start_of_changelist)); |
7 | 5356 else |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5357 emsg(_(e_at_end_of_changelist)); |
7 | 5358 } |
5359 else | |
5360 clearopbeep(cap->oap); | |
5361 # ifdef FEAT_FOLDING | |
5362 if (cap->oap->op_type == OP_NOP | |
5363 && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum) | |
5364 && (fdo_flags & FDO_MARK) | |
5365 && old_KeyTyped) | |
5366 foldOpenCursor(); | |
5367 # endif | |
5368 } | |
5369 } | |
5370 | |
5371 /* | |
5372 * Handle '"' command. | |
5373 */ | |
5374 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5375 nv_regname(cmdarg_T *cap) |
7 | 5376 { |
5377 if (checkclearop(cap->oap)) | |
5378 return; | |
5379 #ifdef FEAT_EVAL | |
5380 if (cap->nchar == '=') | |
5381 cap->nchar = get_expr_register(); | |
5382 #endif | |
5383 if (cap->nchar != NUL && valid_yank_reg(cap->nchar, FALSE)) | |
5384 { | |
5385 cap->oap->regname = cap->nchar; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5386 cap->opcount = cap->count0; // remember count before '"' |
7 | 5387 #ifdef FEAT_EVAL |
5388 set_reg_var(cap->oap->regname); | |
5389 #endif | |
5390 } | |
5391 else | |
5392 clearopbeep(cap->oap); | |
5393 } | |
5394 | |
5395 /* | |
5396 * Handle "v", "V" and "CTRL-V" commands. | |
5397 * Also for "gh", "gH" and "g^H" commands: Always start Select mode, cap->arg | |
5398 * is TRUE. | |
167 | 5399 * Handle CTRL-Q just like CTRL-V. |
7 | 5400 */ |
5401 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5402 nv_visual(cmdarg_T *cap) |
7 | 5403 { |
167 | 5404 if (cap->cmdchar == Ctrl_Q) |
5405 cap->cmdchar = Ctrl_V; | |
5406 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5407 // 'v', 'V' and CTRL-V can be used while an operator is pending to make it |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5408 // characterwise, linewise, or blockwise. |
7 | 5409 if (cap->oap->op_type != OP_NOP) |
5410 { | |
15279
54457fc4af0b
patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
5411 motion_force = cap->oap->motion_force = cap->cmdchar; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5412 finish_op = FALSE; // operator doesn't finish now but later |
7 | 5413 return; |
5414 } | |
5415 | |
5416 VIsual_select = cap->arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5417 if (VIsual_active) // change Visual mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5418 { |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5419 if (VIsual_mode == cap->cmdchar) // stop visual mode |
7 | 5420 end_visual_mode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5421 else // toggle char/block mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5422 { // or char/line mode |
7 | 5423 VIsual_mode = cap->cmdchar; |
5424 showmode(); | |
25790
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25786
diff
changeset
|
5425 trigger_modechanged(); |
7 | 5426 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5427 redraw_curbuf_later(INVERTED); // update the inversion |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5428 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5429 else // start Visual mode |
7 | 5430 { |
5431 check_visual_highlight(); | |
3537 | 5432 if (cap->count0 > 0 && resel_VIsual_mode != NUL) |
5433 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5434 // use previously selected part |
7 | 5435 VIsual = curwin->w_cursor; |
5436 | |
5437 VIsual_active = TRUE; | |
5438 VIsual_reselect = TRUE; | |
5439 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5440 // start Select mode when 'selectmode' contains "cmd" |
7 | 5441 may_start_select('c'); |
5442 setmouse(); | |
641 | 5443 if (p_smd && msg_silent == 0) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5444 redraw_cmdline = TRUE; // show visual mode later |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
5445 // For V and ^V, we multiply the number of lines even if there |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
5446 // was only one -- webb |
7 | 5447 if (resel_VIsual_mode != 'v' || resel_VIsual_line_count > 1) |
5448 { | |
5449 curwin->w_cursor.lnum += | |
5450 resel_VIsual_line_count * cap->count0 - 1; | |
25921
203b0f3a741a
patch 8.2.3494: illegal memory access in utf_head_off
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
5451 check_cursor(); |
7 | 5452 } |
5453 VIsual_mode = resel_VIsual_mode; | |
5454 if (VIsual_mode == 'v') | |
5455 { | |
5456 if (resel_VIsual_line_count <= 1) | |
3125 | 5457 { |
5458 validate_virtcol(); | |
5459 curwin->w_curswant = curwin->w_virtcol | |
5460 + resel_VIsual_vcol * cap->count0 - 1; | |
5461 } | |
7 | 5462 else |
3125 | 5463 curwin->w_curswant = resel_VIsual_vcol; |
5464 coladvance(curwin->w_curswant); | |
7 | 5465 } |
3125 | 5466 if (resel_VIsual_vcol == MAXCOL) |
7 | 5467 { |
5468 curwin->w_curswant = MAXCOL; | |
5469 coladvance((colnr_T)MAXCOL); | |
5470 } | |
5471 else if (VIsual_mode == Ctrl_V) | |
5472 { | |
5473 validate_virtcol(); | |
5474 curwin->w_curswant = curwin->w_virtcol | |
3125 | 5475 + resel_VIsual_vcol * cap->count0 - 1; |
7 | 5476 coladvance(curwin->w_curswant); |
5477 } | |
5478 else | |
5479 curwin->w_set_curswant = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5480 redraw_curbuf_later(INVERTED); // show the inversion |
7 | 5481 } |
5482 else | |
5483 { | |
5484 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5485 // start Select mode when 'selectmode' contains "cmd" |
7 | 5486 may_start_select('c'); |
5487 n_start_visual_mode(cap->cmdchar); | |
3537 | 5488 if (VIsual_mode != 'V' && *p_sel == 'e') |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5489 ++cap->count1; // include one more char |
3537 | 5490 if (cap->count0 > 0 && --cap->count1 > 0) |
5491 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5492 // With a count select that many characters or lines. |
3537 | 5493 if (VIsual_mode == 'v' || VIsual_mode == Ctrl_V) |
5494 nv_right(cap); | |
5495 else if (VIsual_mode == 'V') | |
5496 nv_down(cap); | |
5497 } | |
7 | 5498 } |
5499 } | |
5500 } | |
5501 | |
5502 /* | |
5503 * Start selection for Shift-movement keys. | |
5504 */ | |
5505 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5506 start_selection(void) |
7 | 5507 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5508 // if 'selectmode' contains "key", start Select mode |
7 | 5509 may_start_select('k'); |
5510 n_start_visual_mode('v'); | |
5511 } | |
5512 | |
5513 /* | |
5514 * Start Select mode, if "c" is in 'selectmode' and not in a mapping or menu. | |
5515 */ | |
5516 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5517 may_start_select(int c) |
7 | 5518 { |
5519 VIsual_select = (stuff_empty() && typebuf_typed() | |
5520 && (vim_strchr(p_slm, c) != NULL)); | |
5521 } | |
5522 | |
5523 /* | |
5524 * Start Visual mode "c". | |
5525 * Should set VIsual_select before calling this. | |
5526 */ | |
5527 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5528 n_start_visual_mode(int c) |
7 | 5529 { |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5530 #ifdef FEAT_CONCEAL |
25074
aa55d6d17625
patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5531 int cursor_line_was_concealed = curwin->w_p_cole > 0 |
aa55d6d17625
patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5532 && conceal_cursor_line(curwin); |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5533 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5534 |
7 | 5535 VIsual_mode = c; |
5536 VIsual_active = TRUE; | |
5537 VIsual_reselect = TRUE; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5538 |
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5539 // Corner case: the 0 position in a tab may change when going into |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
18808
diff
changeset
|
5540 // virtualedit. Recalculate curwin->w_cursor to avoid bad highlighting. |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25074
diff
changeset
|
5541 if (c == Ctrl_V && (get_ve_flags() & VE_BLOCK) && gchar_cursor() == TAB) |
3742 | 5542 { |
5543 validate_virtcol(); | |
7 | 5544 coladvance(curwin->w_virtcol); |
3742 | 5545 } |
7 | 5546 VIsual = curwin->w_cursor; |
5547 | |
5548 #ifdef FEAT_FOLDING | |
5549 foldAdjustVisual(); | |
5550 #endif | |
5551 | |
26157
20200363816c
patch 8.2.3610: crash when ModeChanged triggered too early
Bram Moolenaar <Bram@vim.org>
parents:
26101
diff
changeset
|
5552 trigger_modechanged(); |
7 | 5553 setmouse(); |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5554 #ifdef FEAT_CONCEAL |
25074
aa55d6d17625
patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5555 // Check if redraw is needed after changing the state. |
aa55d6d17625
patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5556 conceal_check_cursor_line(cursor_line_was_concealed); |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5557 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5558 |
641 | 5559 if (p_smd && msg_silent == 0) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5560 redraw_cmdline = TRUE; // show visual mode later |
7 | 5561 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5562 // Make sure the clipboard gets updated. Needed because start and |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5563 // end may still be the same, and the selection needs to be owned |
7 | 5564 clip_star.vmode = NUL; |
5565 #endif | |
5566 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5567 // Only need to redraw this line, unless still need to redraw an old |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5568 // Visual area (when 'lazyredraw' is set). |
7 | 5569 if (curwin->w_redr_type < INVERTED) |
5570 { | |
5571 curwin->w_old_cursor_lnum = curwin->w_cursor.lnum; | |
5572 curwin->w_old_visual_lnum = curwin->w_cursor.lnum; | |
5573 } | |
5574 } | |
5575 | |
5576 | |
5577 /* | |
5578 * CTRL-W: Window commands | |
5579 */ | |
5580 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5581 nv_window(cmdarg_T *cap) |
7 | 5582 { |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5583 if (cap->nchar == ':') |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5584 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5585 // "CTRL-W :" is the same as typing ":"; useful in a terminal window |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5586 cap->cmdchar = ':'; |
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5587 cap->nchar = NUL; |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5588 nv_colon(cap); |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5589 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5590 else if (!checkclearop(cap->oap)) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5591 do_window(cap->nchar, cap->count0, NUL); // everything is in window.c |
7 | 5592 } |
5593 | |
5594 /* | |
5595 * CTRL-Z: Suspend | |
5596 */ | |
5597 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5598 nv_suspend(cmdarg_T *cap) |
7 | 5599 { |
5600 clearop(cap->oap); | |
5601 if (VIsual_active) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5602 end_visual_mode(); // stop Visual mode |
23165
a916fca16d4b
patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents:
23076
diff
changeset
|
5603 do_cmdline_cmd((char_u *)"stop"); |
7 | 5604 } |
5605 | |
5606 /* | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5607 * "gv": Reselect the previous Visual area. If Visual already active, |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5608 * exchange previous and current Visual area. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5609 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5610 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5611 nv_gv_cmd(cmdarg_T *cap) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5612 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5613 pos_T tpos; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5614 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5615 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5616 if (checkclearop(cap->oap)) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5617 return; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5618 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5619 if (curbuf->b_visual.vi_start.lnum == 0 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5620 || curbuf->b_visual.vi_start.lnum > curbuf->b_ml.ml_line_count |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5621 || curbuf->b_visual.vi_end.lnum == 0) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5622 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5623 beep_flush(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5624 return; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5625 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5626 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5627 // set w_cursor to the start of the Visual area, tpos to the end |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5628 if (VIsual_active) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5629 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5630 i = VIsual_mode; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5631 VIsual_mode = curbuf->b_visual.vi_mode; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5632 curbuf->b_visual.vi_mode = i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5633 # ifdef FEAT_EVAL |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5634 curbuf->b_visual_mode_eval = i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5635 # endif |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5636 i = curwin->w_curswant; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5637 curwin->w_curswant = curbuf->b_visual.vi_curswant; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5638 curbuf->b_visual.vi_curswant = i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5639 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5640 tpos = curbuf->b_visual.vi_end; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5641 curbuf->b_visual.vi_end = curwin->w_cursor; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5642 curwin->w_cursor = curbuf->b_visual.vi_start; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5643 curbuf->b_visual.vi_start = VIsual; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5644 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5645 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5646 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5647 VIsual_mode = curbuf->b_visual.vi_mode; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5648 curwin->w_curswant = curbuf->b_visual.vi_curswant; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5649 tpos = curbuf->b_visual.vi_end; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5650 curwin->w_cursor = curbuf->b_visual.vi_start; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5651 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5652 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5653 VIsual_active = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5654 VIsual_reselect = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5655 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5656 // Set Visual to the start and w_cursor to the end of the Visual |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5657 // area. Make sure they are on an existing character. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5658 check_cursor(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5659 VIsual = curwin->w_cursor; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5660 curwin->w_cursor = tpos; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5661 check_cursor(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5662 update_topline(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5663 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5664 // When called from normal "g" command: start Select mode when |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5665 // 'selectmode' contains "cmd". When called for K_SELECT, always |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5666 // start Select mode. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5667 if (cap->arg) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5668 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5669 VIsual_select = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5670 VIsual_select_reg = 0; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5671 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5672 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5673 may_start_select('c'); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5674 setmouse(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5675 #ifdef FEAT_CLIPBOARD |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5676 // Make sure the clipboard gets updated. Needed because start and |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5677 // end are still the same, and the selection needs to be owned |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5678 clip_star.vmode = NUL; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5679 #endif |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5680 redraw_curbuf_later(INVERTED); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5681 showmode(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5682 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5683 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5684 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5685 * "g0", "g^" : Like "0" and "^" but for screen lines. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5686 * "gm": middle of "g0" and "g$". |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5687 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5688 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5689 nv_g_home_m_cmd(cmdarg_T *cap) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5690 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5691 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5692 int flag = FALSE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5693 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5694 if (cap->nchar == '^') |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5695 flag = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5696 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5697 cap->oap->motion_type = MCHAR; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5698 cap->oap->inclusive = FALSE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5699 if (curwin->w_p_wrap && curwin->w_width != 0) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5700 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5701 int width1 = curwin->w_width - curwin_col_off(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5702 int width2 = width1 + curwin_col_off2(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5703 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5704 validate_virtcol(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5705 i = 0; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5706 if (curwin->w_virtcol >= (colnr_T)width1 && width2 > 0) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5707 i = (curwin->w_virtcol - width1) / width2 * width2 + width1; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5708 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5709 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5710 i = curwin->w_leftcol; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5711 // Go to the middle of the screen line. When 'number' or |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5712 // 'relativenumber' is on and lines are wrapping the middle can be more |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5713 // to the left. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5714 if (cap->nchar == 'm') |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5715 i += (curwin->w_width - curwin_col_off() |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5716 + ((curwin->w_p_wrap && i > 0) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5717 ? curwin_col_off2() : 0)) / 2; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5718 coladvance((colnr_T)i); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5719 if (flag) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5720 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5721 do |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5722 i = gchar_cursor(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5723 while (VIM_ISWHITE(i) && oneright() == OK); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5724 curwin->w_valid &= ~VALID_WCOL; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5725 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5726 curwin->w_set_curswant = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5727 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5728 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5729 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5730 * "g_": to the last non-blank character in the line or <count> lines |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5731 * downward. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5732 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5733 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5734 nv_g_underscore_cmd(cmdarg_T *cap) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5735 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5736 char_u *ptr; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5737 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5738 cap->oap->motion_type = MCHAR; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5739 cap->oap->inclusive = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5740 curwin->w_curswant = MAXCOL; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5741 if (cursor_down((long)(cap->count1 - 1), |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5742 cap->oap->op_type == OP_NOP) == FAIL) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5743 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5744 clearopbeep(cap->oap); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5745 return; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5746 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5747 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5748 ptr = ml_get_curline(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5749 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5750 // In Visual mode we may end up after the line. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5751 if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5752 --curwin->w_cursor.col; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5753 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5754 // Decrease the cursor column until it's on a non-blank. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5755 while (curwin->w_cursor.col > 0 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5756 && VIM_ISWHITE(ptr[curwin->w_cursor.col])) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5757 --curwin->w_cursor.col; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5758 curwin->w_set_curswant = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5759 adjust_for_sel(cap); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5760 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5761 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5762 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5763 * "g$" : Like "$" but for screen lines. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5764 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5765 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5766 nv_g_dollar_cmd(cmdarg_T *cap) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5767 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5768 oparg_T *oap = cap->oap; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5769 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5770 int col_off = curwin_col_off(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5771 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5772 oap->motion_type = MCHAR; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5773 oap->inclusive = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5774 if (curwin->w_p_wrap && curwin->w_width != 0) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5775 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5776 curwin->w_curswant = MAXCOL; // so we stay at the end |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5777 if (cap->count1 == 1) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5778 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5779 int width1 = curwin->w_width - col_off; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5780 int width2 = width1 + curwin_col_off2(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5781 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5782 validate_virtcol(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5783 i = width1 - 1; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5784 if (curwin->w_virtcol >= (colnr_T)width1) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5785 i += ((curwin->w_virtcol - width1) / width2 + 1) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5786 * width2; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5787 coladvance((colnr_T)i); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5788 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5789 // Make sure we stick in this column. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5790 validate_virtcol(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5791 curwin->w_curswant = curwin->w_virtcol; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5792 curwin->w_set_curswant = FALSE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5793 if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5794 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5795 // Check for landing on a character that got split at |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5796 // the end of the line. We do not want to advance to |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5797 // the next screen line. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5798 if (curwin->w_virtcol > (colnr_T)i) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5799 --curwin->w_cursor.col; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5800 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5801 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5802 else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == FAIL) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5803 clearopbeep(oap); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5804 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5805 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5806 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5807 if (cap->count1 > 1) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5808 // if it fails, let the cursor still move to the last char |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5809 (void)cursor_down(cap->count1 - 1, FALSE); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5810 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5811 i = curwin->w_leftcol + curwin->w_width - col_off - 1; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5812 coladvance((colnr_T)i); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5813 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5814 // if the character doesn't fit move one back |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5815 if (curwin->w_cursor.col > 0 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5816 && (*mb_ptr2cells)(ml_get_cursor()) > 1) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5817 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5818 colnr_T vcol; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5819 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5820 getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5821 if (vcol >= curwin->w_leftcol + curwin->w_width - col_off) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5822 --curwin->w_cursor.col; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5823 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5824 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5825 // Make sure we stick in this column. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5826 validate_virtcol(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5827 curwin->w_curswant = curwin->w_virtcol; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5828 curwin->w_set_curswant = FALSE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5829 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5830 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5831 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5832 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5833 * "gi": start Insert at the last position. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5834 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5835 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5836 nv_gi_cmd(cmdarg_T *cap) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5837 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5838 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5839 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5840 if (curbuf->b_last_insert.lnum != 0) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5841 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5842 curwin->w_cursor = curbuf->b_last_insert; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5843 check_cursor_lnum(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5844 i = (int)STRLEN(ml_get_curline()); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5845 if (curwin->w_cursor.col > (colnr_T)i) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5846 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5847 if (virtual_active()) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5848 curwin->w_cursor.coladd += curwin->w_cursor.col - i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5849 curwin->w_cursor.col = i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5850 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5851 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5852 cap->cmdchar = 'i'; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5853 nv_edit(cap); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5854 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5855 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5856 /* |
7 | 5857 * Commands starting with "g". |
5858 */ | |
5859 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5860 nv_g_cmd(cmdarg_T *cap) |
7 | 5861 { |
5862 oparg_T *oap = cap->oap; | |
5863 int i; | |
5864 | |
5865 switch (cap->nchar) | |
5866 { | |
6868 | 5867 case Ctrl_A: |
5868 case Ctrl_X: | |
7 | 5869 #ifdef MEM_PROFILE |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5870 // "g^A": dump log of used memory. |
6868 | 5871 if (!VIsual_active && cap->nchar == Ctrl_A) |
5872 vim_mem_profile_dump(); | |
5873 else | |
5874 #endif | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5875 // "g^A/g^X": sequentially increment visually selected region |
6868 | 5876 if (VIsual_active) |
5877 { | |
5878 cap->arg = TRUE; | |
5879 cap->cmdchar = cap->nchar; | |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
5880 cap->nchar = NUL; |
6868 | 5881 nv_addsub(cap); |
5882 } | |
5883 else | |
5884 clearopbeep(oap); | |
7 | 5885 break; |
5886 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5887 // "gR": Enter virtual replace mode. |
7 | 5888 case 'R': |
5889 cap->arg = TRUE; | |
5890 nv_Replace(cap); | |
5891 break; | |
5892 | |
5893 case 'r': | |
5894 nv_vreplace(cap); | |
5895 break; | |
5896 | |
5897 case '&': | |
5898 do_cmdline_cmd((char_u *)"%s//~/&"); | |
5899 break; | |
5900 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5901 // "gv": Reselect the previous Visual area. If Visual already active, |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5902 // exchange previous and current Visual area. |
7 | 5903 case 'v': |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5904 nv_gv_cmd(cap); |
7 | 5905 break; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5906 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5907 // "gV": Don't reselect the previous Visual area after a Select mode |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5908 // mapping of menu. |
7 | 5909 case 'V': |
5910 VIsual_reselect = FALSE; | |
5911 break; | |
5912 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5913 // "gh": start Select mode. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5914 // "gH": start Select line mode. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5915 // "g^H": start Select block mode. |
7 | 5916 case K_BS: |
5917 cap->nchar = Ctrl_H; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5918 // FALLTHROUGH |
7 | 5919 case 'h': |
5920 case 'H': | |
5921 case Ctrl_H: | |
5922 cap->cmdchar = cap->nchar + ('v' - 'h'); | |
5923 cap->arg = TRUE; | |
5924 nv_visual(cap); | |
5925 break; | |
3701 | 5926 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5927 // "gn", "gN" visually select next/previous search match |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5928 // "gn" selects next match |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5929 // "gN" selects previous match |
3701 | 5930 case 'N': |
5931 case 'n': | |
5932 if (!current_search(cap->count1, cap->nchar == 'n')) | |
3896 | 5933 clearopbeep(oap); |
3701 | 5934 break; |
7 | 5935 |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5936 // "gj" and "gk" two new funny movement keys -- up and down |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5937 // movement based on *screen* line rather than *file* line. |
7 | 5938 case 'j': |
5939 case K_DOWN: | |
23687
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5940 // with 'nowrap' it works just like the normal "j" command. |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5941 if (!curwin->w_p_wrap) |
7 | 5942 { |
5943 oap->motion_type = MLINE; | |
5944 i = cursor_down(cap->count1, oap->op_type == OP_NOP); | |
5945 } | |
5946 else | |
5947 i = nv_screengo(oap, FORWARD, cap->count1); | |
5948 if (i == FAIL) | |
5949 clearopbeep(oap); | |
5950 break; | |
5951 | |
5952 case 'k': | |
5953 case K_UP: | |
23687
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5954 // with 'nowrap' it works just like the normal "k" command. |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
5955 if (!curwin->w_p_wrap) |
7 | 5956 { |
5957 oap->motion_type = MLINE; | |
5958 i = cursor_up(cap->count1, oap->op_type == OP_NOP); | |
5959 } | |
5960 else | |
5961 i = nv_screengo(oap, BACKWARD, cap->count1); | |
5962 if (i == FAIL) | |
5963 clearopbeep(oap); | |
5964 break; | |
5965 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5966 // "gJ": join two lines without inserting a space. |
7 | 5967 case 'J': |
5968 nv_join(cap); | |
5969 break; | |
5970 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5971 // "g0", "g^" : Like "0" and "^" but for screen lines. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5972 // "gm": middle of "g0" and "g$". |
7 | 5973 case '^': |
5974 case '0': | |
5975 case 'm': | |
5976 case K_HOME: | |
5977 case K_KHOME: | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5978 nv_g_home_m_cmd(cap); |
7 | 5979 break; |
5980 | |
18475
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5981 case 'M': |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5982 { |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5983 oap->motion_type = MCHAR; |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5984 oap->inclusive = FALSE; |
26749
efe4c8a79502
patch 8.2.3903: "gM" does not count tabs as expected
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
5985 i = linetabsize(ml_get_curline()); |
18475
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5986 if (cap->count0 > 0 && cap->count0 <= 100) |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5987 coladvance((colnr_T)(i * cap->count0 / 100)); |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5988 else |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5989 coladvance((colnr_T)(i / 2)); |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5990 curwin->w_set_curswant = TRUE; |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5991 } |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5992 break; |
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
5993 |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5994 // "g_": to the last non-blank character in the line or <count> lines |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5995 // downward. |
7 | 5996 case '_': |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5997 nv_g_underscore_cmd(cap); |
7 | 5998 break; |
5999 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6000 // "g$" : Like "$" but for screen lines. |
7 | 6001 case '$': |
6002 case K_END: | |
6003 case K_KEND: | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6004 nv_g_dollar_cmd(cap); |
7 | 6005 break; |
6006 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6007 // "g*" and "g#", like "*" and "#" but without using "\<" and "\>" |
7 | 6008 case '*': |
6009 case '#': | |
6010 #if POUND != '#' | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6011 case POUND: // pound sign (sometimes equal to '#') |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6012 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6013 case Ctrl_RSB: // :tag or :tselect for current identifier |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6014 case ']': // :tselect for current identifier |
7 | 6015 nv_ident(cap); |
6016 break; | |
6017 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6018 // ge and gE: go back to end of word |
7 | 6019 case 'e': |
6020 case 'E': | |
6021 oap->motion_type = MCHAR; | |
6022 curwin->w_set_curswant = TRUE; | |
6023 oap->inclusive = TRUE; | |
6024 if (bckend_word(cap->count1, cap->nchar == 'E', FALSE) == FAIL) | |
6025 clearopbeep(oap); | |
6026 break; | |
6027 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6028 // "g CTRL-G": display info about cursor position |
7 | 6029 case Ctrl_G: |
7480
a49163681559
commit https://github.com/vim/vim/commit/ed767a2073ef150971b0439a58e7ee582af6984e
Christian Brabandt <cb@256bit.org>
parents:
7311
diff
changeset
|
6030 cursor_pos_info(NULL); |
7 | 6031 break; |
6032 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6033 // "gi": start Insert at the last position. |
7 | 6034 case 'i': |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6035 nv_gi_cmd(cap); |
7 | 6036 break; |
6037 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6038 // "gI": Start insert in column 1. |
7 | 6039 case 'I': |
6040 beginline(0); | |
6041 if (!checkclearopq(oap)) | |
6042 invoke_edit(cap, FALSE, 'g', FALSE); | |
6043 break; | |
6044 | |
6045 #ifdef FEAT_SEARCHPATH | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6046 // "gf": goto file, edit file under cursor |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6047 // "]f" and "[f": can also be used. |
7 | 6048 case 'f': |
681 | 6049 case 'F': |
7 | 6050 nv_gotofile(cap); |
6051 break; | |
6052 #endif | |
6053 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6054 // "g'm" and "g`m": jump to mark without setting pcmark |
7 | 6055 case '\'': |
6056 cap->arg = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6057 // FALLTHROUGH |
7 | 6058 case '`': |
6059 nv_gomark(cap); | |
6060 break; | |
6061 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6062 // "gs": Goto sleep. |
7 | 6063 case 's': |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
6064 do_sleep(cap->count1 * 1000L, FALSE); |
7 | 6065 break; |
6066 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6067 // "ga": Display the ascii value of the character under the |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6068 // cursor. It is displayed in decimal, hex, and octal. -- webb |
7 | 6069 case 'a': |
6070 do_ascii(NULL); | |
6071 break; | |
6072 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6073 // "g8": Display the bytes used for the UTF-8 character under the |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6074 // cursor. It is displayed in hex. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6075 // "8g8" finds illegal byte sequence. |
7 | 6076 case '8': |
775 | 6077 if (cap->count0 == 8) |
6078 utf_find_illegal(); | |
6079 else | |
6080 show_utf8(); | |
7 | 6081 break; |
6082 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6083 // "g<": show scrollback text |
447 | 6084 case '<': |
6085 show_sb_text(); | |
6086 break; | |
6087 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6088 // "gg": Goto the first line in file. With a count it goes to |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6089 // that line number like for "G". -- webb |
7 | 6090 case 'g': |
6091 cap->arg = FALSE; | |
6092 nv_goto(cap); | |
6093 break; | |
6094 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6095 // Two-character operators: |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6096 // "gq" Format text |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6097 // "gw" Format text and keep cursor position |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6098 // "g~" Toggle the case of the text. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6099 // "gu" Change text to lower case. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6100 // "gU" Change text to upper case. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6101 // "g?" rot13 encoding |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6102 // "g@" call 'operatorfunc' |
7 | 6103 case 'q': |
6104 case 'w': | |
6105 oap->cursor_start = curwin->w_cursor; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6106 // FALLTHROUGH |
7 | 6107 case '~': |
6108 case 'u': | |
6109 case 'U': | |
6110 case '?': | |
602 | 6111 case '@': |
7 | 6112 nv_operator(cap); |
6113 break; | |
6114 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6115 // "gd": Find first occurrence of pattern under the cursor in the |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6116 // current function |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6117 // "gD": idem, but in the current file. |
7 | 6118 case 'd': |
6119 case 'D': | |
523 | 6120 nv_gd(oap, cap->nchar, (int)cap->count0); |
7 | 6121 break; |
6122 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6123 // g<*Mouse> : <C-*mouse> |
7 | 6124 case K_MIDDLEMOUSE: |
6125 case K_MIDDLEDRAG: | |
6126 case K_MIDDLERELEASE: | |
6127 case K_LEFTMOUSE: | |
6128 case K_LEFTDRAG: | |
6129 case K_LEFTRELEASE: | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
6130 case K_MOUSEMOVE: |
7 | 6131 case K_RIGHTMOUSE: |
6132 case K_RIGHTDRAG: | |
6133 case K_RIGHTRELEASE: | |
6134 case K_X1MOUSE: | |
6135 case K_X1DRAG: | |
6136 case K_X1RELEASE: | |
6137 case K_X2MOUSE: | |
6138 case K_X2DRAG: | |
6139 case K_X2RELEASE: | |
6140 mod_mask = MOD_MASK_CTRL; | |
6141 (void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); | |
6142 break; | |
6143 | |
6144 case K_IGNORE: | |
6145 break; | |
6146 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6147 // "gP" and "gp": same as "P" and "p" but leave cursor just after new text |
7 | 6148 case 'p': |
6149 case 'P': | |
6150 nv_put(cap); | |
6151 break; | |
6152 | |
6153 #ifdef FEAT_BYTEOFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6154 // "go": goto byte count from start of buffer |
7 | 6155 case 'o': |
6156 goto_byte(cap->count0); | |
6157 break; | |
6158 #endif | |
6159 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6160 // "gQ": improved Ex mode |
7 | 6161 case 'Q': |
633 | 6162 if (text_locked()) |
7 | 6163 { |
6164 clearopbeep(cap->oap); | |
633 | 6165 text_locked_msg(); |
7 | 6166 break; |
6167 } | |
631 | 6168 |
7 | 6169 if (!checkclearopq(oap)) |
6170 do_exmode(TRUE); | |
6171 break; | |
6172 | |
6173 case ',': | |
6174 nv_pcmark(cap); | |
6175 break; | |
6176 | |
6177 case ';': | |
6178 cap->count1 = -cap->count1; | |
6179 nv_pcmark(cap); | |
6180 break; | |
6181 | |
667 | 6182 case 't': |
3630 | 6183 if (!checkclearop(oap)) |
6184 goto_tabpage((int)cap->count0); | |
667 | 6185 break; |
682 | 6186 case 'T': |
3630 | 6187 if (!checkclearop(oap)) |
6188 goto_tabpage(-(int)cap->count1); | |
682 | 6189 break; |
667 | 6190 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6191 case TAB: |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6192 if (!checkclearop(oap) && goto_tabpage_lastused() == FAIL) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6193 clearopbeep(oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6194 break; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6195 |
750 | 6196 case '+': |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6197 case '-': // "g+" and "g-": undo or redo along the timeline |
750 | 6198 if (!checkclearopq(oap)) |
771 | 6199 undo_time(cap->nchar == '-' ? -cap->count1 : cap->count1, |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2259
diff
changeset
|
6200 FALSE, FALSE, FALSE); |
750 | 6201 break; |
6202 | |
7 | 6203 default: |
6204 clearopbeep(oap); | |
6205 break; | |
6206 } | |
6207 } | |
6208 | |
6209 /* | |
6210 * Handle "o" and "O" commands. | |
6211 */ | |
6212 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6213 n_opencmd(cmdarg_T *cap) |
7 | 6214 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6215 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6216 linenr_T oldline = curwin->w_cursor.lnum; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6217 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6218 |
7 | 6219 if (!checkclearopq(cap->oap)) |
6220 { | |
6221 #ifdef FEAT_FOLDING | |
6222 if (cap->cmdchar == 'O') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6223 // Open above the first line of a folded sequence of lines |
7 | 6224 (void)hasFolding(curwin->w_cursor.lnum, |
6225 &curwin->w_cursor.lnum, NULL); | |
6226 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6227 // Open below the last line of a folded sequence of lines |
7 | 6228 (void)hasFolding(curwin->w_cursor.lnum, |
6229 NULL, &curwin->w_cursor.lnum); | |
6230 #endif | |
6231 if (u_save((linenr_T)(curwin->w_cursor.lnum - | |
6232 (cap->cmdchar == 'O' ? 1 : 0)), | |
6233 (linenr_T)(curwin->w_cursor.lnum + | |
6234 (cap->cmdchar == 'o' ? 1 : 0)) | |
6235 ) == OK | |
6236 && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, | |
18203
e0ec4cd7a865
patch 8.1.2096: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
18154
diff
changeset
|
6237 has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, |
26516
9596c652420b
patch 8.2.3787: no proper formatting of a C line comment after a statement
Bram Moolenaar <Bram@vim.org>
parents:
26468
diff
changeset
|
6238 0, NULL) == OK) |
7 | 6239 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6240 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6241 if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15422
diff
changeset
|
6242 redrawWinline(curwin, oldline); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6243 #endif |
6834 | 6244 #ifdef FEAT_SYN_HL |
6821 | 6245 if (curwin->w_p_cul) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6246 // force redraw of cursorline |
6821 | 6247 curwin->w_valid &= ~VALID_CROW; |
6834 | 6248 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6249 // When '#' is in 'cpoptions' ignore the count. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
6250 if (vim_strchr(p_cpo, CPO_HASH) != NULL) |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
6251 cap->count1 = 1; |
7 | 6252 invoke_edit(cap, FALSE, cap->cmdchar, TRUE); |
6253 } | |
6254 } | |
6255 } | |
6256 | |
6257 /* | |
6258 * "." command: redo last change. | |
6259 */ | |
6260 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6261 nv_dot(cmdarg_T *cap) |
7 | 6262 { |
6263 if (!checkclearopq(cap->oap)) | |
6264 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6265 // If "restart_edit" is TRUE, the last but one command is repeated |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6266 // instead of the last command (inserting text). This is used for |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6267 // CTRL-O <.> in insert mode. |
7 | 6268 if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) |
6269 clearopbeep(cap->oap); | |
6270 } | |
6271 } | |
6272 | |
6273 /* | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6274 * CTRL-R: undo undo or specify register in select mode |
7 | 6275 */ |
6276 static void | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6277 nv_redo_or_register(cmdarg_T *cap) |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6278 { |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6279 if (VIsual_select && VIsual_active) |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6280 { |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6281 int reg; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6282 // Get register name |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6283 ++no_mapping; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6284 ++allow_keys; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6285 reg = plain_vgetc(); |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6286 LANGMAP_ADJUST(reg, TRUE); |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6287 --no_mapping; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6288 --allow_keys; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6289 |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6290 if (reg == '"') |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6291 // the unnamed register is 0 |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6292 reg = 0; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6293 |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6294 VIsual_select_reg = valid_yank_reg(reg, TRUE) ? reg : 0; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6295 return; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6296 } |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6297 |
7 | 6298 if (!checkclearopq(cap->oap)) |
6299 { | |
6300 u_redo((int)cap->count1); | |
6301 curwin->w_set_curswant = TRUE; | |
6302 } | |
6303 } | |
6304 | |
6305 /* | |
6306 * Handle "U" command. | |
6307 */ | |
6308 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6309 nv_Undo(cmdarg_T *cap) |
7 | 6310 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6311 // In Visual mode and typing "gUU" triggers an operator |
5735 | 6312 if (cap->oap->op_type == OP_UPPER || VIsual_active) |
7 | 6313 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6314 // translate "gUU" to "gUgU" |
7 | 6315 cap->cmdchar = 'g'; |
6316 cap->nchar = 'U'; | |
6317 nv_operator(cap); | |
6318 } | |
6319 else if (!checkclearopq(cap->oap)) | |
6320 { | |
6321 u_undoline(); | |
6322 curwin->w_set_curswant = TRUE; | |
6323 } | |
6324 } | |
6325 | |
6326 /* | |
6327 * '~' command: If tilde is not an operator and Visual is off: swap case of a | |
6328 * single character. | |
6329 */ | |
6330 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6331 nv_tilde(cmdarg_T *cap) |
7 | 6332 { |
5735 | 6333 if (!p_to && !VIsual_active && cap->oap->op_type != OP_TILDE) |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6334 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6335 #ifdef FEAT_JOB_CHANNEL |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6336 if (bt_prompt(curbuf) && !prompt_curpos_editable()) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6337 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6338 clearopbeep(cap->oap); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6339 return; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6340 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6341 #endif |
7 | 6342 n_swapchar(cap); |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6343 } |
7 | 6344 else |
6345 nv_operator(cap); | |
6346 } | |
6347 | |
6348 /* | |
6349 * Handle an operator command. | |
6350 * The actual work is done by do_pending_operator(). | |
6351 */ | |
6352 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6353 nv_operator(cmdarg_T *cap) |
7 | 6354 { |
6355 int op_type; | |
6356 | |
6357 op_type = get_op_type(cap->cmdchar, cap->nchar); | |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6358 #ifdef FEAT_JOB_CHANNEL |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6359 if (bt_prompt(curbuf) && op_is_change(op_type) && !prompt_curpos_editable()) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6360 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6361 clearopbeep(cap->oap); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6362 return; |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6363 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
6364 #endif |
7 | 6365 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6366 if (op_type == cap->oap->op_type) // double operator works on lines |
7 | 6367 nv_lineop(cap); |
6368 else if (!checkclearop(cap->oap)) | |
6369 { | |
6370 cap->oap->start = curwin->w_cursor; | |
6371 cap->oap->op_type = op_type; | |
1490 | 6372 #ifdef FEAT_EVAL |
6373 set_op_var(op_type); | |
6374 #endif | |
6375 } | |
6376 } | |
6377 | |
6378 #ifdef FEAT_EVAL | |
6379 /* | |
6380 * Set v:operator to the characters for "optype". | |
6381 */ | |
6382 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6383 set_op_var(int optype) |
1490 | 6384 { |
6385 char_u opchars[3]; | |
6386 | |
6387 if (optype == OP_NOP) | |
6388 set_vim_var_string(VV_OP, NULL, 0); | |
6389 else | |
6390 { | |
6391 opchars[0] = get_op_char(optype); | |
6392 opchars[1] = get_extra_op_char(optype); | |
6393 opchars[2] = NUL; | |
6394 set_vim_var_string(VV_OP, opchars, -1); | |
6395 } | |
6396 } | |
6397 #endif | |
7 | 6398 |
6399 /* | |
6400 * Handle linewise operator "dd", "yy", etc. | |
6401 * | |
6402 * "_" is is a strange motion command that helps make operators more logical. | |
6403 * It is actually implemented, but not documented in the real Vi. This motion | |
6404 * command actually refers to "the current line". Commands like "dd" and "yy" | |
6405 * are really an alternate form of "d_" and "y_". It does accept a count, so | |
6406 * "d3_" works to delete 3 lines. | |
6407 */ | |
6408 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6409 nv_lineop(cmdarg_T *cap) |
7 | 6410 { |
6411 cap->oap->motion_type = MLINE; | |
6412 if (cursor_down(cap->count1 - 1L, cap->oap->op_type == OP_NOP) == FAIL) | |
6413 clearopbeep(cap->oap); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6414 else if ( (cap->oap->op_type == OP_DELETE // only with linewise motions |
4011 | 6415 && cap->oap->motion_force != 'v' |
6416 && cap->oap->motion_force != Ctrl_V) | |
7 | 6417 || cap->oap->op_type == OP_LSHIFT |
6418 || cap->oap->op_type == OP_RSHIFT) | |
6419 beginline(BL_SOL | BL_FIX); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6420 else if (cap->oap->op_type != OP_YANK) // 'Y' does not move cursor |
7 | 6421 beginline(BL_WHITE | BL_FIX); |
6422 } | |
6423 | |
6424 /* | |
6425 * <Home> command. | |
6426 */ | |
6427 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6428 nv_home(cmdarg_T *cap) |
7 | 6429 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6430 // CTRL-HOME is like "gg" |
180 | 6431 if (mod_mask & MOD_MASK_CTRL) |
6432 nv_goto(cap); | |
6433 else | |
6434 { | |
6435 cap->count0 = 1; | |
6436 nv_pipe(cap); | |
6437 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6438 ins_at_eol = FALSE; // Don't move cursor past eol (only necessary in a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6439 // one-character line). |
7 | 6440 } |
6441 | |
6442 /* | |
6443 * "|" command. | |
6444 */ | |
6445 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6446 nv_pipe(cmdarg_T *cap) |
7 | 6447 { |
6448 cap->oap->motion_type = MCHAR; | |
6449 cap->oap->inclusive = FALSE; | |
6450 beginline(0); | |
6451 if (cap->count0 > 0) | |
6452 { | |
6453 coladvance((colnr_T)(cap->count0 - 1)); | |
6454 curwin->w_curswant = (colnr_T)(cap->count0 - 1); | |
6455 } | |
6456 else | |
6457 curwin->w_curswant = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6458 // keep curswant at the column where we wanted to go, not where |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6459 // we ended; differs if line is too short |
7 | 6460 curwin->w_set_curswant = FALSE; |
6461 } | |
6462 | |
6463 /* | |
6464 * Handle back-word command "b" and "B". | |
6465 * cap->arg is 1 for "B" | |
6466 */ | |
6467 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6468 nv_bck_word(cmdarg_T *cap) |
7 | 6469 { |
6470 cap->oap->motion_type = MCHAR; | |
6471 cap->oap->inclusive = FALSE; | |
6472 curwin->w_set_curswant = TRUE; | |
6473 if (bck_word(cap->count1, cap->arg, FALSE) == FAIL) | |
6474 clearopbeep(cap->oap); | |
6475 #ifdef FEAT_FOLDING | |
6476 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6477 foldOpenCursor(); | |
6478 #endif | |
6479 } | |
6480 | |
6481 /* | |
6482 * Handle word motion commands "e", "E", "w" and "W". | |
6483 * cap->arg is TRUE for "E" and "W". | |
6484 */ | |
6485 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6486 nv_wordcmd(cmdarg_T *cap) |
7 | 6487 { |
6488 int n; | |
6489 int word_end; | |
6490 int flag = FALSE; | |
1573 | 6491 pos_T startpos = curwin->w_cursor; |
7 | 6492 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6493 // Set inclusive for the "E" and "e" command. |
7 | 6494 if (cap->cmdchar == 'e' || cap->cmdchar == 'E') |
6495 word_end = TRUE; | |
6496 else | |
6497 word_end = FALSE; | |
6498 cap->oap->inclusive = word_end; | |
6499 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6500 // "cw" and "cW" are a special case. |
7 | 6501 if (!word_end && cap->oap->op_type == OP_CHANGE) |
6502 { | |
6503 n = gchar_cursor(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6504 if (n != NUL) // not an empty line |
7 | 6505 { |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6506 if (VIM_ISWHITE(n)) |
7 | 6507 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6508 // Reproduce a funny Vi behaviour: "cw" on a blank only |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6509 // changes one character, not all blanks until the start of |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6510 // the next word. Only do this when the 'w' flag is included |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6511 // in 'cpoptions'. |
7 | 6512 if (cap->count1 == 1 && vim_strchr(p_cpo, CPO_CW) != NULL) |
6513 { | |
6514 cap->oap->inclusive = TRUE; | |
6515 cap->oap->motion_type = MCHAR; | |
6516 return; | |
6517 } | |
6518 } | |
6519 else | |
6520 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6521 // This is a little strange. To match what the real Vi does, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6522 // we effectively map 'cw' to 'ce', and 'cW' to 'cE', provided |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6523 // that we are not on a space or a TAB. This seems impolite |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6524 // at first, but it's really more what we mean when we say |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6525 // 'cw'. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6526 // Another strangeness: When standing on the end of a word |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6527 // "ce" will change until the end of the next word, but "cw" |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6528 // will change only one character! This is done by setting |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6529 // flag. |
7 | 6530 cap->oap->inclusive = TRUE; |
6531 word_end = TRUE; | |
6532 flag = TRUE; | |
6533 } | |
6534 } | |
6535 } | |
6536 | |
6537 cap->oap->motion_type = MCHAR; | |
6538 curwin->w_set_curswant = TRUE; | |
6539 if (word_end) | |
6540 n = end_word(cap->count1, cap->arg, flag, FALSE); | |
6541 else | |
6542 n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP); | |
6543 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6544 // Don't leave the cursor on the NUL past the end of line. Unless we |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6545 // didn't move it forward. |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6546 if (LT_POS(startpos, curwin->w_cursor)) |
1505 | 6547 adjust_cursor(cap->oap); |
7 | 6548 |
6549 if (n == FAIL && cap->oap->op_type == OP_NOP) | |
6550 clearopbeep(cap->oap); | |
6551 else | |
6552 { | |
6553 adjust_for_sel(cap); | |
6554 #ifdef FEAT_FOLDING | |
6555 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6556 foldOpenCursor(); | |
6557 #endif | |
6558 } | |
6559 } | |
6560 | |
6561 /* | |
1505 | 6562 * Used after a movement command: If the cursor ends up on the NUL after the |
6563 * end of the line, may move it back to the last character and make the motion | |
6564 * inclusive. | |
6565 */ | |
6566 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6567 adjust_cursor(oparg_T *oap) |
1505 | 6568 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6569 // The cursor cannot remain on the NUL when: |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6570 // - the column is > 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6571 // - not in Visual mode or 'selection' is "o" |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6572 // - 'virtualedit' is not "all" and not "onemore". |
1505 | 6573 if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL |
6574 && (!VIsual_active || *p_sel == 'o') | |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25074
diff
changeset
|
6575 && !virtual_active() && (get_ve_flags() & VE_ONEMORE) == 0) |
1505 | 6576 { |
6577 --curwin->w_cursor.col; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6578 // prevent cursor from moving on the trail byte |
1505 | 6579 if (has_mbyte) |
6580 mb_adjust_cursor(); | |
6581 oap->inclusive = TRUE; | |
6582 } | |
6583 } | |
6584 | |
6585 /* | |
7 | 6586 * "0" and "^" commands. |
6587 * cap->arg is the argument for beginline(). | |
6588 */ | |
6589 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6590 nv_beginline(cmdarg_T *cap) |
7 | 6591 { |
6592 cap->oap->motion_type = MCHAR; | |
6593 cap->oap->inclusive = FALSE; | |
6594 beginline(cap->arg); | |
6595 #ifdef FEAT_FOLDING | |
6596 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6597 foldOpenCursor(); | |
6598 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6599 ins_at_eol = FALSE; // Don't move cursor past eol (only necessary in a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6600 // one-character line). |
7 | 6601 } |
6602 | |
6603 /* | |
6604 * In exclusive Visual mode, may include the last character. | |
6605 */ | |
6606 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6607 adjust_for_sel(cmdarg_T *cap) |
7 | 6608 { |
6609 if (VIsual_active && cap->oap->inclusive && *p_sel == 'e' | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6610 && gchar_cursor() != NUL && LT_POS(VIsual, curwin->w_cursor)) |
7 | 6611 { |
6612 if (has_mbyte) | |
6613 inc_cursor(); | |
6614 else | |
6615 ++curwin->w_cursor.col; | |
6616 cap->oap->inclusive = FALSE; | |
6617 } | |
6618 } | |
6619 | |
6620 /* | |
6621 * Exclude last character at end of Visual area for 'selection' == "exclusive". | |
6622 * Should check VIsual_mode before calling this. | |
6623 * Returns TRUE when backed up to the previous line. | |
6624 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
6625 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6626 unadjust_for_sel(void) |
7 | 6627 { |
6628 pos_T *pp; | |
6629 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6630 if (*p_sel == 'e' && !EQUAL_POS(VIsual, curwin->w_cursor)) |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6631 { |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6632 if (LT_POS(VIsual, curwin->w_cursor)) |
7 | 6633 pp = &curwin->w_cursor; |
6634 else | |
6635 pp = &VIsual; | |
6636 if (pp->coladd > 0) | |
6637 --pp->coladd; | |
6638 else | |
6639 if (pp->col > 0) | |
6640 { | |
6641 --pp->col; | |
2933 | 6642 mb_adjustpos(curbuf, pp); |
7 | 6643 } |
6644 else if (pp->lnum > 1) | |
6645 { | |
6646 --pp->lnum; | |
6647 pp->col = (colnr_T)STRLEN(ml_get(pp->lnum)); | |
6648 return TRUE; | |
6649 } | |
6650 } | |
6651 return FALSE; | |
6652 } | |
6653 | |
6654 /* | |
6655 * SELECT key in Normal or Visual mode: end of Select mode mapping. | |
6656 */ | |
6657 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6658 nv_select(cmdarg_T *cap) |
7 | 6659 { |
6660 if (VIsual_active) | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6661 { |
7 | 6662 VIsual_select = TRUE; |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6663 VIsual_select_reg = 0; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6664 } |
7 | 6665 else if (VIsual_reselect) |
6666 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6667 cap->nchar = 'v'; // fake "gv" command |
7 | 6668 cap->arg = TRUE; |
6669 nv_g_cmd(cap); | |
6670 } | |
6671 } | |
6672 | |
6673 | |
6674 /* | |
6675 * "G", "gg", CTRL-END, CTRL-HOME. | |
6676 * cap->arg is TRUE for "G". | |
6677 */ | |
6678 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6679 nv_goto(cmdarg_T *cap) |
7 | 6680 { |
6681 linenr_T lnum; | |
6682 | |
6683 if (cap->arg) | |
6684 lnum = curbuf->b_ml.ml_line_count; | |
6685 else | |
6686 lnum = 1L; | |
6687 cap->oap->motion_type = MLINE; | |
6688 setpcmark(); | |
6689 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6690 // When a count is given, use it instead of the default lnum |
7 | 6691 if (cap->count0 != 0) |
6692 lnum = cap->count0; | |
6693 if (lnum < 1L) | |
6694 lnum = 1L; | |
6695 else if (lnum > curbuf->b_ml.ml_line_count) | |
6696 lnum = curbuf->b_ml.ml_line_count; | |
6697 curwin->w_cursor.lnum = lnum; | |
6698 beginline(BL_SOL | BL_FIX); | |
6699 #ifdef FEAT_FOLDING | |
6700 if ((fdo_flags & FDO_JUMP) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6701 foldOpenCursor(); | |
6702 #endif | |
6703 } | |
6704 | |
6705 /* | |
6706 * CTRL-\ in Normal mode. | |
6707 */ | |
6708 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6709 nv_normal(cmdarg_T *cap) |
7 | 6710 { |
6711 if (cap->nchar == Ctrl_N || cap->nchar == Ctrl_G) | |
6712 { | |
6713 clearop(cap->oap); | |
643 | 6714 if (restart_edit != 0 && mode_displayed) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6715 clear_cmdline = TRUE; // unshow mode later |
7 | 6716 restart_edit = 0; |
6717 #ifdef FEAT_CMDWIN | |
6718 if (cmdwin_type != 0) | |
6719 cmdwin_result = Ctrl_C; | |
6720 #endif | |
6721 if (VIsual_active) | |
6722 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6723 end_visual_mode(); // stop Visual |
7 | 6724 redraw_curbuf_later(INVERTED); |
6725 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6726 // CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. |
7 | 6727 if (cap->nchar == Ctrl_G && p_im) |
6728 restart_edit = 'a'; | |
6729 } | |
6730 else | |
6731 clearopbeep(cap->oap); | |
6732 } | |
6733 | |
6734 /* | |
6735 * ESC in Normal mode: beep, but don't flush buffers. | |
6736 * Don't even beep if we are canceling a command. | |
6737 */ | |
6738 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6739 nv_esc(cmdarg_T *cap) |
7 | 6740 { |
6741 int no_reason; | |
6742 | |
6743 no_reason = (cap->oap->op_type == OP_NOP | |
6744 && cap->opcount == 0 | |
6745 && cap->count0 == 0 | |
6746 && cap->oap->regname == 0 | |
6747 && !p_im); | |
6748 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6749 if (cap->arg) // TRUE for CTRL-C |
7 | 6750 { |
6751 if (restart_edit == 0 | |
6752 #ifdef FEAT_CMDWIN | |
6753 && cmdwin_type == 0 | |
6754 #endif | |
6755 && !VIsual_active | |
6756 && no_reason) | |
16089
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6757 { |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6758 if (anyBufIsChanged()) |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6759 msg(_("Type :qa! and press <Enter> to abandon all changes and exit Vim")); |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6760 else |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6761 msg(_("Type :qa and press <Enter> to exit Vim")); |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6762 } |
7 | 6763 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6764 // Don't reset "restart_edit" when 'insertmode' is set, it won't be |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6765 // set again below when halfway a mapping. |
7 | 6766 if (!p_im) |
6767 restart_edit = 0; | |
6768 #ifdef FEAT_CMDWIN | |
6769 if (cmdwin_type != 0) | |
6770 { | |
6771 cmdwin_result = K_IGNORE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6772 got_int = FALSE; // don't stop executing autocommands et al. |
7 | 6773 return; |
6774 } | |
6775 #endif | |
6776 } | |
24012
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6777 #ifdef FEAT_CMDWIN |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6778 else if (cmdwin_type != 0 && ex_normal_busy) |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6779 { |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6780 // When :normal runs out of characters while in the command line window |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6781 // vgetorpeek() will return ESC. Exit the cmdline window to break the |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6782 // loop. |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6783 cmdwin_result = K_IGNORE; |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6784 return; |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6785 } |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6786 #endif |
7 | 6787 |
6788 if (VIsual_active) | |
6789 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6790 end_visual_mode(); // stop Visual |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6791 check_cursor_col(); // make sure cursor is not beyond EOL |
7 | 6792 curwin->w_set_curswant = TRUE; |
6793 redraw_curbuf_later(INVERTED); | |
6794 } | |
5735 | 6795 else if (no_reason) |
6949 | 6796 vim_beep(BO_ESC); |
7 | 6797 clearop(cap->oap); |
6798 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6799 // A CTRL-C is often used at the start of a menu. When 'insertmode' is |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6800 // set return to Insert mode afterwards. |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7829
diff
changeset
|
6801 if (restart_edit == 0 && goto_im() && ex_normal_busy == 0) |
7 | 6802 restart_edit = 'a'; |
6803 } | |
6804 | |
6805 /* | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6806 * Move the cursor for the "A" command. |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6807 */ |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6808 void |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6809 set_cursor_for_append_to_line(void) |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6810 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6811 curwin->w_set_curswant = TRUE; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25074
diff
changeset
|
6812 if (get_ve_flags() == VE_ALL) |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6813 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6814 int save_State = State; |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6815 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6816 // Pretend Insert mode here to allow the cursor on the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6817 // character past the end of the line |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6818 State = INSERT; |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6819 coladvance((colnr_T)MAXCOL); |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6820 State = save_State; |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6821 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6822 else |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6823 curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor()); |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6824 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6825 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6826 /* |
7 | 6827 * Handle "A", "a", "I", "i" and <Insert> commands. |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6828 * Also handle K_PS, start bracketed paste. |
7 | 6829 */ |
6830 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6831 nv_edit(cmdarg_T *cap) |
7 | 6832 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6833 // <Insert> is equal to "i" |
7 | 6834 if (cap->cmdchar == K_INS || cap->cmdchar == K_KINS) |
6835 cap->cmdchar = 'i'; | |
6836 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6837 // in Visual mode "A" and "I" are an operator |
7 | 6838 if (VIsual_active && (cap->cmdchar == 'A' || cap->cmdchar == 'I')) |
12467
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6839 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6840 #ifdef FEAT_TERMINAL |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6841 if (term_in_normal_mode()) |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6842 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6843 end_visual_mode(); |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6844 clearop(cap->oap); |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6845 term_enter_job_mode(); |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6846 return; |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6847 } |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6848 #endif |
7 | 6849 v_visop(cap); |
12467
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6850 } |
7 | 6851 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6852 // in Visual mode and after an operator "a" and "i" are for text objects |
5735 | 6853 else if ((cap->cmdchar == 'a' || cap->cmdchar == 'i') |
6854 && (cap->oap->op_type != OP_NOP || VIsual_active)) | |
7 | 6855 { |
6856 #ifdef FEAT_TEXTOBJ | |
6857 nv_object(cap); | |
6858 #else | |
6859 clearopbeep(cap->oap); | |
6860 #endif | |
6861 } | |
11892
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6862 #ifdef FEAT_TERMINAL |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11987
diff
changeset
|
6863 else if (term_in_normal_mode()) |
11892
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6864 { |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6865 clearop(cap->oap); |
11993
92a86fe8adc0
patch 8.0.0877: using CTRL- CTRL-N in terminal is inconsistent
Christian Brabandt <cb@256bit.org>
parents:
11987
diff
changeset
|
6866 term_enter_job_mode(); |
11892
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6867 return; |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6868 } |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6869 #endif |
7 | 6870 else if (!curbuf->b_p_ma && !p_im) |
6871 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6872 // Only give this error when 'insertmode' is off. |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
6873 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 6874 clearop(cap->oap); |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6875 if (cap->cmdchar == K_PS) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6876 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6877 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 6878 } |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6879 else if (cap->cmdchar == K_PS && VIsual_active) |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6880 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6881 pos_T old_pos = curwin->w_cursor; |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6882 pos_T old_visual = VIsual; |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6883 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6884 // In Visual mode the selected text is deleted. |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6885 if (VIsual_mode == 'V' || curwin->w_cursor.lnum != VIsual.lnum) |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6886 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6887 shift_delete_registers(); |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6888 cap->oap->regname = '1'; |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6889 } |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6890 else |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6891 cap->oap->regname = '-'; |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6892 cap->cmdchar = 'd'; |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6893 cap->nchar = NUL; |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6894 nv_operator(cap); |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6895 do_pending_operator(cap, 0, FALSE); |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6896 cap->cmdchar = K_PS; |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6897 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6898 // When the last char in the line was deleted then append. Detect this |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6899 // by checking if the cursor moved to before the Visual area. |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6900 if (*ml_get_cursor() != NUL && LT_POS(curwin->w_cursor, old_pos) |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6901 && LT_POS(curwin->w_cursor, old_visual)) |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6902 inc_cursor(); |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6903 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6904 // Insert to replace the deleted text with the pasted text. |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6905 invoke_edit(cap, FALSE, cap->cmdchar, FALSE); |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6906 } |
7 | 6907 else if (!checkclearopq(cap->oap)) |
6908 { | |
6909 switch (cap->cmdchar) | |
6910 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6911 case 'A': // "A"ppend after the line |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6912 set_cursor_for_append_to_line(); |
7 | 6913 break; |
6914 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6915 case 'I': // "I"nsert before the first non-blank |
164 | 6916 if (vim_strchr(p_cpo, CPO_INSEND) == NULL) |
6917 beginline(BL_WHITE); | |
6918 else | |
6919 beginline(BL_WHITE|BL_FIX); | |
7 | 6920 break; |
6921 | |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6922 case K_PS: |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6923 // Bracketed paste works like "a"ppend, unless the cursor is in |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6924 // the first column, then it inserts. |
10813
09eb5fd275e0
patch 8.0.0296: bracketed paste can only append, not insert
Christian Brabandt <cb@256bit.org>
parents:
10785
diff
changeset
|
6925 if (curwin->w_cursor.col == 0) |
09eb5fd275e0
patch 8.0.0296: bracketed paste can only append, not insert
Christian Brabandt <cb@256bit.org>
parents:
10785
diff
changeset
|
6926 break; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6927 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6928 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6929 case 'a': // "a"ppend is like "i"nsert on the next character. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6930 // increment coladd when in virtual space, increment the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6931 // column otherwise, also to append after an unprintable char |
7 | 6932 if (virtual_active() |
6933 && (curwin->w_cursor.coladd > 0 | |
6934 || *ml_get_cursor() == NUL | |
6935 || *ml_get_cursor() == TAB)) | |
6936 curwin->w_cursor.coladd++; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
6937 else if (*ml_get_cursor() != NUL) |
7 | 6938 inc_cursor(); |
6939 break; | |
6940 } | |
6941 | |
6942 if (curwin->w_cursor.coladd && cap->cmdchar != 'A') | |
6943 { | |
6944 int save_State = State; | |
6945 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6946 // Pretend Insert mode here to allow the cursor on the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6947 // character past the end of the line |
7 | 6948 State = INSERT; |
6949 coladvance(getviscol()); | |
6950 State = save_State; | |
6951 } | |
6952 | |
6953 invoke_edit(cap, FALSE, cap->cmdchar, FALSE); | |
6954 } | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6955 else if (cap->cmdchar == K_PS) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6956 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6957 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 6958 } |
6959 | |
6960 /* | |
6961 * Invoke edit() and take care of "restart_edit" and the return value. | |
6962 */ | |
6963 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6964 invoke_edit( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6965 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6966 int repl, // "r" or "gr" command |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6967 int cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6968 int startln) |
7 | 6969 { |
6970 int restart_edit_save = 0; | |
6971 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6972 // Complicated: When the user types "a<C-O>a" we don't want to do Insert |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6973 // mode recursively. But when doing "a<C-O>." or "a<C-O>rx" we do allow |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6974 // it. |
7 | 6975 if (repl || !stuff_empty()) |
6976 restart_edit_save = restart_edit; | |
6977 else | |
6978 restart_edit_save = 0; | |
6979 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6980 // Always reset "restart_edit", this is not a restarted edit. |
7 | 6981 restart_edit = 0; |
6982 | |
6983 if (edit(cmd, startln, cap->count1)) | |
6984 cap->retval |= CA_COMMAND_BUSY; | |
6985 | |
6986 if (restart_edit == 0) | |
6987 restart_edit = restart_edit_save; | |
6988 } | |
6989 | |
6990 #ifdef FEAT_TEXTOBJ | |
6991 /* | |
6992 * "a" or "i" while an operator is pending or in Visual mode: object motion. | |
6993 */ | |
6994 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6995 nv_object( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6996 cmdarg_T *cap) |
7 | 6997 { |
6998 int flag; | |
6999 int include; | |
7000 char_u *mps_save; | |
7001 | |
7002 if (cap->cmdchar == 'i') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7003 include = FALSE; // "ix" = inner object: exclude white space |
7 | 7004 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7005 include = TRUE; // "ax" = an object: include white space |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7006 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7007 // Make sure (), [], {} and <> are in 'matchpairs' |
7 | 7008 mps_save = curbuf->b_p_mps; |
7009 curbuf->b_p_mps = (char_u *)"(:),{:},[:],<:>"; | |
7010 | |
7011 switch (cap->nchar) | |
7012 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7013 case 'w': // "aw" = a word |
7 | 7014 flag = current_word(cap->oap, cap->count1, include, FALSE); |
7015 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7016 case 'W': // "aW" = a WORD |
7 | 7017 flag = current_word(cap->oap, cap->count1, include, TRUE); |
7018 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7019 case 'b': // "ab" = a braces block |
7 | 7020 case '(': |
7021 case ')': | |
7022 flag = current_block(cap->oap, cap->count1, include, '(', ')'); | |
7023 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7024 case 'B': // "aB" = a Brackets block |
7 | 7025 case '{': |
7026 case '}': | |
7027 flag = current_block(cap->oap, cap->count1, include, '{', '}'); | |
7028 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7029 case '[': // "a[" = a [] block |
7 | 7030 case ']': |
7031 flag = current_block(cap->oap, cap->count1, include, '[', ']'); | |
7032 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7033 case '<': // "a<" = a <> block |
7 | 7034 case '>': |
7035 flag = current_block(cap->oap, cap->count1, include, '<', '>'); | |
7036 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7037 case 't': // "at" = a tag block (xml and html) |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7038 // Do not adjust oap->end in do_pending_operator() |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7039 // otherwise there are different results for 'dit' |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7040 // (note leading whitespace in last line): |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7041 // 1) <b> 2) <b> |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7042 // foobar foobar |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7043 // </b> </b> |
6661 | 7044 cap->retval |= CA_NO_ADJ_OP_END; |
420 | 7045 flag = current_tagblock(cap->oap, cap->count1, include); |
7046 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7047 case 'p': // "ap" = a paragraph |
7 | 7048 flag = current_par(cap->oap, cap->count1, include, 'p'); |
7049 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7050 case 's': // "as" = a sentence |
7 | 7051 flag = current_sent(cap->oap, cap->count1, include); |
7052 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7053 case '"': // "a"" = a double quoted string |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7054 case '\'': // "a'" = a single quoted string |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7055 case '`': // "a`" = a backtick quoted string |
12 | 7056 flag = current_quote(cap->oap, cap->count1, include, |
7057 cap->nchar); | |
7058 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7059 #if 0 // TODO |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7060 case 'S': // "aS" = a section |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7061 case 'f': // "af" = a filename |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7062 case 'u': // "au" = a URL |
7 | 7063 #endif |
7064 default: | |
7065 flag = FAIL; | |
7066 break; | |
7067 } | |
7068 | |
7069 curbuf->b_p_mps = mps_save; | |
7070 if (flag == FAIL) | |
7071 clearopbeep(cap->oap); | |
7072 adjust_cursor_col(); | |
7073 curwin->w_set_curswant = TRUE; | |
7074 } | |
7075 #endif | |
7076 | |
7077 /* | |
7078 * "q" command: Start/stop recording. | |
7079 * "q:", "q/", "q?": edit command-line in command-line window. | |
7080 */ | |
7081 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7082 nv_record(cmdarg_T *cap) |
7 | 7083 { |
7084 if (cap->oap->op_type == OP_FORMAT) | |
7085 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7086 // "gqq" is the same as "gqgq": format line |
7 | 7087 cap->cmdchar = 'g'; |
7088 cap->nchar = 'q'; | |
7089 nv_operator(cap); | |
7090 } | |
7091 else if (!checkclearop(cap->oap)) | |
7092 { | |
7093 #ifdef FEAT_CMDWIN | |
7094 if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') | |
7095 { | |
7096 stuffcharReadbuff(cap->nchar); | |
7097 stuffcharReadbuff(K_CMDWIN); | |
7098 } | |
7099 else | |
7100 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7101 // (stop) recording into a named register, unless executing a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7102 // register |
14004
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13876
diff
changeset
|
7103 if (reg_executing == 0 && do_record(cap->nchar) == FAIL) |
7 | 7104 clearopbeep(cap->oap); |
7105 } | |
7106 } | |
7107 | |
7108 /* | |
7109 * Handle the "@r" command. | |
7110 */ | |
7111 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7112 nv_at(cmdarg_T *cap) |
7 | 7113 { |
7114 if (checkclearop(cap->oap)) | |
7115 return; | |
7116 #ifdef FEAT_EVAL | |
7117 if (cap->nchar == '=') | |
7118 { | |
7119 if (get_expr_register() == NUL) | |
7120 return; | |
7121 } | |
7122 #endif | |
7123 while (cap->count1-- && !got_int) | |
7124 { | |
1034 | 7125 if (do_execreg(cap->nchar, FALSE, FALSE, FALSE) == FAIL) |
7 | 7126 { |
7127 clearopbeep(cap->oap); | |
7128 break; | |
7129 } | |
7130 line_breakcheck(); | |
7131 } | |
7132 } | |
7133 | |
7134 /* | |
7135 * Handle the CTRL-U and CTRL-D commands. | |
7136 */ | |
7137 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7138 nv_halfpage(cmdarg_T *cap) |
7 | 7139 { |
7140 if ((cap->cmdchar == Ctrl_U && curwin->w_cursor.lnum == 1) | |
7141 || (cap->cmdchar == Ctrl_D | |
7142 && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)) | |
7143 clearopbeep(cap->oap); | |
7144 else if (!checkclearop(cap->oap)) | |
7145 halfpage(cap->cmdchar == Ctrl_D, cap->count0); | |
7146 } | |
7147 | |
7148 /* | |
7149 * Handle "J" or "gJ" command. | |
7150 */ | |
7151 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7152 nv_join(cmdarg_T *cap) |
7 | 7153 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7154 if (VIsual_active) // join the visual lines |
7 | 7155 nv_operator(cap); |
5735 | 7156 else if (!checkclearop(cap->oap)) |
7 | 7157 { |
7158 if (cap->count0 <= 1) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7159 cap->count0 = 2; // default for join is two lines! |
7 | 7160 if (curwin->w_cursor.lnum + cap->count0 - 1 > |
7161 curbuf->b_ml.ml_line_count) | |
8445
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7162 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7163 // can't join when on the last line |
8445
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7164 if (cap->count0 <= 2) |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7165 { |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7166 clearopbeep(cap->oap); |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7167 return; |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7168 } |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7169 cap->count0 = curbuf->b_ml.ml_line_count |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7170 - curwin->w_cursor.lnum + 1; |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7171 } |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7172 |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7173 prep_redo(cap->oap->regname, cap->count0, |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7174 NUL, cap->cmdchar, NUL, NUL, cap->nchar); |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7175 (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); |
7 | 7176 } |
7177 } | |
7178 | |
7179 /* | |
7180 * "P", "gP", "p" and "gp" commands. | |
7181 */ | |
7182 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7183 nv_put(cmdarg_T *cap) |
7 | 7184 { |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7185 nv_put_opt(cap, FALSE); |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7186 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7187 |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7188 /* |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7189 * "P", "gP", "p" and "gp" commands. |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7190 * "fix_indent" is TRUE for "[p", "[P", "]p" and "]P". |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7191 */ |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7192 static void |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7193 nv_put_opt(cmdarg_T *cap, int fix_indent) |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7194 { |
7 | 7195 int regname = 0; |
7196 void *reg1 = NULL, *reg2 = NULL; | |
84 | 7197 int empty = FALSE; |
236 | 7198 int was_visual = FALSE; |
7 | 7199 int dir; |
7200 int flags = 0; | |
27428
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7201 int save_unnamed = FALSE; |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7202 yankreg_T *old_y_current, *old_y_previous; |
7 | 7203 |
7204 if (cap->oap->op_type != OP_NOP) | |
7205 { | |
7206 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7207 // "dp" is ":diffput" |
7 | 7208 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'p') |
7209 { | |
7210 clearop(cap->oap); | |
6314 | 7211 nv_diffgetput(TRUE, cap->opcount); |
7 | 7212 } |
7213 else | |
7214 #endif | |
7215 clearopbeep(cap->oap); | |
7216 } | |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7217 #ifdef FEAT_JOB_CHANNEL |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7218 else if (bt_prompt(curbuf) && !prompt_curpos_editable()) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7219 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7220 clearopbeep(cap->oap); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7221 } |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7222 #endif |
7 | 7223 else |
7224 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7225 if (fix_indent) |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7226 { |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7227 dir = (cap->cmdchar == ']' && cap->nchar == 'p') |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7228 ? FORWARD : BACKWARD; |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7229 flags |= PUT_FIXINDENT; |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7230 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7231 else |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7232 dir = (cap->cmdchar == 'P' |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7233 || ((cap->cmdchar == 'g' || cap->cmdchar == 'z') |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7234 && cap->nchar == 'P')) ? BACKWARD : FORWARD; |
7 | 7235 prep_redo_cmd(cap); |
7236 if (cap->cmdchar == 'g') | |
7237 flags |= PUT_CURSEND; | |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7238 else if (cap->cmdchar == 'z') |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7239 flags |= PUT_BLOCK_INNER; |
7 | 7240 |
7241 if (VIsual_active) | |
7242 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7243 // Putting in Visual mode: The put text replaces the selected |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7244 // text. First delete the selected text, then put the new text. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7245 // Need to save and restore the registers that the delete |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7246 // overwrites if the old contents is being put. |
236 | 7247 was_visual = TRUE; |
7 | 7248 regname = cap->oap->regname; |
27428
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7249 save_unnamed = cap->cmdchar == 'P'; |
5735 | 7250 #ifdef FEAT_CLIPBOARD |
7 | 7251 adjust_clip_reg(®name); |
5735 | 7252 #endif |
5682 | 7253 if (regname == 0 || regname == '"' |
4013 | 7254 || VIM_ISDIGIT(regname) || regname == '-' |
5735 | 7255 #ifdef FEAT_CLIPBOARD |
7 | 7256 || (clip_unnamed && (regname == '*' || regname == '+')) |
5735 | 7257 #endif |
7 | 7258 |
7259 ) | |
7260 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7261 // The delete is going to overwrite the register we want to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7262 // put, save it first. |
7 | 7263 reg1 = get_register(regname, TRUE); |
7264 } | |
7265 | |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7266 // Now delete the selected text. Avoid messages here. |
27428
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7267 if (save_unnamed) |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7268 { |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7269 old_y_current = get_y_current(); |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7270 old_y_previous = get_y_previous(); |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7271 } |
7 | 7272 cap->cmdchar = 'd'; |
7273 cap->nchar = NUL; | |
7274 cap->oap->regname = NUL; | |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7275 ++msg_silent; |
7 | 7276 nv_operator(cap); |
7277 do_pending_operator(cap, 0, FALSE); | |
84 | 7278 empty = (curbuf->b_ml.ml_flags & ML_EMPTY); |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7279 --msg_silent; |
7 | 7280 |
27428
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7281 if (save_unnamed) |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7282 { |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7283 set_y_current(old_y_current); |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7284 set_y_previous(old_y_previous); |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7285 } |
3f8a57b8c7d8
patch 8.2.4242: put in Visual mode cannot be repeated
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
7286 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7287 // delete PUT_LINE_BACKWARD; |
7 | 7288 cap->oap->regname = regname; |
7289 | |
7290 if (reg1 != NULL) | |
7291 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7292 // Delete probably changed the register we want to put, save |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7293 // it first. Then put back what was there before the delete. |
7 | 7294 reg2 = get_register(regname, FALSE); |
7295 put_register(regname, reg1); | |
7296 } | |
7297 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7298 // When deleted a linewise Visual area, put the register as |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7299 // lines to avoid it joined with the next line. When deletion was |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7300 // characterwise, split a line when putting lines. |
7 | 7301 if (VIsual_mode == 'V') |
7302 flags |= PUT_LINE; | |
7303 else if (VIsual_mode == 'v') | |
7304 flags |= PUT_LINE_SPLIT; | |
7305 if (VIsual_mode == Ctrl_V && dir == FORWARD) | |
7306 flags |= PUT_LINE_FORWARD; | |
7307 dir = BACKWARD; | |
7308 if ((VIsual_mode != 'V' | |
7309 && curwin->w_cursor.col < curbuf->b_op_start.col) | |
7310 || (VIsual_mode == 'V' | |
7311 && curwin->w_cursor.lnum < curbuf->b_op_start.lnum)) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7312 // cursor is at the end of the line or end of file, put |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7313 // forward. |
7 | 7314 dir = FORWARD; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7315 // May have been reset in do_put(). |
5365 | 7316 VIsual_active = TRUE; |
7 | 7317 } |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7318 do_put(cap->oap->regname, NULL, dir, cap->count1, flags); |
7 | 7319 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7320 // If a register was saved, put it back now. |
7 | 7321 if (reg2 != NULL) |
7322 put_register(regname, reg2); | |
236 | 7323 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7324 // What to reselect with "gv"? Selecting the just put text seems to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7325 // be the most useful, since the original text was removed. |
236 | 7326 if (was_visual) |
7327 { | |
690 | 7328 curbuf->b_visual.vi_start = curbuf->b_op_start; |
7329 curbuf->b_visual.vi_end = curbuf->b_op_end; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7330 // need to adjust cursor position |
7241
0c1278704b5c
commit https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27
Christian Brabandt <cb@256bit.org>
parents:
7143
diff
changeset
|
7331 if (*p_sel == 'e') |
0c1278704b5c
commit https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27
Christian Brabandt <cb@256bit.org>
parents:
7143
diff
changeset
|
7332 inc(&curbuf->b_visual.vi_end); |
236 | 7333 } |
7334 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7335 // When all lines were selected and deleted do_put() leaves an empty |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7336 // line that needs to be deleted now. |
84 | 7337 if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) |
817 | 7338 { |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
7339 ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE); |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7340 deleted_lines(curbuf->b_ml.ml_line_count + 1, 1); |
817 | 7341 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7342 // If the cursor was in that line, move it to the end of the last |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7343 // line. |
817 | 7344 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
7345 { | |
7346 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
7347 coladvance((colnr_T)MAXCOL); | |
7348 } | |
7349 } | |
7 | 7350 auto_format(FALSE, TRUE); |
7351 } | |
7352 } | |
7353 | |
7354 /* | |
7355 * "o" and "O" commands. | |
7356 */ | |
7357 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7358 nv_open(cmdarg_T *cap) |
7 | 7359 { |
7360 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7361 // "do" is ":diffget" |
7 | 7362 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'o') |
7363 { | |
7364 clearop(cap->oap); | |
6314 | 7365 nv_diffgetput(FALSE, cap->opcount); |
7 | 7366 } |
7367 else | |
7368 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7369 if (VIsual_active) // switch start and end of visual |
7 | 7370 v_swap_corners(cap->cmdchar); |
14019
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7371 #ifdef FEAT_JOB_CHANNEL |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7372 else if (bt_prompt(curbuf)) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7373 clearopbeep(cap->oap); |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7374 #endif |
7 | 7375 else |
7376 n_opencmd(cap); | |
7377 } | |
7378 | |
7379 #ifdef FEAT_NETBEANS_INTG | |
7380 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7381 nv_nbcmd(cmdarg_T *cap) |
7 | 7382 { |
7383 netbeans_keycommand(cap->nchar); | |
7384 } | |
7385 #endif | |
7386 | |
7387 #ifdef FEAT_DND | |
7388 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7389 nv_drop(cmdarg_T *cap UNUSED) |
7 | 7390 { |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7391 do_put('~', NULL, BACKWARD, 1L, PUT_CURSEND); |
7 | 7392 } |
7393 #endif | |
203 | 7394 |
7395 /* | |
7396 * Trigger CursorHold event. | |
7397 * When waiting for a character for 'updatetime' K_CURSORHOLD is put in the | |
7398 * input buffer. "did_cursorhold" is set to avoid retriggering. | |
7399 */ | |
7400 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7401 nv_cursorhold(cmdarg_T *cap) |
203 | 7402 { |
7403 apply_autocmds(EVENT_CURSORHOLD, NULL, NULL, FALSE, curbuf); | |
7404 did_cursorhold = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7405 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
226 | 7406 } |