Mercurial > vim
annotate src/normal.c @ 31426:92afb904fbee v9.0.1046
patch 9.0.1046: class method disassemble test fails on MS-Windows
Commit: https://github.com/vim/vim/commit/3ea8a1b1296af5b0c6a163ab995aa16d49ac5f10
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 10 19:03:51 2022 +0000
patch 9.0.1046: class method disassemble test fails on MS-Windows
Problem: Class method disassemble test fails on MS-Windows.
Solution: Do not match with a specific size.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 10 Dec 2022 20:15:02 +0100 |
parents | ff4473b3fc58 |
children | bb797331e21b |
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 { |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
189 if (text_locked()) |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
190 { |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
191 if (oap != NULL) |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
192 clearopbeep(oap); |
29002
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
193 text_locked_msg(); |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
194 return TRUE; |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
195 } |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
196 return FALSE; |
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 |
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
199 /* |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
200 * 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
|
201 * 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
|
202 * "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
|
203 */ |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
204 int |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
205 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
|
206 { |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
207 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
|
208 return TRUE; |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
209 if (curbuf_locked()) |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
210 { |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
211 if (oap != NULL) |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
212 clearop(oap); |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
213 return TRUE; |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
214 } |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
215 return FALSE; |
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 |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
218 /* |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
219 * 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
|
220 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
221 static int |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
222 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
|
223 cmdarg_T *cap, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
224 int c, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
225 int toplevel UNUSED, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
226 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
|
227 int *ctrl_w, |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
228 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
|
229 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
230 getcount: |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
231 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
|
232 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
233 // 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
|
234 // 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
|
235 // 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
|
236 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
|
237 || (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
|
238 || c == '0'))) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
239 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
240 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
|
241 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
242 cap->count0 /= 10; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
243 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
|
244 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
245 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
|
246 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
247 cap->count0 = 999999999L; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
248 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
249 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
250 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
251 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
|
252 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
253 #ifdef FEAT_EVAL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
254 // 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
|
255 // 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
|
256 // 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
|
257 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
|
258 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
|
259 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
260 if (*ctrl_w) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
261 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
262 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
263 ++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
|
264 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
265 ++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
|
266 c = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
267 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
|
268 --no_zero_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
269 if (*ctrl_w) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
270 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
271 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
272 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
273 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
274 *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
|
275 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
276 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
277 // If we 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
|
278 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
|
279 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
280 *ctrl_w = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
281 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
|
282 cap->count0 = 0; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
283 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
284 ++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
|
285 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
|
286 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
|
287 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
288 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
289 *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
|
290 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
|
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 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
294 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
|
295 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
296 // 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
|
297 // 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
|
298 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
|
299 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
|
300 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
301 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
|
302 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
303 // 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
|
304 // 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
|
305 // 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
|
306 // 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
|
307 // 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
|
308 // 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
|
309 // multiplied. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
310 if (cap->count0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
311 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
312 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
|
313 cap->count0 = 999999999L; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
314 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
315 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
|
316 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
317 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
318 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
|
319 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
320 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
321 // 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
|
322 // 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
|
323 // 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
|
324 // variable. |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
325 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
|
326 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
|
327 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
328 #ifdef FEAT_EVAL |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
329 // 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
|
330 // 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
|
331 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
|
332 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
|
333 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
334 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
335 return c; |
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 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
339 * 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
|
340 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
341 static int |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
342 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
|
343 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
344 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
|
345 && (((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
|
346 && 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
|
347 || (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
|
348 || (cap->cmdchar == 'q' |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
349 && 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
|
350 && reg_recording == 0 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
351 && reg_executing == 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
352 || ((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
|
353 && (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
|
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 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
357 * 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
|
358 * 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
|
359 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
360 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
|
361 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
|
362 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
|
363 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
|
364 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
|
365 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
366 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
|
367 int c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
368 int *cp; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
369 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
|
370 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
|
371 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
|
372 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
|
373 #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
|
374 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
|
375 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
376 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
377 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
378 ++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
|
379 // 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
|
380 // 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
|
381 did_cursorhold = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
382 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
|
383 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
384 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
385 * 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
|
386 * "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
|
387 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
388 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
|
389 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
|
390 *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
|
391 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
|
392 || 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
|
393 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
394 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
|
395 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
|
396 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
|
397 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
398 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
|
399 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
400 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
401 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
|
402 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
403 else |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
404 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
405 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
|
406 repl = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
407 cp = &cap->nchar; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
408 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
409 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
|
410 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
411 /* |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
412 * 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
|
413 */ |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
414 if (cp != NULL) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
415 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
416 if (repl) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
417 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
418 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
|
419 #ifdef CURSOR_SHAPE |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
420 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
|
421 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
422 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
423 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
|
424 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
425 // 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
|
426 --no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
427 --allow_keys; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
428 if (repl) |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
429 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
|
430 else |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
431 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
|
432 langmap_active = TRUE; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
433 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
434 #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
|
435 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
|
436 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
|
437 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
|
438 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
|
439 #endif |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
440 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
|
441 { |
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
|
442 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
|
443 |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
444 // 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
|
445 // 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
|
446 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
|
447 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
|
448 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
449 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
450 *cp = plain_vgetc(); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
451 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
452 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
|
453 { |
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
|
454 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
|
455 |
27354
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
456 // Re-enable bracketed paste mode and modifyOtherKeys |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
457 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
|
458 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
|
459 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
460 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
461 if (langmap_active) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
462 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
463 // 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
|
464 ++no_mapping; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
465 ++allow_keys; |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
466 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
|
467 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
468 #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
|
469 if (lang) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
470 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
471 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
|
472 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
|
473 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
|
474 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
475 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
|
476 #endif |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
477 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
|
478 *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
|
479 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
480 if (!lit) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
481 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
482 #ifdef FEAT_DIGRAPHS |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
483 // 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
|
484 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
|
485 && ((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
|
486 || 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
|
487 && 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
|
488 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
489 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
|
490 if (c > 0) |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
491 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
492 *cp = c; |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
493 // 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
|
494 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
|
495 *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
|
496 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
497 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
498 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
499 |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
500 // 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
|
501 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
|
502 #ifdef FEAT_RIGHTLEFT |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
503 // 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
|
504 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
|
505 *cp = hkmap(*cp); |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
506 #endif |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
507 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
508 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
509 // 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
|
510 // 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
|
511 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
|
512 && 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
|
513 && (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
|
514 { |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
515 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
|
516 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
|
517 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
|
518 } |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
519 else if ((cap->nchar == 'n' || cap->nchar == 'N') && cap->cmdchar == 'g') |
469e643b7729
patch 8.2.4205: the normal_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27273
diff
changeset
|
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 |
902 if (ca.nchar == ESC) | |
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 |
980 c = finish_op; | |
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. |
7 | 987 if (c || ca.cmdchar == 'r') |
988 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
989 ui_cursor_shape(); // may show different cursor shape |
7 | 990 # ifdef FEAT_MOUSESHAPE |
991 update_mouseshape(-1); | |
992 # endif | |
993 } | |
994 #endif | |
995 | |
1692 | 996 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
|
997 && ca.cmdchar != K_CURSORHOLD) |
7 | 998 clear_showcmd(); |
999 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1000 checkpcmark(); // check if we moved since setting pcmark |
7 | 1001 vim_free(ca.searchbuf); |
1002 | |
1003 if (has_mbyte) | |
1004 mb_adjust_cursor(); | |
1005 | |
1006 if (curwin->w_p_scb && toplevel) | |
1007 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1008 validate_cursor(); // may need to update w_leftcol |
7 | 1009 do_check_scrollbind(TRUE); |
1010 } | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
1011 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1012 if (curwin->w_p_crb && toplevel) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1013 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1014 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
|
1015 do_check_cursorbind(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1016 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1017 |
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
|
1018 #ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1019 // 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
|
1020 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
|
1021 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
|
1022 #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
|
1023 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1024 // 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
|
1025 // 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
|
1026 // May switch from Visual to Select mode after CTRL-O command. |
7 | 1027 if ( oap->op_type == OP_NOP |
1028 && ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0) | |
1029 || restart_VIsual_select == 1) | |
1030 && !(ca.retval & CA_COMMAND_BUSY) | |
1031 && stuff_empty() | |
1032 && oap->regname == 0) | |
1033 { | |
1034 if (restart_VIsual_select == 1) | |
1035 { | |
1036 VIsual_select = TRUE; | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
1037 may_trigger_modechanged(); |
7 | 1038 showmode(); |
1039 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
|
1040 VIsual_select_reg = 0; |
7 | 1041 } |
5735 | 1042 if (restart_edit != 0 && !VIsual_active && old_mapped_len == 0) |
7 | 1043 (void)edit(restart_edit, FALSE, 1L); |
1044 } | |
1045 | |
1046 if (restart_VIsual_select == 2) | |
1047 restart_VIsual_select = 1; | |
1048 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1049 // Save count before an operator for next time. |
7 | 1050 opcount = ca.opcount; |
1051 } | |
1052 | |
2667 | 1053 #ifdef FEAT_EVAL |
1054 /* | |
1055 * Set v:count and v:count1 according to "cap". | |
1056 * Set v:prevcount only when "set_prevcount" is TRUE. | |
1057 */ | |
1058 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1059 set_vcount_ca(cmdarg_T *cap, int *set_prevcount) |
2667 | 1060 { |
1061 long count = cap->count0; | |
1062 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1063 // multiply with cap->opcount the same way as above |
2667 | 1064 if (cap->opcount != 0) |
1065 count = cap->opcount * (count == 0 ? 1 : count); | |
1066 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
|
1067 *set_prevcount = FALSE; // only set v:prevcount once |
2667 | 1068 } |
1069 #endif | |
1070 | |
7 | 1071 /* |
19681
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1072 * Check if highlighting for Visual mode is possible, give a warning message |
7 | 1073 * if not. |
1074 */ | |
1075 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1076 check_visual_highlight(void) |
7 | 1077 { |
1078 static int did_check = FALSE; | |
1079 | |
1080 if (full_screen) | |
1081 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
1082 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
|
1083 msg(_("Warning: terminal cannot highlight")); |
7 | 1084 did_check = TRUE; |
1085 } | |
1086 } | |
1087 | |
23021
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1088 #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
|
1089 /* |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1090 * 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
|
1091 */ |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1092 static void |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1093 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
|
1094 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1095 oparg_T oa; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1096 yankreg_T *reg; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1097 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1098 clear_oparg(&oa); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1099 oa.regname = regname; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1100 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
|
1101 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
|
1102 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
|
1103 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
|
1104 free_register(reg); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1105 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1106 #endif |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1107 |
7 | 1108 /* |
638 | 1109 * End Visual mode. |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1110 * 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
|
1111 * from do_pending_operator(). |
7 | 1112 */ |
1113 void | |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1114 end_visual_mode() |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1115 { |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1116 end_visual_mode_keep_button(); |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1117 reset_held_button(); |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1118 } |
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 void |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1121 end_visual_mode_keep_button() |
7 | 1122 { |
1123 #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
|
1124 // 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
|
1125 // 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
|
1126 // 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
|
1127 // the selection when hitting ESC. |
7 | 1128 if (clip_star.available && clip_star.owned) |
1129 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
|
1130 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1131 # 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
|
1132 // 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
|
1133 // 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
|
1134 if (has_textyankpost()) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1135 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1136 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
|
1137 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
|
1138 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
|
1139 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
|
1140 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1141 # endif |
7 | 1142 #endif |
1143 | |
1144 VIsual_active = FALSE; | |
1145 setmouse(); | |
1146 mouse_dragging = 0; | |
1147 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1148 // Save the current VIsual area for '< and '> marks, and "gv" |
690 | 1149 curbuf->b_visual.vi_mode = VIsual_mode; |
1150 curbuf->b_visual.vi_start = VIsual; | |
1151 curbuf->b_visual.vi_end = curwin->w_cursor; | |
1152 curbuf->b_visual.vi_curswant = curwin->w_curswant; | |
7 | 1153 #ifdef FEAT_EVAL |
1154 curbuf->b_visual_mode_eval = VIsual_mode; | |
1155 #endif | |
1156 if (!virtual_active()) | |
1157 curwin->w_cursor.coladd = 0; | |
6979 | 1158 may_clear_cmdline(); |
7 | 1159 |
844 | 1160 adjust_cursor_eol(); |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
1161 may_trigger_modechanged(); |
7 | 1162 } |
1163 | |
1164 /* | |
1165 * Reset VIsual_active and VIsual_reselect. | |
1166 */ | |
1167 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1168 reset_VIsual_and_resel(void) |
7 | 1169 { |
1170 if (VIsual_active) | |
1171 { | |
1172 end_visual_mode(); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1173 redraw_curbuf_later(UPD_INVERTED); // delete the inversion later |
7 | 1174 } |
1175 VIsual_reselect = FALSE; | |
1176 } | |
1177 | |
1178 /* | |
1179 * Reset VIsual_active and VIsual_reselect if it's set. | |
1180 */ | |
1181 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1182 reset_VIsual(void) |
7 | 1183 { |
1184 if (VIsual_active) | |
1185 { | |
1186 end_visual_mode(); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1187 redraw_curbuf_later(UPD_INVERTED); // delete the inversion later |
7 | 1188 VIsual_reselect = FALSE; |
1189 } | |
1190 } | |
1191 | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1192 void |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1193 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
|
1194 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1195 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
|
1196 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1197 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
|
1198 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
|
1199 } |
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 |
7 | 1202 /* |
1203 * Check for a balloon-eval special item to include when searching for an | |
1204 * identifier. When "dir" is BACKWARD "ptr[-1]" must be valid! | |
1205 * Returns TRUE if the character at "*ptr" should be included. | |
1206 * "dir" is FORWARD or BACKWARD, the direction of searching. | |
1207 * "*colp" is in/decremented if "ptr[-dir]" should also be included. | |
1208 * "bnp" points to a counter for square brackets. | |
1209 */ | |
1210 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1211 find_is_eval_item( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1212 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1213 int *colp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1214 int *bnp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1215 int dir) |
7 | 1216 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1217 // Accept everything inside []. |
7 | 1218 if ((*ptr == ']' && dir == BACKWARD) || (*ptr == '[' && dir == FORWARD)) |
1219 ++*bnp; | |
1220 if (*bnp > 0) | |
1221 { | |
1222 if ((*ptr == '[' && dir == BACKWARD) || (*ptr == ']' && dir == FORWARD)) | |
1223 --*bnp; | |
1224 return TRUE; | |
1225 } | |
1226 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1227 // skip over "s.var" |
7 | 1228 if (*ptr == '.') |
1229 return TRUE; | |
1230 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1231 // two-character item: s->var |
7 | 1232 if (ptr[dir == BACKWARD ? 0 : 1] == '>' |
1233 && ptr[dir == BACKWARD ? -1 : 0] == '-') | |
1234 { | |
1235 *colp += dir; | |
1236 return TRUE; | |
1237 } | |
1238 return FALSE; | |
1239 } | |
1240 | |
1241 /* | |
1242 * Find the identifier under or to the right of the cursor. | |
1243 * "find_type" can have one of three values: | |
1244 * 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
|
1245 * 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
|
1246 * FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred. |
184 | 1247 * FIND_EVAL: find text useful for C program debugging |
7 | 1248 * |
1249 * 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
|
1250 * 1. Search forward for the start of an identifier/text. Doesn't move if |
7 | 1251 * 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
|
1252 * 2. Search backward for the start of this identifier/text. |
7 | 1253 * This doesn't match the real Vi but I like it a little better and it |
1254 * 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
|
1255 * 3. Search forward to the end of this identifier/text. |
7 | 1256 * When FIND_IDENT isn't defined, we backup until a blank. |
1257 * | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1258 * 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
|
1259 * 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
|
1260 * points into the current buffer line and is not always NUL terminated. |
7 | 1261 */ |
1262 int | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1263 find_ident_under_cursor(char_u **text, int find_type) |
7 | 1264 { |
1265 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
|
1266 curwin->w_cursor.col, text, NULL, find_type); |
7 | 1267 } |
1268 | |
1269 /* | |
1270 * Like find_ident_under_cursor(), but for any window and any position. | |
1271 * However: Uses 'iskeyword' from the current window!. | |
1272 */ | |
1273 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1274 find_ident_at_pos( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1275 win_T *wp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1276 linenr_T lnum, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1277 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
|
1278 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
|
1279 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
|
1280 int find_type) |
7 | 1281 { |
1282 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
|
1283 int col = 0; // init to shut up GCC |
7 | 1284 int i; |
1285 int this_class = 0; | |
1286 int prev_class; | |
1287 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
|
1288 int bn = 0; // bracket nesting |
7 | 1289 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1290 // 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
|
1291 // if i == 1: try to find any non-white text |
7 | 1292 ptr = ml_get_buf(wp->w_buffer, lnum, FALSE); |
1293 for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i) | |
1294 { | |
1295 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1296 * 1. skip to start of identifier/text |
7 | 1297 */ |
1298 col = startcol; | |
1299 if (has_mbyte) | |
1300 { | |
1301 while (ptr[col] != NUL) | |
1302 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1303 // Stop at a ']' to evaluate "a[x]". |
7 | 1304 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1305 break; | |
1306 this_class = mb_get_class(ptr + col); | |
1307 if (this_class != 0 && (i == 1 || this_class != 1)) | |
1308 break; | |
474 | 1309 col += (*mb_ptr2len)(ptr + col); |
7 | 1310 } |
1311 } | |
1312 else | |
1313 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
|
1314 && (i == 0 ? !vim_iswordc(ptr[col]) : VIM_ISWHITE(ptr[col])) |
7 | 1315 && (!(find_type & FIND_EVAL) || ptr[col] != ']') |
1316 ) | |
1317 ++col; | |
1318 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1319 // When starting on a ']' count it, so that we include the '['. |
7 | 1320 bn = ptr[col] == ']'; |
1321 | |
1322 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1323 * 2. Back up to start of identifier/text. |
7 | 1324 */ |
1325 if (has_mbyte) | |
1326 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1327 // Remember class of character under cursor. |
7 | 1328 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1329 this_class = mb_get_class((char_u *)"a"); | |
1330 else | |
1331 this_class = mb_get_class(ptr + col); | |
835 | 1332 while (col > 0 && this_class != 0) |
7 | 1333 { |
1334 prevcol = col - 1 - (*mb_head_off)(ptr, ptr + col - 1); | |
1335 prev_class = mb_get_class(ptr + prevcol); | |
1336 if (this_class != prev_class | |
1337 && (i == 0 | |
1338 || prev_class == 0 | |
1339 || (find_type & FIND_IDENT)) | |
1340 && (!(find_type & FIND_EVAL) | |
1341 || prevcol == 0 | |
1342 || !find_is_eval_item(ptr + prevcol, &prevcol, | |
1343 &bn, BACKWARD)) | |
1344 ) | |
1345 break; | |
1346 col = prevcol; | |
1347 } | |
1348 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1349 // 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
|
1350 // identifier, stop searching. |
7 | 1351 if (this_class > 2) |
1352 this_class = 2; | |
1353 if (!(find_type & FIND_STRING) || this_class == 2) | |
1354 break; | |
1355 } | |
1356 else | |
1357 { | |
1358 while (col > 0 | |
1359 && ((i == 0 | |
1360 ? 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
|
1361 : (!VIM_ISWHITE(ptr[col - 1]) |
7 | 1362 && (!(find_type & FIND_IDENT) |
1363 || !vim_iswordc(ptr[col - 1])))) | |
1364 || ((find_type & FIND_EVAL) | |
1365 && col > 1 | |
1366 && find_is_eval_item(ptr + col - 1, &col, | |
1367 &bn, BACKWARD)) | |
1368 )) | |
1369 --col; | |
1370 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1371 // 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
|
1372 // identifier, stop searching. |
7 | 1373 if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col])) |
1374 break; | |
1375 } | |
1376 } | |
1377 | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1378 if (ptr[col] == NUL || (i == 0 |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1379 && (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col])))) |
7 | 1380 { |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1381 // 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
|
1382 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
|
1383 { |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1384 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
|
1385 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
|
1386 else |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
1387 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
|
1388 } |
7 | 1389 return 0; |
1390 } | |
1391 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
|
1392 *text = ptr; |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1393 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
|
1394 *textcol = col; |
7 | 1395 |
1396 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1397 * 3. Find the end if the identifier/text. |
7 | 1398 */ |
1399 bn = 0; | |
1400 startcol -= col; | |
1401 col = 0; | |
1402 if (has_mbyte) | |
1403 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1404 // Search for point of changing multibyte character class. |
7 | 1405 this_class = mb_get_class(ptr); |
1406 while (ptr[col] != NUL | |
1407 && ((i == 0 ? mb_get_class(ptr + col) == this_class | |
1408 : mb_get_class(ptr + col) != 0) | |
1409 || ((find_type & FIND_EVAL) | |
1410 && col <= (int)startcol | |
1411 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1412 )) | |
474 | 1413 col += (*mb_ptr2len)(ptr + col); |
7 | 1414 } |
1415 else | |
1416 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
|
1417 : (ptr[col] != NUL && !VIM_ISWHITE(ptr[col]))) |
7 | 1418 || ((find_type & FIND_EVAL) |
1419 && col <= (int)startcol | |
1420 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1421 ) | |
1422 ++col; | |
1423 | |
1424 return col; | |
1425 } | |
1426 | |
1427 /* | |
1428 * Prepare for redo of a normal command. | |
1429 */ | |
1430 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1431 prep_redo_cmd(cmdarg_T *cap) |
7 | 1432 { |
1433 prep_redo(cap->oap->regname, cap->count0, | |
1434 NUL, cap->cmdchar, NUL, NUL, cap->nchar); | |
1435 } | |
1436 | |
1437 /* | |
1438 * Prepare for redo of any command. | |
1439 * Note that only the last argument can be a multi-byte char. | |
1440 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1441 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1442 prep_redo( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1443 int regname, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1444 long num, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1445 int cmd1, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1446 int cmd2, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1447 int cmd3, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1448 int cmd4, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1449 int cmd5) |
7 | 1450 { |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1451 prep_redo_num2(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
|
1452 } |
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 * 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
|
1456 */ |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1457 void |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1458 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
|
1459 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
|
1460 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
|
1461 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
|
1462 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
|
1463 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
|
1464 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
|
1465 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
|
1466 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
|
1467 { |
7 | 1468 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
|
1469 |
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1470 #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
|
1471 // 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
|
1472 // 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
|
1473 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
|
1474 #endif |
539fb427124d
patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
1475 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1476 if (regname != 0) // yank from specified buffer |
7 | 1477 { |
1478 AppendCharToRedobuff('"'); | |
1479 AppendCharToRedobuff(regname); | |
1480 } | |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1481 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
|
1482 AppendNumberToRedobuff(num1); |
7 | 1483 if (cmd1 != NUL) |
1484 AppendCharToRedobuff(cmd1); | |
1485 if (cmd2 != NUL) | |
1486 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
|
1487 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
|
1488 AppendNumberToRedobuff(num2); |
7 | 1489 if (cmd3 != NUL) |
1490 AppendCharToRedobuff(cmd3); | |
1491 if (cmd4 != NUL) | |
1492 AppendCharToRedobuff(cmd4); | |
1493 if (cmd5 != NUL) | |
1494 AppendCharToRedobuff(cmd5); | |
1495 } | |
1496 | |
1497 /* | |
1498 * check for operator active and clear it | |
1499 * | |
1500 * return TRUE if operator was active | |
1501 */ | |
1502 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1503 checkclearop(oparg_T *oap) |
7 | 1504 { |
1505 if (oap->op_type == OP_NOP) | |
1506 return FALSE; | |
1507 clearopbeep(oap); | |
1508 return TRUE; | |
1509 } | |
1510 | |
1511 /* | |
1131 | 1512 * Check for operator or Visual active. Clear active operator. |
7 | 1513 * |
1131 | 1514 * Return TRUE if operator or Visual was active. |
7 | 1515 */ |
1516 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1517 checkclearopq(oparg_T *oap) |
7 | 1518 { |
5735 | 1519 if (oap->op_type == OP_NOP && !VIsual_active) |
7 | 1520 return FALSE; |
1521 clearopbeep(oap); | |
1522 return TRUE; | |
1523 } | |
1524 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1525 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1526 clearop(oparg_T *oap) |
7 | 1527 { |
1528 oap->op_type = OP_NOP; | |
1529 oap->regname = 0; | |
1530 oap->motion_force = NUL; | |
1531 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
|
1532 motion_force = NUL; |
7 | 1533 } |
1534 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1535 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1536 clearopbeep(oparg_T *oap) |
7 | 1537 { |
1538 clearop(oap); | |
1539 beep_flush(); | |
1540 } | |
1541 | |
1542 /* | |
1543 * Remove the shift modifier from a special key. | |
1544 */ | |
1545 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1546 unshift_special(cmdarg_T *cap) |
7 | 1547 { |
1548 switch (cap->cmdchar) | |
1549 { | |
1550 case K_S_RIGHT: cap->cmdchar = K_RIGHT; break; | |
1551 case K_S_LEFT: cap->cmdchar = K_LEFT; break; | |
1552 case K_S_UP: cap->cmdchar = K_UP; break; | |
1553 case K_S_DOWN: cap->cmdchar = K_DOWN; break; | |
1554 case K_S_HOME: cap->cmdchar = K_HOME; break; | |
1555 case K_S_END: cap->cmdchar = K_END; break; | |
1556 } | |
1557 cap->cmdchar = simplify_key(cap->cmdchar, &mod_mask); | |
1558 } | |
1559 | |
6979 | 1560 /* |
1561 * If the mode is currently displayed clear the command line or update the | |
1562 * command displayed. | |
1563 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1564 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1565 may_clear_cmdline(void) |
6979 | 1566 { |
1567 if (mode_displayed) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1568 clear_cmdline = TRUE; // unshow visual mode later |
6979 | 1569 else |
1570 clear_showcmd(); | |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1571 } |
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
1572 |
7 | 1573 /* |
1574 * Routines for displaying a partly typed command | |
1575 */ | |
1576 | |
27752
c1d1639b52dd
patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1577 #define SHOWCMD_BUFLEN (SHOWCMD_COLS + 1 + 30) |
7 | 1578 static char_u showcmd_buf[SHOWCMD_BUFLEN]; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1579 static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd() |
7 | 1580 static int showcmd_is_clear = TRUE; |
1581 static int showcmd_visual = FALSE; | |
1582 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
1583 static void display_showcmd(void); |
7 | 1584 |
1585 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1586 clear_showcmd(void) |
7 | 1587 { |
1588 if (!p_sc) | |
1589 return; | |
1590 | |
1591 if (VIsual_active && !char_avail()) | |
1592 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
1593 int cursor_bot = LT_POS(VIsual, curwin->w_cursor); |
7 | 1594 long lines; |
1595 colnr_T leftcol, rightcol; | |
1596 linenr_T top, bot; | |
1597 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1598 // Show the size of the Visual area. |
1866 | 1599 if (cursor_bot) |
7 | 1600 { |
1601 top = VIsual.lnum; | |
1602 bot = curwin->w_cursor.lnum; | |
1603 } | |
1604 else | |
1605 { | |
1606 top = curwin->w_cursor.lnum; | |
1607 bot = VIsual.lnum; | |
1608 } | |
1609 # ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1610 // Include closed folds as a whole. |
7009 | 1611 (void)hasFolding(top, &top, NULL); |
1612 (void)hasFolding(bot, NULL, &bot); | |
7 | 1613 # endif |
1614 lines = bot - top + 1; | |
1615 | |
1616 if (VIsual_mode == Ctrl_V) | |
1617 { | |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1618 # ifdef FEAT_LINEBREAK |
1866 | 1619 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
|
1620 char_u *saved_w_sbr = curwin->w_p_sbr; |
1866 | 1621 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1622 // Make 'sbr' empty for a moment to get the correct size. |
1866 | 1623 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
|
1624 curwin->w_p_sbr = empty_option; |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1625 # endif |
7 | 1626 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
|
1627 # ifdef FEAT_LINEBREAK |
1866 | 1628 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
|
1629 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
|
1630 # endif |
7 | 1631 sprintf((char *)showcmd_buf, "%ldx%ld", lines, |
1632 (long)(rightcol - leftcol + 1)); | |
1633 } | |
1634 else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) | |
1635 sprintf((char *)showcmd_buf, "%ld", lines); | |
1636 else | |
2324
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1637 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1638 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
|
1639 int l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1640 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
|
1641 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
|
1642 |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1643 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
|
1644 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1645 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
|
1646 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
|
1647 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1648 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1649 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1650 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
|
1651 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
|
1652 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1653 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
|
1654 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1655 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
|
1656 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
|
1657 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1658 ++bytes; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1659 ++chars; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1660 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
|
1661 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1662 bytes += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1663 ++chars; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1664 s += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1665 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1666 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
|
1667 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
|
1668 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1669 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
|
1670 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1671 showcmd_buf[SHOWCMD_COLS] = NUL; // truncate |
7 | 1672 showcmd_visual = TRUE; |
1673 } | |
1674 else | |
1675 { | |
1676 showcmd_buf[0] = NUL; | |
1677 showcmd_visual = FALSE; | |
1678 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1679 // Don't actually display something if there is nothing to clear. |
7 | 1680 if (showcmd_is_clear) |
1681 return; | |
1682 } | |
1683 | |
1684 display_showcmd(); | |
1685 } | |
1686 | |
1687 /* | |
1688 * Add 'c' to string of shown command chars. | |
1689 * Return TRUE if output has been written (and setcursor() has been called). | |
1690 */ | |
1691 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1692 add_to_showcmd(int c) |
7 | 1693 { |
1694 char_u *p; | |
1695 int old_len; | |
1696 int extra_len; | |
1697 int overflow; | |
1698 int i; | |
1699 static int ignore[] = | |
1700 { | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18291
diff
changeset
|
1701 #ifdef FEAT_GUI |
7 | 1702 K_VER_SCROLLBAR, K_HOR_SCROLLBAR, |
1703 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
|
1704 #endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
1705 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
|
1706 K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE, |
7 | 1707 K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE, |
1708 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
|
1709 K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT, |
7 | 1710 K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE, |
631 | 1711 K_CURSORHOLD, |
7 | 1712 0 |
1713 }; | |
1714 | |
641 | 1715 if (!p_sc || msg_silent != 0) |
7 | 1716 return FALSE; |
1717 | |
1718 if (showcmd_visual) | |
1719 { | |
1720 showcmd_buf[0] = NUL; | |
1721 showcmd_visual = FALSE; | |
1722 } | |
1723 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1724 // Ignore keys that are scrollbar updates and mouse clicks |
7 | 1725 if (IS_SPECIAL(c)) |
1726 for (i = 0; ignore[i] != 0; ++i) | |
1727 if (ignore[i] == c) | |
1728 return FALSE; | |
1729 | |
1730 p = transchar(c); | |
5535 | 1731 if (*p == ' ') |
1732 STRCPY(p, "<20>"); | |
7 | 1733 old_len = (int)STRLEN(showcmd_buf); |
1734 extra_len = (int)STRLEN(p); | |
1735 overflow = old_len + extra_len - SHOWCMD_COLS; | |
1736 if (overflow > 0) | |
1362 | 1737 mch_memmove(showcmd_buf, showcmd_buf + overflow, |
1738 old_len - overflow + 1); | |
7 | 1739 STRCAT(showcmd_buf, p); |
1740 | |
1741 if (char_avail()) | |
1742 return FALSE; | |
1743 | |
1744 display_showcmd(); | |
1745 | |
1746 return TRUE; | |
1747 } | |
1748 | |
1749 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1750 add_to_showcmd_c(int c) |
7 | 1751 { |
1752 if (!add_to_showcmd(c)) | |
1753 setcursor(); | |
1754 } | |
1755 | |
1756 /* | |
1757 * Delete 'len' characters from the end of the shown command. | |
1758 */ | |
1759 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1760 del_from_showcmd(int len) |
7 | 1761 { |
1762 int old_len; | |
1763 | |
1764 if (!p_sc) | |
1765 return; | |
1766 | |
1767 old_len = (int)STRLEN(showcmd_buf); | |
1768 if (len > old_len) | |
1769 len = old_len; | |
1770 showcmd_buf[old_len - len] = NUL; | |
1771 | |
1772 if (!char_avail()) | |
1773 display_showcmd(); | |
1774 } | |
1775 | |
1776 /* | |
1777 * push_showcmd() and pop_showcmd() are used when waiting for the user to type | |
1778 * something and there is a partial mapping. | |
1779 */ | |
1780 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1781 push_showcmd(void) |
7 | 1782 { |
1783 if (p_sc) | |
1784 STRCPY(old_showcmd_buf, showcmd_buf); | |
1785 } | |
1786 | |
1787 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1788 pop_showcmd(void) |
7 | 1789 { |
1790 if (!p_sc) | |
1791 return; | |
1792 | |
1793 STRCPY(showcmd_buf, old_showcmd_buf); | |
1794 | |
1795 display_showcmd(); | |
1796 } | |
1797 | |
1798 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1799 display_showcmd(void) |
7 | 1800 { |
1801 int len; | |
1802 | |
1803 cursor_off(); | |
1804 | |
1805 len = (int)STRLEN(showcmd_buf); | |
1806 if (len == 0) | |
1807 showcmd_is_clear = TRUE; | |
1808 else | |
1809 { | |
1810 screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0); | |
1811 showcmd_is_clear = FALSE; | |
1812 } | |
1813 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1814 // clear the rest of an old message by outputting up to SHOWCMD_COLS |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1815 // spaces |
7 | 1816 screen_puts((char_u *)" " + len, (int)Rows - 1, sc_col + len, 0); |
1817 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1818 setcursor(); // put cursor back where it belongs |
7 | 1819 } |
1820 | |
1821 /* | |
1822 * When "check" is FALSE, prepare for commands that scroll the window. | |
1823 * When "check" is TRUE, take care of scroll-binding after the window has | |
1824 * scrolled. Called from normal_cmd() and edit(). | |
1825 */ | |
1826 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1827 do_check_scrollbind(int check) |
7 | 1828 { |
1829 static win_T *old_curwin = NULL; | |
1830 static linenr_T old_topline = 0; | |
1831 #ifdef FEAT_DIFF | |
1832 static int old_topfill = 0; | |
1833 #endif | |
1834 static buf_T *old_buf = NULL; | |
1835 static colnr_T old_leftcol = 0; | |
1836 | |
1837 if (check && curwin->w_p_scb) | |
1838 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1839 // 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
|
1840 // the values. |
7 | 1841 if (did_syncbind) |
1842 did_syncbind = FALSE; | |
1843 else if (curwin == old_curwin) | |
1844 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1845 // 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
|
1846 // '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
|
1847 // when 'diff' is set. |
7 | 1848 if ((curwin->w_buffer == old_buf |
1849 #ifdef FEAT_DIFF | |
1850 || curwin->w_p_diff | |
1851 #endif | |
1852 ) | |
1853 && (curwin->w_topline != old_topline | |
1854 #ifdef FEAT_DIFF | |
1855 || curwin->w_topfill != old_topfill | |
1856 #endif | |
1857 || curwin->w_leftcol != old_leftcol)) | |
1858 { | |
1859 check_scrollbind(curwin->w_topline - old_topline, | |
1860 (long)(curwin->w_leftcol - old_leftcol)); | |
1861 } | |
1862 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1863 else if (vim_strchr(p_sbo, 'j')) // jump flag set in 'scrollopt' |
7 | 1864 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1865 // 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
|
1866 // 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
|
1867 // 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
|
1868 // 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
|
1869 // 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
|
1870 // 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
|
1871 // 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
|
1872 // visible on-screen. |
7 | 1873 check_scrollbind(curwin->w_topline - curwin->w_scbind_pos, 0L); |
1874 } | |
1875 curwin->w_scbind_pos = curwin->w_topline; | |
1876 } | |
1877 | |
1878 old_curwin = curwin; | |
1879 old_topline = curwin->w_topline; | |
1880 #ifdef FEAT_DIFF | |
1881 old_topfill = curwin->w_topfill; | |
1882 #endif | |
1883 old_buf = curwin->w_buffer; | |
1884 old_leftcol = curwin->w_leftcol; | |
1885 } | |
1886 | |
1887 /* | |
1888 * Synchronize any windows that have "scrollbind" set, based on the | |
1889 * number of rows by which the current window has changed | |
1890 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
1891 */ | |
1892 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1893 check_scrollbind(linenr_T topline_diff, long leftcol_diff) |
7 | 1894 { |
1895 int want_ver; | |
1896 int want_hor; | |
1897 win_T *old_curwin = curwin; | |
1898 buf_T *old_curbuf = curbuf; | |
1899 int old_VIsual_select = VIsual_select; | |
1900 int old_VIsual_active = VIsual_active; | |
1901 colnr_T tgt_leftcol = curwin->w_leftcol; | |
1902 long topline; | |
1903 long y; | |
1904 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1905 // check 'scrollopt' string for vertical and horizontal scroll options |
7 | 1906 want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0); |
1907 #ifdef FEAT_DIFF | |
1908 want_ver |= old_curwin->w_p_diff; | |
1909 #endif | |
1910 want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0)); | |
1911 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1912 // loop through the scrollbound windows and scroll accordingly |
7 | 1913 VIsual_select = VIsual_active = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
1914 FOR_ALL_WINDOWS(curwin) |
7 | 1915 { |
1916 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
|
1917 // 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
|
1918 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
|
1919 continue; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1920 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1921 // do the vertical scroll |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1922 if (want_ver) |
7 | 1923 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1924 #ifdef FEAT_DIFF |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1925 if (old_curwin->w_p_diff && curwin->w_p_diff) |
7 | 1926 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1927 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
|
1928 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1929 else |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1930 #endif |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1931 { |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1932 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
|
1933 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
|
1934 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
|
1935 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
|
1936 if (topline < 1) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1937 topline = 1; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1938 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1939 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
|
1940 if (y > 0) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1941 scrollup(y, FALSE); |
7 | 1942 else |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1943 scrolldown(-y, FALSE); |
7 | 1944 } |
1945 | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1946 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
|
1947 cursor_correct(); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1948 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
|
1949 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1950 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29546
diff
changeset
|
1951 // 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
|
1952 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
|
1953 (void)set_leftcol(tgt_leftcol); |
7 | 1954 } |
1955 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
1956 // reset current-window |
7 | 1957 VIsual_select = old_VIsual_select; |
1958 VIsual_active = old_VIsual_active; | |
1959 curwin = old_curwin; | |
1960 curbuf = old_curbuf; | |
1961 } | |
1962 | |
1963 /* | |
1964 * Command character that's ignored. | |
1965 * 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
|
1966 * xon/xoff. |
7 | 1967 */ |
1968 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1969 nv_ignore(cmdarg_T *cap) |
7 | 1970 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1971 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
7 | 1972 } |
1973 | |
1974 /* | |
620 | 1975 * Command character that doesn't do anything, but unlike nv_ignore() does |
1976 * start edit(). Used for "startinsert" executed while starting up. | |
1977 */ | |
1978 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1979 nv_nop(cmdarg_T *cap UNUSED) |
620 | 1980 { |
1981 } | |
1982 | |
1983 /* | |
7 | 1984 * Command character doesn't exist. |
1985 */ | |
1986 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1987 nv_error(cmdarg_T *cap) |
7 | 1988 { |
1989 clearopbeep(cap->oap); | |
1990 } | |
1991 | |
1992 /* | |
1993 * <Help> and <F1> commands. | |
1994 */ | |
1995 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1996 nv_help(cmdarg_T *cap) |
7 | 1997 { |
1998 if (!checkclearopq(cap->oap)) | |
1999 ex_help(NULL); | |
2000 } | |
2001 | |
2002 /* | |
2003 * CTRL-A and CTRL-X: Add or subtract from letter or number under cursor. | |
2004 */ | |
2005 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2006 nv_addsub(cmdarg_T *cap) |
7 | 2007 { |
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
|
2008 #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
|
2009 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
|
2010 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
|
2011 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
|
2012 #endif |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2013 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
|
2014 { |
7578
fdae4c496775
commit https://github.com/vim/vim/commit/ef2b5036b3005f1ce15d146dce72379a9834c56d
Christian Brabandt <cb@256bit.org>
parents:
7574
diff
changeset
|
2015 prep_redo_cmd(cap); |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2016 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
|
2017 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
|
2018 cap->oap->op_type = OP_NOP; |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2019 } |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2020 else if (VIsual_active) |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2021 nv_operator(cap); |
6868 | 2022 else |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2023 clearop(cap->oap); |
7 | 2024 } |
2025 | |
2026 /* | |
2027 * CTRL-F, CTRL-B, etc: Scroll page up or down. | |
2028 */ | |
2029 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2030 nv_page(cmdarg_T *cap) |
7 | 2031 { |
2032 if (!checkclearop(cap->oap)) | |
819 | 2033 { |
2034 if (mod_mask & MOD_MASK_CTRL) | |
2035 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2036 // <C-PageUp>: tab page back; <C-PageDown>: tab page forward |
819 | 2037 if (cap->arg == BACKWARD) |
2038 goto_tabpage(-(int)cap->count1); | |
2039 else | |
2040 goto_tabpage((int)cap->count0); | |
2041 } | |
2042 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12467
diff
changeset
|
2043 (void)onepage(cap->arg, cap->count1); |
819 | 2044 } |
7 | 2045 } |
2046 | |
2047 /* | |
2048 * Implementation of "gd" and "gD" command. | |
2049 */ | |
2050 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2051 nv_gd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2052 oparg_T *oap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2053 int nchar, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2054 int thisblock) // 1 for "1gd" and "1gD" |
7 | 2055 { |
2056 int len; | |
503 | 2057 char_u *ptr; |
2058 | |
2059 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
|
2060 || 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
|
2061 == 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
|
2062 { |
503 | 2063 clearopbeep(oap); |
26101
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2064 } |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2065 else |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2066 { |
503 | 2067 #ifdef FEAT_FOLDING |
26101
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2068 if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2069 foldOpenCursor(); |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2070 #endif |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2071 // clear any search statistics |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2072 if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT)) |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2073 clear_cmdline = TRUE; |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2074 } |
503 | 2075 } |
2076 | |
2077 /* | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2078 * 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
|
2079 * otherwise. |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2080 */ |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2081 static int |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2082 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
|
2083 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2084 int i; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2085 int incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2086 int instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2087 int prev = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2088 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2089 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
|
2090 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2091 if (instring != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2092 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2093 if (prev != '\\' && line[i] == instring) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2094 instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2095 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2096 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
|
2097 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2098 instring = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2099 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2100 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2101 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2102 if (incomment) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2103 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2104 if (prev == '*' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2105 incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2106 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2107 else if (prev == '/' && line[i] == '*') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2108 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2109 incomment = TRUE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2110 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2111 else if (prev == '/' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2112 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2113 return FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2114 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2115 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2116 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2117 prev = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2118 } |
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 return incomment == FALSE && instring == 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2121 } |
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 /* |
523 | 2124 * Search for variable declaration of "ptr[len]". |
2125 * When "locally" is TRUE in the current function ("gd"), otherwise in the | |
2126 * current file ("gD"). | |
2127 * When "thisblock" is TRUE check the {} block scope. | |
503 | 2128 * Return FAIL when not found. |
2129 */ | |
2130 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2131 find_decl( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2132 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2133 int len, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2134 int locally, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2135 int thisblock, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2136 int flags_arg) // flags passed to searchit() |
503 | 2137 { |
7 | 2138 char_u *pat; |
2139 pos_T old_pos; | |
503 | 2140 pos_T par_pos; |
2141 pos_T found_pos; | |
7 | 2142 int t; |
2143 int save_p_ws; | |
2144 int save_p_scs; | |
503 | 2145 int retval = OK; |
944 | 2146 int incll; |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2147 int searchflags = flags_arg; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2148 int valid; |
503 | 2149 |
2150 if ((pat = alloc(len + 7)) == NULL) | |
2151 return FAIL; | |
268 | 2152 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2153 // 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
|
2154 // and "~" causes trouble. |
268 | 2155 sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", |
2156 len, ptr); | |
7 | 2157 old_pos = curwin->w_cursor; |
2158 save_p_ws = p_ws; | |
2159 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
|
2160 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
|
2161 p_scs = FALSE; // don't switch ignorecase off now |
7 | 2162 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2163 // 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
|
2164 // 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
|
2165 // back until a blank line. If this fails go to line 1. |
944 | 2166 if (!locally || !findpar(&incll, BACKWARD, 1L, '{', FALSE)) |
7 | 2167 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2168 setpcmark(); // Set in findpar() otherwise |
7 | 2169 curwin->w_cursor.lnum = 1; |
539 | 2170 par_pos = curwin->w_cursor; |
7 | 2171 } |
2172 else | |
2173 { | |
539 | 2174 par_pos = curwin->w_cursor; |
7 | 2175 while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL) |
2176 --curwin->w_cursor.lnum; | |
2177 } | |
2178 curwin->w_cursor.col = 0; | |
2179 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2180 // 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
|
2181 CLEAR_POS(&found_pos); |
503 | 2182 for (;;) |
2183 { | |
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
|
2184 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
|
2185 pat, 1L, searchflags, RE_LAST, NULL); |
503 | 2186 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
|
2187 t = FAIL; // match after start is failure too |
523 | 2188 |
718 | 2189 if (thisblock && t != FAIL) |
523 | 2190 { |
2191 pos_T *pos; | |
2192 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2193 // 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
|
2194 // position where we started the search from. |
523 | 2195 if ((pos = findmatchlimit(NULL, '}', FM_FORWARD, |
2196 (int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL | |
2197 && pos->lnum < old_pos.lnum) | |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2198 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2199 // 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
|
2200 // Skip to the end. |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2201 curwin->w_cursor = *pos; |
523 | 2202 continue; |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2203 } |
523 | 2204 } |
2205 | |
503 | 2206 if (t == FAIL) |
2207 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2208 // If we previously found a valid position, use it. |
503 | 2209 if (found_pos.lnum != 0) |
2210 { | |
2211 curwin->w_cursor = found_pos; | |
2212 t = OK; | |
2213 } | |
2214 break; | |
2215 } | |
3562 | 2216 if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0) |
503 | 2217 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2218 // Ignore this line, continue at start of next line. |
503 | 2219 ++curwin->w_cursor.lnum; |
2220 curwin->w_cursor.col = 0; | |
2221 continue; | |
2222 } | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2223 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
|
2224 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2225 // 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
|
2226 // 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
|
2227 if (!valid && found_pos.lnum != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2228 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2229 curwin->w_cursor = found_pos; |
503 | 2230 break; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2231 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2232 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2233 // 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
|
2234 if (valid && !locally) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2235 break; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2236 if (valid && curwin->w_cursor.lnum >= par_pos.lnum) |
503 | 2237 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2238 // If we previously found a valid position, use it. |
503 | 2239 if (found_pos.lnum != 0) |
2240 curwin->w_cursor = found_pos; | |
2241 break; | |
2242 } | |
2243 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2244 // 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
|
2245 // 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
|
2246 // 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
|
2247 if (!valid) |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
2248 CLEAR_POS(&found_pos); |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2249 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2250 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
|
2251 // 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
|
2252 // position. |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2253 searchflags &= ~SEARCH_START; |
503 | 2254 } |
2255 | |
2256 if (t == FAIL) | |
2257 { | |
2258 retval = FAIL; | |
7 | 2259 curwin->w_cursor = old_pos; |
2260 } | |
2261 else | |
2262 { | |
2263 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
|
2264 // "n" searches forward now |
7 | 2265 reset_search_dir(); |
2266 } | |
2267 | |
2268 vim_free(pat); | |
2269 p_ws = save_p_ws; | |
2270 p_scs = save_p_scs; | |
503 | 2271 |
2272 return retval; | |
7 | 2273 } |
2274 | |
2275 /* | |
2276 * Move 'dist' lines in direction 'dir', counting lines by *screen* | |
2277 * lines rather than lines in the file. | |
2278 * 'dist' must be positive. | |
2279 * | |
2280 * Return OK if able to move cursor, FAIL otherwise. | |
2281 */ | |
2282 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2283 nv_screengo(oparg_T *oap, int dir, long dist) |
7 | 2284 { |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
2285 int linelen = linetabsize_str(ml_get_curline()); |
7 | 2286 int retval = OK; |
2287 int atend = FALSE; | |
2288 int n; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2289 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
|
2290 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
|
2291 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
|
2292 int width2; // text width for wrapped screen line |
7 | 2293 |
2294 oap->motion_type = MCHAR; | |
5192
c28202427d71
updated for version 7.4a.022
Bram Moolenaar <bram@vim.org>
parents:
5162
diff
changeset
|
2295 oap->inclusive = (curwin->w_curswant == MAXCOL); |
7 | 2296 |
2297 col_off1 = curwin_col_off(); | |
2298 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
|
2299 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
|
2300 width2 = curwin->w_width - col_off2; |
6559 | 2301 if (width2 == 0) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2302 width2 = 1; // avoid divide by zero |
7 | 2303 |
2304 if (curwin->w_width != 0) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2305 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2306 // 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
|
2307 // try to stick in the last column of the screen. |
7 | 2308 if (curwin->w_curswant == MAXCOL) |
2309 { | |
2310 atend = TRUE; | |
2311 validate_virtcol(); | |
2312 if (width1 <= 0) | |
2313 curwin->w_curswant = 0; | |
2314 else | |
2315 { | |
2316 curwin->w_curswant = width1 - 1; | |
2317 if (curwin->w_virtcol > curwin->w_curswant) | |
2318 curwin->w_curswant += ((curwin->w_virtcol | |
2319 - curwin->w_curswant - 1) / width2 + 1) * width2; | |
2320 } | |
2321 } | |
2322 else | |
2323 { | |
2324 if (linelen > width1) | |
2325 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2326 else | |
2327 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
|
2328 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
|
2329 curwin->w_curswant = n - 1; |
7 | 2330 } |
2331 | |
2332 while (dist--) | |
2333 { | |
2334 if (dir == BACKWARD) | |
2335 { | |
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
|
2336 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
|
2337 #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
|
2338 && !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
|
2339 #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
|
2340 ) |
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
|
2341 // 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
|
2342 // 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
|
2343 // which will get clipped to column 0. |
7 | 2344 curwin->w_curswant -= width2; |
2345 else | |
2346 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2347 // to previous line |
23687
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2348 #ifdef FEAT_FOLDING |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2349 // Move to the start of a closed fold. Don't do that when |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2350 // 'foldopen' contains "all": it will open in a moment. |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2351 if (!(fdo_flags & FDO_ALL)) |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2352 (void)hasFolding(curwin->w_cursor.lnum, |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2353 &curwin->w_cursor.lnum, NULL); |
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2354 #endif |
7 | 2355 if (curwin->w_cursor.lnum == 1) |
2356 { | |
2357 retval = FAIL; | |
2358 break; | |
2359 } | |
2360 --curwin->w_cursor.lnum; | |
23687
09ad3f1b9714
patch 8.2.2385: "gj" and "gk" do not work correctly when inside a fold
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
2361 |
30833
e3d5781c7ec6
patch 9.0.0751: 'scrolloff' does not work well with 'smoothscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
2362 linelen = linetabsize_str(ml_get_curline()); |
7 | 2363 if (linelen > width1) |
2364 curwin->w_curswant += (((linelen - width1 - 1) / width2) | |
2365 + 1) * width2; | |
2366 } | |
2367 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2368 else // dir == FORWARD |
7 | 2369 { |
2370 if (linelen > width1) | |
2371 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2372 else | |
2373 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
|
2374 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
|
2375 #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
|
2376 && !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
|
2377 #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
|
2378 ) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2379 // move forward within line |
7 | 2380 curwin->w_curswant += width2; |
2381 else | |
2382 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2383 // to next line |
7 | 2384 #ifdef FEAT_FOLDING |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2385 // Move to the end of a closed fold. |
7 | 2386 (void)hasFolding(curwin->w_cursor.lnum, NULL, |
2387 &curwin->w_cursor.lnum); | |
2388 #endif | |
2389 if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) | |
2390 { | |
2391 retval = FAIL; | |
2392 break; | |
2393 } | |
2394 curwin->w_cursor.lnum++; | |
2395 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
|
2396 // 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
|
2397 // 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
|
2398 // 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
|
2399 // 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
|
2400 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
|
2401 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
|
2402 linelen = linetabsize_str(ml_get_curline()); |
7 | 2403 } |
2404 } | |
2405 } | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2406 } |
7 | 2407 |
5600 | 2408 if (virtual_active() && atend) |
2409 coladvance(MAXCOL); | |
2410 else | |
2411 coladvance(curwin->w_curswant); | |
7 | 2412 |
2413 if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) | |
2414 { | |
6178 | 2415 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
|
2416 int c; |
6178 | 2417 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2418 // 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
|
2419 // 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
|
2420 // screenline or move two screenlines. |
7 | 2421 validate_virtcol(); |
6178 | 2422 virtcol = curwin->w_virtcol; |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2423 #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
|
2424 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
|
2425 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
|
2426 #endif |
6178 | 2427 |
26094
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2428 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
|
2429 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
|
2430 && (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
|
2431 && !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
|
2432 oneright(); |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2433 |
6178 | 2434 if (virtcol > curwin->w_curswant |
7 | 2435 && (curwin->w_curswant < (colnr_T)width1 |
2436 ? (curwin->w_curswant > (colnr_T)width1 / 2) | |
2437 : ((curwin->w_curswant - width1) % width2 | |
2438 > (colnr_T)width2 / 2))) | |
2439 --curwin->w_cursor.col; | |
2440 } | |
2441 | |
2442 if (atend) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2443 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
|
2444 adjust_skipcol(); |
7 | 2445 |
2446 return retval; | |
2447 } | |
2448 | |
2449 /* | |
2450 * Handle CTRL-E and CTRL-Y commands: scroll a line up or down. | |
2451 * cap->arg must be TRUE for CTRL-E. | |
2452 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
2453 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2454 nv_scroll_line(cmdarg_T *cap) |
7 | 2455 { |
2456 if (!checkclearop(cap->oap)) | |
2457 scroll_redraw(cap->arg, cap->count1); | |
2458 } | |
2459 | |
2460 /* | |
2461 * Scroll "count" lines up or down, and redraw. | |
2462 */ | |
2463 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2464 scroll_redraw(int up, long count) |
7 | 2465 { |
2466 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
|
2467 int prev_skipcol = curwin->w_skipcol; |
7 | 2468 #ifdef FEAT_DIFF |
2469 int prev_topfill = curwin->w_topfill; | |
2470 #endif | |
2471 linenr_T prev_lnum = curwin->w_cursor.lnum; | |
2472 | |
2473 if (up) | |
2474 scrollup(count, TRUE); | |
2475 else | |
2476 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
|
2477 if (get_scrolloff_value() > 0) |
7 | 2478 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2479 // 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
|
2480 // valid, otherwise the screen jumps back at the end of the file. |
7 | 2481 cursor_correct(); |
2482 check_cursor_moved(curwin); | |
2483 curwin->w_valid |= VALID_TOPLINE; | |
2484 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2485 // 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
|
2486 // 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
|
2487 // first line of the buffer is already on the screen |
7 | 2488 while (curwin->w_topline == prev_topline |
30616
eb86a6330ae3
patch 9.0.0643: smoothscroll test fails
Bram Moolenaar <Bram@vim.org>
parents:
30471
diff
changeset
|
2489 && curwin->w_skipcol == prev_skipcol |
7 | 2490 #ifdef FEAT_DIFF |
2491 && curwin->w_topfill == prev_topfill | |
2492 #endif | |
2493 ) | |
2494 { | |
2495 if (up) | |
2496 { | |
2497 if (curwin->w_cursor.lnum > prev_lnum | |
2498 || cursor_down(1L, FALSE) == FAIL) | |
2499 break; | |
2500 } | |
2501 else | |
2502 { | |
2503 if (curwin->w_cursor.lnum < prev_lnum | |
2504 || prev_topline == 1L | |
2505 || cursor_up(1L, FALSE) == FAIL) | |
2506 break; | |
2507 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2508 // 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
|
2509 // end of the file. |
7 | 2510 check_cursor_moved(curwin); |
2511 curwin->w_valid |= VALID_TOPLINE; | |
2512 } | |
2513 } | |
2514 if (curwin->w_cursor.lnum != prev_lnum) | |
2515 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
|
2516 redraw_later(UPD_VALID); |
7 | 2517 } |
2518 | |
2519 /* | |
27400
722db0819111
patch 8.2.4228: no tests for clicking in the GUI tabline
Bram Moolenaar <Bram@vim.org>
parents:
27386
diff
changeset
|
2520 * 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
|
2521 * '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
|
2522 * 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
|
2523 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2524 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2525 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
|
2526 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2527 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
|
2528 long n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2529 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2530 // "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
|
2531 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
|
2532 return FALSE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2533 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
|
2534 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2535 for (;;) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2536 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2537 #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
|
2538 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
|
2539 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2540 ++no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2541 ++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
|
2542 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
|
2543 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
|
2544 --no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2545 --allow_keys; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2546 (void)add_to_showcmd(nchar); |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
2547 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2548 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
|
2549 n /= 10; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2550 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
|
2551 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
|
2552 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
|
2553 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2554 #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
|
2555 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
|
2556 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2557 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
|
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 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
|
2561 || nchar == 'h' |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2562 || 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
|
2563 || 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
|
2564 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2565 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
|
2566 *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
|
2567 return TRUE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2568 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2569 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2570 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2571 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
|
2572 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2573 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2574 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2575 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
|
2576 return FALSE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2577 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2578 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2579 #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
|
2580 /* |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2581 * "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
|
2582 * "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
|
2583 * "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
|
2584 * "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
|
2585 * "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
|
2586 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2587 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2588 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
|
2589 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2590 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
|
2591 int len; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2592 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
|
2593 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2594 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
|
2595 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2596 ++no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2597 ++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
|
2598 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
|
2599 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
|
2600 --no_mapping; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2601 --allow_keys; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2602 (void)add_to_showcmd(nchar); |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30799
diff
changeset
|
2603 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2604 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
|
2605 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2606 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
|
2607 return OK; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2608 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2609 undo = TRUE; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2610 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2611 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2612 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
|
2613 return OK; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2614 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
|
2615 return FAIL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2616 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
|
2617 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2618 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
|
2619 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2620 // 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
|
2621 // 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
|
2622 // used below. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2623 emsg_off++; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2624 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
|
2625 emsg_off--; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2626 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
|
2627 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
|
2628 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
|
2629 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2630 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2631 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
|
2632 && (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
|
2633 return FAIL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2634 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
|
2635 ? 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
|
2636 (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
|
2637 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2638 return OK; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2639 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2640 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2641 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2642 /* |
7 | 2643 * Commands that start with "z". |
2644 */ | |
2645 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2646 nv_zet(cmdarg_T *cap) |
7 | 2647 { |
2648 long n; | |
2649 colnr_T col; | |
2650 int nchar = cap->nchar; | |
2651 #ifdef FEAT_FOLDING | |
2652 long old_fdl = curwin->w_p_fdl; | |
2653 int old_fen = curwin->w_p_fen; | |
2654 #endif | |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
2655 long siso = get_sidescrolloff_value(); |
7 | 2656 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2657 if (VIM_ISDIGIT(nchar) && !nv_z_get_count(cap, &nchar)) |
7 | 2658 return; |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2659 |
7 | 2660 if ( |
2661 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2662 // "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
|
2663 // 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
|
2664 // commands. |
7 | 2665 cap->nchar != 'f' && cap->nchar != 'F' |
2666 && !(VIsual_active && vim_strchr((char_u *)"dcCoO", cap->nchar)) | |
2667 && cap->nchar != 'j' && cap->nchar != 'k' | |
2668 && | |
2669 #endif | |
2670 checkclearop(cap->oap)) | |
2671 return; | |
2672 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
2673 // 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
|
2674 // If line number given, set cursor. |
7 | 2675 if ((vim_strchr((char_u *)"+\r\nt.z^-b", nchar) != NULL) |
2676 && cap->count0 | |
2677 && cap->count0 != curwin->w_cursor.lnum) | |
2678 { | |
2679 setpcmark(); | |
2680 if (cap->count0 > curbuf->b_ml.ml_line_count) | |
2681 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2682 else | |
2683 curwin->w_cursor.lnum = cap->count0; | |
22 | 2684 check_cursor_col(); |
7 | 2685 } |
2686 | |
2687 switch (nchar) | |
2688 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2689 // "z+", "z<CR>" and "zt": put cursor at top of screen |
7 | 2690 case '+': |
2691 if (cap->count0 == 0) | |
2692 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2693 // 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
|
2694 validate_botline(); // make sure w_botline is valid |
7 | 2695 if (curwin->w_botline > curbuf->b_ml.ml_line_count) |
2696 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2697 else | |
2698 curwin->w_cursor.lnum = curwin->w_botline; | |
2699 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2700 // FALLTHROUGH |
7 | 2701 case NL: |
2702 case CAR: | |
2703 case K_KENTER: | |
2704 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
|
2705 // FALLTHROUGH |
7 | 2706 |
2707 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
|
2708 redraw_later(UPD_VALID); |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2709 set_fraction(curwin); |
7 | 2710 break; |
2711 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2712 // "z." and "zz": put cursor in middle of screen |
7 | 2713 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
|
2714 // FALLTHROUGH |
7 | 2715 |
2716 case 'z': scroll_cursor_halfway(TRUE); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
2717 redraw_later(UPD_VALID); |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2718 set_fraction(curwin); |
7 | 2719 break; |
2720 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2721 // "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
|
2722 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
|
2723 // 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
|
2724 // bottom of window. |
7 | 2725 if (cap->count0 != 0) |
2726 { | |
2727 scroll_cursor_bot(0, TRUE); | |
2728 curwin->w_cursor.lnum = curwin->w_topline; | |
2729 } | |
2730 else if (curwin->w_topline == 1) | |
2731 curwin->w_cursor.lnum = 1; | |
2732 else | |
2733 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
|
2734 // FALLTHROUGH |
7 | 2735 case '-': |
2736 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
|
2737 // FALLTHROUGH |
7 | 2738 |
2739 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
|
2740 redraw_later(UPD_VALID); |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2741 set_fraction(curwin); |
7 | 2742 break; |
2743 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2744 // "zH" - scroll screen right half-page |
7 | 2745 case 'H': |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2746 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
|
2747 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2748 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2749 // "zh" - scroll screen to the right |
7 | 2750 case 'h': |
2751 case K_LEFT: | |
2752 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
|
2753 (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
|
2754 ? 0 : curwin->w_leftcol - (colnr_T)cap->count1); |
7 | 2755 break; |
2756 | |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2757 // "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
|
2758 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
|
2759 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2760 |
31133
cc0c4141fb73
patch 9.0.0901: setting w_leftcol and handling side effects is confusing
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
2761 // "zl" - scroll window to the left if not wrapping |
7 | 2762 case 'l': |
2763 case K_RIGHT: | |
2764 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
|
2765 (void)set_leftcol(curwin->w_leftcol + (colnr_T)cap->count1); |
7 | 2766 break; |
2767 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2768 // "zs" - scroll screen, cursor at the start |
7 | 2769 case 's': if (!curwin->w_p_wrap) |
2770 { | |
2771 #ifdef FEAT_FOLDING | |
2772 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
|
2773 col = 0; // like the cursor is in col 0 |
7 | 2774 else |
2775 #endif | |
2776 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
|
2777 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
|
2778 col -= siso; |
7 | 2779 else |
2780 col = 0; | |
2781 if (curwin->w_leftcol != col) | |
2782 { | |
2783 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
|
2784 redraw_later(UPD_NOT_VALID); |
7 | 2785 } |
2786 } | |
2787 break; | |
2788 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2789 // "ze" - scroll screen, cursor at the end |
7 | 2790 case 'e': if (!curwin->w_p_wrap) |
2791 { | |
2792 #ifdef FEAT_FOLDING | |
2793 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
|
2794 col = 0; // like the cursor is in col 0 |
7 | 2795 else |
2796 #endif | |
2797 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
|
2798 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
|
2799 if ((long)col + siso < n) |
7 | 2800 col = 0; |
2801 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
|
2802 col = col + siso - n + 1; |
7 | 2803 if (curwin->w_leftcol != col) |
2804 { | |
2805 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
|
2806 redraw_later(UPD_NOT_VALID); |
7 | 2807 } |
2808 } | |
2809 break; | |
2810 | |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
2811 // "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
|
2812 case 'P': |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
2813 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
|
2814 break; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24800
diff
changeset
|
2815 // "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
|
2816 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
|
2817 break; |
7 | 2818 #ifdef FEAT_FOLDING |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2819 // "zF": create fold command |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2820 // "zf": create fold operator |
7 | 2821 case 'F': |
2822 case 'f': if (foldManualAllowed(TRUE)) | |
2823 { | |
2824 cap->nchar = 'f'; | |
2825 nv_operator(cap); | |
2826 curwin->w_p_fen = TRUE; | |
2827 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2828 // "zF" is like "zfzf" |
7 | 2829 if (nchar == 'F' && cap->oap->op_type == OP_FOLD) |
2830 { | |
2831 nv_operator(cap); | |
2832 finish_op = TRUE; | |
2833 } | |
2834 } | |
2835 else | |
2836 clearopbeep(cap->oap); | |
2837 break; | |
2838 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2839 // "zd": delete fold at cursor |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2840 // "zD": delete fold at cursor recursively |
7 | 2841 case 'd': |
2842 case 'D': if (foldManualAllowed(FALSE)) | |
2843 { | |
2844 if (VIsual_active) | |
2845 nv_operator(cap); | |
2846 else | |
2847 deleteFold(curwin->w_cursor.lnum, | |
2848 curwin->w_cursor.lnum, nchar == 'D', FALSE); | |
2849 } | |
2850 break; | |
2851 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2852 // "zE": erase all folds |
7 | 2853 case 'E': if (foldmethodIsManual(curwin)) |
2854 { | |
2855 clearFolding(curwin); | |
2856 changed_window_setting(); | |
2857 } | |
2858 else if (foldmethodIsMarker(curwin)) | |
2859 deleteFold((linenr_T)1, curbuf->b_ml.ml_line_count, | |
2860 TRUE, FALSE); | |
2861 else | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26909
diff
changeset
|
2862 emsg(_(e_cannot_erase_folds_with_current_foldmethod)); |
7 | 2863 break; |
2864 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2865 // "zn": fold none: reset 'foldenable' |
7 | 2866 case 'n': curwin->w_p_fen = FALSE; |
2867 break; | |
2868 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2869 // "zN": fold Normal: set 'foldenable' |
7 | 2870 case 'N': curwin->w_p_fen = TRUE; |
2871 break; | |
2872 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2873 // "zi": invert folding: toggle 'foldenable' |
7 | 2874 case 'i': curwin->w_p_fen = !curwin->w_p_fen; |
2875 break; | |
2876 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2877 // "za": open closed fold or close open fold at cursor |
7 | 2878 case 'a': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
2879 openFold(curwin->w_cursor.lnum, cap->count1); | |
2880 else | |
2881 { | |
2882 closeFold(curwin->w_cursor.lnum, cap->count1); | |
2883 curwin->w_p_fen = TRUE; | |
2884 } | |
2885 break; | |
2886 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2887 // "zA": open fold at cursor recursively |
7 | 2888 case 'A': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
2889 openFoldRecurse(curwin->w_cursor.lnum); | |
2890 else | |
2891 { | |
2892 closeFoldRecurse(curwin->w_cursor.lnum); | |
2893 curwin->w_p_fen = TRUE; | |
2894 } | |
2895 break; | |
2896 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2897 // "zo": open fold at cursor or Visual area |
7 | 2898 case 'o': if (VIsual_active) |
2899 nv_operator(cap); | |
2900 else | |
2901 openFold(curwin->w_cursor.lnum, cap->count1); | |
2902 break; | |
2903 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2904 // "zO": open fold recursively |
7 | 2905 case 'O': if (VIsual_active) |
2906 nv_operator(cap); | |
2907 else | |
2908 openFoldRecurse(curwin->w_cursor.lnum); | |
2909 break; | |
2910 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2911 // "zc": close fold at cursor or Visual area |
7 | 2912 case 'c': if (VIsual_active) |
2913 nv_operator(cap); | |
2914 else | |
2915 closeFold(curwin->w_cursor.lnum, cap->count1); | |
2916 curwin->w_p_fen = TRUE; | |
2917 break; | |
2918 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2919 // "zC": close fold recursively |
7 | 2920 case 'C': if (VIsual_active) |
2921 nv_operator(cap); | |
2922 else | |
2923 closeFoldRecurse(curwin->w_cursor.lnum); | |
2924 curwin->w_p_fen = TRUE; | |
2925 break; | |
2926 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2927 // "zv": open folds at the cursor |
7 | 2928 case 'v': foldOpenCursor(); |
2929 break; | |
2930 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2931 // "zx": re-apply 'foldlevel' and open folds at the cursor |
7 | 2932 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
|
2933 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
|
2934 newFoldLevel(); // update right now |
7 | 2935 foldOpenCursor(); |
2936 break; | |
2937 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2938 // "zX": undo manual opens/closes, re-apply 'foldlevel' |
7 | 2939 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
|
2940 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
|
2941 old_fdl = -1; // force an update |
7 | 2942 break; |
2943 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2944 // "zm": fold more |
7 | 2945 case 'm': if (curwin->w_p_fdl > 0) |
6725 | 2946 { |
2947 curwin->w_p_fdl -= cap->count1; | |
2948 if (curwin->w_p_fdl < 0) | |
2949 curwin->w_p_fdl = 0; | |
2950 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2951 old_fdl = -1; // force an update |
7 | 2952 curwin->w_p_fen = TRUE; |
2953 break; | |
2954 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2955 // "zM": close all folds |
7 | 2956 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
|
2957 old_fdl = -1; // force an update |
7 | 2958 curwin->w_p_fen = TRUE; |
2959 break; | |
2960 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2961 // "zr": reduce folding |
6725 | 2962 case 'r': curwin->w_p_fdl += cap->count1; |
2963 { | |
2964 int d = getDeepestNesting(); | |
2965 | |
2966 if (curwin->w_p_fdl >= d) | |
2967 curwin->w_p_fdl = d; | |
2968 } | |
7 | 2969 break; |
2970 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2971 // "zR": open all folds |
7 | 2972 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
|
2973 old_fdl = -1; // force an update |
7 | 2974 break; |
2975 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2976 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
|
2977 case 'k': // "zk" move to next fold upwards |
7 | 2978 if (foldMoveTo(TRUE, nchar == 'j' ? FORWARD : BACKWARD, |
2979 cap->count1) == FAIL) | |
2980 clearopbeep(cap->oap); | |
2981 break; | |
2982 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2983 #endif // FEAT_FOLDING |
7 | 2984 |
737 | 2985 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2986 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
|
2987 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
|
2988 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
|
2989 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
|
2990 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
|
2991 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
|
2992 return; |
316 | 2993 break; |
323 | 2994 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2995 case '=': // "z=": suggestions for a badly spelled word |
638 | 2996 if (!checkclearop(cap->oap)) |
485 | 2997 spell_suggest((int)cap->count0); |
323 | 2998 break; |
310 | 2999 #endif |
3000 | |
7 | 3001 default: clearopbeep(cap->oap); |
3002 } | |
3003 | |
3004 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3005 // Redraw when 'foldenable' changed |
7 | 3006 if (old_fen != curwin->w_p_fen) |
3007 { | |
3008 # ifdef FEAT_DIFF | |
3009 win_T *wp; | |
3010 | |
3011 if (foldmethodIsDiff(curwin) && curwin->w_p_scb) | |
3012 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3013 // Adjust 'foldenable' in diff-synced windows. |
7 | 3014 FOR_ALL_WINDOWS(wp) |
3015 { | |
3016 if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) | |
3017 { | |
3018 wp->w_p_fen = curwin->w_p_fen; | |
3019 changed_window_setting_win(wp); | |
3020 } | |
3021 } | |
3022 } | |
3023 # endif | |
3024 changed_window_setting(); | |
3025 } | |
3026 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3027 // Redraw when 'foldlevel' changed. |
7 | 3028 if (old_fdl != curwin->w_p_fdl) |
3029 newFoldLevel(); | |
3030 #endif | |
3031 } | |
3032 | |
3033 #ifdef FEAT_GUI | |
3034 /* | |
3035 * Vertical scrollbar movement. | |
3036 */ | |
3037 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3038 nv_ver_scrollbar(cmdarg_T *cap) |
7 | 3039 { |
3040 if (cap->oap->op_type != OP_NOP) | |
3041 clearopbeep(cap->oap); | |
3042 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3043 // Even if an operator was pending, we still want to scroll |
7 | 3044 gui_do_scroll(); |
3045 } | |
3046 | |
3047 /* | |
3048 * Horizontal scrollbar movement. | |
3049 */ | |
3050 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3051 nv_hor_scrollbar(cmdarg_T *cap) |
7 | 3052 { |
3053 if (cap->oap->op_type != OP_NOP) | |
3054 clearopbeep(cap->oap); | |
3055 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3056 // 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
|
3057 do_mousescroll_horiz(scrollbar_value); |
7 | 3058 } |
3059 #endif | |
3060 | |
690 | 3061 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
685 | 3062 /* |
3063 * Click in GUI tab. | |
3064 */ | |
3065 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3066 nv_tabline(cmdarg_T *cap) |
685 | 3067 { |
3068 if (cap->oap->op_type != OP_NOP) | |
3069 clearopbeep(cap->oap); | |
3070 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3071 // Even if an operator was pending, we still want to jump tabs. |
685 | 3072 goto_tabpage(current_tab); |
3073 } | |
686 | 3074 |
3075 /* | |
3076 * Selected item in tab line menu. | |
3077 */ | |
3078 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3079 nv_tabmenu(cmdarg_T *cap) |
686 | 3080 { |
3081 if (cap->oap->op_type != OP_NOP) | |
3082 clearopbeep(cap->oap); | |
3083 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3084 // Even if an operator was pending, we still want to jump tabs. |
690 | 3085 handle_tabmenu(); |
3086 } | |
3087 | |
3088 /* | |
3089 * Handle selecting an item of the GUI tab line menu. | |
3090 * Used in Normal and Insert mode. | |
3091 */ | |
3092 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3093 handle_tabmenu(void) |
690 | 3094 { |
686 | 3095 switch (current_tabmenu) |
3096 { | |
3097 case TABLINE_MENU_CLOSE: | |
3098 if (current_tab == 0) | |
3099 do_cmdline_cmd((char_u *)"tabclose"); | |
3100 else | |
3101 { | |
3102 vim_snprintf((char *)IObuff, IOSIZE, "tabclose %d", | |
3103 current_tab); | |
3104 do_cmdline_cmd(IObuff); | |
3105 } | |
3106 break; | |
3107 | |
3108 case TABLINE_MENU_NEW: | |
6631 | 3109 if (current_tab == 0) |
3110 do_cmdline_cmd((char_u *)"$tabnew"); | |
3111 else | |
3112 { | |
3113 vim_snprintf((char *)IObuff, IOSIZE, "%dtabnew", | |
3114 current_tab - 1); | |
3115 do_cmdline_cmd(IObuff); | |
3116 } | |
686 | 3117 break; |
3118 | |
3119 case TABLINE_MENU_OPEN: | |
6631 | 3120 if (current_tab == 0) |
3121 do_cmdline_cmd((char_u *)"browse $tabnew"); | |
3122 else | |
3123 { | |
3124 vim_snprintf((char *)IObuff, IOSIZE, "browse %dtabnew", | |
3125 current_tab - 1); | |
3126 do_cmdline_cmd(IObuff); | |
3127 } | |
686 | 3128 break; |
3129 } | |
3130 } | |
685 | 3131 #endif |
3132 | |
7 | 3133 /* |
3134 * "Q" command. | |
3135 */ | |
3136 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3137 nv_exmode(cmdarg_T *cap) |
7 | 3138 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3139 // Ignore 'Q' in Visual mode, just give a beep. |
7 | 3140 if (VIsual_active) |
6949 | 3141 vim_beep(BO_EX); |
5735 | 3142 else if (!checkclearop(cap->oap)) |
7 | 3143 do_exmode(FALSE); |
3144 } | |
3145 | |
3146 /* | |
3147 * Handle a ":" command. | |
3148 */ | |
3149 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3150 nv_colon(cmdarg_T *cap) |
7 | 3151 { |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3152 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
|
3153 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
|
3154 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
|
3155 || 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
|
3156 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
|
3157 |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3158 if (VIsual_active && !is_cmdkey) |
7 | 3159 nv_operator(cap); |
3160 else | |
3161 { | |
3162 if (cap->oap->op_type != OP_NOP) | |
3163 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3164 // Using ":" as a movement is characterwise exclusive. |
7 | 3165 cap->oap->motion_type = MCHAR; |
3166 cap->oap->inclusive = FALSE; | |
3167 } | |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3168 else if (cap->count0 && !is_cmdkey) |
7 | 3169 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3170 // translate "count:" into ":.,.+(count - 1)" |
7 | 3171 stuffcharReadbuff('.'); |
3172 if (cap->count0 > 1) | |
3173 { | |
3174 stuffReadbuff((char_u *)",.+"); | |
3175 stuffnumReadbuff((long)cap->count0 - 1L); | |
3176 } | |
3177 } | |
3178 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3179 // When typing, don't type below an old message |
7 | 3180 if (KeyTyped) |
3181 compute_cmdrow(); | |
3182 | |
3183 old_p_im = p_im; | |
3184 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3185 // get a command line and execute it |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3186 flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0; |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3187 if (is_cmdkey) |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3188 cmd_result = do_cmdkey_command(cap->cmdchar, flags); |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3189 else |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3190 cmd_result = do_cmdline(NULL, getexline, NULL, flags); |
7 | 3191 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3192 // If 'insertmode' changed, enter or exit Insert mode |
7 | 3193 if (p_im != old_p_im) |
3194 { | |
3195 if (p_im) | |
3196 restart_edit = 'i'; | |
3197 else | |
3198 restart_edit = 0; | |
3199 } | |
3200 | |
4256 | 3201 if (cmd_result == FAIL) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3202 // The Ex command failed, do not execute the operator. |
4256 | 3203 clearop(cap->oap); |
3204 else if (cap->oap->op_type != OP_NOP | |
7 | 3205 && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count |
3206 || cap->oap->start.col > | |
4256 | 3207 (colnr_T)STRLEN(ml_get(cap->oap->start.lnum)) |
3208 || did_emsg | |
3209 )) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3210 // The start of the operator has become invalid by the Ex command. |
7 | 3211 clearopbeep(cap->oap); |
3212 } | |
3213 } | |
3214 | |
3215 /* | |
3216 * Handle CTRL-G command. | |
3217 */ | |
3218 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3219 nv_ctrlg(cmdarg_T *cap) |
7 | 3220 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3221 if (VIsual_active) // toggle Selection/Visual mode |
7 | 3222 { |
3223 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
|
3224 may_trigger_modechanged(); |
7 | 3225 showmode(); |
3226 } | |
5735 | 3227 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
|
3228 // print full name if count given or :cd used |
7 | 3229 fileinfo((int)cap->count0, FALSE, TRUE); |
3230 } | |
3231 | |
3232 /* | |
3233 * Handle CTRL-H <Backspace> command. | |
3234 */ | |
3235 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3236 nv_ctrlh(cmdarg_T *cap) |
7 | 3237 { |
3238 if (VIsual_active && VIsual_select) | |
3239 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3240 cap->cmdchar = 'x'; // BS key behaves like 'x' in Select mode |
7 | 3241 v_visop(cap); |
3242 } | |
3243 else | |
3244 nv_left(cap); | |
3245 } | |
3246 | |
3247 /* | |
3248 * CTRL-L: clear screen and redraw. | |
3249 */ | |
3250 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3251 nv_clear(cmdarg_T *cap) |
7 | 3252 { |
3253 if (!checkclearop(cap->oap)) | |
3254 { | |
3255 #ifdef FEAT_SYN_HL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3256 // Clear all syntax states to force resyncing. |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
3257 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
|
3258 # ifdef FEAT_RELTIME |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3259 { |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3260 win_T *wp; |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3261 |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3262 FOR_ALL_WINDOWS(wp) |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3263 wp->w_s->b_syn_slow = FALSE; |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3264 } |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3265 # endif |
7 | 3266 #endif |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
3267 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
|
3268 #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
|
3269 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3270 if (!gui.in_use) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3271 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3272 resize_console_buf(); |
15866
6ddcd10aa7af
patch 8.1.0940: MS-Windows console resizing not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
3273 #endif |
7 | 3274 } |
3275 } | |
3276 | |
3277 /* | |
3278 * CTRL-O: In Select mode: switch to Visual mode for one command. | |
3279 * Otherwise: Go to older pcmark. | |
3280 */ | |
3281 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3282 nv_ctrlo(cmdarg_T *cap) |
7 | 3283 { |
3284 if (VIsual_active && VIsual_select) | |
3285 { | |
3286 VIsual_select = FALSE; | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
3287 may_trigger_modechanged(); |
7 | 3288 showmode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3289 restart_VIsual_select = 2; // restart Select mode later |
7 | 3290 } |
3291 else | |
3292 { | |
3293 cap->count1 = -cap->count1; | |
3294 nv_pcmark(cap); | |
3295 } | |
3296 } | |
3297 | |
3298 /* | |
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
|
3299 * 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
|
3300 * not named. |
7 | 3301 */ |
3302 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3303 nv_hat(cmdarg_T *cap) |
7 | 3304 { |
3305 if (!checkclearopq(cap->oap)) | |
3306 (void)buflist_getfile((int)cap->count0, (linenr_T)0, | |
3307 GETF_SETMARK|GETF_ALT, FALSE); | |
3308 } | |
3309 | |
3310 /* | |
3311 * "Z" commands. | |
3312 */ | |
3313 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3314 nv_Zet(cmdarg_T *cap) |
7 | 3315 { |
3316 if (!checkclearopq(cap->oap)) | |
3317 { | |
3318 switch (cap->nchar) | |
3319 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3320 // "ZZ": equivalent to ":x". |
7 | 3321 case 'Z': do_cmdline_cmd((char_u *)"x"); |
3322 break; | |
3323 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3324 // "ZQ": equivalent to ":q!" (Elvis compatible). |
7 | 3325 case 'Q': do_cmdline_cmd((char_u *)"q!"); |
3326 break; | |
3327 | |
3328 default: clearopbeep(cap->oap); | |
3329 } | |
3330 } | |
3331 } | |
3332 | |
3333 /* | |
3334 * Call nv_ident() as if "c1" was used, with "c2" as next character. | |
3335 */ | |
3336 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3337 do_nv_ident(int c1, int c2) |
7 | 3338 { |
3339 oparg_T oa; | |
3340 cmdarg_T ca; | |
3341 | |
3342 clear_oparg(&oa); | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
3343 CLEAR_FIELD(ca); |
7 | 3344 ca.oap = &oa; |
3345 ca.cmdchar = c1; | |
3346 ca.nchar = c2; | |
3347 nv_ident(&ca); | |
3348 } | |
3349 | |
3350 /* | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3351 * '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
|
3352 * cursor. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3353 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3354 static int |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3355 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
|
3356 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
|
3357 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
|
3358 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
|
3359 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
|
3360 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
|
3361 int n, |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3362 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
|
3363 unsigned buflen) |
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 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
|
3366 int isman; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3367 int isman_s; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3368 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3369 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
|
3370 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3371 // 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
|
3372 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
|
3373 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3374 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3375 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3376 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
|
3377 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3378 // '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
|
3379 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
|
3380 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
|
3381 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3382 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
|
3383 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3384 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3385 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3386 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3387 // 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
|
3388 // 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
|
3389 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
|
3390 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3391 ++ptr; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3392 --n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3393 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3394 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
|
3395 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3396 // 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
|
3397 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
|
3398 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
|
3399 *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
|
3400 return 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3401 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3402 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3403 // 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
|
3404 // 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
|
3405 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
|
3406 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
|
3407 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
|
3408 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
|
3409 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3410 STRCAT(buf, "! "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3411 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
|
3412 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
|
3413 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3414 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
|
3415 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3416 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
|
3417 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3418 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
|
3419 STRCAT(buf, " "); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3420 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3421 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3422 *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
|
3423 return n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3424 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3425 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3426 /* |
7 | 3427 * Handle the commands that use the word under the cursor. |
3428 * [g] CTRL-] :ta to current identifier | |
3429 * [g] 'K' run program for current identifier | |
3430 * [g] '*' / to current identifier or string | |
3431 * [g] '#' ? to current identifier or string | |
3432 * g ']' :tselect for current identifier | |
3433 */ | |
3434 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3435 nv_ident(cmdarg_T *cap) |
7 | 3436 { |
3437 char_u *ptr = NULL; | |
3438 char_u *buf; | |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3439 unsigned buflen; |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3440 char_u *newbuf; |
7 | 3441 char_u *p; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3442 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
|
3443 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
|
3444 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
|
3445 int n = 0; // init for GCC |
7 | 3446 int cmdchar; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3447 int g_cmd; // "g" command |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3448 int tag_cmd = FALSE; |
7 | 3449 char_u *aux_ptr; |
3450 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3451 if (cap->cmdchar == 'g') // "g*", "g#", "g]" and "gCTRL-]" |
7 | 3452 { |
3453 cmdchar = cap->nchar; | |
3454 g_cmd = TRUE; | |
3455 } | |
3456 else | |
3457 { | |
3458 cmdchar = cap->cmdchar; | |
3459 g_cmd = FALSE; | |
3460 } | |
3461 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3462 if (cmdchar == POUND) // the pound sign, '#' for English keyboards |
7 | 3463 cmdchar = '#'; |
3464 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3465 // The "]", "CTRL-]" and "K" commands accept an argument in Visual mode. |
7 | 3466 if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K') |
3467 { | |
3468 if (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL) | |
3469 return; | |
3470 if (checkclearopq(cap->oap)) | |
3471 return; | |
3472 } | |
3473 | |
3474 if (ptr == NULL && (n = find_ident_under_cursor(&ptr, | |
3475 (cmdchar == '*' || cmdchar == '#') | |
3476 ? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0) | |
3477 { | |
3478 clearop(cap->oap); | |
3479 return; | |
3480 } | |
3481 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3482 // 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
|
3483 // 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
|
3484 // and some numbers. |
7 | 3485 kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp); |
3486 kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 | |
3487 || 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
|
3488 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
|
3489 { |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
3490 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
|
3491 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
|
3492 } |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3493 kp_ex = (*kp == ':'); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3494 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
|
3495 buf = alloc(buflen); |
7 | 3496 if (buf == NULL) |
3497 return; | |
3498 buf[0] = NUL; | |
3499 | |
3500 switch (cmdchar) | |
3501 { | |
3502 case '*': | |
3503 case '#': | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3504 // 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
|
3505 // 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
|
3506 // 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
|
3507 // it was. |
7 | 3508 setpcmark(); |
3509 curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline()); | |
3510 | |
3511 if (!g_cmd && vim_iswordp(ptr)) | |
3512 STRCPY(buf, "\\<"); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3513 no_smartcase = TRUE; // don't use 'smartcase' now |
7 | 3514 break; |
3515 | |
3516 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
|
3517 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
|
3518 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
|
3519 return; |
7 | 3520 break; |
3521 | |
3522 case ']': | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3523 tag_cmd = TRUE; |
7 | 3524 #ifdef FEAT_CSCOPE |
3525 if (p_cst) | |
3526 STRCPY(buf, "cstag "); | |
3527 else | |
3528 #endif | |
3529 STRCPY(buf, "ts "); | |
3530 break; | |
3531 | |
3532 default: | |
2112
6b5d641bcdd4
updated for version 7.2.395
Bram Moolenaar <bram@zimbu.org>
parents:
2049
diff
changeset
|
3533 tag_cmd = TRUE; |
7 | 3534 if (curbuf->b_help) |
3535 STRCPY(buf, "he! "); | |
3536 else | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3537 { |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3538 if (g_cmd) |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3539 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
|
3540 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
|
3541 STRCPY(buf, "ta "); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3542 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
|
3543 sprintf((char *)buf, ":%ldta ", cap->count0); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3544 } |
7 | 3545 } |
3546 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3547 // Now grab the chars in the identifier |
1712 | 3548 if (cmdchar == 'K' && !kp_help) |
3549 { | |
1728 | 3550 ptr = vim_strnsave(ptr, n); |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3551 if (kp_ex) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3552 // 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
|
3553 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
|
3554 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3555 // 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
|
3556 p = vim_strsave_shellescape(ptr, TRUE, TRUE); |
1728 | 3557 vim_free(ptr); |
1712 | 3558 if (p == NULL) |
3559 { | |
3560 vim_free(buf); | |
3561 return; | |
3562 } | |
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
|
3563 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
|
3564 if (newbuf == NULL) |
1712 | 3565 { |
3566 vim_free(buf); | |
3567 vim_free(p); | |
3568 return; | |
3569 } | |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3570 buf = newbuf; |
1712 | 3571 STRCAT(buf, p); |
3572 vim_free(p); | |
3573 } | |
7 | 3574 else |
1712 | 3575 { |
3576 if (cmdchar == '*') | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3577 aux_ptr = (char_u *)(magic_isset() ? "/.*~[^$\\" : "/^$\\"); |
1712 | 3578 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
|
3579 aux_ptr = (char_u *)(magic_isset() ? "/?.*~[^$\\" : "/?^$\\"); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3580 else if (tag_cmd) |
2603 | 3581 { |
3582 if (curbuf->b_help) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3583 // ":help" handles unescaped argument |
2603 | 3584 aux_ptr = (char_u *)""; |
3585 else | |
3586 aux_ptr = (char_u *)"\\|\"\n["; | |
3587 } | |
1712 | 3588 else |
3589 aux_ptr = (char_u *)"\\|\"\n*?["; | |
3590 | |
3591 p = buf + STRLEN(buf); | |
3592 while (n-- > 0) | |
3593 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3594 // put a backslash before \ and some others |
1712 | 3595 if (vim_strchr(aux_ptr, *ptr) != NULL) |
3596 *p++ = '\\'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3597 // 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
|
3598 // bytes of that character. |
1712 | 3599 if (has_mbyte) |
3600 { | |
3601 int i; | |
3602 int len = (*mb_ptr2len)(ptr) - 1; | |
3603 | |
3604 for (i = 0; i < len && n >= 1; ++i, --n) | |
3605 *p++ = *ptr++; | |
3606 } | |
3607 *p++ = *ptr++; | |
3608 } | |
3609 *p = NUL; | |
3610 } | |
7 | 3611 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3612 // Execute the command. |
7 | 3613 if (cmdchar == '*' || cmdchar == '#') |
3614 { | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3615 if (!g_cmd && (has_mbyte |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3616 ? 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
|
3617 : vim_iswordc(ptr[-1]))) |
7 | 3618 STRCAT(buf, "\\>"); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3619 |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3620 // put pattern in search history |
2024 | 3621 init_history(); |
7 | 3622 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
|
3623 |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
3624 (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); |
7 | 3625 } |
3626 else | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3627 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3628 g_tag_at_cursor = TRUE; |
7 | 3629 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
|
3630 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
|
3631 } |
7 | 3632 |
3633 vim_free(buf); | |
3634 } | |
3635 | |
3636 /* | |
3637 * Get visually selected text, within one line only. | |
3638 * Returns FAIL if more than one line selected. | |
3639 */ | |
344 | 3640 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3641 get_visual_text( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3642 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3643 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
|
3644 int *lenp) // return: length of selected text |
7 | 3645 { |
3646 if (VIsual_mode != 'V') | |
3647 unadjust_for_sel(); | |
3648 if (VIsual.lnum != curwin->w_cursor.lnum) | |
3649 { | |
344 | 3650 if (cap != NULL) |
3651 clearopbeep(cap->oap); | |
7 | 3652 return FAIL; |
3653 } | |
3654 if (VIsual_mode == 'V') | |
3655 { | |
3656 *pp = ml_get_curline(); | |
3657 *lenp = (int)STRLEN(*pp); | |
3658 } | |
3659 else | |
3660 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3661 if (LT_POS(curwin->w_cursor, VIsual)) |
7 | 3662 { |
3663 *pp = ml_get_pos(&curwin->w_cursor); | |
3664 *lenp = VIsual.col - curwin->w_cursor.col + 1; | |
3665 } | |
3666 else | |
3667 { | |
3668 *pp = ml_get_pos(&VIsual); | |
3669 *lenp = curwin->w_cursor.col - VIsual.col + 1; | |
3670 } | |
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
|
3671 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
|
3672 *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
|
3673 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
|
3674 { |
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
|
3675 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
|
3676 // 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
|
3677 // 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
|
3678 *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
|
3679 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
|
3680 // 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
|
3681 *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
|
3682 } |
7 | 3683 } |
3684 reset_VIsual_and_resel(); | |
3685 return OK; | |
3686 } | |
3687 | |
3688 /* | |
3689 * CTRL-T: backwards in tag stack | |
3690 */ | |
3691 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3692 nv_tagpop(cmdarg_T *cap) |
7 | 3693 { |
3694 if (!checkclearopq(cap->oap)) | |
3695 do_tag((char_u *)"", DT_POP, (int)cap->count1, FALSE, TRUE); | |
3696 } | |
3697 | |
3698 /* | |
3699 * Handle scrolling command 'H', 'L' and 'M'. | |
3700 */ | |
3701 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3702 nv_scroll(cmdarg_T *cap) |
7 | 3703 { |
3704 int used = 0; | |
3705 long n; | |
3706 #ifdef FEAT_FOLDING | |
3707 linenr_T lnum; | |
3708 #endif | |
3709 int half; | |
3710 | |
3711 cap->oap->motion_type = MLINE; | |
3712 setpcmark(); | |
3713 | |
3714 if (cap->cmdchar == 'L') | |
3715 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3716 validate_botline(); // make sure curwin->w_botline is valid |
7 | 3717 curwin->w_cursor.lnum = curwin->w_botline - 1; |
3718 if (cap->count1 - 1 >= curwin->w_cursor.lnum) | |
3719 curwin->w_cursor.lnum = 1; | |
3720 else | |
9 | 3721 { |
3722 #ifdef FEAT_FOLDING | |
3723 if (hasAnyFolding(curwin)) | |
3724 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3725 // Count a fold for one screen line. |
9 | 3726 for (n = cap->count1 - 1; n > 0 |
3727 && curwin->w_cursor.lnum > curwin->w_topline; --n) | |
3728 { | |
3729 (void)hasFolding(curwin->w_cursor.lnum, | |
3730 &curwin->w_cursor.lnum, NULL); | |
3731 --curwin->w_cursor.lnum; | |
3732 } | |
3733 } | |
3734 else | |
3735 #endif | |
3736 curwin->w_cursor.lnum -= cap->count1 - 1; | |
3737 } | |
7 | 3738 } |
3739 else | |
3740 { | |
3741 if (cap->cmdchar == 'M') | |
3742 { | |
3743 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3744 // Don't count filler lines above the window. |
7 | 3745 used -= diff_check_fill(curwin, curwin->w_topline) |
3746 - curwin->w_topfill; | |
3747 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3748 validate_botline(); // make sure w_empty_rows is valid |
7 | 3749 half = (curwin->w_height - curwin->w_empty_rows + 1) / 2; |
3750 for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; ++n) | |
3751 { | |
3752 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3753 // 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
|
3754 // line" and half to be "above the next line". |
7 | 3755 if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline |
3756 + n) / 2 >= half) | |
3757 { | |
3758 --n; | |
3759 break; | |
3760 } | |
3761 #endif | |
3762 used += plines(curwin->w_topline + n); | |
3763 if (used >= half) | |
3764 break; | |
3765 #ifdef FEAT_FOLDING | |
3766 if (hasFolding(curwin->w_topline + n, NULL, &lnum)) | |
3767 n = lnum - curwin->w_topline; | |
3768 #endif | |
3769 } | |
3770 if (n > 0 && used > curwin->w_height) | |
3771 --n; | |
3772 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3773 else // (cap->cmdchar == 'H') |
9 | 3774 { |
7 | 3775 n = cap->count1 - 1; |
9 | 3776 #ifdef FEAT_FOLDING |
3777 if (hasAnyFolding(curwin)) | |
3778 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3779 // Count a fold for one screen line. |
9 | 3780 lnum = curwin->w_topline; |
3781 while (n-- > 0 && lnum < curwin->w_botline - 1) | |
3782 { | |
7009 | 3783 (void)hasFolding(lnum, NULL, &lnum); |
9 | 3784 ++lnum; |
3785 } | |
3786 n = lnum - curwin->w_topline; | |
3787 } | |
3788 #endif | |
3789 } | |
7 | 3790 curwin->w_cursor.lnum = curwin->w_topline + n; |
3791 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
3792 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
3793 } | |
3794 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3795 // 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
|
3796 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
|
3797 cursor_correct(); |
7 | 3798 beginline(BL_SOL | BL_FIX); |
3799 } | |
3800 | |
3801 /* | |
3802 * Cursor right commands. | |
3803 */ | |
3804 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3805 nv_right(cmdarg_T *cap) |
7 | 3806 { |
3807 long n; | |
5735 | 3808 int past_line; |
7 | 3809 |
180 | 3810 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
3811 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3812 // <C-Right> and <S-Right> move a word or WORD right |
180 | 3813 if (mod_mask & MOD_MASK_CTRL) |
3814 cap->arg = TRUE; | |
3815 nv_wordcmd(cap); | |
3816 return; | |
3817 } | |
3818 | |
7 | 3819 cap->oap->motion_type = MCHAR; |
3820 cap->oap->inclusive = FALSE; | |
5735 | 3821 past_line = (VIsual_active && *p_sel != 'o'); |
3822 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3823 // 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
|
3824 // are (theoretically) infinitely long. |
7 | 3825 if (virtual_active()) |
5735 | 3826 past_line = 0; |
7 | 3827 |
3828 for (n = cap->count1; n > 0; --n) | |
3829 { | |
5735 | 3830 if ((!past_line && oneright() == FAIL) |
3831 || (past_line && *ml_get_cursor() == NUL) | |
1877 | 3832 ) |
7 | 3833 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
3834 // <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
|
3835 // '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
|
3836 // CURS_RIGHT wraps to next line if 'whichwrap' has '>'. |
7 | 3837 if ( ((cap->cmdchar == ' ' |
3838 && vim_strchr(p_ww, 's') != NULL) | |
3839 || (cap->cmdchar == 'l' | |
3840 && vim_strchr(p_ww, 'l') != NULL) | |
229 | 3841 || (cap->cmdchar == K_RIGHT |
7 | 3842 && vim_strchr(p_ww, '>') != NULL)) |
3843 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
3844 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3845 // 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
|
3846 // 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
|
3847 // included, move to next line after that |
714 | 3848 if ( cap->oap->op_type != OP_NOP |
7 | 3849 && !cap->oap->inclusive |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3850 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3851 cap->oap->inclusive = TRUE; |
3852 else | |
3853 { | |
3854 ++curwin->w_cursor.lnum; | |
3855 curwin->w_cursor.col = 0; | |
3856 curwin->w_cursor.coladd = 0; | |
3857 curwin->w_set_curswant = TRUE; | |
3858 cap->oap->inclusive = FALSE; | |
3859 } | |
3860 continue; | |
3861 } | |
3862 if (cap->oap->op_type == OP_NOP) | |
3863 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3864 // Only beep and flush if not moved at all |
7 | 3865 if (n == cap->count1) |
3866 beep_flush(); | |
3867 } | |
3868 else | |
3869 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3870 if (!LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3871 cap->oap->inclusive = TRUE; |
3872 } | |
3873 break; | |
3874 } | |
5735 | 3875 else if (past_line) |
7 | 3876 { |
3877 curwin->w_set_curswant = TRUE; | |
3878 if (virtual_active()) | |
3879 oneright(); | |
3880 else | |
5735 | 3881 { |
7 | 3882 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
|
3883 curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); |
7 | 3884 else |
3885 ++curwin->w_cursor.col; | |
3886 } | |
3887 } | |
3888 } | |
3889 #ifdef FEAT_FOLDING | |
3890 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
3891 && cap->oap->op_type == OP_NOP) | |
3892 foldOpenCursor(); | |
3893 #endif | |
3894 } | |
3895 | |
3896 /* | |
3897 * Cursor left commands. | |
3898 * | |
3899 * Returns TRUE when operator end should not be adjusted. | |
3900 */ | |
3901 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3902 nv_left(cmdarg_T *cap) |
7 | 3903 { |
3904 long n; | |
3905 | |
180 | 3906 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
3907 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3908 // <C-Left> and <S-Left> move a word or WORD left |
180 | 3909 if (mod_mask & MOD_MASK_CTRL) |
3910 cap->arg = 1; | |
3911 nv_bck_word(cap); | |
3912 return; | |
3913 } | |
3914 | |
7 | 3915 cap->oap->motion_type = MCHAR; |
3916 cap->oap->inclusive = FALSE; | |
3917 for (n = cap->count1; n > 0; --n) | |
3918 { | |
3919 if (oneleft() == FAIL) | |
3920 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3921 // <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
|
3922 // '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
|
3923 // CURS_LEFT wraps to previous line if 'whichwrap' has '<'. |
7 | 3924 if ( (((cap->cmdchar == K_BS |
3925 || cap->cmdchar == Ctrl_H) | |
3926 && vim_strchr(p_ww, 'b') != NULL) | |
3927 || (cap->cmdchar == 'h' | |
3928 && vim_strchr(p_ww, 'h') != NULL) | |
229 | 3929 || (cap->cmdchar == K_LEFT |
7 | 3930 && vim_strchr(p_ww, '<') != NULL)) |
3931 && curwin->w_cursor.lnum > 1) | |
3932 { | |
3933 --(curwin->w_cursor.lnum); | |
3934 coladvance((colnr_T)MAXCOL); | |
3935 curwin->w_set_curswant = TRUE; | |
3936 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3937 // 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
|
3938 // 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
|
3939 // 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
|
3940 // Don't adjust op_end now, otherwise it won't work. |
7 | 3941 if ( (cap->oap->op_type == OP_DELETE |
3942 || 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
|
3943 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 3944 { |
5682 | 3945 char_u *cp = ml_get_cursor(); |
3946 | |
3947 if (*cp != NUL) | |
3948 { | |
3949 if (has_mbyte) | |
3950 curwin->w_cursor.col += (*mb_ptr2len)(cp); | |
3951 else | |
3952 ++curwin->w_cursor.col; | |
3953 } | |
7 | 3954 cap->retval |= CA_NO_ADJ_OP_END; |
3955 } | |
3956 continue; | |
3957 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3958 // Only beep and flush if not moved at all |
7 | 3959 else if (cap->oap->op_type == OP_NOP && n == cap->count1) |
3960 beep_flush(); | |
3961 break; | |
3962 } | |
3963 } | |
3964 #ifdef FEAT_FOLDING | |
3965 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
3966 && cap->oap->op_type == OP_NOP) | |
3967 foldOpenCursor(); | |
3968 #endif | |
3969 } | |
3970 | |
3971 /* | |
3972 * Cursor up commands. | |
3973 * cap->arg is TRUE for "-": Move cursor to first non-blank. | |
3974 */ | |
3975 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3976 nv_up(cmdarg_T *cap) |
7 | 3977 { |
180 | 3978 if (mod_mask & MOD_MASK_SHIFT) |
3979 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3980 // <S-Up> is page up |
180 | 3981 cap->arg = BACKWARD; |
3982 nv_page(cap); | |
3983 } | |
3984 else | |
3985 { | |
3986 cap->oap->motion_type = MLINE; | |
3987 if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
3988 clearopbeep(cap->oap); | |
3989 else if (cap->arg) | |
3990 beginline(BL_WHITE | BL_FIX); | |
3991 } | |
7 | 3992 } |
3993 | |
3994 /* | |
3995 * Cursor down commands. | |
3996 * cap->arg is TRUE for CR and "+": Move cursor to first non-blank. | |
3997 */ | |
3998 static void | |
10192
758f3d5a463d
commit https://github.com/vim/vim/commit/1b010058235fb803c1d4f42a02d2883921be8ef4
Christian Brabandt <cb@256bit.org>
parents:
10154
diff
changeset
|
3999 nv_down(cmdarg_T *cap) |
7 | 4000 { |
180 | 4001 if (mod_mask & MOD_MASK_SHIFT) |
4002 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4003 // <S-Down> is page down |
180 | 4004 cap->arg = FORWARD; |
4005 nv_page(cap); | |
4006 } | |
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
|
4007 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4008 // 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
|
4009 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
|
4010 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
|
4011 #endif |
180 | 4012 else |
7 | 4013 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4014 // In the cmdline window a <CR> executes the command. |
170 | 4015 if (cmdwin_type != 0 && cap->cmdchar == CAR) |
7 | 4016 cmdwin_result = CAR; |
4017 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
|
4018 #ifdef FEAT_JOB_CHANNEL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4019 // 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
|
4020 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
|
4021 && 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
|
4022 { |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
4023 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
|
4024 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
|
4025 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
|
4026 } |
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
|
4027 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
|
4028 #endif |
7 | 4029 { |
4030 cap->oap->motion_type = MLINE; | |
4031 if (cursor_down(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
4032 clearopbeep(cap->oap); | |
4033 else if (cap->arg) | |
4034 beginline(BL_WHITE | BL_FIX); | |
4035 } | |
4036 } | |
4037 } | |
4038 | |
4039 /* | |
4040 * Grab the file name under the cursor and edit it. | |
4041 */ | |
4042 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4043 nv_gotofile(cmdarg_T *cap) |
7 | 4044 { |
4045 char_u *ptr; | |
681 | 4046 linenr_T lnum = -1; |
7 | 4047 |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
4048 if (check_text_or_curbuf_locked(cap->oap)) |
7 | 4049 return; |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31192
diff
changeset
|
4050 |
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
|
4051 #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
|
4052 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
|
4053 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
|
4054 #endif |
7 | 4055 |
681 | 4056 ptr = grab_file_name(cap->count1, &lnum); |
7 | 4057 |
4058 if (ptr != NULL) | |
4059 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4060 // 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
|
4061 if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !buf_hide(curbuf)) |
7009 | 4062 (void)autowrite(curbuf, FALSE); |
7 | 4063 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
|
4064 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
|
4065 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
|
4066 && cap->nchar == 'F' && lnum >= 0) |
681 | 4067 { |
4068 curwin->w_cursor.lnum = lnum; | |
4069 check_cursor_lnum(); | |
4070 beginline(BL_SOL | BL_FIX); | |
4071 } | |
7 | 4072 vim_free(ptr); |
4073 } | |
4074 else | |
4075 clearop(cap->oap); | |
4076 } | |
4077 | |
4078 /* | |
4079 * <End> command: to end of current line or last line. | |
4080 */ | |
4081 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4082 nv_end(cmdarg_T *cap) |
7 | 4083 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4084 if (cap->arg || (mod_mask & MOD_MASK_CTRL)) // CTRL-END = goto last line |
180 | 4085 { |
4086 cap->arg = TRUE; | |
7 | 4087 nv_goto(cap); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4088 cap->count1 = 1; // to end of current line |
7 | 4089 } |
4090 nv_dollar(cap); | |
4091 } | |
4092 | |
4093 /* | |
4094 * Handle the "$" command. | |
4095 */ | |
4096 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4097 nv_dollar(cmdarg_T *cap) |
7 | 4098 { |
4099 cap->oap->motion_type = MCHAR; | |
4100 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4101 // 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
|
4102 // 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
|
4103 // Otherwise, send it to the end of the line. |
7 | 4104 if (!virtual_active() || gchar_cursor() != NUL |
4105 || 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
|
4106 curwin->w_curswant = MAXCOL; // so we stay at the end |
7 | 4107 if (cursor_down((long)(cap->count1 - 1), |
4108 cap->oap->op_type == OP_NOP) == FAIL) | |
4109 clearopbeep(cap->oap); | |
4110 #ifdef FEAT_FOLDING | |
4111 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4112 foldOpenCursor(); | |
4113 #endif | |
4114 } | |
4115 | |
4116 /* | |
4117 * Implementation of '?' and '/' commands. | |
4118 * If cap->arg is TRUE don't set PC mark. | |
4119 */ | |
4120 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4121 nv_search(cmdarg_T *cap) |
7 | 4122 { |
4123 oparg_T *oap = cap->oap; | |
10098
72e4b7f90465
commit https://github.com/vim/vim/commit/dda933d06c06c2792bd686d059f6ad19191ad30b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4124 pos_T save_cursor = curwin->w_cursor; |
7 | 4125 |
4126 if (cap->cmdchar == '?' && cap->oap->op_type == OP_ROT13) | |
4127 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4128 // Translate "g??" to "g?g?" |
7 | 4129 cap->cmdchar = 'g'; |
4130 cap->nchar = '?'; | |
4131 nv_operator(cap); | |
4132 return; | |
4133 } | |
4134 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4135 // 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
|
4136 // start position. |
26804
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26749
diff
changeset
|
4137 cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, 0); |
7 | 4138 |
4139 if (cap->searchbuf == NULL) | |
4140 { | |
4141 clearop(oap); | |
4142 return; | |
4143 } | |
4144 | |
6620 | 4145 (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
|
4146 (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
|
4147 ? 0 : SEARCH_MARK, NULL); |
7 | 4148 } |
4149 | |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4150 |
7 | 4151 /* |
4152 * Handle "N" and "n" commands. | |
4153 * cap->arg is SEARCH_REV for "N", 0 for "n". | |
4154 */ | |
4155 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4156 nv_next(cmdarg_T *cap) |
7 | 4157 { |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4158 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
|
4159 int wrapped = FALSE; |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4160 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
|
4161 |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4162 if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor)) |
6620 | 4163 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4164 // 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
|
4165 // 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
|
4166 // in the buffer: Repeat with count + 1. |
6620 | 4167 cap->count1 += 1; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4168 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); |
6620 | 4169 cap->count1 -= 1; |
4170 } | |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4171 |
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4172 #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
|
4173 // 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
|
4174 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
|
4175 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
|
4176 #endif |
7 | 4177 } |
4178 | |
4179 /* | |
4180 * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat). | |
4181 * Uses only cap->count1 and cap->oap from "cap". | |
6620 | 4182 * Return 0 for failure, 1 for found, 2 for found and line offset added. |
4183 */ | |
4184 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4185 normal_search( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4186 cmdarg_T *cap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4187 int dir, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4188 char_u *pat, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4189 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
|
4190 int *wrapped) |
7 | 4191 { |
4192 int i; | |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4193 searchit_arg_T sia; |
28401
d1982178f787
patch 8.2.4725: unused variable in tiny build
Bram Moolenaar <Bram@vim.org>
parents:
28399
diff
changeset
|
4194 #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
|
4195 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
|
4196 #endif |
7 | 4197 |
4198 cap->oap->motion_type = MCHAR; | |
4199 cap->oap->inclusive = FALSE; | |
4200 cap->oap->use_reg_one = TRUE; | |
4201 curwin->w_set_curswant = TRUE; | |
4202 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
4203 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
|
4204 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
|
4205 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
|
4206 if (wrapped != NULL) |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4207 *wrapped = sia.sa_wrapped; |
7 | 4208 if (i == 0) |
4209 clearop(cap->oap); | |
4210 else | |
4211 { | |
4212 if (i == 2) | |
4213 cap->oap->motion_type = MLINE; | |
4214 curwin->w_cursor.coladd = 0; | |
4215 #ifdef FEAT_FOLDING | |
4216 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4217 foldOpenCursor(); | |
4218 #endif | |
4219 } | |
28399
d395fadbaf67
patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4220 #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
|
4221 // 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
|
4222 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
|
4223 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
|
4224 #endif |
7 | 4225 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4226 // "/$" 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
|
4227 // correct that here |
7 | 4228 check_cursor(); |
6620 | 4229 return i; |
7 | 4230 } |
4231 | |
4232 /* | |
4233 * Character search commands. | |
4234 * cap->arg is BACKWARD for 'F' and 'T', FORWARD for 'f' and 't', TRUE for | |
4235 * ',' and FALSE for ';'. | |
4236 * cap->nchar is NUL for ',' and ';' (repeat the search) | |
4237 */ | |
4238 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4239 nv_csearch(cmdarg_T *cap) |
7 | 4240 { |
4241 int t_cmd; | |
4242 | |
4243 if (cap->cmdchar == 't' || cap->cmdchar == 'T') | |
4244 t_cmd = TRUE; | |
4245 else | |
4246 t_cmd = FALSE; | |
4247 | |
4248 cap->oap->motion_type = MCHAR; | |
4249 if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL) | |
4250 clearopbeep(cap->oap); | |
4251 else | |
4252 { | |
4253 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
|
4254 // Include a Tab for "tx" and for "dfx". |
7 | 4255 if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD |
4256 && (t_cmd || cap->oap->op_type != OP_NOP)) | |
4257 { | |
4258 colnr_T scol, ecol; | |
4259 | |
4260 getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); | |
4261 curwin->w_cursor.coladd = ecol - scol; | |
4262 } | |
4263 else | |
4264 curwin->w_cursor.coladd = 0; | |
4265 adjust_for_sel(cap); | |
4266 #ifdef FEAT_FOLDING | |
4267 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4268 foldOpenCursor(); | |
4269 #endif | |
4270 } | |
4271 } | |
4272 | |
4273 /* | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4274 * "[{", "[(", "]}" 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
|
4275 * "[#", "]#": 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
|
4276 * "[/", "[*", "]/", "]*": 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
|
4277 * "[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
|
4278 * "[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
|
4279 */ |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4280 static void |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4281 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
|
4282 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4283 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
|
4284 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
|
4285 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
|
4286 long n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4287 int findc; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4288 int c; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4289 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4290 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
|
4291 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 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
|
4293 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
|
4294 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4295 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
|
4296 findc = '{'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4297 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4298 findc = '}'; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4299 n = 9999; |
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 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4302 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4303 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
|
4304 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
|
4305 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4306 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
|
4307 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4308 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
|
4309 (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
|
4310 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4311 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
|
4312 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4313 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
|
4314 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
|
4315 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4316 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4317 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
|
4318 break; |
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 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
|
4321 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
|
4322 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
|
4323 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4324 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
|
4325 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4326 // 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
|
4327 // 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
|
4328 // 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
|
4329 // 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
|
4330 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
|
4331 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4332 // 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
|
4333 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
|
4334 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4335 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
|
4336 // 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
|
4337 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
|
4338 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4339 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
|
4340 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
|
4341 if (norm) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4342 --n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4343 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4344 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4345 pos = NULL; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4346 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
|
4347 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4348 for (;;) |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4349 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4350 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
|
4351 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4352 // 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
|
4353 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
|
4354 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
|
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 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4357 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4358 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
|
4359 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
|
4360 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4361 // 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
|
4362 // 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
|
4363 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
|
4364 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4365 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
|
4366 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
|
4367 n = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4368 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4369 // 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
|
4370 // 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
|
4371 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
|
4372 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4373 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
|
4374 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
|
4375 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4376 // 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
|
4377 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
|
4378 (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
|
4379 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
|
4380 n = 0; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4381 else |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4382 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
|
4383 break; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4384 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4385 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4386 --n; |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4387 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4388 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
|
4389 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
|
4390 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
|
4391 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4392 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
|
4393 { |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4394 setpcmark(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4395 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
|
4396 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
|
4397 #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
|
4398 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
|
4399 && 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
|
4400 foldOpenCursor(); |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4401 #endif |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4402 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4403 } |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4404 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4405 /* |
7 | 4406 * "[" and "]" commands. |
4407 * cap->arg is BACKWARD for "[" and FORWARD for "]". | |
4408 */ | |
4409 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4410 nv_brackets(cmdarg_T *cap) |
7 | 4411 { |
4412 pos_T prev_pos; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4413 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
|
4414 pos_T old_pos; // cursor position before command |
7 | 4415 int flag; |
4416 long n; | |
4417 | |
4418 cap->oap->motion_type = MCHAR; | |
4419 cap->oap->inclusive = FALSE; | |
4420 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
|
4421 curwin->w_cursor.coladd = 0; // TODO: don't do this for an error. |
7 | 4422 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4423 // "[f" or "]f" : Edit file under the cursor (same as "gf") |
7 | 4424 if (cap->nchar == 'f') |
4425 nv_gotofile(cap); | |
4426 else | |
4427 | |
4428 #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
|
4429 // 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
|
4430 // 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
|
4431 // |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4432 // 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
|
4433 // 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
|
4434 // 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
|
4435 // 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
|
4436 if (vim_strchr((char_u *)"iI\011dD\004", cap->nchar) != NULL) |
7 | 4437 { |
4438 char_u *ptr; | |
4439 int len; | |
4440 | |
4441 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) | |
4442 clearop(cap->oap); | |
4443 else | |
4444 { | |
29004
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4445 // 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
|
4446 ptr = vim_strnsave(ptr, len); |
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4447 if (ptr == NULL) |
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4448 return; |
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4449 |
7 | 4450 find_pattern_in_path(ptr, 0, len, TRUE, |
4451 cap->count0 == 0 ? !isupper(cap->nchar) : FALSE, | |
4452 ((cap->nchar & 0xf) == ('d' & 0xf)) ? FIND_DEFINE : FIND_ANY, | |
4453 cap->count1, | |
4454 isupper(cap->nchar) ? ACTION_SHOW_ALL : | |
4455 islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO, | |
4456 cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1, | |
4457 (linenr_T)MAXLNUM); | |
29004
c7e3721ec88f
patch 8.2.5024: using freed memory with "]d"
Bram Moolenaar <Bram@vim.org>
parents:
29002
diff
changeset
|
4458 vim_free(ptr); |
7 | 4459 curwin->w_set_curswant = TRUE; |
4460 } | |
4461 } | |
4462 else | |
4463 #endif | |
4464 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4465 // "[{", "[(", "]}" 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
|
4466 // "[#", "]#": 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
|
4467 // "[/", "[*", "]/", "]*": 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
|
4468 // "[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
|
4469 // "[M" or "]M" search for prev/next end of (Java) method. |
7 | 4470 if ( (cap->cmdchar == '[' |
4471 && vim_strchr((char_u *)"{(*/#mM", cap->nchar) != NULL) | |
4472 || (cap->cmdchar == ']' | |
4473 && 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
|
4474 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
|
4475 |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4476 // "[[", "[]", "]]" and "][": move to start or end of function |
7 | 4477 else if (cap->nchar == '[' || cap->nchar == ']') |
4478 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4479 if (cap->nchar == cap->cmdchar) // "]]" or "[[" |
7 | 4480 flag = '{'; |
4481 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4482 flag = '}'; // "][" or "[]" |
7 | 4483 |
4484 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
|
4485 // 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
|
4486 // we also stop at '}'. |
503 | 4487 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, flag, |
7 | 4488 (cap->oap->op_type != OP_NOP |
4489 && cap->arg == FORWARD && flag == '{'))) | |
4490 clearopbeep(cap->oap); | |
4491 else | |
4492 { | |
4493 if (cap->oap->op_type == OP_NOP) | |
4494 beginline(BL_WHITE | BL_FIX); | |
4495 #ifdef FEAT_FOLDING | |
4496 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4497 foldOpenCursor(); | |
4498 #endif | |
4499 } | |
4500 } | |
4501 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4502 // "[p", "[P", "]P" and "]p": put with indent adjustment |
7 | 4503 else if (cap->nchar == 'p' || cap->nchar == 'P') |
4504 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
4505 nv_put_opt(cap, TRUE); |
7 | 4506 } |
4507 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4508 // "['", "[`", "]'" and "]`": jump to next mark |
7 | 4509 else if (cap->nchar == '\'' || cap->nchar == '`') |
4510 { | |
4511 pos = &curwin->w_cursor; | |
4512 for (n = cap->count1; n > 0; --n) | |
4513 { | |
4514 prev_pos = *pos; | |
4515 pos = getnextmark(pos, cap->cmdchar == '[' ? BACKWARD : FORWARD, | |
4516 cap->nchar == '\''); | |
4517 if (pos == NULL) | |
4518 break; | |
4519 } | |
4520 if (pos == NULL) | |
4521 pos = &prev_pos; | |
4522 nv_cursormark(cap, cap->nchar == '\'', pos); | |
4523 } | |
4524 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4525 // [ 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
|
4526 // 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
|
4527 else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) |
7 | 4528 { |
4529 (void)do_mouse(cap->oap, cap->nchar, | |
4530 (cap->cmdchar == ']') ? FORWARD : BACKWARD, | |
4531 cap->count1, PUT_FIXINDENT); | |
4532 } | |
4533 | |
4534 #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
|
4535 // "[z" and "]z": move to start or end of open fold. |
7 | 4536 else if (cap->nchar == 'z') |
4537 { | |
4538 if (foldMoveTo(FALSE, cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4539 cap->count1) == FAIL) | |
4540 clearopbeep(cap->oap); | |
4541 } | |
4542 #endif | |
4543 | |
4544 #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
|
4545 // "[c" and "]c": move to next or previous diff-change. |
7 | 4546 else if (cap->nchar == 'c') |
4547 { | |
4548 if (diff_move_to(cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4549 cap->count1) == FAIL) | |
4550 clearopbeep(cap->oap); | |
4551 } | |
4552 #endif | |
4553 | |
737 | 4554 #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
|
4555 // "[s", "[S", "]s" and "]S": move to next spell error. |
236 | 4556 else if (cap->nchar == 's' || cap->nchar == 'S') |
4557 { | |
249 | 4558 setpcmark(); |
4559 for (n = 0; n < cap->count1; ++n) | |
498 | 4560 if (spell_move_to(curwin, cap->cmdchar == ']' ? FORWARD : BACKWARD, |
4561 cap->nchar == 's' ? TRUE : FALSE, FALSE, NULL) == 0) | |
249 | 4562 { |
4563 clearopbeep(cap->oap); | |
4564 break; | |
4565 } | |
13088
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4566 else |
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4567 curwin->w_set_curswant = TRUE; |
819 | 4568 # ifdef FEAT_FOLDING |
4569 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4570 foldOpenCursor(); | |
4571 # endif | |
236 | 4572 } |
4573 #endif | |
4574 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4575 // Not a valid cap->nchar. |
7 | 4576 else |
4577 clearopbeep(cap->oap); | |
4578 } | |
4579 | |
4580 /* | |
4581 * Handle Normal mode "%" command. | |
4582 */ | |
4583 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4584 nv_percent(cmdarg_T *cap) |
7 | 4585 { |
4586 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
|
4587 #if defined(FEAT_FOLDING) |
7 | 4588 linenr_T lnum = curwin->w_cursor.lnum; |
4589 #endif | |
4590 | |
4591 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4592 if (cap->count0) // {cnt}% : goto {cnt} percentage in file |
7 | 4593 { |
4594 if (cap->count0 > 100) | |
4595 clearopbeep(cap->oap); | |
4596 else | |
4597 { | |
4598 cap->oap->motion_type = MLINE; | |
4599 setpcmark(); | |
24010
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4600 // 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
|
4601 // 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
|
4602 // 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
|
4603 // to avoid overflows. |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4604 if (curbuf->b_ml.ml_line_count >= 21474836) |
7 | 4605 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L) |
4606 / 100L * cap->count0; | |
4607 else | |
4608 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count * | |
4609 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
|
4610 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
|
4611 curwin->w_cursor.lnum = 1; |
7 | 4612 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
4613 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
4614 beginline(BL_SOL | BL_FIX); | |
4615 } | |
4616 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4617 else // "%" : go to matching paren |
7 | 4618 { |
4619 cap->oap->motion_type = MCHAR; | |
4620 cap->oap->use_reg_one = TRUE; | |
4621 if ((pos = findmatch(cap->oap, NUL)) == NULL) | |
4622 clearopbeep(cap->oap); | |
4623 else | |
4624 { | |
4625 setpcmark(); | |
4626 curwin->w_cursor = *pos; | |
4627 curwin->w_set_curswant = TRUE; | |
4628 curwin->w_cursor.coladd = 0; | |
4629 adjust_for_sel(cap); | |
4630 } | |
4631 } | |
4632 #ifdef FEAT_FOLDING | |
4633 if (cap->oap->op_type == OP_NOP | |
4634 && lnum != curwin->w_cursor.lnum | |
4635 && (fdo_flags & FDO_PERCENT) | |
4636 && KeyTyped) | |
4637 foldOpenCursor(); | |
4638 #endif | |
4639 } | |
4640 | |
4641 /* | |
4642 * Handle "(" and ")" commands. | |
4643 * cap->arg is BACKWARD for "(" and FORWARD for ")". | |
4644 */ | |
4645 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4646 nv_brace(cmdarg_T *cap) |
7 | 4647 { |
4648 cap->oap->motion_type = MCHAR; | |
4649 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
|
4650 // The motion used to be inclusive for "(", but that is not what Vi does. |
620 | 4651 cap->oap->inclusive = FALSE; |
7 | 4652 curwin->w_set_curswant = TRUE; |
4653 | |
4654 if (findsent(cap->arg, cap->count1) == FAIL) | |
4655 clearopbeep(cap->oap); | |
4656 else | |
4657 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4658 // Don't leave the cursor on the NUL past end of line. |
1505 | 4659 adjust_cursor(cap->oap); |
7 | 4660 curwin->w_cursor.coladd = 0; |
4661 #ifdef FEAT_FOLDING | |
4662 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4663 foldOpenCursor(); | |
4664 #endif | |
4665 } | |
4666 } | |
4667 | |
4668 /* | |
4669 * "m" command: Mark a position. | |
4670 */ | |
4671 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4672 nv_mark(cmdarg_T *cap) |
7 | 4673 { |
4674 if (!checkclearop(cap->oap)) | |
4675 { | |
4676 if (setmark(cap->nchar) == FAIL) | |
4677 clearopbeep(cap->oap); | |
4678 } | |
4679 } | |
4680 | |
4681 /* | |
4682 * "{" and "}" commands. | |
4683 * cmd->arg is BACKWARD for "{" and FORWARD for "}". | |
4684 */ | |
4685 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4686 nv_findpar(cmdarg_T *cap) |
7 | 4687 { |
4688 cap->oap->motion_type = MCHAR; | |
4689 cap->oap->inclusive = FALSE; | |
4690 cap->oap->use_reg_one = TRUE; | |
4691 curwin->w_set_curswant = TRUE; | |
503 | 4692 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE)) |
7 | 4693 clearopbeep(cap->oap); |
4694 else | |
4695 { | |
4696 curwin->w_cursor.coladd = 0; | |
4697 #ifdef FEAT_FOLDING | |
4698 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4699 foldOpenCursor(); | |
4700 #endif | |
4701 } | |
4702 } | |
4703 | |
4704 /* | |
4705 * "u" command: Undo or make lower case. | |
4706 */ | |
4707 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4708 nv_undo(cmdarg_T *cap) |
7 | 4709 { |
5735 | 4710 if (cap->oap->op_type == OP_LOWER || VIsual_active) |
7 | 4711 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4712 // translate "<Visual>u" to "<Visual>gu" and "guu" to "gugu" |
7 | 4713 cap->cmdchar = 'g'; |
4714 cap->nchar = 'u'; | |
4715 nv_operator(cap); | |
4716 } | |
4717 else | |
4718 nv_kundo(cap); | |
4719 } | |
4720 | |
4721 /* | |
4722 * <Undo> command. | |
4723 */ | |
4724 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4725 nv_kundo(cmdarg_T *cap) |
7 | 4726 { |
4727 if (!checkclearopq(cap->oap)) | |
4728 { | |
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
|
4729 #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
|
4730 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
|
4731 { |
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
|
4732 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
|
4733 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
|
4734 } |
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
|
4735 #endif |
7 | 4736 u_undo((int)cap->count1); |
4737 curwin->w_set_curswant = TRUE; | |
4738 } | |
4739 } | |
4740 | |
4741 /* | |
4742 * Handle the "r" command. | |
4743 */ | |
4744 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4745 nv_replace(cmdarg_T *cap) |
7 | 4746 { |
4747 char_u *ptr; | |
4748 int had_ctrl_v; | |
4749 long n; | |
4750 | |
4751 if (checkclearop(cap->oap)) | |
4752 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
|
4753 #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
|
4754 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
|
4755 { |
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
|
4756 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
|
4757 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
|
4758 } |
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
|
4759 #endif |
7 | 4760 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4761 // get another character |
7 | 4762 if (cap->nchar == Ctrl_V) |
4763 { | |
4764 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
|
4765 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
|
4766 // Don't redo a multibyte character with CTRL-V. |
7 | 4767 if (cap->nchar > DEL) |
4768 had_ctrl_v = NUL; | |
4769 } | |
4770 else | |
4771 had_ctrl_v = NUL; | |
4772 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4773 // Abort if the character is a special key. |
1343 | 4774 if (IS_SPECIAL(cap->nchar)) |
4775 { | |
4776 clearopbeep(cap->oap); | |
4777 return; | |
4778 } | |
4779 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4780 // Visual mode "r" |
7 | 4781 if (VIsual_active) |
4782 { | |
1797 | 4783 if (got_int) |
4784 reset_VIsual(); | |
5428 | 4785 if (had_ctrl_v) |
4786 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4787 // 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
|
4788 // 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
|
4789 if (cap->nchar == CAR) |
2941a86f8aaa
patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents:
13088
diff
changeset
|
4790 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
|
4791 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
|
4792 cap->nchar = REPLACE_NL_NCHAR; |
5428 | 4793 } |
7 | 4794 nv_operator(cap); |
4795 return; | |
4796 } | |
4797 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4798 // Break tabs, etc. |
7 | 4799 if (virtual_active()) |
4800 { | |
4801 if (u_save_cursor() == FAIL) | |
4802 return; | |
4803 if (gchar_cursor() == NUL) | |
4804 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4805 // Add extra space and put the cursor on the first one. |
7 | 4806 coladvance_force((colnr_T)(getviscol() + cap->count1)); |
4807 curwin->w_cursor.col -= cap->count1; | |
4808 } | |
4809 else if (gchar_cursor() == TAB) | |
4810 coladvance_force(getviscol()); | |
4811 } | |
4812 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4813 // Abort if not enough characters to replace. |
7 | 4814 ptr = ml_get_cursor(); |
1343 | 4815 if (STRLEN(ptr) < (unsigned)cap->count1 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4816 || (has_mbyte && mb_charlen(ptr) < cap->count1)) |
7 | 4817 { |
4818 clearopbeep(cap->oap); | |
4819 return; | |
4820 } | |
4821 | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4822 // 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
|
4823 // '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
|
4824 // 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
|
4825 // CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC). |
7 | 4826 if (had_ctrl_v != Ctrl_V && cap->nchar == '\t' && (curbuf->b_p_et || p_sta)) |
4827 { | |
4828 stuffnumReadbuff(cap->count1); | |
4829 stuffcharReadbuff('R'); | |
4830 stuffcharReadbuff('\t'); | |
4831 stuffcharReadbuff(ESC); | |
4832 return; | |
4833 } | |
4834 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4835 // save line for undo |
7 | 4836 if (u_save_cursor() == FAIL) |
4837 return; | |
4838 | |
4839 if (had_ctrl_v != Ctrl_V && (cap->nchar == '\r' || cap->nchar == '\n')) | |
4840 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4841 // 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
|
4842 // 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
|
4843 // 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
|
4844 // 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
|
4845 // 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
|
4846 // 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
|
4847 (void)del_chars(cap->count1, FALSE); // delete the characters |
7 | 4848 stuffcharReadbuff('\r'); |
4849 stuffcharReadbuff(ESC); | |
4850 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4851 // Give 'r' to edit(), to get the redo command right. |
7 | 4852 invoke_edit(cap, TRUE, 'r', FALSE); |
4853 } | |
4854 else | |
4855 { | |
4856 prep_redo(cap->oap->regname, cap->count1, | |
4857 NUL, 'r', NUL, had_ctrl_v, cap->nchar); | |
4858 | |
4859 curbuf->b_op_start = curwin->w_cursor; | |
4860 if (has_mbyte) | |
4861 { | |
4862 int old_State = State; | |
4863 | |
4864 if (cap->ncharC1 != 0) | |
4865 AppendCharToRedobuff(cap->ncharC1); | |
4866 if (cap->ncharC2 != 0) | |
4867 AppendCharToRedobuff(cap->ncharC2); | |
4868 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4869 // 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
|
4870 // 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
|
4871 // composing characters for utf-8. |
7 | 4872 for (n = cap->count1; n > 0; --n) |
4873 { | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28714
diff
changeset
|
4874 State = MODE_REPLACE; |
3501 | 4875 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
4876 { | |
4877 int c = ins_copychar(curwin->w_cursor.lnum | |
4878 + (cap->nchar == Ctrl_Y ? -1 : 1)); | |
4879 if (c != NUL) | |
4880 ins_char(c); | |
4881 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4882 // will be decremented further down |
3501 | 4883 ++curwin->w_cursor.col; |
4884 } | |
4885 else | |
4886 ins_char(cap->nchar); | |
7 | 4887 State = old_State; |
4888 if (cap->ncharC1 != 0) | |
4889 ins_char(cap->ncharC1); | |
4890 if (cap->ncharC2 != 0) | |
4891 ins_char(cap->ncharC2); | |
4892 } | |
4893 } | |
4894 else | |
4895 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4896 // Replace the characters within one line. |
7 | 4897 for (n = cap->count1; n > 0; --n) |
4898 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
4899 // 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
|
4900 // 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
|
4901 // At the same time we let know that the line will be changed. |
3501 | 4902 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
4903 { | |
4904 int c = ins_copychar(curwin->w_cursor.lnum | |
4905 + (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
|
4906 |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4907 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); |
3501 | 4908 if (c != NUL) |
4909 ptr[curwin->w_cursor.col] = c; | |
4910 } | |
4911 else | |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4912 { |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
4913 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); |
3501 | 4914 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
|
4915 } |
7 | 4916 if (p_sm && msg_silent == 0) |
4917 showmatch(cap->nchar); | |
4918 ++curwin->w_cursor.col; | |
4919 } | |
4920 #ifdef FEAT_NETBEANS_INTG | |
2210 | 4921 if (netbeans_active()) |
7 | 4922 { |
2210 | 4923 colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1); |
7 | 4924 |
33 | 4925 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
|
4926 cap->count1); |
7 | 4927 netbeans_inserted(curbuf, curwin->w_cursor.lnum, start, |
33 | 4928 &ptr[start], (int)cap->count1); |
7 | 4929 } |
4930 #endif | |
4931 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4932 // mark the buffer as changed and prepare for displaying |
7 | 4933 changed_bytes(curwin->w_cursor.lnum, |
4934 (colnr_T)(curwin->w_cursor.col - cap->count1)); | |
4935 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4936 --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
|
4937 // 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
|
4938 // character, move two characters left |
7 | 4939 if (has_mbyte) |
4940 mb_adjust_cursor(); | |
4941 curbuf->b_op_end = curwin->w_cursor; | |
4942 curwin->w_set_curswant = TRUE; | |
4943 set_last_insert(cap->nchar); | |
4944 } | |
4945 } | |
4946 | |
4947 /* | |
4948 * 'o': Exchange start and end of Visual area. | |
4949 * 'O': same, but in block mode exchange left and right corners. | |
4950 */ | |
4951 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4952 v_swap_corners(int cmdchar) |
7 | 4953 { |
4954 pos_T old_cursor; | |
4955 colnr_T left, right; | |
4956 | |
4957 if (cmdchar == 'O' && VIsual_mode == Ctrl_V) | |
4958 { | |
4959 old_cursor = curwin->w_cursor; | |
4960 getvcols(curwin, &old_cursor, &VIsual, &left, &right); | |
4961 curwin->w_cursor.lnum = VIsual.lnum; | |
4962 coladvance(left); | |
4963 VIsual = curwin->w_cursor; | |
4964 | |
4965 curwin->w_cursor.lnum = old_cursor.lnum; | |
4966 curwin->w_curswant = right; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4967 // '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
|
4968 // right one column |
7 | 4969 if (old_cursor.lnum >= VIsual.lnum && *p_sel == 'e') |
4970 ++curwin->w_curswant; | |
4971 coladvance(curwin->w_curswant); | |
4972 if (curwin->w_cursor.col == old_cursor.col | |
4973 && (!virtual_active() | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4974 || curwin->w_cursor.coladd == old_cursor.coladd)) |
7 | 4975 { |
4976 curwin->w_cursor.lnum = VIsual.lnum; | |
4977 if (old_cursor.lnum <= VIsual.lnum && *p_sel == 'e') | |
4978 ++right; | |
4979 coladvance(right); | |
4980 VIsual = curwin->w_cursor; | |
4981 | |
4982 curwin->w_cursor.lnum = old_cursor.lnum; | |
4983 coladvance(left); | |
4984 curwin->w_curswant = left; | |
4985 } | |
4986 } | |
4987 else | |
4988 { | |
4989 old_cursor = curwin->w_cursor; | |
4990 curwin->w_cursor = VIsual; | |
4991 VIsual = old_cursor; | |
4992 curwin->w_set_curswant = TRUE; | |
4993 } | |
4994 } | |
4995 | |
4996 /* | |
4997 * "R" (cap->arg is FALSE) and "gR" (cap->arg is TRUE). | |
4998 */ | |
4999 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5000 nv_Replace(cmdarg_T *cap) |
7 | 5001 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5002 if (VIsual_active) // "R" is replace lines |
7 | 5003 { |
5004 cap->cmdchar = 'c'; | |
5005 cap->nchar = NUL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5006 VIsual_mode_orig = VIsual_mode; // remember original area for gv |
7 | 5007 VIsual_mode = 'V'; |
5008 nv_operator(cap); | |
5009 } | |
5735 | 5010 else if (!checkclearopq(cap->oap)) |
7 | 5011 { |
5012 if (!curbuf->b_p_ma) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
5013 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 5014 else |
5015 { | |
5016 if (virtual_active()) | |
5017 coladvance(getviscol()); | |
5018 invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE); | |
5019 } | |
5020 } | |
5021 } | |
5022 | |
5023 /* | |
5024 * "gr". | |
5025 */ | |
5026 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5027 nv_vreplace(cmdarg_T *cap) |
7 | 5028 { |
5029 if (VIsual_active) | |
5030 { | |
5031 cap->cmdchar = 'r'; | |
5032 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
|
5033 nv_replace(cap); // Do same as "r" in Visual mode for now |
7 | 5034 } |
5735 | 5035 else if (!checkclearopq(cap->oap)) |
7 | 5036 { |
5037 if (!curbuf->b_p_ma) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
5038 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 5039 else |
5040 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5041 if (cap->extra_char == Ctrl_V) // get another character |
23076
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
23021
diff
changeset
|
5042 cap->extra_char = get_literal(FALSE); |
7 | 5043 stuffcharReadbuff(cap->extra_char); |
5044 stuffcharReadbuff(ESC); | |
5045 if (virtual_active()) | |
5046 coladvance(getviscol()); | |
5047 invoke_edit(cap, TRUE, 'v', FALSE); | |
5048 } | |
5049 } | |
5050 } | |
5051 | |
5052 /* | |
5053 * Swap case for "~" command, when it does not work like an operator. | |
5054 */ | |
5055 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5056 n_swapchar(cmdarg_T *cap) |
7 | 5057 { |
5058 long n; | |
5059 pos_T startpos; | |
5060 int did_change = 0; | |
5061 #ifdef FEAT_NETBEANS_INTG | |
5062 pos_T pos; | |
5063 char_u *ptr; | |
5064 int count; | |
5065 #endif | |
5066 | |
5067 if (checkclearopq(cap->oap)) | |
5068 return; | |
5069 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5070 if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) |
7 | 5071 { |
5072 clearopbeep(cap->oap); | |
5073 return; | |
5074 } | |
5075 | |
5076 prep_redo_cmd(cap); | |
5077 | |
5078 if (u_save_cursor() == FAIL) | |
5079 return; | |
5080 | |
5081 startpos = curwin->w_cursor; | |
5082 #ifdef FEAT_NETBEANS_INTG | |
5083 pos = startpos; | |
5084 #endif | |
5085 for (n = cap->count1; n > 0; --n) | |
5086 { | |
5087 did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); | |
5088 inc_cursor(); | |
5089 if (gchar_cursor() == NUL) | |
5090 { | |
5091 if (vim_strchr(p_ww, '~') != NULL | |
5092 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
5093 { | |
5094 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5095 if (netbeans_active()) |
7 | 5096 { |
5097 if (did_change) | |
5098 { | |
5099 ptr = ml_get(pos.lnum); | |
835 | 5100 count = (int)STRLEN(ptr) - pos.col; |
33 | 5101 netbeans_removed(curbuf, pos.lnum, pos.col, |
5102 (long)count); | |
29340
fba9e366ced4
patch 9.0.0013: reproducing memory access errors can be difficult
Bram Moolenaar <Bram@vim.org>
parents:
29179
diff
changeset
|
5103 // 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
|
5104 ptr = ml_get(pos.lnum); |
7 | 5105 netbeans_inserted(curbuf, pos.lnum, pos.col, |
33 | 5106 &ptr[pos.col], count); |
7 | 5107 } |
5108 pos.col = 0; | |
5109 pos.lnum++; | |
5110 } | |
5111 #endif | |
5112 ++curwin->w_cursor.lnum; | |
5113 curwin->w_cursor.col = 0; | |
5114 if (n > 1) | |
5115 { | |
5116 if (u_savesub(curwin->w_cursor.lnum) == FAIL) | |
5117 break; | |
5118 u_clearline(); | |
5119 } | |
5120 } | |
5121 else | |
5122 break; | |
5123 } | |
5124 } | |
5125 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5126 if (did_change && netbeans_active()) |
7 | 5127 { |
5128 ptr = ml_get(pos.lnum); | |
5129 count = curwin->w_cursor.col - pos.col; | |
33 | 5130 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count); |
5131 netbeans_inserted(curbuf, pos.lnum, pos.col, &ptr[pos.col], count); | |
7 | 5132 } |
5133 #endif | |
5134 | |
5135 | |
5136 check_cursor(); | |
5137 curwin->w_set_curswant = TRUE; | |
5138 if (did_change) | |
5139 { | |
5140 changed_lines(startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1, | |
5141 0L); | |
5142 curbuf->b_op_start = startpos; | |
5143 curbuf->b_op_end = curwin->w_cursor; | |
5144 if (curbuf->b_op_end.col > 0) | |
5145 --curbuf->b_op_end.col; | |
5146 } | |
5147 } | |
5148 | |
5149 /* | |
5150 * Move cursor to mark. | |
5151 */ | |
5152 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5153 nv_cursormark(cmdarg_T *cap, int flag, pos_T *pos) |
7 | 5154 { |
5155 if (check_mark(pos) == FAIL) | |
5156 clearop(cap->oap); | |
5157 else | |
5158 { | |
5159 if (cap->cmdchar == '\'' | |
5160 || cap->cmdchar == '`' | |
5161 || cap->cmdchar == '[' | |
5162 || cap->cmdchar == ']') | |
5163 setpcmark(); | |
5164 curwin->w_cursor = *pos; | |
5165 if (flag) | |
5166 beginline(BL_WHITE | BL_FIX); | |
5167 else | |
5168 check_cursor(); | |
5169 } | |
5170 cap->oap->motion_type = flag ? MLINE : MCHAR; | |
5171 if (cap->cmdchar == '`') | |
5172 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
|
5173 cap->oap->inclusive = FALSE; // ignored if not MCHAR |
7 | 5174 curwin->w_set_curswant = TRUE; |
5175 } | |
5176 | |
5177 /* | |
5178 * Handle commands that are operators in Visual mode. | |
5179 */ | |
5180 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5181 v_visop(cmdarg_T *cap) |
7 | 5182 { |
5183 static char_u trans[] = "YyDdCcxdXdAAIIrr"; | |
5184 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5185 // 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
|
5186 // the end of the line, and "C" replaces till EOL |
7 | 5187 if (isupper(cap->cmdchar)) |
5188 { | |
5189 if (VIsual_mode != Ctrl_V) | |
4213 | 5190 { |
5191 VIsual_mode_orig = VIsual_mode; | |
7 | 5192 VIsual_mode = 'V'; |
4213 | 5193 } |
7 | 5194 else if (cap->cmdchar == 'C' || cap->cmdchar == 'D') |
5195 curwin->w_curswant = MAXCOL; | |
5196 } | |
5197 cap->cmdchar = *(vim_strchr(trans, cap->cmdchar) + 1); | |
5198 nv_operator(cap); | |
5199 } | |
5200 | |
5201 /* | |
5202 * "s" and "S" commands. | |
5203 */ | |
5204 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5205 nv_subst(cmdarg_T *cap) |
7 | 5206 { |
13298
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5207 #ifdef FEAT_TERMINAL |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
23165
diff
changeset
|
5208 // 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
|
5209 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
|
5210 return; |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5211 #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
|
5212 #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
|
5213 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
|
5214 { |
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 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
|
5216 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
|
5217 } |
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
|
5218 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5219 if (VIsual_active) // "vs" and "vS" are the same as "vc" |
7 | 5220 { |
5221 if (cap->cmdchar == 'S') | |
4213 | 5222 { |
5223 VIsual_mode_orig = VIsual_mode; | |
7 | 5224 VIsual_mode = 'V'; |
4213 | 5225 } |
7 | 5226 cap->cmdchar = 'c'; |
5227 nv_operator(cap); | |
5228 } | |
5229 else | |
5230 nv_optrans(cap); | |
5231 } | |
5232 | |
5233 /* | |
5234 * Abbreviated commands. | |
5235 */ | |
5236 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5237 nv_abbrev(cmdarg_T *cap) |
7 | 5238 { |
5239 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
|
5240 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
|
5241 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5242 // in Visual mode these commands are operators |
7 | 5243 if (VIsual_active) |
5244 v_visop(cap); | |
5245 else | |
5246 nv_optrans(cap); | |
5247 } | |
5248 | |
5249 /* | |
5250 * Translate a command into another command. | |
5251 */ | |
5252 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5253 nv_optrans(cmdarg_T *cap) |
7 | 5254 { |
5255 static char_u *(ar[8]) = {(char_u *)"dl", (char_u *)"dh", | |
5256 (char_u *)"d$", (char_u *)"c$", | |
5257 (char_u *)"cl", (char_u *)"cc", | |
5258 (char_u *)"yy", (char_u *)":s\r"}; | |
5259 static char_u *str = (char_u *)"xXDCsSY&"; | |
5260 | |
5261 if (!checkclearopq(cap->oap)) | |
5262 { | |
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
|
5263 // 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
|
5264 // either, because "2." should also not use the count. |
164 | 5265 if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL) |
5266 { | |
5267 cap->oap->start = curwin->w_cursor; | |
5268 cap->oap->op_type = OP_DELETE; | |
1490 | 5269 #ifdef FEAT_EVAL |
5270 set_op_var(OP_DELETE); | |
5271 #endif | |
164 | 5272 cap->count1 = 1; |
5273 nv_dollar(cap); | |
5274 finish_op = TRUE; | |
5275 ResetRedobuff(); | |
5276 AppendCharToRedobuff('D'); | |
5277 } | |
5278 else | |
5279 { | |
5280 if (cap->count0) | |
5281 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
|
5282 stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]); |
164 | 5283 } |
7 | 5284 } |
5285 cap->opcount = 0; | |
5286 } | |
5287 | |
5288 /* | |
5289 * "'" and "`" commands. Also for "g'" and "g`". | |
5290 * cap->arg is TRUE for "'" and "g'". | |
5291 */ | |
5292 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5293 nv_gomark(cmdarg_T *cap) |
7 | 5294 { |
5295 pos_T *pos; | |
5296 int c; | |
5297 #ifdef FEAT_FOLDING | |
4017 | 5298 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
|
5299 int old_KeyTyped = KeyTyped; // getting file may reset it |
7 | 5300 #endif |
5301 | |
5302 if (cap->cmdchar == 'g') | |
5303 c = cap->extra_char; | |
5304 else | |
5305 c = cap->nchar; | |
5306 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
|
5307 if (pos == (pos_T *)-1) // jumped to other file |
7 | 5308 { |
5309 if (cap->arg) | |
5310 { | |
5311 check_cursor_lnum(); | |
5312 beginline(BL_WHITE | BL_FIX); | |
5313 } | |
5314 else | |
5315 check_cursor(); | |
5316 } | |
5317 else | |
5318 nv_cursormark(cap, cap->arg, pos); | |
5319 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5320 // May need to clear the coladd that a mark includes. |
7 | 5321 if (!virtual_active()) |
5322 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
|
5323 check_cursor_col(); |
7 | 5324 #ifdef FEAT_FOLDING |
5325 if (cap->oap->op_type == OP_NOP | |
4057 | 5326 && pos != NULL |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5327 && (pos == (pos_T *)-1 || !EQUAL_POS(old_cursor, *pos)) |
7 | 5328 && (fdo_flags & FDO_MARK) |
5329 && old_KeyTyped) | |
5330 foldOpenCursor(); | |
5331 #endif | |
5332 } | |
5333 | |
5334 /* | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5335 * Handle CTRL-O, CTRL-I, "g;", "g," and "CTRL-Tab" commands. |
7 | 5336 */ |
5337 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5338 nv_pcmark(cmdarg_T *cap) |
7 | 5339 { |
5340 pos_T *pos; | |
26532
255bc9a08e58
patch 8.2.3795: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
26516
diff
changeset
|
5341 #ifdef FEAT_FOLDING |
7 | 5342 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
|
5343 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
|
5344 #endif |
7 | 5345 |
5346 if (!checkclearopq(cap->oap)) | |
5347 { | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5348 if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5349 { |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5350 if (goto_tabpage_lastused() == FAIL) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5351 clearopbeep(cap->oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5352 return; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5353 } |
7 | 5354 if (cap->cmdchar == 'g') |
5355 pos = movechangelist((int)cap->count1); | |
5356 else | |
5357 pos = movemark((int)cap->count1); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5358 if (pos == (pos_T *)-1) // jump to other file |
7 | 5359 { |
5360 curwin->w_set_curswant = TRUE; | |
5361 check_cursor(); | |
5362 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5363 else if (pos != NULL) // can jump |
7 | 5364 nv_cursormark(cap, FALSE, pos); |
5365 else if (cap->cmdchar == 'g') | |
5366 { | |
5367 if (curbuf->b_changelistlen == 0) | |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5368 emsg(_(e_changelist_is_empty)); |
7 | 5369 else if (cap->count1 < 0) |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5370 emsg(_(e_at_start_of_changelist)); |
7 | 5371 else |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5372 emsg(_(e_at_end_of_changelist)); |
7 | 5373 } |
5374 else | |
5375 clearopbeep(cap->oap); | |
5376 # ifdef FEAT_FOLDING | |
5377 if (cap->oap->op_type == OP_NOP | |
5378 && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum) | |
5379 && (fdo_flags & FDO_MARK) | |
5380 && old_KeyTyped) | |
5381 foldOpenCursor(); | |
5382 # endif | |
5383 } | |
5384 } | |
5385 | |
5386 /* | |
5387 * Handle '"' command. | |
5388 */ | |
5389 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5390 nv_regname(cmdarg_T *cap) |
7 | 5391 { |
5392 if (checkclearop(cap->oap)) | |
5393 return; | |
5394 #ifdef FEAT_EVAL | |
5395 if (cap->nchar == '=') | |
5396 cap->nchar = get_expr_register(); | |
5397 #endif | |
5398 if (cap->nchar != NUL && valid_yank_reg(cap->nchar, FALSE)) | |
5399 { | |
5400 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
|
5401 cap->opcount = cap->count0; // remember count before '"' |
7 | 5402 #ifdef FEAT_EVAL |
5403 set_reg_var(cap->oap->regname); | |
5404 #endif | |
5405 } | |
5406 else | |
5407 clearopbeep(cap->oap); | |
5408 } | |
5409 | |
5410 /* | |
5411 * Handle "v", "V" and "CTRL-V" commands. | |
5412 * Also for "gh", "gH" and "g^H" commands: Always start Select mode, cap->arg | |
5413 * is TRUE. | |
167 | 5414 * Handle CTRL-Q just like CTRL-V. |
7 | 5415 */ |
5416 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5417 nv_visual(cmdarg_T *cap) |
7 | 5418 { |
167 | 5419 if (cap->cmdchar == Ctrl_Q) |
5420 cap->cmdchar = Ctrl_V; | |
5421 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5422 // '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
|
5423 // characterwise, linewise, or blockwise. |
7 | 5424 if (cap->oap->op_type != OP_NOP) |
5425 { | |
15279
54457fc4af0b
patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
5426 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
|
5427 finish_op = FALSE; // operator doesn't finish now but later |
7 | 5428 return; |
5429 } | |
5430 | |
5431 VIsual_select = cap->arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5432 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
|
5433 { |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5434 if (VIsual_mode == cap->cmdchar) // stop visual mode |
7 | 5435 end_visual_mode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5436 else // toggle char/block mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5437 { // or char/line mode |
7 | 5438 VIsual_mode = cap->cmdchar; |
5439 showmode(); | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
5440 may_trigger_modechanged(); |
7 | 5441 } |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5442 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
|
5443 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5444 else // start Visual mode |
7 | 5445 { |
5446 check_visual_highlight(); | |
3537 | 5447 if (cap->count0 > 0 && resel_VIsual_mode != NUL) |
5448 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5449 // use previously selected part |
7 | 5450 VIsual = curwin->w_cursor; |
5451 | |
5452 VIsual_active = TRUE; | |
5453 VIsual_reselect = TRUE; | |
5454 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5455 // start Select mode when 'selectmode' contains "cmd" |
7 | 5456 may_start_select('c'); |
5457 setmouse(); | |
641 | 5458 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
|
5459 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
|
5460 // 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
|
5461 // was only one -- webb |
7 | 5462 if (resel_VIsual_mode != 'v' || resel_VIsual_line_count > 1) |
5463 { | |
5464 curwin->w_cursor.lnum += | |
5465 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
|
5466 check_cursor(); |
7 | 5467 } |
5468 VIsual_mode = resel_VIsual_mode; | |
5469 if (VIsual_mode == 'v') | |
5470 { | |
5471 if (resel_VIsual_line_count <= 1) | |
3125 | 5472 { |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5473 update_curswant_force(); |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5474 curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1; |
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 { | |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5487 update_curswant_force(); |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5488 curwin->w_curswant += + resel_VIsual_vcol * cap->count0 - 1; |
7 | 5489 coladvance(curwin->w_curswant); |
5490 } | |
5491 else | |
5492 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
|
5493 redraw_curbuf_later(UPD_INVERTED); // show the inversion |
7 | 5494 } |
5495 else | |
5496 { | |
5497 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5498 // start Select mode when 'selectmode' contains "cmd" |
7 | 5499 may_start_select('c'); |
5500 n_start_visual_mode(cap->cmdchar); | |
3537 | 5501 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
|
5502 ++cap->count1; // include one more char |
3537 | 5503 if (cap->count0 > 0 && --cap->count1 > 0) |
5504 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5505 // With a count select that many characters or lines. |
3537 | 5506 if (VIsual_mode == 'v' || VIsual_mode == Ctrl_V) |
5507 nv_right(cap); | |
5508 else if (VIsual_mode == 'V') | |
5509 nv_down(cap); | |
5510 } | |
7 | 5511 } |
5512 } | |
5513 } | |
5514 | |
5515 /* | |
5516 * Start selection for Shift-movement keys. | |
5517 */ | |
5518 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5519 start_selection(void) |
7 | 5520 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5521 // if 'selectmode' contains "key", start Select mode |
7 | 5522 may_start_select('k'); |
5523 n_start_visual_mode('v'); | |
5524 } | |
5525 | |
5526 /* | |
5527 * 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
|
5528 * When "c" is 'o' (checking for "mouse") then also when mapped. |
7 | 5529 */ |
5530 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5531 may_start_select(int c) |
7 | 5532 { |
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 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
|
5534 && vim_strchr(p_slm, c) != NULL; |
7 | 5535 } |
5536 | |
5537 /* | |
5538 * Start Visual mode "c". | |
5539 * Should set VIsual_select before calling this. | |
5540 */ | |
5541 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5542 n_start_visual_mode(int c) |
7 | 5543 { |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5544 #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
|
5545 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
|
5546 && 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
|
5547 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5548 |
7 | 5549 VIsual_mode = c; |
5550 VIsual_active = TRUE; | |
5551 VIsual_reselect = TRUE; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5552 |
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5553 // 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
|
5554 // 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
|
5555 if (c == Ctrl_V && (get_ve_flags() & VE_BLOCK) && gchar_cursor() == TAB) |
3742 | 5556 { |
5557 validate_virtcol(); | |
7 | 5558 coladvance(curwin->w_virtcol); |
3742 | 5559 } |
7 | 5560 VIsual = curwin->w_cursor; |
5561 | |
5562 #ifdef FEAT_FOLDING | |
5563 foldAdjustVisual(); | |
5564 #endif | |
5565 | |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28224
diff
changeset
|
5566 may_trigger_modechanged(); |
7 | 5567 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
|
5568 #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
|
5569 // 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
|
5570 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
|
5571 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5572 |
641 | 5573 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
|
5574 redraw_cmdline = TRUE; // show visual mode later |
7 | 5575 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5576 // 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
|
5577 // end may still be the same, and the selection needs to be owned |
7 | 5578 clip_star.vmode = NUL; |
5579 #endif | |
5580 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5581 // 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
|
5582 // 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
|
5583 if (curwin->w_redr_type < UPD_INVERTED) |
7 | 5584 { |
5585 curwin->w_old_cursor_lnum = curwin->w_cursor.lnum; | |
5586 curwin->w_old_visual_lnum = curwin->w_cursor.lnum; | |
5587 } | |
5588 } | |
5589 | |
5590 | |
5591 /* | |
5592 * CTRL-W: Window commands | |
5593 */ | |
5594 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5595 nv_window(cmdarg_T *cap) |
7 | 5596 { |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5597 if (cap->nchar == ':') |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5598 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5599 // "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
|
5600 cap->cmdchar = ':'; |
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5601 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
|
5602 nv_colon(cap); |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5603 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5604 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
|
5605 do_window(cap->nchar, cap->count0, NUL); // everything is in window.c |
7 | 5606 } |
5607 | |
5608 /* | |
5609 * CTRL-Z: Suspend | |
5610 */ | |
5611 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5612 nv_suspend(cmdarg_T *cap) |
7 | 5613 { |
5614 clearop(cap->oap); | |
5615 if (VIsual_active) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5616 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
|
5617 do_cmdline_cmd((char_u *)"stop"); |
7 | 5618 } |
5619 | |
5620 /* | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5621 * "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
|
5622 * 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
|
5623 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5624 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5625 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
|
5626 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5627 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
|
5628 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5629 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5630 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
|
5631 return; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5632 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5633 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
|
5634 || 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
|
5635 || 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
|
5636 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5637 beep_flush(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5638 return; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5639 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5640 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5641 // 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
|
5642 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
|
5643 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5644 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
|
5645 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
|
5646 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
|
5647 # 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
|
5648 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
|
5649 # endif |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5650 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
|
5651 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
|
5652 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
|
5653 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5654 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
|
5655 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
|
5656 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
|
5657 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
|
5658 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5659 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5660 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5661 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
|
5662 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
|
5663 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
|
5664 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
|
5665 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5666 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5667 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
|
5668 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
|
5669 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5670 // 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
|
5671 // 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
|
5672 check_cursor(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5673 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
|
5674 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
|
5675 check_cursor(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5676 update_topline(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5677 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5678 // 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
|
5679 // '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
|
5680 // 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
|
5681 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
|
5682 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5683 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
|
5684 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
|
5685 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5686 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5687 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
|
5688 setmouse(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5689 #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
|
5690 // 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
|
5691 // 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
|
5692 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
|
5693 #endif |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
5694 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
|
5695 showmode(); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5696 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5697 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5698 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5699 * "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
|
5700 * "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
|
5701 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5702 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5703 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
|
5704 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5705 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5706 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
|
5707 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5708 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
|
5709 flag = TRUE; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5710 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5711 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
|
5712 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
|
5713 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
|
5714 { |
30293
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5715 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
|
5716 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
|
5717 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
|
5718 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5719 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
|
5720 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
|
5721 #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
|
5722 - 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
|
5723 #endif |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5724 ; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5725 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
|
5726 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
|
5727 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
|
5728 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5729 else |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5730 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
|
5731 // 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
|
5732 // '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
|
5733 // 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
|
5734 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
|
5735 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
|
5736 + ((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
|
5737 ? 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
|
5738 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
|
5739 if (flag) |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5740 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5741 do |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5742 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
|
5743 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
|
5744 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
|
5745 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5746 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
|
5747 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5748 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5749 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5750 * "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
|
5751 * downward. |
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 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5754 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
|
5755 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5756 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
|
5757 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5758 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
|
5759 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
|
5760 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
|
5761 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
|
5762 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
|
5763 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5764 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
|
5765 return; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5766 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5767 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5768 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
|
5769 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5770 // 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
|
5771 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
|
5772 --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
|
5773 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5774 // 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
|
5775 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
|
5776 && 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
|
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 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
|
5779 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
|
5780 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5781 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5782 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5783 * "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
|
5784 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5785 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5786 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
|
5787 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5788 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
|
5789 int i; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5790 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
|
5791 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5792 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
|
5793 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
|
5794 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
|
5795 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5796 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
|
5797 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
|
5798 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5799 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
|
5800 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
|
5801 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
|
5802 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5803 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
|
5804 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
|
5805 #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
|
5806 - 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
|
5807 #endif |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5808 ; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5809 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
|
5810 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
|
5811 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
|
5812 * width2; |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5813 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
|
5814 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5815 // 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
|
5816 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
|
5817 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
|
5818 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5819 // 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
|
5820 // 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
|
5821 // 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
|
5822 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
|
5823 #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
|
5824 - 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
|
5825 #endif |
914b3c64ab92
patch 9.0.0482: "g0" moves to wrong location with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents:
30102
diff
changeset
|
5826 > (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
|
5827 --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
|
5828 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5829 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5830 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
|
5831 clearopbeep(oap); |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5832 } |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5833 else |
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 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
|
5836 // 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
|
5837 (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
|
5838 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5839 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
|
5840 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
|
5841 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5842 // 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
|
5843 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
|
5844 && (*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
|
5845 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5846 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
|
5847 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5848 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
|
5849 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
|
5850 --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
|
5851 } |
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 // 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
|
5854 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
|
5855 } |
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 /* |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5859 * "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
|
5860 */ |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5861 static void |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5862 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
|
5863 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5864 int i; |
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 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
|
5867 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5868 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
|
5869 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
|
5870 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
|
5871 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
|
5872 { |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5873 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
|
5874 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
|
5875 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
|
5876 } |
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 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
|
5879 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
|
5880 } |
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 /* |
7 | 5883 * Commands starting with "g". |
5884 */ | |
5885 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5886 nv_g_cmd(cmdarg_T *cap) |
7 | 5887 { |
5888 oparg_T *oap = cap->oap; | |
5889 int i; | |
5890 | |
5891 switch (cap->nchar) | |
5892 { | |
6868 | 5893 case Ctrl_A: |
5894 case Ctrl_X: | |
7 | 5895 #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
|
5896 // "g^A": dump log of used memory. |
6868 | 5897 if (!VIsual_active && cap->nchar == Ctrl_A) |
5898 vim_mem_profile_dump(); | |
5899 else | |
5900 #endif | |
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/g^X": sequentially increment visually selected region |
6868 | 5902 if (VIsual_active) |
5903 { | |
5904 cap->arg = TRUE; | |
5905 cap->cmdchar = cap->nchar; | |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
5906 cap->nchar = NUL; |
6868 | 5907 nv_addsub(cap); |
5908 } | |
5909 else | |
5910 clearopbeep(oap); | |
7 | 5911 break; |
5912 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5913 // "gR": Enter virtual replace mode. |
7 | 5914 case 'R': |
5915 cap->arg = TRUE; | |
5916 nv_Replace(cap); | |
5917 break; | |
5918 | |
5919 case 'r': | |
5920 nv_vreplace(cap); | |
5921 break; | |
5922 | |
5923 case '&': | |
5924 do_cmdline_cmd((char_u *)"%s//~/&"); | |
5925 break; | |
5926 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5927 // "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
|
5928 // exchange previous and current Visual area. |
7 | 5929 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
|
5930 nv_gv_cmd(cap); |
7 | 5931 break; |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5932 |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5933 // "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
|
5934 // mapping of menu. |
7 | 5935 case 'V': |
5936 VIsual_reselect = FALSE; | |
5937 break; | |
5938 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5939 // "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
|
5940 // "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
|
5941 // "g^H": start Select block mode. |
7 | 5942 case K_BS: |
5943 cap->nchar = Ctrl_H; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5944 // FALLTHROUGH |
7 | 5945 case 'h': |
5946 case 'H': | |
5947 case Ctrl_H: | |
5948 cap->cmdchar = cap->nchar + ('v' - 'h'); | |
5949 cap->arg = TRUE; | |
5950 nv_visual(cap); | |
5951 break; | |
3701 | 5952 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5953 // "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
|
5954 // "gn" selects next match |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5955 // "gN" selects previous match |
3701 | 5956 case 'N': |
5957 case 'n': | |
5958 if (!current_search(cap->count1, cap->nchar == 'n')) | |
3896 | 5959 clearopbeep(oap); |
3701 | 5960 break; |
7 | 5961 |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5962 // "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
|
5963 // movement based on *screen* line rather than *file* line. |
7 | 5964 case 'j': |
5965 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
|
5966 // 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
|
5967 if (!curwin->w_p_wrap) |
7 | 5968 { |
5969 oap->motion_type = MLINE; | |
5970 i = cursor_down(cap->count1, oap->op_type == OP_NOP); | |
5971 } | |
5972 else | |
5973 i = nv_screengo(oap, FORWARD, cap->count1); | |
5974 if (i == FAIL) | |
5975 clearopbeep(oap); | |
5976 break; | |
5977 | |
5978 case 'k': | |
5979 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
|
5980 // 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
|
5981 if (!curwin->w_p_wrap) |
7 | 5982 { |
5983 oap->motion_type = MLINE; | |
5984 i = cursor_up(cap->count1, oap->op_type == OP_NOP); | |
5985 } | |
5986 else | |
5987 i = nv_screengo(oap, BACKWARD, cap->count1); | |
5988 if (i == FAIL) | |
5989 clearopbeep(oap); | |
5990 break; | |
5991 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
5992 // "gJ": join two lines without inserting a space. |
7 | 5993 case 'J': |
5994 nv_join(cap); | |
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 // "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
|
5998 // "gm": middle of "g0" and "g$". |
7 | 5999 case '^': |
6000 case '0': | |
6001 case 'm': | |
6002 case K_HOME: | |
6003 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
|
6004 nv_g_home_m_cmd(cap); |
7 | 6005 break; |
6006 | |
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
|
6007 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
|
6008 { |
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
|
6009 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
|
6010 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
|
6011 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
|
6012 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
|
6013 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
|
6014 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
|
6015 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
|
6016 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
|
6017 } |
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 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
|
6019 |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6020 // "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
|
6021 // downward. |
7 | 6022 case '_': |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6023 nv_g_underscore_cmd(cap); |
7 | 6024 break; |
6025 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6026 // "g$" : Like "$" but for screen lines. |
7 | 6027 case '$': |
6028 case K_END: | |
6029 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
|
6030 nv_g_dollar_cmd(cap); |
7 | 6031 break; |
6032 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6033 // "g*" and "g#", like "*" and "#" but without using "\<" and "\>" |
7 | 6034 case '*': |
6035 case '#': | |
6036 #if POUND != '#' | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6037 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
|
6038 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6039 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
|
6040 case ']': // :tselect for current identifier |
7 | 6041 nv_ident(cap); |
6042 break; | |
6043 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6044 // ge and gE: go back to end of word |
7 | 6045 case 'e': |
6046 case 'E': | |
6047 oap->motion_type = MCHAR; | |
6048 curwin->w_set_curswant = TRUE; | |
6049 oap->inclusive = TRUE; | |
6050 if (bckend_word(cap->count1, cap->nchar == 'E', FALSE) == FAIL) | |
6051 clearopbeep(oap); | |
6052 break; | |
6053 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6054 // "g CTRL-G": display info about cursor position |
7 | 6055 case Ctrl_G: |
7480
a49163681559
commit https://github.com/vim/vim/commit/ed767a2073ef150971b0439a58e7ee582af6984e
Christian Brabandt <cb@256bit.org>
parents:
7311
diff
changeset
|
6056 cursor_pos_info(NULL); |
7 | 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 // "gi": start Insert at the last position. |
7 | 6060 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
|
6061 nv_gi_cmd(cap); |
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 in column 1. |
7 | 6065 case 'I': |
6066 beginline(0); | |
6067 if (!checkclearopq(oap)) | |
6068 invoke_edit(cap, FALSE, 'g', FALSE); | |
6069 break; | |
6070 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6071 // "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
|
6072 // "]f" and "[f": can also be used. |
7 | 6073 case 'f': |
681 | 6074 case 'F': |
7 | 6075 nv_gotofile(cap); |
6076 break; | |
6077 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6078 // "g'm" and "g`m": jump to mark without setting pcmark |
7 | 6079 case '\'': |
6080 cap->arg = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6081 // FALLTHROUGH |
7 | 6082 case '`': |
6083 nv_gomark(cap); | |
6084 break; | |
6085 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6086 // "gs": Goto sleep. |
7 | 6087 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
|
6088 do_sleep(cap->count1 * 1000L, FALSE); |
7 | 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 // "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
|
6092 // cursor. It is displayed in decimal, hex, and octal. -- webb |
7 | 6093 case 'a': |
6094 do_ascii(NULL); | |
6095 break; | |
6096 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6097 // "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
|
6098 // 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
|
6099 // "8g8" finds illegal byte sequence. |
7 | 6100 case '8': |
775 | 6101 if (cap->count0 == 8) |
6102 utf_find_illegal(); | |
6103 else | |
6104 show_utf8(); | |
7 | 6105 break; |
6106 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6107 // "g<": show scrollback text |
447 | 6108 case '<': |
6109 show_sb_text(); | |
6110 break; | |
6111 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6112 // "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
|
6113 // that line number like for "G". -- webb |
7 | 6114 case 'g': |
6115 cap->arg = FALSE; | |
6116 nv_goto(cap); | |
6117 break; | |
6118 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6119 // 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
|
6120 // "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
|
6121 // "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
|
6122 // "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
|
6123 // "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
|
6124 // "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
|
6125 // "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
|
6126 // "g@" call 'operatorfunc' |
7 | 6127 case 'q': |
6128 case 'w': | |
6129 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
|
6130 // FALLTHROUGH |
7 | 6131 case '~': |
6132 case 'u': | |
6133 case 'U': | |
6134 case '?': | |
602 | 6135 case '@': |
7 | 6136 nv_operator(cap); |
6137 break; | |
6138 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6139 // "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
|
6140 // current function |
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6141 // "gD": idem, but in the current file. |
7 | 6142 case 'd': |
6143 case 'D': | |
523 | 6144 nv_gd(oap, cap->nchar, (int)cap->count0); |
7 | 6145 break; |
6146 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6147 // g<*Mouse> : <C-*mouse> |
7 | 6148 case K_MIDDLEMOUSE: |
6149 case K_MIDDLEDRAG: | |
6150 case K_MIDDLERELEASE: | |
6151 case K_LEFTMOUSE: | |
6152 case K_LEFTDRAG: | |
6153 case K_LEFTRELEASE: | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
6154 case K_MOUSEMOVE: |
7 | 6155 case K_RIGHTMOUSE: |
6156 case K_RIGHTDRAG: | |
6157 case K_RIGHTRELEASE: | |
6158 case K_X1MOUSE: | |
6159 case K_X1DRAG: | |
6160 case K_X1RELEASE: | |
6161 case K_X2MOUSE: | |
6162 case K_X2DRAG: | |
6163 case K_X2RELEASE: | |
6164 mod_mask = MOD_MASK_CTRL; | |
6165 (void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); | |
6166 break; | |
6167 | |
6168 case K_IGNORE: | |
6169 break; | |
6170 | |
27273
a9f0c1f06c84
patch 8.2.4165: the nv_g_cmd() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
27263
diff
changeset
|
6171 // "gP" and "gp": same as "P" and "p" but leave cursor just after new text |
7 | 6172 case 'p': |
6173 case 'P': | |
6174 nv_put(cap); | |
6175 break; | |
6176 | |
6177 #ifdef FEAT_BYTEOFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6178 // "go": goto byte count from start of buffer |
7 | 6179 case 'o': |
6180 goto_byte(cap->count0); | |
6181 break; | |
6182 #endif | |
6183 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6184 // "gQ": improved Ex mode |
7 | 6185 case 'Q': |
29002
48d74a5822eb
patch 8.2.5023: substitute overwrites allocated buffer
Bram Moolenaar <Bram@vim.org>
parents:
28867
diff
changeset
|
6186 if (!check_text_locked(cap->oap) && !checkclearopq(oap)) |
7 | 6187 do_exmode(TRUE); |
6188 break; | |
6189 | |
6190 case ',': | |
6191 nv_pcmark(cap); | |
6192 break; | |
6193 | |
6194 case ';': | |
6195 cap->count1 = -cap->count1; | |
6196 nv_pcmark(cap); | |
6197 break; | |
6198 | |
667 | 6199 case 't': |
3630 | 6200 if (!checkclearop(oap)) |
6201 goto_tabpage((int)cap->count0); | |
667 | 6202 break; |
682 | 6203 case 'T': |
3630 | 6204 if (!checkclearop(oap)) |
6205 goto_tabpage(-(int)cap->count1); | |
682 | 6206 break; |
667 | 6207 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6208 case TAB: |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6209 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
|
6210 clearopbeep(oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6211 break; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6212 |
750 | 6213 case '+': |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6214 case '-': // "g+" and "g-": undo or redo along the timeline |
750 | 6215 if (!checkclearopq(oap)) |
771 | 6216 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
|
6217 FALSE, FALSE, FALSE); |
750 | 6218 break; |
6219 | |
7 | 6220 default: |
6221 clearopbeep(oap); | |
6222 break; | |
6223 } | |
6224 } | |
6225 | |
6226 /* | |
6227 * Handle "o" and "O" commands. | |
6228 */ | |
6229 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6230 n_opencmd(cmdarg_T *cap) |
7 | 6231 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6232 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6233 linenr_T oldline = curwin->w_cursor.lnum; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6234 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6235 |
7 | 6236 if (!checkclearopq(cap->oap)) |
6237 { | |
6238 #ifdef FEAT_FOLDING | |
6239 if (cap->cmdchar == 'O') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6240 // Open above the first line of a folded sequence of lines |
7 | 6241 (void)hasFolding(curwin->w_cursor.lnum, |
6242 &curwin->w_cursor.lnum, NULL); | |
6243 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6244 // Open below the last line of a folded sequence of lines |
7 | 6245 (void)hasFolding(curwin->w_cursor.lnum, |
6246 NULL, &curwin->w_cursor.lnum); | |
6247 #endif | |
6248 if (u_save((linenr_T)(curwin->w_cursor.lnum - | |
6249 (cap->cmdchar == 'O' ? 1 : 0)), | |
6250 (linenr_T)(curwin->w_cursor.lnum + | |
6251 (cap->cmdchar == 'o' ? 1 : 0)) | |
6252 ) == OK | |
6253 && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, | |
18203
e0ec4cd7a865
patch 8.1.2096: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
18154
diff
changeset
|
6254 has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, |
26516
9596c652420b
patch 8.2.3787: no proper formatting of a C line comment after a statement
Bram Moolenaar <Bram@vim.org>
parents:
26468
diff
changeset
|
6255 0, NULL) == OK) |
7 | 6256 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6257 #ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
6258 if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15422
diff
changeset
|
6259 redrawWinline(curwin, oldline); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6260 #endif |
6834 | 6261 #ifdef FEAT_SYN_HL |
6821 | 6262 if (curwin->w_p_cul) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6263 // force redraw of cursorline |
6821 | 6264 curwin->w_valid &= ~VALID_CROW; |
6834 | 6265 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6266 // When '#' is in 'cpoptions' ignore the count. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
6267 if (vim_strchr(p_cpo, CPO_HASH) != NULL) |
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
6268 cap->count1 = 1; |
7 | 6269 invoke_edit(cap, FALSE, cap->cmdchar, TRUE); |
6270 } | |
6271 } | |
6272 } | |
6273 | |
6274 /* | |
6275 * "." command: redo last change. | |
6276 */ | |
6277 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6278 nv_dot(cmdarg_T *cap) |
7 | 6279 { |
6280 if (!checkclearopq(cap->oap)) | |
6281 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6282 // If "restart_edit" is TRUE, the last but one command is repeated |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6283 // instead of the last command (inserting text). This is used for |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6284 // CTRL-O <.> in insert mode. |
7 | 6285 if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) |
6286 clearopbeep(cap->oap); | |
6287 } | |
6288 } | |
6289 | |
6290 /* | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6291 * CTRL-R: undo undo or specify register in select mode |
7 | 6292 */ |
6293 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
|
6294 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
|
6295 { |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6296 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
|
6297 { |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6298 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
|
6299 // 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
|
6300 ++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
|
6301 ++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
|
6302 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
|
6303 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
|
6304 --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
|
6305 --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
|
6306 |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6307 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
|
6308 // 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
|
6309 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
|
6310 |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
6311 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
|
6312 return; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6313 } |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6314 |
7 | 6315 if (!checkclearopq(cap->oap)) |
6316 { | |
6317 u_redo((int)cap->count1); | |
6318 curwin->w_set_curswant = TRUE; | |
6319 } | |
6320 } | |
6321 | |
6322 /* | |
6323 * Handle "U" command. | |
6324 */ | |
6325 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6326 nv_Undo(cmdarg_T *cap) |
7 | 6327 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6328 // In Visual mode and typing "gUU" triggers an operator |
5735 | 6329 if (cap->oap->op_type == OP_UPPER || VIsual_active) |
7 | 6330 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6331 // translate "gUU" to "gUgU" |
7 | 6332 cap->cmdchar = 'g'; |
6333 cap->nchar = 'U'; | |
6334 nv_operator(cap); | |
6335 } | |
6336 else if (!checkclearopq(cap->oap)) | |
6337 { | |
6338 u_undoline(); | |
6339 curwin->w_set_curswant = TRUE; | |
6340 } | |
6341 } | |
6342 | |
6343 /* | |
6344 * '~' command: If tilde is not an operator and Visual is off: swap case of a | |
6345 * single character. | |
6346 */ | |
6347 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6348 nv_tilde(cmdarg_T *cap) |
7 | 6349 { |
5735 | 6350 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
|
6351 { |
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
|
6352 #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
|
6353 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
|
6354 { |
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
|
6355 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
|
6356 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
|
6357 } |
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 #endif |
7 | 6359 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
|
6360 } |
7 | 6361 else |
6362 nv_operator(cap); | |
6363 } | |
6364 | |
6365 /* | |
6366 * Handle an operator command. | |
6367 * The actual work is done by do_pending_operator(). | |
6368 */ | |
6369 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6370 nv_operator(cmdarg_T *cap) |
7 | 6371 { |
6372 int op_type; | |
6373 | |
6374 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
|
6375 #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
|
6376 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
|
6377 { |
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
|
6378 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
|
6379 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
|
6380 } |
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
|
6381 #endif |
7 | 6382 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6383 if (op_type == cap->oap->op_type) // double operator works on lines |
7 | 6384 nv_lineop(cap); |
6385 else if (!checkclearop(cap->oap)) | |
6386 { | |
6387 cap->oap->start = curwin->w_cursor; | |
6388 cap->oap->op_type = op_type; | |
1490 | 6389 #ifdef FEAT_EVAL |
6390 set_op_var(op_type); | |
6391 #endif | |
6392 } | |
6393 } | |
6394 | |
6395 #ifdef FEAT_EVAL | |
6396 /* | |
6397 * Set v:operator to the characters for "optype". | |
6398 */ | |
6399 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6400 set_op_var(int optype) |
1490 | 6401 { |
6402 char_u opchars[3]; | |
6403 | |
6404 if (optype == OP_NOP) | |
6405 set_vim_var_string(VV_OP, NULL, 0); | |
6406 else | |
6407 { | |
6408 opchars[0] = get_op_char(optype); | |
6409 opchars[1] = get_extra_op_char(optype); | |
6410 opchars[2] = NUL; | |
6411 set_vim_var_string(VV_OP, opchars, -1); | |
6412 } | |
6413 } | |
6414 #endif | |
7 | 6415 |
6416 /* | |
6417 * Handle linewise operator "dd", "yy", etc. | |
6418 * | |
6419 * "_" is is a strange motion command that helps make operators more logical. | |
6420 * It is actually implemented, but not documented in the real Vi. This motion | |
6421 * command actually refers to "the current line". Commands like "dd" and "yy" | |
6422 * are really an alternate form of "d_" and "y_". It does accept a count, so | |
6423 * "d3_" works to delete 3 lines. | |
6424 */ | |
6425 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6426 nv_lineop(cmdarg_T *cap) |
7 | 6427 { |
6428 cap->oap->motion_type = MLINE; | |
6429 if (cursor_down(cap->count1 - 1L, cap->oap->op_type == OP_NOP) == FAIL) | |
6430 clearopbeep(cap->oap); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6431 else if ( (cap->oap->op_type == OP_DELETE // only with linewise motions |
4011 | 6432 && cap->oap->motion_force != 'v' |
6433 && cap->oap->motion_force != Ctrl_V) | |
7 | 6434 || cap->oap->op_type == OP_LSHIFT |
6435 || cap->oap->op_type == OP_RSHIFT) | |
6436 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
|
6437 else if (cap->oap->op_type != OP_YANK) // 'Y' does not move cursor |
7 | 6438 beginline(BL_WHITE | BL_FIX); |
6439 } | |
6440 | |
6441 /* | |
6442 * <Home> command. | |
6443 */ | |
6444 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6445 nv_home(cmdarg_T *cap) |
7 | 6446 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6447 // CTRL-HOME is like "gg" |
180 | 6448 if (mod_mask & MOD_MASK_CTRL) |
6449 nv_goto(cap); | |
6450 else | |
6451 { | |
6452 cap->count0 = 1; | |
6453 nv_pipe(cap); | |
6454 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6455 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
|
6456 // one-character line). |
7 | 6457 } |
6458 | |
6459 /* | |
6460 * "|" command. | |
6461 */ | |
6462 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6463 nv_pipe(cmdarg_T *cap) |
7 | 6464 { |
6465 cap->oap->motion_type = MCHAR; | |
6466 cap->oap->inclusive = FALSE; | |
6467 beginline(0); | |
6468 if (cap->count0 > 0) | |
6469 { | |
6470 coladvance((colnr_T)(cap->count0 - 1)); | |
6471 curwin->w_curswant = (colnr_T)(cap->count0 - 1); | |
6472 } | |
6473 else | |
6474 curwin->w_curswant = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6475 // 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
|
6476 // we ended; differs if line is too short |
7 | 6477 curwin->w_set_curswant = FALSE; |
6478 } | |
6479 | |
6480 /* | |
6481 * Handle back-word command "b" and "B". | |
6482 * cap->arg is 1 for "B" | |
6483 */ | |
6484 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6485 nv_bck_word(cmdarg_T *cap) |
7 | 6486 { |
6487 cap->oap->motion_type = MCHAR; | |
6488 cap->oap->inclusive = FALSE; | |
6489 curwin->w_set_curswant = TRUE; | |
6490 if (bck_word(cap->count1, cap->arg, FALSE) == FAIL) | |
6491 clearopbeep(cap->oap); | |
6492 #ifdef FEAT_FOLDING | |
6493 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6494 foldOpenCursor(); | |
6495 #endif | |
6496 } | |
6497 | |
6498 /* | |
6499 * Handle word motion commands "e", "E", "w" and "W". | |
6500 * cap->arg is TRUE for "E" and "W". | |
6501 */ | |
6502 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6503 nv_wordcmd(cmdarg_T *cap) |
7 | 6504 { |
6505 int n; | |
6506 int word_end; | |
6507 int flag = FALSE; | |
1573 | 6508 pos_T startpos = curwin->w_cursor; |
7 | 6509 |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6510 // Set inclusive for the "E" and "e" command. |
7 | 6511 if (cap->cmdchar == 'e' || cap->cmdchar == 'E') |
6512 word_end = TRUE; | |
6513 else | |
6514 word_end = FALSE; | |
6515 cap->oap->inclusive = word_end; | |
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 // "cw" and "cW" are a special case. |
7 | 6518 if (!word_end && cap->oap->op_type == OP_CHANGE) |
6519 { | |
6520 n = gchar_cursor(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6521 if (n != NUL) // not an empty line |
7 | 6522 { |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6523 if (VIM_ISWHITE(n)) |
7 | 6524 { |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6525 // 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
|
6526 // 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
|
6527 // 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
|
6528 // in 'cpoptions'. |
7 | 6529 if (cap->count1 == 1 && vim_strchr(p_cpo, CPO_CW) != NULL) |
6530 { | |
6531 cap->oap->inclusive = TRUE; | |
6532 cap->oap->motion_type = MCHAR; | |
6533 return; | |
6534 } | |
6535 } | |
6536 else | |
6537 { | |
27386
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6538 // 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
|
6539 // 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
|
6540 // 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
|
6541 // 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
|
6542 // 'cw'. |
ccfb16d876b1
patch 8.2.4221: some functions in normal.c are very long
Bram Moolenaar <Bram@vim.org>
parents:
27354
diff
changeset
|
6543 // 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
|
6544 // "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
|
6545 // 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
|
6546 // flag. |
7 | 6547 cap->oap->inclusive = TRUE; |
6548 word_end = TRUE; | |
6549 flag = TRUE; | |
6550 } | |
6551 } | |
6552 } | |
6553 | |
6554 cap->oap->motion_type = MCHAR; | |
6555 curwin->w_set_curswant = TRUE; | |
6556 if (word_end) | |
6557 n = end_word(cap->count1, cap->arg, flag, FALSE); | |
6558 else | |
6559 n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP); | |
6560 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6561 // 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
|
6562 // 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
|
6563 if (LT_POS(startpos, curwin->w_cursor)) |
1505 | 6564 adjust_cursor(cap->oap); |
7 | 6565 |
6566 if (n == FAIL && cap->oap->op_type == OP_NOP) | |
6567 clearopbeep(cap->oap); | |
6568 else | |
6569 { | |
6570 adjust_for_sel(cap); | |
6571 #ifdef FEAT_FOLDING | |
6572 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6573 foldOpenCursor(); | |
6574 #endif | |
6575 } | |
6576 } | |
6577 | |
6578 /* | |
1505 | 6579 * Used after a movement command: If the cursor ends up on the NUL after the |
6580 * end of the line, may move it back to the last character and make the motion | |
6581 * inclusive. | |
6582 */ | |
6583 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6584 adjust_cursor(oparg_T *oap) |
1505 | 6585 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6586 // 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
|
6587 // - the column is > 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6588 // - 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
|
6589 // - 'virtualedit' is not "all" and not "onemore". |
1505 | 6590 if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL |
6591 && (!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
|
6592 && !virtual_active() && (get_ve_flags() & VE_ONEMORE) == 0) |
1505 | 6593 { |
6594 --curwin->w_cursor.col; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6595 // prevent cursor from moving on the trail byte |
1505 | 6596 if (has_mbyte) |
6597 mb_adjust_cursor(); | |
6598 oap->inclusive = TRUE; | |
6599 } | |
6600 } | |
6601 | |
6602 /* | |
7 | 6603 * "0" and "^" commands. |
6604 * cap->arg is the argument for beginline(). | |
6605 */ | |
6606 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6607 nv_beginline(cmdarg_T *cap) |
7 | 6608 { |
6609 cap->oap->motion_type = MCHAR; | |
6610 cap->oap->inclusive = FALSE; | |
6611 beginline(cap->arg); | |
6612 #ifdef FEAT_FOLDING | |
6613 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6614 foldOpenCursor(); | |
6615 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6616 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
|
6617 // one-character line). |
7 | 6618 } |
6619 | |
6620 /* | |
6621 * In exclusive Visual mode, may include the last character. | |
6622 */ | |
6623 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6624 adjust_for_sel(cmdarg_T *cap) |
7 | 6625 { |
6626 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
|
6627 && gchar_cursor() != NUL && LT_POS(VIsual, curwin->w_cursor)) |
7 | 6628 { |
6629 if (has_mbyte) | |
6630 inc_cursor(); | |
6631 else | |
6632 ++curwin->w_cursor.col; | |
6633 cap->oap->inclusive = FALSE; | |
6634 } | |
6635 } | |
6636 | |
6637 /* | |
6638 * Exclude last character at end of Visual area for 'selection' == "exclusive". | |
6639 * Should check VIsual_mode before calling this. | |
6640 * Returns TRUE when backed up to the previous line. | |
6641 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
6642 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6643 unadjust_for_sel(void) |
7 | 6644 { |
6645 pos_T *pp; | |
6646 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6647 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
|
6648 { |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6649 if (LT_POS(VIsual, curwin->w_cursor)) |
7 | 6650 pp = &curwin->w_cursor; |
6651 else | |
6652 pp = &VIsual; | |
6653 if (pp->coladd > 0) | |
6654 --pp->coladd; | |
6655 else | |
6656 if (pp->col > 0) | |
6657 { | |
6658 --pp->col; | |
2933 | 6659 mb_adjustpos(curbuf, pp); |
7 | 6660 } |
6661 else if (pp->lnum > 1) | |
6662 { | |
6663 --pp->lnum; | |
6664 pp->col = (colnr_T)STRLEN(ml_get(pp->lnum)); | |
6665 return TRUE; | |
6666 } | |
6667 } | |
6668 return FALSE; | |
6669 } | |
6670 | |
6671 /* | |
6672 * SELECT key in Normal or Visual mode: end of Select mode mapping. | |
6673 */ | |
6674 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6675 nv_select(cmdarg_T *cap) |
7 | 6676 { |
6677 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
|
6678 { |
7 | 6679 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
|
6680 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
|
6681 } |
7 | 6682 else if (VIsual_reselect) |
6683 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6684 cap->nchar = 'v'; // fake "gv" command |
7 | 6685 cap->arg = TRUE; |
6686 nv_g_cmd(cap); | |
6687 } | |
6688 } | |
6689 | |
6690 | |
6691 /* | |
6692 * "G", "gg", CTRL-END, CTRL-HOME. | |
6693 * cap->arg is TRUE for "G". | |
6694 */ | |
6695 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6696 nv_goto(cmdarg_T *cap) |
7 | 6697 { |
6698 linenr_T lnum; | |
6699 | |
6700 if (cap->arg) | |
6701 lnum = curbuf->b_ml.ml_line_count; | |
6702 else | |
6703 lnum = 1L; | |
6704 cap->oap->motion_type = MLINE; | |
6705 setpcmark(); | |
6706 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6707 // When a count is given, use it instead of the default lnum |
7 | 6708 if (cap->count0 != 0) |
6709 lnum = cap->count0; | |
6710 if (lnum < 1L) | |
6711 lnum = 1L; | |
6712 else if (lnum > curbuf->b_ml.ml_line_count) | |
6713 lnum = curbuf->b_ml.ml_line_count; | |
6714 curwin->w_cursor.lnum = lnum; | |
6715 beginline(BL_SOL | BL_FIX); | |
6716 #ifdef FEAT_FOLDING | |
6717 if ((fdo_flags & FDO_JUMP) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6718 foldOpenCursor(); | |
6719 #endif | |
6720 } | |
6721 | |
6722 /* | |
6723 * CTRL-\ in Normal mode. | |
6724 */ | |
6725 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6726 nv_normal(cmdarg_T *cap) |
7 | 6727 { |
6728 if (cap->nchar == Ctrl_N || cap->nchar == Ctrl_G) | |
6729 { | |
6730 clearop(cap->oap); | |
643 | 6731 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
|
6732 clear_cmdline = TRUE; // unshow mode later |
7 | 6733 restart_edit = 0; |
6734 if (cmdwin_type != 0) | |
6735 cmdwin_result = Ctrl_C; | |
6736 if (VIsual_active) | |
6737 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6738 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
|
6739 redraw_curbuf_later(UPD_INVERTED); |
7 | 6740 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6741 // CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. |
7 | 6742 if (cap->nchar == Ctrl_G && p_im) |
6743 restart_edit = 'a'; | |
6744 } | |
6745 else | |
6746 clearopbeep(cap->oap); | |
6747 } | |
6748 | |
6749 /* | |
6750 * ESC in Normal mode: beep, but don't flush buffers. | |
6751 * Don't even beep if we are canceling a command. | |
6752 */ | |
6753 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6754 nv_esc(cmdarg_T *cap) |
7 | 6755 { |
6756 int no_reason; | |
6757 | |
6758 no_reason = (cap->oap->op_type == OP_NOP | |
6759 && cap->opcount == 0 | |
6760 && cap->count0 == 0 | |
6761 && cap->oap->regname == 0 | |
6762 && !p_im); | |
6763 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6764 if (cap->arg) // TRUE for CTRL-C |
7 | 6765 { |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30616
diff
changeset
|
6766 if (restart_edit == 0 && cmdwin_type == 0 |
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30616
diff
changeset
|
6767 && !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
|
6768 { |
30471
584231b9b37e
patch 9.0.0571: MS-Windows: CTRL-C can make Vim exit
Bram Moolenaar <Bram@vim.org>
parents:
30467
diff
changeset
|
6769 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
|
6770 |
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
|
6771 // 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
|
6772 // 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
|
6773 // 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
|
6774 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
|
6775 { |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6776 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
|
6777 |
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 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
|
6779 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
|
6780 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
|
6781 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
|
6782 } |
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
|
6783 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
|
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 { |
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 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
|
6788 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
|
6789 } |
072c61082148
patch 9.0.0569: cannot easily get out when using "vim file | grep word"
Bram Moolenaar <Bram@vim.org>
parents:
30293
diff
changeset
|
6790 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
|
6791 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
|
6792 } |
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
|
6793 } |
7 | 6794 |
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
|
6795 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
|
6796 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
|
6797 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6798 // 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
|
6799 // set again below when halfway a mapping. |
7 | 6800 if (!p_im) |
6801 restart_edit = 0; | |
6802 if (cmdwin_type != 0) | |
6803 { | |
6804 cmdwin_result = K_IGNORE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6805 got_int = FALSE; // don't stop executing autocommands et al. |
7 | 6806 return; |
6807 } | |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30616
diff
changeset
|
6808 } |
29790
8874cb642b70
patch 9.0.0234: cannot make difference between :normal end and argument char
Bram Moolenaar <Bram@vim.org>
parents:
29765
diff
changeset
|
6809 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
|
6810 { |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6811 // 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
|
6812 // 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
|
6813 // 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
|
6814 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
|
6815 return; |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
6816 } |
7 | 6817 |
6818 if (VIsual_active) | |
6819 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6820 end_visual_mode(); // stop Visual |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6821 check_cursor_col(); // make sure cursor is not beyond EOL |
7 | 6822 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
|
6823 redraw_curbuf_later(UPD_INVERTED); |
7 | 6824 } |
5735 | 6825 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
|
6826 { |
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6827 #ifdef HAS_MESSAGE_WINDOW |
29948
29e4cd9e66de
patch 9.0.0312: test for cmdheight zero fails
Bram Moolenaar <Bram@vim.org>
parents:
29944
diff
changeset
|
6828 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
|
6829 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
|
6830 else |
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6831 #endif |
34c5647efe7a
patch 9.0.0310: output of :messages dissappears when cmdheight is zero
Bram Moolenaar <Bram@vim.org>
parents:
29853
diff
changeset
|
6832 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
|
6833 } |
7 | 6834 clearop(cap->oap); |
6835 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6836 // 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
|
6837 // 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
|
6838 if (restart_edit == 0 && goto_im() && ex_normal_busy == 0) |
7 | 6839 restart_edit = 'a'; |
6840 } | |
6841 | |
6842 /* | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6843 * 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
|
6844 */ |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6845 void |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6846 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
|
6847 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6848 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
|
6849 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
|
6850 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6851 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
|
6852 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6853 // 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
|
6854 // 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
|
6855 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
|
6856 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
|
6857 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
|
6858 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6859 else |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6860 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
|
6861 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6862 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6863 /* |
7 | 6864 * 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
|
6865 * Also handle K_PS, start bracketed paste. |
7 | 6866 */ |
6867 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6868 nv_edit(cmdarg_T *cap) |
7 | 6869 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6870 // <Insert> is equal to "i" |
7 | 6871 if (cap->cmdchar == K_INS || cap->cmdchar == K_KINS) |
6872 cap->cmdchar = 'i'; | |
6873 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6874 // in Visual mode "A" and "I" are an operator |
7 | 6875 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
|
6876 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6877 #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
|
6878 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
|
6879 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6880 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
|
6881 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
|
6882 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
|
6883 return; |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6884 } |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6885 #endif |
7 | 6886 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
|
6887 } |
7 | 6888 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6889 // in Visual mode and after an operator "a" and "i" are for text objects |
5735 | 6890 else if ((cap->cmdchar == 'a' || cap->cmdchar == 'i') |
6891 && (cap->oap->op_type != OP_NOP || VIsual_active)) | |
7 | 6892 { |
6893 nv_object(cap); | |
6894 } | |
11892
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6895 #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
|
6896 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
|
6897 { |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6898 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
|
6899 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
|
6900 return; |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6901 } |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
6902 #endif |
7 | 6903 else if (!curbuf->b_p_ma && !p_im) |
6904 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6905 // 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
|
6906 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 6907 clearop(cap->oap); |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6908 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
|
6909 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
6910 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 6911 } |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6912 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
|
6913 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6914 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
|
6915 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
|
6916 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
|
6917 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6918 // 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
|
6919 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
|
6920 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6921 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
|
6922 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
|
6923 } |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6924 else |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6925 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
|
6926 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
|
6927 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
|
6928 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
|
6929 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
|
6930 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
|
6931 |
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
|
6932 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
|
6933 { |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6934 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
|
6935 { |
7976d709c963
patch 8.2.4567: bracketed paste doesn't work well in Visual linewise mode
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
6936 // 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
|
6937 // 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
|
6938 // 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
|
6939 // 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
|
6940 // 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
|
6941 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
|
6942 && 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
|
6943 { |
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 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
|
6945 { |
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 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
|
6947 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
|
6948 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
|
6949 } |
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 } |
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 // 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
|
6953 // 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
|
6954 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
|
6955 && 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
|
6956 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
|
6957 } |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6958 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6959 // 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
|
6960 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
|
6961 } |
7 | 6962 else if (!checkclearopq(cap->oap)) |
6963 { | |
6964 switch (cap->cmdchar) | |
6965 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6966 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
|
6967 set_cursor_for_append_to_line(); |
7 | 6968 break; |
6969 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6970 case 'I': // "I"nsert before the first non-blank |
164 | 6971 if (vim_strchr(p_cpo, CPO_INSEND) == NULL) |
6972 beginline(BL_WHITE); | |
6973 else | |
6974 beginline(BL_WHITE|BL_FIX); | |
7 | 6975 break; |
6976 | |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
6977 case K_PS: |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6978 // 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
|
6979 // 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
|
6980 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
|
6981 break; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6982 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6983 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6984 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
|
6985 // 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
|
6986 // column otherwise, also to append after an unprintable char |
7 | 6987 if (virtual_active() |
6988 && (curwin->w_cursor.coladd > 0 | |
6989 || *ml_get_cursor() == NUL | |
6990 || *ml_get_cursor() == TAB)) | |
6991 curwin->w_cursor.coladd++; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
6992 else if (*ml_get_cursor() != NUL) |
7 | 6993 inc_cursor(); |
6994 break; | |
6995 } | |
6996 | |
6997 if (curwin->w_cursor.coladd && cap->cmdchar != 'A') | |
6998 { | |
6999 int save_State = State; | |
7000 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7001 // 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
|
7002 // 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
|
7003 State = MODE_INSERT; |
7 | 7004 coladvance(getviscol()); |
7005 State = save_State; | |
7006 } | |
7007 | |
7008 invoke_edit(cap, FALSE, cap->cmdchar, FALSE); | |
7009 } | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7010 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
|
7011 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7012 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 7013 } |
7014 | |
7015 /* | |
7016 * Invoke edit() and take care of "restart_edit" and the return value. | |
7017 */ | |
7018 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7019 invoke_edit( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7020 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7021 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
|
7022 int cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7023 int startln) |
7 | 7024 { |
7025 int restart_edit_save = 0; | |
7026 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7027 // 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
|
7028 // 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
|
7029 // it. |
7 | 7030 if (repl || !stuff_empty()) |
7031 restart_edit_save = restart_edit; | |
7032 else | |
7033 restart_edit_save = 0; | |
7034 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7035 // Always reset "restart_edit", this is not a restarted edit. |
7 | 7036 restart_edit = 0; |
7037 | |
7038 if (edit(cmd, startln, cap->count1)) | |
7039 cap->retval |= CA_COMMAND_BUSY; | |
7040 | |
7041 if (restart_edit == 0) | |
7042 restart_edit = restart_edit_save; | |
7043 } | |
7044 | |
7045 /* | |
7046 * "a" or "i" while an operator is pending or in Visual mode: object motion. | |
7047 */ | |
7048 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7049 nv_object( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7050 cmdarg_T *cap) |
7 | 7051 { |
7052 int flag; | |
7053 int include; | |
7054 char_u *mps_save; | |
7055 | |
7056 if (cap->cmdchar == 'i') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7057 include = FALSE; // "ix" = inner object: exclude white space |
7 | 7058 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7059 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
|
7060 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7061 // Make sure (), [], {} and <> are in 'matchpairs' |
7 | 7062 mps_save = curbuf->b_p_mps; |
7063 curbuf->b_p_mps = (char_u *)"(:),{:},[:],<:>"; | |
7064 | |
7065 switch (cap->nchar) | |
7066 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7067 case 'w': // "aw" = a word |
7 | 7068 flag = current_word(cap->oap, cap->count1, include, FALSE); |
7069 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7070 case 'W': // "aW" = a WORD |
7 | 7071 flag = current_word(cap->oap, cap->count1, include, TRUE); |
7072 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7073 case 'b': // "ab" = a braces block |
7 | 7074 case '(': |
7075 case ')': | |
7076 flag = current_block(cap->oap, cap->count1, include, '(', ')'); | |
7077 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7078 case 'B': // "aB" = a Brackets block |
7 | 7079 case '{': |
7080 case '}': | |
7081 flag = current_block(cap->oap, cap->count1, include, '{', '}'); | |
7082 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7083 case '[': // "a[" = a [] block |
7 | 7084 case ']': |
7085 flag = current_block(cap->oap, cap->count1, include, '[', ']'); | |
7086 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7087 case '<': // "a<" = a <> block |
7 | 7088 case '>': |
7089 flag = current_block(cap->oap, cap->count1, include, '<', '>'); | |
7090 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
|
7091 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7092 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
|
7093 // 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
|
7094 // 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
|
7095 // (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
|
7096 // 1) <b> 2) <b> |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7097 // foobar foobar |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7098 // </b> </b> |
6661 | 7099 cap->retval |= CA_NO_ADJ_OP_END; |
420 | 7100 flag = current_tagblock(cap->oap, cap->count1, include); |
7101 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
|
7102 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7103 case 'p': // "ap" = a paragraph |
7 | 7104 flag = current_par(cap->oap, cap->count1, include, 'p'); |
7105 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7106 case 's': // "as" = a sentence |
7 | 7107 flag = current_sent(cap->oap, cap->count1, include); |
7108 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7109 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
|
7110 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
|
7111 case '`': // "a`" = a backtick quoted string |
12 | 7112 flag = current_quote(cap->oap, cap->count1, include, |
7113 cap->nchar); | |
7114 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7115 #if 0 // TODO |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7116 case 'S': // "aS" = a section |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7117 case 'f': // "af" = a filename |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7118 case 'u': // "au" = a URL |
7 | 7119 #endif |
7120 default: | |
7121 flag = FAIL; | |
7122 break; | |
7123 } | |
7124 | |
7125 curbuf->b_p_mps = mps_save; | |
7126 if (flag == FAIL) | |
7127 clearopbeep(cap->oap); | |
7128 adjust_cursor_col(); | |
7129 curwin->w_set_curswant = TRUE; | |
7130 } | |
7131 | |
7132 /* | |
7133 * "q" command: Start/stop recording. | |
7134 * "q:", "q/", "q?": edit command-line in command-line window. | |
7135 */ | |
7136 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7137 nv_record(cmdarg_T *cap) |
7 | 7138 { |
7139 if (cap->oap->op_type == OP_FORMAT) | |
7140 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7141 // "gqq" is the same as "gqgq": format line |
7 | 7142 cap->cmdchar = 'g'; |
7143 cap->nchar = 'q'; | |
7144 nv_operator(cap); | |
7145 } | |
7146 else if (!checkclearop(cap->oap)) | |
7147 { | |
7148 if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') | |
7149 { | |
29444
44bb4a607125
patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents:
29340
diff
changeset
|
7150 if (cmdwin_type != 0) |
44bb4a607125
patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents:
29340
diff
changeset
|
7151 { |
44bb4a607125
patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents:
29340
diff
changeset
|
7152 emsg(_(e_cmdline_window_already_open)); |
44bb4a607125
patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents:
29340
diff
changeset
|
7153 return; |
44bb4a607125
patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents:
29340
diff
changeset
|
7154 } |
7 | 7155 stuffcharReadbuff(cap->nchar); |
7156 stuffcharReadbuff(K_CMDWIN); | |
7157 } | |
7158 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7159 // (stop) recording into a named register, unless executing a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7160 // register |
14004
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13876
diff
changeset
|
7161 if (reg_executing == 0 && do_record(cap->nchar) == FAIL) |
7 | 7162 clearopbeep(cap->oap); |
7163 } | |
7164 } | |
7165 | |
7166 /* | |
7167 * Handle the "@r" command. | |
7168 */ | |
7169 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7170 nv_at(cmdarg_T *cap) |
7 | 7171 { |
7172 if (checkclearop(cap->oap)) | |
7173 return; | |
7174 #ifdef FEAT_EVAL | |
7175 if (cap->nchar == '=') | |
7176 { | |
7177 if (get_expr_register() == NUL) | |
7178 return; | |
7179 } | |
7180 #endif | |
7181 while (cap->count1-- && !got_int) | |
7182 { | |
1034 | 7183 if (do_execreg(cap->nchar, FALSE, FALSE, FALSE) == FAIL) |
7 | 7184 { |
7185 clearopbeep(cap->oap); | |
7186 break; | |
7187 } | |
7188 line_breakcheck(); | |
7189 } | |
7190 } | |
7191 | |
7192 /* | |
7193 * Handle the CTRL-U and CTRL-D commands. | |
7194 */ | |
7195 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7196 nv_halfpage(cmdarg_T *cap) |
7 | 7197 { |
7198 if ((cap->cmdchar == Ctrl_U && curwin->w_cursor.lnum == 1) | |
7199 || (cap->cmdchar == Ctrl_D | |
7200 && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)) | |
7201 clearopbeep(cap->oap); | |
7202 else if (!checkclearop(cap->oap)) | |
7203 halfpage(cap->cmdchar == Ctrl_D, cap->count0); | |
7204 } | |
7205 | |
7206 /* | |
7207 * Handle "J" or "gJ" command. | |
7208 */ | |
7209 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7210 nv_join(cmdarg_T *cap) |
7 | 7211 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7212 if (VIsual_active) // join the visual lines |
7 | 7213 nv_operator(cap); |
5735 | 7214 else if (!checkclearop(cap->oap)) |
7 | 7215 { |
7216 if (cap->count0 <= 1) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7217 cap->count0 = 2; // default for join is two lines! |
7 | 7218 if (curwin->w_cursor.lnum + cap->count0 - 1 > |
7219 curbuf->b_ml.ml_line_count) | |
8445
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7220 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7221 // can't join when on the last line |
8445
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7222 if (cap->count0 <= 2) |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7223 { |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7224 clearopbeep(cap->oap); |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7225 return; |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7226 } |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7227 cap->count0 = curbuf->b_ml.ml_line_count |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7228 - curwin->w_cursor.lnum + 1; |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7229 } |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7230 |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7231 prep_redo(cap->oap->regname, cap->count0, |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7232 NUL, cap->cmdchar, NUL, NUL, cap->nchar); |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7233 (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); |
7 | 7234 } |
7235 } | |
7236 | |
7237 /* | |
7238 * "P", "gP", "p" and "gp" commands. | |
7239 */ | |
7240 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7241 nv_put(cmdarg_T *cap) |
7 | 7242 { |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7243 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
|
7244 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7245 |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7246 /* |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7247 * "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
|
7248 * "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
|
7249 */ |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7250 static void |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7251 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
|
7252 { |
7 | 7253 int regname = 0; |
7254 void *reg1 = NULL, *reg2 = NULL; | |
84 | 7255 int empty = FALSE; |
236 | 7256 int was_visual = FALSE; |
7 | 7257 int dir; |
7258 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
|
7259 int keep_registers = FALSE; |
7 | 7260 |
7261 if (cap->oap->op_type != OP_NOP) | |
7262 { | |
7263 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7264 // "dp" is ":diffput" |
7 | 7265 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'p') |
7266 { | |
7267 clearop(cap->oap); | |
6314 | 7268 nv_diffgetput(TRUE, cap->opcount); |
7 | 7269 } |
7270 else | |
7271 #endif | |
7272 clearopbeep(cap->oap); | |
7273 } | |
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
|
7274 #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
|
7275 else if (bt_prompt(curbuf) && !prompt_curpos_editable()) |
dc67449d648c
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Christian Brabandt <cb@256bit.org>
parents:
14004
diff
changeset
|
7276 { |
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
|
7277 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
|
7278 } |
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
|
7279 #endif |
7 | 7280 else |
7281 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7282 if (fix_indent) |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7283 { |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7284 dir = (cap->cmdchar == ']' && cap->nchar == 'p') |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7285 ? FORWARD : BACKWARD; |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7286 flags |= PUT_FIXINDENT; |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7287 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7288 else |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7289 dir = (cap->cmdchar == 'P' |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7290 || ((cap->cmdchar == 'g' || cap->cmdchar == 'z') |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7291 && cap->nchar == 'P')) ? BACKWARD : FORWARD; |
7 | 7292 prep_redo_cmd(cap); |
7293 if (cap->cmdchar == 'g') | |
7294 flags |= PUT_CURSEND; | |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7295 else if (cap->cmdchar == 'z') |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7296 flags |= PUT_BLOCK_INNER; |
7 | 7297 |
7298 if (VIsual_active) | |
7299 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7300 // Putting in Visual mode: The put text replaces the selected |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7301 // text. First delete the selected text, then put the new text. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7302 // Need to save and restore the registers that the delete |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7303 // overwrites if the old contents is being put. |
236 | 7304 was_visual = TRUE; |
7 | 7305 regname = cap->oap->regname; |
28714
5eea8a249f86
patch 8.2.4881: "P" in Visual mode still changes some registers
Bram Moolenaar <Bram@vim.org>
parents:
28564
diff
changeset
|
7306 keep_registers = cap->cmdchar == 'P'; |
5735 | 7307 #ifdef FEAT_CLIPBOARD |
7 | 7308 adjust_clip_reg(®name); |
5735 | 7309 #endif |
5682 | 7310 if (regname == 0 || regname == '"' |
4013 | 7311 || VIM_ISDIGIT(regname) || regname == '-' |
5735 | 7312 #ifdef FEAT_CLIPBOARD |
7 | 7313 || (clip_unnamed && (regname == '*' || regname == '+')) |
5735 | 7314 #endif |
7 | 7315 |
7316 ) | |
7317 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7318 // The delete is going to overwrite the register we want to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7319 // put, save it first. |
7 | 7320 reg1 = get_register(regname, TRUE); |
7321 } | |
7322 | |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7323 // Now delete the selected text. Avoid messages here. |
7 | 7324 cap->cmdchar = 'd'; |
7325 cap->nchar = NUL; | |
28714
5eea8a249f86
patch 8.2.4881: "P" in Visual mode still changes some registers
Bram Moolenaar <Bram@vim.org>
parents:
28564
diff
changeset
|
7326 cap->oap->regname = keep_registers ? '_' : NUL; |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7327 ++msg_silent; |
7 | 7328 nv_operator(cap); |
7329 do_pending_operator(cap, 0, FALSE); | |
84 | 7330 empty = (curbuf->b_ml.ml_flags & ML_EMPTY); |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7331 --msg_silent; |
7 | 7332 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7333 // delete PUT_LINE_BACKWARD; |
7 | 7334 cap->oap->regname = regname; |
7335 | |
7336 if (reg1 != NULL) | |
7337 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7338 // Delete probably changed the register we want to put, save |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7339 // it first. Then put back what was there before the delete. |
7 | 7340 reg2 = get_register(regname, FALSE); |
7341 put_register(regname, reg1); | |
7342 } | |
7343 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7344 // When deleted a linewise Visual area, put the register as |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7345 // lines to avoid it joined with the next line. When deletion was |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7346 // characterwise, split a line when putting lines. |
7 | 7347 if (VIsual_mode == 'V') |
7348 flags |= PUT_LINE; | |
7349 else if (VIsual_mode == 'v') | |
7350 flags |= PUT_LINE_SPLIT; | |
7351 if (VIsual_mode == Ctrl_V && dir == FORWARD) | |
7352 flags |= PUT_LINE_FORWARD; | |
7353 dir = BACKWARD; | |
7354 if ((VIsual_mode != 'V' | |
7355 && curwin->w_cursor.col < curbuf->b_op_start.col) | |
7356 || (VIsual_mode == 'V' | |
7357 && curwin->w_cursor.lnum < curbuf->b_op_start.lnum)) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7358 // cursor is at the end of the line or end of file, put |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7359 // forward. |
7 | 7360 dir = FORWARD; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7361 // May have been reset in do_put(). |
5365 | 7362 VIsual_active = TRUE; |
7 | 7363 } |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7364 do_put(cap->oap->regname, NULL, dir, cap->count1, flags); |
7 | 7365 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7366 // If a register was saved, put it back now. |
7 | 7367 if (reg2 != NULL) |
7368 put_register(regname, reg2); | |
236 | 7369 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7370 // What to reselect with "gv"? Selecting the just put text seems to |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7371 // be the most useful, since the original text was removed. |
236 | 7372 if (was_visual) |
7373 { | |
690 | 7374 curbuf->b_visual.vi_start = curbuf->b_op_start; |
7375 curbuf->b_visual.vi_end = curbuf->b_op_end; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7376 // need to adjust cursor position |
7241
0c1278704b5c
commit https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27
Christian Brabandt <cb@256bit.org>
parents:
7143
diff
changeset
|
7377 if (*p_sel == 'e') |
0c1278704b5c
commit https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27
Christian Brabandt <cb@256bit.org>
parents:
7143
diff
changeset
|
7378 inc(&curbuf->b_visual.vi_end); |
236 | 7379 } |
7380 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7381 // When all lines were selected and deleted do_put() leaves an empty |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7382 // line that needs to be deleted now. |
84 | 7383 if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) |
817 | 7384 { |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
7385 ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE); |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7386 deleted_lines(curbuf->b_ml.ml_line_count + 1, 1); |
817 | 7387 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7388 // If the cursor was in that line, move it to the end of the last |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7389 // line. |
817 | 7390 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
7391 { | |
7392 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
7393 coladvance((colnr_T)MAXCOL); | |
7394 } | |
7395 } | |
7 | 7396 auto_format(FALSE, TRUE); |
7397 } | |
7398 } | |
7399 | |
7400 /* | |
7401 * "o" and "O" commands. | |
7402 */ | |
7403 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7404 nv_open(cmdarg_T *cap) |
7 | 7405 { |
7406 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7407 // "do" is ":diffget" |
7 | 7408 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'o') |
7409 { | |
7410 clearop(cap->oap); | |
6314 | 7411 nv_diffgetput(FALSE, cap->opcount); |
7 | 7412 } |
7413 else | |
7414 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7415 if (VIsual_active) // switch start and end of visual |
7 | 7416 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
|
7417 #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
|
7418 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
|
7419 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
|
7420 #endif |
7 | 7421 else |
7422 n_opencmd(cap); | |
7423 } | |
7424 | |
7425 #ifdef FEAT_NETBEANS_INTG | |
7426 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7427 nv_nbcmd(cmdarg_T *cap) |
7 | 7428 { |
7429 netbeans_keycommand(cap->nchar); | |
7430 } | |
7431 #endif | |
7432 | |
7433 #ifdef FEAT_DND | |
7434 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7435 nv_drop(cmdarg_T *cap UNUSED) |
7 | 7436 { |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7437 do_put('~', NULL, BACKWARD, 1L, PUT_CURSEND); |
7 | 7438 } |
7439 #endif | |
203 | 7440 |
7441 /* | |
7442 * Trigger CursorHold event. | |
7443 * When waiting for a character for 'updatetime' K_CURSORHOLD is put in the | |
7444 * input buffer. "did_cursorhold" is set to avoid retriggering. | |
7445 */ | |
7446 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7447 nv_cursorhold(cmdarg_T *cap) |
203 | 7448 { |
7449 apply_autocmds(EVENT_CURSORHOLD, NULL, NULL, FALSE, curbuf); | |
7450 did_cursorhold = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7451 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
226 | 7452 } |