Mercurial > vim
annotate src/normal.c @ 32228:ac2f07ae1957 v9.0.1445
patch 9.0.1445: openSUSE: configure doesn't find the Motif library
Commit: https://github.com/vim/vim/commit/01967f5b1042b375b38098eceaf31671902c8dbb
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Apr 12 16:24:03 2023 +0100
patch 9.0.1445: openSUSE: configure doesn't find the Motif library
Problem: openSUSE: configure doesn't find the Motif library. (Tony
Mechelynck)
Solution: Also search in /usr/lib64.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 12 Apr 2023 17:30:06 +0200 |
parents | cbf0ed5c83d0 |
children | 7d552e52fe92 |
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); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
23 static void del_from_showcmd(int); |
7 | 24 |
25 /* | |
26 * nv_*(): functions called to handle Normal and Visual mode commands. | |
27 * n_*(): functions called to handle Normal mode commands. | |
28 * v_*(): functions called to handle Visual mode commands. | |
29 */ | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 static void nv_zet(cmdarg_T *cap); |
7 | 37 #ifdef FEAT_GUI |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
38 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
|
39 static void nv_hor_scrollbar(cmdarg_T *cap); |
7 | 40 #endif |
685 | 41 #ifdef FEAT_GUI_TABLINE |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
42 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
|
43 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
|
44 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 static void nv_operator(cmdarg_T *cap); |
1490 | 93 #ifdef FEAT_EVAL |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
94 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
|
95 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 static void invoke_edit(cmdarg_T *cap, int repl, int cmd, int startln); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 static void nv_open(cmdarg_T *cap); |
7 | 118 #ifdef FEAT_NETBEANS_INTG |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
119 static void nv_nbcmd(cmdarg_T *cap); |
7 | 120 #endif |
121 #ifdef FEAT_DND | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
122 static void nv_drop(cmdarg_T *cap); |
7 | 123 #endif |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
124 static void nv_cursorhold(cmdarg_T *cap); |
7 | 125 |
27484
ee1019e59bef
patch 8.2.4270: generating nv_cmdidxs.h requires building Vim twice
Bram Moolenaar <Bram@vim.org>
parents:
27447
diff
changeset
|
126 // 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
|
127 #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
|
128 #include "nv_cmds.h" |
7 | 129 |
27447
4050f0554902
patch 8.2.4252: generating the normal command table at runtime is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
27428
diff
changeset
|
130 // 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
|
131 #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
|
132 |
7 | 133 /* |
134 * Search for a command in the commands table. | |
135 * Returns -1 for invalid command. | |
136 */ | |
137 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
138 find_command(int cmdchar) |
7 | 139 { |
140 int i; | |
141 int idx; | |
142 int top, bot; | |
143 int c; | |
144 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
145 // A multi-byte character is never a command. |
7 | 146 if (cmdchar >= 0x100) |
147 return -1; | |
148 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
149 // 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
|
150 // negative value, but are sorted on their absolute value. |
7 | 151 if (cmdchar < 0) |
152 cmdchar = -cmdchar; | |
153 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
154 // 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
|
155 // nv_cmd_idx[]. |
7 | 156 if (cmdchar <= nv_max_linear) |
157 return nv_cmd_idx[cmdchar]; | |
158 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
159 // Perform a binary search. |
7 | 160 bot = nv_max_linear + 1; |
161 top = NV_CMDS_SIZE - 1; | |
162 idx = -1; | |
163 while (bot <= top) | |
164 { | |
165 i = (top + bot) / 2; | |
166 c = nv_cmds[nv_cmd_idx[i]].cmd_char; | |
167 if (c < 0) | |
168 c = -c; | |
169 if (cmdchar == c) | |
170 { | |
171 idx = nv_cmd_idx[i]; | |
172 break; | |
173 } | |
174 if (cmdchar > c) | |
175 bot = i + 1; | |
176 else | |
177 top = i - 1; | |
178 } | |
179 return idx; | |
180 } | |
181 | |
182 /* | |
29002
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
183 * If currently editing a cmdline or text is locked: beep and give an error |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
184 * message, return TRUE. |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
185 */ |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
186 static int |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
187 check_text_locked(oparg_T *oap) |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
188 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
189 if (!text_locked()) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
190 return FALSE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
191 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
192 if (oap != NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
193 clearopbeep(oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
194 text_locked_msg(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
195 return TRUE; |
29002
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
196 } |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
197 |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
198 /* |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
199 * If text is locked, "curbuf_lock" or "allbuf_lock" is set: |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
200 * Give an error message, possibly beep and return TRUE. |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
201 * "oap" may be NULL. |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
202 */ |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
203 int |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
204 check_text_or_curbuf_locked(oparg_T *oap) |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
205 { |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
206 if (check_text_locked(oap)) |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
207 return TRUE; |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
208 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
209 if (!curbuf_locked()) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
210 return FALSE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
211 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
212 if (oap != NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
213 clearop(oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
214 return TRUE; |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
215 } |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
216 |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
217 /* |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
218 * 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
|
219 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
220 static int |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
221 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
|
222 cmdarg_T *cap, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
223 int c, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
224 int toplevel UNUSED, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
225 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
|
226 int *ctrl_w, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
227 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
|
228 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
229 getcount: |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
230 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
|
231 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
232 // 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
|
233 // 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
|
234 // 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
|
235 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
|
236 || (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
|
237 || c == '0'))) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
238 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
239 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
|
240 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
241 cap->count0 /= 10; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
242 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
|
243 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
244 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
|
245 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
246 cap->count0 = 999999999L; |
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 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
249 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
250 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
|
251 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
252 #ifdef FEAT_EVAL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
253 // 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
|
254 // 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
|
255 // 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
|
256 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
|
257 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
|
258 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
259 if (*ctrl_w) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
260 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
261 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
262 ++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
|
263 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
264 ++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
|
265 c = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
266 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
|
267 --no_zero_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
268 if (*ctrl_w) |
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 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
271 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
272 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
273 *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
|
274 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
275 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
276 // 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
|
277 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
|
278 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
279 *ctrl_w = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
280 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
|
281 cap->count0 = 0; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
282 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
283 ++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
|
284 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
|
285 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
|
286 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
287 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
288 *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
|
289 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
|
290 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
291 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
292 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
293 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
|
294 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
295 // 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
|
296 // 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
|
297 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
|
298 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
|
299 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
300 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
|
301 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
302 // 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
|
303 // 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
|
304 // 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
|
305 // 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
|
306 // 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
|
307 // 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
|
308 // multiplied. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
309 if (cap->count0) |
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 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
|
312 cap->count0 = 999999999L; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
313 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
314 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
|
315 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
316 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
317 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
|
318 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
319 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
320 // 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
|
321 // 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
|
322 // 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
|
323 // variable. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
324 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
|
325 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
|
326 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
327 #ifdef FEAT_EVAL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
328 // 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
|
329 // 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
|
330 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
|
331 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
|
332 #endif |
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 return c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
335 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
336 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
337 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
338 * 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
|
339 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
340 static int |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
341 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
|
342 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
343 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
|
344 && (((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
|
345 && 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
|
346 || (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
|
347 || (cap->cmdchar == 'q' |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
348 && 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
|
349 && reg_recording == 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
350 && reg_executing == 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
351 || ((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
|
352 && (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
|
353 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
354 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
355 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
356 * 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
|
357 * 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
|
358 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
359 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
|
360 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
|
361 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
|
362 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
|
363 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
|
364 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
365 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
|
366 int c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
367 int *cp; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
368 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
|
369 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
|
370 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
|
371 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
|
372 #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
|
373 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
|
374 #endif |
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 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
377 ++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
|
378 // 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
|
379 // 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
|
380 did_cursorhold = TRUE; |
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 == 'g') |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
382 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
383 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
384 * 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
|
385 * "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
|
386 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
387 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
|
388 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
|
389 *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
|
390 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
|
391 || 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
|
392 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
393 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
|
394 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
|
395 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
|
396 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
397 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
|
398 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
399 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
400 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
|
401 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
402 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
403 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
404 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
|
405 repl = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
406 cp = &cap->nchar; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
407 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
408 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
|
409 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
410 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
411 * 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
|
412 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
413 if (cp != NULL) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
414 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
415 if (repl) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
416 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
417 State = MODE_REPLACE; // pretend Replace mode |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
418 #ifdef CURSOR_SHAPE |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
419 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
|
420 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
421 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
422 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
|
423 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
424 // 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
|
425 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
426 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
427 if (repl) |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
428 State = MODE_LREPLACE; |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
429 else |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
430 State = MODE_LANGMAP; |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
431 langmap_active = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
432 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
433 #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
|
434 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
|
435 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
|
436 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
|
437 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
|
438 #endif |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
439 if ((State & MODE_INSERT) && !p_ek) |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
440 { |
29069
be6c32395444
patch 8.2.5056: the channel log only contains some of the raw terminal output
Bram Moolenaar <Bram@vim.org>
parents:
29004
diff
changeset
|
441 MAY_WANT_TO_LOG_THIS; |
be6c32395444
patch 8.2.5056: the channel log only contains some of the raw terminal output
Bram Moolenaar <Bram@vim.org>
parents:
29004
diff
changeset
|
442 |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
443 // 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
|
444 // 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
|
445 out_str(T_BD); |
31192
dcde141f2d1e
patch 9.0.0930: cannot debug the Kitty keyboard protocol with TermDebug
Bram Moolenaar <Bram@vim.org>
parents:
31133
diff
changeset
|
446 out_str_t_TE(); |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
447 } |
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 *cp = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
450 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
451 if ((State & MODE_INSERT) && !p_ek) |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
452 { |
29069
be6c32395444
patch 8.2.5056: the channel log only contains some of the raw terminal output
Bram Moolenaar <Bram@vim.org>
parents:
29004
diff
changeset
|
453 MAY_WANT_TO_LOG_THIS; |
be6c32395444
patch 8.2.5056: the channel log only contains some of the raw terminal output
Bram Moolenaar <Bram@vim.org>
parents:
29004
diff
changeset
|
454 |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
455 // Re-enable bracketed paste mode and modifyOtherKeys |
31588
e94571ac4134
patch 9.0.1126: bracketed paste can be enabled when it is not recognized
Bram Moolenaar <Bram@vim.org>
parents:
31457
diff
changeset
|
456 out_str_t_BE(); |
31293
ff4473b3fc58
patch 9.0.0980: the keyboard state response may end up in a shell command
Bram Moolenaar <Bram@vim.org>
parents:
31227
diff
changeset
|
457 out_str_t_TI(); |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
458 } |
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 (langmap_active) |
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 // 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
|
463 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
464 ++allow_keys; |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
465 State = MODE_NORMAL_BUSY; |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
466 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
467 #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
|
468 if (lang) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
469 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
470 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
|
471 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
|
472 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
|
473 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
474 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
|
475 #endif |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
476 State = MODE_NORMAL_BUSY; |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
477 *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
|
478 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
479 if (!lit) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
480 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
481 #ifdef FEAT_DIGRAPHS |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
482 // 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
|
483 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
|
484 && ((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
|
485 || 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
|
486 && 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
|
487 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
488 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
|
489 if (c > 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
490 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
491 *cp = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
492 // 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
|
493 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
|
494 *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
|
495 } |
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 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
498 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
499 // 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
|
500 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
|
501 #ifdef FEAT_RIGHTLEFT |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
502 // 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
|
503 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
|
504 *cp = hkmap(*cp); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
505 #endif |
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 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
508 // 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
|
509 // 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
|
510 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
|
511 && 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
|
512 && (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
|
513 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
514 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
|
515 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
|
516 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
|
517 } |
32049
717a1a8dc751
patch 9.0.1356: cannot cancel "gr" with Esc
Bram Moolenaar <Bram@vim.org>
parents:
32045
diff
changeset
|
518 else if ((cap->nchar == 'n' || cap->nchar == 'N') |
717a1a8dc751
patch 9.0.1356: cannot cancel "gr" with Esc
Bram Moolenaar <Bram@vim.org>
parents:
32045
diff
changeset
|
519 && cap->cmdchar == 'g') |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
520 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
|
521 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
|
522 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
523 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
|
524 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
525 // 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
|
526 // 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
|
527 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
|
528 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
529 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
|
530 towait -= 50L; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
531 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
532 if (c > 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
533 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
534 c = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
535 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
|
536 vungetc(c); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
537 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
538 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
539 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
|
540 cap->nchar = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
541 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
|
542 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
543 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
544 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
545 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
546 // 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
|
547 // 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
|
548 // 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
|
549 // 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
|
550 // mapping. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
551 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
552 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
|
553 && (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
|
554 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
555 c = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
556 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
|
557 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
558 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
|
559 break; |
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 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
|
562 cap->ncharC1 = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
563 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
564 cap->ncharC2 = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
565 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
566 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
567 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
568 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
569 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
570 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
571 return idx; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
572 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
573 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
574 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
575 * 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
|
576 * 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
|
577 * message. |
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 static int |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
580 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
|
581 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
582 // 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
|
583 // 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
|
584 // 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
|
585 // 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
|
586 // 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
|
587 // 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
|
588 // 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
|
589 // 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
|
590 return ( ((p_smd |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
591 && msg_silent == 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
592 && (restart_edit != 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
593 || (VIsual_active |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
594 && 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
|
595 && 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
|
596 ) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
597 && (clear_cmdline |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
598 || redraw_cmdline) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
599 && (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
|
600 && !msg_nowait |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
601 && KeyTyped) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
602 || (restart_edit != 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
603 && !VIsual_active |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
604 && (msg_scroll |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
605 || emsg_on_display))) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
606 && 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
|
607 && !(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
|
608 && stuff_empty() |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
609 && typebuf_typed() |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
610 && emsg_silent == 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
611 && !in_assert_fails |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
612 && !did_wait_return |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
613 && 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
|
614 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
615 |
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 * 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
|
618 * 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
|
619 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
620 static void |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
621 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
|
622 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
623 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
|
624 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
625 // 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
|
626 if (restart_edit != 0) |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
627 State = MODE_INSERT; |
27354
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 // 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
|
630 // delay |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
631 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
|
632 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
633 char_u *kmsg; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
634 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
635 kmsg = keep_msg; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
636 keep_msg = NULL; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
637 // 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
|
638 // 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
|
639 setcursor(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
640 update_screen(0); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
641 // 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
|
642 keep_msg = kmsg; |
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 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
|
645 if (kmsg != NULL) |
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 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
|
648 vim_free(kmsg); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
649 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
650 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
651 setcursor(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
652 #ifdef CURSOR_SHAPE |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
653 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
|
654 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
655 cursor_on(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
656 out_flush(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
657 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
|
658 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
|
659 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
|
660 State = save_State; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
661 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
662 msg_scroll = FALSE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
663 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
|
664 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
665 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
666 /* |
7 | 667 * Execute a command in Normal mode. |
668 */ | |
669 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
670 normal_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
671 oparg_T *oap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
672 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
|
673 { |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
674 cmdarg_T ca; // command arguments |
7 | 675 int c; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
676 int ctrl_w = FALSE; // got CTRL-W command |
7 | 677 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
|
678 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
|
679 pos_T old_pos; // cursor position before command |
7 | 680 int mapped_len; |
681 static int old_mapped_len = 0; | |
682 int idx; | |
1751 | 683 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
|
684 int save_did_cursorhold = did_cursorhold; |
7 | 685 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
686 CLEAR_FIELD(ca); // also resets ca.retval |
7 | 687 ca.oap = oap; |
1692 | 688 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
689 // 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
|
690 // "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
|
691 // remembered in "opcount". |
7 | 692 ca.opcount = opcount; |
693 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
694 // 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
|
695 // 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
|
696 // returning this time (unless the operation was cancelled). |
7 | 697 #ifdef CURSOR_SHAPE |
698 c = finish_op; | |
699 #endif | |
700 finish_op = (oap->op_type != OP_NOP); | |
701 #ifdef CURSOR_SHAPE | |
702 if (finish_op != c) | |
703 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
704 ui_cursor_shape(); // may show different cursor shape |
7 | 705 # ifdef FEAT_MOUSESHAPE |
706 update_mouseshape(-1); | |
707 # endif | |
708 } | |
709 #endif | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
710 may_trigger_modechanged(); |
7 | 711 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
712 // 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
|
713 // count. |
7 | 714 if (!finish_op && !oap->regname) |
1751 | 715 { |
7 | 716 ca.opcount = 0; |
1751 | 717 #ifdef FEAT_EVAL |
718 set_prevcount = TRUE; | |
719 #endif | |
720 } | |
7 | 721 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
722 // 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
|
723 // 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
|
724 // "3 * 2". |
1692 | 725 if (oap->prev_opcount > 0 || oap->prev_count0 > 0) |
726 { | |
727 ca.opcount = oap->prev_opcount; | |
728 ca.count0 = oap->prev_count0; | |
729 oap->prev_opcount = 0; | |
730 oap->prev_count0 = 0; | |
731 } | |
732 | |
7 | 733 mapped_len = typebuf_maplen(); |
734 | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
735 State = MODE_NORMAL_BUSY; |
7 | 736 #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
|
737 dont_scroll = FALSE; // allow scrolling here |
7 | 738 #endif |
739 | |
2667 | 740 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
741 // 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
|
742 // 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
|
743 // when there is no count. Do set it for redo. |
5649 | 744 if (toplevel && readbuf1_empty()) |
2667 | 745 set_vcount_ca(&ca, &set_prevcount); |
746 #endif | |
747 | |
7 | 748 /* |
749 * Get the command character from the user. | |
750 */ | |
751 c = safe_vgetc(); | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
752 LANGMAP_ADJUST(c, get_real_state() != MODE_SELECT); |
7 | 753 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
754 // 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
|
755 // 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
|
756 // long as the mapping is being executed. |
7 | 757 if (restart_edit == 0) |
758 old_mapped_len = 0; | |
759 else if (old_mapped_len | |
819 | 760 || (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0)) |
7 | 761 old_mapped_len = typebuf_maplen(); |
762 | |
763 if (c == NUL) | |
764 c = K_ZERO; | |
765 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
766 // In Select mode, typed text replaces the selection. |
7 | 767 if (VIsual_active |
768 && VIsual_select | |
769 && (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER)) | |
770 { | |
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
|
771 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
|
772 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
773 // 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
|
774 // '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
|
775 // restart automatically. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
776 // 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
|
777 // 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
|
778 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
|
779 |
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
|
780 // 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
|
781 // 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
|
782 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
|
783 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
|
784 |
275 | 785 if (restart_edit != 0) |
786 c = 'd'; | |
787 else | |
788 c = 'c'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
789 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
|
790 old_mapped_len = 0; // do go to Insert mode |
7 | 791 } |
792 | |
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
|
793 // 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
|
794 // 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
|
795 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
|
796 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
|
797 |
7 | 798 need_flushbuf = add_to_showcmd(c); |
799 | |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
800 // 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
|
801 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
|
802 &need_flushbuf); |
7 | 803 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
804 // 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
|
805 // For CTRL-W we already got nchar when looking for a count. |
7 | 806 if (ctrl_w) |
807 { | |
808 ca.nchar = c; | |
809 ca.cmdchar = Ctrl_W; | |
810 } | |
811 else | |
812 ca.cmdchar = c; | |
813 idx = find_command(ca.cmdchar); | |
814 if (idx < 0) | |
815 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
816 // Not a known command: beep. |
7 | 817 clearopbeep(oap); |
818 goto normal_end; | |
819 } | |
631 | 820 |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
821 if ((nv_cmds[idx].cmd_flags & NV_NCW) && check_text_or_curbuf_locked(oap)) |
29002
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
822 // this command is not allowed now |
819 | 823 goto normal_end; |
7 | 824 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
825 // In Visual/Select mode, a few keys are handled in a special way. |
7 | 826 if (VIsual_active) |
827 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
828 // when 'keymodel' contains "stopsel" may stop Select/Visual mode |
7 | 829 if (km_stopsel |
830 && (nv_cmds[idx].cmd_flags & NV_STS) | |
831 && !(mod_mask & MOD_MASK_SHIFT)) | |
832 { | |
833 end_visual_mode(); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
834 redraw_curbuf_later(UPD_INVERTED); |
7 | 835 } |
836 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
837 // Keys that work different when 'keymodel' contains "startsel" |
7 | 838 if (km_startsel) |
839 { | |
840 if (nv_cmds[idx].cmd_flags & NV_SS) | |
841 { | |
842 unshift_special(&ca); | |
843 idx = find_command(ca.cmdchar); | |
840 | 844 if (idx < 0) |
845 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
846 // Just in case |
840 | 847 clearopbeep(oap); |
848 goto normal_end; | |
849 } | |
7 | 850 } |
851 else if ((nv_cmds[idx].cmd_flags & NV_SSS) | |
852 && (mod_mask & MOD_MASK_SHIFT)) | |
853 mod_mask &= ~MOD_MASK_SHIFT; | |
854 } | |
855 } | |
856 | |
857 #ifdef FEAT_RIGHTLEFT | |
858 if (curwin->w_p_rl && KeyTyped && !KeyStuffed | |
859 && (nv_cmds[idx].cmd_flags & NV_RL)) | |
860 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
861 // 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
|
862 // 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
|
863 // to "dl". |
7 | 864 switch (ca.cmdchar) |
865 { | |
866 case 'l': ca.cmdchar = 'h'; break; | |
867 case K_RIGHT: ca.cmdchar = K_LEFT; break; | |
868 case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break; | |
869 case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break; | |
870 case 'h': ca.cmdchar = 'l'; break; | |
871 case K_LEFT: ca.cmdchar = K_RIGHT; break; | |
872 case K_S_LEFT: ca.cmdchar = K_S_RIGHT; break; | |
873 case K_C_LEFT: ca.cmdchar = K_C_RIGHT; break; | |
874 case '>': ca.cmdchar = '<'; break; | |
875 case '<': ca.cmdchar = '>'; break; | |
876 } | |
877 idx = find_command(ca.cmdchar); | |
878 } | |
879 #endif | |
880 | |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
881 // 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
|
882 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
|
883 idx = normal_cmd_get_more_chars(idx, &ca, &need_flushbuf); |
7 | 884 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
885 // 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
|
886 // 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
|
887 // 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
|
888 // mappings. |
7 | 889 if (need_flushbuf) |
890 out_flush(); | |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
891 |
1727 | 892 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
|
893 { |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
894 if (ex_normal_busy) |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
895 did_cursorhold = save_did_cursorhold; |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
896 else |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
897 did_cursorhold = FALSE; |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
898 } |
7 | 899 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
900 State = MODE_NORMAL; |
7 | 901 |
32108
cbf0ed5c83d0
patch 9.0.1385: g'Esc is considered an error
Bram Moolenaar <Bram@vim.org>
parents:
32049
diff
changeset
|
902 if (ca.nchar == ESC || ca.extra_char == ESC) |
7 | 903 { |
904 clearop(oap); | |
905 if (restart_edit == 0 && goto_im()) | |
906 restart_edit = 'a'; | |
907 goto normal_end; | |
908 } | |
909 | |
24 | 910 if (ca.cmdchar != K_IGNORE) |
911 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
912 msg_didout = FALSE; // don't scroll screen up for normal command |
24 | 913 msg_col = 0; |
914 } | |
7 | 915 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
916 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
|
917 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
918 // 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
|
919 // mode. |
7 | 920 if (!VIsual_active && km_startsel) |
921 { | |
922 if (nv_cmds[idx].cmd_flags & NV_SS) | |
923 { | |
924 start_selection(); | |
925 unshift_special(&ca); | |
926 idx = find_command(ca.cmdchar); | |
927 } | |
928 else if ((nv_cmds[idx].cmd_flags & NV_SSS) | |
929 && (mod_mask & MOD_MASK_SHIFT)) | |
930 { | |
931 start_selection(); | |
932 mod_mask &= ~MOD_MASK_SHIFT; | |
933 } | |
934 } | |
935 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
936 // 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
|
937 // Call the command function found in the commands table. |
7 | 938 ca.arg = nv_cmds[idx].cmd_arg; |
939 (nv_cmds[idx].cmd_func)(&ca); | |
940 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
941 // 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
|
942 // need it later. |
7 | 943 if (!finish_op |
944 && !oap->op_type | |
945 && (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG))) | |
946 { | |
947 clearop(oap); | |
948 #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
|
949 reset_reg_var(); |
7 | 950 #endif |
951 } | |
952 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
953 // 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
|
954 // character or "z333<cr>". |
36 | 955 if (old_mapped_len > 0) |
956 old_mapped_len = typebuf_maplen(); | |
957 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
958 // 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
|
959 // 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
|
960 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
|
961 do_pending_operator(&ca, old_col, FALSE); |
7 | 962 |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
963 // 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
|
964 // 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
|
965 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
|
966 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
|
967 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
968 // Finish up after executing a Normal mode command. |
7 | 969 normal_end: |
970 | |
971 msg_nowait = FALSE; | |
972 | |
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
|
973 #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
|
974 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
|
975 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
|
976 #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
|
977 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
978 // Reset finish_op, in case it was set |
7 | 979 #ifdef CURSOR_SHAPE |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31984
diff
changeset
|
980 int prev_finish_op = finish_op; |
7 | 981 #endif |
982 finish_op = FALSE; | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
983 may_trigger_modechanged(); |
7 | 984 #ifdef CURSOR_SHAPE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
985 // 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
|
986 // mode or did a replace command. |
32108
cbf0ed5c83d0
patch 9.0.1385: g'Esc is considered an error
Bram Moolenaar <Bram@vim.org>
parents:
32049
diff
changeset
|
987 if (prev_finish_op || ca.cmdchar == 'r' |
cbf0ed5c83d0
patch 9.0.1385: g'Esc is considered an error
Bram Moolenaar <Bram@vim.org>
parents:
32049
diff
changeset
|
988 || (ca.cmdchar == 'g' && ca.nchar == 'r')) |
7 | 989 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
990 ui_cursor_shape(); // may show different cursor shape |
7 | 991 # ifdef FEAT_MOUSESHAPE |
992 update_mouseshape(-1); | |
993 # endif | |
994 } | |
995 #endif | |
996 | |
1692 | 997 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
|
998 && ca.cmdchar != K_CURSORHOLD) |
7 | 999 clear_showcmd(); |
1000 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1001 checkpcmark(); // check if we moved since setting pcmark |
7 | 1002 vim_free(ca.searchbuf); |
1003 | |
1004 if (has_mbyte) | |
1005 mb_adjust_cursor(); | |
1006 | |
1007 if (curwin->w_p_scb && toplevel) | |
1008 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1009 validate_cursor(); // may need to update w_leftcol |
7 | 1010 do_check_scrollbind(TRUE); |
1011 } | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
1012 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1013 if (curwin->w_p_crb && toplevel) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1014 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1015 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
|
1016 do_check_cursorbind(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1017 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1018 |
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
|
1019 #ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1020 // 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
|
1021 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
|
1022 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
|
1023 #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
|
1024 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1025 // 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
|
1026 // 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
|
1027 // May switch from Visual to Select mode after CTRL-O command. |
7 | 1028 if ( oap->op_type == OP_NOP |
1029 && ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0) | |
1030 || restart_VIsual_select == 1) | |
1031 && !(ca.retval & CA_COMMAND_BUSY) | |
1032 && stuff_empty() | |
1033 && oap->regname == 0) | |
1034 { | |
1035 if (restart_VIsual_select == 1) | |
1036 { | |
1037 VIsual_select = TRUE; | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
1038 may_trigger_modechanged(); |
7 | 1039 showmode(); |
1040 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
|
1041 VIsual_select_reg = 0; |
7 | 1042 } |
5735 | 1043 if (restart_edit != 0 && !VIsual_active && old_mapped_len == 0) |
7 | 1044 (void)edit(restart_edit, FALSE, 1L); |
1045 } | |
1046 | |
1047 if (restart_VIsual_select == 2) | |
1048 restart_VIsual_select = 1; | |
1049 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1050 // Save count before an operator for next time. |
7 | 1051 opcount = ca.opcount; |
1052 } | |
1053 | |
2667 | 1054 #ifdef FEAT_EVAL |
1055 /* | |
1056 * Set v:count and v:count1 according to "cap". | |
1057 * Set v:prevcount only when "set_prevcount" is TRUE. | |
1058 */ | |
1059 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1060 set_vcount_ca(cmdarg_T *cap, int *set_prevcount) |
2667 | 1061 { |
1062 long count = cap->count0; | |
1063 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1064 // multiply with cap->opcount the same way as above |
2667 | 1065 if (cap->opcount != 0) |
1066 count = cap->opcount * (count == 0 ? 1 : count); | |
1067 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
|
1068 *set_prevcount = FALSE; // only set v:prevcount once |
2667 | 1069 } |
1070 #endif | |
1071 | |
7 | 1072 /* |
19681
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1073 * Check if highlighting for Visual mode is possible, give a warning message |
7 | 1074 * if not. |
1075 */ | |
1076 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1077 check_visual_highlight(void) |
7 | 1078 { |
1079 static int did_check = FALSE; | |
1080 | |
1081 if (full_screen) | |
1082 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
1083 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
|
1084 msg(_("Warning: terminal cannot highlight")); |
7 | 1085 did_check = TRUE; |
1086 } | |
1087 } | |
1088 | |
23021
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1089 #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
|
1090 /* |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1091 * 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
|
1092 */ |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1093 static void |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1094 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
|
1095 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1096 oparg_T oa; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1097 yankreg_T *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 clear_oparg(&oa); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1100 oa.regname = regname; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1101 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
|
1102 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
|
1103 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
|
1104 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
|
1105 free_register(reg); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1106 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1107 #endif |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1108 |
7 | 1109 /* |
638 | 1110 * End Visual mode. |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1111 * 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
|
1112 * from do_pending_operator(). |
7 | 1113 */ |
1114 void | |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31984
diff
changeset
|
1115 end_visual_mode(void) |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1116 { |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1117 end_visual_mode_keep_button(); |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1118 reset_held_button(); |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1119 } |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1120 |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1121 void |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31984
diff
changeset
|
1122 end_visual_mode_keep_button(void) |
7 | 1123 { |
1124 #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
|
1125 // 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
|
1126 // 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
|
1127 // 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
|
1128 // the selection when hitting ESC. |
7 | 1129 if (clip_star.available && clip_star.owned) |
1130 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
|
1131 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1132 # 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
|
1133 // 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
|
1134 // 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
|
1135 if (has_textyankpost()) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1136 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1137 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
|
1138 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
|
1139 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
|
1140 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
|
1141 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1142 # endif |
7 | 1143 #endif |
1144 | |
1145 VIsual_active = FALSE; | |
1146 setmouse(); | |
1147 mouse_dragging = 0; | |
1148 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1149 // Save the current VIsual area for '< and '> marks, and "gv" |
690 | 1150 curbuf->b_visual.vi_mode = VIsual_mode; |
1151 curbuf->b_visual.vi_start = VIsual; | |
1152 curbuf->b_visual.vi_end = curwin->w_cursor; | |
1153 curbuf->b_visual.vi_curswant = curwin->w_curswant; | |
7 | 1154 #ifdef FEAT_EVAL |
1155 curbuf->b_visual_mode_eval = VIsual_mode; | |
1156 #endif | |
1157 if (!virtual_active()) | |
1158 curwin->w_cursor.coladd = 0; | |
6979 | 1159 may_clear_cmdline(); |
7 | 1160 |
844 | 1161 adjust_cursor_eol(); |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
1162 may_trigger_modechanged(); |
7 | 1163 } |
1164 | |
1165 /* | |
1166 * Reset VIsual_active and VIsual_reselect. | |
1167 */ | |
1168 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1169 reset_VIsual_and_resel(void) |
7 | 1170 { |
1171 if (VIsual_active) | |
1172 { | |
1173 end_visual_mode(); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1174 redraw_curbuf_later(UPD_INVERTED); // delete the inversion later |
7 | 1175 } |
1176 VIsual_reselect = FALSE; | |
1177 } | |
1178 | |
1179 /* | |
1180 * Reset VIsual_active and VIsual_reselect if it's set. | |
1181 */ | |
1182 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1183 reset_VIsual(void) |
7 | 1184 { |
1185 if (VIsual_active) | |
1186 { | |
1187 end_visual_mode(); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1188 redraw_curbuf_later(UPD_INVERTED); // delete the inversion later |
7 | 1189 VIsual_reselect = FALSE; |
1190 } | |
1191 } | |
1192 | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1193 void |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1194 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
|
1195 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1196 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
|
1197 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1198 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
|
1199 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
|
1200 } |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1201 } |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1202 |
7 | 1203 /* |
1204 * Check for a balloon-eval special item to include when searching for an | |
1205 * identifier. When "dir" is BACKWARD "ptr[-1]" must be valid! | |
1206 * Returns TRUE if the character at "*ptr" should be included. | |
1207 * "dir" is FORWARD or BACKWARD, the direction of searching. | |
1208 * "*colp" is in/decremented if "ptr[-dir]" should also be included. | |
1209 * "bnp" points to a counter for square brackets. | |
1210 */ | |
1211 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1212 find_is_eval_item( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1213 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1214 int *colp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1215 int *bnp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1216 int dir) |
7 | 1217 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1218 // Accept everything inside []. |
7 | 1219 if ((*ptr == ']' && dir == BACKWARD) || (*ptr == '[' && dir == FORWARD)) |
1220 ++*bnp; | |
1221 if (*bnp > 0) | |
1222 { | |
1223 if ((*ptr == '[' && dir == BACKWARD) || (*ptr == ']' && dir == FORWARD)) | |
1224 --*bnp; | |
1225 return TRUE; | |
1226 } | |
1227 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1228 // skip over "s.var" |
7 | 1229 if (*ptr == '.') |
1230 return TRUE; | |
1231 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1232 // two-character item: s->var |
7 | 1233 if (ptr[dir == BACKWARD ? 0 : 1] == '>' |
1234 && ptr[dir == BACKWARD ? -1 : 0] == '-') | |
1235 { | |
1236 *colp += dir; | |
1237 return TRUE; | |
1238 } | |
1239 return FALSE; | |
1240 } | |
1241 | |
1242 /* | |
1243 * Find the identifier under or to the right of the cursor. | |
1244 * "find_type" can have one of three values: | |
1245 * 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
|
1246 * 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
|
1247 * FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred. |
184 | 1248 * FIND_EVAL: find text useful for C program debugging |
7 | 1249 * |
1250 * 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
|
1251 * 1. Search forward for the start of an identifier/text. Doesn't move if |
7 | 1252 * 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
|
1253 * 2. Search backward for the start of this identifier/text. |
7 | 1254 * This doesn't match the real Vi but I like it a little better and it |
1255 * 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
|
1256 * 3. Search forward to the end of this identifier/text. |
7 | 1257 * When FIND_IDENT isn't defined, we backup until a blank. |
1258 * | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1259 * 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
|
1260 * 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
|
1261 * points into the current buffer line and is not always NUL terminated. |
7 | 1262 */ |
1263 int | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1264 find_ident_under_cursor(char_u **text, int find_type) |
7 | 1265 { |
1266 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
|
1267 curwin->w_cursor.col, text, NULL, find_type); |
7 | 1268 } |
1269 | |
1270 /* | |
1271 * Like find_ident_under_cursor(), but for any window and any position. | |
1272 * However: Uses 'iskeyword' from the current window!. | |
1273 */ | |
1274 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1275 find_ident_at_pos( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1276 win_T *wp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1277 linenr_T lnum, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1278 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
|
1279 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
|
1280 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
|
1281 int find_type) |
7 | 1282 { |
1283 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
|
1284 int col = 0; // init to shut up GCC |
7 | 1285 int i; |
1286 int this_class = 0; | |
1287 int prev_class; | |
1288 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
|
1289 int bn = 0; // bracket nesting |
7 | 1290 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1291 // 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
|
1292 // if i == 1: try to find any non-white text |
7 | 1293 ptr = ml_get_buf(wp->w_buffer, lnum, FALSE); |
1294 for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i) | |
1295 { | |
1296 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1297 * 1. skip to start of identifier/text |
7 | 1298 */ |
1299 col = startcol; | |
1300 if (has_mbyte) | |
1301 { | |
1302 while (ptr[col] != NUL) | |
1303 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1304 // Stop at a ']' to evaluate "a[x]". |
7 | 1305 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1306 break; | |
1307 this_class = mb_get_class(ptr + col); | |
1308 if (this_class != 0 && (i == 1 || this_class != 1)) | |
1309 break; | |
474 | 1310 col += (*mb_ptr2len)(ptr + col); |
7 | 1311 } |
1312 } | |
1313 else | |
1314 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
|
1315 && (i == 0 ? !vim_iswordc(ptr[col]) : VIM_ISWHITE(ptr[col])) |
7 | 1316 && (!(find_type & FIND_EVAL) || ptr[col] != ']') |
1317 ) | |
1318 ++col; | |
1319 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1320 // When starting on a ']' count it, so that we include the '['. |
7 | 1321 bn = ptr[col] == ']'; |
1322 | |
1323 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1324 * 2. Back up to start of identifier/text. |
7 | 1325 */ |
1326 if (has_mbyte) | |
1327 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1328 // Remember class of character under cursor. |
7 | 1329 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1330 this_class = mb_get_class((char_u *)"a"); | |
1331 else | |
1332 this_class = mb_get_class(ptr + col); | |
835 | 1333 while (col > 0 && this_class != 0) |
7 | 1334 { |
1335 prevcol = col - 1 - (*mb_head_off)(ptr, ptr + col - 1); | |
1336 prev_class = mb_get_class(ptr + prevcol); | |
1337 if (this_class != prev_class | |
1338 && (i == 0 | |
1339 || prev_class == 0 | |
1340 || (find_type & FIND_IDENT)) | |
1341 && (!(find_type & FIND_EVAL) | |
1342 || prevcol == 0 | |
1343 || !find_is_eval_item(ptr + prevcol, &prevcol, | |
1344 &bn, BACKWARD)) | |
1345 ) | |
1346 break; | |
1347 col = prevcol; | |
1348 } | |
1349 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1350 // 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
|
1351 // identifier, stop searching. |
7 | 1352 if (this_class > 2) |
1353 this_class = 2; | |
1354 if (!(find_type & FIND_STRING) || this_class == 2) | |
1355 break; | |
1356 } | |
1357 else | |
1358 { | |
1359 while (col > 0 | |
1360 && ((i == 0 | |
1361 ? 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
|
1362 : (!VIM_ISWHITE(ptr[col - 1]) |
7 | 1363 && (!(find_type & FIND_IDENT) |
1364 || !vim_iswordc(ptr[col - 1])))) | |
1365 || ((find_type & FIND_EVAL) | |
1366 && col > 1 | |
1367 && find_is_eval_item(ptr + col - 1, &col, | |
1368 &bn, BACKWARD)) | |
1369 )) | |
1370 --col; | |
1371 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1372 // 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
|
1373 // identifier, stop searching. |
7 | 1374 if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col])) |
1375 break; | |
1376 } | |
1377 } | |
1378 | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1379 if (ptr[col] == NUL || (i == 0 |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1380 && (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col])))) |
7 | 1381 { |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1382 // 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
|
1383 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
|
1384 { |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1385 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
|
1386 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
|
1387 else |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
1388 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
|
1389 } |
7 | 1390 return 0; |
1391 } | |
1392 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
|
1393 *text = ptr; |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1394 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
|
1395 *textcol = col; |
7 | 1396 |
1397 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1398 * 3. Find the end if the identifier/text. |
7 | 1399 */ |
1400 bn = 0; | |
1401 startcol -= col; | |
1402 col = 0; | |
1403 if (has_mbyte) | |
1404 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1405 // Search for point of changing multibyte character class. |
7 | 1406 this_class = mb_get_class(ptr); |
1407 while (ptr[col] != NUL | |
1408 && ((i == 0 ? mb_get_class(ptr + col) == this_class | |
1409 : mb_get_class(ptr + col) != 0) | |
1410 || ((find_type & FIND_EVAL) | |
1411 && col <= (int)startcol | |
1412 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1413 )) | |
474 | 1414 col += (*mb_ptr2len)(ptr + col); |
7 | 1415 } |
1416 else | |
1417 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
|
1418 : (ptr[col] != NUL && !VIM_ISWHITE(ptr[col]))) |
7 | 1419 || ((find_type & FIND_EVAL) |
1420 && col <= (int)startcol | |
1421 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1422 ) | |
1423 ++col; | |
1424 | |
1425 return col; | |
1426 } | |
1427 | |
1428 /* | |
1429 * Prepare for redo of a normal command. | |
1430 */ | |
1431 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1432 prep_redo_cmd(cmdarg_T *cap) |
7 | 1433 { |
1434 prep_redo(cap->oap->regname, cap->count0, | |
1435 NUL, cap->cmdchar, NUL, NUL, cap->nchar); | |
1436 } | |
1437 | |
1438 /* | |
1439 * Prepare for redo of any command. | |
1440 * Note that only the last argument can be a multi-byte char. | |
1441 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1442 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1443 prep_redo( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1444 int regname, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1445 long num, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1446 int cmd1, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1447 int cmd2, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1448 int cmd3, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1449 int cmd4, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1450 int cmd5) |
7 | 1451 { |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1452 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
|
1453 } |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1454 |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1455 /* |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1456 * 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
|
1457 */ |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1458 void |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1459 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
|
1460 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
|
1461 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
|
1462 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
|
1463 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
|
1464 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
|
1465 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
|
1466 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
|
1467 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
|
1468 { |
7 | 1469 ResetRedobuff(); |
30102
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1470 |
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1471 #ifdef FEAT_EVAL |
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1472 // Put info about a mapping in the redo buffer, so that "." will use the |
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1473 // same script context. |
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1474 may_add_last_used_map_to_redobuff(); |
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1475 #endif |
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1476 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1477 if (regname != 0) // yank from specified buffer |
7 | 1478 { |
1479 AppendCharToRedobuff('"'); | |
1480 AppendCharToRedobuff(regname); | |
1481 } | |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1482 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
|
1483 AppendNumberToRedobuff(num1); |
7 | 1484 if (cmd1 != NUL) |
1485 AppendCharToRedobuff(cmd1); | |
1486 if (cmd2 != NUL) | |
1487 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
|
1488 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
|
1489 AppendNumberToRedobuff(num2); |
7 | 1490 if (cmd3 != NUL) |
1491 AppendCharToRedobuff(cmd3); | |
1492 if (cmd4 != NUL) | |
1493 AppendCharToRedobuff(cmd4); | |
1494 if (cmd5 != NUL) | |
1495 AppendCharToRedobuff(cmd5); | |
1496 } | |
1497 | |
1498 /* | |
1499 * check for operator active and clear it | |
1500 * | |
1501 * return TRUE if operator was active | |
1502 */ | |
1503 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1504 checkclearop(oparg_T *oap) |
7 | 1505 { |
1506 if (oap->op_type == OP_NOP) | |
1507 return FALSE; | |
1508 clearopbeep(oap); | |
1509 return TRUE; | |
1510 } | |
1511 | |
1512 /* | |
1131 | 1513 * Check for operator or Visual active. Clear active operator. |
7 | 1514 * |
1131 | 1515 * Return TRUE if operator or Visual was active. |
7 | 1516 */ |
1517 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1518 checkclearopq(oparg_T *oap) |
7 | 1519 { |
5735 | 1520 if (oap->op_type == OP_NOP && !VIsual_active) |
7 | 1521 return FALSE; |
1522 clearopbeep(oap); | |
1523 return TRUE; | |
1524 } | |
1525 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1526 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1527 clearop(oparg_T *oap) |
7 | 1528 { |
1529 oap->op_type = OP_NOP; | |
1530 oap->regname = 0; | |
1531 oap->motion_force = NUL; | |
1532 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
|
1533 motion_force = NUL; |
7 | 1534 } |
1535 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1536 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1537 clearopbeep(oparg_T *oap) |
7 | 1538 { |
1539 clearop(oap); | |
1540 beep_flush(); | |
1541 } | |
1542 | |
1543 /* | |
1544 * Remove the shift modifier from a special key. | |
1545 */ | |
1546 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1547 unshift_special(cmdarg_T *cap) |
7 | 1548 { |
1549 switch (cap->cmdchar) | |
1550 { | |
1551 case K_S_RIGHT: cap->cmdchar = K_RIGHT; break; | |
1552 case K_S_LEFT: cap->cmdchar = K_LEFT; break; | |
1553 case K_S_UP: cap->cmdchar = K_UP; break; | |
1554 case K_S_DOWN: cap->cmdchar = K_DOWN; break; | |
1555 case K_S_HOME: cap->cmdchar = K_HOME; break; | |
1556 case K_S_END: cap->cmdchar = K_END; break; | |
1557 } | |
1558 cap->cmdchar = simplify_key(cap->cmdchar, &mod_mask); | |
1559 } | |
1560 | |
6979 | 1561 /* |
1562 * If the mode is currently displayed clear the command line or update the | |
1563 * command displayed. | |
1564 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1565 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1566 may_clear_cmdline(void) |
6979 | 1567 { |
1568 if (mode_displayed) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1569 clear_cmdline = TRUE; // unshow visual mode later |
6979 | 1570 else |
1571 clear_showcmd(); | |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1572 } |
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1573 |
7 | 1574 /* |
1575 * Routines for displaying a partly typed command | |
1576 */ | |
1577 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1578 static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd() |
7 | 1579 static int showcmd_is_clear = TRUE; |
1580 static int showcmd_visual = FALSE; | |
1581 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
1582 static void display_showcmd(void); |
7 | 1583 |
1584 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1585 clear_showcmd(void) |
7 | 1586 { |
1587 if (!p_sc) | |
1588 return; | |
1589 | |
1590 if (VIsual_active && !char_avail()) | |
1591 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
1592 int cursor_bot = LT_POS(VIsual, curwin->w_cursor); |
7 | 1593 long lines; |
1594 colnr_T leftcol, rightcol; | |
1595 linenr_T top, bot; | |
1596 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1597 // Show the size of the Visual area. |
1866 | 1598 if (cursor_bot) |
7 | 1599 { |
1600 top = VIsual.lnum; | |
1601 bot = curwin->w_cursor.lnum; | |
1602 } | |
1603 else | |
1604 { | |
1605 top = curwin->w_cursor.lnum; | |
1606 bot = VIsual.lnum; | |
1607 } | |
1608 # ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1609 // Include closed folds as a whole. |
7009 | 1610 (void)hasFolding(top, &top, NULL); |
1611 (void)hasFolding(bot, NULL, &bot); | |
7 | 1612 # endif |
1613 lines = bot - top + 1; | |
1614 | |
1615 if (VIsual_mode == Ctrl_V) | |
1616 { | |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1617 # ifdef FEAT_LINEBREAK |
1866 | 1618 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
|
1619 char_u *saved_w_sbr = curwin->w_p_sbr; |
1866 | 1620 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1621 // Make 'sbr' empty for a moment to get the correct size. |
1866 | 1622 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
|
1623 curwin->w_p_sbr = empty_option; |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1624 # endif |
7 | 1625 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
|
1626 # ifdef FEAT_LINEBREAK |
1866 | 1627 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
|
1628 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
|
1629 # endif |
7 | 1630 sprintf((char *)showcmd_buf, "%ldx%ld", lines, |
1631 (long)(rightcol - leftcol + 1)); | |
1632 } | |
1633 else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) | |
1634 sprintf((char *)showcmd_buf, "%ld", lines); | |
1635 else | |
2324
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 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
|
1638 int l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1639 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
|
1640 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
|
1641 |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1642 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
|
1643 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1644 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
|
1645 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
|
1646 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1647 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1648 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1649 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
|
1650 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
|
1651 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1652 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
|
1653 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1654 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
|
1655 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
|
1656 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1657 ++bytes; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1658 ++chars; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1659 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
|
1660 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1661 bytes += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1662 ++chars; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1663 s += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1664 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1665 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
|
1666 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
|
1667 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1668 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
|
1669 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1670 showcmd_buf[SHOWCMD_COLS] = NUL; // truncate |
7 | 1671 showcmd_visual = TRUE; |
1672 } | |
1673 else | |
1674 { | |
1675 showcmd_buf[0] = NUL; | |
1676 showcmd_visual = FALSE; | |
1677 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1678 // Don't actually display something if there is nothing to clear. |
7 | 1679 if (showcmd_is_clear) |
1680 return; | |
1681 } | |
1682 | |
1683 display_showcmd(); | |
1684 } | |
1685 | |
1686 /* | |
1687 * Add 'c' to string of shown command chars. | |
1688 * Return TRUE if output has been written (and setcursor() has been called). | |
1689 */ | |
1690 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1691 add_to_showcmd(int c) |
7 | 1692 { |
1693 char_u *p; | |
1694 int old_len; | |
1695 int extra_len; | |
1696 int overflow; | |
1697 int i; | |
1698 static int ignore[] = | |
1699 { | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18291
diff
changeset
|
1700 #ifdef FEAT_GUI |
7 | 1701 K_VER_SCROLLBAR, K_HOR_SCROLLBAR, |
1702 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
|
1703 #endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
1704 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
|
1705 K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE, |
7 | 1706 K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE, |
1707 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
|
1708 K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT, |
7 | 1709 K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE, |
631 | 1710 K_CURSORHOLD, |
7 | 1711 0 |
1712 }; | |
1713 | |
641 | 1714 if (!p_sc || msg_silent != 0) |
7 | 1715 return FALSE; |
1716 | |
1717 if (showcmd_visual) | |
1718 { | |
1719 showcmd_buf[0] = NUL; | |
1720 showcmd_visual = FALSE; | |
1721 } | |
1722 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1723 // Ignore keys that are scrollbar updates and mouse clicks |
7 | 1724 if (IS_SPECIAL(c)) |
1725 for (i = 0; ignore[i] != 0; ++i) | |
1726 if (ignore[i] == c) | |
1727 return FALSE; | |
1728 | |
1729 p = transchar(c); | |
5535 | 1730 if (*p == ' ') |
1731 STRCPY(p, "<20>"); | |
7 | 1732 old_len = (int)STRLEN(showcmd_buf); |
1733 extra_len = (int)STRLEN(p); | |
1734 overflow = old_len + extra_len - SHOWCMD_COLS; | |
1735 if (overflow > 0) | |
1362 | 1736 mch_memmove(showcmd_buf, showcmd_buf + overflow, |
1737 old_len - overflow + 1); | |
7 | 1738 STRCAT(showcmd_buf, p); |
1739 | |
1740 if (char_avail()) | |
1741 return FALSE; | |
1742 | |
1743 display_showcmd(); | |
1744 | |
1745 return TRUE; | |
1746 } | |
1747 | |
1748 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1749 add_to_showcmd_c(int c) |
7 | 1750 { |
1751 if (!add_to_showcmd(c)) | |
1752 setcursor(); | |
1753 } | |
1754 | |
1755 /* | |
1756 * Delete 'len' characters from the end of the shown command. | |
1757 */ | |
1758 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1759 del_from_showcmd(int len) |
7 | 1760 { |
1761 int old_len; | |
1762 | |
1763 if (!p_sc) | |
1764 return; | |
1765 | |
1766 old_len = (int)STRLEN(showcmd_buf); | |
1767 if (len > old_len) | |
1768 len = old_len; | |
1769 showcmd_buf[old_len - len] = NUL; | |
1770 | |
1771 if (!char_avail()) | |
1772 display_showcmd(); | |
1773 } | |
1774 | |
1775 /* | |
1776 * push_showcmd() and pop_showcmd() are used when waiting for the user to type | |
1777 * something and there is a partial mapping. | |
1778 */ | |
1779 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1780 push_showcmd(void) |
7 | 1781 { |
1782 if (p_sc) | |
1783 STRCPY(old_showcmd_buf, showcmd_buf); | |
1784 } | |
1785 | |
1786 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1787 pop_showcmd(void) |
7 | 1788 { |
1789 if (!p_sc) | |
1790 return; | |
1791 | |
1792 STRCPY(showcmd_buf, old_showcmd_buf); | |
1793 | |
1794 display_showcmd(); | |
1795 } | |
1796 | |
1797 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1798 display_showcmd(void) |
7 | 1799 { |
31457
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1800 int len = (int)STRLEN(showcmd_buf); |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1801 |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1802 showcmd_is_clear = (len == 0); |
7 | 1803 cursor_off(); |
1804 | |
31457
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1805 if (*p_sloc == 's') |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1806 win_redr_status(curwin, FALSE); |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1807 else if (*p_sloc == 't') |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1808 draw_tabline(); |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1809 else // 'showcmdloc' is "last" or empty |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1810 { |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1811 if (!showcmd_is_clear) |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1812 screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0); |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1813 |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1814 // clear the rest of an old message by outputting up to SHOWCMD_COLS |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1815 // spaces |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1816 screen_puts((char_u *)" " + len, |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1817 (int)Rows - 1, sc_col + len, 0); |
bb797331e21b
patch 9.0.1061: cannot display 'showcmd' somewhere else
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1818 } |
7 | 1819 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1820 setcursor(); // put cursor back where it belongs |
7 | 1821 } |
1822 | |
1823 /* | |
1824 * When "check" is FALSE, prepare for commands that scroll the window. | |
1825 * When "check" is TRUE, take care of scroll-binding after the window has | |
1826 * scrolled. Called from normal_cmd() and edit(). | |
1827 */ | |
1828 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1829 do_check_scrollbind(int check) |
7 | 1830 { |
1831 static win_T *old_curwin = NULL; | |
1832 static linenr_T old_topline = 0; | |
1833 #ifdef FEAT_DIFF | |
1834 static int old_topfill = 0; | |
1835 #endif | |
1836 static buf_T *old_buf = NULL; | |
1837 static colnr_T old_leftcol = 0; | |
1838 | |
1839 if (check && curwin->w_p_scb) | |
1840 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1841 // 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
|
1842 // the values. |
7 | 1843 if (did_syncbind) |
1844 did_syncbind = FALSE; | |
1845 else if (curwin == old_curwin) | |
1846 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1847 // 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
|
1848 // '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
|
1849 // when 'diff' is set. |
7 | 1850 if ((curwin->w_buffer == old_buf |
1851 #ifdef FEAT_DIFF | |
1852 || curwin->w_p_diff | |
1853 #endif | |
1854 ) | |
1855 && (curwin->w_topline != old_topline | |
1856 #ifdef FEAT_DIFF | |
1857 || curwin->w_topfill != old_topfill | |
1858 #endif | |
1859 || curwin->w_leftcol != old_leftcol)) | |
1860 { | |
1861 check_scrollbind(curwin->w_topline - old_topline, | |
1862 (long)(curwin->w_leftcol - old_leftcol)); | |
1863 } | |
1864 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1865 else if (vim_strchr(p_sbo, 'j')) // jump flag set in 'scrollopt' |
7 | 1866 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1867 // 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
|
1868 // 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
|
1869 // 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
|
1870 // 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
|
1871 // 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
|
1872 // 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
|
1873 // 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
|
1874 // visible on-screen. |
7 | 1875 check_scrollbind(curwin->w_topline - curwin->w_scbind_pos, 0L); |
1876 } | |
1877 curwin->w_scbind_pos = curwin->w_topline; | |
1878 } | |
1879 | |
1880 old_curwin = curwin; | |
1881 old_topline = curwin->w_topline; | |
1882 #ifdef FEAT_DIFF | |
1883 old_topfill = curwin->w_topfill; | |
1884 #endif | |
1885 old_buf = curwin->w_buffer; | |
1886 old_leftcol = curwin->w_leftcol; | |
1887 } | |
1888 | |
1889 /* | |
1890 * Synchronize any windows that have "scrollbind" set, based on the | |
1891 * number of rows by which the current window has changed | |
1892 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
1893 */ | |
1894 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1895 check_scrollbind(linenr_T topline_diff, long leftcol_diff) |
7 | 1896 { |
1897 int want_ver; | |
1898 int want_hor; | |
1899 win_T *old_curwin = curwin; | |
1900 buf_T *old_curbuf = curbuf; | |
1901 int old_VIsual_select = VIsual_select; | |
1902 int old_VIsual_active = VIsual_active; | |
1903 colnr_T tgt_leftcol = curwin->w_leftcol; | |
1904 long topline; | |
1905 long y; | |
1906 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1907 // check 'scrollopt' string for vertical and horizontal scroll options |
7 | 1908 want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0); |
1909 #ifdef FEAT_DIFF | |
1910 want_ver |= old_curwin->w_p_diff; | |
1911 #endif | |
1912 want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0)); | |
1913 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1914 // loop through the scrollbound windows and scroll accordingly |
7 | 1915 VIsual_select = VIsual_active = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
1916 FOR_ALL_WINDOWS(curwin) |
7 | 1917 { |
1918 curbuf = curwin->w_buffer; | |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1919 // skip original window and windows with 'noscrollbind' |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1920 if (curwin == old_curwin || !curwin->w_p_scb) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1921 continue; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1922 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1923 // do the vertical scroll |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1924 if (want_ver) |
7 | 1925 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1926 #ifdef FEAT_DIFF |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1927 if (old_curwin->w_p_diff && curwin->w_p_diff) |
7 | 1928 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1929 diff_set_topline(old_curwin, curwin); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1930 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1931 else |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1932 #endif |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1933 { |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1934 curwin->w_scbind_pos += topline_diff; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1935 topline = curwin->w_scbind_pos; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1936 if (topline > curbuf->b_ml.ml_line_count) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1937 topline = curbuf->b_ml.ml_line_count; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1938 if (topline < 1) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1939 topline = 1; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1940 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1941 y = topline - curwin->w_topline; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1942 if (y > 0) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1943 scrollup(y, FALSE); |
7 | 1944 else |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1945 scrolldown(-y, FALSE); |
7 | 1946 } |
1947 | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1948 redraw_later(UPD_VALID); |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1949 cursor_correct(); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1950 curwin->w_redr_status = TRUE; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1951 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1952 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1953 // do the horizontal scroll |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
1954 if (want_hor) |
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
1955 (void)set_leftcol(tgt_leftcol); |
7 | 1956 } |
1957 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1958 // reset current-window |
7 | 1959 VIsual_select = old_VIsual_select; |
1960 VIsual_active = old_VIsual_active; | |
1961 curwin = old_curwin; | |
1962 curbuf = old_curbuf; | |
1963 } | |
1964 | |
1965 /* | |
1966 * Command character that's ignored. | |
1967 * 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
|
1968 * xon/xoff. |
7 | 1969 */ |
1970 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1971 nv_ignore(cmdarg_T *cap) |
7 | 1972 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1973 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
7 | 1974 } |
1975 | |
1976 /* | |
620 | 1977 * Command character that doesn't do anything, but unlike nv_ignore() does |
1978 * start edit(). Used for "startinsert" executed while starting up. | |
1979 */ | |
1980 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1981 nv_nop(cmdarg_T *cap UNUSED) |
620 | 1982 { |
1983 } | |
1984 | |
1985 /* | |
7 | 1986 * Command character doesn't exist. |
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_error(cmdarg_T *cap) |
7 | 1990 { |
1991 clearopbeep(cap->oap); | |
1992 } | |
1993 | |
1994 /* | |
1995 * <Help> and <F1> commands. | |
1996 */ | |
1997 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1998 nv_help(cmdarg_T *cap) |
7 | 1999 { |
2000 if (!checkclearopq(cap->oap)) | |
2001 ex_help(NULL); | |
2002 } | |
2003 | |
2004 /* | |
2005 * CTRL-A and CTRL-X: Add or subtract from letter or number under cursor. | |
2006 */ | |
2007 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2008 nv_addsub(cmdarg_T *cap) |
7 | 2009 { |
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
|
2010 #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
|
2011 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
|
2012 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
|
2013 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
|
2014 #endif |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2015 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
|
2016 { |
7578
fdae4c496775
commit https://github.com/vim/vim/commit/ef2b5036b3005f1ce15d146dce72379a9834c56d
Christian Brabandt <cb@256bit.org>
parents:
7574
diff
changeset
|
2017 prep_redo_cmd(cap); |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2018 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
|
2019 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
|
2020 cap->oap->op_type = OP_NOP; |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2021 } |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2022 else if (VIsual_active) |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2023 nv_operator(cap); |
6868 | 2024 else |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2025 clearop(cap->oap); |
7 | 2026 } |
2027 | |
2028 /* | |
2029 * CTRL-F, CTRL-B, etc: Scroll page up or down. | |
2030 */ | |
2031 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2032 nv_page(cmdarg_T *cap) |
7 | 2033 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2034 if (checkclearop(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2035 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2036 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2037 if (mod_mask & MOD_MASK_CTRL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2038 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2039 // <C-PageUp>: tab page back; <C-PageDown>: tab page forward |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2040 if (cap->arg == BACKWARD) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2041 goto_tabpage(-(int)cap->count1); |
819 | 2042 else |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2043 goto_tabpage((int)cap->count0); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2044 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2045 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2046 (void)onepage(cap->arg, cap->count1); |
7 | 2047 } |
2048 | |
2049 /* | |
2050 * Implementation of "gd" and "gD" command. | |
2051 */ | |
2052 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2053 nv_gd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2054 oparg_T *oap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2055 int nchar, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2056 int thisblock) // 1 for "1gd" and "1gD" |
7 | 2057 { |
2058 int len; | |
503 | 2059 char_u *ptr; |
2060 | |
2061 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
|
2062 || 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
|
2063 == 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
|
2064 { |
503 | 2065 clearopbeep(oap); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2066 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2067 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2068 |
503 | 2069 #ifdef FEAT_FOLDING |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2070 if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2071 foldOpenCursor(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2072 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2073 // clear any search statistics |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2074 if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
2075 clear_cmdline = TRUE; |
503 | 2076 } |
2077 | |
2078 /* | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2079 * 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
|
2080 * otherwise. |
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 static int |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2083 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
|
2084 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2085 int i; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2086 int incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2087 int instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2088 int prev = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2089 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2090 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
|
2091 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2092 if (instring != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2093 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2094 if (prev != '\\' && line[i] == instring) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2095 instring = 0; |
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 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
|
2098 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2099 instring = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2100 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2101 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2102 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2103 if (incomment) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2104 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2105 if (prev == '*' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2106 incomment = 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 else if (prev == '/' && line[i] == '*') |
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 incomment = TRUE; |
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 else if (prev == '/' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2113 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2114 return FALSE; |
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 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2117 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2118 prev = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2119 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2120 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2121 return incomment == FALSE && instring == 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2122 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2123 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2124 /* |
523 | 2125 * Search for variable declaration of "ptr[len]". |
2126 * When "locally" is TRUE in the current function ("gd"), otherwise in the | |
2127 * current file ("gD"). | |
2128 * When "thisblock" is TRUE check the {} block scope. | |
503 | 2129 * Return FAIL when not found. |
2130 */ | |
2131 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2132 find_decl( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2133 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2134 int len, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2135 int locally, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2136 int thisblock, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2137 int flags_arg) // flags passed to searchit() |
503 | 2138 { |
7 | 2139 char_u *pat; |
2140 pos_T old_pos; | |
503 | 2141 pos_T par_pos; |
2142 pos_T found_pos; | |
7 | 2143 int t; |
2144 int save_p_ws; | |
2145 int save_p_scs; | |
503 | 2146 int retval = OK; |
944 | 2147 int incll; |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2148 int searchflags = flags_arg; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2149 int valid; |
503 | 2150 |
2151 if ((pat = alloc(len + 7)) == NULL) | |
2152 return FAIL; | |
268 | 2153 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2154 // 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
|
2155 // and "~" causes trouble. |
268 | 2156 sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", |
2157 len, ptr); | |
7 | 2158 old_pos = curwin->w_cursor; |
2159 save_p_ws = p_ws; | |
2160 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
|
2161 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
|
2162 p_scs = FALSE; // don't switch ignorecase off now |
7 | 2163 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2164 // 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
|
2165 // 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
|
2166 // back until a blank line. If this fails go to line 1. |
944 | 2167 if (!locally || !findpar(&incll, BACKWARD, 1L, '{', FALSE)) |
7 | 2168 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2169 setpcmark(); // Set in findpar() otherwise |
7 | 2170 curwin->w_cursor.lnum = 1; |
539 | 2171 par_pos = curwin->w_cursor; |
7 | 2172 } |
2173 else | |
2174 { | |
539 | 2175 par_pos = curwin->w_cursor; |
7 | 2176 while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL) |
2177 --curwin->w_cursor.lnum; | |
2178 } | |
2179 curwin->w_cursor.col = 0; | |
2180 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2181 // 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
|
2182 CLEAR_POS(&found_pos); |
503 | 2183 for (;;) |
2184 { | |
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
|
2185 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
|
2186 pat, 1L, searchflags, RE_LAST, NULL); |
503 | 2187 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
|
2188 t = FAIL; // match after start is failure too |
523 | 2189 |
718 | 2190 if (thisblock && t != FAIL) |
523 | 2191 { |
2192 pos_T *pos; | |
2193 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2194 // 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
|
2195 // position where we started the search from. |
523 | 2196 if ((pos = findmatchlimit(NULL, '}', FM_FORWARD, |
2197 (int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL | |
2198 && pos->lnum < old_pos.lnum) | |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2199 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2200 // 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
|
2201 // Skip to the end. |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2202 curwin->w_cursor = *pos; |
523 | 2203 continue; |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2204 } |
523 | 2205 } |
2206 | |
503 | 2207 if (t == FAIL) |
2208 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2209 // If we previously found a valid position, use it. |
503 | 2210 if (found_pos.lnum != 0) |
2211 { | |
2212 curwin->w_cursor = found_pos; | |
2213 t = OK; | |
2214 } | |
2215 break; | |
2216 } | |
3562 | 2217 if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0) |
503 | 2218 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2219 // Ignore this line, continue at start of next line. |
503 | 2220 ++curwin->w_cursor.lnum; |
2221 curwin->w_cursor.col = 0; | |
2222 continue; | |
2223 } | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2224 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
|
2225 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2226 // 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
|
2227 // 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
|
2228 if (!valid && found_pos.lnum != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2229 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2230 curwin->w_cursor = found_pos; |
503 | 2231 break; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2232 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2233 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2234 // 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
|
2235 if (valid && !locally) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2236 break; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2237 if (valid && curwin->w_cursor.lnum >= par_pos.lnum) |
503 | 2238 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2239 // If we previously found a valid position, use it. |
503 | 2240 if (found_pos.lnum != 0) |
2241 curwin->w_cursor = found_pos; | |
2242 break; | |
2243 } | |
2244 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2245 // 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
|
2246 // 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
|
2247 // 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
|
2248 if (!valid) |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
2249 CLEAR_POS(&found_pos); |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2250 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2251 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
|
2252 // 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
|
2253 // position. |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2254 searchflags &= ~SEARCH_START; |
503 | 2255 } |
2256 | |
2257 if (t == FAIL) | |
2258 { | |
2259 retval = FAIL; | |
7 | 2260 curwin->w_cursor = old_pos; |
2261 } | |
2262 else | |
2263 { | |
2264 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
|
2265 // "n" searches forward now |
7 | 2266 reset_search_dir(); |
2267 } | |
2268 | |
2269 vim_free(pat); | |
2270 p_ws = save_p_ws; | |
2271 p_scs = save_p_scs; | |
503 | 2272 |
2273 return retval; | |
7 | 2274 } |
2275 | |
2276 /* | |
2277 * Move 'dist' lines in direction 'dir', counting lines by *screen* | |
2278 * lines rather than lines in the file. | |
2279 * 'dist' must be positive. | |
2280 * | |
2281 * Return OK if able to move cursor, FAIL otherwise. | |
2282 */ | |
2283 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2284 nv_screengo(oparg_T *oap, int dir, long dist) |
7 | 2285 { |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
2286 int linelen = linetabsize_str(ml_get_curline()); |
7 | 2287 int retval = OK; |
2288 int atend = FALSE; | |
2289 int n; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2290 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
|
2291 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
|
2292 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
|
2293 int width2; // text width for wrapped screen line |
7 | 2294 |
2295 oap->motion_type = MCHAR; | |
5192
c28202427d71
updated for version 7.4a.022
Bram Moolenaar <bram@vim.org>
parents:
5162
diff
changeset
|
2296 oap->inclusive = (curwin->w_curswant == MAXCOL); |
7 | 2297 |
2298 col_off1 = curwin_col_off(); | |
2299 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
|
2300 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
|
2301 width2 = curwin->w_width - col_off2; |
6559 | 2302 if (width2 == 0) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2303 width2 = 1; // avoid divide by zero |
7 | 2304 |
2305 if (curwin->w_width != 0) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2306 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2307 // 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
|
2308 // try to stick in the last column of the screen. |
7 | 2309 if (curwin->w_curswant == MAXCOL) |
2310 { | |
2311 atend = TRUE; | |
2312 validate_virtcol(); | |
2313 if (width1 <= 0) | |
2314 curwin->w_curswant = 0; | |
2315 else | |
2316 { | |
2317 curwin->w_curswant = width1 - 1; | |
2318 if (curwin->w_virtcol > curwin->w_curswant) | |
2319 curwin->w_curswant += ((curwin->w_virtcol | |
2320 - curwin->w_curswant - 1) / width2 + 1) * width2; | |
2321 } | |
2322 } | |
2323 else | |
2324 { | |
2325 if (linelen > width1) | |
2326 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2327 else | |
2328 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
|
2329 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
|
2330 curwin->w_curswant = n - 1; |
7 | 2331 } |
2332 | |
2333 while (dist--) | |
2334 { | |
2335 if (dir == BACKWARD) | |
2336 { | |
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
|
2337 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
|
2338 #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
|
2339 && !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
|
2340 #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
|
2341 ) |
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
|
2342 // 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
|
2343 // 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
|
2344 // which will get clipped to column 0. |
7 | 2345 curwin->w_curswant -= width2; |
2346 else | |
2347 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2348 // to previous line |
31984
479c93ad4a3b
patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
31954
diff
changeset
|
2349 if (!cursor_up_inner(curwin, 1)) |
7 | 2350 { |
2351 retval = FAIL; | |
2352 break; | |
2353 } | |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
2354 linelen = linetabsize_str(ml_get_curline()); |
7 | 2355 if (linelen > width1) |
2356 curwin->w_curswant += (((linelen - width1 - 1) / width2) | |
2357 + 1) * width2; | |
2358 } | |
2359 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2360 else // dir == FORWARD |
7 | 2361 { |
2362 if (linelen > width1) | |
2363 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2364 else | |
2365 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
|
2366 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
|
2367 #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
|
2368 && !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
|
2369 #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
|
2370 ) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2371 // move forward within line |
7 | 2372 curwin->w_curswant += width2; |
2373 else | |
2374 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2375 // to next line |
31984
479c93ad4a3b
patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
31954
diff
changeset
|
2376 if (!cursor_down_inner(curwin, 1)) |
7 | 2377 { |
2378 retval = FAIL; | |
2379 break; | |
2380 } | |
2381 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
|
2382 // 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
|
2383 // 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
|
2384 // 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
|
2385 // 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
|
2386 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
|
2387 curwin->w_curswant -= width2; |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
2388 linelen = linetabsize_str(ml_get_curline()); |
7 | 2389 } |
2390 } | |
2391 } | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2392 } |
7 | 2393 |
5600 | 2394 if (virtual_active() && atend) |
2395 coladvance(MAXCOL); | |
2396 else | |
2397 coladvance(curwin->w_curswant); | |
7 | 2398 |
2399 if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) | |
2400 { | |
6178 | 2401 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
|
2402 int c; |
6178 | 2403 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2404 // 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
|
2405 // 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
|
2406 // screenline or move two screenlines. |
7 | 2407 validate_virtcol(); |
6178 | 2408 virtcol = curwin->w_virtcol; |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2409 #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
|
2410 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
|
2411 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
|
2412 #endif |
6178 | 2413 |
26094
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2414 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
|
2415 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
|
2416 && (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
|
2417 && !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
|
2418 oneright(); |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2419 |
6178 | 2420 if (virtcol > curwin->w_curswant |
7 | 2421 && (curwin->w_curswant < (colnr_T)width1 |
2422 ? (curwin->w_curswant > (colnr_T)width1 / 2) | |
2423 : ((curwin->w_curswant - width1) % width2 | |
2424 > (colnr_T)width2 / 2))) | |
2425 --curwin->w_cursor.col; | |
2426 } | |
2427 | |
2428 if (atend) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2429 curwin->w_curswant = MAXCOL; // stick in the last column |
30799
ffa5492137c3
patch 9.0.0734: cursor position invalid when scrolling with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
2430 adjust_skipcol(); |
7 | 2431 |
2432 return retval; | |
2433 } | |
2434 | |
2435 /* | |
2436 * Handle CTRL-E and CTRL-Y commands: scroll a line up or down. | |
2437 * cap->arg must be TRUE for CTRL-E. | |
2438 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
2439 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2440 nv_scroll_line(cmdarg_T *cap) |
7 | 2441 { |
2442 if (!checkclearop(cap->oap)) | |
2443 scroll_redraw(cap->arg, cap->count1); | |
2444 } | |
2445 | |
2446 /* | |
2447 * Scroll "count" lines up or down, and redraw. | |
2448 */ | |
2449 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2450 scroll_redraw(int up, long count) |
7 | 2451 { |
2452 linenr_T prev_topline = curwin->w_topline; | |
30616
eb86a6330ae3
patch 9.0.0643: smoothscroll test fails
Bram Moolenaar <Bram@vim.org>
parents:
30471
diff
changeset
|
2453 int prev_skipcol = curwin->w_skipcol; |
7 | 2454 #ifdef FEAT_DIFF |
2455 int prev_topfill = curwin->w_topfill; | |
2456 #endif | |
2457 linenr_T prev_lnum = curwin->w_cursor.lnum; | |
2458 | |
2459 if (up) | |
2460 scrollup(count, TRUE); | |
2461 else | |
2462 scrolldown(count, TRUE); | |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2463 if (get_scrolloff_value() > 0) |
7 | 2464 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2465 // 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
|
2466 // valid, otherwise the screen jumps back at the end of the file. |
7 | 2467 cursor_correct(); |
2468 check_cursor_moved(curwin); | |
2469 curwin->w_valid |= VALID_TOPLINE; | |
2470 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2471 // 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
|
2472 // 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
|
2473 // first line of the buffer is already on the screen |
7 | 2474 while (curwin->w_topline == prev_topline |
30616
eb86a6330ae3
patch 9.0.0643: smoothscroll test fails
Bram Moolenaar <Bram@vim.org>
parents:
30471
diff
changeset
|
2475 && curwin->w_skipcol == prev_skipcol |
7 | 2476 #ifdef FEAT_DIFF |
2477 && curwin->w_topfill == prev_topfill | |
2478 #endif | |
2479 ) | |
2480 { | |
2481 if (up) | |
2482 { | |
2483 if (curwin->w_cursor.lnum > prev_lnum | |
2484 || cursor_down(1L, FALSE) == FAIL) | |
2485 break; | |
2486 } | |
2487 else | |
2488 { | |
2489 if (curwin->w_cursor.lnum < prev_lnum | |
2490 || prev_topline == 1L | |
2491 || cursor_up(1L, FALSE) == FAIL) | |
2492 break; | |
2493 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2494 // 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
|
2495 // end of the file. |
7 | 2496 check_cursor_moved(curwin); |
2497 curwin->w_valid |= VALID_TOPLINE; | |
2498 } | |
2499 } | |
2500 if (curwin->w_cursor.lnum != prev_lnum) | |
2501 coladvance(curwin->w_curswant); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
2502 redraw_later(UPD_VALID); |
7 | 2503 } |
2504 | |
2505 /* | |
27400
722db0819111
patch 8.2.4228: no tests for clicking in the GUI tabline
Bram Moolenaar <Bram@vim.org>
parents:
27386
diff
changeset
|
2506 * 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
|
2507 * '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
|
2508 * 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
|
2509 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2510 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2511 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
|
2512 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2513 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
|
2514 long n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2515 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2516 // "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
|
2517 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
|
2518 return FALSE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2519 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
|
2520 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2521 for (;;) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2522 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2523 #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
|
2524 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
|
2525 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2526 ++no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2527 ++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
|
2528 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
|
2529 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
|
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; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2532 (void)add_to_showcmd(nchar); |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
2533 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2534 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
|
2535 n /= 10; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2536 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
|
2537 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
|
2538 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
|
2539 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2540 #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
|
2541 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
|
2542 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2543 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
|
2544 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2545 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2546 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
|
2547 || nchar == 'h' |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2548 || 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
|
2549 || 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
|
2550 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2551 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
|
2552 *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
|
2553 return TRUE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2554 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2555 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2556 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2557 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
|
2558 break; |
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 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2561 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
|
2562 return FALSE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2563 } |
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 #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
|
2566 /* |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2567 * "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
|
2568 * "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
|
2569 * "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
|
2570 * "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
|
2571 * "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
|
2572 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2573 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2574 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
|
2575 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2576 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
|
2577 int len; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2578 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
|
2579 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2580 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
|
2581 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2582 ++no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2583 ++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
|
2584 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
|
2585 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
|
2586 --no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2587 --allow_keys; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2588 (void)add_to_showcmd(nchar); |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
2589 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2590 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
|
2591 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2592 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
|
2593 return OK; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2594 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2595 undo = TRUE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2596 } |
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 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
|
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 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
|
2601 return FAIL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2602 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
|
2603 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2604 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
|
2605 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2606 // 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
|
2607 // 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
|
2608 // used below. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2609 emsg_off++; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2610 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
|
2611 emsg_off--; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2612 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
|
2613 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
|
2614 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
|
2615 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2616 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2617 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
|
2618 && (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
|
2619 return FAIL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2620 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
|
2621 ? 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
|
2622 (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
|
2623 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2624 return OK; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2625 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2626 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2627 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2628 /* |
7 | 2629 * Commands that start with "z". |
2630 */ | |
2631 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2632 nv_zet(cmdarg_T *cap) |
7 | 2633 { |
2634 long n; | |
2635 colnr_T col; | |
2636 int nchar = cap->nchar; | |
2637 #ifdef FEAT_FOLDING | |
2638 long old_fdl = curwin->w_p_fdl; | |
2639 int old_fen = curwin->w_p_fen; | |
2640 #endif | |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2641 long siso = get_sidescrolloff_value(); |
7 | 2642 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2643 if (VIM_ISDIGIT(nchar) && !nv_z_get_count(cap, &nchar)) |
7 | 2644 return; |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2645 |
7 | 2646 if ( |
2647 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2648 // "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
|
2649 // 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
|
2650 // commands. |
7 | 2651 cap->nchar != 'f' && cap->nchar != 'F' |
2652 && !(VIsual_active && vim_strchr((char_u *)"dcCoO", cap->nchar)) | |
2653 && cap->nchar != 'j' && cap->nchar != 'k' | |
2654 && | |
2655 #endif | |
2656 checkclearop(cap->oap)) | |
2657 return; | |
2658 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2659 // 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
|
2660 // If line number given, set cursor. |
7 | 2661 if ((vim_strchr((char_u *)"+\r\nt.z^-b", nchar) != NULL) |
2662 && cap->count0 | |
2663 && cap->count0 != curwin->w_cursor.lnum) | |
2664 { | |
2665 setpcmark(); | |
2666 if (cap->count0 > curbuf->b_ml.ml_line_count) | |
2667 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2668 else | |
2669 curwin->w_cursor.lnum = cap->count0; | |
22 | 2670 check_cursor_col(); |
7 | 2671 } |
2672 | |
2673 switch (nchar) | |
2674 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2675 // "z+", "z<CR>" and "zt": put cursor at top of screen |
7 | 2676 case '+': |
2677 if (cap->count0 == 0) | |
2678 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2679 // 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
|
2680 validate_botline(); // make sure w_botline is valid |
7 | 2681 if (curwin->w_botline > curbuf->b_ml.ml_line_count) |
2682 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2683 else | |
2684 curwin->w_cursor.lnum = curwin->w_botline; | |
2685 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2686 // FALLTHROUGH |
7 | 2687 case NL: |
2688 case CAR: | |
2689 case K_KENTER: | |
2690 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
|
2691 // FALLTHROUGH |
7 | 2692 |
2693 case 't': scroll_cursor_top(0, TRUE); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
2694 redraw_later(UPD_VALID); |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2695 set_fraction(curwin); |
7 | 2696 break; |
2697 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2698 // "z." and "zz": put cursor in middle of screen |
7 | 2699 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
|
2700 // FALLTHROUGH |
7 | 2701 |
31954
d8fdafc4b390
patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' set
Bram Moolenaar <Bram@vim.org>
parents:
31881
diff
changeset
|
2702 case 'z': scroll_cursor_halfway(TRUE, FALSE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
2703 redraw_later(UPD_VALID); |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2704 set_fraction(curwin); |
7 | 2705 break; |
2706 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2707 // "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
|
2708 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
|
2709 // 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
|
2710 // bottom of window. |
7 | 2711 if (cap->count0 != 0) |
2712 { | |
2713 scroll_cursor_bot(0, TRUE); | |
2714 curwin->w_cursor.lnum = curwin->w_topline; | |
2715 } | |
2716 else if (curwin->w_topline == 1) | |
2717 curwin->w_cursor.lnum = 1; | |
2718 else | |
2719 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
|
2720 // FALLTHROUGH |
7 | 2721 case '-': |
2722 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
|
2723 // FALLTHROUGH |
7 | 2724 |
2725 case 'b': scroll_cursor_bot(0, TRUE); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
2726 redraw_later(UPD_VALID); |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2727 set_fraction(curwin); |
7 | 2728 break; |
2729 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2730 // "zH" - scroll screen right half-page |
7 | 2731 case 'H': |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2732 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
|
2733 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2734 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2735 // "zh" - scroll screen to the right |
7 | 2736 case 'h': |
2737 case K_LEFT: | |
2738 if (!curwin->w_p_wrap) | |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2739 (void)set_leftcol((colnr_T)cap->count1 > curwin->w_leftcol |
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2740 ? 0 : curwin->w_leftcol - (colnr_T)cap->count1); |
7 | 2741 break; |
2742 | |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2743 // "zL" - scroll window left half-page |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2744 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
|
2745 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2746 |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2747 // "zl" - scroll window to the left if not wrapping |
7 | 2748 case 'l': |
2749 case K_RIGHT: | |
2750 if (!curwin->w_p_wrap) | |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2751 (void)set_leftcol(curwin->w_leftcol + (colnr_T)cap->count1); |
7 | 2752 break; |
2753 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2754 // "zs" - scroll screen, cursor at the start |
7 | 2755 case 's': if (!curwin->w_p_wrap) |
2756 { | |
2757 #ifdef FEAT_FOLDING | |
2758 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
|
2759 col = 0; // like the cursor is in col 0 |
7 | 2760 else |
2761 #endif | |
2762 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
|
2763 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
|
2764 col -= siso; |
7 | 2765 else |
2766 col = 0; | |
2767 if (curwin->w_leftcol != col) | |
2768 { | |
2769 curwin->w_leftcol = col; | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
2770 redraw_later(UPD_NOT_VALID); |
7 | 2771 } |
2772 } | |
2773 break; | |
2774 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2775 // "ze" - scroll screen, cursor at the end |
7 | 2776 case 'e': if (!curwin->w_p_wrap) |
2777 { | |
2778 #ifdef FEAT_FOLDING | |
2779 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
|
2780 col = 0; // like the cursor is in col 0 |
7 | 2781 else |
2782 #endif | |
2783 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
|
2784 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
|
2785 if ((long)col + siso < n) |
7 | 2786 col = 0; |
2787 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
|
2788 col = col + siso - n + 1; |
7 | 2789 if (curwin->w_leftcol != col) |
2790 { | |
2791 curwin->w_leftcol = col; | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
2792 redraw_later(UPD_NOT_VALID); |
7 | 2793 } |
2794 } | |
2795 break; | |
2796 | |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
2797 // "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
|
2798 case 'P': |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
2799 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
|
2800 break; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24800
diff
changeset
|
2801 // "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
|
2802 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
|
2803 break; |
7 | 2804 #ifdef FEAT_FOLDING |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2805 // "zF": create fold command |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2806 // "zf": create fold operator |
7 | 2807 case 'F': |
2808 case 'f': if (foldManualAllowed(TRUE)) | |
2809 { | |
2810 cap->nchar = 'f'; | |
2811 nv_operator(cap); | |
2812 curwin->w_p_fen = TRUE; | |
2813 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2814 // "zF" is like "zfzf" |
7 | 2815 if (nchar == 'F' && cap->oap->op_type == OP_FOLD) |
2816 { | |
2817 nv_operator(cap); | |
2818 finish_op = TRUE; | |
2819 } | |
2820 } | |
2821 else | |
2822 clearopbeep(cap->oap); | |
2823 break; | |
2824 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2825 // "zd": delete fold at cursor |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2826 // "zD": delete fold at cursor recursively |
7 | 2827 case 'd': |
2828 case 'D': if (foldManualAllowed(FALSE)) | |
2829 { | |
2830 if (VIsual_active) | |
2831 nv_operator(cap); | |
2832 else | |
2833 deleteFold(curwin->w_cursor.lnum, | |
2834 curwin->w_cursor.lnum, nchar == 'D', FALSE); | |
2835 } | |
2836 break; | |
2837 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2838 // "zE": erase all folds |
7 | 2839 case 'E': if (foldmethodIsManual(curwin)) |
2840 { | |
2841 clearFolding(curwin); | |
2842 changed_window_setting(); | |
2843 } | |
2844 else if (foldmethodIsMarker(curwin)) | |
2845 deleteFold((linenr_T)1, curbuf->b_ml.ml_line_count, | |
2846 TRUE, FALSE); | |
2847 else | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26909
diff
changeset
|
2848 emsg(_(e_cannot_erase_folds_with_current_foldmethod)); |
7 | 2849 break; |
2850 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2851 // "zn": fold none: reset 'foldenable' |
7 | 2852 case 'n': curwin->w_p_fen = FALSE; |
2853 break; | |
2854 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2855 // "zN": fold Normal: set 'foldenable' |
7 | 2856 case 'N': curwin->w_p_fen = TRUE; |
2857 break; | |
2858 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2859 // "zi": invert folding: toggle 'foldenable' |
7 | 2860 case 'i': curwin->w_p_fen = !curwin->w_p_fen; |
2861 break; | |
2862 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2863 // "za": open closed fold or close open fold at cursor |
7 | 2864 case 'a': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
2865 openFold(curwin->w_cursor.lnum, cap->count1); | |
2866 else | |
2867 { | |
2868 closeFold(curwin->w_cursor.lnum, cap->count1); | |
2869 curwin->w_p_fen = TRUE; | |
2870 } | |
2871 break; | |
2872 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2873 // "zA": open fold at cursor recursively |
7 | 2874 case 'A': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
2875 openFoldRecurse(curwin->w_cursor.lnum); | |
2876 else | |
2877 { | |
2878 closeFoldRecurse(curwin->w_cursor.lnum); | |
2879 curwin->w_p_fen = TRUE; | |
2880 } | |
2881 break; | |
2882 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2883 // "zo": open fold at cursor or Visual area |
7 | 2884 case 'o': if (VIsual_active) |
2885 nv_operator(cap); | |
2886 else | |
2887 openFold(curwin->w_cursor.lnum, cap->count1); | |
2888 break; | |
2889 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2890 // "zO": open fold recursively |
7 | 2891 case 'O': if (VIsual_active) |
2892 nv_operator(cap); | |
2893 else | |
2894 openFoldRecurse(curwin->w_cursor.lnum); | |
2895 break; | |
2896 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2897 // "zc": close fold at cursor or Visual area |
7 | 2898 case 'c': if (VIsual_active) |
2899 nv_operator(cap); | |
2900 else | |
2901 closeFold(curwin->w_cursor.lnum, cap->count1); | |
2902 curwin->w_p_fen = TRUE; | |
2903 break; | |
2904 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2905 // "zC": close fold recursively |
7 | 2906 case 'C': if (VIsual_active) |
2907 nv_operator(cap); | |
2908 else | |
2909 closeFoldRecurse(curwin->w_cursor.lnum); | |
2910 curwin->w_p_fen = TRUE; | |
2911 break; | |
2912 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2913 // "zv": open folds at the cursor |
7 | 2914 case 'v': foldOpenCursor(); |
2915 break; | |
2916 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2917 // "zx": re-apply 'foldlevel' and open folds at the cursor |
7 | 2918 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
|
2919 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
|
2920 newFoldLevel(); // update right now |
7 | 2921 foldOpenCursor(); |
2922 break; | |
2923 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2924 // "zX": undo manual opens/closes, re-apply 'foldlevel' |
7 | 2925 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
|
2926 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
|
2927 old_fdl = -1; // force an update |
7 | 2928 break; |
2929 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2930 // "zm": fold more |
7 | 2931 case 'm': if (curwin->w_p_fdl > 0) |
6725 | 2932 { |
2933 curwin->w_p_fdl -= cap->count1; | |
2934 if (curwin->w_p_fdl < 0) | |
2935 curwin->w_p_fdl = 0; | |
2936 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2937 old_fdl = -1; // force an update |
7 | 2938 curwin->w_p_fen = TRUE; |
2939 break; | |
2940 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2941 // "zM": close all folds |
7 | 2942 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
|
2943 old_fdl = -1; // force an update |
7 | 2944 curwin->w_p_fen = TRUE; |
2945 break; | |
2946 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2947 // "zr": reduce folding |
6725 | 2948 case 'r': curwin->w_p_fdl += cap->count1; |
2949 { | |
2950 int d = getDeepestNesting(); | |
2951 | |
2952 if (curwin->w_p_fdl >= d) | |
2953 curwin->w_p_fdl = d; | |
2954 } | |
7 | 2955 break; |
2956 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2957 // "zR": open all folds |
7 | 2958 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
|
2959 old_fdl = -1; // force an update |
7 | 2960 break; |
2961 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2962 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
|
2963 case 'k': // "zk" move to next fold upwards |
7 | 2964 if (foldMoveTo(TRUE, nchar == 'j' ? FORWARD : BACKWARD, |
2965 cap->count1) == FAIL) | |
2966 clearopbeep(cap->oap); | |
2967 break; | |
2968 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2969 #endif // FEAT_FOLDING |
7 | 2970 |
737 | 2971 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2972 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
|
2973 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
|
2974 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
|
2975 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
|
2976 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
|
2977 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
|
2978 return; |
316 | 2979 break; |
323 | 2980 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2981 case '=': // "z=": suggestions for a badly spelled word |
638 | 2982 if (!checkclearop(cap->oap)) |
485 | 2983 spell_suggest((int)cap->count0); |
323 | 2984 break; |
310 | 2985 #endif |
2986 | |
7 | 2987 default: clearopbeep(cap->oap); |
2988 } | |
2989 | |
2990 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2991 // Redraw when 'foldenable' changed |
7 | 2992 if (old_fen != curwin->w_p_fen) |
2993 { | |
2994 # ifdef FEAT_DIFF | |
2995 win_T *wp; | |
2996 | |
2997 if (foldmethodIsDiff(curwin) && curwin->w_p_scb) | |
2998 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2999 // Adjust 'foldenable' in diff-synced windows. |
7 | 3000 FOR_ALL_WINDOWS(wp) |
3001 { | |
3002 if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) | |
3003 { | |
3004 wp->w_p_fen = curwin->w_p_fen; | |
3005 changed_window_setting_win(wp); | |
3006 } | |
3007 } | |
3008 } | |
3009 # endif | |
3010 changed_window_setting(); | |
3011 } | |
3012 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3013 // Redraw when 'foldlevel' changed. |
7 | 3014 if (old_fdl != curwin->w_p_fdl) |
3015 newFoldLevel(); | |
3016 #endif | |
3017 } | |
3018 | |
3019 #ifdef FEAT_GUI | |
3020 /* | |
3021 * Vertical scrollbar movement. | |
3022 */ | |
3023 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3024 nv_ver_scrollbar(cmdarg_T *cap) |
7 | 3025 { |
3026 if (cap->oap->op_type != OP_NOP) | |
3027 clearopbeep(cap->oap); | |
3028 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3029 // Even if an operator was pending, we still want to scroll |
7 | 3030 gui_do_scroll(); |
3031 } | |
3032 | |
3033 /* | |
3034 * Horizontal scrollbar movement. | |
3035 */ | |
3036 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3037 nv_hor_scrollbar(cmdarg_T *cap) |
7 | 3038 { |
3039 if (cap->oap->op_type != OP_NOP) | |
3040 clearopbeep(cap->oap); | |
3041 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3042 // Even if an operator was pending, we still want to scroll |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30833
diff
changeset
|
3043 do_mousescroll_horiz(scrollbar_value); |
7 | 3044 } |
3045 #endif | |
3046 | |
690 | 3047 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
685 | 3048 /* |
3049 * Click in GUI tab. | |
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_tabline(cmdarg_T *cap) |
685 | 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 jump tabs. |
685 | 3058 goto_tabpage(current_tab); |
3059 } | |
686 | 3060 |
3061 /* | |
3062 * Selected item in tab line menu. | |
3063 */ | |
3064 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3065 nv_tabmenu(cmdarg_T *cap) |
686 | 3066 { |
3067 if (cap->oap->op_type != OP_NOP) | |
3068 clearopbeep(cap->oap); | |
3069 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3070 // Even if an operator was pending, we still want to jump tabs. |
690 | 3071 handle_tabmenu(); |
3072 } | |
3073 | |
3074 /* | |
3075 * Handle selecting an item of the GUI tab line menu. | |
3076 * Used in Normal and Insert mode. | |
3077 */ | |
3078 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3079 handle_tabmenu(void) |
690 | 3080 { |
686 | 3081 switch (current_tabmenu) |
3082 { | |
3083 case TABLINE_MENU_CLOSE: | |
3084 if (current_tab == 0) | |
3085 do_cmdline_cmd((char_u *)"tabclose"); | |
3086 else | |
3087 { | |
3088 vim_snprintf((char *)IObuff, IOSIZE, "tabclose %d", | |
3089 current_tab); | |
3090 do_cmdline_cmd(IObuff); | |
3091 } | |
3092 break; | |
3093 | |
3094 case TABLINE_MENU_NEW: | |
6631 | 3095 if (current_tab == 0) |
3096 do_cmdline_cmd((char_u *)"$tabnew"); | |
3097 else | |
3098 { | |
3099 vim_snprintf((char *)IObuff, IOSIZE, "%dtabnew", | |
3100 current_tab - 1); | |
3101 do_cmdline_cmd(IObuff); | |
3102 } | |
686 | 3103 break; |
3104 | |
3105 case TABLINE_MENU_OPEN: | |
6631 | 3106 if (current_tab == 0) |
3107 do_cmdline_cmd((char_u *)"browse $tabnew"); | |
3108 else | |
3109 { | |
3110 vim_snprintf((char *)IObuff, IOSIZE, "browse %dtabnew", | |
3111 current_tab - 1); | |
3112 do_cmdline_cmd(IObuff); | |
3113 } | |
686 | 3114 break; |
3115 } | |
3116 } | |
685 | 3117 #endif |
3118 | |
7 | 3119 /* |
3120 * "Q" command. | |
3121 */ | |
3122 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3123 nv_exmode(cmdarg_T *cap) |
7 | 3124 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3125 // Ignore 'Q' in Visual mode, just give a beep. |
7 | 3126 if (VIsual_active) |
6949 | 3127 vim_beep(BO_EX); |
5735 | 3128 else if (!checkclearop(cap->oap)) |
7 | 3129 do_exmode(FALSE); |
3130 } | |
3131 | |
3132 /* | |
3133 * Handle a ":" command. | |
3134 */ | |
3135 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3136 nv_colon(cmdarg_T *cap) |
7 | 3137 { |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3138 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
|
3139 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
|
3140 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
|
3141 || 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
|
3142 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
|
3143 |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3144 if (VIsual_active && !is_cmdkey) |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3145 { |
7 | 3146 nv_operator(cap); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3147 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3148 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3149 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3150 if (cap->oap->op_type != OP_NOP) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3151 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3152 // Using ":" as a movement is characterwise exclusive. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3153 cap->oap->motion_type = MCHAR; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3154 cap->oap->inclusive = FALSE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3155 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3156 else if (cap->count0 && !is_cmdkey) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3157 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3158 // translate "count:" into ":.,.+(count - 1)" |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3159 stuffcharReadbuff('.'); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3160 if (cap->count0 > 1) |
7 | 3161 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3162 stuffReadbuff((char_u *)",.+"); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3163 stuffnumReadbuff((long)cap->count0 - 1L); |
7 | 3164 } |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3165 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3166 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3167 // When typing, don't type below an old message |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3168 if (KeyTyped) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3169 compute_cmdrow(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3170 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3171 old_p_im = p_im; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3172 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3173 // get a command line and execute it |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3174 flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3175 if (is_cmdkey) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3176 cmd_result = do_cmdkey_command(cap->cmdchar, flags); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3177 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3178 cmd_result = do_cmdline(NULL, getexline, NULL, flags); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3179 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3180 // If 'insertmode' changed, enter or exit Insert mode |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3181 if (p_im != old_p_im) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3182 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3183 if (p_im) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3184 restart_edit = 'i'; |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3185 else |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3186 restart_edit = 0; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3187 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3188 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3189 if (cmd_result == FAIL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3190 // The Ex command failed, do not execute the operator. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3191 clearop(cap->oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3192 else if (cap->oap->op_type != OP_NOP |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3193 && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3194 || cap->oap->start.col > |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31984
diff
changeset
|
3195 (colnr_T)STRLEN(ml_get(cap->oap->start.lnum)) |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3196 || did_emsg |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3197 )) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3198 // The start of the operator has become invalid by the Ex command. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3199 clearopbeep(cap->oap); |
7 | 3200 } |
3201 | |
3202 /* | |
3203 * Handle CTRL-G command. | |
3204 */ | |
3205 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3206 nv_ctrlg(cmdarg_T *cap) |
7 | 3207 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3208 if (VIsual_active) // toggle Selection/Visual mode |
7 | 3209 { |
3210 VIsual_select = !VIsual_select; | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
3211 may_trigger_modechanged(); |
7 | 3212 showmode(); |
3213 } | |
5735 | 3214 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
|
3215 // print full name if count given or :cd used |
7 | 3216 fileinfo((int)cap->count0, FALSE, TRUE); |
3217 } | |
3218 | |
3219 /* | |
3220 * Handle CTRL-H <Backspace> command. | |
3221 */ | |
3222 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3223 nv_ctrlh(cmdarg_T *cap) |
7 | 3224 { |
3225 if (VIsual_active && VIsual_select) | |
3226 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3227 cap->cmdchar = 'x'; // BS key behaves like 'x' in Select mode |
7 | 3228 v_visop(cap); |
3229 } | |
3230 else | |
3231 nv_left(cap); | |
3232 } | |
3233 | |
3234 /* | |
3235 * CTRL-L: clear screen and redraw. | |
3236 */ | |
3237 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3238 nv_clear(cmdarg_T *cap) |
7 | 3239 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3240 if (checkclearop(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3241 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3242 |
7 | 3243 #ifdef FEAT_SYN_HL |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3244 // Clear all syntax states to force resyncing. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3245 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
|
3246 # ifdef FEAT_RELTIME |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3247 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3248 win_T *wp; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3249 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3250 FOR_ALL_WINDOWS(wp) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3251 wp->w_s->b_syn_slow = FALSE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3252 } |
11529
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3253 # endif |
7 | 3254 #endif |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3255 redraw_later(UPD_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
|
3256 #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
|
3257 # ifdef VIMDLL |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3258 if (!gui.in_use) |
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
|
3259 # endif |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3260 resize_console_buf(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3261 #endif |
7 | 3262 } |
3263 | |
3264 /* | |
3265 * CTRL-O: In Select mode: switch to Visual mode for one command. | |
3266 * Otherwise: Go to older pcmark. | |
3267 */ | |
3268 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3269 nv_ctrlo(cmdarg_T *cap) |
7 | 3270 { |
3271 if (VIsual_active && VIsual_select) | |
3272 { | |
3273 VIsual_select = FALSE; | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
3274 may_trigger_modechanged(); |
7 | 3275 showmode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3276 restart_VIsual_select = 2; // restart Select mode later |
7 | 3277 } |
3278 else | |
3279 { | |
3280 cap->count1 = -cap->count1; | |
3281 nv_pcmark(cap); | |
3282 } | |
3283 } | |
3284 | |
3285 /* | |
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
|
3286 * 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
|
3287 * not named. |
7 | 3288 */ |
3289 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3290 nv_hat(cmdarg_T *cap) |
7 | 3291 { |
3292 if (!checkclearopq(cap->oap)) | |
3293 (void)buflist_getfile((int)cap->count0, (linenr_T)0, | |
3294 GETF_SETMARK|GETF_ALT, FALSE); | |
3295 } | |
3296 | |
3297 /* | |
3298 * "Z" commands. | |
3299 */ | |
3300 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3301 nv_Zet(cmdarg_T *cap) |
7 | 3302 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3303 if (checkclearopq(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3304 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3305 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3306 switch (cap->nchar) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3307 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3308 // "ZZ": equivalent to ":x". |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3309 case 'Z': do_cmdline_cmd((char_u *)"x"); |
7 | 3310 break; |
3311 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3312 // "ZQ": equivalent to ":q!" (Elvis compatible). |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3313 case 'Q': do_cmdline_cmd((char_u *)"q!"); |
7 | 3314 break; |
3315 | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3316 default: clearopbeep(cap->oap); |
7 | 3317 } |
3318 } | |
3319 | |
3320 /* | |
3321 * Call nv_ident() as if "c1" was used, with "c2" as next character. | |
3322 */ | |
3323 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3324 do_nv_ident(int c1, int c2) |
7 | 3325 { |
3326 oparg_T oa; | |
3327 cmdarg_T ca; | |
3328 | |
3329 clear_oparg(&oa); | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
3330 CLEAR_FIELD(ca); |
7 | 3331 ca.oap = &oa; |
3332 ca.cmdchar = c1; | |
3333 ca.nchar = c2; | |
3334 nv_ident(&ca); | |
3335 } | |
3336 | |
3337 /* | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3338 * '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
|
3339 * cursor. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3340 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3341 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3342 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
|
3343 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
|
3344 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
|
3345 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
|
3346 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
|
3347 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
|
3348 int n, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3349 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
|
3350 unsigned buflen) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3351 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3352 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
|
3353 int isman; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3354 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
|
3355 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3356 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
|
3357 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3358 // 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
|
3359 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
|
3360 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3361 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3362 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3363 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
|
3364 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3365 // '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
|
3366 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
|
3367 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
|
3368 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3369 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
|
3370 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3371 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3372 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3373 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3374 // 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
|
3375 // 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
|
3376 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
|
3377 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3378 ++ptr; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3379 --n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3380 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3381 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
|
3382 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3383 // 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
|
3384 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
|
3385 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
|
3386 *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
|
3387 return 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3388 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3389 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3390 // 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
|
3391 // 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
|
3392 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
|
3393 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
|
3394 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
|
3395 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
|
3396 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3397 STRCAT(buf, "! "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3398 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
|
3399 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
|
3400 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3401 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
|
3402 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3403 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
|
3404 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3405 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
|
3406 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3407 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3408 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3409 *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
|
3410 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3411 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3412 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3413 /* |
7 | 3414 * Handle the commands that use the word under the cursor. |
3415 * [g] CTRL-] :ta to current identifier | |
3416 * [g] 'K' run program for current identifier | |
3417 * [g] '*' / to current identifier or string | |
3418 * [g] '#' ? to current identifier or string | |
3419 * g ']' :tselect for current identifier | |
3420 */ | |
3421 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3422 nv_ident(cmdarg_T *cap) |
7 | 3423 { |
3424 char_u *ptr = NULL; | |
3425 char_u *buf; | |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3426 unsigned buflen; |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3427 char_u *newbuf; |
7 | 3428 char_u *p; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3429 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
|
3430 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
|
3431 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
|
3432 int n = 0; // init for GCC |
7 | 3433 int cmdchar; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3434 int g_cmd; // "g" command |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3435 int tag_cmd = FALSE; |
7 | 3436 char_u *aux_ptr; |
3437 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3438 if (cap->cmdchar == 'g') // "g*", "g#", "g]" and "gCTRL-]" |
7 | 3439 { |
3440 cmdchar = cap->nchar; | |
3441 g_cmd = TRUE; | |
3442 } | |
3443 else | |
3444 { | |
3445 cmdchar = cap->cmdchar; | |
3446 g_cmd = FALSE; | |
3447 } | |
3448 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3449 if (cmdchar == POUND) // the pound sign, '#' for English keyboards |
7 | 3450 cmdchar = '#'; |
3451 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3452 // The "]", "CTRL-]" and "K" commands accept an argument in Visual mode. |
7 | 3453 if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K') |
3454 { | |
3455 if (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL) | |
3456 return; | |
3457 if (checkclearopq(cap->oap)) | |
3458 return; | |
3459 } | |
3460 | |
3461 if (ptr == NULL && (n = find_ident_under_cursor(&ptr, | |
3462 (cmdchar == '*' || cmdchar == '#') | |
3463 ? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0) | |
3464 { | |
3465 clearop(cap->oap); | |
3466 return; | |
3467 } | |
3468 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3469 // 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
|
3470 // 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
|
3471 // and some numbers. |
7 | 3472 kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp); |
3473 kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 | |
3474 || 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
|
3475 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
|
3476 { |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
3477 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
|
3478 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
|
3479 } |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3480 kp_ex = (*kp == ':'); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3481 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
|
3482 buf = alloc(buflen); |
7 | 3483 if (buf == NULL) |
3484 return; | |
3485 buf[0] = NUL; | |
3486 | |
3487 switch (cmdchar) | |
3488 { | |
3489 case '*': | |
3490 case '#': | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3491 // 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
|
3492 // 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
|
3493 // 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
|
3494 // it was. |
7 | 3495 setpcmark(); |
3496 curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline()); | |
3497 | |
3498 if (!g_cmd && vim_iswordp(ptr)) | |
3499 STRCPY(buf, "\\<"); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3500 no_smartcase = TRUE; // don't use 'smartcase' now |
7 | 3501 break; |
3502 | |
3503 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
|
3504 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
|
3505 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
|
3506 return; |
7 | 3507 break; |
3508 | |
3509 case ']': | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3510 tag_cmd = TRUE; |
7 | 3511 #ifdef FEAT_CSCOPE |
3512 if (p_cst) | |
3513 STRCPY(buf, "cstag "); | |
3514 else | |
3515 #endif | |
3516 STRCPY(buf, "ts "); | |
3517 break; | |
3518 | |
3519 default: | |
2112
6b5d641bcdd4
updated for version 7.2.395
Bram Moolenaar <bram@zimbu.org>
parents:
2049
diff
changeset
|
3520 tag_cmd = TRUE; |
7 | 3521 if (curbuf->b_help) |
3522 STRCPY(buf, "he! "); | |
3523 else | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3524 { |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3525 if (g_cmd) |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3526 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
|
3527 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
|
3528 STRCPY(buf, "ta "); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3529 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
|
3530 sprintf((char *)buf, ":%ldta ", cap->count0); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3531 } |
7 | 3532 } |
3533 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3534 // Now grab the chars in the identifier |
1712 | 3535 if (cmdchar == 'K' && !kp_help) |
3536 { | |
1728 | 3537 ptr = vim_strnsave(ptr, n); |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3538 if (kp_ex) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3539 // 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
|
3540 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
|
3541 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3542 // 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
|
3543 p = vim_strsave_shellescape(ptr, TRUE, TRUE); |
1728 | 3544 vim_free(ptr); |
1712 | 3545 if (p == NULL) |
3546 { | |
3547 vim_free(buf); | |
3548 return; | |
3549 } | |
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
|
3550 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
|
3551 if (newbuf == NULL) |
1712 | 3552 { |
3553 vim_free(buf); | |
3554 vim_free(p); | |
3555 return; | |
3556 } | |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3557 buf = newbuf; |
1712 | 3558 STRCAT(buf, p); |
3559 vim_free(p); | |
3560 } | |
7 | 3561 else |
1712 | 3562 { |
3563 if (cmdchar == '*') | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3564 aux_ptr = (char_u *)(magic_isset() ? "/.*~[^$\\" : "/^$\\"); |
1712 | 3565 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
|
3566 aux_ptr = (char_u *)(magic_isset() ? "/?.*~[^$\\" : "/?^$\\"); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3567 else if (tag_cmd) |
2603 | 3568 { |
3569 if (curbuf->b_help) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3570 // ":help" handles unescaped argument |
2603 | 3571 aux_ptr = (char_u *)""; |
3572 else | |
3573 aux_ptr = (char_u *)"\\|\"\n["; | |
3574 } | |
1712 | 3575 else |
3576 aux_ptr = (char_u *)"\\|\"\n*?["; | |
3577 | |
3578 p = buf + STRLEN(buf); | |
3579 while (n-- > 0) | |
3580 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3581 // put a backslash before \ and some others |
1712 | 3582 if (vim_strchr(aux_ptr, *ptr) != NULL) |
3583 *p++ = '\\'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3584 // 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
|
3585 // bytes of that character. |
1712 | 3586 if (has_mbyte) |
3587 { | |
3588 int i; | |
3589 int len = (*mb_ptr2len)(ptr) - 1; | |
3590 | |
3591 for (i = 0; i < len && n >= 1; ++i, --n) | |
3592 *p++ = *ptr++; | |
3593 } | |
3594 *p++ = *ptr++; | |
3595 } | |
3596 *p = NUL; | |
3597 } | |
7 | 3598 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3599 // Execute the command. |
7 | 3600 if (cmdchar == '*' || cmdchar == '#') |
3601 { | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3602 if (!g_cmd && (has_mbyte |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3603 ? 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
|
3604 : vim_iswordc(ptr[-1]))) |
7 | 3605 STRCAT(buf, "\\>"); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3606 |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3607 // put pattern in search history |
2024 | 3608 init_history(); |
7 | 3609 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
|
3610 |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
3611 (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); |
7 | 3612 } |
3613 else | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3614 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3615 g_tag_at_cursor = TRUE; |
7 | 3616 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
|
3617 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
|
3618 } |
7 | 3619 |
3620 vim_free(buf); | |
3621 } | |
3622 | |
3623 /* | |
3624 * Get visually selected text, within one line only. | |
3625 * Returns FAIL if more than one line selected. | |
3626 */ | |
344 | 3627 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3628 get_visual_text( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3629 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3630 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
|
3631 int *lenp) // return: length of selected text |
7 | 3632 { |
3633 if (VIsual_mode != 'V') | |
3634 unadjust_for_sel(); | |
3635 if (VIsual.lnum != curwin->w_cursor.lnum) | |
3636 { | |
344 | 3637 if (cap != NULL) |
3638 clearopbeep(cap->oap); | |
7 | 3639 return FAIL; |
3640 } | |
3641 if (VIsual_mode == 'V') | |
3642 { | |
3643 *pp = ml_get_curline(); | |
3644 *lenp = (int)STRLEN(*pp); | |
3645 } | |
3646 else | |
3647 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3648 if (LT_POS(curwin->w_cursor, VIsual)) |
7 | 3649 { |
3650 *pp = ml_get_pos(&curwin->w_cursor); | |
3651 *lenp = VIsual.col - curwin->w_cursor.col + 1; | |
3652 } | |
3653 else | |
3654 { | |
3655 *pp = ml_get_pos(&VIsual); | |
3656 *lenp = curwin->w_cursor.col - VIsual.col + 1; | |
3657 } | |
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
|
3658 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
|
3659 *lenp = 0; |
28867
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3660 if (*lenp > 0) |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3661 { |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3662 if (has_mbyte) |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3663 // Correct the length to include all bytes of the last |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3664 // character. |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3665 *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1; |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3666 else if ((*pp)[*lenp - 1] == NUL) |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3667 // Do not include a trailing NUL. |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3668 *lenp -= 1; |
987d29ca36a5
patch 8.2.4956: reading past end of line with "gf" in Visual block mode
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
3669 } |
7 | 3670 } |
3671 reset_VIsual_and_resel(); | |
3672 return OK; | |
3673 } | |
3674 | |
3675 /* | |
3676 * CTRL-T: backwards in tag stack | |
3677 */ | |
3678 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3679 nv_tagpop(cmdarg_T *cap) |
7 | 3680 { |
3681 if (!checkclearopq(cap->oap)) | |
3682 do_tag((char_u *)"", DT_POP, (int)cap->count1, FALSE, TRUE); | |
3683 } | |
3684 | |
3685 /* | |
3686 * Handle scrolling command 'H', 'L' and 'M'. | |
3687 */ | |
3688 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3689 nv_scroll(cmdarg_T *cap) |
7 | 3690 { |
3691 int used = 0; | |
3692 long n; | |
3693 #ifdef FEAT_FOLDING | |
3694 linenr_T lnum; | |
3695 #endif | |
3696 int half; | |
3697 | |
3698 cap->oap->motion_type = MLINE; | |
3699 setpcmark(); | |
3700 | |
3701 if (cap->cmdchar == 'L') | |
3702 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3703 validate_botline(); // make sure curwin->w_botline is valid |
7 | 3704 curwin->w_cursor.lnum = curwin->w_botline - 1; |
3705 if (cap->count1 - 1 >= curwin->w_cursor.lnum) | |
3706 curwin->w_cursor.lnum = 1; | |
3707 else | |
9 | 3708 { |
3709 #ifdef FEAT_FOLDING | |
3710 if (hasAnyFolding(curwin)) | |
3711 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3712 // Count a fold for one screen line. |
9 | 3713 for (n = cap->count1 - 1; n > 0 |
3714 && curwin->w_cursor.lnum > curwin->w_topline; --n) | |
3715 { | |
3716 (void)hasFolding(curwin->w_cursor.lnum, | |
3717 &curwin->w_cursor.lnum, NULL); | |
31714
07480c2f5ea8
patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents:
31680
diff
changeset
|
3718 if (curwin->w_cursor.lnum > curwin->w_topline) |
07480c2f5ea8
patch 9.0.1189: invalid memory access with folding and using "L"
Bram Moolenaar <Bram@vim.org>
parents:
31680
diff
changeset
|
3719 --curwin->w_cursor.lnum; |
9 | 3720 } |
3721 } | |
3722 else | |
3723 #endif | |
3724 curwin->w_cursor.lnum -= cap->count1 - 1; | |
3725 } | |
7 | 3726 } |
3727 else | |
3728 { | |
3729 if (cap->cmdchar == 'M') | |
3730 { | |
3731 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3732 // Don't count filler lines above the window. |
7 | 3733 used -= diff_check_fill(curwin, curwin->w_topline) |
3734 - curwin->w_topfill; | |
3735 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3736 validate_botline(); // make sure w_empty_rows is valid |
7 | 3737 half = (curwin->w_height - curwin->w_empty_rows + 1) / 2; |
3738 for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; ++n) | |
3739 { | |
3740 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3741 // 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
|
3742 // line" and half to be "above the next line". |
7 | 3743 if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline |
3744 + n) / 2 >= half) | |
3745 { | |
3746 --n; | |
3747 break; | |
3748 } | |
3749 #endif | |
3750 used += plines(curwin->w_topline + n); | |
3751 if (used >= half) | |
3752 break; | |
3753 #ifdef FEAT_FOLDING | |
3754 if (hasFolding(curwin->w_topline + n, NULL, &lnum)) | |
3755 n = lnum - curwin->w_topline; | |
3756 #endif | |
3757 } | |
3758 if (n > 0 && used > curwin->w_height) | |
3759 --n; | |
3760 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3761 else // (cap->cmdchar == 'H') |
9 | 3762 { |
7 | 3763 n = cap->count1 - 1; |
9 | 3764 #ifdef FEAT_FOLDING |
3765 if (hasAnyFolding(curwin)) | |
3766 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3767 // Count a fold for one screen line. |
9 | 3768 lnum = curwin->w_topline; |
3769 while (n-- > 0 && lnum < curwin->w_botline - 1) | |
3770 { | |
7009 | 3771 (void)hasFolding(lnum, NULL, &lnum); |
9 | 3772 ++lnum; |
3773 } | |
3774 n = lnum - curwin->w_topline; | |
3775 } | |
3776 #endif | |
3777 } | |
7 | 3778 curwin->w_cursor.lnum = curwin->w_topline + n; |
3779 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
3780 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
3781 } | |
3782 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3783 // 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
|
3784 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
|
3785 cursor_correct(); |
7 | 3786 beginline(BL_SOL | BL_FIX); |
3787 } | |
3788 | |
3789 /* | |
3790 * Cursor right commands. | |
3791 */ | |
3792 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3793 nv_right(cmdarg_T *cap) |
7 | 3794 { |
3795 long n; | |
5735 | 3796 int past_line; |
7 | 3797 |
180 | 3798 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
3799 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3800 // <C-Right> and <S-Right> move a word or WORD right |
180 | 3801 if (mod_mask & MOD_MASK_CTRL) |
3802 cap->arg = TRUE; | |
3803 nv_wordcmd(cap); | |
3804 return; | |
3805 } | |
3806 | |
7 | 3807 cap->oap->motion_type = MCHAR; |
3808 cap->oap->inclusive = FALSE; | |
5735 | 3809 past_line = (VIsual_active && *p_sel != 'o'); |
3810 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3811 // 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
|
3812 // are (theoretically) infinitely long. |
7 | 3813 if (virtual_active()) |
5735 | 3814 past_line = 0; |
7 | 3815 |
3816 for (n = cap->count1; n > 0; --n) | |
3817 { | |
5735 | 3818 if ((!past_line && oneright() == FAIL) |
3819 || (past_line && *ml_get_cursor() == NUL) | |
1877 | 3820 ) |
7 | 3821 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3822 // <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
|
3823 // '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
|
3824 // CURS_RIGHT wraps to next line if 'whichwrap' has '>'. |
7 | 3825 if ( ((cap->cmdchar == ' ' |
3826 && vim_strchr(p_ww, 's') != NULL) | |
3827 || (cap->cmdchar == 'l' | |
3828 && vim_strchr(p_ww, 'l') != NULL) | |
229 | 3829 || (cap->cmdchar == K_RIGHT |
7 | 3830 && vim_strchr(p_ww, '>') != NULL)) |
3831 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
3832 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3833 // 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
|
3834 // 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
|
3835 // included, move to next line after that |
714 | 3836 if ( cap->oap->op_type != OP_NOP |
7 | 3837 && !cap->oap->inclusive |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3838 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3839 cap->oap->inclusive = TRUE; |
3840 else | |
3841 { | |
3842 ++curwin->w_cursor.lnum; | |
3843 curwin->w_cursor.col = 0; | |
3844 curwin->w_cursor.coladd = 0; | |
3845 curwin->w_set_curswant = TRUE; | |
3846 cap->oap->inclusive = FALSE; | |
3847 } | |
3848 continue; | |
3849 } | |
3850 if (cap->oap->op_type == OP_NOP) | |
3851 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3852 // Only beep and flush if not moved at all |
7 | 3853 if (n == cap->count1) |
3854 beep_flush(); | |
3855 } | |
3856 else | |
3857 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3858 if (!LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3859 cap->oap->inclusive = TRUE; |
3860 } | |
3861 break; | |
3862 } | |
5735 | 3863 else if (past_line) |
7 | 3864 { |
3865 curwin->w_set_curswant = TRUE; | |
3866 if (virtual_active()) | |
3867 oneright(); | |
3868 else | |
5735 | 3869 { |
7 | 3870 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
|
3871 curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); |
7 | 3872 else |
3873 ++curwin->w_cursor.col; | |
3874 } | |
3875 } | |
3876 } | |
3877 #ifdef FEAT_FOLDING | |
3878 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
3879 && cap->oap->op_type == OP_NOP) | |
3880 foldOpenCursor(); | |
3881 #endif | |
3882 } | |
3883 | |
3884 /* | |
3885 * Cursor left commands. | |
3886 * | |
3887 * Returns TRUE when operator end should not be adjusted. | |
3888 */ | |
3889 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3890 nv_left(cmdarg_T *cap) |
7 | 3891 { |
3892 long n; | |
3893 | |
180 | 3894 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
3895 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3896 // <C-Left> and <S-Left> move a word or WORD left |
180 | 3897 if (mod_mask & MOD_MASK_CTRL) |
3898 cap->arg = 1; | |
3899 nv_bck_word(cap); | |
3900 return; | |
3901 } | |
3902 | |
7 | 3903 cap->oap->motion_type = MCHAR; |
3904 cap->oap->inclusive = FALSE; | |
3905 for (n = cap->count1; n > 0; --n) | |
3906 { | |
3907 if (oneleft() == FAIL) | |
3908 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3909 // <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
|
3910 // '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
|
3911 // CURS_LEFT wraps to previous line if 'whichwrap' has '<'. |
7 | 3912 if ( (((cap->cmdchar == K_BS |
3913 || cap->cmdchar == Ctrl_H) | |
3914 && vim_strchr(p_ww, 'b') != NULL) | |
3915 || (cap->cmdchar == 'h' | |
3916 && vim_strchr(p_ww, 'h') != NULL) | |
229 | 3917 || (cap->cmdchar == K_LEFT |
7 | 3918 && vim_strchr(p_ww, '<') != NULL)) |
3919 && curwin->w_cursor.lnum > 1) | |
3920 { | |
3921 --(curwin->w_cursor.lnum); | |
3922 coladvance((colnr_T)MAXCOL); | |
3923 curwin->w_set_curswant = TRUE; | |
3924 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3925 // 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
|
3926 // 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
|
3927 // 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
|
3928 // Don't adjust op_end now, otherwise it won't work. |
7 | 3929 if ( (cap->oap->op_type == OP_DELETE |
3930 || 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
|
3931 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3932 { |
5682 | 3933 char_u *cp = ml_get_cursor(); |
3934 | |
3935 if (*cp != NUL) | |
3936 { | |
3937 if (has_mbyte) | |
3938 curwin->w_cursor.col += (*mb_ptr2len)(cp); | |
3939 else | |
3940 ++curwin->w_cursor.col; | |
3941 } | |
7 | 3942 cap->retval |= CA_NO_ADJ_OP_END; |
3943 } | |
3944 continue; | |
3945 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3946 // Only beep and flush if not moved at all |
7 | 3947 else if (cap->oap->op_type == OP_NOP && n == cap->count1) |
3948 beep_flush(); | |
3949 break; | |
3950 } | |
3951 } | |
3952 #ifdef FEAT_FOLDING | |
3953 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
3954 && cap->oap->op_type == OP_NOP) | |
3955 foldOpenCursor(); | |
3956 #endif | |
3957 } | |
3958 | |
3959 /* | |
3960 * Cursor up commands. | |
3961 * cap->arg is TRUE for "-": Move cursor to first non-blank. | |
3962 */ | |
3963 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3964 nv_up(cmdarg_T *cap) |
7 | 3965 { |
180 | 3966 if (mod_mask & MOD_MASK_SHIFT) |
3967 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3968 // <S-Up> is page up |
180 | 3969 cap->arg = BACKWARD; |
3970 nv_page(cap); | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3971 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3972 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3973 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3974 cap->oap->motion_type = MLINE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3975 if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3976 clearopbeep(cap->oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3977 else if (cap->arg) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
3978 beginline(BL_WHITE | BL_FIX); |
7 | 3979 } |
3980 | |
3981 /* | |
3982 * Cursor down commands. | |
3983 * cap->arg is TRUE for CR and "+": Move cursor to first non-blank. | |
3984 */ | |
3985 static void | |
10192
758f3d5a463d
commit https://github.com/vim/vim/commit/1b010058235fb803c1d4f42a02d2883921be8ef4
Christian Brabandt <cb@256bit.org>
parents:
10154
diff
changeset
|
3986 nv_down(cmdarg_T *cap) |
7 | 3987 { |
180 | 3988 if (mod_mask & MOD_MASK_SHIFT) |
3989 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3990 // <S-Down> is page down |
180 | 3991 cap->arg = FORWARD; |
3992 nv_page(cap); | |
3993 } | |
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
|
3994 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3995 // 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
|
3996 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
|
3997 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
|
3998 #endif |
180 | 3999 else |
7 | 4000 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4001 // In the cmdline window a <CR> executes the command. |
170 | 4002 if (cmdwin_type != 0 && cap->cmdchar == CAR) |
7 | 4003 cmdwin_result = CAR; |
4004 else | |
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
|
4005 #ifdef FEAT_JOB_CHANNEL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4006 // 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
|
4007 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
|
4008 && 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
|
4009 { |
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
|
4010 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
|
4011 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
|
4012 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
|
4013 } |
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 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
|
4015 #endif |
7 | 4016 { |
4017 cap->oap->motion_type = MLINE; | |
4018 if (cursor_down(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
4019 clearopbeep(cap->oap); | |
4020 else if (cap->arg) | |
4021 beginline(BL_WHITE | BL_FIX); | |
4022 } | |
4023 } | |
4024 } | |
4025 | |
4026 /* | |
4027 * Grab the file name under the cursor and edit it. | |
4028 */ | |
4029 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4030 nv_gotofile(cmdarg_T *cap) |
7 | 4031 { |
4032 char_u *ptr; | |
681 | 4033 linenr_T lnum = -1; |
7 | 4034 |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
4035 if (check_text_or_curbuf_locked(cap->oap)) |
7 | 4036 return; |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
4037 |
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
|
4038 #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
|
4039 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
|
4040 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
|
4041 #endif |
7 | 4042 |
681 | 4043 ptr = grab_file_name(cap->count1, &lnum); |
7 | 4044 |
4045 if (ptr != NULL) | |
4046 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4047 // 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
|
4048 if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !buf_hide(curbuf)) |
7009 | 4049 (void)autowrite(curbuf, FALSE); |
7 | 4050 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
|
4051 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
|
4052 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
|
4053 && cap->nchar == 'F' && lnum >= 0) |
681 | 4054 { |
4055 curwin->w_cursor.lnum = lnum; | |
4056 check_cursor_lnum(); | |
4057 beginline(BL_SOL | BL_FIX); | |
4058 } | |
7 | 4059 vim_free(ptr); |
4060 } | |
4061 else | |
4062 clearop(cap->oap); | |
4063 } | |
4064 | |
4065 /* | |
4066 * <End> command: to end of current line or last line. | |
4067 */ | |
4068 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4069 nv_end(cmdarg_T *cap) |
7 | 4070 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4071 if (cap->arg || (mod_mask & MOD_MASK_CTRL)) // CTRL-END = goto last line |
180 | 4072 { |
4073 cap->arg = TRUE; | |
7 | 4074 nv_goto(cap); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4075 cap->count1 = 1; // to end of current line |
7 | 4076 } |
4077 nv_dollar(cap); | |
4078 } | |
4079 | |
4080 /* | |
4081 * Handle the "$" command. | |
4082 */ | |
4083 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4084 nv_dollar(cmdarg_T *cap) |
7 | 4085 { |
4086 cap->oap->motion_type = MCHAR; | |
4087 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4088 // 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
|
4089 // 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
|
4090 // Otherwise, send it to the end of the line. |
7 | 4091 if (!virtual_active() || gchar_cursor() != NUL |
4092 || 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
|
4093 curwin->w_curswant = MAXCOL; // so we stay at the end |
7 | 4094 if (cursor_down((long)(cap->count1 - 1), |
4095 cap->oap->op_type == OP_NOP) == FAIL) | |
4096 clearopbeep(cap->oap); | |
4097 #ifdef FEAT_FOLDING | |
4098 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4099 foldOpenCursor(); | |
4100 #endif | |
4101 } | |
4102 | |
4103 /* | |
4104 * Implementation of '?' and '/' commands. | |
4105 * If cap->arg is TRUE don't set PC mark. | |
4106 */ | |
4107 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4108 nv_search(cmdarg_T *cap) |
7 | 4109 { |
4110 oparg_T *oap = cap->oap; | |
10098
72e4b7f90465
commit https://github.com/vim/vim/commit/dda933d06c06c2792bd686d059f6ad19191ad30b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4111 pos_T save_cursor = curwin->w_cursor; |
7 | 4112 |
4113 if (cap->cmdchar == '?' && cap->oap->op_type == OP_ROT13) | |
4114 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4115 // Translate "g??" to "g?g?" |
7 | 4116 cap->cmdchar = 'g'; |
4117 cap->nchar = '?'; | |
4118 nv_operator(cap); | |
4119 return; | |
4120 } | |
4121 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4122 // 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
|
4123 // start position. |
26804
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26749
diff
changeset
|
4124 cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, 0); |
7 | 4125 |
4126 if (cap->searchbuf == NULL) | |
4127 { | |
4128 clearop(oap); | |
4129 return; | |
4130 } | |
4131 | |
6620 | 4132 (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
|
4133 (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
|
4134 ? 0 : SEARCH_MARK, NULL); |
7 | 4135 } |
4136 | |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4137 |
7 | 4138 /* |
4139 * Handle "N" and "n" commands. | |
4140 * cap->arg is SEARCH_REV for "N", 0 for "n". | |
4141 */ | |
4142 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4143 nv_next(cmdarg_T *cap) |
7 | 4144 { |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4145 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
|
4146 int wrapped = FALSE; |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4147 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
|
4148 |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4149 if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor)) |
6620 | 4150 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4151 // 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
|
4152 // 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
|
4153 // in the buffer: Repeat with count + 1. |
6620 | 4154 cap->count1 += 1; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4155 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); |
6620 | 4156 cap->count1 -= 1; |
4157 } | |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4158 |
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4159 #ifdef FEAT_SEARCH_EXTRA |
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4160 // Redraw the window to refresh the highlighted matches. |
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4161 if (i > 0 && p_hls && !no_hlsearch) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4162 redraw_later(UPD_SOME_VALID); |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4163 #endif |
7 | 4164 } |
4165 | |
4166 /* | |
4167 * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat). | |
4168 * Uses only cap->count1 and cap->oap from "cap". | |
6620 | 4169 * Return 0 for failure, 1 for found, 2 for found and line offset added. |
4170 */ | |
4171 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4172 normal_search( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4173 cmdarg_T *cap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4174 int dir, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4175 char_u *pat, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4176 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
|
4177 int *wrapped) |
7 | 4178 { |
4179 int i; | |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4180 searchit_arg_T sia; |
28401
d1982178f787
patch 8.2.4725: unused variable in tiny build
Bram Moolenaar <Bram@vim.org>
parents:
28399
diff
changeset
|
4181 #ifdef FEAT_SEARCH_EXTRA |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4182 pos_T prev_cursor = curwin->w_cursor; |
28401
d1982178f787
patch 8.2.4725: unused variable in tiny build
Bram Moolenaar <Bram@vim.org>
parents:
28399
diff
changeset
|
4183 #endif |
7 | 4184 |
4185 cap->oap->motion_type = MCHAR; | |
4186 cap->oap->inclusive = FALSE; | |
4187 cap->oap->use_reg_one = TRUE; | |
4188 curwin->w_set_curswant = TRUE; | |
4189 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
4190 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
|
4191 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
|
4192 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
|
4193 if (wrapped != NULL) |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4194 *wrapped = sia.sa_wrapped; |
7 | 4195 if (i == 0) |
4196 clearop(cap->oap); | |
4197 else | |
4198 { | |
4199 if (i == 2) | |
4200 cap->oap->motion_type = MLINE; | |
4201 curwin->w_cursor.coladd = 0; | |
4202 #ifdef FEAT_FOLDING | |
4203 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4204 foldOpenCursor(); | |
4205 #endif | |
4206 } | |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4207 #ifdef FEAT_SEARCH_EXTRA |
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4208 // Redraw the window to refresh the highlighted matches. |
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4209 if (!EQUAL_POS(curwin->w_cursor, prev_cursor) && p_hls && !no_hlsearch) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4210 redraw_later(UPD_SOME_VALID); |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4211 #endif |
7 | 4212 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4213 // "/$" 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
|
4214 // correct that here |
7 | 4215 check_cursor(); |
6620 | 4216 return i; |
7 | 4217 } |
4218 | |
4219 /* | |
4220 * Character search commands. | |
4221 * cap->arg is BACKWARD for 'F' and 'T', FORWARD for 'f' and 't', TRUE for | |
4222 * ',' and FALSE for ';'. | |
4223 * cap->nchar is NUL for ',' and ';' (repeat the search) | |
4224 */ | |
4225 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4226 nv_csearch(cmdarg_T *cap) |
7 | 4227 { |
4228 int t_cmd; | |
4229 | |
4230 if (cap->cmdchar == 't' || cap->cmdchar == 'T') | |
4231 t_cmd = TRUE; | |
4232 else | |
4233 t_cmd = FALSE; | |
4234 | |
4235 cap->oap->motion_type = MCHAR; | |
4236 if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL) | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4237 { |
7 | 4238 clearopbeep(cap->oap); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4239 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4240 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4241 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4242 curwin->w_set_curswant = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4243 // Include a Tab for "tx" and for "dfx". |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4244 if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4245 && (t_cmd || cap->oap->op_type != OP_NOP)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4246 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4247 colnr_T scol, ecol; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4248 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4249 getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4250 curwin->w_cursor.coladd = ecol - scol; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4251 } |
7 | 4252 else |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4253 curwin->w_cursor.coladd = 0; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4254 adjust_for_sel(cap); |
7 | 4255 #ifdef FEAT_FOLDING |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4256 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4257 foldOpenCursor(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4258 #endif |
7 | 4259 } |
4260 | |
4261 /* | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4262 * "[{", "[(", "]}" 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
|
4263 * "[#", "]#": 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
|
4264 * "[/", "[*", "]/", "]*": 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
|
4265 * "[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
|
4266 * "[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
|
4267 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4268 static void |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4269 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
|
4270 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4271 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
|
4272 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
|
4273 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
|
4274 long n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4275 int findc; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4276 int c; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4277 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4278 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
|
4279 cap->nchar = '/'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4280 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
|
4281 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
|
4282 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4283 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
|
4284 findc = '{'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4285 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4286 findc = '}'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4287 n = 9999; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4288 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4289 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4290 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4291 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
|
4292 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
|
4293 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4294 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
|
4295 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4296 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
|
4297 (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
|
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 (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
|
4300 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4301 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
|
4302 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
|
4303 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4304 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4305 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
|
4306 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4307 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4308 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
|
4309 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
|
4310 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
|
4311 } |
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 = *old_pos; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4313 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4314 // 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
|
4315 // 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
|
4316 // 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
|
4317 // 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
|
4318 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
|
4319 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4320 // 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
|
4321 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
|
4322 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4323 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
|
4324 // 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
|
4325 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
|
4326 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4327 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
|
4328 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
|
4329 if (norm) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4330 --n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4331 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4332 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4333 pos = NULL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4334 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
|
4335 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4336 for (;;) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4337 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4338 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
|
4339 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4340 // 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
|
4341 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
|
4342 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
|
4343 n = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4344 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4345 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4346 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
|
4347 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
|
4348 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4349 // 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
|
4350 // 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
|
4351 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
|
4352 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4353 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
|
4354 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
|
4355 n = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4356 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4357 // 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
|
4358 // 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
|
4359 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
|
4360 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4361 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
|
4362 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
|
4363 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4364 // 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
|
4365 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
|
4366 (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
|
4367 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
|
4368 n = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4369 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4370 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
|
4371 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4372 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4373 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4374 --n; |
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 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
|
4377 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
|
4378 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
|
4379 } |
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) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4381 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4382 setpcmark(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4383 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
|
4384 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
|
4385 #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
|
4386 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
|
4387 && 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
|
4388 foldOpenCursor(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4389 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4390 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4391 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4392 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4393 /* |
7 | 4394 * "[" and "]" commands. |
4395 * cap->arg is BACKWARD for "[" and FORWARD for "]". | |
4396 */ | |
4397 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4398 nv_brackets(cmdarg_T *cap) |
7 | 4399 { |
4400 pos_T prev_pos; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4401 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
|
4402 pos_T old_pos; // cursor position before command |
7 | 4403 int flag; |
4404 long n; | |
4405 | |
4406 cap->oap->motion_type = MCHAR; | |
4407 cap->oap->inclusive = FALSE; | |
4408 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
|
4409 curwin->w_cursor.coladd = 0; // TODO: don't do this for an error. |
7 | 4410 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4411 // "[f" or "]f" : Edit file under the cursor (same as "gf") |
7 | 4412 if (cap->nchar == 'f') |
4413 nv_gotofile(cap); | |
4414 else | |
4415 | |
4416 #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
|
4417 // 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
|
4418 // 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
|
4419 // |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4420 // 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
|
4421 // 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
|
4422 // 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
|
4423 // 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
|
4424 if (vim_strchr((char_u *)"iI\011dD\004", cap->nchar) != NULL) |
7 | 4425 { |
4426 char_u *ptr; | |
4427 int len; | |
4428 | |
4429 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) | |
4430 clearop(cap->oap); | |
4431 else | |
4432 { | |
29004
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4433 // Make a copy, if the line was changed it will be freed. |
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4434 ptr = vim_strnsave(ptr, len); |
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4435 if (ptr == NULL) |
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4436 return; |
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4437 |
7 | 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); | |
29004
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4446 vim_free(ptr); |
7 | 4447 curwin->w_set_curswant = TRUE; |
4448 } | |
4449 } | |
4450 else | |
4451 #endif | |
4452 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4453 // "[{", "[(", "]}" 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
|
4454 // "[#", "]#": 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
|
4455 // "[/", "[*", "]/", "]*": 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
|
4456 // "[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
|
4457 // "[M" or "]M" search for prev/next end of (Java) method. |
7 | 4458 if ( (cap->cmdchar == '[' |
4459 && vim_strchr((char_u *)"{(*/#mM", cap->nchar) != NULL) | |
4460 || (cap->cmdchar == ']' | |
4461 && 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
|
4462 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
|
4463 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4464 // "[[", "[]", "]]" and "][": move to start or end of function |
7 | 4465 else if (cap->nchar == '[' || cap->nchar == ']') |
4466 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4467 if (cap->nchar == cap->cmdchar) // "]]" or "[[" |
7 | 4468 flag = '{'; |
4469 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4470 flag = '}'; // "][" or "[]" |
7 | 4471 |
4472 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
|
4473 // 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
|
4474 // we also stop at '}'. |
503 | 4475 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, flag, |
7 | 4476 (cap->oap->op_type != OP_NOP |
4477 && cap->arg == FORWARD && flag == '{'))) | |
4478 clearopbeep(cap->oap); | |
4479 else | |
4480 { | |
4481 if (cap->oap->op_type == OP_NOP) | |
4482 beginline(BL_WHITE | BL_FIX); | |
4483 #ifdef FEAT_FOLDING | |
4484 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4485 foldOpenCursor(); | |
4486 #endif | |
4487 } | |
4488 } | |
4489 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4490 // "[p", "[P", "]P" and "]p": put with indent adjustment |
7 | 4491 else if (cap->nchar == 'p' || cap->nchar == 'P') |
4492 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
4493 nv_put_opt(cap, TRUE); |
7 | 4494 } |
4495 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4496 // "['", "[`", "]'" and "]`": jump to next mark |
7 | 4497 else if (cap->nchar == '\'' || cap->nchar == '`') |
4498 { | |
4499 pos = &curwin->w_cursor; | |
4500 for (n = cap->count1; n > 0; --n) | |
4501 { | |
4502 prev_pos = *pos; | |
4503 pos = getnextmark(pos, cap->cmdchar == '[' ? BACKWARD : FORWARD, | |
4504 cap->nchar == '\''); | |
4505 if (pos == NULL) | |
4506 break; | |
4507 } | |
4508 if (pos == NULL) | |
4509 pos = &prev_pos; | |
4510 nv_cursormark(cap, cap->nchar == '\'', pos); | |
4511 } | |
4512 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4513 // [ 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
|
4514 // 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
|
4515 else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) |
7 | 4516 { |
4517 (void)do_mouse(cap->oap, cap->nchar, | |
4518 (cap->cmdchar == ']') ? FORWARD : BACKWARD, | |
4519 cap->count1, PUT_FIXINDENT); | |
4520 } | |
4521 | |
4522 #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
|
4523 // "[z" and "]z": move to start or end of open fold. |
7 | 4524 else if (cap->nchar == 'z') |
4525 { | |
4526 if (foldMoveTo(FALSE, cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4527 cap->count1) == FAIL) | |
4528 clearopbeep(cap->oap); | |
4529 } | |
4530 #endif | |
4531 | |
4532 #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
|
4533 // "[c" and "]c": move to next or previous diff-change. |
7 | 4534 else if (cap->nchar == 'c') |
4535 { | |
4536 if (diff_move_to(cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4537 cap->count1) == FAIL) | |
4538 clearopbeep(cap->oap); | |
4539 } | |
4540 #endif | |
4541 | |
737 | 4542 #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
|
4543 // "[s", "[S", "]s" and "]S": move to next spell error. |
236 | 4544 else if (cap->nchar == 's' || cap->nchar == 'S') |
4545 { | |
249 | 4546 setpcmark(); |
4547 for (n = 0; n < cap->count1; ++n) | |
498 | 4548 if (spell_move_to(curwin, cap->cmdchar == ']' ? FORWARD : BACKWARD, |
4549 cap->nchar == 's' ? TRUE : FALSE, FALSE, NULL) == 0) | |
249 | 4550 { |
4551 clearopbeep(cap->oap); | |
4552 break; | |
4553 } | |
13088
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4554 else |
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4555 curwin->w_set_curswant = TRUE; |
819 | 4556 # ifdef FEAT_FOLDING |
4557 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4558 foldOpenCursor(); | |
4559 # endif | |
236 | 4560 } |
4561 #endif | |
4562 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4563 // Not a valid cap->nchar. |
7 | 4564 else |
4565 clearopbeep(cap->oap); | |
4566 } | |
4567 | |
4568 /* | |
4569 * Handle Normal mode "%" command. | |
4570 */ | |
4571 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4572 nv_percent(cmdarg_T *cap) |
7 | 4573 { |
4574 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
|
4575 #if defined(FEAT_FOLDING) |
7 | 4576 linenr_T lnum = curwin->w_cursor.lnum; |
4577 #endif | |
4578 | |
4579 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4580 if (cap->count0) // {cnt}% : goto {cnt} percentage in file |
7 | 4581 { |
4582 if (cap->count0 > 100) | |
4583 clearopbeep(cap->oap); | |
4584 else | |
4585 { | |
4586 cap->oap->motion_type = MLINE; | |
4587 setpcmark(); | |
24010
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4588 // 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
|
4589 // 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
|
4590 // 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
|
4591 // to avoid overflows. |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4592 if (curbuf->b_ml.ml_line_count >= 21474836) |
7 | 4593 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L) |
4594 / 100L * cap->count0; | |
4595 else | |
4596 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count * | |
4597 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
|
4598 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
|
4599 curwin->w_cursor.lnum = 1; |
7 | 4600 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
4601 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
4602 beginline(BL_SOL | BL_FIX); | |
4603 } | |
4604 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4605 else // "%" : go to matching paren |
7 | 4606 { |
4607 cap->oap->motion_type = MCHAR; | |
4608 cap->oap->use_reg_one = TRUE; | |
4609 if ((pos = findmatch(cap->oap, NUL)) == NULL) | |
4610 clearopbeep(cap->oap); | |
4611 else | |
4612 { | |
4613 setpcmark(); | |
4614 curwin->w_cursor = *pos; | |
4615 curwin->w_set_curswant = TRUE; | |
4616 curwin->w_cursor.coladd = 0; | |
4617 adjust_for_sel(cap); | |
4618 } | |
4619 } | |
4620 #ifdef FEAT_FOLDING | |
4621 if (cap->oap->op_type == OP_NOP | |
4622 && lnum != curwin->w_cursor.lnum | |
4623 && (fdo_flags & FDO_PERCENT) | |
4624 && KeyTyped) | |
4625 foldOpenCursor(); | |
4626 #endif | |
4627 } | |
4628 | |
4629 /* | |
4630 * Handle "(" and ")" commands. | |
4631 * cap->arg is BACKWARD for "(" and FORWARD for ")". | |
4632 */ | |
4633 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4634 nv_brace(cmdarg_T *cap) |
7 | 4635 { |
4636 cap->oap->motion_type = MCHAR; | |
4637 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
|
4638 // The motion used to be inclusive for "(", but that is not what Vi does. |
620 | 4639 cap->oap->inclusive = FALSE; |
7 | 4640 curwin->w_set_curswant = TRUE; |
4641 | |
4642 if (findsent(cap->arg, cap->count1) == FAIL) | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4643 { |
7 | 4644 clearopbeep(cap->oap); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4645 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4646 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4647 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4648 // Don't leave the cursor on the NUL past end of line. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4649 adjust_cursor(cap->oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4650 curwin->w_cursor.coladd = 0; |
7 | 4651 #ifdef FEAT_FOLDING |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4652 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4653 foldOpenCursor(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4654 #endif |
7 | 4655 } |
4656 | |
4657 /* | |
4658 * "m" command: Mark a position. | |
4659 */ | |
4660 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4661 nv_mark(cmdarg_T *cap) |
7 | 4662 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4663 if (checkclearop(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4664 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4665 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4666 if (setmark(cap->nchar) == FAIL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4667 clearopbeep(cap->oap); |
7 | 4668 } |
4669 | |
4670 /* | |
4671 * "{" and "}" commands. | |
4672 * cmd->arg is BACKWARD for "{" and FORWARD for "}". | |
4673 */ | |
4674 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4675 nv_findpar(cmdarg_T *cap) |
7 | 4676 { |
4677 cap->oap->motion_type = MCHAR; | |
4678 cap->oap->inclusive = FALSE; | |
4679 cap->oap->use_reg_one = TRUE; | |
4680 curwin->w_set_curswant = TRUE; | |
503 | 4681 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE)) |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4682 { |
7 | 4683 clearopbeep(cap->oap); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4684 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4685 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4686 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4687 curwin->w_cursor.coladd = 0; |
7 | 4688 #ifdef FEAT_FOLDING |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4689 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4690 foldOpenCursor(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4691 #endif |
7 | 4692 } |
4693 | |
4694 /* | |
4695 * "u" command: Undo or make lower case. | |
4696 */ | |
4697 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4698 nv_undo(cmdarg_T *cap) |
7 | 4699 { |
5735 | 4700 if (cap->oap->op_type == OP_LOWER || VIsual_active) |
7 | 4701 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4702 // translate "<Visual>u" to "<Visual>gu" and "guu" to "gugu" |
7 | 4703 cap->cmdchar = 'g'; |
4704 cap->nchar = 'u'; | |
4705 nv_operator(cap); | |
4706 } | |
4707 else | |
4708 nv_kundo(cap); | |
4709 } | |
4710 | |
4711 /* | |
4712 * <Undo> command. | |
4713 */ | |
4714 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4715 nv_kundo(cmdarg_T *cap) |
7 | 4716 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4717 if (checkclearopq(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4718 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4719 |
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
|
4720 #ifdef FEAT_JOB_CHANNEL |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4721 if (bt_prompt(curbuf)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4722 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4723 clearopbeep(cap->oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4724 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4725 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4726 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4727 u_undo((int)cap->count1); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4728 curwin->w_set_curswant = TRUE; |
7 | 4729 } |
4730 | |
4731 /* | |
4732 * Handle the "r" command. | |
4733 */ | |
4734 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4735 nv_replace(cmdarg_T *cap) |
7 | 4736 { |
4737 char_u *ptr; | |
4738 int had_ctrl_v; | |
4739 long n; | |
4740 | |
4741 if (checkclearop(cap->oap)) | |
4742 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
|
4743 #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
|
4744 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
|
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 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
|
4747 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
|
4748 } |
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
|
4749 #endif |
7 | 4750 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4751 // get another character |
7 | 4752 if (cap->nchar == Ctrl_V) |
4753 { | |
4754 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
|
4755 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
|
4756 // Don't redo a multibyte character with CTRL-V. |
7 | 4757 if (cap->nchar > DEL) |
4758 had_ctrl_v = NUL; | |
4759 } | |
4760 else | |
4761 had_ctrl_v = NUL; | |
4762 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4763 // Abort if the character is a special key. |
1343 | 4764 if (IS_SPECIAL(cap->nchar)) |
4765 { | |
4766 clearopbeep(cap->oap); | |
4767 return; | |
4768 } | |
4769 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4770 // Visual mode "r" |
7 | 4771 if (VIsual_active) |
4772 { | |
1797 | 4773 if (got_int) |
4774 reset_VIsual(); | |
5428 | 4775 if (had_ctrl_v) |
4776 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4777 // 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
|
4778 // 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
|
4779 if (cap->nchar == CAR) |
2941a86f8aaa
patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents:
13088
diff
changeset
|
4780 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
|
4781 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
|
4782 cap->nchar = REPLACE_NL_NCHAR; |
5428 | 4783 } |
7 | 4784 nv_operator(cap); |
4785 return; | |
4786 } | |
4787 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4788 // Break tabs, etc. |
7 | 4789 if (virtual_active()) |
4790 { | |
4791 if (u_save_cursor() == FAIL) | |
4792 return; | |
4793 if (gchar_cursor() == NUL) | |
4794 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4795 // Add extra space and put the cursor on the first one. |
7 | 4796 coladvance_force((colnr_T)(getviscol() + cap->count1)); |
4797 curwin->w_cursor.col -= cap->count1; | |
4798 } | |
4799 else if (gchar_cursor() == TAB) | |
4800 coladvance_force(getviscol()); | |
4801 } | |
4802 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4803 // Abort if not enough characters to replace. |
7 | 4804 ptr = ml_get_cursor(); |
1343 | 4805 if (STRLEN(ptr) < (unsigned)cap->count1 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4806 || (has_mbyte && mb_charlen(ptr) < cap->count1)) |
7 | 4807 { |
4808 clearopbeep(cap->oap); | |
4809 return; | |
4810 } | |
4811 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4812 // 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
|
4813 // '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
|
4814 // 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
|
4815 // CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC). |
7 | 4816 if (had_ctrl_v != Ctrl_V && cap->nchar == '\t' && (curbuf->b_p_et || p_sta)) |
4817 { | |
4818 stuffnumReadbuff(cap->count1); | |
4819 stuffcharReadbuff('R'); | |
4820 stuffcharReadbuff('\t'); | |
4821 stuffcharReadbuff(ESC); | |
4822 return; | |
4823 } | |
4824 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4825 // save line for undo |
7 | 4826 if (u_save_cursor() == FAIL) |
4827 return; | |
4828 | |
4829 if (had_ctrl_v != Ctrl_V && (cap->nchar == '\r' || cap->nchar == '\n')) | |
4830 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4831 // 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
|
4832 // 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
|
4833 // 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
|
4834 // 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
|
4835 // 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
|
4836 // 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
|
4837 (void)del_chars(cap->count1, FALSE); // delete the characters |
7 | 4838 stuffcharReadbuff('\r'); |
4839 stuffcharReadbuff(ESC); | |
4840 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4841 // Give 'r' to edit(), to get the redo command right. |
7 | 4842 invoke_edit(cap, TRUE, 'r', FALSE); |
4843 } | |
4844 else | |
4845 { | |
4846 prep_redo(cap->oap->regname, cap->count1, | |
4847 NUL, 'r', NUL, had_ctrl_v, cap->nchar); | |
4848 | |
4849 curbuf->b_op_start = curwin->w_cursor; | |
4850 if (has_mbyte) | |
4851 { | |
4852 int old_State = State; | |
4853 | |
4854 if (cap->ncharC1 != 0) | |
4855 AppendCharToRedobuff(cap->ncharC1); | |
4856 if (cap->ncharC2 != 0) | |
4857 AppendCharToRedobuff(cap->ncharC2); | |
4858 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4859 // 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
|
4860 // 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
|
4861 // composing characters for utf-8. |
7 | 4862 for (n = cap->count1; n > 0; --n) |
4863 { | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
4864 State = MODE_REPLACE; |
3501 | 4865 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
4866 { | |
4867 int c = ins_copychar(curwin->w_cursor.lnum | |
4868 + (cap->nchar == Ctrl_Y ? -1 : 1)); | |
4869 if (c != NUL) | |
4870 ins_char(c); | |
4871 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4872 // will be decremented further down |
3501 | 4873 ++curwin->w_cursor.col; |
4874 } | |
4875 else | |
4876 ins_char(cap->nchar); | |
7 | 4877 State = old_State; |
4878 if (cap->ncharC1 != 0) | |
4879 ins_char(cap->ncharC1); | |
4880 if (cap->ncharC2 != 0) | |
4881 ins_char(cap->ncharC2); | |
4882 } | |
4883 } | |
4884 else | |
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 // Replace the characters within one line. |
7 | 4887 for (n = cap->count1; n > 0; --n) |
4888 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4889 // 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
|
4890 // 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
|
4891 // At the same time we let know that the line will be changed. |
3501 | 4892 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
4893 { | |
4894 int c = ins_copychar(curwin->w_cursor.lnum | |
4895 + (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
|
4896 |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4897 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); |
3501 | 4898 if (c != NUL) |
4899 ptr[curwin->w_cursor.col] = c; | |
4900 } | |
4901 else | |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4902 { |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4903 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); |
3501 | 4904 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
|
4905 } |
7 | 4906 if (p_sm && msg_silent == 0) |
4907 showmatch(cap->nchar); | |
4908 ++curwin->w_cursor.col; | |
4909 } | |
4910 #ifdef FEAT_NETBEANS_INTG | |
2210 | 4911 if (netbeans_active()) |
7 | 4912 { |
2210 | 4913 colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1); |
7 | 4914 |
33 | 4915 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
|
4916 cap->count1); |
7 | 4917 netbeans_inserted(curbuf, curwin->w_cursor.lnum, start, |
33 | 4918 &ptr[start], (int)cap->count1); |
7 | 4919 } |
4920 #endif | |
4921 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4922 // mark the buffer as changed and prepare for displaying |
7 | 4923 changed_bytes(curwin->w_cursor.lnum, |
4924 (colnr_T)(curwin->w_cursor.col - cap->count1)); | |
4925 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4926 --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
|
4927 // 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
|
4928 // character, move two characters left |
7 | 4929 if (has_mbyte) |
4930 mb_adjust_cursor(); | |
4931 curbuf->b_op_end = curwin->w_cursor; | |
4932 curwin->w_set_curswant = TRUE; | |
4933 set_last_insert(cap->nchar); | |
4934 } | |
4935 } | |
4936 | |
4937 /* | |
4938 * 'o': Exchange start and end of Visual area. | |
4939 * 'O': same, but in block mode exchange left and right corners. | |
4940 */ | |
4941 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4942 v_swap_corners(int cmdchar) |
7 | 4943 { |
4944 pos_T old_cursor; | |
4945 colnr_T left, right; | |
4946 | |
4947 if (cmdchar == 'O' && VIsual_mode == Ctrl_V) | |
4948 { | |
4949 old_cursor = curwin->w_cursor; | |
4950 getvcols(curwin, &old_cursor, &VIsual, &left, &right); | |
4951 curwin->w_cursor.lnum = VIsual.lnum; | |
4952 coladvance(left); | |
4953 VIsual = curwin->w_cursor; | |
4954 | |
4955 curwin->w_cursor.lnum = old_cursor.lnum; | |
4956 curwin->w_curswant = right; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4957 // '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
|
4958 // right one column |
7 | 4959 if (old_cursor.lnum >= VIsual.lnum && *p_sel == 'e') |
4960 ++curwin->w_curswant; | |
4961 coladvance(curwin->w_curswant); | |
4962 if (curwin->w_cursor.col == old_cursor.col | |
4963 && (!virtual_active() | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4964 || curwin->w_cursor.coladd == old_cursor.coladd)) |
7 | 4965 { |
4966 curwin->w_cursor.lnum = VIsual.lnum; | |
4967 if (old_cursor.lnum <= VIsual.lnum && *p_sel == 'e') | |
4968 ++right; | |
4969 coladvance(right); | |
4970 VIsual = curwin->w_cursor; | |
4971 | |
4972 curwin->w_cursor.lnum = old_cursor.lnum; | |
4973 coladvance(left); | |
4974 curwin->w_curswant = left; | |
4975 } | |
4976 } | |
4977 else | |
4978 { | |
4979 old_cursor = curwin->w_cursor; | |
4980 curwin->w_cursor = VIsual; | |
4981 VIsual = old_cursor; | |
4982 curwin->w_set_curswant = TRUE; | |
4983 } | |
4984 } | |
4985 | |
4986 /* | |
4987 * "R" (cap->arg is FALSE) and "gR" (cap->arg is TRUE). | |
4988 */ | |
4989 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4990 nv_Replace(cmdarg_T *cap) |
7 | 4991 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4992 if (VIsual_active) // "R" is replace lines |
7 | 4993 { |
4994 cap->cmdchar = 'c'; | |
4995 cap->nchar = NUL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4996 VIsual_mode_orig = VIsual_mode; // remember original area for gv |
7 | 4997 VIsual_mode = 'V'; |
4998 nv_operator(cap); | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
4999 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5000 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5001 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5002 if (checkclearopq(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5003 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5004 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5005 if (!curbuf->b_p_ma) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5006 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5007 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5008 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5009 if (virtual_active()) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5010 coladvance(getviscol()); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5011 invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE); |
7 | 5012 } |
5013 } | |
5014 | |
5015 /* | |
5016 * "gr". | |
5017 */ | |
5018 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5019 nv_vreplace(cmdarg_T *cap) |
7 | 5020 { |
5021 if (VIsual_active) | |
5022 { | |
5023 cap->cmdchar = 'r'; | |
5024 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
|
5025 nv_replace(cap); // Do same as "r" in Visual mode for now |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5026 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5027 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5028 |
32108
cbf0ed5c83d0
patch 9.0.1385: g'Esc is considered an error
Bram Moolenaar <Bram@vim.org>
parents:
32049
diff
changeset
|
5029 if (checkclearopq(cap->oap)) |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5030 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5031 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5032 if (!curbuf->b_p_ma) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5033 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5034 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5035 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5036 if (cap->extra_char == Ctrl_V) // get another character |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5037 cap->extra_char = get_literal(FALSE); |
32045
55926b4f2246
patch 9.0.1354: "gr CTRL-G" stays in virtual replace mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5038 if (cap->extra_char < ' ') |
55926b4f2246
patch 9.0.1354: "gr CTRL-G" stays in virtual replace mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5039 // Prefix a control character with CTRL-V to avoid it being used as |
55926b4f2246
patch 9.0.1354: "gr CTRL-G" stays in virtual replace mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5040 // a command. |
55926b4f2246
patch 9.0.1354: "gr CTRL-G" stays in virtual replace mode
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5041 stuffcharReadbuff(Ctrl_V); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5042 stuffcharReadbuff(cap->extra_char); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5043 stuffcharReadbuff(ESC); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5044 if (virtual_active()) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5045 coladvance(getviscol()); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5046 invoke_edit(cap, TRUE, 'v', FALSE); |
7 | 5047 } |
5048 } | |
5049 | |
5050 /* | |
5051 * Swap case for "~" command, when it does not work like an operator. | |
5052 */ | |
5053 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5054 n_swapchar(cmdarg_T *cap) |
7 | 5055 { |
5056 long n; | |
5057 pos_T startpos; | |
5058 int did_change = 0; | |
5059 #ifdef FEAT_NETBEANS_INTG | |
5060 pos_T pos; | |
5061 char_u *ptr; | |
5062 int count; | |
5063 #endif | |
5064 | |
5065 if (checkclearopq(cap->oap)) | |
5066 return; | |
5067 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5068 if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) |
7 | 5069 { |
5070 clearopbeep(cap->oap); | |
5071 return; | |
5072 } | |
5073 | |
5074 prep_redo_cmd(cap); | |
5075 | |
5076 if (u_save_cursor() == FAIL) | |
5077 return; | |
5078 | |
5079 startpos = curwin->w_cursor; | |
5080 #ifdef FEAT_NETBEANS_INTG | |
5081 pos = startpos; | |
5082 #endif | |
5083 for (n = cap->count1; n > 0; --n) | |
5084 { | |
5085 did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); | |
5086 inc_cursor(); | |
5087 if (gchar_cursor() == NUL) | |
5088 { | |
5089 if (vim_strchr(p_ww, '~') != NULL | |
5090 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
5091 { | |
5092 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5093 if (netbeans_active()) |
7 | 5094 { |
5095 if (did_change) | |
5096 { | |
5097 ptr = ml_get(pos.lnum); | |
835 | 5098 count = (int)STRLEN(ptr) - pos.col; |
33 | 5099 netbeans_removed(curbuf, pos.lnum, pos.col, |
5100 (long)count); | |
29340
fba9e366ced4
patch 9.0.0013: reproducing memory access errors can be difficult
Bram Moolenaar <Bram@vim.org>
parents:
29179
diff
changeset
|
5101 // line may have been flushed, get it again |
fba9e366ced4
patch 9.0.0013: reproducing memory access errors can be difficult
Bram Moolenaar <Bram@vim.org>
parents:
29179
diff
changeset
|
5102 ptr = ml_get(pos.lnum); |
7 | 5103 netbeans_inserted(curbuf, pos.lnum, pos.col, |
33 | 5104 &ptr[pos.col], count); |
7 | 5105 } |
5106 pos.col = 0; | |
5107 pos.lnum++; | |
5108 } | |
5109 #endif | |
5110 ++curwin->w_cursor.lnum; | |
5111 curwin->w_cursor.col = 0; | |
5112 if (n > 1) | |
5113 { | |
5114 if (u_savesub(curwin->w_cursor.lnum) == FAIL) | |
5115 break; | |
5116 u_clearline(); | |
5117 } | |
5118 } | |
5119 else | |
5120 break; | |
5121 } | |
5122 } | |
5123 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5124 if (did_change && netbeans_active()) |
7 | 5125 { |
5126 ptr = ml_get(pos.lnum); | |
5127 count = curwin->w_cursor.col - pos.col; | |
33 | 5128 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count); |
5129 netbeans_inserted(curbuf, pos.lnum, pos.col, &ptr[pos.col], count); | |
7 | 5130 } |
5131 #endif | |
5132 | |
5133 | |
5134 check_cursor(); | |
5135 curwin->w_set_curswant = TRUE; | |
5136 if (did_change) | |
5137 { | |
5138 changed_lines(startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1, | |
5139 0L); | |
5140 curbuf->b_op_start = startpos; | |
5141 curbuf->b_op_end = curwin->w_cursor; | |
5142 if (curbuf->b_op_end.col > 0) | |
5143 --curbuf->b_op_end.col; | |
5144 } | |
5145 } | |
5146 | |
5147 /* | |
5148 * Move cursor to mark. | |
5149 */ | |
5150 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5151 nv_cursormark(cmdarg_T *cap, int flag, pos_T *pos) |
7 | 5152 { |
5153 if (check_mark(pos) == FAIL) | |
5154 clearop(cap->oap); | |
5155 else | |
5156 { | |
5157 if (cap->cmdchar == '\'' | |
5158 || cap->cmdchar == '`' | |
5159 || cap->cmdchar == '[' | |
5160 || cap->cmdchar == ']') | |
5161 setpcmark(); | |
5162 curwin->w_cursor = *pos; | |
5163 if (flag) | |
5164 beginline(BL_WHITE | BL_FIX); | |
5165 else | |
5166 check_cursor(); | |
5167 } | |
5168 cap->oap->motion_type = flag ? MLINE : MCHAR; | |
5169 if (cap->cmdchar == '`') | |
5170 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
|
5171 cap->oap->inclusive = FALSE; // ignored if not MCHAR |
7 | 5172 curwin->w_set_curswant = TRUE; |
5173 } | |
5174 | |
5175 /* | |
5176 * Handle commands that are operators in Visual mode. | |
5177 */ | |
5178 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5179 v_visop(cmdarg_T *cap) |
7 | 5180 { |
5181 static char_u trans[] = "YyDdCcxdXdAAIIrr"; | |
5182 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5183 // 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
|
5184 // the end of the line, and "C" replaces till EOL |
7 | 5185 if (isupper(cap->cmdchar)) |
5186 { | |
5187 if (VIsual_mode != Ctrl_V) | |
4213 | 5188 { |
5189 VIsual_mode_orig = VIsual_mode; | |
7 | 5190 VIsual_mode = 'V'; |
4213 | 5191 } |
7 | 5192 else if (cap->cmdchar == 'C' || cap->cmdchar == 'D') |
5193 curwin->w_curswant = MAXCOL; | |
5194 } | |
5195 cap->cmdchar = *(vim_strchr(trans, cap->cmdchar) + 1); | |
5196 nv_operator(cap); | |
5197 } | |
5198 | |
5199 /* | |
5200 * "s" and "S" commands. | |
5201 */ | |
5202 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5203 nv_subst(cmdarg_T *cap) |
7 | 5204 { |
13298
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5205 #ifdef FEAT_TERMINAL |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
23165
diff
changeset
|
5206 // 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
|
5207 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
|
5208 return; |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5209 #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
|
5210 #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
|
5211 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
|
5212 { |
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
|
5213 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
|
5214 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
|
5215 } |
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
|
5216 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5217 if (VIsual_active) // "vs" and "vS" are the same as "vc" |
7 | 5218 { |
5219 if (cap->cmdchar == 'S') | |
4213 | 5220 { |
5221 VIsual_mode_orig = VIsual_mode; | |
7 | 5222 VIsual_mode = 'V'; |
4213 | 5223 } |
7 | 5224 cap->cmdchar = 'c'; |
5225 nv_operator(cap); | |
5226 } | |
5227 else | |
5228 nv_optrans(cap); | |
5229 } | |
5230 | |
5231 /* | |
5232 * Abbreviated commands. | |
5233 */ | |
5234 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5235 nv_abbrev(cmdarg_T *cap) |
7 | 5236 { |
5237 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
|
5238 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
|
5239 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5240 // in Visual mode these commands are operators |
7 | 5241 if (VIsual_active) |
5242 v_visop(cap); | |
5243 else | |
5244 nv_optrans(cap); | |
5245 } | |
5246 | |
5247 /* | |
5248 * Translate a command into another command. | |
5249 */ | |
5250 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5251 nv_optrans(cmdarg_T *cap) |
7 | 5252 { |
5253 static char_u *(ar[8]) = {(char_u *)"dl", (char_u *)"dh", | |
5254 (char_u *)"d$", (char_u *)"c$", | |
5255 (char_u *)"cl", (char_u *)"cc", | |
5256 (char_u *)"yy", (char_u *)":s\r"}; | |
5257 static char_u *str = (char_u *)"xXDCsSY&"; | |
5258 | |
5259 if (!checkclearopq(cap->oap)) | |
5260 { | |
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
|
5261 // 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
|
5262 // either, because "2." should also not use the count. |
164 | 5263 if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL) |
5264 { | |
5265 cap->oap->start = curwin->w_cursor; | |
5266 cap->oap->op_type = OP_DELETE; | |
1490 | 5267 #ifdef FEAT_EVAL |
5268 set_op_var(OP_DELETE); | |
5269 #endif | |
164 | 5270 cap->count1 = 1; |
5271 nv_dollar(cap); | |
5272 finish_op = TRUE; | |
5273 ResetRedobuff(); | |
5274 AppendCharToRedobuff('D'); | |
5275 } | |
5276 else | |
5277 { | |
5278 if (cap->count0) | |
5279 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
|
5280 stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]); |
164 | 5281 } |
7 | 5282 } |
5283 cap->opcount = 0; | |
5284 } | |
5285 | |
5286 /* | |
5287 * "'" and "`" commands. Also for "g'" and "g`". | |
5288 * cap->arg is TRUE for "'" and "g'". | |
5289 */ | |
5290 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5291 nv_gomark(cmdarg_T *cap) |
7 | 5292 { |
5293 pos_T *pos; | |
5294 int c; | |
5295 #ifdef FEAT_FOLDING | |
4017 | 5296 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
|
5297 int old_KeyTyped = KeyTyped; // getting file may reset it |
7 | 5298 #endif |
5299 | |
5300 if (cap->cmdchar == 'g') | |
5301 c = cap->extra_char; | |
5302 else | |
5303 c = cap->nchar; | |
5304 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
|
5305 if (pos == (pos_T *)-1) // jumped to other file |
7 | 5306 { |
5307 if (cap->arg) | |
5308 { | |
5309 check_cursor_lnum(); | |
5310 beginline(BL_WHITE | BL_FIX); | |
5311 } | |
5312 else | |
5313 check_cursor(); | |
5314 } | |
5315 else | |
5316 nv_cursormark(cap, cap->arg, pos); | |
5317 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5318 // May need to clear the coladd that a mark includes. |
7 | 5319 if (!virtual_active()) |
5320 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
|
5321 check_cursor_col(); |
7 | 5322 #ifdef FEAT_FOLDING |
5323 if (cap->oap->op_type == OP_NOP | |
4057 | 5324 && pos != NULL |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5325 && (pos == (pos_T *)-1 || !EQUAL_POS(old_cursor, *pos)) |
7 | 5326 && (fdo_flags & FDO_MARK) |
5327 && old_KeyTyped) | |
5328 foldOpenCursor(); | |
5329 #endif | |
5330 } | |
5331 | |
5332 /* | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5333 * Handle CTRL-O, CTRL-I, "g;", "g," and "CTRL-Tab" commands. |
7 | 5334 */ |
5335 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5336 nv_pcmark(cmdarg_T *cap) |
7 | 5337 { |
5338 pos_T *pos; | |
26532
255bc9a08e58
patch 8.2.3795: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
26516
diff
changeset
|
5339 #ifdef FEAT_FOLDING |
7 | 5340 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
|
5341 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
|
5342 #endif |
7 | 5343 |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5344 if (checkclearopq(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5345 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5346 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5347 if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5348 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5349 if (goto_tabpage_lastused() == FAIL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5350 clearopbeep(cap->oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5351 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5352 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5353 if (cap->cmdchar == 'g') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5354 pos = movechangelist((int)cap->count1); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5355 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5356 pos = movemark((int)cap->count1); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5357 if (pos == (pos_T *)-1) // jump to other file |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5358 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5359 curwin->w_set_curswant = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5360 check_cursor(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5361 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5362 else if (pos != NULL) // can jump |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5363 nv_cursormark(cap, FALSE, pos); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5364 else if (cap->cmdchar == 'g') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5365 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5366 if (curbuf->b_changelistlen == 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5367 emsg(_(e_changelist_is_empty)); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5368 else if (cap->count1 < 0) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5369 emsg(_(e_at_start_of_changelist)); |
7 | 5370 else |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5371 emsg(_(e_at_end_of_changelist)); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5372 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5373 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5374 clearopbeep(cap->oap); |
7 | 5375 # ifdef FEAT_FOLDING |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5376 if (cap->oap->op_type == OP_NOP |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5377 && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5378 && (fdo_flags & FDO_MARK) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5379 && old_KeyTyped) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
5380 foldOpenCursor(); |
7 | 5381 # endif |
5382 } | |
5383 | |
5384 /* | |
5385 * Handle '"' command. | |
5386 */ | |
5387 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5388 nv_regname(cmdarg_T *cap) |
7 | 5389 { |
5390 if (checkclearop(cap->oap)) | |
5391 return; | |
5392 #ifdef FEAT_EVAL | |
5393 if (cap->nchar == '=') | |
5394 cap->nchar = get_expr_register(); | |
5395 #endif | |
5396 if (cap->nchar != NUL && valid_yank_reg(cap->nchar, FALSE)) | |
5397 { | |
5398 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
|
5399 cap->opcount = cap->count0; // remember count before '"' |
7 | 5400 #ifdef FEAT_EVAL |
5401 set_reg_var(cap->oap->regname); | |
5402 #endif | |
5403 } | |
5404 else | |
5405 clearopbeep(cap->oap); | |
5406 } | |
5407 | |
5408 /* | |
5409 * Handle "v", "V" and "CTRL-V" commands. | |
5410 * Also for "gh", "gH" and "g^H" commands: Always start Select mode, cap->arg | |
5411 * is TRUE. | |
167 | 5412 * Handle CTRL-Q just like CTRL-V. |
7 | 5413 */ |
5414 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5415 nv_visual(cmdarg_T *cap) |
7 | 5416 { |
167 | 5417 if (cap->cmdchar == Ctrl_Q) |
5418 cap->cmdchar = Ctrl_V; | |
5419 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5420 // '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
|
5421 // characterwise, linewise, or blockwise. |
7 | 5422 if (cap->oap->op_type != OP_NOP) |
5423 { | |
15279
54457fc4af0b
patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
5424 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
|
5425 finish_op = FALSE; // operator doesn't finish now but later |
7 | 5426 return; |
5427 } | |
5428 | |
5429 VIsual_select = cap->arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5430 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
|
5431 { |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5432 if (VIsual_mode == cap->cmdchar) // stop visual mode |
7 | 5433 end_visual_mode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5434 else // toggle char/block mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5435 { // or char/line mode |
7 | 5436 VIsual_mode = cap->cmdchar; |
5437 showmode(); | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
5438 may_trigger_modechanged(); |
7 | 5439 } |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5440 redraw_curbuf_later(UPD_INVERTED); // update the inversion |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5441 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5442 else // start Visual mode |
7 | 5443 { |
5444 check_visual_highlight(); | |
3537 | 5445 if (cap->count0 > 0 && resel_VIsual_mode != NUL) |
5446 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5447 // use previously selected part |
7 | 5448 VIsual = curwin->w_cursor; |
5449 | |
5450 VIsual_active = TRUE; | |
5451 VIsual_reselect = TRUE; | |
5452 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5453 // start Select mode when 'selectmode' contains "cmd" |
7 | 5454 may_start_select('c'); |
5455 setmouse(); | |
641 | 5456 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
|
5457 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
|
5458 // 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
|
5459 // was only one -- webb |
7 | 5460 if (resel_VIsual_mode != 'v' || resel_VIsual_line_count > 1) |
5461 { | |
5462 curwin->w_cursor.lnum += | |
5463 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
|
5464 check_cursor(); |
7 | 5465 } |
5466 VIsual_mode = resel_VIsual_mode; | |
5467 if (VIsual_mode == 'v') | |
5468 { | |
5469 if (resel_VIsual_line_count <= 1) | |
3125 | 5470 { |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5471 update_curswant_force(); |
31680
24d9c23bf665
patch 9.0.1172: when 'selection' is "exclusive" then "1v" is one char short
Bram Moolenaar <Bram@vim.org>
parents:
31588
diff
changeset
|
5472 curwin->w_curswant += resel_VIsual_vcol * cap->count0; |
24d9c23bf665
patch 9.0.1172: when 'selection' is "exclusive" then "1v" is one char short
Bram Moolenaar <Bram@vim.org>
parents:
31588
diff
changeset
|
5473 if (*p_sel != 'e') |
24d9c23bf665
patch 9.0.1172: when 'selection' is "exclusive" then "1v" is one char short
Bram Moolenaar <Bram@vim.org>
parents:
31588
diff
changeset
|
5474 --curwin->w_curswant; |
3125 | 5475 } |
7 | 5476 else |
3125 | 5477 curwin->w_curswant = resel_VIsual_vcol; |
5478 coladvance(curwin->w_curswant); | |
7 | 5479 } |
3125 | 5480 if (resel_VIsual_vcol == MAXCOL) |
7 | 5481 { |
5482 curwin->w_curswant = MAXCOL; | |
5483 coladvance((colnr_T)MAXCOL); | |
5484 } | |
5485 else if (VIsual_mode == Ctrl_V) | |
5486 { | |
31881
df061831a85f
patch 9.0.1273: "1v" may select block with wrong size
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
5487 // Update curswant on the original line, that is where "col" is |
df061831a85f
patch 9.0.1273: "1v" may select block with wrong size
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
5488 // valid. |
df061831a85f
patch 9.0.1273: "1v" may select block with wrong size
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
5489 linenr_T lnum = curwin->w_cursor.lnum; |
df061831a85f
patch 9.0.1273: "1v" may select block with wrong size
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
5490 curwin->w_cursor.lnum = VIsual.lnum; |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5491 update_curswant_force(); |
31881
df061831a85f
patch 9.0.1273: "1v" may select block with wrong size
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
5492 curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1; |
df061831a85f
patch 9.0.1273: "1v" may select block with wrong size
Bram Moolenaar <Bram@vim.org>
parents:
31752
diff
changeset
|
5493 curwin->w_cursor.lnum = lnum; |
7 | 5494 coladvance(curwin->w_curswant); |
5495 } | |
5496 else | |
5497 curwin->w_set_curswant = TRUE; | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5498 redraw_curbuf_later(UPD_INVERTED); // show the inversion |
7 | 5499 } |
5500 else | |
5501 { | |
5502 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5503 // start Select mode when 'selectmode' contains "cmd" |
7 | 5504 may_start_select('c'); |
5505 n_start_visual_mode(cap->cmdchar); | |
3537 | 5506 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
|
5507 ++cap->count1; // include one more char |
3537 | 5508 if (cap->count0 > 0 && --cap->count1 > 0) |
5509 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5510 // With a count select that many characters or lines. |
3537 | 5511 if (VIsual_mode == 'v' || VIsual_mode == Ctrl_V) |
5512 nv_right(cap); | |
5513 else if (VIsual_mode == 'V') | |
5514 nv_down(cap); | |
5515 } | |
7 | 5516 } |
5517 } | |
5518 } | |
5519 | |
5520 /* | |
5521 * Start selection for Shift-movement keys. | |
5522 */ | |
5523 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5524 start_selection(void) |
7 | 5525 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5526 // if 'selectmode' contains "key", start Select mode |
7 | 5527 may_start_select('k'); |
5528 n_start_visual_mode('v'); | |
5529 } | |
5530 | |
5531 /* | |
5532 * Start Select mode, if "c" is in 'selectmode' and not in a mapping or menu. | |
28564
9a2fb96475ed
patch 8.2.4806: a mapping using <LeftDrag> does not start Select mode
Bram Moolenaar <Bram@vim.org>
parents:
28401
diff
changeset
|
5533 * When "c" is 'o' (checking for "mouse") then also when mapped. |
7 | 5534 */ |
5535 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5536 may_start_select(int c) |
7 | 5537 { |
28564
9a2fb96475ed
patch 8.2.4806: a mapping using <LeftDrag> does not start Select mode
Bram Moolenaar <Bram@vim.org>
parents:
28401
diff
changeset
|
5538 VIsual_select = (c == 'o' || (stuff_empty() && typebuf_typed())) |
9a2fb96475ed
patch 8.2.4806: a mapping using <LeftDrag> does not start Select mode
Bram Moolenaar <Bram@vim.org>
parents:
28401
diff
changeset
|
5539 && vim_strchr(p_slm, c) != NULL; |
7 | 5540 } |
5541 | |
5542 /* | |
5543 * Start Visual mode "c". | |
5544 * Should set VIsual_select before calling this. | |
5545 */ | |
5546 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5547 n_start_visual_mode(int c) |
7 | 5548 { |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5549 #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
|
5550 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
|
5551 && 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
|
5552 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5553 |
7 | 5554 VIsual_mode = c; |
5555 VIsual_active = TRUE; | |
5556 VIsual_reselect = TRUE; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5557 |
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5558 // 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
|
5559 // 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
|
5560 if (c == Ctrl_V && (get_ve_flags() & VE_BLOCK) && gchar_cursor() == TAB) |
3742 | 5561 { |
5562 validate_virtcol(); | |
7 | 5563 coladvance(curwin->w_virtcol); |
3742 | 5564 } |
7 | 5565 VIsual = curwin->w_cursor; |
5566 | |
5567 #ifdef FEAT_FOLDING | |
5568 foldAdjustVisual(); | |
5569 #endif | |
5570 | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
5571 may_trigger_modechanged(); |
7 | 5572 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
|
5573 #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
|
5574 // 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
|
5575 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
|
5576 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5577 |
641 | 5578 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
|
5579 redraw_cmdline = TRUE; // show visual mode later |
7 | 5580 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5581 // 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
|
5582 // end may still be the same, and the selection needs to be owned |
7 | 5583 clip_star.vmode = NUL; |
5584 #endif | |
5585 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5586 // 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
|
5587 // Visual area (when 'lazyredraw' is set). |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5588 if (curwin->w_redr_type < UPD_INVERTED) |
7 | 5589 { |
5590 curwin->w_old_cursor_lnum = curwin->w_cursor.lnum; | |
5591 curwin->w_old_visual_lnum = curwin->w_cursor.lnum; | |
5592 } | |
5593 } | |
5594 | |
5595 | |
5596 /* | |
5597 * CTRL-W: Window commands | |
5598 */ | |
5599 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5600 nv_window(cmdarg_T *cap) |
7 | 5601 { |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5602 if (cap->nchar == ':') |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5603 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5604 // "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
|
5605 cap->cmdchar = ':'; |
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5606 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
|
5607 nv_colon(cap); |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5608 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5609 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
|
5610 do_window(cap->nchar, cap->count0, NUL); // everything is in window.c |
7 | 5611 } |
5612 | |
5613 /* | |
5614 * CTRL-Z: Suspend | |
5615 */ | |
5616 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5617 nv_suspend(cmdarg_T *cap) |
7 | 5618 { |
5619 clearop(cap->oap); | |
5620 if (VIsual_active) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5621 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
|
5622 do_cmdline_cmd((char_u *)"stop"); |
7 | 5623 } |
5624 | |
5625 /* | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5626 * "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
|
5627 * 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
|
5628 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5629 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5630 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
|
5631 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5632 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
|
5633 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5634 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5635 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
|
5636 return; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5637 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5638 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
|
5639 || 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
|
5640 || 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
|
5641 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5642 beep_flush(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5643 return; |
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 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5646 // 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
|
5647 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
|
5648 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5649 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
|
5650 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
|
5651 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
|
5652 # 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
|
5653 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
|
5654 # endif |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5655 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
|
5656 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
|
5657 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
|
5658 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5659 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
|
5660 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
|
5661 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
|
5662 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
|
5663 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5664 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5665 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5666 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
|
5667 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
|
5668 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
|
5669 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
|
5670 } |
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 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
|
5673 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
|
5674 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5675 // 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
|
5676 // 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
|
5677 check_cursor(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5678 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
|
5679 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
|
5680 check_cursor(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5681 update_topline(); |
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 // 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
|
5684 // '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
|
5685 // 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
|
5686 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
|
5687 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5688 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
|
5689 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
|
5690 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5691 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5692 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
|
5693 setmouse(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5694 #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
|
5695 // 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
|
5696 // 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
|
5697 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
|
5698 #endif |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5699 redraw_curbuf_later(UPD_INVERTED); |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5700 showmode(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5701 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5702 |
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 * "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
|
5705 * "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
|
5706 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5707 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5708 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
|
5709 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5710 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5711 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
|
5712 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5713 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
|
5714 flag = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5715 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5716 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
|
5717 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
|
5718 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
|
5719 { |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5720 int width1 = curwin->w_width - curwin_col_off(); |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5721 int width2 = width1 + curwin_col_off2(); |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5722 int virtcol; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5723 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5724 validate_virtcol(); |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5725 virtcol = curwin->w_virtcol |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5726 #ifdef FEAT_PROP_POPUP |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5727 - curwin->w_virtcol_first_char |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5728 #endif |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5729 ; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5730 i = 0; |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5731 if (virtcol >= (colnr_T)width1 && width2 > 0) |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5732 i = (virtcol - width1) / width2 * width2 + width1; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5733 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5734 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5735 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
|
5736 // 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
|
5737 // '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
|
5738 // 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
|
5739 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
|
5740 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
|
5741 + ((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
|
5742 ? 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
|
5743 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
|
5744 if (flag) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5745 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5746 do |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5747 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
|
5748 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
|
5749 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
|
5750 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5751 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
|
5752 } |
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 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5755 * "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
|
5756 * downward. |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5757 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5758 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5759 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
|
5760 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5761 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
|
5762 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5763 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
|
5764 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
|
5765 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
|
5766 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
|
5767 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
|
5768 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5769 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
|
5770 return; |
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 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5773 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
|
5774 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5775 // 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
|
5776 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
|
5777 --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
|
5778 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5779 // 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
|
5780 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
|
5781 && 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
|
5782 --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
|
5783 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
|
5784 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
|
5785 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5786 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5787 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5788 * "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
|
5789 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5790 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5791 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
|
5792 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5793 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
|
5794 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5795 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
|
5796 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5797 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
|
5798 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
|
5799 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
|
5800 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5801 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
|
5802 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
|
5803 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5804 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
|
5805 int width2 = width1 + curwin_col_off2(); |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5806 int virtcol; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5807 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5808 validate_virtcol(); |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5809 virtcol = curwin->w_virtcol |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5810 #ifdef FEAT_PROP_POPUP |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5811 - curwin->w_virtcol_first_char |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5812 #endif |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5813 ; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5814 i = width1 - 1; |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5815 if (virtcol >= (colnr_T)width1) |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5816 i += ((virtcol - width1) / width2 + 1) |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5817 * width2; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5818 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
|
5819 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5820 // Make sure we stick in this column. |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5821 update_curswant_force(); |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5822 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
|
5823 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5824 // 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
|
5825 // 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
|
5826 // the next screen line. |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5827 if (curwin->w_virtcol |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5828 #ifdef FEAT_PROP_POPUP |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5829 - curwin->w_virtcol_first_char |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5830 #endif |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5831 > (colnr_T)i) |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5832 --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
|
5833 } |
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 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
|
5836 clearopbeep(oap); |
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 else |
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 (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
|
5841 // 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
|
5842 (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
|
5843 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5844 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
|
5845 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
|
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 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
|
5848 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
|
5849 && (*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
|
5850 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5851 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
|
5852 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5853 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
|
5854 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
|
5855 --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
|
5856 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5857 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5858 // Make sure we stick in this column. |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5859 update_curswant_force(); |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5860 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5861 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5862 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5863 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5864 * "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
|
5865 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5866 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5867 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
|
5868 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5869 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5870 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5871 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
|
5872 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5873 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
|
5874 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
|
5875 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
|
5876 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
|
5877 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5878 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
|
5879 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
|
5880 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
|
5881 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5882 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5883 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
|
5884 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
|
5885 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5886 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5887 /* |
7 | 5888 * Commands starting with "g". |
5889 */ | |
5890 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5891 nv_g_cmd(cmdarg_T *cap) |
7 | 5892 { |
5893 oparg_T *oap = cap->oap; | |
5894 int i; | |
5895 | |
5896 switch (cap->nchar) | |
5897 { | |
6868 | 5898 case Ctrl_A: |
5899 case Ctrl_X: | |
7 | 5900 #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
|
5901 // "g^A": dump log of used memory. |
6868 | 5902 if (!VIsual_active && cap->nchar == Ctrl_A) |
5903 vim_mem_profile_dump(); | |
5904 else | |
5905 #endif | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5906 // "g^A/g^X": sequentially increment visually selected region |
32108
cbf0ed5c83d0
patch 9.0.1385: g'Esc is considered an error
Bram Moolenaar <Bram@vim.org>
parents:
32049
diff
changeset
|
5907 if (VIsual_active) |
6868 | 5908 { |
5909 cap->arg = TRUE; | |
5910 cap->cmdchar = cap->nchar; | |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
5911 cap->nchar = NUL; |
6868 | 5912 nv_addsub(cap); |
5913 } | |
5914 else | |
5915 clearopbeep(oap); | |
7 | 5916 break; |
5917 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5918 // "gR": Enter virtual replace mode. |
7 | 5919 case 'R': |
5920 cap->arg = TRUE; | |
5921 nv_Replace(cap); | |
5922 break; | |
5923 | |
5924 case 'r': | |
5925 nv_vreplace(cap); | |
5926 break; | |
5927 | |
5928 case '&': | |
5929 do_cmdline_cmd((char_u *)"%s//~/&"); | |
5930 break; | |
5931 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5932 // "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
|
5933 // exchange previous and current Visual area. |
7 | 5934 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
|
5935 nv_gv_cmd(cap); |
7 | 5936 break; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5937 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5938 // "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
|
5939 // mapping of menu. |
7 | 5940 case 'V': |
5941 VIsual_reselect = FALSE; | |
5942 break; | |
5943 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5944 // "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
|
5945 // "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
|
5946 // "g^H": start Select block mode. |
7 | 5947 case K_BS: |
5948 cap->nchar = Ctrl_H; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5949 // FALLTHROUGH |
7 | 5950 case 'h': |
5951 case 'H': | |
5952 case Ctrl_H: | |
5953 cap->cmdchar = cap->nchar + ('v' - 'h'); | |
5954 cap->arg = TRUE; | |
5955 nv_visual(cap); | |
5956 break; | |
3701 | 5957 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5958 // "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
|
5959 // "gn" selects next match |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5960 // "gN" selects previous match |
3701 | 5961 case 'N': |
5962 case 'n': | |
5963 if (!current_search(cap->count1, cap->nchar == 'n')) | |
3896 | 5964 clearopbeep(oap); |
3701 | 5965 break; |
7 | 5966 |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5967 // "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
|
5968 // movement based on *screen* line rather than *file* line. |
7 | 5969 case 'j': |
5970 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
|
5971 // 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
|
5972 if (!curwin->w_p_wrap) |
7 | 5973 { |
5974 oap->motion_type = MLINE; | |
5975 i = cursor_down(cap->count1, oap->op_type == OP_NOP); | |
5976 } | |
5977 else | |
5978 i = nv_screengo(oap, FORWARD, cap->count1); | |
5979 if (i == FAIL) | |
5980 clearopbeep(oap); | |
5981 break; | |
5982 | |
5983 case 'k': | |
5984 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
|
5985 // 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
|
5986 if (!curwin->w_p_wrap) |
7 | 5987 { |
5988 oap->motion_type = MLINE; | |
5989 i = cursor_up(cap->count1, oap->op_type == OP_NOP); | |
5990 } | |
5991 else | |
5992 i = nv_screengo(oap, BACKWARD, cap->count1); | |
5993 if (i == FAIL) | |
5994 clearopbeep(oap); | |
5995 break; | |
5996 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5997 // "gJ": join two lines without inserting a space. |
7 | 5998 case 'J': |
5999 nv_join(cap); | |
6000 break; | |
6001 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6002 // "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
|
6003 // "gm": middle of "g0" and "g$". |
7 | 6004 case '^': |
6005 case '0': | |
6006 case 'm': | |
6007 case K_HOME: | |
6008 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
|
6009 nv_g_home_m_cmd(cap); |
7 | 6010 break; |
6011 | |
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
|
6012 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
|
6013 { |
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
|
6014 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
|
6015 oap->inclusive = FALSE; |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
6016 i = linetabsize_str(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
|
6017 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
|
6018 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
|
6019 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
|
6020 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
|
6021 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
|
6022 } |
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
|
6023 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
|
6024 |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6025 // "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
|
6026 // downward. |
7 | 6027 case '_': |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6028 nv_g_underscore_cmd(cap); |
7 | 6029 break; |
6030 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6031 // "g$" : Like "$" but for screen lines. |
7 | 6032 case '$': |
6033 case K_END: | |
6034 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
|
6035 nv_g_dollar_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 // "g*" and "g#", like "*" and "#" but without using "\<" and "\>" |
7 | 6039 case '*': |
6040 case '#': | |
6041 #if POUND != '#' | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6042 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
|
6043 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6044 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
|
6045 case ']': // :tselect for current identifier |
7 | 6046 nv_ident(cap); |
6047 break; | |
6048 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6049 // ge and gE: go back to end of word |
7 | 6050 case 'e': |
6051 case 'E': | |
6052 oap->motion_type = MCHAR; | |
6053 curwin->w_set_curswant = TRUE; | |
6054 oap->inclusive = TRUE; | |
6055 if (bckend_word(cap->count1, cap->nchar == 'E', FALSE) == FAIL) | |
6056 clearopbeep(oap); | |
6057 break; | |
6058 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6059 // "g CTRL-G": display info about cursor position |
7 | 6060 case Ctrl_G: |
7480
a49163681559
commit https://github.com/vim/vim/commit/ed767a2073ef150971b0439a58e7ee582af6984e
Christian Brabandt <cb@256bit.org>
parents:
7311
diff
changeset
|
6061 cursor_pos_info(NULL); |
7 | 6062 break; |
6063 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6064 // "gi": start Insert at the last position. |
7 | 6065 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
|
6066 nv_gi_cmd(cap); |
7 | 6067 break; |
6068 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6069 // "gI": Start insert in column 1. |
7 | 6070 case 'I': |
6071 beginline(0); | |
6072 if (!checkclearopq(oap)) | |
6073 invoke_edit(cap, FALSE, 'g', FALSE); | |
6074 break; | |
6075 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6076 // "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
|
6077 // "]f" and "[f": can also be used. |
7 | 6078 case 'f': |
681 | 6079 case 'F': |
7 | 6080 nv_gotofile(cap); |
6081 break; | |
6082 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6083 // "g'm" and "g`m": jump to mark without setting pcmark |
7 | 6084 case '\'': |
6085 cap->arg = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6086 // FALLTHROUGH |
7 | 6087 case '`': |
6088 nv_gomark(cap); | |
6089 break; | |
6090 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6091 // "gs": Goto sleep. |
7 | 6092 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
|
6093 do_sleep(cap->count1 * 1000L, FALSE); |
7 | 6094 break; |
6095 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6096 // "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
|
6097 // cursor. It is displayed in decimal, hex, and octal. -- webb |
7 | 6098 case 'a': |
6099 do_ascii(NULL); | |
6100 break; | |
6101 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6102 // "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
|
6103 // 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
|
6104 // "8g8" finds illegal byte sequence. |
7 | 6105 case '8': |
775 | 6106 if (cap->count0 == 8) |
6107 utf_find_illegal(); | |
6108 else | |
6109 show_utf8(); | |
7 | 6110 break; |
6111 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6112 // "g<": show scrollback text |
447 | 6113 case '<': |
6114 show_sb_text(); | |
6115 break; | |
6116 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6117 // "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
|
6118 // that line number like for "G". -- webb |
7 | 6119 case 'g': |
6120 cap->arg = FALSE; | |
6121 nv_goto(cap); | |
6122 break; | |
6123 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6124 // 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
|
6125 // "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
|
6126 // "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
|
6127 // "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
|
6128 // "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
|
6129 // "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
|
6130 // "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
|
6131 // "g@" call 'operatorfunc' |
7 | 6132 case 'q': |
6133 case 'w': | |
6134 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
|
6135 // FALLTHROUGH |
7 | 6136 case '~': |
6137 case 'u': | |
6138 case 'U': | |
6139 case '?': | |
602 | 6140 case '@': |
7 | 6141 nv_operator(cap); |
6142 break; | |
6143 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6144 // "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
|
6145 // current function |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6146 // "gD": idem, but in the current file. |
7 | 6147 case 'd': |
6148 case 'D': | |
523 | 6149 nv_gd(oap, cap->nchar, (int)cap->count0); |
7 | 6150 break; |
6151 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6152 // g<*Mouse> : <C-*mouse> |
7 | 6153 case K_MIDDLEMOUSE: |
6154 case K_MIDDLEDRAG: | |
6155 case K_MIDDLERELEASE: | |
6156 case K_LEFTMOUSE: | |
6157 case K_LEFTDRAG: | |
6158 case K_LEFTRELEASE: | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
6159 case K_MOUSEMOVE: |
7 | 6160 case K_RIGHTMOUSE: |
6161 case K_RIGHTDRAG: | |
6162 case K_RIGHTRELEASE: | |
6163 case K_X1MOUSE: | |
6164 case K_X1DRAG: | |
6165 case K_X1RELEASE: | |
6166 case K_X2MOUSE: | |
6167 case K_X2DRAG: | |
6168 case K_X2RELEASE: | |
6169 mod_mask = MOD_MASK_CTRL; | |
6170 (void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); | |
6171 break; | |
6172 | |
6173 case K_IGNORE: | |
6174 break; | |
6175 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6176 // "gP" and "gp": same as "P" and "p" but leave cursor just after new text |
7 | 6177 case 'p': |
6178 case 'P': | |
6179 nv_put(cap); | |
6180 break; | |
6181 | |
6182 #ifdef FEAT_BYTEOFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6183 // "go": goto byte count from start of buffer |
7 | 6184 case 'o': |
6185 goto_byte(cap->count0); | |
6186 break; | |
6187 #endif | |
6188 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6189 // "gQ": improved Ex mode |
7 | 6190 case 'Q': |
29002
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
6191 if (!check_text_locked(cap->oap) && !checkclearopq(oap)) |
7 | 6192 do_exmode(TRUE); |
6193 break; | |
6194 | |
6195 case ',': | |
6196 nv_pcmark(cap); | |
6197 break; | |
6198 | |
6199 case ';': | |
6200 cap->count1 = -cap->count1; | |
6201 nv_pcmark(cap); | |
6202 break; | |
6203 | |
667 | 6204 case 't': |
3630 | 6205 if (!checkclearop(oap)) |
6206 goto_tabpage((int)cap->count0); | |
667 | 6207 break; |
682 | 6208 case 'T': |
3630 | 6209 if (!checkclearop(oap)) |
6210 goto_tabpage(-(int)cap->count1); | |
682 | 6211 break; |
667 | 6212 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6213 case TAB: |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6214 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
|
6215 clearopbeep(oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6216 break; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6217 |
750 | 6218 case '+': |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6219 case '-': // "g+" and "g-": undo or redo along the timeline |
750 | 6220 if (!checkclearopq(oap)) |
771 | 6221 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
|
6222 FALSE, FALSE, FALSE); |
750 | 6223 break; |
6224 | |
7 | 6225 default: |
6226 clearopbeep(oap); | |
6227 break; | |
6228 } | |
6229 } | |
6230 | |
6231 /* | |
6232 * Handle "o" and "O" commands. | |
6233 */ | |
6234 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6235 n_opencmd(cmdarg_T *cap) |
7 | 6236 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6237 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6238 linenr_T oldline = curwin->w_cursor.lnum; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6239 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6240 |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6241 if (checkclearopq(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6242 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6243 |
7 | 6244 #ifdef FEAT_FOLDING |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6245 if (cap->cmdchar == 'O') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6246 // Open above the first line of a folded sequence of lines |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6247 (void)hasFolding(curwin->w_cursor.lnum, |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6248 &curwin->w_cursor.lnum, NULL); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6249 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6250 // Open below the last line of a folded sequence of lines |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6251 (void)hasFolding(curwin->w_cursor.lnum, |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6252 NULL, &curwin->w_cursor.lnum); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6253 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6254 if (u_save((linenr_T)(curwin->w_cursor.lnum - |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6255 (cap->cmdchar == 'O' ? 1 : 0)), |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6256 (linenr_T)(curwin->w_cursor.lnum + |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6257 (cap->cmdchar == 'o' ? 1 : 0)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6258 ) == OK |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6259 && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6260 has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6261 0, NULL) == OK) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6262 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6263 #ifdef FEAT_CONCEAL |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6264 if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6265 redrawWinline(curwin, oldline); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6266 #endif |
6834 | 6267 #ifdef FEAT_SYN_HL |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6268 if (curwin->w_p_cul) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6269 // force redraw of cursorline |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6270 curwin->w_valid &= ~VALID_CROW; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6271 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6272 // When '#' is in 'cpoptions' ignore the count. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6273 if (vim_strchr(p_cpo, CPO_HASH) != NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6274 cap->count1 = 1; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6275 invoke_edit(cap, FALSE, cap->cmdchar, TRUE); |
7 | 6276 } |
6277 } | |
6278 | |
6279 /* | |
6280 * "." command: redo last change. | |
6281 */ | |
6282 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6283 nv_dot(cmdarg_T *cap) |
7 | 6284 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6285 if (checkclearopq(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6286 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6287 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6288 // If "restart_edit" is TRUE, the last but one command is repeated |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6289 // instead of the last command (inserting text). This is used for |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6290 // CTRL-O <.> in insert mode. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6291 if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6292 clearopbeep(cap->oap); |
7 | 6293 } |
6294 | |
6295 /* | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6296 * CTRL-R: undo undo or specify register in select mode |
7 | 6297 */ |
6298 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
|
6299 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
|
6300 { |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6301 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
|
6302 { |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6303 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
|
6304 // 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
|
6305 ++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
|
6306 ++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
|
6307 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
|
6308 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
|
6309 --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
|
6310 --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
|
6311 |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6312 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
|
6313 // 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
|
6314 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
|
6315 |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
6316 VIsual_select_reg = valid_yank_reg(reg, TRUE) ? reg : 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
|
6317 return; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6318 } |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6319 |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6320 if (checkclearopq(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6321 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6322 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6323 u_redo((int)cap->count1); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6324 curwin->w_set_curswant = TRUE; |
7 | 6325 } |
6326 | |
6327 /* | |
6328 * Handle "U" command. | |
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_Undo(cmdarg_T *cap) |
7 | 6332 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6333 // In Visual mode and typing "gUU" triggers an operator |
5735 | 6334 if (cap->oap->op_type == OP_UPPER || VIsual_active) |
7 | 6335 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6336 // translate "gUU" to "gUgU" |
7 | 6337 cap->cmdchar = 'g'; |
6338 cap->nchar = 'U'; | |
6339 nv_operator(cap); | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6340 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6341 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6342 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6343 if (checkclearopq(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6344 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6345 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6346 u_undoline(); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
6347 curwin->w_set_curswant = TRUE; |
7 | 6348 } |
6349 | |
6350 /* | |
6351 * '~' command: If tilde is not an operator and Visual is off: swap case of a | |
6352 * single character. | |
6353 */ | |
6354 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6355 nv_tilde(cmdarg_T *cap) |
7 | 6356 { |
5735 | 6357 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
|
6358 { |
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 #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
|
6360 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
|
6361 { |
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 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
|
6363 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
|
6364 } |
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
|
6365 #endif |
7 | 6366 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
|
6367 } |
7 | 6368 else |
6369 nv_operator(cap); | |
6370 } | |
6371 | |
6372 /* | |
6373 * Handle an operator command. | |
6374 * The actual work is done by do_pending_operator(). | |
6375 */ | |
6376 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6377 nv_operator(cmdarg_T *cap) |
7 | 6378 { |
6379 int op_type; | |
6380 | |
6381 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
|
6382 #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
|
6383 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
|
6384 { |
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
|
6385 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
|
6386 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
|
6387 } |
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
|
6388 #endif |
7 | 6389 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6390 if (op_type == cap->oap->op_type) // double operator works on lines |
7 | 6391 nv_lineop(cap); |
6392 else if (!checkclearop(cap->oap)) | |
6393 { | |
6394 cap->oap->start = curwin->w_cursor; | |
6395 cap->oap->op_type = op_type; | |
1490 | 6396 #ifdef FEAT_EVAL |
6397 set_op_var(op_type); | |
6398 #endif | |
6399 } | |
6400 } | |
6401 | |
6402 #ifdef FEAT_EVAL | |
6403 /* | |
6404 * Set v:operator to the characters for "optype". | |
6405 */ | |
6406 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6407 set_op_var(int optype) |
1490 | 6408 { |
6409 char_u opchars[3]; | |
6410 | |
6411 if (optype == OP_NOP) | |
6412 set_vim_var_string(VV_OP, NULL, 0); | |
6413 else | |
6414 { | |
6415 opchars[0] = get_op_char(optype); | |
6416 opchars[1] = get_extra_op_char(optype); | |
6417 opchars[2] = NUL; | |
6418 set_vim_var_string(VV_OP, opchars, -1); | |
6419 } | |
6420 } | |
6421 #endif | |
7 | 6422 |
6423 /* | |
6424 * Handle linewise operator "dd", "yy", etc. | |
6425 * | |
6426 * "_" is is a strange motion command that helps make operators more logical. | |
6427 * It is actually implemented, but not documented in the real Vi. This motion | |
6428 * command actually refers to "the current line". Commands like "dd" and "yy" | |
6429 * are really an alternate form of "d_" and "y_". It does accept a count, so | |
6430 * "d3_" works to delete 3 lines. | |
6431 */ | |
6432 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6433 nv_lineop(cmdarg_T *cap) |
7 | 6434 { |
6435 cap->oap->motion_type = MLINE; | |
6436 if (cursor_down(cap->count1 - 1L, cap->oap->op_type == OP_NOP) == FAIL) | |
6437 clearopbeep(cap->oap); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6438 else if ( (cap->oap->op_type == OP_DELETE // only with linewise motions |
4011 | 6439 && cap->oap->motion_force != 'v' |
6440 && cap->oap->motion_force != Ctrl_V) | |
7 | 6441 || cap->oap->op_type == OP_LSHIFT |
6442 || cap->oap->op_type == OP_RSHIFT) | |
6443 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
|
6444 else if (cap->oap->op_type != OP_YANK) // 'Y' does not move cursor |
7 | 6445 beginline(BL_WHITE | BL_FIX); |
6446 } | |
6447 | |
6448 /* | |
6449 * <Home> command. | |
6450 */ | |
6451 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6452 nv_home(cmdarg_T *cap) |
7 | 6453 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6454 // CTRL-HOME is like "gg" |
180 | 6455 if (mod_mask & MOD_MASK_CTRL) |
6456 nv_goto(cap); | |
6457 else | |
6458 { | |
6459 cap->count0 = 1; | |
6460 nv_pipe(cap); | |
6461 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6462 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
|
6463 // one-character line). |
7 | 6464 } |
6465 | |
6466 /* | |
6467 * "|" command. | |
6468 */ | |
6469 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6470 nv_pipe(cmdarg_T *cap) |
7 | 6471 { |
6472 cap->oap->motion_type = MCHAR; | |
6473 cap->oap->inclusive = FALSE; | |
6474 beginline(0); | |
6475 if (cap->count0 > 0) | |
6476 { | |
6477 coladvance((colnr_T)(cap->count0 - 1)); | |
6478 curwin->w_curswant = (colnr_T)(cap->count0 - 1); | |
6479 } | |
6480 else | |
6481 curwin->w_curswant = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6482 // 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
|
6483 // we ended; differs if line is too short |
7 | 6484 curwin->w_set_curswant = FALSE; |
6485 } | |
6486 | |
6487 /* | |
6488 * Handle back-word command "b" and "B". | |
6489 * cap->arg is 1 for "B" | |
6490 */ | |
6491 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6492 nv_bck_word(cmdarg_T *cap) |
7 | 6493 { |
6494 cap->oap->motion_type = MCHAR; | |
6495 cap->oap->inclusive = FALSE; | |
6496 curwin->w_set_curswant = TRUE; | |
6497 if (bck_word(cap->count1, cap->arg, FALSE) == FAIL) | |
6498 clearopbeep(cap->oap); | |
6499 #ifdef FEAT_FOLDING | |
6500 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6501 foldOpenCursor(); | |
6502 #endif | |
6503 } | |
6504 | |
6505 /* | |
6506 * Handle word motion commands "e", "E", "w" and "W". | |
6507 * cap->arg is TRUE for "E" and "W". | |
6508 */ | |
6509 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6510 nv_wordcmd(cmdarg_T *cap) |
7 | 6511 { |
6512 int n; | |
6513 int word_end; | |
6514 int flag = FALSE; | |
1573 | 6515 pos_T startpos = curwin->w_cursor; |
7 | 6516 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6517 // Set inclusive for the "E" and "e" command. |
7 | 6518 if (cap->cmdchar == 'e' || cap->cmdchar == 'E') |
6519 word_end = TRUE; | |
6520 else | |
6521 word_end = FALSE; | |
6522 cap->oap->inclusive = word_end; | |
6523 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6524 // "cw" and "cW" are a special case. |
7 | 6525 if (!word_end && cap->oap->op_type == OP_CHANGE) |
6526 { | |
6527 n = gchar_cursor(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6528 if (n != NUL) // not an empty line |
7 | 6529 { |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6530 if (VIM_ISWHITE(n)) |
7 | 6531 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6532 // 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
|
6533 // 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
|
6534 // 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
|
6535 // in 'cpoptions'. |
7 | 6536 if (cap->count1 == 1 && vim_strchr(p_cpo, CPO_CW) != NULL) |
6537 { | |
6538 cap->oap->inclusive = TRUE; | |
6539 cap->oap->motion_type = MCHAR; | |
6540 return; | |
6541 } | |
6542 } | |
6543 else | |
6544 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6545 // 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
|
6546 // 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
|
6547 // 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
|
6548 // 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
|
6549 // 'cw'. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6550 // 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
|
6551 // "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
|
6552 // 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
|
6553 // flag. |
7 | 6554 cap->oap->inclusive = TRUE; |
6555 word_end = TRUE; | |
6556 flag = TRUE; | |
6557 } | |
6558 } | |
6559 } | |
6560 | |
6561 cap->oap->motion_type = MCHAR; | |
6562 curwin->w_set_curswant = TRUE; | |
6563 if (word_end) | |
6564 n = end_word(cap->count1, cap->arg, flag, FALSE); | |
6565 else | |
6566 n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP); | |
6567 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6568 // 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
|
6569 // 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
|
6570 if (LT_POS(startpos, curwin->w_cursor)) |
1505 | 6571 adjust_cursor(cap->oap); |
7 | 6572 |
6573 if (n == FAIL && cap->oap->op_type == OP_NOP) | |
6574 clearopbeep(cap->oap); | |
6575 else | |
6576 { | |
6577 adjust_for_sel(cap); | |
6578 #ifdef FEAT_FOLDING | |
6579 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6580 foldOpenCursor(); | |
6581 #endif | |
6582 } | |
6583 } | |
6584 | |
6585 /* | |
1505 | 6586 * Used after a movement command: If the cursor ends up on the NUL after the |
6587 * end of the line, may move it back to the last character and make the motion | |
6588 * inclusive. | |
6589 */ | |
6590 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6591 adjust_cursor(oparg_T *oap) |
1505 | 6592 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6593 // 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
|
6594 // - the column is > 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6595 // - 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
|
6596 // - 'virtualedit' is not "all" and not "onemore". |
1505 | 6597 if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL |
6598 && (!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
|
6599 && !virtual_active() && (get_ve_flags() & VE_ONEMORE) == 0) |
1505 | 6600 { |
6601 --curwin->w_cursor.col; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6602 // prevent cursor from moving on the trail byte |
1505 | 6603 if (has_mbyte) |
6604 mb_adjust_cursor(); | |
6605 oap->inclusive = TRUE; | |
6606 } | |
6607 } | |
6608 | |
6609 /* | |
7 | 6610 * "0" and "^" commands. |
6611 * cap->arg is the argument for beginline(). | |
6612 */ | |
6613 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6614 nv_beginline(cmdarg_T *cap) |
7 | 6615 { |
6616 cap->oap->motion_type = MCHAR; | |
6617 cap->oap->inclusive = FALSE; | |
6618 beginline(cap->arg); | |
6619 #ifdef FEAT_FOLDING | |
6620 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6621 foldOpenCursor(); | |
6622 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6623 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
|
6624 // one-character line). |
7 | 6625 } |
6626 | |
6627 /* | |
6628 * In exclusive Visual mode, may include the last character. | |
6629 */ | |
6630 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6631 adjust_for_sel(cmdarg_T *cap) |
7 | 6632 { |
6633 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
|
6634 && gchar_cursor() != NUL && LT_POS(VIsual, curwin->w_cursor)) |
7 | 6635 { |
6636 if (has_mbyte) | |
6637 inc_cursor(); | |
6638 else | |
6639 ++curwin->w_cursor.col; | |
6640 cap->oap->inclusive = FALSE; | |
6641 } | |
6642 } | |
6643 | |
6644 /* | |
6645 * Exclude last character at end of Visual area for 'selection' == "exclusive". | |
6646 * Should check VIsual_mode before calling this. | |
6647 * Returns TRUE when backed up to the previous line. | |
6648 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
6649 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6650 unadjust_for_sel(void) |
7 | 6651 { |
6652 pos_T *pp; | |
6653 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6654 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
|
6655 { |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6656 if (LT_POS(VIsual, curwin->w_cursor)) |
7 | 6657 pp = &curwin->w_cursor; |
6658 else | |
6659 pp = &VIsual; | |
6660 if (pp->coladd > 0) | |
6661 --pp->coladd; | |
6662 else | |
6663 if (pp->col > 0) | |
6664 { | |
6665 --pp->col; | |
2933 | 6666 mb_adjustpos(curbuf, pp); |
7 | 6667 } |
6668 else if (pp->lnum > 1) | |
6669 { | |
6670 --pp->lnum; | |
6671 pp->col = (colnr_T)STRLEN(ml_get(pp->lnum)); | |
6672 return TRUE; | |
6673 } | |
6674 } | |
6675 return FALSE; | |
6676 } | |
6677 | |
6678 /* | |
6679 * SELECT key in Normal or Visual mode: end of Select mode mapping. | |
6680 */ | |
6681 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6682 nv_select(cmdarg_T *cap) |
7 | 6683 { |
6684 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
|
6685 { |
7 | 6686 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
|
6687 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
|
6688 } |
7 | 6689 else if (VIsual_reselect) |
6690 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6691 cap->nchar = 'v'; // fake "gv" command |
7 | 6692 cap->arg = TRUE; |
6693 nv_g_cmd(cap); | |
6694 } | |
6695 } | |
6696 | |
6697 | |
6698 /* | |
6699 * "G", "gg", CTRL-END, CTRL-HOME. | |
6700 * cap->arg is TRUE for "G". | |
6701 */ | |
6702 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6703 nv_goto(cmdarg_T *cap) |
7 | 6704 { |
6705 linenr_T lnum; | |
6706 | |
6707 if (cap->arg) | |
6708 lnum = curbuf->b_ml.ml_line_count; | |
6709 else | |
6710 lnum = 1L; | |
6711 cap->oap->motion_type = MLINE; | |
6712 setpcmark(); | |
6713 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6714 // When a count is given, use it instead of the default lnum |
7 | 6715 if (cap->count0 != 0) |
6716 lnum = cap->count0; | |
6717 if (lnum < 1L) | |
6718 lnum = 1L; | |
6719 else if (lnum > curbuf->b_ml.ml_line_count) | |
6720 lnum = curbuf->b_ml.ml_line_count; | |
6721 curwin->w_cursor.lnum = lnum; | |
6722 beginline(BL_SOL | BL_FIX); | |
6723 #ifdef FEAT_FOLDING | |
6724 if ((fdo_flags & FDO_JUMP) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6725 foldOpenCursor(); | |
6726 #endif | |
6727 } | |
6728 | |
6729 /* | |
6730 * CTRL-\ in Normal mode. | |
6731 */ | |
6732 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6733 nv_normal(cmdarg_T *cap) |
7 | 6734 { |
6735 if (cap->nchar == Ctrl_N || cap->nchar == Ctrl_G) | |
6736 { | |
6737 clearop(cap->oap); | |
643 | 6738 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
|
6739 clear_cmdline = TRUE; // unshow mode later |
7 | 6740 restart_edit = 0; |
6741 if (cmdwin_type != 0) | |
6742 cmdwin_result = Ctrl_C; | |
6743 if (VIsual_active) | |
6744 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6745 end_visual_mode(); // stop Visual |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
6746 redraw_curbuf_later(UPD_INVERTED); |
7 | 6747 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6748 // CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. |
7 | 6749 if (cap->nchar == Ctrl_G && p_im) |
6750 restart_edit = 'a'; | |
6751 } | |
6752 else | |
6753 clearopbeep(cap->oap); | |
6754 } | |
6755 | |
6756 /* | |
6757 * ESC in Normal mode: beep, but don't flush buffers. | |
6758 * Don't even beep if we are canceling a command. | |
6759 */ | |
6760 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6761 nv_esc(cmdarg_T *cap) |
7 | 6762 { |
6763 int no_reason; | |
6764 | |
6765 no_reason = (cap->oap->op_type == OP_NOP | |
6766 && cap->opcount == 0 | |
6767 && cap->count0 == 0 | |
6768 && cap->oap->regname == 0 | |
6769 && !p_im); | |
6770 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6771 if (cap->arg) // TRUE for CTRL-C |
7 | 6772 { |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30616
diff
changeset
|
6773 if (restart_edit == 0 && cmdwin_type == 0 |
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30616
diff
changeset
|
6774 && !VIsual_active && 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
|
6775 { |
30471
584231b9b37e
patch 9.0.0571: MS-Windows: CTRL-C can make Vim exit
Bram Moolenaar <Bram@vim.org>
parents:
30467
diff
changeset
|
6776 int out_redir = !stdout_isatty && !is_not_a_term_or_gui(); |
584231b9b37e
patch 9.0.0571: MS-Windows: CTRL-C can make Vim exit
Bram Moolenaar <Bram@vim.org>
parents:
30467
diff
changeset
|
6777 |
30467
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6778 // The user may accidentally do "vim file | grep word" and then |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6779 // CTRL-C doesn't show anything. With a changed buffer give the |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6780 // message on stderr. Without any changes might as well exit. |
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
|
6781 if (anyBufIsChanged()) |
30467
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6782 { |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6783 char *ms = _("Type :qa! and press <Enter> to abandon all changes and exit Vim"); |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6784 |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6785 if (out_redir) |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6786 mch_errmsg(ms); |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6787 else |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6788 msg(ms); |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6789 } |
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
|
6790 else |
30467
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6791 { |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6792 if (out_redir) |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6793 { |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6794 got_int = FALSE; |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6795 do_cmdline_cmd((char_u *)"qa"); |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6796 } |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6797 else |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6798 msg(_("Type :qa and press <Enter> to exit Vim")); |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6799 } |
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
|
6800 } |
7 | 6801 |
29179
432e1535ef2c
patch 8.2.5109: mode not updated after CTRL-O CTRL-C in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
29069
diff
changeset
|
6802 if (restart_edit != 0) |
432e1535ef2c
patch 8.2.5109: mode not updated after CTRL-O CTRL-C in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
29069
diff
changeset
|
6803 redraw_mode = TRUE; // remove "-- (insert) --" |
432e1535ef2c
patch 8.2.5109: mode not updated after CTRL-O CTRL-C in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
29069
diff
changeset
|
6804 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6805 // 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
|
6806 // set again below when halfway a mapping. |
7 | 6807 if (!p_im) |
6808 restart_edit = 0; | |
6809 if (cmdwin_type != 0) | |
6810 { | |
6811 cmdwin_result = K_IGNORE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6812 got_int = FALSE; // don't stop executing autocommands et al. |
7 | 6813 return; |
6814 } | |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30616
diff
changeset
|
6815 } |
29790
8874cb642b70
patch 9.0.0234: cannot make difference between :normal end and argument char
Bram Moolenaar <Bram@vim.org>
parents:
29765
diff
changeset
|
6816 else if (cmdwin_type != 0 && ex_normal_busy && typebuf_was_empty) |
24012
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6817 { |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6818 // When :normal runs out of characters while in the command line window |
29790
8874cb642b70
patch 9.0.0234: cannot make difference between :normal end and argument char
Bram Moolenaar <Bram@vim.org>
parents:
29765
diff
changeset
|
6819 // vgetorpeek() will repeatedly return ESC. Exit the cmdline window to |
8874cb642b70
patch 9.0.0234: cannot make difference between :normal end and argument char
Bram Moolenaar <Bram@vim.org>
parents:
29765
diff
changeset
|
6820 // break the loop. |
24012
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6821 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
|
6822 return; |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6823 } |
7 | 6824 |
6825 if (VIsual_active) | |
6826 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6827 end_visual_mode(); // stop Visual |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6828 check_cursor_col(); // make sure cursor is not beyond EOL |
7 | 6829 curwin->w_set_curswant = TRUE; |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
6830 redraw_curbuf_later(UPD_INVERTED); |
7 | 6831 } |
5735 | 6832 else if (no_reason) |
29944
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6833 { |
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6834 #ifdef HAS_MESSAGE_WINDOW |
29948
29e4cd9e66de
patch 9.0.0312: test for cmdheight zero fails
Bram Moolenaar <Bram@vim.org>
parents:
29944
diff
changeset
|
6835 if (!cap->arg && popup_message_win_visible()) |
29944
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6836 popup_hide_message_win(); |
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6837 else |
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6838 #endif |
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6839 vim_beep(BO_ESC); |
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6840 } |
7 | 6841 clearop(cap->oap); |
6842 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6843 // 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
|
6844 // 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
|
6845 if (restart_edit == 0 && goto_im() && ex_normal_busy == 0) |
7 | 6846 restart_edit = 'a'; |
6847 } | |
6848 | |
6849 /* | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6850 * 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
|
6851 */ |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6852 void |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6853 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
|
6854 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6855 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
|
6856 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
|
6857 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6858 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
|
6859 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6860 // 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
|
6861 // character past the end of the line |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
6862 State = MODE_INSERT; |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6863 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
|
6864 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
|
6865 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6866 else |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6867 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
|
6868 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6869 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6870 /* |
7 | 6871 * 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
|
6872 * Also handle K_PS, start bracketed paste. |
7 | 6873 */ |
6874 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6875 nv_edit(cmdarg_T *cap) |
7 | 6876 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6877 // <Insert> is equal to "i" |
7 | 6878 if (cap->cmdchar == K_INS || cap->cmdchar == K_KINS) |
6879 cap->cmdchar = 'i'; | |
6880 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6881 // in Visual mode "A" and "I" are an operator |
7 | 6882 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
|
6883 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6884 #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
|
6885 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
|
6886 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6887 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
|
6888 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
|
6889 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
|
6890 return; |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6891 } |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6892 #endif |
7 | 6893 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
|
6894 } |
7 | 6895 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6896 // in Visual mode and after an operator "a" and "i" are for text objects |
5735 | 6897 else if ((cap->cmdchar == 'a' || cap->cmdchar == 'i') |
6898 && (cap->oap->op_type != OP_NOP || VIsual_active)) | |
7 | 6899 { |
6900 nv_object(cap); | |
6901 } | |
11892
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6902 #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
|
6903 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
|
6904 { |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6905 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
|
6906 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
|
6907 return; |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6908 } |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6909 #endif |
7 | 6910 else if (!curbuf->b_p_ma && !p_im) |
6911 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6912 // 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
|
6913 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 6914 clearop(cap->oap); |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6915 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
|
6916 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6917 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 6918 } |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6919 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
|
6920 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6921 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
|
6922 pos_T old_visual = VIsual; |
28085
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6923 int old_visual_mode = VIsual_mode; |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6924 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6925 // 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
|
6926 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
|
6927 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6928 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
|
6929 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
|
6930 } |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6931 else |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6932 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
|
6933 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
|
6934 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
|
6935 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
|
6936 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
|
6937 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
|
6938 |
28085
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6939 if (*ml_get_cursor() != NUL) |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6940 { |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6941 if (old_visual_mode == 'V') |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6942 { |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6943 // In linewise Visual mode insert before the beginning of the |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6944 // next line. |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6945 // When the last line in the buffer was deleted then create a |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6946 // new line, otherwise there is not need to move cursor. |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6947 // Detect this by checking if cursor moved above Visual area. |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6948 if (curwin->w_cursor.lnum < old_pos.lnum |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6949 && curwin->w_cursor.lnum < old_visual.lnum) |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6950 { |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6951 if (u_save_cursor() == OK) |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6952 { |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6953 ml_append(curwin->w_cursor.lnum, (char_u *)"", 0, |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6954 FALSE); |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6955 appended_lines(curwin->w_cursor.lnum++, 1L); |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6956 } |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6957 } |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6958 } |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6959 // When the last char in the line was deleted then append. |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6960 // Detect this by checking if cursor moved before Visual area. |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6961 else if (curwin->w_cursor.col < old_pos.col |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6962 && curwin->w_cursor.col < old_visual.col) |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6963 inc_cursor(); |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6964 } |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6965 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6966 // 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
|
6967 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
|
6968 } |
7 | 6969 else if (!checkclearopq(cap->oap)) |
6970 { | |
6971 switch (cap->cmdchar) | |
6972 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6973 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
|
6974 set_cursor_for_append_to_line(); |
7 | 6975 break; |
6976 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6977 case 'I': // "I"nsert before the first non-blank |
164 | 6978 if (vim_strchr(p_cpo, CPO_INSEND) == NULL) |
6979 beginline(BL_WHITE); | |
6980 else | |
6981 beginline(BL_WHITE|BL_FIX); | |
7 | 6982 break; |
6983 | |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6984 case K_PS: |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6985 // 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
|
6986 // 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
|
6987 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
|
6988 break; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6989 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6990 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6991 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
|
6992 // 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
|
6993 // column otherwise, also to append after an unprintable char |
7 | 6994 if (virtual_active() |
6995 && (curwin->w_cursor.coladd > 0 | |
6996 || *ml_get_cursor() == NUL | |
6997 || *ml_get_cursor() == TAB)) | |
6998 curwin->w_cursor.coladd++; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
6999 else if (*ml_get_cursor() != NUL) |
7 | 7000 inc_cursor(); |
7001 break; | |
7002 } | |
7003 | |
7004 if (curwin->w_cursor.coladd && cap->cmdchar != 'A') | |
7005 { | |
7006 int save_State = State; | |
7007 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7008 // 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
|
7009 // character past the end of the line |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
7010 State = MODE_INSERT; |
7 | 7011 coladvance(getviscol()); |
7012 State = save_State; | |
7013 } | |
7014 | |
7015 invoke_edit(cap, FALSE, cap->cmdchar, FALSE); | |
7016 } | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7017 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
|
7018 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7019 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 7020 } |
7021 | |
7022 /* | |
7023 * Invoke edit() and take care of "restart_edit" and the return value. | |
7024 */ | |
7025 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7026 invoke_edit( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7027 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7028 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
|
7029 int cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7030 int startln) |
7 | 7031 { |
7032 int restart_edit_save = 0; | |
7033 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7034 // 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
|
7035 // 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
|
7036 // it. |
7 | 7037 if (repl || !stuff_empty()) |
7038 restart_edit_save = restart_edit; | |
7039 else | |
7040 restart_edit_save = 0; | |
7041 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7042 // Always reset "restart_edit", this is not a restarted edit. |
7 | 7043 restart_edit = 0; |
7044 | |
7045 if (edit(cmd, startln, cap->count1)) | |
7046 cap->retval |= CA_COMMAND_BUSY; | |
7047 | |
7048 if (restart_edit == 0) | |
7049 restart_edit = restart_edit_save; | |
7050 } | |
7051 | |
7052 /* | |
7053 * "a" or "i" while an operator is pending or in Visual mode: object motion. | |
7054 */ | |
7055 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7056 nv_object( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7057 cmdarg_T *cap) |
7 | 7058 { |
7059 int flag; | |
7060 int include; | |
7061 char_u *mps_save; | |
7062 | |
7063 if (cap->cmdchar == 'i') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7064 include = FALSE; // "ix" = inner object: exclude white space |
7 | 7065 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7066 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
|
7067 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7068 // Make sure (), [], {} and <> are in 'matchpairs' |
7 | 7069 mps_save = curbuf->b_p_mps; |
7070 curbuf->b_p_mps = (char_u *)"(:),{:},[:],<:>"; | |
7071 | |
7072 switch (cap->nchar) | |
7073 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7074 case 'w': // "aw" = a word |
7 | 7075 flag = current_word(cap->oap, cap->count1, include, FALSE); |
7076 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7077 case 'W': // "aW" = a WORD |
7 | 7078 flag = current_word(cap->oap, cap->count1, include, TRUE); |
7079 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7080 case 'b': // "ab" = a braces block |
7 | 7081 case '(': |
7082 case ')': | |
7083 flag = current_block(cap->oap, cap->count1, include, '(', ')'); | |
7084 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7085 case 'B': // "aB" = a Brackets block |
7 | 7086 case '{': |
7087 case '}': | |
7088 flag = current_block(cap->oap, cap->count1, include, '{', '}'); | |
7089 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7090 case '[': // "a[" = a [] block |
7 | 7091 case ']': |
7092 flag = current_block(cap->oap, cap->count1, include, '[', ']'); | |
7093 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7094 case '<': // "a<" = a <> block |
7 | 7095 case '>': |
7096 flag = current_block(cap->oap, cap->count1, include, '<', '>'); | |
7097 break; | |
29765
bc6cf208b1b4
patch 9.0.0222: no good reason why text objects are only in larger builds
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
7098 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7099 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
|
7100 // 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
|
7101 // 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
|
7102 // (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
|
7103 // 1) <b> 2) <b> |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7104 // foobar foobar |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7105 // </b> </b> |
6661 | 7106 cap->retval |= CA_NO_ADJ_OP_END; |
420 | 7107 flag = current_tagblock(cap->oap, cap->count1, include); |
7108 break; | |
29765
bc6cf208b1b4
patch 9.0.0222: no good reason why text objects are only in larger builds
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
7109 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7110 case 'p': // "ap" = a paragraph |
7 | 7111 flag = current_par(cap->oap, cap->count1, include, 'p'); |
7112 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7113 case 's': // "as" = a sentence |
7 | 7114 flag = current_sent(cap->oap, cap->count1, include); |
7115 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7116 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
|
7117 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
|
7118 case '`': // "a`" = a backtick quoted string |
12 | 7119 flag = current_quote(cap->oap, cap->count1, include, |
7120 cap->nchar); | |
7121 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7122 #if 0 // TODO |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7123 case 'S': // "aS" = a section |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7124 case 'f': // "af" = a filename |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7125 case 'u': // "au" = a URL |
7 | 7126 #endif |
7127 default: | |
7128 flag = FAIL; | |
7129 break; | |
7130 } | |
7131 | |
7132 curbuf->b_p_mps = mps_save; | |
7133 if (flag == FAIL) | |
7134 clearopbeep(cap->oap); | |
7135 adjust_cursor_col(); | |
7136 curwin->w_set_curswant = TRUE; | |
7137 } | |
7138 | |
7139 /* | |
7140 * "q" command: Start/stop recording. | |
7141 * "q:", "q/", "q?": edit command-line in command-line window. | |
7142 */ | |
7143 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7144 nv_record(cmdarg_T *cap) |
7 | 7145 { |
7146 if (cap->oap->op_type == OP_FORMAT) | |
7147 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7148 // "gqq" is the same as "gqgq": format line |
7 | 7149 cap->cmdchar = 'g'; |
7150 cap->nchar = 'q'; | |
7151 nv_operator(cap); | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7152 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7153 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7154 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7155 if (checkclearop(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7156 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7157 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7158 if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7159 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7160 if (cmdwin_type != 0) |
7 | 7161 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7162 emsg(_(e_cmdline_window_already_open)); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7163 return; |
7 | 7164 } |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7165 stuffcharReadbuff(cap->nchar); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7166 stuffcharReadbuff(K_CMDWIN); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7167 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7168 else |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7169 // (stop) recording into a named register, unless executing a |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7170 // register |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7171 if (reg_executing == 0 && do_record(cap->nchar) == FAIL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7172 clearopbeep(cap->oap); |
7 | 7173 } |
7174 | |
7175 /* | |
7176 * Handle the "@r" command. | |
7177 */ | |
7178 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7179 nv_at(cmdarg_T *cap) |
7 | 7180 { |
7181 if (checkclearop(cap->oap)) | |
7182 return; | |
7183 #ifdef FEAT_EVAL | |
7184 if (cap->nchar == '=') | |
7185 { | |
7186 if (get_expr_register() == NUL) | |
7187 return; | |
7188 } | |
7189 #endif | |
7190 while (cap->count1-- && !got_int) | |
7191 { | |
1034 | 7192 if (do_execreg(cap->nchar, FALSE, FALSE, FALSE) == FAIL) |
7 | 7193 { |
7194 clearopbeep(cap->oap); | |
7195 break; | |
7196 } | |
7197 line_breakcheck(); | |
7198 } | |
7199 } | |
7200 | |
7201 /* | |
7202 * Handle the CTRL-U and CTRL-D commands. | |
7203 */ | |
7204 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7205 nv_halfpage(cmdarg_T *cap) |
7 | 7206 { |
7207 if ((cap->cmdchar == Ctrl_U && curwin->w_cursor.lnum == 1) | |
7208 || (cap->cmdchar == Ctrl_D | |
7209 && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)) | |
7210 clearopbeep(cap->oap); | |
7211 else if (!checkclearop(cap->oap)) | |
7212 halfpage(cap->cmdchar == Ctrl_D, cap->count0); | |
7213 } | |
7214 | |
7215 /* | |
7216 * Handle "J" or "gJ" command. | |
7217 */ | |
7218 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7219 nv_join(cmdarg_T *cap) |
7 | 7220 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7221 if (VIsual_active) // join the visual lines |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7222 { |
7 | 7223 nv_operator(cap); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7224 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7225 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7226 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7227 if (checkclearop(cap->oap)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7228 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7229 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7230 if (cap->count0 <= 1) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7231 cap->count0 = 2; // default for join is two lines! |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7232 if (curwin->w_cursor.lnum + cap->count0 - 1 > |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7233 curbuf->b_ml.ml_line_count) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7234 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7235 // can't join when on the last line |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7236 if (cap->count0 <= 2) |
8445
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7237 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7238 clearopbeep(cap->oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7239 return; |
8445
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7240 } |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7241 cap->count0 = curbuf->b_ml.ml_line_count |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7242 - curwin->w_cursor.lnum + 1; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7243 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7244 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7245 prep_redo(cap->oap->regname, cap->count0, |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7246 NUL, cap->cmdchar, NUL, NUL, cap->nchar); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7247 (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); |
7 | 7248 } |
7249 | |
7250 /* | |
7251 * "P", "gP", "p" and "gp" commands. | |
7252 */ | |
7253 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7254 nv_put(cmdarg_T *cap) |
7 | 7255 { |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7256 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
|
7257 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7258 |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7259 /* |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7260 * "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
|
7261 * "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
|
7262 */ |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7263 static void |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7264 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
|
7265 { |
7 | 7266 int regname = 0; |
7267 void *reg1 = NULL, *reg2 = NULL; | |
84 | 7268 int empty = FALSE; |
236 | 7269 int was_visual = FALSE; |
7 | 7270 int dir; |
7271 int flags = 0; | |
28714
5eea8a249f86
patch 8.2.4881: "P" in Visual mode still changes some registers
Bram Moolenaar <Bram@vim.org>
parents:
28564
diff
changeset
|
7272 int keep_registers = FALSE; |
7 | 7273 |
7274 if (cap->oap->op_type != OP_NOP) | |
7275 { | |
7276 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7277 // "dp" is ":diffput" |
7 | 7278 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'p') |
7279 { | |
7280 clearop(cap->oap); | |
6314 | 7281 nv_diffgetput(TRUE, cap->opcount); |
7 | 7282 } |
7283 else | |
7284 #endif | |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7285 clearopbeep(cap->oap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7286 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7287 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7288 |
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
|
7289 #ifdef FEAT_JOB_CHANNEL |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7290 if (bt_prompt(curbuf) && !prompt_curpos_editable()) |
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
|
7291 { |
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
|
7292 clearopbeep(cap->oap); |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7293 return; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7294 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7295 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7296 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7297 if (fix_indent) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7298 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7299 dir = (cap->cmdchar == ']' && cap->nchar == 'p') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7300 ? FORWARD : BACKWARD; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7301 flags |= PUT_FIXINDENT; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7302 } |
7 | 7303 else |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7304 dir = (cap->cmdchar == 'P' |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7305 || ((cap->cmdchar == 'g' || cap->cmdchar == 'z') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7306 && cap->nchar == 'P')) ? BACKWARD : FORWARD; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7307 prep_redo_cmd(cap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7308 if (cap->cmdchar == 'g') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7309 flags |= PUT_CURSEND; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7310 else if (cap->cmdchar == 'z') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7311 flags |= PUT_BLOCK_INNER; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7312 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7313 if (VIsual_active) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7314 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7315 // Putting in Visual mode: The put text replaces the selected |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7316 // text. First delete the selected text, then put the new text. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7317 // Need to save and restore the registers that the delete |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7318 // overwrites if the old contents is being put. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7319 was_visual = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7320 regname = cap->oap->regname; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7321 keep_registers = cap->cmdchar == 'P'; |
5735 | 7322 #ifdef FEAT_CLIPBOARD |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7323 adjust_clip_reg(®name); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7324 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7325 if (regname == 0 || regname == '"' |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7326 || VIM_ISDIGIT(regname) || regname == '-' |
5735 | 7327 #ifdef FEAT_CLIPBOARD |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7328 || (clip_unnamed && (regname == '*' || regname == '+')) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7329 #endif |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7330 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7331 ) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7332 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7333 // The delete is going to overwrite the register we want to |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7334 // put, save it first. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7335 reg1 = get_register(regname, TRUE); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7336 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7337 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7338 // Now delete the selected text. Avoid messages here. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7339 cap->cmdchar = 'd'; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7340 cap->nchar = NUL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7341 cap->oap->regname = keep_registers ? '_' : NUL; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7342 ++msg_silent; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7343 nv_operator(cap); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7344 do_pending_operator(cap, 0, FALSE); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7345 empty = (curbuf->b_ml.ml_flags & ML_EMPTY); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7346 --msg_silent; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7347 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7348 // delete PUT_LINE_BACKWARD; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7349 cap->oap->regname = regname; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7350 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7351 if (reg1 != NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7352 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7353 // Delete probably changed the register we want to put, save |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7354 // it first. Then put back what was there before the delete. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7355 reg2 = get_register(regname, FALSE); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7356 put_register(regname, reg1); |
7 | 7357 } |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7358 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7359 // When deleted a linewise Visual area, put the register as |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7360 // lines to avoid it joined with the next line. When deletion was |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7361 // characterwise, split a line when putting lines. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7362 if (VIsual_mode == 'V') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7363 flags |= PUT_LINE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7364 else if (VIsual_mode == 'v') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7365 flags |= PUT_LINE_SPLIT; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7366 if (VIsual_mode == Ctrl_V && dir == FORWARD) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7367 flags |= PUT_LINE_FORWARD; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7368 dir = BACKWARD; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7369 if ((VIsual_mode != 'V' |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7370 && curwin->w_cursor.col < curbuf->b_op_start.col) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7371 || (VIsual_mode == 'V' |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7372 && curwin->w_cursor.lnum < curbuf->b_op_start.lnum)) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7373 // cursor is at the end of the line or end of file, put |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7374 // forward. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7375 dir = FORWARD; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7376 // May have been reset in do_put(). |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7377 VIsual_active = TRUE; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7378 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7379 do_put(cap->oap->regname, NULL, dir, cap->count1, flags); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7380 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7381 // If a register was saved, put it back now. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7382 if (reg2 != NULL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7383 put_register(regname, reg2); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7384 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7385 // What to reselect with "gv"? Selecting the just put text seems to |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7386 // be the most useful, since the original text was removed. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7387 if (was_visual) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7388 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7389 curbuf->b_visual.vi_start = curbuf->b_op_start; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7390 curbuf->b_visual.vi_end = curbuf->b_op_end; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7391 // need to adjust cursor position |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7392 if (*p_sel == 'e') |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7393 inc(&curbuf->b_visual.vi_end); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7394 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7395 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7396 // When all lines were selected and deleted do_put() leaves an empty |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7397 // line that needs to be deleted now. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7398 if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7399 { |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7400 ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7401 deleted_lines(curbuf->b_ml.ml_line_count + 1, 1); |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7402 |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7403 // If the cursor was in that line, move it to the end of the last |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7404 // line. |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7405 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
236 | 7406 { |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7407 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7408 coladvance((colnr_T)MAXCOL); |
236 | 7409 } |
31752
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7410 } |
3365a601e73b
patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31714
diff
changeset
|
7411 auto_format(FALSE, TRUE); |
7 | 7412 } |
7413 | |
7414 /* | |
7415 * "o" and "O" commands. | |
7416 */ | |
7417 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7418 nv_open(cmdarg_T *cap) |
7 | 7419 { |
7420 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7421 // "do" is ":diffget" |
7 | 7422 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'o') |
7423 { | |
7424 clearop(cap->oap); | |
6314 | 7425 nv_diffgetput(FALSE, cap->opcount); |
7 | 7426 } |
7427 else | |
7428 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7429 if (VIsual_active) // switch start and end of visual |
7 | 7430 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
|
7431 #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
|
7432 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
|
7433 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
|
7434 #endif |
7 | 7435 else |
7436 n_opencmd(cap); | |
7437 } | |
7438 | |
7439 #ifdef FEAT_NETBEANS_INTG | |
7440 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7441 nv_nbcmd(cmdarg_T *cap) |
7 | 7442 { |
7443 netbeans_keycommand(cap->nchar); | |
7444 } | |
7445 #endif | |
7446 | |
7447 #ifdef FEAT_DND | |
7448 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7449 nv_drop(cmdarg_T *cap UNUSED) |
7 | 7450 { |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7451 do_put('~', NULL, BACKWARD, 1L, PUT_CURSEND); |
7 | 7452 } |
7453 #endif | |
203 | 7454 |
7455 /* | |
7456 * Trigger CursorHold event. | |
7457 * When waiting for a character for 'updatetime' K_CURSORHOLD is put in the | |
7458 * input buffer. "did_cursorhold" is set to avoid retriggering. | |
7459 */ | |
7460 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7461 nv_cursorhold(cmdarg_T *cap) |
203 | 7462 { |
7463 apply_autocmds(EVENT_CURSORHOLD, NULL, NULL, FALSE, curbuf); | |
7464 did_cursorhold = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7465 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
226 | 7466 } |