Mercurial > vim
annotate src/normal.c @ 23976:03819ebd3e6d v8.2.2530
patch 8.2.2530: Vim9: not enough testing for profiling
Commit: https://github.com/vim/vim/commit/12d265315fac9e4f3436c38a87f6d9a23b9e7e2b
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 19 19:13:21 2021 +0100
patch 8.2.2530: Vim9: not enough testing for profiling
Problem: Vim9: not enough testing for profiling.
Solution: Add a test with nested functions and a lambda. Fix profiling
for calling a compiled function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 19 Feb 2021 19:15:03 +0100 |
parents | 0f89d58eb3e3 |
children | c9849ed1ce05 |
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 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
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 static int restart_VIsual_select = 0; |
19 | |
2667 | 20 #ifdef FEAT_EVAL |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
21 static void set_vcount_ca(cmdarg_T *cap, int *set_prevcount); |
2667 | 22 #endif |
16606
7e733046db1d
patch 8.1.1306: Borland support is outdated and doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16598
diff
changeset
|
23 static int nv_compare(const void *s1, const void *s2); |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
24 static void unshift_special(cmdarg_T *cap); |
7 | 25 #ifdef FEAT_CMDL_INFO |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
26 static void del_from_showcmd(int); |
7 | 27 #endif |
28 | |
29 /* | |
30 * nv_*(): functions called to handle Normal and Visual mode commands. | |
31 * n_*(): functions called to handle Normal mode commands. | |
32 * v_*(): functions called to handle Visual mode commands. | |
33 */ | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 static void nv_zet(cmdarg_T *cap); |
7 | 41 #ifdef FEAT_GUI |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
42 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
|
43 static void nv_hor_scrollbar(cmdarg_T *cap); |
7 | 44 #endif |
685 | 45 #ifdef FEAT_GUI_TABLINE |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
46 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
|
47 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
|
48 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 static void nv_dot(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
93 static void nv_redo(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
94 static void nv_Undo(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
95 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
|
96 static void nv_operator(cmdarg_T *cap); |
1490 | 97 #ifdef FEAT_EVAL |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
98 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
|
99 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 static void invoke_edit(cmdarg_T *cap, int repl, int cmd, int startln); |
7 | 114 #ifdef FEAT_TEXTOBJ |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
115 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
|
116 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 static void nv_open(cmdarg_T *cap); |
7 | 124 #ifdef FEAT_NETBEANS_INTG |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
125 static void nv_nbcmd(cmdarg_T *cap); |
7 | 126 #endif |
127 #ifdef FEAT_DND | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
128 static void nv_drop(cmdarg_T *cap); |
7 | 129 #endif |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
130 static void nv_cursorhold(cmdarg_T *cap); |
7 | 131 |
1728 | 132 static char *e_noident = N_("E349: No identifier under cursor"); |
133 | |
7 | 134 /* |
135 * Function to be called for a Normal or Visual mode command. | |
136 * The argument is a cmdarg_T. | |
137 */ | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
138 typedef void (*nv_func_T)(cmdarg_T *cap); |
7 | 139 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
140 // Values for cmd_flags. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
141 #define NV_NCH 0x01 // may need to get a second char |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
142 #define NV_NCH_NOP (0x02|NV_NCH) // get second char when no operator pending |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
143 #define NV_NCH_ALW (0x04|NV_NCH) // always get a second char |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
144 #define NV_LANG 0x08 // second char needs language adjustment |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
145 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
146 #define NV_SS 0x10 // may start selection |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
147 #define NV_SSS 0x20 // may start selection with shift modifier |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
148 #define NV_STS 0x40 // may stop selection without shift modif. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
149 #define NV_RL 0x80 // 'rightleft' modifies command |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
150 #define NV_KEEPREG 0x100 // don't clear regname |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
151 #define NV_NCW 0x200 // not allowed in command-line window |
7 | 152 |
153 /* | |
154 * Generally speaking, every Normal mode command should either clear any | |
155 * pending operator (with *clearop*()), or set the motion type variable | |
156 * oap->motion_type. | |
157 * | |
158 * When a cursor motion command is made, it is marked as being a character or | |
159 * line oriented motion. Then, if an operator is in effect, the operation | |
160 * becomes character or line oriented accordingly. | |
161 */ | |
162 | |
163 /* | |
164 * This table contains one entry for every Normal or Visual mode command. | |
165 * The order doesn't matter, init_normal_cmds() will create a sorted index. | |
166 * It is faster when all keys from zero to '~' are present. | |
167 */ | |
168 static const struct nv_cmd | |
169 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
170 int cmd_char; // (first) command character |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
171 nv_func_T cmd_func; // function for this command |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
172 short_u cmd_flags; // NV_ flags |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
173 short cmd_arg; // value for ca.arg |
7 | 174 } nv_cmds[] = |
175 { | |
176 {NUL, nv_error, 0, 0}, | |
177 {Ctrl_A, nv_addsub, 0, 0}, | |
178 {Ctrl_B, nv_page, NV_STS, BACKWARD}, | |
179 {Ctrl_C, nv_esc, 0, TRUE}, | |
180 {Ctrl_D, nv_halfpage, 0, 0}, | |
181 {Ctrl_E, nv_scroll_line, 0, TRUE}, | |
182 {Ctrl_F, nv_page, NV_STS, FORWARD}, | |
183 {Ctrl_G, nv_ctrlg, 0, 0}, | |
184 {Ctrl_H, nv_ctrlh, 0, 0}, | |
185 {Ctrl_I, nv_pcmark, 0, 0}, | |
186 {NL, nv_down, 0, FALSE}, | |
187 {Ctrl_K, nv_error, 0, 0}, | |
188 {Ctrl_L, nv_clear, 0, 0}, | |
16054
78faa25f9698
patch 8.1.1032: warnings from clang static analyzer
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
189 {CAR, nv_down, 0, TRUE}, |
7 | 190 {Ctrl_N, nv_down, NV_STS, FALSE}, |
191 {Ctrl_O, nv_ctrlo, 0, 0}, | |
192 {Ctrl_P, nv_up, NV_STS, FALSE}, | |
167 | 193 {Ctrl_Q, nv_visual, 0, FALSE}, |
7 | 194 {Ctrl_R, nv_redo, 0, 0}, |
195 {Ctrl_S, nv_ignore, 0, 0}, | |
196 {Ctrl_T, nv_tagpop, NV_NCW, 0}, | |
197 {Ctrl_U, nv_halfpage, 0, 0}, | |
198 {Ctrl_V, nv_visual, 0, FALSE}, | |
199 {'V', nv_visual, 0, FALSE}, | |
200 {'v', nv_visual, 0, FALSE}, | |
201 {Ctrl_W, nv_window, 0, 0}, | |
202 {Ctrl_X, nv_addsub, 0, 0}, | |
203 {Ctrl_Y, nv_scroll_line, 0, FALSE}, | |
204 {Ctrl_Z, nv_suspend, 0, 0}, | |
205 {ESC, nv_esc, 0, FALSE}, | |
206 {Ctrl_BSL, nv_normal, NV_NCH_ALW, 0}, | |
207 {Ctrl_RSB, nv_ident, NV_NCW, 0}, | |
208 {Ctrl_HAT, nv_hat, NV_NCW, 0}, | |
209 {Ctrl__, nv_error, 0, 0}, | |
210 {' ', nv_right, 0, 0}, | |
211 {'!', nv_operator, 0, 0}, | |
212 {'"', nv_regname, NV_NCH_NOP|NV_KEEPREG, 0}, | |
213 {'#', nv_ident, 0, 0}, | |
214 {'$', nv_dollar, 0, 0}, | |
215 {'%', nv_percent, 0, 0}, | |
216 {'&', nv_optrans, 0, 0}, | |
217 {'\'', nv_gomark, NV_NCH_ALW, TRUE}, | |
218 {'(', nv_brace, 0, BACKWARD}, | |
219 {')', nv_brace, 0, FORWARD}, | |
220 {'*', nv_ident, 0, 0}, | |
221 {'+', nv_down, 0, TRUE}, | |
222 {',', nv_csearch, 0, TRUE}, | |
223 {'-', nv_up, 0, TRUE}, | |
224 {'.', nv_dot, NV_KEEPREG, 0}, | |
225 {'/', nv_search, 0, FALSE}, | |
226 {'0', nv_beginline, 0, 0}, | |
227 {'1', nv_ignore, 0, 0}, | |
228 {'2', nv_ignore, 0, 0}, | |
229 {'3', nv_ignore, 0, 0}, | |
230 {'4', nv_ignore, 0, 0}, | |
231 {'5', nv_ignore, 0, 0}, | |
232 {'6', nv_ignore, 0, 0}, | |
233 {'7', nv_ignore, 0, 0}, | |
234 {'8', nv_ignore, 0, 0}, | |
235 {'9', nv_ignore, 0, 0}, | |
236 {':', nv_colon, 0, 0}, | |
237 {';', nv_csearch, 0, FALSE}, | |
238 {'<', nv_operator, NV_RL, 0}, | |
239 {'=', nv_operator, 0, 0}, | |
240 {'>', nv_operator, NV_RL, 0}, | |
241 {'?', nv_search, 0, FALSE}, | |
242 {'@', nv_at, NV_NCH_NOP, FALSE}, | |
243 {'A', nv_edit, 0, 0}, | |
244 {'B', nv_bck_word, 0, 1}, | |
245 {'C', nv_abbrev, NV_KEEPREG, 0}, | |
246 {'D', nv_abbrev, NV_KEEPREG, 0}, | |
247 {'E', nv_wordcmd, 0, TRUE}, | |
248 {'F', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD}, | |
249 {'G', nv_goto, 0, TRUE}, | |
250 {'H', nv_scroll, 0, 0}, | |
251 {'I', nv_edit, 0, 0}, | |
252 {'J', nv_join, 0, 0}, | |
253 {'K', nv_ident, 0, 0}, | |
254 {'L', nv_scroll, 0, 0}, | |
255 {'M', nv_scroll, 0, 0}, | |
256 {'N', nv_next, 0, SEARCH_REV}, | |
257 {'O', nv_open, 0, 0}, | |
258 {'P', nv_put, 0, 0}, | |
259 {'Q', nv_exmode, NV_NCW, 0}, | |
260 {'R', nv_Replace, 0, FALSE}, | |
261 {'S', nv_subst, NV_KEEPREG, 0}, | |
262 {'T', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD}, | |
263 {'U', nv_Undo, 0, 0}, | |
264 {'W', nv_wordcmd, 0, TRUE}, | |
265 {'X', nv_abbrev, NV_KEEPREG, 0}, | |
266 {'Y', nv_abbrev, NV_KEEPREG, 0}, | |
267 {'Z', nv_Zet, NV_NCH_NOP|NV_NCW, 0}, | |
268 {'[', nv_brackets, NV_NCH_ALW, BACKWARD}, | |
269 {'\\', nv_error, 0, 0}, | |
270 {']', nv_brackets, NV_NCH_ALW, FORWARD}, | |
271 {'^', nv_beginline, 0, BL_WHITE | BL_FIX}, | |
272 {'_', nv_lineop, 0, 0}, | |
273 {'`', nv_gomark, NV_NCH_ALW, FALSE}, | |
274 {'a', nv_edit, NV_NCH, 0}, | |
275 {'b', nv_bck_word, 0, 0}, | |
276 {'c', nv_operator, 0, 0}, | |
277 {'d', nv_operator, 0, 0}, | |
278 {'e', nv_wordcmd, 0, FALSE}, | |
279 {'f', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD}, | |
280 {'g', nv_g_cmd, NV_NCH_ALW, FALSE}, | |
281 {'h', nv_left, NV_RL, 0}, | |
282 {'i', nv_edit, NV_NCH, 0}, | |
283 {'j', nv_down, 0, FALSE}, | |
284 {'k', nv_up, 0, FALSE}, | |
285 {'l', nv_right, NV_RL, 0}, | |
286 {'m', nv_mark, NV_NCH_NOP, 0}, | |
287 {'n', nv_next, 0, 0}, | |
288 {'o', nv_open, 0, 0}, | |
289 {'p', nv_put, 0, 0}, | |
290 {'q', nv_record, NV_NCH, 0}, | |
291 {'r', nv_replace, NV_NCH_NOP|NV_LANG, 0}, | |
292 {'s', nv_subst, NV_KEEPREG, 0}, | |
293 {'t', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD}, | |
294 {'u', nv_undo, 0, 0}, | |
295 {'w', nv_wordcmd, 0, FALSE}, | |
296 {'x', nv_abbrev, NV_KEEPREG, 0}, | |
297 {'y', nv_operator, 0, 0}, | |
298 {'z', nv_zet, NV_NCH_ALW, 0}, | |
299 {'{', nv_findpar, 0, BACKWARD}, | |
300 {'|', nv_pipe, 0, 0}, | |
301 {'}', nv_findpar, 0, FORWARD}, | |
302 {'~', nv_tilde, 0, 0}, | |
303 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
304 // pound sign |
7 | 305 {POUND, nv_ident, 0, 0}, |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
306 {K_MOUSEUP, nv_mousescroll, 0, MSCR_UP}, |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
307 {K_MOUSEDOWN, nv_mousescroll, 0, MSCR_DOWN}, |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
308 {K_MOUSELEFT, nv_mousescroll, 0, MSCR_LEFT}, |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
309 {K_MOUSERIGHT, nv_mousescroll, 0, MSCR_RIGHT}, |
7 | 310 {K_LEFTMOUSE, nv_mouse, 0, 0}, |
311 {K_LEFTMOUSE_NM, nv_mouse, 0, 0}, | |
312 {K_LEFTDRAG, nv_mouse, 0, 0}, | |
313 {K_LEFTRELEASE, nv_mouse, 0, 0}, | |
314 {K_LEFTRELEASE_NM, nv_mouse, 0, 0}, | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
315 {K_MOUSEMOVE, nv_mouse, 0, 0}, |
7 | 316 {K_MIDDLEMOUSE, nv_mouse, 0, 0}, |
317 {K_MIDDLEDRAG, nv_mouse, 0, 0}, | |
318 {K_MIDDLERELEASE, nv_mouse, 0, 0}, | |
319 {K_RIGHTMOUSE, nv_mouse, 0, 0}, | |
320 {K_RIGHTDRAG, nv_mouse, 0, 0}, | |
321 {K_RIGHTRELEASE, nv_mouse, 0, 0}, | |
322 {K_X1MOUSE, nv_mouse, 0, 0}, | |
323 {K_X1DRAG, nv_mouse, 0, 0}, | |
324 {K_X1RELEASE, nv_mouse, 0, 0}, | |
325 {K_X2MOUSE, nv_mouse, 0, 0}, | |
326 {K_X2DRAG, nv_mouse, 0, 0}, | |
327 {K_X2RELEASE, nv_mouse, 0, 0}, | |
819 | 328 {K_IGNORE, nv_ignore, NV_KEEPREG, 0}, |
620 | 329 {K_NOP, nv_nop, 0, 0}, |
7 | 330 {K_INS, nv_edit, 0, 0}, |
331 {K_KINS, nv_edit, 0, 0}, | |
332 {K_BS, nv_ctrlh, 0, 0}, | |
333 {K_UP, nv_up, NV_SSS|NV_STS, FALSE}, | |
334 {K_S_UP, nv_page, NV_SS, BACKWARD}, | |
335 {K_DOWN, nv_down, NV_SSS|NV_STS, FALSE}, | |
336 {K_S_DOWN, nv_page, NV_SS, FORWARD}, | |
337 {K_LEFT, nv_left, NV_SSS|NV_STS|NV_RL, 0}, | |
338 {K_S_LEFT, nv_bck_word, NV_SS|NV_RL, 0}, | |
339 {K_C_LEFT, nv_bck_word, NV_SSS|NV_RL|NV_STS, 1}, | |
340 {K_RIGHT, nv_right, NV_SSS|NV_STS|NV_RL, 0}, | |
341 {K_S_RIGHT, nv_wordcmd, NV_SS|NV_RL, FALSE}, | |
342 {K_C_RIGHT, nv_wordcmd, NV_SSS|NV_RL|NV_STS, TRUE}, | |
343 {K_PAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD}, | |
344 {K_KPAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD}, | |
345 {K_PAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD}, | |
346 {K_KPAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD}, | |
347 {K_END, nv_end, NV_SSS|NV_STS, FALSE}, | |
348 {K_KEND, nv_end, NV_SSS|NV_STS, FALSE}, | |
349 {K_S_END, nv_end, NV_SS, FALSE}, | |
350 {K_C_END, nv_end, NV_SSS|NV_STS, TRUE}, | |
351 {K_HOME, nv_home, NV_SSS|NV_STS, 0}, | |
352 {K_KHOME, nv_home, NV_SSS|NV_STS, 0}, | |
353 {K_S_HOME, nv_home, NV_SS, 0}, | |
354 {K_C_HOME, nv_goto, NV_SSS|NV_STS, FALSE}, | |
355 {K_DEL, nv_abbrev, 0, 0}, | |
356 {K_KDEL, nv_abbrev, 0, 0}, | |
357 {K_UNDO, nv_kundo, 0, 0}, | |
358 {K_HELP, nv_help, NV_NCW, 0}, | |
359 {K_F1, nv_help, NV_NCW, 0}, | |
360 {K_XF1, nv_help, NV_NCW, 0}, | |
361 {K_SELECT, nv_select, 0, 0}, | |
362 #ifdef FEAT_GUI | |
363 {K_VER_SCROLLBAR, nv_ver_scrollbar, 0, 0}, | |
364 {K_HOR_SCROLLBAR, nv_hor_scrollbar, 0, 0}, | |
365 #endif | |
685 | 366 #ifdef FEAT_GUI_TABLINE |
367 {K_TABLINE, nv_tabline, 0, 0}, | |
686 | 368 {K_TABMENU, nv_tabmenu, 0, 0}, |
685 | 369 #endif |
7 | 370 #ifdef FEAT_NETBEANS_INTG |
371 {K_F21, nv_nbcmd, NV_NCH_ALW, 0}, | |
372 #endif | |
373 #ifdef FEAT_DND | |
374 {K_DROP, nv_drop, NV_STS, 0}, | |
375 #endif | |
819 | 376 {K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0}, |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
377 {K_PS, nv_edit, 0, 0}, |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
378 {K_COMMAND, nv_colon, 0, 0}, |
7 | 379 }; |
380 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
381 // Number of commands in nv_cmds[]. |
7 | 382 #define NV_CMDS_SIZE (sizeof(nv_cmds) / sizeof(struct nv_cmd)) |
383 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
384 // Sorted index of commands in nv_cmds[]. |
7 | 385 static short nv_cmd_idx[NV_CMDS_SIZE]; |
386 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
387 // The highest index for which |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
388 // nv_cmds[idx].cmd_char == nv_cmd_idx[nv_cmds[idx].cmd_char] |
7 | 389 static int nv_max_linear; |
390 | |
391 /* | |
392 * Compare functions for qsort() below, that checks the command character | |
393 * through the index in nv_cmd_idx[]. | |
394 */ | |
395 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
396 nv_compare(const void *s1, const void *s2) |
7 | 397 { |
398 int c1, c2; | |
399 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
400 // The commands are sorted on absolute value. |
7 | 401 c1 = nv_cmds[*(const short *)s1].cmd_char; |
402 c2 = nv_cmds[*(const short *)s2].cmd_char; | |
403 if (c1 < 0) | |
404 c1 = -c1; | |
405 if (c2 < 0) | |
406 c2 = -c2; | |
407 return c1 - c2; | |
408 } | |
409 | |
410 /* | |
411 * Initialize the nv_cmd_idx[] table. | |
412 */ | |
413 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
414 init_normal_cmds(void) |
7 | 415 { |
416 int i; | |
417 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
418 // Fill the index table with a one to one relation. |
1877 | 419 for (i = 0; i < (int)NV_CMDS_SIZE; ++i) |
7 | 420 nv_cmd_idx[i] = i; |
421 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
422 // Sort the commands by the command character. |
7 | 423 qsort((void *)&nv_cmd_idx, (size_t)NV_CMDS_SIZE, sizeof(short), nv_compare); |
424 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
425 // Find the first entry that can't be indexed by the command character. |
1877 | 426 for (i = 0; i < (int)NV_CMDS_SIZE; ++i) |
7 | 427 if (i != nv_cmds[nv_cmd_idx[i]].cmd_char) |
428 break; | |
429 nv_max_linear = i - 1; | |
430 } | |
431 | |
432 /* | |
433 * Search for a command in the commands table. | |
434 * Returns -1 for invalid command. | |
435 */ | |
436 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
437 find_command(int cmdchar) |
7 | 438 { |
439 int i; | |
440 int idx; | |
441 int top, bot; | |
442 int c; | |
443 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
444 // A multi-byte character is never a command. |
7 | 445 if (cmdchar >= 0x100) |
446 return -1; | |
447 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
448 // 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
|
449 // negative value, but are sorted on their absolute value. |
7 | 450 if (cmdchar < 0) |
451 cmdchar = -cmdchar; | |
452 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
453 // 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
|
454 // nv_cmd_idx[]. |
7 | 455 if (cmdchar <= nv_max_linear) |
456 return nv_cmd_idx[cmdchar]; | |
457 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
458 // Perform a binary search. |
7 | 459 bot = nv_max_linear + 1; |
460 top = NV_CMDS_SIZE - 1; | |
461 idx = -1; | |
462 while (bot <= top) | |
463 { | |
464 i = (top + bot) / 2; | |
465 c = nv_cmds[nv_cmd_idx[i]].cmd_char; | |
466 if (c < 0) | |
467 c = -c; | |
468 if (cmdchar == c) | |
469 { | |
470 idx = nv_cmd_idx[i]; | |
471 break; | |
472 } | |
473 if (cmdchar > c) | |
474 bot = i + 1; | |
475 else | |
476 top = i - 1; | |
477 } | |
478 return idx; | |
479 } | |
480 | |
481 /* | |
482 * Execute a command in Normal mode. | |
483 */ | |
484 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
485 normal_cmd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
486 oparg_T *oap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
487 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
|
488 { |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
489 cmdarg_T ca; // command arguments |
7 | 490 int c; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
491 int ctrl_w = FALSE; // got CTRL-W command |
7 | 492 int old_col = curwin->w_curswant; |
493 #ifdef FEAT_CMDL_INFO | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
494 int need_flushbuf; // need to call out_flush() |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
495 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
496 pos_T old_pos; // cursor position before command |
7 | 497 int mapped_len; |
498 static int old_mapped_len = 0; | |
499 int idx; | |
1751 | 500 #ifdef FEAT_EVAL |
501 int set_prevcount = FALSE; | |
502 #endif | |
21405
5324acb43fea
patch 8.2.1253: CTRL-K in Insert mode gets <CursorHold> inserted
Bram Moolenaar <Bram@vim.org>
parents:
20754
diff
changeset
|
503 int save_did_cursorhold = did_cursorhold; |
7 | 504 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
505 CLEAR_FIELD(ca); // also resets ca.retval |
7 | 506 ca.oap = oap; |
1692 | 507 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
508 // 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
|
509 // "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
|
510 // remembered in "opcount". |
7 | 511 ca.opcount = opcount; |
512 | |
513 /* | |
514 * If there is an operator pending, then the command we take this time | |
515 * will terminate it. Finish_op tells us to finish the operation before | |
516 * returning this time (unless the operation was cancelled). | |
517 */ | |
518 #ifdef CURSOR_SHAPE | |
519 c = finish_op; | |
520 #endif | |
521 finish_op = (oap->op_type != OP_NOP); | |
522 #ifdef CURSOR_SHAPE | |
523 if (finish_op != c) | |
524 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
525 ui_cursor_shape(); // may show different cursor shape |
7 | 526 # ifdef FEAT_MOUSESHAPE |
527 update_mouseshape(-1); | |
528 # endif | |
529 } | |
530 #endif | |
531 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
532 // 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
|
533 // count. |
7 | 534 if (!finish_op && !oap->regname) |
1751 | 535 { |
7 | 536 ca.opcount = 0; |
1751 | 537 #ifdef FEAT_EVAL |
538 set_prevcount = TRUE; | |
539 #endif | |
540 } | |
7 | 541 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
542 // 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
|
543 // 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
|
544 // "3 * 2". |
1692 | 545 if (oap->prev_opcount > 0 || oap->prev_count0 > 0) |
546 { | |
547 ca.opcount = oap->prev_opcount; | |
548 ca.count0 = oap->prev_count0; | |
549 oap->prev_opcount = 0; | |
550 oap->prev_count0 = 0; | |
551 } | |
552 | |
7 | 553 mapped_len = typebuf_maplen(); |
554 | |
555 State = NORMAL_BUSY; | |
556 #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
|
557 dont_scroll = FALSE; // allow scrolling here |
7 | 558 #endif |
559 | |
2667 | 560 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
561 // 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
|
562 // 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
|
563 // when there is no count. Do set it for redo. |
5649 | 564 if (toplevel && readbuf1_empty()) |
2667 | 565 set_vcount_ca(&ca, &set_prevcount); |
566 #endif | |
567 | |
7 | 568 /* |
569 * Get the command character from the user. | |
570 */ | |
571 c = safe_vgetc(); | |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7578
diff
changeset
|
572 LANGMAP_ADJUST(c, get_real_state() != SELECTMODE); |
7 | 573 |
574 /* | |
575 * If a mapping was started in Visual or Select mode, remember the length | |
576 * of the mapping. This is used below to not return to Insert mode for as | |
577 * long as the mapping is being executed. | |
578 */ | |
579 if (restart_edit == 0) | |
580 old_mapped_len = 0; | |
581 else if (old_mapped_len | |
819 | 582 || (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0)) |
7 | 583 old_mapped_len = typebuf_maplen(); |
584 | |
585 if (c == NUL) | |
586 c = K_ZERO; | |
587 | |
588 /* | |
589 * In Select mode, typed text replaces the selection. | |
590 */ | |
591 if (VIsual_active | |
592 && VIsual_select | |
593 && (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER)) | |
594 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
595 // 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
|
596 // '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
|
597 // restart automatically. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
598 // 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
|
599 // be mapped in Insert mode. Required for ":lmap" to work. |
20571
5995db0fe84a
patch 8.2.0839: dropping modifier when putting a character back in typeahead
Bram Moolenaar <Bram@vim.org>
parents:
20375
diff
changeset
|
600 ins_char_typebuf(vgetc_char, vgetc_mod_mask); |
275 | 601 if (restart_edit != 0) |
602 c = 'd'; | |
603 else | |
604 c = 'c'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
605 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
|
606 old_mapped_len = 0; // do go to Insert mode |
7 | 607 } |
608 | |
609 #ifdef FEAT_CMDL_INFO | |
610 need_flushbuf = add_to_showcmd(c); | |
611 #endif | |
612 | |
613 getcount: | |
614 if (!(VIsual_active && VIsual_select)) | |
615 { | |
616 /* | |
617 * Handle a count before a command and compute ca.count0. | |
618 * Note that '0' is a command and not the start of a count, but it's | |
619 * part of a count after other digits. | |
620 */ | |
621 while ( (c >= '1' && c <= '9') | |
622 || (ca.count0 != 0 && (c == K_DEL || c == K_KDEL || c == '0'))) | |
623 { | |
624 if (c == K_DEL || c == K_KDEL) | |
625 { | |
626 ca.count0 /= 10; | |
627 #ifdef FEAT_CMDL_INFO | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
628 del_from_showcmd(4); // delete the digit and ~@% |
7 | 629 #endif |
630 } | |
631 else | |
632 ca.count0 = ca.count0 * 10 + (c - '0'); | |
23762
0f89d58eb3e3
patch 8.2.2422: crash when deleting with line number out of range
Bram Moolenaar <Bram@vim.org>
parents:
23687
diff
changeset
|
633 if (ca.count0 < 0) // overflow |
7 | 634 ca.count0 = 999999999L; |
1425 | 635 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
636 // 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
|
637 // 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
|
638 // right after the count. Do set it for redo. |
5649 | 639 if (toplevel && readbuf1_empty()) |
2667 | 640 set_vcount_ca(&ca, &set_prevcount); |
1425 | 641 #endif |
7 | 642 if (ctrl_w) |
643 { | |
644 ++no_mapping; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
645 ++allow_keys; // no mapping for nchar, but keys |
7 | 646 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
647 ++no_zero_mapping; // don't map zero here |
1389 | 648 c = plain_vgetc(); |
7 | 649 LANGMAP_ADJUST(c, TRUE); |
650 --no_zero_mapping; | |
651 if (ctrl_w) | |
652 { | |
653 --no_mapping; | |
654 --allow_keys; | |
655 } | |
656 #ifdef FEAT_CMDL_INFO | |
657 need_flushbuf |= add_to_showcmd(c); | |
658 #endif | |
659 } | |
660 | |
661 /* | |
662 * If we got CTRL-W there may be a/another count | |
663 */ | |
664 if (c == Ctrl_W && !ctrl_w && oap->op_type == OP_NOP) | |
665 { | |
666 ctrl_w = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
667 ca.opcount = ca.count0; // remember first count |
7 | 668 ca.count0 = 0; |
669 ++no_mapping; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
670 ++allow_keys; // no mapping for nchar, but keys |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
671 c = plain_vgetc(); // get next character |
7 | 672 LANGMAP_ADJUST(c, TRUE); |
673 --no_mapping; | |
674 --allow_keys; | |
675 #ifdef FEAT_CMDL_INFO | |
676 need_flushbuf |= add_to_showcmd(c); | |
677 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
678 goto getcount; // jump back |
7 | 679 } |
680 } | |
681 | |
1692 | 682 if (c == K_CURSORHOLD) |
683 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
684 // Save the count values so that ca.opcount and ca.count0 are exactly |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
685 // the same when coming back here after handling K_CURSORHOLD. |
1692 | 686 oap->prev_opcount = ca.opcount; |
687 oap->prev_count0 = ca.count0; | |
688 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
689 else if (ca.opcount != 0) |
1692 | 690 { |
691 /* | |
692 * If we're in the middle of an operator (including after entering a | |
693 * yank buffer with '"') AND we had a count before the operator, then | |
694 * that count overrides the current value of ca.count0. | |
695 * What this means effectively, is that commands like "3dw" get turned | |
696 * into "d3w" which makes things fall into place pretty neatly. | |
697 * If you give a count before AND after the operator, they are | |
698 * multiplied. | |
699 */ | |
7 | 700 if (ca.count0) |
701 ca.count0 *= ca.opcount; | |
702 else | |
703 ca.count0 = ca.opcount; | |
23762
0f89d58eb3e3
patch 8.2.2422: crash when deleting with line number out of range
Bram Moolenaar <Bram@vim.org>
parents:
23687
diff
changeset
|
704 if (ca.count0 < 0) // overflow |
0f89d58eb3e3
patch 8.2.2422: crash when deleting with line number out of range
Bram Moolenaar <Bram@vim.org>
parents:
23687
diff
changeset
|
705 ca.count0 = 999999999L; |
7 | 706 } |
707 | |
708 /* | |
709 * Always remember the count. It will be set to zero (on the next call, | |
710 * above) when there is no pending operator. | |
711 * When called from main(), save the count for use by the "count" built-in | |
712 * variable. | |
713 */ | |
714 ca.opcount = ca.count0; | |
715 ca.count1 = (ca.count0 == 0 ? 1 : ca.count0); | |
716 | |
717 #ifdef FEAT_EVAL | |
718 /* | |
719 * Only set v:count when called from main() and not a stuffed command. | |
5649 | 720 * Do set it for redo. |
7 | 721 */ |
5649 | 722 if (toplevel && readbuf1_empty()) |
1751 | 723 set_vcount(ca.count0, ca.count1, set_prevcount); |
7 | 724 #endif |
725 | |
726 /* | |
727 * Find the command character in the table of commands. | |
728 * For CTRL-W we already got nchar when looking for a count. | |
729 */ | |
730 if (ctrl_w) | |
731 { | |
732 ca.nchar = c; | |
733 ca.cmdchar = Ctrl_W; | |
734 } | |
735 else | |
736 ca.cmdchar = c; | |
737 idx = find_command(ca.cmdchar); | |
738 if (idx < 0) | |
739 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
740 // Not a known command: beep. |
7 | 741 clearopbeep(oap); |
742 goto normal_end; | |
743 } | |
631 | 744 |
633 | 745 if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW)) |
631 | 746 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
747 // This command is not allowed while editing a cmdline: beep. |
7 | 748 clearopbeep(oap); |
633 | 749 text_locked_msg(); |
7 | 750 goto normal_end; |
751 } | |
819 | 752 if ((nv_cmds[idx].cmd_flags & NV_NCW) && curbuf_locked()) |
753 goto normal_end; | |
7 | 754 |
755 /* | |
756 * In Visual/Select mode, a few keys are handled in a special way. | |
757 */ | |
758 if (VIsual_active) | |
759 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
760 // when 'keymodel' contains "stopsel" may stop Select/Visual mode |
7 | 761 if (km_stopsel |
762 && (nv_cmds[idx].cmd_flags & NV_STS) | |
763 && !(mod_mask & MOD_MASK_SHIFT)) | |
764 { | |
765 end_visual_mode(); | |
766 redraw_curbuf_later(INVERTED); | |
767 } | |
768 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
769 // Keys that work different when 'keymodel' contains "startsel" |
7 | 770 if (km_startsel) |
771 { | |
772 if (nv_cmds[idx].cmd_flags & NV_SS) | |
773 { | |
774 unshift_special(&ca); | |
775 idx = find_command(ca.cmdchar); | |
840 | 776 if (idx < 0) |
777 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
778 // Just in case |
840 | 779 clearopbeep(oap); |
780 goto normal_end; | |
781 } | |
7 | 782 } |
783 else if ((nv_cmds[idx].cmd_flags & NV_SSS) | |
784 && (mod_mask & MOD_MASK_SHIFT)) | |
785 mod_mask &= ~MOD_MASK_SHIFT; | |
786 } | |
787 } | |
788 | |
789 #ifdef FEAT_RIGHTLEFT | |
790 if (curwin->w_p_rl && KeyTyped && !KeyStuffed | |
791 && (nv_cmds[idx].cmd_flags & NV_RL)) | |
792 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
793 // 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
|
794 // 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
|
795 // to "dl". |
7 | 796 switch (ca.cmdchar) |
797 { | |
798 case 'l': ca.cmdchar = 'h'; break; | |
799 case K_RIGHT: ca.cmdchar = K_LEFT; break; | |
800 case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break; | |
801 case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break; | |
802 case 'h': ca.cmdchar = 'l'; break; | |
803 case K_LEFT: ca.cmdchar = K_RIGHT; break; | |
804 case K_S_LEFT: ca.cmdchar = K_S_RIGHT; break; | |
805 case K_C_LEFT: ca.cmdchar = K_C_RIGHT; break; | |
806 case '>': ca.cmdchar = '<'; break; | |
807 case '<': ca.cmdchar = '>'; break; | |
808 } | |
809 idx = find_command(ca.cmdchar); | |
810 } | |
811 #endif | |
812 | |
813 /* | |
814 * Get an additional character if we need one. | |
815 */ | |
816 if ((nv_cmds[idx].cmd_flags & NV_NCH) | |
817 && (((nv_cmds[idx].cmd_flags & NV_NCH_NOP) == NV_NCH_NOP | |
818 && oap->op_type == OP_NOP) | |
819 || (nv_cmds[idx].cmd_flags & NV_NCH_ALW) == NV_NCH_ALW | |
820 || (ca.cmdchar == 'q' | |
821 && oap->op_type == OP_NOP | |
14004
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13876
diff
changeset
|
822 && reg_recording == 0 |
e124262d435e
patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents:
13876
diff
changeset
|
823 && reg_executing == 0) |
7 | 824 || ((ca.cmdchar == 'a' || ca.cmdchar == 'i') |
5735 | 825 && (oap->op_type != OP_NOP || VIsual_active)))) |
7 | 826 { |
827 int *cp; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
828 int repl = FALSE; // get character for replace mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
829 int lit = FALSE; // get extra character literally |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
830 int langmap_active = FALSE; // using :lmap mappings |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
831 int lang; // getting a text character |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
832 #ifdef HAVE_INPUT_METHOD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
833 int save_smd; // saved value of p_smd |
7 | 834 #endif |
835 | |
836 ++no_mapping; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
837 ++allow_keys; // no mapping for nchar, but allow key codes |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
838 // Don't generate a CursorHold event here, most commands can't handle |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
839 // it, e.g., nv_replace(), nv_csearch(). |
1343 | 840 did_cursorhold = TRUE; |
7 | 841 if (ca.cmdchar == 'g') |
842 { | |
843 /* | |
844 * For 'g' get the next character now, so that we can check for | |
845 * "gr", "g'" and "g`". | |
846 */ | |
1389 | 847 ca.nchar = plain_vgetc(); |
7 | 848 LANGMAP_ADJUST(ca.nchar, TRUE); |
849 #ifdef FEAT_CMDL_INFO | |
850 need_flushbuf |= add_to_showcmd(ca.nchar); | |
851 #endif | |
852 if (ca.nchar == 'r' || ca.nchar == '\'' || ca.nchar == '`' | |
5523 | 853 || ca.nchar == Ctrl_BSL) |
7 | 854 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
855 cp = &ca.extra_char; // need to get a third character |
7 | 856 if (ca.nchar != 'r') |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
857 lit = TRUE; // get it literally |
7 | 858 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
859 repl = TRUE; // get it in replace mode |
7 | 860 } |
861 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
862 cp = NULL; // no third character needed |
7 | 863 } |
864 else | |
865 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
866 if (ca.cmdchar == 'r') // get it in replace mode |
7 | 867 repl = TRUE; |
868 cp = &ca.nchar; | |
869 } | |
870 lang = (repl || (nv_cmds[idx].cmd_flags & NV_LANG)); | |
871 | |
872 /* | |
873 * Get a second or third character. | |
874 */ | |
875 if (cp != NULL) | |
876 { | |
877 if (repl) | |
878 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
879 State = REPLACE; // pretend Replace mode |
18485
63ee3c2b140f
patch 8.1.2237: mode() result depends on whether CURSOR_SHAPE is defined
Bram Moolenaar <Bram@vim.org>
parents:
18477
diff
changeset
|
880 #ifdef CURSOR_SHAPE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
881 ui_cursor_shape(); // show different cursor shape |
18485
63ee3c2b140f
patch 8.1.2237: mode() result depends on whether CURSOR_SHAPE is defined
Bram Moolenaar <Bram@vim.org>
parents:
18477
diff
changeset
|
882 #endif |
7 | 883 } |
884 if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) | |
885 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
886 // Allow mappings defined with ":lmap". |
7 | 887 --no_mapping; |
888 --allow_keys; | |
889 if (repl) | |
890 State = LREPLACE; | |
891 else | |
892 State = LANGMAP; | |
893 langmap_active = TRUE; | |
894 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
895 #ifdef HAVE_INPUT_METHOD |
7 | 896 save_smd = p_smd; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
897 p_smd = FALSE; // Don't let the IM code show the mode here |
7 | 898 if (lang && curbuf->b_p_iminsert == B_IMODE_IM) |
899 im_set_active(TRUE); | |
900 #endif | |
22000
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
901 if ((State & INSERT) && !p_ek) |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
902 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
22000
diff
changeset
|
903 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
22000
diff
changeset
|
904 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
22000
diff
changeset
|
905 #endif |
22000
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
906 // Disable bracketed paste and modifyOtherKeys here, we won't |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
907 // recognize the escape sequences with 'esckeys' off. |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
908 out_str(T_BD); |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
909 out_str(T_CTE); |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
910 } |
7 | 911 |
1389 | 912 *cp = plain_vgetc(); |
7 | 913 |
22000
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
914 if ((State & INSERT) && !p_ek) |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
915 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
22000
diff
changeset
|
916 #ifdef FEAT_JOB_CHANNEL |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
22000
diff
changeset
|
917 ch_log_output = TRUE; |
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
22000
diff
changeset
|
918 #endif |
22000
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
919 // Re-enable bracketed paste mode and modifyOtherKeys |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
920 out_str(T_BE); |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
921 out_str(T_CTI); |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
922 } |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
923 |
7 | 924 if (langmap_active) |
925 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
926 // Undo the decrement done above |
7 | 927 ++no_mapping; |
928 ++allow_keys; | |
929 State = NORMAL_BUSY; | |
930 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
931 #ifdef HAVE_INPUT_METHOD |
7 | 932 if (lang) |
933 { | |
934 if (curbuf->b_p_iminsert != B_IMODE_LMAP) | |
935 im_save_status(&curbuf->b_p_iminsert); | |
936 im_set_active(FALSE); | |
937 } | |
938 p_smd = save_smd; | |
939 #endif | |
940 State = NORMAL_BUSY; | |
941 #ifdef FEAT_CMDL_INFO | |
942 need_flushbuf |= add_to_showcmd(*cp); | |
943 #endif | |
944 | |
945 if (!lit) | |
946 { | |
947 #ifdef FEAT_DIGRAPHS | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
948 // Typing CTRL-K gets a digraph. |
7 | 949 if (*cp == Ctrl_K |
950 && ((nv_cmds[idx].cmd_flags & NV_LANG) | |
951 || cp == &ca.extra_char) | |
952 && vim_strchr(p_cpo, CPO_DIGRAPH) == NULL) | |
953 { | |
954 c = get_digraph(FALSE); | |
955 if (c > 0) | |
956 { | |
957 *cp = c; | |
958 # ifdef FEAT_CMDL_INFO | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
959 // Guessing how to update showcmd here... |
7 | 960 del_from_showcmd(3); |
961 need_flushbuf |= add_to_showcmd(*cp); | |
962 # endif | |
963 } | |
964 } | |
965 #endif | |
966 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
967 // adjust chars > 127, except after "tTfFr" commands |
7 | 968 LANGMAP_ADJUST(*cp, !lang); |
969 #ifdef FEAT_RIGHTLEFT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
970 // adjust Hebrew mapped char |
7 | 971 if (p_hkmap && lang && KeyTyped) |
972 *cp = hkmap(*cp); | |
973 #endif | |
974 } | |
975 | |
976 /* | |
977 * When the next character is CTRL-\ a following CTRL-N means the | |
978 * command is aborted and we go to Normal mode. | |
979 */ | |
980 if (cp == &ca.extra_char | |
981 && ca.nchar == Ctrl_BSL | |
982 && (ca.extra_char == Ctrl_N || ca.extra_char == Ctrl_G)) | |
983 { | |
984 ca.cmdchar = Ctrl_BSL; | |
985 ca.nchar = ca.extra_char; | |
986 idx = find_command(ca.cmdchar); | |
987 } | |
3908 | 988 else if ((ca.nchar == 'n' || ca.nchar == 'N') && ca.cmdchar == 'g') |
3896 | 989 ca.oap->op_type = get_op_type(*cp, NUL); |
7 | 990 else if (*cp == Ctrl_BSL) |
991 { | |
992 long towait = (p_ttm >= 0 ? p_ttm : p_tm); | |
993 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
994 // There is a busy wait here when typing "f<C-\>" and then |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
995 // something different from CTRL-N. Can't be avoided. |
7 | 996 while ((c = vpeekc()) <= 0 && towait > 0L) |
997 { | |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
998 do_sleep(towait > 50L ? 50L : towait, FALSE); |
7 | 999 towait -= 50L; |
1000 } | |
1001 if (c > 0) | |
1002 { | |
1389 | 1003 c = plain_vgetc(); |
7 | 1004 if (c != Ctrl_N && c != Ctrl_G) |
1005 vungetc(c); | |
1006 else | |
1007 { | |
1008 ca.cmdchar = Ctrl_BSL; | |
1009 ca.nchar = c; | |
1010 idx = find_command(ca.cmdchar); | |
1011 } | |
1012 } | |
1013 } | |
1014 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1015 // When getting a text character and the next character is a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1016 // multi-byte character, it could be a composing character. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1017 // However, don't wait for it to arrive. Also, do enable mapping, |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1018 // because if it's put back with vungetc() it's too late to apply |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1019 // mapping. |
6071 | 1020 --no_mapping; |
7 | 1021 while (enc_utf8 && lang && (c = vpeekc()) > 0 |
1022 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) | |
1023 { | |
1389 | 1024 c = plain_vgetc(); |
7 | 1025 if (!utf_iscomposing(c)) |
1026 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1027 vungetc(c); // it wasn't, put it back |
7 | 1028 break; |
1029 } | |
1030 else if (ca.ncharC1 == 0) | |
1031 ca.ncharC1 = c; | |
1032 else | |
1033 ca.ncharC2 = c; | |
1034 } | |
6071 | 1035 ++no_mapping; |
7 | 1036 } |
1037 --no_mapping; | |
1038 --allow_keys; | |
1039 } | |
1040 | |
1041 #ifdef FEAT_CMDL_INFO | |
1042 /* | |
1043 * Flush the showcmd characters onto the screen so we can see them while | |
1044 * the command is being executed. Only do this when the shown command was | |
1045 * actually displayed, otherwise this will slow down a lot when executing | |
1046 * mappings. | |
1047 */ | |
1048 if (need_flushbuf) | |
1049 out_flush(); | |
1050 #endif | |
1727 | 1051 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
|
1052 { |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1053 if (ex_normal_busy) |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1054 did_cursorhold = save_did_cursorhold; |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1055 else |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1056 did_cursorhold = FALSE; |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1057 } |
7 | 1058 |
1059 State = NORMAL; | |
1060 | |
1061 if (ca.nchar == ESC) | |
1062 { | |
1063 clearop(oap); | |
1064 if (restart_edit == 0 && goto_im()) | |
1065 restart_edit = 'a'; | |
1066 goto normal_end; | |
1067 } | |
1068 | |
24 | 1069 if (ca.cmdchar != K_IGNORE) |
1070 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1071 msg_didout = FALSE; // don't scroll screen up for normal command |
24 | 1072 msg_col = 0; |
1073 } | |
7 | 1074 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1075 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
|
1076 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1077 // 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
|
1078 // mode. |
7 | 1079 if (!VIsual_active && km_startsel) |
1080 { | |
1081 if (nv_cmds[idx].cmd_flags & NV_SS) | |
1082 { | |
1083 start_selection(); | |
1084 unshift_special(&ca); | |
1085 idx = find_command(ca.cmdchar); | |
1086 } | |
1087 else if ((nv_cmds[idx].cmd_flags & NV_SSS) | |
1088 && (mod_mask & MOD_MASK_SHIFT)) | |
1089 { | |
1090 start_selection(); | |
1091 mod_mask &= ~MOD_MASK_SHIFT; | |
1092 } | |
1093 } | |
1094 | |
1095 /* | |
1096 * Execute the command! | |
1097 * Call the command function found in the commands table. | |
1098 */ | |
1099 ca.arg = nv_cmds[idx].cmd_arg; | |
1100 (nv_cmds[idx].cmd_func)(&ca); | |
1101 | |
1102 /* | |
1103 * If we didn't start or finish an operator, reset oap->regname, unless we | |
1104 * need it later. | |
1105 */ | |
1106 if (!finish_op | |
1107 && !oap->op_type | |
1108 && (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG))) | |
1109 { | |
1110 clearop(oap); | |
1111 #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
|
1112 reset_reg_var(); |
7 | 1113 #endif |
1114 } | |
1115 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1116 // 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
|
1117 // character or "z333<cr>". |
36 | 1118 if (old_mapped_len > 0) |
1119 old_mapped_len = typebuf_maplen(); | |
1120 | |
7 | 1121 /* |
18775
5da1ad9165f0
patch 8.1.2377: GUI: when losing focus a pending operator is executed
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
1122 * If an operation is pending, handle it. But not for K_IGNORE. |
7 | 1123 */ |
18775
5da1ad9165f0
patch 8.1.2377: GUI: when losing focus a pending operator is executed
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
1124 if (ca.cmdchar != K_IGNORE) |
5da1ad9165f0
patch 8.1.2377: GUI: when losing focus a pending operator is executed
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
1125 do_pending_operator(&ca, old_col, FALSE); |
7 | 1126 |
1127 /* | |
1128 * Wait for a moment when a message is displayed that will be overwritten | |
1129 * by the mode message. | |
1130 * In Visual mode and with "^O" in Insert mode, a short message will be | |
1131 * overwritten by the mode message. Wait a bit, until a key is hit. | |
1132 * In Visual mode, it's more important to keep the Visual area updated | |
1133 * than keeping a message (e.g. from a /pat search). | |
1134 * Only do this if the command was typed, not from a mapping. | |
1135 * Don't wait when emsg_silent is non-zero. | |
1136 * Also wait a bit after an error message, e.g. for "^O:". | |
1137 * Don't redraw the screen, it would remove the message. | |
1138 */ | |
1139 if ( ((p_smd | |
641 | 1140 && msg_silent == 0 |
7 | 1141 && (restart_edit != 0 |
1142 || (VIsual_active | |
1143 && old_pos.lnum == curwin->w_cursor.lnum | |
1144 && old_pos.col == curwin->w_cursor.col) | |
1145 ) | |
1146 && (clear_cmdline | |
1147 || redraw_cmdline) | |
1148 && (msg_didout || (msg_didany && msg_scroll)) | |
1149 && !msg_nowait | |
1150 && KeyTyped) | |
1151 || (restart_edit != 0 | |
1152 && !VIsual_active | |
1153 && (msg_scroll | |
1154 || emsg_on_display))) | |
1155 && oap->regname == 0 | |
1156 && !(ca.retval & CA_COMMAND_BUSY) | |
1157 && stuff_empty() | |
1158 && typebuf_typed() | |
1159 && emsg_silent == 0 | |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
1160 && !in_assert_fails |
7 | 1161 && !did_wait_return |
1162 && oap->op_type == OP_NOP) | |
1163 { | |
1164 int save_State = State; | |
1165 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1166 // Draw the cursor with the right shape here |
7 | 1167 if (restart_edit != 0) |
1168 State = INSERT; | |
1169 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1170 // If need to redraw, and there is a "keep_msg", redraw before the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1171 // delay |
7 | 1172 if (must_redraw && keep_msg != NULL && !emsg_on_display) |
1173 { | |
1174 char_u *kmsg; | |
1175 | |
1176 kmsg = keep_msg; | |
1177 keep_msg = NULL; | |
19681
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1178 // Showmode() will clear keep_msg, but we want to use it anyway. |
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1179 // First update w_topline. |
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1180 setcursor(); |
7 | 1181 update_screen(0); |
18045
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1182 // now reset it, otherwise it's put in the history again |
7 | 1183 keep_msg = kmsg; |
18045
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1184 |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1185 kmsg = vim_strsave(keep_msg); |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1186 if (kmsg != NULL) |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1187 { |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1188 msg_attr((char *)kmsg, keep_msg_attr); |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1189 vim_free(kmsg); |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1190 } |
7 | 1191 } |
1192 setcursor(); | |
19681
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1193 #ifdef CURSOR_SHAPE |
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1194 ui_cursor_shape(); // may show different cursor shape |
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1195 #endif |
7 | 1196 cursor_on(); |
1197 out_flush(); | |
1198 if (msg_scroll || emsg_on_display) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1199 ui_delay(1003L, TRUE); // wait at least one second |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1200 ui_delay(3003L, FALSE); // wait up to three seconds |
7 | 1201 State = save_State; |
1202 | |
1203 msg_scroll = FALSE; | |
1204 emsg_on_display = FALSE; | |
1205 } | |
1206 | |
1207 /* | |
1208 * Finish up after executing a Normal mode command. | |
1209 */ | |
1210 normal_end: | |
1211 | |
1212 msg_nowait = FALSE; | |
1213 | |
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
|
1214 #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
|
1215 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
|
1216 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
|
1217 #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
|
1218 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1219 // Reset finish_op, in case it was set |
7 | 1220 #ifdef CURSOR_SHAPE |
1221 c = finish_op; | |
1222 #endif | |
1223 finish_op = FALSE; | |
1224 #ifdef CURSOR_SHAPE | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1225 // 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
|
1226 // mode or did a replace command. |
7 | 1227 if (c || ca.cmdchar == 'r') |
1228 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1229 ui_cursor_shape(); // may show different cursor shape |
7 | 1230 # ifdef FEAT_MOUSESHAPE |
1231 update_mouseshape(-1); | |
1232 # endif | |
1233 } | |
1234 #endif | |
1235 | |
1236 #ifdef FEAT_CMDL_INFO | |
1692 | 1237 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
|
1238 && ca.cmdchar != K_CURSORHOLD) |
7 | 1239 clear_showcmd(); |
1240 #endif | |
1241 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1242 checkpcmark(); // check if we moved since setting pcmark |
7 | 1243 vim_free(ca.searchbuf); |
1244 | |
1245 if (has_mbyte) | |
1246 mb_adjust_cursor(); | |
1247 | |
1248 if (curwin->w_p_scb && toplevel) | |
1249 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1250 validate_cursor(); // may need to update w_leftcol |
7 | 1251 do_check_scrollbind(TRUE); |
1252 } | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
1253 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1254 if (curwin->w_p_crb && toplevel) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1255 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1256 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
|
1257 do_check_cursorbind(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1258 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1259 |
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
|
1260 #ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1261 // 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
|
1262 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
|
1263 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
|
1264 #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
|
1265 |
7 | 1266 /* |
1267 * May restart edit(), if we got here with CTRL-O in Insert mode (but not | |
1268 * if still inside a mapping that started in Visual mode). | |
1269 * May switch from Visual to Select mode after CTRL-O command. | |
1270 */ | |
1271 if ( oap->op_type == OP_NOP | |
1272 && ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0) | |
1273 || restart_VIsual_select == 1) | |
1274 && !(ca.retval & CA_COMMAND_BUSY) | |
1275 && stuff_empty() | |
1276 && oap->regname == 0) | |
1277 { | |
1278 if (restart_VIsual_select == 1) | |
1279 { | |
1280 VIsual_select = TRUE; | |
1281 showmode(); | |
1282 restart_VIsual_select = 0; | |
1283 } | |
5735 | 1284 if (restart_edit != 0 && !VIsual_active && old_mapped_len == 0) |
7 | 1285 (void)edit(restart_edit, FALSE, 1L); |
1286 } | |
1287 | |
1288 if (restart_VIsual_select == 2) | |
1289 restart_VIsual_select = 1; | |
1290 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1291 // Save count before an operator for next time. |
7 | 1292 opcount = ca.opcount; |
1293 } | |
1294 | |
2667 | 1295 #ifdef FEAT_EVAL |
1296 /* | |
1297 * Set v:count and v:count1 according to "cap". | |
1298 * Set v:prevcount only when "set_prevcount" is TRUE. | |
1299 */ | |
1300 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1301 set_vcount_ca(cmdarg_T *cap, int *set_prevcount) |
2667 | 1302 { |
1303 long count = cap->count0; | |
1304 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1305 // multiply with cap->opcount the same way as above |
2667 | 1306 if (cap->opcount != 0) |
1307 count = cap->opcount * (count == 0 ? 1 : count); | |
1308 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
|
1309 *set_prevcount = FALSE; // only set v:prevcount once |
2667 | 1310 } |
1311 #endif | |
1312 | |
7 | 1313 /* |
19681
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1314 * Check if highlighting for Visual mode is possible, give a warning message |
7 | 1315 * if not. |
1316 */ | |
1317 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1318 check_visual_highlight(void) |
7 | 1319 { |
1320 static int did_check = FALSE; | |
1321 | |
1322 if (full_screen) | |
1323 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
1324 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
|
1325 msg(_("Warning: terminal cannot highlight")); |
7 | 1326 did_check = TRUE; |
1327 } | |
1328 } | |
1329 | |
23021
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1330 #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
|
1331 /* |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1332 * 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
|
1333 */ |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1334 static void |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1335 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
|
1336 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1337 oparg_T oa; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1338 yankreg_T *reg; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1339 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1340 clear_oparg(&oa); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1341 oa.regname = regname; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1342 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
|
1343 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
|
1344 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
|
1345 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
|
1346 free_register(reg); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1347 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1348 #endif |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1349 |
7 | 1350 /* |
638 | 1351 * End Visual mode. |
7 | 1352 * This function should ALWAYS be called to end Visual mode, except from |
1353 * do_pending_operator(). | |
1354 */ | |
1355 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1356 end_visual_mode(void) |
7 | 1357 { |
1358 #ifdef FEAT_CLIPBOARD | |
1359 /* | |
1360 * If we are using the clipboard, then remember what was selected in case | |
1361 * we need to paste it somewhere while we still own the selection. | |
1362 * Only do this when the clipboard is already owned. Don't want to grab | |
1363 * the selection when hitting ESC. | |
1364 */ | |
1365 if (clip_star.available && clip_star.owned) | |
1366 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
|
1367 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1368 # 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
|
1369 // 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
|
1370 // 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
|
1371 if (has_textyankpost()) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1372 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1373 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
|
1374 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
|
1375 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
|
1376 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
|
1377 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1378 # endif |
7 | 1379 #endif |
1380 | |
1381 VIsual_active = FALSE; | |
1382 setmouse(); | |
1383 mouse_dragging = 0; | |
1384 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1385 // Save the current VIsual area for '< and '> marks, and "gv" |
690 | 1386 curbuf->b_visual.vi_mode = VIsual_mode; |
1387 curbuf->b_visual.vi_start = VIsual; | |
1388 curbuf->b_visual.vi_end = curwin->w_cursor; | |
1389 curbuf->b_visual.vi_curswant = curwin->w_curswant; | |
7 | 1390 #ifdef FEAT_EVAL |
1391 curbuf->b_visual_mode_eval = VIsual_mode; | |
1392 #endif | |
1393 if (!virtual_active()) | |
1394 curwin->w_cursor.coladd = 0; | |
6979 | 1395 may_clear_cmdline(); |
7 | 1396 |
844 | 1397 adjust_cursor_eol(); |
7 | 1398 } |
1399 | |
1400 /* | |
1401 * Reset VIsual_active and VIsual_reselect. | |
1402 */ | |
1403 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1404 reset_VIsual_and_resel(void) |
7 | 1405 { |
1406 if (VIsual_active) | |
1407 { | |
1408 end_visual_mode(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1409 redraw_curbuf_later(INVERTED); // delete the inversion later |
7 | 1410 } |
1411 VIsual_reselect = FALSE; | |
1412 } | |
1413 | |
1414 /* | |
1415 * Reset VIsual_active and VIsual_reselect if it's set. | |
1416 */ | |
1417 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1418 reset_VIsual(void) |
7 | 1419 { |
1420 if (VIsual_active) | |
1421 { | |
1422 end_visual_mode(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1423 redraw_curbuf_later(INVERTED); // delete the inversion later |
7 | 1424 VIsual_reselect = FALSE; |
1425 } | |
1426 } | |
1427 | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1428 void |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1429 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
|
1430 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1431 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
|
1432 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1433 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
|
1434 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
|
1435 } |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1436 } |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1437 |
7 | 1438 /* |
1439 * Check for a balloon-eval special item to include when searching for an | |
1440 * identifier. When "dir" is BACKWARD "ptr[-1]" must be valid! | |
1441 * Returns TRUE if the character at "*ptr" should be included. | |
1442 * "dir" is FORWARD or BACKWARD, the direction of searching. | |
1443 * "*colp" is in/decremented if "ptr[-dir]" should also be included. | |
1444 * "bnp" points to a counter for square brackets. | |
1445 */ | |
1446 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1447 find_is_eval_item( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1448 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1449 int *colp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1450 int *bnp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1451 int dir) |
7 | 1452 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1453 // Accept everything inside []. |
7 | 1454 if ((*ptr == ']' && dir == BACKWARD) || (*ptr == '[' && dir == FORWARD)) |
1455 ++*bnp; | |
1456 if (*bnp > 0) | |
1457 { | |
1458 if ((*ptr == '[' && dir == BACKWARD) || (*ptr == ']' && dir == FORWARD)) | |
1459 --*bnp; | |
1460 return TRUE; | |
1461 } | |
1462 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1463 // skip over "s.var" |
7 | 1464 if (*ptr == '.') |
1465 return TRUE; | |
1466 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1467 // two-character item: s->var |
7 | 1468 if (ptr[dir == BACKWARD ? 0 : 1] == '>' |
1469 && ptr[dir == BACKWARD ? -1 : 0] == '-') | |
1470 { | |
1471 *colp += dir; | |
1472 return TRUE; | |
1473 } | |
1474 return FALSE; | |
1475 } | |
1476 | |
1477 /* | |
1478 * Find the identifier under or to the right of the cursor. | |
1479 * "find_type" can have one of three values: | |
1480 * 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
|
1481 * 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
|
1482 * FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred. |
184 | 1483 * FIND_EVAL: find text useful for C program debugging |
7 | 1484 * |
1485 * 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
|
1486 * 1. Search forward for the start of an identifier/text. Doesn't move if |
7 | 1487 * 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
|
1488 * 2. Search backward for the start of this identifier/text. |
7 | 1489 * This doesn't match the real Vi but I like it a little better and it |
1490 * 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
|
1491 * 3. Search forward to the end of this identifier/text. |
7 | 1492 * When FIND_IDENT isn't defined, we backup until a blank. |
1493 * | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1494 * 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
|
1495 * 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
|
1496 * points into the current buffer line and is not always NUL terminated. |
7 | 1497 */ |
1498 int | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1499 find_ident_under_cursor(char_u **text, int find_type) |
7 | 1500 { |
1501 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
|
1502 curwin->w_cursor.col, text, NULL, find_type); |
7 | 1503 } |
1504 | |
1505 /* | |
1506 * Like find_ident_under_cursor(), but for any window and any position. | |
1507 * However: Uses 'iskeyword' from the current window!. | |
1508 */ | |
1509 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1510 find_ident_at_pos( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1511 win_T *wp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1512 linenr_T lnum, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1513 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
|
1514 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
|
1515 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
|
1516 int find_type) |
7 | 1517 { |
1518 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
|
1519 int col = 0; // init to shut up GCC |
7 | 1520 int i; |
1521 int this_class = 0; | |
1522 int prev_class; | |
1523 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
|
1524 int bn = 0; // bracket nesting |
7 | 1525 |
1526 /* | |
1527 * if i == 0: try to find an identifier | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1528 * if i == 1: try to find any non-white text |
7 | 1529 */ |
1530 ptr = ml_get_buf(wp->w_buffer, lnum, FALSE); | |
1531 for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i) | |
1532 { | |
1533 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1534 * 1. skip to start of identifier/text |
7 | 1535 */ |
1536 col = startcol; | |
1537 if (has_mbyte) | |
1538 { | |
1539 while (ptr[col] != NUL) | |
1540 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1541 // Stop at a ']' to evaluate "a[x]". |
7 | 1542 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1543 break; | |
1544 this_class = mb_get_class(ptr + col); | |
1545 if (this_class != 0 && (i == 1 || this_class != 1)) | |
1546 break; | |
474 | 1547 col += (*mb_ptr2len)(ptr + col); |
7 | 1548 } |
1549 } | |
1550 else | |
1551 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
|
1552 && (i == 0 ? !vim_iswordc(ptr[col]) : VIM_ISWHITE(ptr[col])) |
7 | 1553 && (!(find_type & FIND_EVAL) || ptr[col] != ']') |
1554 ) | |
1555 ++col; | |
1556 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1557 // When starting on a ']' count it, so that we include the '['. |
7 | 1558 bn = ptr[col] == ']'; |
1559 | |
1560 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1561 * 2. Back up to start of identifier/text. |
7 | 1562 */ |
1563 if (has_mbyte) | |
1564 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1565 // Remember class of character under cursor. |
7 | 1566 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1567 this_class = mb_get_class((char_u *)"a"); | |
1568 else | |
1569 this_class = mb_get_class(ptr + col); | |
835 | 1570 while (col > 0 && this_class != 0) |
7 | 1571 { |
1572 prevcol = col - 1 - (*mb_head_off)(ptr, ptr + col - 1); | |
1573 prev_class = mb_get_class(ptr + prevcol); | |
1574 if (this_class != prev_class | |
1575 && (i == 0 | |
1576 || prev_class == 0 | |
1577 || (find_type & FIND_IDENT)) | |
1578 && (!(find_type & FIND_EVAL) | |
1579 || prevcol == 0 | |
1580 || !find_is_eval_item(ptr + prevcol, &prevcol, | |
1581 &bn, BACKWARD)) | |
1582 ) | |
1583 break; | |
1584 col = prevcol; | |
1585 } | |
1586 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1587 // 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
|
1588 // identifier, stop searching. |
7 | 1589 if (this_class > 2) |
1590 this_class = 2; | |
1591 if (!(find_type & FIND_STRING) || this_class == 2) | |
1592 break; | |
1593 } | |
1594 else | |
1595 { | |
1596 while (col > 0 | |
1597 && ((i == 0 | |
1598 ? 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
|
1599 : (!VIM_ISWHITE(ptr[col - 1]) |
7 | 1600 && (!(find_type & FIND_IDENT) |
1601 || !vim_iswordc(ptr[col - 1])))) | |
1602 || ((find_type & FIND_EVAL) | |
1603 && col > 1 | |
1604 && find_is_eval_item(ptr + col - 1, &col, | |
1605 &bn, BACKWARD)) | |
1606 )) | |
1607 --col; | |
1608 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1609 // 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
|
1610 // identifier, stop searching. |
7 | 1611 if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col])) |
1612 break; | |
1613 } | |
1614 } | |
1615 | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1616 if (ptr[col] == NUL || (i == 0 |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1617 && (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col])))) |
7 | 1618 { |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1619 // 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
|
1620 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
|
1621 { |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1622 if (find_type & FIND_STRING) |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1623 emsg(_("E348: No string under cursor")); |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1624 else |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1625 emsg(_(e_noident)); |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1626 } |
7 | 1627 return 0; |
1628 } | |
1629 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
|
1630 *text = ptr; |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1631 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
|
1632 *textcol = col; |
7 | 1633 |
1634 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1635 * 3. Find the end if the identifier/text. |
7 | 1636 */ |
1637 bn = 0; | |
1638 startcol -= col; | |
1639 col = 0; | |
1640 if (has_mbyte) | |
1641 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1642 // Search for point of changing multibyte character class. |
7 | 1643 this_class = mb_get_class(ptr); |
1644 while (ptr[col] != NUL | |
1645 && ((i == 0 ? mb_get_class(ptr + col) == this_class | |
1646 : mb_get_class(ptr + col) != 0) | |
1647 || ((find_type & FIND_EVAL) | |
1648 && col <= (int)startcol | |
1649 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1650 )) | |
474 | 1651 col += (*mb_ptr2len)(ptr + col); |
7 | 1652 } |
1653 else | |
1654 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
|
1655 : (ptr[col] != NUL && !VIM_ISWHITE(ptr[col]))) |
7 | 1656 || ((find_type & FIND_EVAL) |
1657 && col <= (int)startcol | |
1658 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1659 ) | |
1660 ++col; | |
1661 | |
1662 return col; | |
1663 } | |
1664 | |
1665 /* | |
1666 * Prepare for redo of a normal command. | |
1667 */ | |
1668 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1669 prep_redo_cmd(cmdarg_T *cap) |
7 | 1670 { |
1671 prep_redo(cap->oap->regname, cap->count0, | |
1672 NUL, cap->cmdchar, NUL, NUL, cap->nchar); | |
1673 } | |
1674 | |
1675 /* | |
1676 * Prepare for redo of any command. | |
1677 * Note that only the last argument can be a multi-byte char. | |
1678 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1679 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1680 prep_redo( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1681 int regname, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1682 long num, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1683 int cmd1, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1684 int cmd2, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1685 int cmd3, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1686 int cmd4, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1687 int cmd5) |
7 | 1688 { |
1689 ResetRedobuff(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1690 if (regname != 0) // yank from specified buffer |
7 | 1691 { |
1692 AppendCharToRedobuff('"'); | |
1693 AppendCharToRedobuff(regname); | |
1694 } | |
1695 if (num) | |
1696 AppendNumberToRedobuff(num); | |
1697 | |
1698 if (cmd1 != NUL) | |
1699 AppendCharToRedobuff(cmd1); | |
1700 if (cmd2 != NUL) | |
1701 AppendCharToRedobuff(cmd2); | |
1702 if (cmd3 != NUL) | |
1703 AppendCharToRedobuff(cmd3); | |
1704 if (cmd4 != NUL) | |
1705 AppendCharToRedobuff(cmd4); | |
1706 if (cmd5 != NUL) | |
1707 AppendCharToRedobuff(cmd5); | |
1708 } | |
1709 | |
1710 /* | |
1711 * check for operator active and clear it | |
1712 * | |
1713 * return TRUE if operator was active | |
1714 */ | |
1715 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1716 checkclearop(oparg_T *oap) |
7 | 1717 { |
1718 if (oap->op_type == OP_NOP) | |
1719 return FALSE; | |
1720 clearopbeep(oap); | |
1721 return TRUE; | |
1722 } | |
1723 | |
1724 /* | |
1131 | 1725 * Check for operator or Visual active. Clear active operator. |
7 | 1726 * |
1131 | 1727 * Return TRUE if operator or Visual was active. |
7 | 1728 */ |
1729 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1730 checkclearopq(oparg_T *oap) |
7 | 1731 { |
5735 | 1732 if (oap->op_type == OP_NOP && !VIsual_active) |
7 | 1733 return FALSE; |
1734 clearopbeep(oap); | |
1735 return TRUE; | |
1736 } | |
1737 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1738 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1739 clearop(oparg_T *oap) |
7 | 1740 { |
1741 oap->op_type = OP_NOP; | |
1742 oap->regname = 0; | |
1743 oap->motion_force = NUL; | |
1744 oap->use_reg_one = FALSE; | |
1745 } | |
1746 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1747 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1748 clearopbeep(oparg_T *oap) |
7 | 1749 { |
1750 clearop(oap); | |
1751 beep_flush(); | |
1752 } | |
1753 | |
1754 /* | |
1755 * Remove the shift modifier from a special key. | |
1756 */ | |
1757 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1758 unshift_special(cmdarg_T *cap) |
7 | 1759 { |
1760 switch (cap->cmdchar) | |
1761 { | |
1762 case K_S_RIGHT: cap->cmdchar = K_RIGHT; break; | |
1763 case K_S_LEFT: cap->cmdchar = K_LEFT; break; | |
1764 case K_S_UP: cap->cmdchar = K_UP; break; | |
1765 case K_S_DOWN: cap->cmdchar = K_DOWN; break; | |
1766 case K_S_HOME: cap->cmdchar = K_HOME; break; | |
1767 case K_S_END: cap->cmdchar = K_END; break; | |
1768 } | |
1769 cap->cmdchar = simplify_key(cap->cmdchar, &mod_mask); | |
1770 } | |
1771 | |
6979 | 1772 /* |
1773 * If the mode is currently displayed clear the command line or update the | |
1774 * command displayed. | |
1775 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1776 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1777 may_clear_cmdline(void) |
6979 | 1778 { |
1779 if (mode_displayed) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1780 clear_cmdline = TRUE; // unshow visual mode later |
6979 | 1781 #ifdef FEAT_CMDL_INFO |
1782 else | |
1783 clear_showcmd(); | |
1784 #endif | |
1785 } | |
1786 | |
7 | 1787 #if defined(FEAT_CMDL_INFO) || defined(PROTO) |
1788 /* | |
1789 * Routines for displaying a partly typed command | |
1790 */ | |
1791 | |
5735 | 1792 #define SHOWCMD_BUFLEN SHOWCMD_COLS + 1 + 30 |
7 | 1793 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
|
1794 static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd() |
7 | 1795 static int showcmd_is_clear = TRUE; |
1796 static int showcmd_visual = FALSE; | |
1797 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
1798 static void display_showcmd(void); |
7 | 1799 |
1800 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1801 clear_showcmd(void) |
7 | 1802 { |
1803 if (!p_sc) | |
1804 return; | |
1805 | |
1806 if (VIsual_active && !char_avail()) | |
1807 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
1808 int cursor_bot = LT_POS(VIsual, curwin->w_cursor); |
7 | 1809 long lines; |
1810 colnr_T leftcol, rightcol; | |
1811 linenr_T top, bot; | |
1812 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1813 // Show the size of the Visual area. |
1866 | 1814 if (cursor_bot) |
7 | 1815 { |
1816 top = VIsual.lnum; | |
1817 bot = curwin->w_cursor.lnum; | |
1818 } | |
1819 else | |
1820 { | |
1821 top = curwin->w_cursor.lnum; | |
1822 bot = VIsual.lnum; | |
1823 } | |
1824 # ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1825 // Include closed folds as a whole. |
7009 | 1826 (void)hasFolding(top, &top, NULL); |
1827 (void)hasFolding(bot, NULL, &bot); | |
7 | 1828 # endif |
1829 lines = bot - top + 1; | |
1830 | |
1831 if (VIsual_mode == Ctrl_V) | |
1832 { | |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1833 # ifdef FEAT_LINEBREAK |
1866 | 1834 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
|
1835 char_u *saved_w_sbr = curwin->w_p_sbr; |
1866 | 1836 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1837 // Make 'sbr' empty for a moment to get the correct size. |
1866 | 1838 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
|
1839 curwin->w_p_sbr = empty_option; |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1840 # endif |
7 | 1841 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
|
1842 # ifdef FEAT_LINEBREAK |
1866 | 1843 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
|
1844 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
|
1845 # endif |
7 | 1846 sprintf((char *)showcmd_buf, "%ldx%ld", lines, |
1847 (long)(rightcol - leftcol + 1)); | |
1848 } | |
1849 else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) | |
1850 sprintf((char *)showcmd_buf, "%ld", lines); | |
1851 else | |
2324
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1852 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1853 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
|
1854 int l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1855 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
|
1856 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
|
1857 |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1858 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
|
1859 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1860 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
|
1861 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
|
1862 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1863 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1864 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1865 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
|
1866 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
|
1867 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1868 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
|
1869 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1870 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
|
1871 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
|
1872 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1873 ++bytes; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1874 ++chars; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1875 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
|
1876 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1877 bytes += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1878 ++chars; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1879 s += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1880 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1881 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
|
1882 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
|
1883 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1884 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
|
1885 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1886 showcmd_buf[SHOWCMD_COLS] = NUL; // truncate |
7 | 1887 showcmd_visual = TRUE; |
1888 } | |
1889 else | |
1890 { | |
1891 showcmd_buf[0] = NUL; | |
1892 showcmd_visual = FALSE; | |
1893 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1894 // Don't actually display something if there is nothing to clear. |
7 | 1895 if (showcmd_is_clear) |
1896 return; | |
1897 } | |
1898 | |
1899 display_showcmd(); | |
1900 } | |
1901 | |
1902 /* | |
1903 * Add 'c' to string of shown command chars. | |
1904 * Return TRUE if output has been written (and setcursor() has been called). | |
1905 */ | |
1906 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1907 add_to_showcmd(int c) |
7 | 1908 { |
1909 char_u *p; | |
1910 int old_len; | |
1911 int extra_len; | |
1912 int overflow; | |
1913 int i; | |
1914 static int ignore[] = | |
1915 { | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18291
diff
changeset
|
1916 #ifdef FEAT_GUI |
7 | 1917 K_VER_SCROLLBAR, K_HOR_SCROLLBAR, |
1918 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
|
1919 #endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
1920 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
|
1921 K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE, |
7 | 1922 K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE, |
1923 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
|
1924 K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT, |
7 | 1925 K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE, |
631 | 1926 K_CURSORHOLD, |
7 | 1927 0 |
1928 }; | |
1929 | |
641 | 1930 if (!p_sc || msg_silent != 0) |
7 | 1931 return FALSE; |
1932 | |
1933 if (showcmd_visual) | |
1934 { | |
1935 showcmd_buf[0] = NUL; | |
1936 showcmd_visual = FALSE; | |
1937 } | |
1938 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1939 // Ignore keys that are scrollbar updates and mouse clicks |
7 | 1940 if (IS_SPECIAL(c)) |
1941 for (i = 0; ignore[i] != 0; ++i) | |
1942 if (ignore[i] == c) | |
1943 return FALSE; | |
1944 | |
1945 p = transchar(c); | |
5535 | 1946 if (*p == ' ') |
1947 STRCPY(p, "<20>"); | |
7 | 1948 old_len = (int)STRLEN(showcmd_buf); |
1949 extra_len = (int)STRLEN(p); | |
1950 overflow = old_len + extra_len - SHOWCMD_COLS; | |
1951 if (overflow > 0) | |
1362 | 1952 mch_memmove(showcmd_buf, showcmd_buf + overflow, |
1953 old_len - overflow + 1); | |
7 | 1954 STRCAT(showcmd_buf, p); |
1955 | |
1956 if (char_avail()) | |
1957 return FALSE; | |
1958 | |
1959 display_showcmd(); | |
1960 | |
1961 return TRUE; | |
1962 } | |
1963 | |
1964 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1965 add_to_showcmd_c(int c) |
7 | 1966 { |
1967 if (!add_to_showcmd(c)) | |
1968 setcursor(); | |
1969 } | |
1970 | |
1971 /* | |
1972 * Delete 'len' characters from the end of the shown command. | |
1973 */ | |
1974 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1975 del_from_showcmd(int len) |
7 | 1976 { |
1977 int old_len; | |
1978 | |
1979 if (!p_sc) | |
1980 return; | |
1981 | |
1982 old_len = (int)STRLEN(showcmd_buf); | |
1983 if (len > old_len) | |
1984 len = old_len; | |
1985 showcmd_buf[old_len - len] = NUL; | |
1986 | |
1987 if (!char_avail()) | |
1988 display_showcmd(); | |
1989 } | |
1990 | |
1991 /* | |
1992 * push_showcmd() and pop_showcmd() are used when waiting for the user to type | |
1993 * something and there is a partial mapping. | |
1994 */ | |
1995 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1996 push_showcmd(void) |
7 | 1997 { |
1998 if (p_sc) | |
1999 STRCPY(old_showcmd_buf, showcmd_buf); | |
2000 } | |
2001 | |
2002 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2003 pop_showcmd(void) |
7 | 2004 { |
2005 if (!p_sc) | |
2006 return; | |
2007 | |
2008 STRCPY(showcmd_buf, old_showcmd_buf); | |
2009 | |
2010 display_showcmd(); | |
2011 } | |
2012 | |
2013 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2014 display_showcmd(void) |
7 | 2015 { |
2016 int len; | |
2017 | |
2018 cursor_off(); | |
2019 | |
2020 len = (int)STRLEN(showcmd_buf); | |
2021 if (len == 0) | |
2022 showcmd_is_clear = TRUE; | |
2023 else | |
2024 { | |
2025 screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0); | |
2026 showcmd_is_clear = FALSE; | |
2027 } | |
2028 | |
2029 /* | |
1188 | 2030 * clear the rest of an old message by outputting up to SHOWCMD_COLS |
2031 * spaces | |
7 | 2032 */ |
2033 screen_puts((char_u *)" " + len, (int)Rows - 1, sc_col + len, 0); | |
2034 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2035 setcursor(); // put cursor back where it belongs |
7 | 2036 } |
2037 #endif | |
2038 | |
2039 /* | |
2040 * When "check" is FALSE, prepare for commands that scroll the window. | |
2041 * When "check" is TRUE, take care of scroll-binding after the window has | |
2042 * scrolled. Called from normal_cmd() and edit(). | |
2043 */ | |
2044 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2045 do_check_scrollbind(int check) |
7 | 2046 { |
2047 static win_T *old_curwin = NULL; | |
2048 static linenr_T old_topline = 0; | |
2049 #ifdef FEAT_DIFF | |
2050 static int old_topfill = 0; | |
2051 #endif | |
2052 static buf_T *old_buf = NULL; | |
2053 static colnr_T old_leftcol = 0; | |
2054 | |
2055 if (check && curwin->w_p_scb) | |
2056 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2057 // 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
|
2058 // the values. |
7 | 2059 if (did_syncbind) |
2060 did_syncbind = FALSE; | |
2061 else if (curwin == old_curwin) | |
2062 { | |
2063 /* | |
2064 * Synchronize other windows, as necessary according to | |
2065 * 'scrollbind'. Don't do this after an ":edit" command, except | |
2066 * when 'diff' is set. | |
2067 */ | |
2068 if ((curwin->w_buffer == old_buf | |
2069 #ifdef FEAT_DIFF | |
2070 || curwin->w_p_diff | |
2071 #endif | |
2072 ) | |
2073 && (curwin->w_topline != old_topline | |
2074 #ifdef FEAT_DIFF | |
2075 || curwin->w_topfill != old_topfill | |
2076 #endif | |
2077 || curwin->w_leftcol != old_leftcol)) | |
2078 { | |
2079 check_scrollbind(curwin->w_topline - old_topline, | |
2080 (long)(curwin->w_leftcol - old_leftcol)); | |
2081 } | |
2082 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2083 else if (vim_strchr(p_sbo, 'j')) // jump flag set in 'scrollopt' |
7 | 2084 { |
2085 /* | |
2086 * When switching between windows, make sure that the relative | |
2087 * vertical offset is valid for the new window. The relative | |
2088 * offset is invalid whenever another 'scrollbind' window has | |
2089 * scrolled to a point that would force the current window to | |
2090 * scroll past the beginning or end of its buffer. When the | |
2091 * resync is performed, some of the other 'scrollbind' windows may | |
2092 * need to jump so that the current window's relative position is | |
2093 * visible on-screen. | |
2094 */ | |
2095 check_scrollbind(curwin->w_topline - curwin->w_scbind_pos, 0L); | |
2096 } | |
2097 curwin->w_scbind_pos = curwin->w_topline; | |
2098 } | |
2099 | |
2100 old_curwin = curwin; | |
2101 old_topline = curwin->w_topline; | |
2102 #ifdef FEAT_DIFF | |
2103 old_topfill = curwin->w_topfill; | |
2104 #endif | |
2105 old_buf = curwin->w_buffer; | |
2106 old_leftcol = curwin->w_leftcol; | |
2107 } | |
2108 | |
2109 /* | |
2110 * Synchronize any windows that have "scrollbind" set, based on the | |
2111 * number of rows by which the current window has changed | |
2112 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
2113 */ | |
2114 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2115 check_scrollbind(linenr_T topline_diff, long leftcol_diff) |
7 | 2116 { |
2117 int want_ver; | |
2118 int want_hor; | |
2119 win_T *old_curwin = curwin; | |
2120 buf_T *old_curbuf = curbuf; | |
2121 int old_VIsual_select = VIsual_select; | |
2122 int old_VIsual_active = VIsual_active; | |
2123 colnr_T tgt_leftcol = curwin->w_leftcol; | |
2124 long topline; | |
2125 long y; | |
2126 | |
2127 /* | |
2128 * check 'scrollopt' string for vertical and horizontal scroll options | |
2129 */ | |
2130 want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0); | |
2131 #ifdef FEAT_DIFF | |
2132 want_ver |= old_curwin->w_p_diff; | |
2133 #endif | |
2134 want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0)); | |
2135 | |
2136 /* | |
2137 * loop through the scrollbound windows and scroll accordingly | |
2138 */ | |
2139 VIsual_select = VIsual_active = 0; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
2140 FOR_ALL_WINDOWS(curwin) |
7 | 2141 { |
2142 curbuf = curwin->w_buffer; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2143 // skip original window and windows with 'noscrollbind' |
7 | 2144 if (curwin != old_curwin && curwin->w_p_scb) |
2145 { | |
2146 /* | |
2147 * do the vertical scroll | |
2148 */ | |
2149 if (want_ver) | |
2150 { | |
2151 #ifdef FEAT_DIFF | |
2152 if (old_curwin->w_p_diff && curwin->w_p_diff) | |
2153 { | |
2154 diff_set_topline(old_curwin, curwin); | |
2155 } | |
2156 else | |
2157 #endif | |
2158 { | |
2159 curwin->w_scbind_pos += topline_diff; | |
2160 topline = curwin->w_scbind_pos; | |
2161 if (topline > curbuf->b_ml.ml_line_count) | |
2162 topline = curbuf->b_ml.ml_line_count; | |
2163 if (topline < 1) | |
2164 topline = 1; | |
2165 | |
2166 y = topline - curwin->w_topline; | |
2167 if (y > 0) | |
2168 scrollup(y, FALSE); | |
2169 else | |
2170 scrolldown(-y, FALSE); | |
2171 } | |
2172 | |
2173 redraw_later(VALID); | |
2174 cursor_correct(); | |
2175 curwin->w_redr_status = TRUE; | |
2176 } | |
2177 | |
2178 /* | |
2179 * do the horizontal scroll | |
2180 */ | |
2181 if (want_hor && curwin->w_leftcol != tgt_leftcol) | |
2182 { | |
2183 curwin->w_leftcol = tgt_leftcol; | |
2184 leftcol_changed(); | |
2185 } | |
2186 } | |
2187 } | |
2188 | |
2189 /* | |
2190 * reset current-window | |
2191 */ | |
2192 VIsual_select = old_VIsual_select; | |
2193 VIsual_active = old_VIsual_active; | |
2194 curwin = old_curwin; | |
2195 curbuf = old_curbuf; | |
2196 } | |
2197 | |
2198 /* | |
2199 * Command character that's ignored. | |
2200 * 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
|
2201 * xon/xoff. |
7 | 2202 */ |
2203 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2204 nv_ignore(cmdarg_T *cap) |
7 | 2205 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2206 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
7 | 2207 } |
2208 | |
2209 /* | |
620 | 2210 * Command character that doesn't do anything, but unlike nv_ignore() does |
2211 * start edit(). Used for "startinsert" executed while starting up. | |
2212 */ | |
2213 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2214 nv_nop(cmdarg_T *cap UNUSED) |
620 | 2215 { |
2216 } | |
2217 | |
2218 /* | |
7 | 2219 * Command character doesn't exist. |
2220 */ | |
2221 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2222 nv_error(cmdarg_T *cap) |
7 | 2223 { |
2224 clearopbeep(cap->oap); | |
2225 } | |
2226 | |
2227 /* | |
2228 * <Help> and <F1> commands. | |
2229 */ | |
2230 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2231 nv_help(cmdarg_T *cap) |
7 | 2232 { |
2233 if (!checkclearopq(cap->oap)) | |
2234 ex_help(NULL); | |
2235 } | |
2236 | |
2237 /* | |
2238 * CTRL-A and CTRL-X: Add or subtract from letter or number under cursor. | |
2239 */ | |
2240 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2241 nv_addsub(cmdarg_T *cap) |
7 | 2242 { |
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
|
2243 #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
|
2244 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
|
2245 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
|
2246 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
|
2247 #endif |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2248 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
|
2249 { |
7578
fdae4c496775
commit https://github.com/vim/vim/commit/ef2b5036b3005f1ce15d146dce72379a9834c56d
Christian Brabandt <cb@256bit.org>
parents:
7574
diff
changeset
|
2250 prep_redo_cmd(cap); |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2251 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
|
2252 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
|
2253 cap->oap->op_type = OP_NOP; |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2254 } |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2255 else if (VIsual_active) |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2256 nv_operator(cap); |
6868 | 2257 else |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2258 clearop(cap->oap); |
7 | 2259 } |
2260 | |
2261 /* | |
2262 * CTRL-F, CTRL-B, etc: Scroll page up or down. | |
2263 */ | |
2264 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2265 nv_page(cmdarg_T *cap) |
7 | 2266 { |
2267 if (!checkclearop(cap->oap)) | |
819 | 2268 { |
2269 if (mod_mask & MOD_MASK_CTRL) | |
2270 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2271 // <C-PageUp>: tab page back; <C-PageDown>: tab page forward |
819 | 2272 if (cap->arg == BACKWARD) |
2273 goto_tabpage(-(int)cap->count1); | |
2274 else | |
2275 goto_tabpage((int)cap->count0); | |
2276 } | |
2277 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12467
diff
changeset
|
2278 (void)onepage(cap->arg, cap->count1); |
819 | 2279 } |
7 | 2280 } |
2281 | |
2282 /* | |
2283 * Implementation of "gd" and "gD" command. | |
2284 */ | |
2285 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2286 nv_gd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2287 oparg_T *oap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2288 int nchar, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2289 int thisblock) // 1 for "1gd" and "1gD" |
7 | 2290 { |
2291 int len; | |
503 | 2292 char_u *ptr; |
2293 | |
2294 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
|
2295 || find_decl(ptr, len, nchar == 'd', thisblock, SEARCH_START) |
face93b02af4
commit https://github.com/vim/vim/commit/1538fc34fae3fae39773ca43f6ff52401fce61d8
Christian Brabandt <cb@256bit.org>
parents:
8651
diff
changeset
|
2296 == FAIL) |
503 | 2297 clearopbeep(oap); |
2298 #ifdef FEAT_FOLDING | |
2299 else if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) | |
2300 foldOpenCursor(); | |
2301 #endif | |
2302 } | |
2303 | |
2304 /* | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2305 * 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
|
2306 * otherwise. |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2307 */ |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2308 static int |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2309 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
|
2310 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2311 int i; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2312 int incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2313 int instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2314 int prev = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2315 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2316 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
|
2317 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2318 if (instring != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2319 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2320 if (prev != '\\' && line[i] == instring) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2321 instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2322 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2323 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
|
2324 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2325 instring = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2326 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2327 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2328 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2329 if (incomment) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2330 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2331 if (prev == '*' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2332 incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2333 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2334 else if (prev == '/' && line[i] == '*') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2335 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2336 incomment = TRUE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2337 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2338 else if (prev == '/' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2339 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2340 return FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2341 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2342 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2343 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2344 prev = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2345 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2346 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2347 return incomment == FALSE && instring == 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2348 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2349 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2350 /* |
523 | 2351 * Search for variable declaration of "ptr[len]". |
2352 * When "locally" is TRUE in the current function ("gd"), otherwise in the | |
2353 * current file ("gD"). | |
2354 * When "thisblock" is TRUE check the {} block scope. | |
503 | 2355 * Return FAIL when not found. |
2356 */ | |
2357 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2358 find_decl( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2359 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2360 int len, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2361 int locally, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2362 int thisblock, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2363 int flags_arg) // flags passed to searchit() |
503 | 2364 { |
7 | 2365 char_u *pat; |
2366 pos_T old_pos; | |
503 | 2367 pos_T par_pos; |
2368 pos_T found_pos; | |
7 | 2369 int t; |
2370 int save_p_ws; | |
2371 int save_p_scs; | |
503 | 2372 int retval = OK; |
944 | 2373 int incll; |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2374 int searchflags = flags_arg; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2375 int valid; |
503 | 2376 |
2377 if ((pat = alloc(len + 7)) == NULL) | |
2378 return FAIL; | |
268 | 2379 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2380 // 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
|
2381 // and "~" causes trouble. |
268 | 2382 sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", |
2383 len, ptr); | |
7 | 2384 old_pos = curwin->w_cursor; |
2385 save_p_ws = p_ws; | |
2386 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
|
2387 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
|
2388 p_scs = FALSE; // don't switch ignorecase off now |
7 | 2389 |
2390 /* | |
2391 * With "gD" go to line 1. | |
2392 * With "gd" Search back for the start of the current function, then go | |
2393 * back until a blank line. If this fails go to line 1. | |
2394 */ | |
944 | 2395 if (!locally || !findpar(&incll, BACKWARD, 1L, '{', FALSE)) |
7 | 2396 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2397 setpcmark(); // Set in findpar() otherwise |
7 | 2398 curwin->w_cursor.lnum = 1; |
539 | 2399 par_pos = curwin->w_cursor; |
7 | 2400 } |
2401 else | |
2402 { | |
539 | 2403 par_pos = curwin->w_cursor; |
7 | 2404 while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL) |
2405 --curwin->w_cursor.lnum; | |
2406 } | |
2407 curwin->w_cursor.col = 0; | |
2408 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2409 // 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
|
2410 CLEAR_POS(&found_pos); |
503 | 2411 for (;;) |
2412 { | |
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
|
2413 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
|
2414 pat, 1L, searchflags, RE_LAST, NULL); |
503 | 2415 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
|
2416 t = FAIL; // match after start is failure too |
523 | 2417 |
718 | 2418 if (thisblock && t != FAIL) |
523 | 2419 { |
2420 pos_T *pos; | |
2421 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2422 // 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
|
2423 // position where we started the search from. |
523 | 2424 if ((pos = findmatchlimit(NULL, '}', FM_FORWARD, |
2425 (int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL | |
2426 && pos->lnum < old_pos.lnum) | |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2427 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2428 // 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
|
2429 // Skip to the end. |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2430 curwin->w_cursor = *pos; |
523 | 2431 continue; |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2432 } |
523 | 2433 } |
2434 | |
503 | 2435 if (t == FAIL) |
2436 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2437 // If we previously found a valid position, use it. |
503 | 2438 if (found_pos.lnum != 0) |
2439 { | |
2440 curwin->w_cursor = found_pos; | |
2441 t = OK; | |
2442 } | |
2443 break; | |
2444 } | |
3562 | 2445 if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0) |
503 | 2446 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2447 // Ignore this line, continue at start of next line. |
503 | 2448 ++curwin->w_cursor.lnum; |
2449 curwin->w_cursor.col = 0; | |
2450 continue; | |
2451 } | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2452 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
|
2453 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2454 // 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
|
2455 // 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
|
2456 if (!valid && found_pos.lnum != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2457 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2458 curwin->w_cursor = found_pos; |
503 | 2459 break; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2460 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2461 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2462 // 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
|
2463 if (valid && !locally) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2464 break; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2465 if (valid && curwin->w_cursor.lnum >= par_pos.lnum) |
503 | 2466 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2467 // If we previously found a valid position, use it. |
503 | 2468 if (found_pos.lnum != 0) |
2469 curwin->w_cursor = found_pos; | |
2470 break; | |
2471 } | |
2472 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2473 // 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
|
2474 // 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
|
2475 // 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
|
2476 if (!valid) |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
2477 CLEAR_POS(&found_pos); |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2478 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2479 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
|
2480 // 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
|
2481 // position. |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2482 searchflags &= ~SEARCH_START; |
503 | 2483 } |
2484 | |
2485 if (t == FAIL) | |
2486 { | |
2487 retval = FAIL; | |
7 | 2488 curwin->w_cursor = old_pos; |
2489 } | |
2490 else | |
2491 { | |
2492 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
|
2493 // "n" searches forward now |
7 | 2494 reset_search_dir(); |
2495 } | |
2496 | |
2497 vim_free(pat); | |
2498 p_ws = save_p_ws; | |
2499 p_scs = save_p_scs; | |
503 | 2500 |
2501 return retval; | |
7 | 2502 } |
2503 | |
2504 /* | |
2505 * Move 'dist' lines in direction 'dir', counting lines by *screen* | |
2506 * lines rather than lines in the file. | |
2507 * 'dist' must be positive. | |
2508 * | |
2509 * Return OK if able to move cursor, FAIL otherwise. | |
2510 */ | |
2511 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2512 nv_screengo(oparg_T *oap, int dir, long dist) |
7 | 2513 { |
2514 int linelen = linetabsize(ml_get_curline()); | |
2515 int retval = OK; | |
2516 int atend = FALSE; | |
2517 int n; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2518 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
|
2519 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
|
2520 int width1; // text width for first screen line |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2521 int width2; // test width for wrapped screen line |
7 | 2522 |
2523 oap->motion_type = MCHAR; | |
5192
c28202427d71
updated for version 7.4a.022
Bram Moolenaar <bram@vim.org>
parents:
5162
diff
changeset
|
2524 oap->inclusive = (curwin->w_curswant == MAXCOL); |
7 | 2525 |
2526 col_off1 = curwin_col_off(); | |
2527 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
|
2528 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
|
2529 width2 = curwin->w_width - col_off2; |
6559 | 2530 if (width2 == 0) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2531 width2 = 1; // avoid divide by zero |
7 | 2532 |
2533 if (curwin->w_width != 0) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2534 { |
7 | 2535 /* |
2536 * Instead of sticking at the last character of the buffer line we | |
2537 * try to stick in the last column of the screen. | |
2538 */ | |
2539 if (curwin->w_curswant == MAXCOL) | |
2540 { | |
2541 atend = TRUE; | |
2542 validate_virtcol(); | |
2543 if (width1 <= 0) | |
2544 curwin->w_curswant = 0; | |
2545 else | |
2546 { | |
2547 curwin->w_curswant = width1 - 1; | |
2548 if (curwin->w_virtcol > curwin->w_curswant) | |
2549 curwin->w_curswant += ((curwin->w_virtcol | |
2550 - curwin->w_curswant - 1) / width2 + 1) * width2; | |
2551 } | |
2552 } | |
2553 else | |
2554 { | |
2555 if (linelen > width1) | |
2556 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2557 else | |
2558 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
|
2559 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
|
2560 curwin->w_curswant = n - 1; |
7 | 2561 } |
2562 | |
2563 while (dist--) | |
2564 { | |
2565 if (dir == BACKWARD) | |
2566 { | |
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
|
2567 if ((long)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
|
2568 // 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
|
2569 // 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
|
2570 // which will get clipped to column 0. |
7 | 2571 curwin->w_curswant -= width2; |
2572 else | |
2573 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2574 // 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
|
2575 #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
|
2576 // 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
|
2577 // '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
|
2578 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
|
2579 (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
|
2580 &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
|
2581 #endif |
7 | 2582 if (curwin->w_cursor.lnum == 1) |
2583 { | |
2584 retval = FAIL; | |
2585 break; | |
2586 } | |
2587 --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
|
2588 |
7 | 2589 linelen = linetabsize(ml_get_curline()); |
2590 if (linelen > width1) | |
2591 curwin->w_curswant += (((linelen - width1 - 1) / width2) | |
2592 + 1) * width2; | |
2593 } | |
2594 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2595 else // dir == FORWARD |
7 | 2596 { |
2597 if (linelen > width1) | |
2598 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2599 else | |
2600 n = width1; | |
2601 if (curwin->w_curswant + width2 < (colnr_T)n) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2602 // move forward within line |
7 | 2603 curwin->w_curswant += width2; |
2604 else | |
2605 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2606 // to next line |
7 | 2607 #ifdef FEAT_FOLDING |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2608 // Move to the end of a closed fold. |
7 | 2609 (void)hasFolding(curwin->w_cursor.lnum, NULL, |
2610 &curwin->w_cursor.lnum); | |
2611 #endif | |
2612 if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) | |
2613 { | |
2614 retval = FAIL; | |
2615 break; | |
2616 } | |
2617 curwin->w_cursor.lnum++; | |
2618 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
|
2619 // 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
|
2620 // 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
|
2621 // 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
|
2622 // 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
|
2623 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
|
2624 curwin->w_curswant -= width2; |
2911 | 2625 linelen = linetabsize(ml_get_curline()); |
7 | 2626 } |
2627 } | |
2628 } | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2629 } |
7 | 2630 |
5600 | 2631 if (virtual_active() && atend) |
2632 coladvance(MAXCOL); | |
2633 else | |
2634 coladvance(curwin->w_curswant); | |
7 | 2635 |
2636 if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) | |
2637 { | |
6178 | 2638 colnr_T virtcol; |
2639 | |
7 | 2640 /* |
2641 * Check for landing on a character that got split at the end of the | |
2642 * last line. We want to advance a screenline, not end up in the same | |
2643 * screenline or move two screenlines. | |
2644 */ | |
2645 validate_virtcol(); | |
6178 | 2646 virtcol = curwin->w_virtcol; |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2647 #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
|
2648 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
|
2649 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
|
2650 #endif |
6178 | 2651 |
2652 if (virtcol > curwin->w_curswant | |
7 | 2653 && (curwin->w_curswant < (colnr_T)width1 |
2654 ? (curwin->w_curswant > (colnr_T)width1 / 2) | |
2655 : ((curwin->w_curswant - width1) % width2 | |
2656 > (colnr_T)width2 / 2))) | |
2657 --curwin->w_cursor.col; | |
2658 } | |
2659 | |
2660 if (atend) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2661 curwin->w_curswant = MAXCOL; // stick in the last column |
7 | 2662 |
2663 return retval; | |
2664 } | |
2665 | |
2666 /* | |
2667 * Handle CTRL-E and CTRL-Y commands: scroll a line up or down. | |
2668 * cap->arg must be TRUE for CTRL-E. | |
2669 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
2670 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2671 nv_scroll_line(cmdarg_T *cap) |
7 | 2672 { |
2673 if (!checkclearop(cap->oap)) | |
2674 scroll_redraw(cap->arg, cap->count1); | |
2675 } | |
2676 | |
2677 /* | |
2678 * Scroll "count" lines up or down, and redraw. | |
2679 */ | |
2680 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2681 scroll_redraw(int up, long count) |
7 | 2682 { |
2683 linenr_T prev_topline = curwin->w_topline; | |
2684 #ifdef FEAT_DIFF | |
2685 int prev_topfill = curwin->w_topfill; | |
2686 #endif | |
2687 linenr_T prev_lnum = curwin->w_cursor.lnum; | |
2688 | |
2689 if (up) | |
2690 scrollup(count, TRUE); | |
2691 else | |
2692 scrolldown(count, TRUE); | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2693 if (get_scrolloff_value()) |
7 | 2694 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2695 // 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
|
2696 // valid, otherwise the screen jumps back at the end of the file. |
7 | 2697 cursor_correct(); |
2698 check_cursor_moved(curwin); | |
2699 curwin->w_valid |= VALID_TOPLINE; | |
2700 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2701 // 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
|
2702 // 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
|
2703 // first line of the buffer is already on the screen |
7 | 2704 while (curwin->w_topline == prev_topline |
2705 #ifdef FEAT_DIFF | |
2706 && curwin->w_topfill == prev_topfill | |
2707 #endif | |
2708 ) | |
2709 { | |
2710 if (up) | |
2711 { | |
2712 if (curwin->w_cursor.lnum > prev_lnum | |
2713 || cursor_down(1L, FALSE) == FAIL) | |
2714 break; | |
2715 } | |
2716 else | |
2717 { | |
2718 if (curwin->w_cursor.lnum < prev_lnum | |
2719 || prev_topline == 1L | |
2720 || cursor_up(1L, FALSE) == FAIL) | |
2721 break; | |
2722 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2723 // 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
|
2724 // end of the file. |
7 | 2725 check_cursor_moved(curwin); |
2726 curwin->w_valid |= VALID_TOPLINE; | |
2727 } | |
2728 } | |
2729 if (curwin->w_cursor.lnum != prev_lnum) | |
2730 coladvance(curwin->w_curswant); | |
2731 redraw_later(VALID); | |
2732 } | |
2733 | |
2734 /* | |
2735 * Commands that start with "z". | |
2736 */ | |
2737 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2738 nv_zet(cmdarg_T *cap) |
7 | 2739 { |
2740 long n; | |
2741 colnr_T col; | |
2742 int nchar = cap->nchar; | |
2743 #ifdef FEAT_FOLDING | |
2744 long old_fdl = curwin->w_p_fdl; | |
2745 int old_fen = curwin->w_p_fen; | |
2746 #endif | |
737 | 2747 #ifdef FEAT_SPELL |
710 | 2748 int undo = FALSE; |
2749 #endif | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15697
diff
changeset
|
2750 long siso = get_sidescrolloff_value(); |
7 | 2751 |
2752 if (VIM_ISDIGIT(nchar)) | |
2753 { | |
2754 /* | |
2755 * "z123{nchar}": edit the count before obtaining {nchar} | |
2756 */ | |
2757 if (checkclearop(cap->oap)) | |
2758 return; | |
2759 n = nchar - '0'; | |
2760 for (;;) | |
2761 { | |
2762 #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
|
2763 dont_scroll = TRUE; // disallow scrolling here |
7 | 2764 #endif |
2765 ++no_mapping; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2766 ++allow_keys; // no mapping for nchar, but allow key codes |
1389 | 2767 nchar = plain_vgetc(); |
7 | 2768 LANGMAP_ADJUST(nchar, TRUE); |
2769 --no_mapping; | |
2770 --allow_keys; | |
2771 #ifdef FEAT_CMDL_INFO | |
2772 (void)add_to_showcmd(nchar); | |
2773 #endif | |
2774 if (nchar == K_DEL || nchar == K_KDEL) | |
2775 n /= 10; | |
2776 else if (VIM_ISDIGIT(nchar)) | |
2777 n = n * 10 + (nchar - '0'); | |
2778 else if (nchar == CAR) | |
2779 { | |
2780 #ifdef FEAT_GUI | |
2781 need_mouse_correct = TRUE; | |
2782 #endif | |
2783 win_setheight((int)n); | |
2784 break; | |
2785 } | |
2786 else if (nchar == 'l' | |
2787 || nchar == 'h' | |
2788 || nchar == K_LEFT | |
229 | 2789 || nchar == K_RIGHT) |
7 | 2790 { |
2791 cap->count1 = n ? n * cap->count1 : cap->count1; | |
2792 goto dozet; | |
2793 } | |
2794 else | |
2795 { | |
2796 clearopbeep(cap->oap); | |
2797 break; | |
2798 } | |
2799 } | |
2800 cap->oap->op_type = OP_NOP; | |
2801 return; | |
2802 } | |
2803 | |
2804 dozet: | |
2805 if ( | |
2806 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2807 // "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
|
2808 // 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
|
2809 // commands. |
7 | 2810 cap->nchar != 'f' && cap->nchar != 'F' |
2811 && !(VIsual_active && vim_strchr((char_u *)"dcCoO", cap->nchar)) | |
2812 && cap->nchar != 'j' && cap->nchar != 'k' | |
2813 && | |
2814 #endif | |
2815 checkclearop(cap->oap)) | |
2816 return; | |
2817 | |
2818 /* | |
2819 * For "z+", "z<CR>", "zt", "z.", "zz", "z^", "z-", "zb": | |
2820 * If line number given, set cursor. | |
2821 */ | |
2822 if ((vim_strchr((char_u *)"+\r\nt.z^-b", nchar) != NULL) | |
2823 && cap->count0 | |
2824 && cap->count0 != curwin->w_cursor.lnum) | |
2825 { | |
2826 setpcmark(); | |
2827 if (cap->count0 > curbuf->b_ml.ml_line_count) | |
2828 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2829 else | |
2830 curwin->w_cursor.lnum = cap->count0; | |
22 | 2831 check_cursor_col(); |
7 | 2832 } |
2833 | |
2834 switch (nchar) | |
2835 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2836 // "z+", "z<CR>" and "zt": put cursor at top of screen |
7 | 2837 case '+': |
2838 if (cap->count0 == 0) | |
2839 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2840 // 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
|
2841 validate_botline(); // make sure w_botline is valid |
7 | 2842 if (curwin->w_botline > curbuf->b_ml.ml_line_count) |
2843 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2844 else | |
2845 curwin->w_cursor.lnum = curwin->w_botline; | |
2846 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2847 // FALLTHROUGH |
7 | 2848 case NL: |
2849 case CAR: | |
2850 case K_KENTER: | |
2851 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
|
2852 // FALLTHROUGH |
7 | 2853 |
2854 case 't': scroll_cursor_top(0, TRUE); | |
2855 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2856 set_fraction(curwin); |
7 | 2857 break; |
2858 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2859 // "z." and "zz": put cursor in middle of screen |
7 | 2860 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
|
2861 // FALLTHROUGH |
7 | 2862 |
2863 case 'z': scroll_cursor_halfway(TRUE); | |
2864 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2865 set_fraction(curwin); |
7 | 2866 break; |
2867 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2868 // "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
|
2869 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
|
2870 // 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
|
2871 // bottom of window. |
7 | 2872 if (cap->count0 != 0) |
2873 { | |
2874 scroll_cursor_bot(0, TRUE); | |
2875 curwin->w_cursor.lnum = curwin->w_topline; | |
2876 } | |
2877 else if (curwin->w_topline == 1) | |
2878 curwin->w_cursor.lnum = 1; | |
2879 else | |
2880 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
|
2881 // FALLTHROUGH |
7 | 2882 case '-': |
2883 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
|
2884 // FALLTHROUGH |
7 | 2885 |
2886 case 'b': scroll_cursor_bot(0, TRUE); | |
2887 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2888 set_fraction(curwin); |
7 | 2889 break; |
2890 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2891 // "zH" - scroll screen right half-page |
7 | 2892 case 'H': |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2893 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
|
2894 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2895 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2896 // "zh" - scroll screen to the right |
7 | 2897 case 'h': |
2898 case K_LEFT: | |
2899 if (!curwin->w_p_wrap) | |
2900 { | |
2901 if ((colnr_T)cap->count1 > curwin->w_leftcol) | |
2902 curwin->w_leftcol = 0; | |
2903 else | |
2904 curwin->w_leftcol -= (colnr_T)cap->count1; | |
2905 leftcol_changed(); | |
2906 } | |
2907 break; | |
2908 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2909 // "zL" - scroll screen left half-page |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2910 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
|
2911 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2912 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2913 // "zl" - scroll screen to the left |
7 | 2914 case 'l': |
2915 case K_RIGHT: | |
2916 if (!curwin->w_p_wrap) | |
2917 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2918 // scroll the window left |
7 | 2919 curwin->w_leftcol += (colnr_T)cap->count1; |
2920 leftcol_changed(); | |
2921 } | |
2922 break; | |
2923 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2924 // "zs" - scroll screen, cursor at the start |
7 | 2925 case 's': if (!curwin->w_p_wrap) |
2926 { | |
2927 #ifdef FEAT_FOLDING | |
2928 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
|
2929 col = 0; // like the cursor is in col 0 |
7 | 2930 else |
2931 #endif | |
2932 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
|
2933 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
|
2934 col -= siso; |
7 | 2935 else |
2936 col = 0; | |
2937 if (curwin->w_leftcol != col) | |
2938 { | |
2939 curwin->w_leftcol = col; | |
2940 redraw_later(NOT_VALID); | |
2941 } | |
2942 } | |
2943 break; | |
2944 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2945 // "ze" - scroll screen, cursor at the end |
7 | 2946 case 'e': if (!curwin->w_p_wrap) |
2947 { | |
2948 #ifdef FEAT_FOLDING | |
2949 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
|
2950 col = 0; // like the cursor is in col 0 |
7 | 2951 else |
2952 #endif | |
2953 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
|
2954 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
|
2955 if ((long)col + siso < n) |
7 | 2956 col = 0; |
2957 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
|
2958 col = col + siso - n + 1; |
7 | 2959 if (curwin->w_leftcol != col) |
2960 { | |
2961 curwin->w_leftcol = col; | |
2962 redraw_later(NOT_VALID); | |
2963 } | |
2964 } | |
2965 break; | |
2966 | |
2967 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2968 // "zF": create fold command |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2969 // "zf": create fold operator |
7 | 2970 case 'F': |
2971 case 'f': if (foldManualAllowed(TRUE)) | |
2972 { | |
2973 cap->nchar = 'f'; | |
2974 nv_operator(cap); | |
2975 curwin->w_p_fen = TRUE; | |
2976 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2977 // "zF" is like "zfzf" |
7 | 2978 if (nchar == 'F' && cap->oap->op_type == OP_FOLD) |
2979 { | |
2980 nv_operator(cap); | |
2981 finish_op = TRUE; | |
2982 } | |
2983 } | |
2984 else | |
2985 clearopbeep(cap->oap); | |
2986 break; | |
2987 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2988 // "zd": delete fold at cursor |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2989 // "zD": delete fold at cursor recursively |
7 | 2990 case 'd': |
2991 case 'D': if (foldManualAllowed(FALSE)) | |
2992 { | |
2993 if (VIsual_active) | |
2994 nv_operator(cap); | |
2995 else | |
2996 deleteFold(curwin->w_cursor.lnum, | |
2997 curwin->w_cursor.lnum, nchar == 'D', FALSE); | |
2998 } | |
2999 break; | |
3000 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3001 // "zE": erase all folds |
7 | 3002 case 'E': if (foldmethodIsManual(curwin)) |
3003 { | |
3004 clearFolding(curwin); | |
3005 changed_window_setting(); | |
3006 } | |
3007 else if (foldmethodIsMarker(curwin)) | |
3008 deleteFold((linenr_T)1, curbuf->b_ml.ml_line_count, | |
3009 TRUE, FALSE); | |
3010 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
3011 emsg(_("E352: Cannot erase folds with current 'foldmethod'")); |
7 | 3012 break; |
3013 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3014 // "zn": fold none: reset 'foldenable' |
7 | 3015 case 'n': curwin->w_p_fen = FALSE; |
3016 break; | |
3017 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3018 // "zN": fold Normal: set 'foldenable' |
7 | 3019 case 'N': curwin->w_p_fen = TRUE; |
3020 break; | |
3021 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3022 // "zi": invert folding: toggle 'foldenable' |
7 | 3023 case 'i': curwin->w_p_fen = !curwin->w_p_fen; |
3024 break; | |
3025 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3026 // "za": open closed fold or close open fold at cursor |
7 | 3027 case 'a': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
3028 openFold(curwin->w_cursor.lnum, cap->count1); | |
3029 else | |
3030 { | |
3031 closeFold(curwin->w_cursor.lnum, cap->count1); | |
3032 curwin->w_p_fen = TRUE; | |
3033 } | |
3034 break; | |
3035 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3036 // "zA": open fold at cursor recursively |
7 | 3037 case 'A': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
3038 openFoldRecurse(curwin->w_cursor.lnum); | |
3039 else | |
3040 { | |
3041 closeFoldRecurse(curwin->w_cursor.lnum); | |
3042 curwin->w_p_fen = TRUE; | |
3043 } | |
3044 break; | |
3045 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3046 // "zo": open fold at cursor or Visual area |
7 | 3047 case 'o': if (VIsual_active) |
3048 nv_operator(cap); | |
3049 else | |
3050 openFold(curwin->w_cursor.lnum, cap->count1); | |
3051 break; | |
3052 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3053 // "zO": open fold recursively |
7 | 3054 case 'O': if (VIsual_active) |
3055 nv_operator(cap); | |
3056 else | |
3057 openFoldRecurse(curwin->w_cursor.lnum); | |
3058 break; | |
3059 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3060 // "zc": close fold at cursor or Visual area |
7 | 3061 case 'c': if (VIsual_active) |
3062 nv_operator(cap); | |
3063 else | |
3064 closeFold(curwin->w_cursor.lnum, cap->count1); | |
3065 curwin->w_p_fen = TRUE; | |
3066 break; | |
3067 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3068 // "zC": close fold recursively |
7 | 3069 case 'C': if (VIsual_active) |
3070 nv_operator(cap); | |
3071 else | |
3072 closeFoldRecurse(curwin->w_cursor.lnum); | |
3073 curwin->w_p_fen = TRUE; | |
3074 break; | |
3075 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3076 // "zv": open folds at the cursor |
7 | 3077 case 'v': foldOpenCursor(); |
3078 break; | |
3079 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3080 // "zx": re-apply 'foldlevel' and open folds at the cursor |
7 | 3081 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
|
3082 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
|
3083 newFoldLevel(); // update right now |
7 | 3084 foldOpenCursor(); |
3085 break; | |
3086 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3087 // "zX": undo manual opens/closes, re-apply 'foldlevel' |
7 | 3088 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
|
3089 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
|
3090 old_fdl = -1; // force an update |
7 | 3091 break; |
3092 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3093 // "zm": fold more |
7 | 3094 case 'm': if (curwin->w_p_fdl > 0) |
6725 | 3095 { |
3096 curwin->w_p_fdl -= cap->count1; | |
3097 if (curwin->w_p_fdl < 0) | |
3098 curwin->w_p_fdl = 0; | |
3099 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3100 old_fdl = -1; // force an update |
7 | 3101 curwin->w_p_fen = TRUE; |
3102 break; | |
3103 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3104 // "zM": close all folds |
7 | 3105 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
|
3106 old_fdl = -1; // force an update |
7 | 3107 curwin->w_p_fen = TRUE; |
3108 break; | |
3109 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3110 // "zr": reduce folding |
6725 | 3111 case 'r': curwin->w_p_fdl += cap->count1; |
3112 { | |
3113 int d = getDeepestNesting(); | |
3114 | |
3115 if (curwin->w_p_fdl >= d) | |
3116 curwin->w_p_fdl = d; | |
3117 } | |
7 | 3118 break; |
3119 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3120 // "zR": open all folds |
7 | 3121 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
|
3122 old_fdl = -1; // force an update |
7 | 3123 break; |
3124 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3125 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
|
3126 case 'k': // "zk" move to next fold upwards |
7 | 3127 if (foldMoveTo(TRUE, nchar == 'j' ? FORWARD : BACKWARD, |
3128 cap->count1) == FAIL) | |
3129 clearopbeep(cap->oap); | |
3130 break; | |
3131 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3132 #endif // FEAT_FOLDING |
7 | 3133 |
737 | 3134 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3135 case 'u': // "zug" and "zuw": undo "zg" and "zw" |
710 | 3136 ++no_mapping; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3137 ++allow_keys; // no mapping for nchar, but allow key codes |
1389 | 3138 nchar = plain_vgetc(); |
710 | 3139 LANGMAP_ADJUST(nchar, TRUE); |
3140 --no_mapping; | |
3141 --allow_keys; | |
3142 #ifdef FEAT_CMDL_INFO | |
3143 (void)add_to_showcmd(nchar); | |
3144 #endif | |
3145 if (vim_strchr((char_u *)"gGwW", nchar) == NULL) | |
3146 { | |
3147 clearopbeep(cap->oap); | |
3148 break; | |
3149 } | |
3150 undo = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3151 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3152 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3153 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
|
3154 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
|
3155 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
|
3156 case 'W': // "zW": add wrong word to temp word list |
310 | 3157 { |
3158 char_u *ptr = NULL; | |
3159 int len; | |
3160 | |
3161 if (checkclearop(cap->oap)) | |
3162 break; | |
3163 if (VIsual_active && get_visual_text(cap, &ptr, &len) | |
3164 == FAIL) | |
3165 return; | |
501 | 3166 if (ptr == NULL) |
3167 { | |
3168 pos_T pos = curwin->w_cursor; | |
3169 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3170 // Find bad word under the cursor. When 'spell' is |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3171 // off this fails and find_ident_under_cursor() is |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3172 // used below. |
5374 | 3173 emsg_off++; |
534 | 3174 len = spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL); |
5374 | 3175 emsg_off--; |
501 | 3176 if (len != 0 && curwin->w_cursor.col <= pos.col) |
3177 ptr = ml_get_pos(&curwin->w_cursor); | |
3178 curwin->w_cursor = pos; | |
3179 } | |
3180 | |
310 | 3181 if (ptr == NULL && (len = find_ident_under_cursor(&ptr, |
3182 FIND_IDENT)) == 0) | |
3183 return; | |
17682
3dbff5d37520
patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3184 spell_add_word(ptr, len, nchar == 'w' || nchar == 'W' |
3dbff5d37520
patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3185 ? SPELL_ADD_BAD : SPELL_ADD_GOOD, |
710 | 3186 (nchar == 'G' || nchar == 'W') |
3187 ? 0 : (int)cap->count1, | |
3188 undo); | |
310 | 3189 } |
316 | 3190 break; |
323 | 3191 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3192 case '=': // "z=": suggestions for a badly spelled word |
638 | 3193 if (!checkclearop(cap->oap)) |
485 | 3194 spell_suggest((int)cap->count0); |
323 | 3195 break; |
310 | 3196 #endif |
3197 | |
7 | 3198 default: clearopbeep(cap->oap); |
3199 } | |
3200 | |
3201 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3202 // Redraw when 'foldenable' changed |
7 | 3203 if (old_fen != curwin->w_p_fen) |
3204 { | |
3205 # ifdef FEAT_DIFF | |
3206 win_T *wp; | |
3207 | |
3208 if (foldmethodIsDiff(curwin) && curwin->w_p_scb) | |
3209 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3210 // Adjust 'foldenable' in diff-synced windows. |
7 | 3211 FOR_ALL_WINDOWS(wp) |
3212 { | |
3213 if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) | |
3214 { | |
3215 wp->w_p_fen = curwin->w_p_fen; | |
3216 changed_window_setting_win(wp); | |
3217 } | |
3218 } | |
3219 } | |
3220 # endif | |
3221 changed_window_setting(); | |
3222 } | |
3223 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3224 // Redraw when 'foldlevel' changed. |
7 | 3225 if (old_fdl != curwin->w_p_fdl) |
3226 newFoldLevel(); | |
3227 #endif | |
3228 } | |
3229 | |
3230 #ifdef FEAT_GUI | |
3231 /* | |
3232 * Vertical scrollbar movement. | |
3233 */ | |
3234 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3235 nv_ver_scrollbar(cmdarg_T *cap) |
7 | 3236 { |
3237 if (cap->oap->op_type != OP_NOP) | |
3238 clearopbeep(cap->oap); | |
3239 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3240 // Even if an operator was pending, we still want to scroll |
7 | 3241 gui_do_scroll(); |
3242 } | |
3243 | |
3244 /* | |
3245 * Horizontal scrollbar movement. | |
3246 */ | |
3247 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3248 nv_hor_scrollbar(cmdarg_T *cap) |
7 | 3249 { |
3250 if (cap->oap->op_type != OP_NOP) | |
3251 clearopbeep(cap->oap); | |
3252 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3253 // Even if an operator was pending, we still want to scroll |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3254 gui_do_horiz_scroll(scrollbar_value, FALSE); |
7 | 3255 } |
3256 #endif | |
3257 | |
690 | 3258 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
685 | 3259 /* |
3260 * Click in GUI tab. | |
3261 */ | |
3262 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3263 nv_tabline(cmdarg_T *cap) |
685 | 3264 { |
3265 if (cap->oap->op_type != OP_NOP) | |
3266 clearopbeep(cap->oap); | |
3267 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3268 // Even if an operator was pending, we still want to jump tabs. |
685 | 3269 goto_tabpage(current_tab); |
3270 } | |
686 | 3271 |
3272 /* | |
3273 * Selected item in tab line menu. | |
3274 */ | |
3275 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3276 nv_tabmenu(cmdarg_T *cap) |
686 | 3277 { |
3278 if (cap->oap->op_type != OP_NOP) | |
3279 clearopbeep(cap->oap); | |
3280 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3281 // Even if an operator was pending, we still want to jump tabs. |
690 | 3282 handle_tabmenu(); |
3283 } | |
3284 | |
3285 /* | |
3286 * Handle selecting an item of the GUI tab line menu. | |
3287 * Used in Normal and Insert mode. | |
3288 */ | |
3289 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3290 handle_tabmenu(void) |
690 | 3291 { |
686 | 3292 switch (current_tabmenu) |
3293 { | |
3294 case TABLINE_MENU_CLOSE: | |
3295 if (current_tab == 0) | |
3296 do_cmdline_cmd((char_u *)"tabclose"); | |
3297 else | |
3298 { | |
3299 vim_snprintf((char *)IObuff, IOSIZE, "tabclose %d", | |
3300 current_tab); | |
3301 do_cmdline_cmd(IObuff); | |
3302 } | |
3303 break; | |
3304 | |
3305 case TABLINE_MENU_NEW: | |
6631 | 3306 if (current_tab == 0) |
3307 do_cmdline_cmd((char_u *)"$tabnew"); | |
3308 else | |
3309 { | |
3310 vim_snprintf((char *)IObuff, IOSIZE, "%dtabnew", | |
3311 current_tab - 1); | |
3312 do_cmdline_cmd(IObuff); | |
3313 } | |
686 | 3314 break; |
3315 | |
3316 case TABLINE_MENU_OPEN: | |
6631 | 3317 if (current_tab == 0) |
3318 do_cmdline_cmd((char_u *)"browse $tabnew"); | |
3319 else | |
3320 { | |
3321 vim_snprintf((char *)IObuff, IOSIZE, "browse %dtabnew", | |
3322 current_tab - 1); | |
3323 do_cmdline_cmd(IObuff); | |
3324 } | |
686 | 3325 break; |
3326 } | |
3327 } | |
685 | 3328 #endif |
3329 | |
7 | 3330 /* |
3331 * "Q" command. | |
3332 */ | |
3333 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3334 nv_exmode(cmdarg_T *cap) |
7 | 3335 { |
3336 /* | |
3337 * Ignore 'Q' in Visual mode, just give a beep. | |
3338 */ | |
3339 if (VIsual_active) | |
6949 | 3340 vim_beep(BO_EX); |
5735 | 3341 else if (!checkclearop(cap->oap)) |
7 | 3342 do_exmode(FALSE); |
3343 } | |
3344 | |
3345 /* | |
3346 * Handle a ":" command. | |
3347 */ | |
3348 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3349 nv_colon(cmdarg_T *cap) |
7 | 3350 { |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3351 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
|
3352 int cmd_result; |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3353 int is_cmdkey = cap->cmdchar == K_COMMAND; |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3354 |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3355 if (VIsual_active && !is_cmdkey) |
7 | 3356 nv_operator(cap); |
3357 else | |
3358 { | |
3359 if (cap->oap->op_type != OP_NOP) | |
3360 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3361 // Using ":" as a movement is characterwise exclusive. |
7 | 3362 cap->oap->motion_type = MCHAR; |
3363 cap->oap->inclusive = FALSE; | |
3364 } | |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3365 else if (cap->count0 && !is_cmdkey) |
7 | 3366 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3367 // translate "count:" into ":.,.+(count - 1)" |
7 | 3368 stuffcharReadbuff('.'); |
3369 if (cap->count0 > 1) | |
3370 { | |
3371 stuffReadbuff((char_u *)",.+"); | |
3372 stuffnumReadbuff((long)cap->count0 - 1L); | |
3373 } | |
3374 } | |
3375 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3376 // When typing, don't type below an old message |
7 | 3377 if (KeyTyped) |
3378 compute_cmdrow(); | |
3379 | |
3380 old_p_im = p_im; | |
3381 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3382 // get a command line and execute it |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3383 cmd_result = do_cmdline(NULL, is_cmdkey ? getcmdkeycmd : getexline, NULL, |
7 | 3384 cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0); |
3385 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3386 // If 'insertmode' changed, enter or exit Insert mode |
7 | 3387 if (p_im != old_p_im) |
3388 { | |
3389 if (p_im) | |
3390 restart_edit = 'i'; | |
3391 else | |
3392 restart_edit = 0; | |
3393 } | |
3394 | |
4256 | 3395 if (cmd_result == FAIL) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3396 // The Ex command failed, do not execute the operator. |
4256 | 3397 clearop(cap->oap); |
3398 else if (cap->oap->op_type != OP_NOP | |
7 | 3399 && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count |
3400 || cap->oap->start.col > | |
4256 | 3401 (colnr_T)STRLEN(ml_get(cap->oap->start.lnum)) |
3402 || did_emsg | |
3403 )) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3404 // The start of the operator has become invalid by the Ex command. |
7 | 3405 clearopbeep(cap->oap); |
3406 } | |
3407 } | |
3408 | |
3409 /* | |
3410 * Handle CTRL-G command. | |
3411 */ | |
3412 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3413 nv_ctrlg(cmdarg_T *cap) |
7 | 3414 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3415 if (VIsual_active) // toggle Selection/Visual mode |
7 | 3416 { |
3417 VIsual_select = !VIsual_select; | |
3418 showmode(); | |
3419 } | |
5735 | 3420 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
|
3421 // print full name if count given or :cd used |
7 | 3422 fileinfo((int)cap->count0, FALSE, TRUE); |
3423 } | |
3424 | |
3425 /* | |
3426 * Handle CTRL-H <Backspace> command. | |
3427 */ | |
3428 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3429 nv_ctrlh(cmdarg_T *cap) |
7 | 3430 { |
3431 if (VIsual_active && VIsual_select) | |
3432 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3433 cap->cmdchar = 'x'; // BS key behaves like 'x' in Select mode |
7 | 3434 v_visop(cap); |
3435 } | |
3436 else | |
3437 nv_left(cap); | |
3438 } | |
3439 | |
3440 /* | |
3441 * CTRL-L: clear screen and redraw. | |
3442 */ | |
3443 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3444 nv_clear(cmdarg_T *cap) |
7 | 3445 { |
3446 if (!checkclearop(cap->oap)) | |
3447 { | |
3448 #ifdef FEAT_SYN_HL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3449 // 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
|
3450 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
|
3451 # ifdef FEAT_RELTIME |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3452 { |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3453 win_T *wp; |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3454 |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3455 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
|
3456 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
|
3457 } |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3458 # endif |
7 | 3459 #endif |
3460 redraw_later(CLEAR); | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
3461 #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
|
3462 # 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
|
3463 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
|
3464 # 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
|
3465 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
|
3466 #endif |
7 | 3467 } |
3468 } | |
3469 | |
3470 /* | |
3471 * CTRL-O: In Select mode: switch to Visual mode for one command. | |
3472 * Otherwise: Go to older pcmark. | |
3473 */ | |
3474 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3475 nv_ctrlo(cmdarg_T *cap) |
7 | 3476 { |
3477 if (VIsual_active && VIsual_select) | |
3478 { | |
3479 VIsual_select = FALSE; | |
3480 showmode(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3481 restart_VIsual_select = 2; // restart Select mode later |
7 | 3482 } |
3483 else | |
3484 { | |
3485 cap->count1 = -cap->count1; | |
3486 nv_pcmark(cap); | |
3487 } | |
3488 } | |
3489 | |
3490 /* | |
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
|
3491 * 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
|
3492 * not named. |
7 | 3493 */ |
3494 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3495 nv_hat(cmdarg_T *cap) |
7 | 3496 { |
3497 if (!checkclearopq(cap->oap)) | |
3498 (void)buflist_getfile((int)cap->count0, (linenr_T)0, | |
3499 GETF_SETMARK|GETF_ALT, FALSE); | |
3500 } | |
3501 | |
3502 /* | |
3503 * "Z" commands. | |
3504 */ | |
3505 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3506 nv_Zet(cmdarg_T *cap) |
7 | 3507 { |
3508 if (!checkclearopq(cap->oap)) | |
3509 { | |
3510 switch (cap->nchar) | |
3511 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3512 // "ZZ": equivalent to ":x". |
7 | 3513 case 'Z': do_cmdline_cmd((char_u *)"x"); |
3514 break; | |
3515 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3516 // "ZQ": equivalent to ":q!" (Elvis compatible). |
7 | 3517 case 'Q': do_cmdline_cmd((char_u *)"q!"); |
3518 break; | |
3519 | |
3520 default: clearopbeep(cap->oap); | |
3521 } | |
3522 } | |
3523 } | |
3524 | |
3525 /* | |
3526 * Call nv_ident() as if "c1" was used, with "c2" as next character. | |
3527 */ | |
3528 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3529 do_nv_ident(int c1, int c2) |
7 | 3530 { |
3531 oparg_T oa; | |
3532 cmdarg_T ca; | |
3533 | |
3534 clear_oparg(&oa); | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
3535 CLEAR_FIELD(ca); |
7 | 3536 ca.oap = &oa; |
3537 ca.cmdchar = c1; | |
3538 ca.nchar = c2; | |
3539 nv_ident(&ca); | |
3540 } | |
3541 | |
3542 /* | |
3543 * Handle the commands that use the word under the cursor. | |
3544 * [g] CTRL-] :ta to current identifier | |
3545 * [g] 'K' run program for current identifier | |
3546 * [g] '*' / to current identifier or string | |
3547 * [g] '#' ? to current identifier or string | |
3548 * g ']' :tselect for current identifier | |
3549 */ | |
3550 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3551 nv_ident(cmdarg_T *cap) |
7 | 3552 { |
3553 char_u *ptr = NULL; | |
3554 char_u *buf; | |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3555 unsigned buflen; |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3556 char_u *newbuf; |
7 | 3557 char_u *p; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3558 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
|
3559 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
|
3560 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
|
3561 int n = 0; // init for GCC |
7 | 3562 int cmdchar; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3563 int g_cmd; // "g" command |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3564 int tag_cmd = FALSE; |
7 | 3565 char_u *aux_ptr; |
3566 int isman; | |
3567 int isman_s; | |
3568 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3569 if (cap->cmdchar == 'g') // "g*", "g#", "g]" and "gCTRL-]" |
7 | 3570 { |
3571 cmdchar = cap->nchar; | |
3572 g_cmd = TRUE; | |
3573 } | |
3574 else | |
3575 { | |
3576 cmdchar = cap->cmdchar; | |
3577 g_cmd = FALSE; | |
3578 } | |
3579 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3580 if (cmdchar == POUND) // the pound sign, '#' for English keyboards |
7 | 3581 cmdchar = '#'; |
3582 | |
3583 /* | |
3584 * The "]", "CTRL-]" and "K" commands accept an argument in Visual mode. | |
3585 */ | |
3586 if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K') | |
3587 { | |
3588 if (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL) | |
3589 return; | |
3590 if (checkclearopq(cap->oap)) | |
3591 return; | |
3592 } | |
3593 | |
3594 if (ptr == NULL && (n = find_ident_under_cursor(&ptr, | |
3595 (cmdchar == '*' || cmdchar == '#') | |
3596 ? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0) | |
3597 { | |
3598 clearop(cap->oap); | |
3599 return; | |
3600 } | |
3601 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3602 // 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
|
3603 // 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
|
3604 // and some numbers. |
7 | 3605 kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp); |
3606 kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 | |
3607 || 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
|
3608 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
|
3609 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3610 emsg(_(e_noident)); // 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
|
3611 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
|
3612 } |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3613 kp_ex = (*kp == ':'); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3614 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
|
3615 buf = alloc(buflen); |
7 | 3616 if (buf == NULL) |
3617 return; | |
3618 buf[0] = NUL; | |
3619 | |
3620 switch (cmdchar) | |
3621 { | |
3622 case '*': | |
3623 case '#': | |
3624 /* | |
3625 * Put cursor at start of word, makes search skip the word | |
3626 * under the cursor. | |
3627 * Call setpcmark() first, so "*``" puts the cursor back where | |
3628 * it was. | |
3629 */ | |
3630 setpcmark(); | |
3631 curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline()); | |
3632 | |
3633 if (!g_cmd && vim_iswordp(ptr)) | |
3634 STRCPY(buf, "\\<"); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3635 no_smartcase = TRUE; // don't use 'smartcase' now |
7 | 3636 break; |
3637 | |
3638 case 'K': | |
3639 if (kp_help) | |
3640 STRCPY(buf, "he! "); | |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3641 else if (kp_ex) |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3642 { |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3643 if (cap->count0 != 0) |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3644 vim_snprintf((char *)buf, buflen, "%s %ld", |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3645 kp, cap->count0); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3646 else |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3647 STRCPY(buf, kp); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3648 STRCAT(buf, " "); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3649 } |
7 | 3650 else |
3651 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3652 // An external command will probably use an argument starting |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3653 // with "-" as an option. To avoid trouble we skip the "-". |
1728 | 3654 while (*ptr == '-' && n > 0) |
3655 { | |
1712 | 3656 ++ptr; |
1728 | 3657 --n; |
3658 } | |
3659 if (n == 0) | |
3660 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3661 emsg(_(e_noident)); // found dashes only |
1728 | 3662 vim_free(buf); |
3663 return; | |
3664 } | |
1712 | 3665 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3666 // When a count is given, turn it into a range. Is this |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3667 // really what we want? |
7 | 3668 isman = (STRCMP(kp, "man") == 0); |
3669 isman_s = (STRCMP(kp, "man -s") == 0); | |
3670 if (cap->count0 != 0 && !(isman || isman_s)) | |
3671 sprintf((char *)buf, ".,.+%ld", cap->count0 - 1); | |
3672 | |
3673 STRCAT(buf, "! "); | |
3674 if (cap->count0 == 0 && isman_s) | |
3675 STRCAT(buf, "man"); | |
3676 else | |
3677 STRCAT(buf, kp); | |
3678 STRCAT(buf, " "); | |
3679 if (cap->count0 != 0 && (isman || isman_s)) | |
3680 { | |
3681 sprintf((char *)buf + STRLEN(buf), "%ld", cap->count0); | |
3682 STRCAT(buf, " "); | |
3683 } | |
3684 } | |
3685 break; | |
3686 | |
3687 case ']': | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3688 tag_cmd = TRUE; |
7 | 3689 #ifdef FEAT_CSCOPE |
3690 if (p_cst) | |
3691 STRCPY(buf, "cstag "); | |
3692 else | |
3693 #endif | |
3694 STRCPY(buf, "ts "); | |
3695 break; | |
3696 | |
3697 default: | |
2112
6b5d641bcdd4
updated for version 7.2.395
Bram Moolenaar <bram@zimbu.org>
parents:
2049
diff
changeset
|
3698 tag_cmd = TRUE; |
7 | 3699 if (curbuf->b_help) |
3700 STRCPY(buf, "he! "); | |
3701 else | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3702 { |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3703 if (g_cmd) |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3704 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
|
3705 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
|
3706 STRCPY(buf, "ta "); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3707 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
|
3708 sprintf((char *)buf, ":%ldta ", cap->count0); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3709 } |
7 | 3710 } |
3711 | |
3712 /* | |
3713 * Now grab the chars in the identifier | |
3714 */ | |
1712 | 3715 if (cmdchar == 'K' && !kp_help) |
3716 { | |
1728 | 3717 ptr = vim_strnsave(ptr, n); |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3718 if (kp_ex) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3719 // Escape the argument properly for an Ex command |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3720 p = vim_strsave_fnameescape(ptr, FALSE); |
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3721 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3722 // 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
|
3723 p = vim_strsave_shellescape(ptr, TRUE, TRUE); |
1728 | 3724 vim_free(ptr); |
1712 | 3725 if (p == NULL) |
3726 { | |
3727 vim_free(buf); | |
3728 return; | |
3729 } | |
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
|
3730 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
|
3731 if (newbuf == NULL) |
1712 | 3732 { |
3733 vim_free(buf); | |
3734 vim_free(p); | |
3735 return; | |
3736 } | |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3737 buf = newbuf; |
1712 | 3738 STRCAT(buf, p); |
3739 vim_free(p); | |
3740 } | |
7 | 3741 else |
1712 | 3742 { |
3743 if (cmdchar == '*') | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3744 aux_ptr = (char_u *)(magic_isset() ? "/.*~[^$\\" : "/^$\\"); |
1712 | 3745 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
|
3746 aux_ptr = (char_u *)(magic_isset() ? "/?.*~[^$\\" : "/?^$\\"); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3747 else if (tag_cmd) |
2603 | 3748 { |
3749 if (curbuf->b_help) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3750 // ":help" handles unescaped argument |
2603 | 3751 aux_ptr = (char_u *)""; |
3752 else | |
3753 aux_ptr = (char_u *)"\\|\"\n["; | |
3754 } | |
1712 | 3755 else |
3756 aux_ptr = (char_u *)"\\|\"\n*?["; | |
3757 | |
3758 p = buf + STRLEN(buf); | |
3759 while (n-- > 0) | |
3760 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3761 // put a backslash before \ and some others |
1712 | 3762 if (vim_strchr(aux_ptr, *ptr) != NULL) |
3763 *p++ = '\\'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3764 // 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
|
3765 // bytes of that character. |
1712 | 3766 if (has_mbyte) |
3767 { | |
3768 int i; | |
3769 int len = (*mb_ptr2len)(ptr) - 1; | |
3770 | |
3771 for (i = 0; i < len && n >= 1; ++i, --n) | |
3772 *p++ = *ptr++; | |
3773 } | |
3774 *p++ = *ptr++; | |
3775 } | |
3776 *p = NUL; | |
3777 } | |
7 | 3778 |
3779 /* | |
3780 * Execute the command. | |
3781 */ | |
3782 if (cmdchar == '*' || cmdchar == '#') | |
3783 { | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3784 if (!g_cmd && (has_mbyte |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3785 ? 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
|
3786 : vim_iswordc(ptr[-1]))) |
7 | 3787 STRCAT(buf, "\\>"); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3788 |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3789 // put pattern in search history |
2024 | 3790 init_history(); |
7 | 3791 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
|
3792 |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
3793 (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); |
7 | 3794 } |
3795 else | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3796 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3797 g_tag_at_cursor = TRUE; |
7 | 3798 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
|
3799 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
|
3800 } |
7 | 3801 |
3802 vim_free(buf); | |
3803 } | |
3804 | |
3805 /* | |
3806 * Get visually selected text, within one line only. | |
3807 * Returns FAIL if more than one line selected. | |
3808 */ | |
344 | 3809 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3810 get_visual_text( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3811 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3812 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
|
3813 int *lenp) // return: length of selected text |
7 | 3814 { |
3815 if (VIsual_mode != 'V') | |
3816 unadjust_for_sel(); | |
3817 if (VIsual.lnum != curwin->w_cursor.lnum) | |
3818 { | |
344 | 3819 if (cap != NULL) |
3820 clearopbeep(cap->oap); | |
7 | 3821 return FAIL; |
3822 } | |
3823 if (VIsual_mode == 'V') | |
3824 { | |
3825 *pp = ml_get_curline(); | |
3826 *lenp = (int)STRLEN(*pp); | |
3827 } | |
3828 else | |
3829 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3830 if (LT_POS(curwin->w_cursor, VIsual)) |
7 | 3831 { |
3832 *pp = ml_get_pos(&curwin->w_cursor); | |
3833 *lenp = VIsual.col - curwin->w_cursor.col + 1; | |
3834 } | |
3835 else | |
3836 { | |
3837 *pp = ml_get_pos(&VIsual); | |
3838 *lenp = curwin->w_cursor.col - VIsual.col + 1; | |
3839 } | |
3840 if (has_mbyte) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3841 // Correct the length to include the whole last character. |
474 | 3842 *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1; |
7 | 3843 } |
3844 reset_VIsual_and_resel(); | |
3845 return OK; | |
3846 } | |
3847 | |
3848 /* | |
3849 * CTRL-T: backwards in tag stack | |
3850 */ | |
3851 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3852 nv_tagpop(cmdarg_T *cap) |
7 | 3853 { |
3854 if (!checkclearopq(cap->oap)) | |
3855 do_tag((char_u *)"", DT_POP, (int)cap->count1, FALSE, TRUE); | |
3856 } | |
3857 | |
3858 /* | |
3859 * Handle scrolling command 'H', 'L' and 'M'. | |
3860 */ | |
3861 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3862 nv_scroll(cmdarg_T *cap) |
7 | 3863 { |
3864 int used = 0; | |
3865 long n; | |
3866 #ifdef FEAT_FOLDING | |
3867 linenr_T lnum; | |
3868 #endif | |
3869 int half; | |
3870 | |
3871 cap->oap->motion_type = MLINE; | |
3872 setpcmark(); | |
3873 | |
3874 if (cap->cmdchar == 'L') | |
3875 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3876 validate_botline(); // make sure curwin->w_botline is valid |
7 | 3877 curwin->w_cursor.lnum = curwin->w_botline - 1; |
3878 if (cap->count1 - 1 >= curwin->w_cursor.lnum) | |
3879 curwin->w_cursor.lnum = 1; | |
3880 else | |
9 | 3881 { |
3882 #ifdef FEAT_FOLDING | |
3883 if (hasAnyFolding(curwin)) | |
3884 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3885 // Count a fold for one screen line. |
9 | 3886 for (n = cap->count1 - 1; n > 0 |
3887 && curwin->w_cursor.lnum > curwin->w_topline; --n) | |
3888 { | |
3889 (void)hasFolding(curwin->w_cursor.lnum, | |
3890 &curwin->w_cursor.lnum, NULL); | |
3891 --curwin->w_cursor.lnum; | |
3892 } | |
3893 } | |
3894 else | |
3895 #endif | |
3896 curwin->w_cursor.lnum -= cap->count1 - 1; | |
3897 } | |
7 | 3898 } |
3899 else | |
3900 { | |
3901 if (cap->cmdchar == 'M') | |
3902 { | |
3903 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3904 // Don't count filler lines above the window. |
7 | 3905 used -= diff_check_fill(curwin, curwin->w_topline) |
3906 - curwin->w_topfill; | |
3907 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3908 validate_botline(); // make sure w_empty_rows is valid |
7 | 3909 half = (curwin->w_height - curwin->w_empty_rows + 1) / 2; |
3910 for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; ++n) | |
3911 { | |
3912 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3913 // 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
|
3914 // line" and half to be "above the next line". |
7 | 3915 if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline |
3916 + n) / 2 >= half) | |
3917 { | |
3918 --n; | |
3919 break; | |
3920 } | |
3921 #endif | |
3922 used += plines(curwin->w_topline + n); | |
3923 if (used >= half) | |
3924 break; | |
3925 #ifdef FEAT_FOLDING | |
3926 if (hasFolding(curwin->w_topline + n, NULL, &lnum)) | |
3927 n = lnum - curwin->w_topline; | |
3928 #endif | |
3929 } | |
3930 if (n > 0 && used > curwin->w_height) | |
3931 --n; | |
3932 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3933 else // (cap->cmdchar == 'H') |
9 | 3934 { |
7 | 3935 n = cap->count1 - 1; |
9 | 3936 #ifdef FEAT_FOLDING |
3937 if (hasAnyFolding(curwin)) | |
3938 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3939 // Count a fold for one screen line. |
9 | 3940 lnum = curwin->w_topline; |
3941 while (n-- > 0 && lnum < curwin->w_botline - 1) | |
3942 { | |
7009 | 3943 (void)hasFolding(lnum, NULL, &lnum); |
9 | 3944 ++lnum; |
3945 } | |
3946 n = lnum - curwin->w_topline; | |
3947 } | |
3948 #endif | |
3949 } | |
7 | 3950 curwin->w_cursor.lnum = curwin->w_topline + n; |
3951 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
3952 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
3953 } | |
3954 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3955 // 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
|
3956 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
|
3957 cursor_correct(); |
7 | 3958 beginline(BL_SOL | BL_FIX); |
3959 } | |
3960 | |
3961 /* | |
3962 * Cursor right commands. | |
3963 */ | |
3964 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3965 nv_right(cmdarg_T *cap) |
7 | 3966 { |
3967 long n; | |
5735 | 3968 int past_line; |
7 | 3969 |
180 | 3970 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
3971 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3972 // <C-Right> and <S-Right> move a word or WORD right |
180 | 3973 if (mod_mask & MOD_MASK_CTRL) |
3974 cap->arg = TRUE; | |
3975 nv_wordcmd(cap); | |
3976 return; | |
3977 } | |
3978 | |
7 | 3979 cap->oap->motion_type = MCHAR; |
3980 cap->oap->inclusive = FALSE; | |
5735 | 3981 past_line = (VIsual_active && *p_sel != 'o'); |
3982 | |
7 | 3983 /* |
5735 | 3984 * In virtual edit mode, there's no such thing as "past_line", as lines |
3985 * are (theoretically) infinitely long. | |
7 | 3986 */ |
3987 if (virtual_active()) | |
5735 | 3988 past_line = 0; |
7 | 3989 |
3990 for (n = cap->count1; n > 0; --n) | |
3991 { | |
5735 | 3992 if ((!past_line && oneright() == FAIL) |
3993 || (past_line && *ml_get_cursor() == NUL) | |
1877 | 3994 ) |
7 | 3995 { |
3996 /* | |
714 | 3997 * <Space> wraps to next line if 'whichwrap' has 's'. |
3998 * 'l' wraps to next line if 'whichwrap' has 'l'. | |
3999 * CURS_RIGHT wraps to next line if 'whichwrap' has '>'. | |
7 | 4000 */ |
4001 if ( ((cap->cmdchar == ' ' | |
4002 && vim_strchr(p_ww, 's') != NULL) | |
4003 || (cap->cmdchar == 'l' | |
4004 && vim_strchr(p_ww, 'l') != NULL) | |
229 | 4005 || (cap->cmdchar == K_RIGHT |
7 | 4006 && vim_strchr(p_ww, '>') != NULL)) |
4007 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
4008 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4009 // 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
|
4010 // 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
|
4011 // included, move to next line after that |
714 | 4012 if ( cap->oap->op_type != OP_NOP |
7 | 4013 && !cap->oap->inclusive |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
4014 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 4015 cap->oap->inclusive = TRUE; |
4016 else | |
4017 { | |
4018 ++curwin->w_cursor.lnum; | |
4019 curwin->w_cursor.col = 0; | |
4020 curwin->w_cursor.coladd = 0; | |
4021 curwin->w_set_curswant = TRUE; | |
4022 cap->oap->inclusive = FALSE; | |
4023 } | |
4024 continue; | |
4025 } | |
4026 if (cap->oap->op_type == OP_NOP) | |
4027 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4028 // Only beep and flush if not moved at all |
7 | 4029 if (n == cap->count1) |
4030 beep_flush(); | |
4031 } | |
4032 else | |
4033 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
4034 if (!LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 4035 cap->oap->inclusive = TRUE; |
4036 } | |
4037 break; | |
4038 } | |
5735 | 4039 else if (past_line) |
7 | 4040 { |
4041 curwin->w_set_curswant = TRUE; | |
4042 if (virtual_active()) | |
4043 oneright(); | |
4044 else | |
5735 | 4045 { |
7 | 4046 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
|
4047 curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); |
7 | 4048 else |
4049 ++curwin->w_cursor.col; | |
4050 } | |
4051 } | |
4052 } | |
4053 #ifdef FEAT_FOLDING | |
4054 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
4055 && cap->oap->op_type == OP_NOP) | |
4056 foldOpenCursor(); | |
4057 #endif | |
4058 } | |
4059 | |
4060 /* | |
4061 * Cursor left commands. | |
4062 * | |
4063 * Returns TRUE when operator end should not be adjusted. | |
4064 */ | |
4065 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4066 nv_left(cmdarg_T *cap) |
7 | 4067 { |
4068 long n; | |
4069 | |
180 | 4070 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
4071 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4072 // <C-Left> and <S-Left> move a word or WORD left |
180 | 4073 if (mod_mask & MOD_MASK_CTRL) |
4074 cap->arg = 1; | |
4075 nv_bck_word(cap); | |
4076 return; | |
4077 } | |
4078 | |
7 | 4079 cap->oap->motion_type = MCHAR; |
4080 cap->oap->inclusive = FALSE; | |
4081 for (n = cap->count1; n > 0; --n) | |
4082 { | |
4083 if (oneleft() == FAIL) | |
4084 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4085 // <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
|
4086 // '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
|
4087 // CURS_LEFT wraps to previous line if 'whichwrap' has '<'. |
7 | 4088 if ( (((cap->cmdchar == K_BS |
4089 || cap->cmdchar == Ctrl_H) | |
4090 && vim_strchr(p_ww, 'b') != NULL) | |
4091 || (cap->cmdchar == 'h' | |
4092 && vim_strchr(p_ww, 'h') != NULL) | |
229 | 4093 || (cap->cmdchar == K_LEFT |
7 | 4094 && vim_strchr(p_ww, '<') != NULL)) |
4095 && curwin->w_cursor.lnum > 1) | |
4096 { | |
4097 --(curwin->w_cursor.lnum); | |
4098 coladvance((colnr_T)MAXCOL); | |
4099 curwin->w_set_curswant = TRUE; | |
4100 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4101 // 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
|
4102 // 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
|
4103 // 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
|
4104 // Don't adjust op_end now, otherwise it won't work. |
7 | 4105 if ( (cap->oap->op_type == OP_DELETE |
4106 || 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
|
4107 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 4108 { |
5682 | 4109 char_u *cp = ml_get_cursor(); |
4110 | |
4111 if (*cp != NUL) | |
4112 { | |
4113 if (has_mbyte) | |
4114 curwin->w_cursor.col += (*mb_ptr2len)(cp); | |
4115 else | |
4116 ++curwin->w_cursor.col; | |
4117 } | |
7 | 4118 cap->retval |= CA_NO_ADJ_OP_END; |
4119 } | |
4120 continue; | |
4121 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4122 // Only beep and flush if not moved at all |
7 | 4123 else if (cap->oap->op_type == OP_NOP && n == cap->count1) |
4124 beep_flush(); | |
4125 break; | |
4126 } | |
4127 } | |
4128 #ifdef FEAT_FOLDING | |
4129 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
4130 && cap->oap->op_type == OP_NOP) | |
4131 foldOpenCursor(); | |
4132 #endif | |
4133 } | |
4134 | |
4135 /* | |
4136 * Cursor up commands. | |
4137 * cap->arg is TRUE for "-": Move cursor to first non-blank. | |
4138 */ | |
4139 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4140 nv_up(cmdarg_T *cap) |
7 | 4141 { |
180 | 4142 if (mod_mask & MOD_MASK_SHIFT) |
4143 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4144 // <S-Up> is page up |
180 | 4145 cap->arg = BACKWARD; |
4146 nv_page(cap); | |
4147 } | |
4148 else | |
4149 { | |
4150 cap->oap->motion_type = MLINE; | |
4151 if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
4152 clearopbeep(cap->oap); | |
4153 else if (cap->arg) | |
4154 beginline(BL_WHITE | BL_FIX); | |
4155 } | |
7 | 4156 } |
4157 | |
4158 /* | |
4159 * Cursor down commands. | |
4160 * cap->arg is TRUE for CR and "+": Move cursor to first non-blank. | |
4161 */ | |
4162 static void | |
10192
758f3d5a463d
commit https://github.com/vim/vim/commit/1b010058235fb803c1d4f42a02d2883921be8ef4
Christian Brabandt <cb@256bit.org>
parents:
10154
diff
changeset
|
4163 nv_down(cmdarg_T *cap) |
7 | 4164 { |
180 | 4165 if (mod_mask & MOD_MASK_SHIFT) |
4166 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4167 // <S-Down> is page down |
180 | 4168 cap->arg = FORWARD; |
4169 nv_page(cap); | |
4170 } | |
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
|
4171 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4172 // 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
|
4173 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
|
4174 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
|
4175 #endif |
180 | 4176 else |
7 | 4177 { |
4178 #ifdef FEAT_CMDWIN | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4179 // In the cmdline window a <CR> executes the command. |
170 | 4180 if (cmdwin_type != 0 && cap->cmdchar == CAR) |
7 | 4181 cmdwin_result = CAR; |
4182 else | |
4183 #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
|
4184 #ifdef FEAT_JOB_CHANNEL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4185 // 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
|
4186 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
|
4187 && 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
|
4188 { |
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
|
4189 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
|
4190 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
|
4191 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
|
4192 } |
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
|
4193 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
|
4194 #endif |
7 | 4195 { |
4196 cap->oap->motion_type = MLINE; | |
4197 if (cursor_down(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
4198 clearopbeep(cap->oap); | |
4199 else if (cap->arg) | |
4200 beginline(BL_WHITE | BL_FIX); | |
4201 } | |
4202 } | |
4203 } | |
4204 | |
4205 #ifdef FEAT_SEARCHPATH | |
4206 /* | |
4207 * Grab the file name under the cursor and edit it. | |
4208 */ | |
4209 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4210 nv_gotofile(cmdarg_T *cap) |
7 | 4211 { |
4212 char_u *ptr; | |
681 | 4213 linenr_T lnum = -1; |
7 | 4214 |
633 | 4215 if (text_locked()) |
7 | 4216 { |
4217 clearopbeep(cap->oap); | |
633 | 4218 text_locked_msg(); |
7 | 4219 return; |
4220 } | |
819 | 4221 if (curbuf_locked()) |
4222 { | |
4223 clearop(cap->oap); | |
4224 return; | |
4225 } | |
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
|
4226 #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
|
4227 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
|
4228 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
|
4229 #endif |
7 | 4230 |
681 | 4231 ptr = grab_file_name(cap->count1, &lnum); |
7 | 4232 |
4233 if (ptr != NULL) | |
4234 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4235 // 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
|
4236 if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !buf_hide(curbuf)) |
7009 | 4237 (void)autowrite(curbuf, FALSE); |
7 | 4238 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
|
4239 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
|
4240 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
|
4241 && cap->nchar == 'F' && lnum >= 0) |
681 | 4242 { |
4243 curwin->w_cursor.lnum = lnum; | |
4244 check_cursor_lnum(); | |
4245 beginline(BL_SOL | BL_FIX); | |
4246 } | |
7 | 4247 vim_free(ptr); |
4248 } | |
4249 else | |
4250 clearop(cap->oap); | |
4251 } | |
4252 #endif | |
4253 | |
4254 /* | |
4255 * <End> command: to end of current line or last line. | |
4256 */ | |
4257 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4258 nv_end(cmdarg_T *cap) |
7 | 4259 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4260 if (cap->arg || (mod_mask & MOD_MASK_CTRL)) // CTRL-END = goto last line |
180 | 4261 { |
4262 cap->arg = TRUE; | |
7 | 4263 nv_goto(cap); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4264 cap->count1 = 1; // to end of current line |
7 | 4265 } |
4266 nv_dollar(cap); | |
4267 } | |
4268 | |
4269 /* | |
4270 * Handle the "$" command. | |
4271 */ | |
4272 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4273 nv_dollar(cmdarg_T *cap) |
7 | 4274 { |
4275 cap->oap->motion_type = MCHAR; | |
4276 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4277 // 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
|
4278 // 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
|
4279 // Otherwise, send it to the end of the line. |
7 | 4280 if (!virtual_active() || gchar_cursor() != NUL |
4281 || 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
|
4282 curwin->w_curswant = MAXCOL; // so we stay at the end |
7 | 4283 if (cursor_down((long)(cap->count1 - 1), |
4284 cap->oap->op_type == OP_NOP) == FAIL) | |
4285 clearopbeep(cap->oap); | |
4286 #ifdef FEAT_FOLDING | |
4287 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4288 foldOpenCursor(); | |
4289 #endif | |
4290 } | |
4291 | |
4292 /* | |
4293 * Implementation of '?' and '/' commands. | |
4294 * If cap->arg is TRUE don't set PC mark. | |
4295 */ | |
4296 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4297 nv_search(cmdarg_T *cap) |
7 | 4298 { |
4299 oparg_T *oap = cap->oap; | |
10098
72e4b7f90465
commit https://github.com/vim/vim/commit/dda933d06c06c2792bd686d059f6ad19191ad30b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4300 pos_T save_cursor = curwin->w_cursor; |
7 | 4301 |
4302 if (cap->cmdchar == '?' && cap->oap->op_type == OP_ROT13) | |
4303 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4304 // Translate "g??" to "g?g?" |
7 | 4305 cap->cmdchar = 'g'; |
4306 cap->nchar = '?'; | |
4307 nv_operator(cap); | |
4308 return; | |
4309 } | |
4310 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4311 // 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
|
4312 // start position. |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
4313 cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, TRUE); |
7 | 4314 |
4315 if (cap->searchbuf == NULL) | |
4316 { | |
4317 clearop(oap); | |
4318 return; | |
4319 } | |
4320 | |
6620 | 4321 (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
|
4322 (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
|
4323 ? 0 : SEARCH_MARK, NULL); |
7 | 4324 } |
4325 | |
4326 /* | |
4327 * Handle "N" and "n" commands. | |
4328 * cap->arg is SEARCH_REV for "N", 0 for "n". | |
4329 */ | |
4330 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4331 nv_next(cmdarg_T *cap) |
7 | 4332 { |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4333 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
|
4334 int wrapped = FALSE; |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4335 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
|
4336 |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4337 if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor)) |
6620 | 4338 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4339 // 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
|
4340 // 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
|
4341 // in the buffer: Repeat with count + 1. |
6620 | 4342 cap->count1 += 1; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4343 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); |
6620 | 4344 cap->count1 -= 1; |
4345 } | |
7 | 4346 } |
4347 | |
4348 /* | |
4349 * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat). | |
4350 * Uses only cap->count1 and cap->oap from "cap". | |
6620 | 4351 * Return 0 for failure, 1 for found, 2 for found and line offset added. |
4352 */ | |
4353 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4354 normal_search( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4355 cmdarg_T *cap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4356 int dir, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4357 char_u *pat, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4358 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
|
4359 int *wrapped) |
7 | 4360 { |
4361 int i; | |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4362 searchit_arg_T sia; |
7 | 4363 |
4364 cap->oap->motion_type = MCHAR; | |
4365 cap->oap->inclusive = FALSE; | |
4366 cap->oap->use_reg_one = TRUE; | |
4367 curwin->w_set_curswant = TRUE; | |
4368 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
4369 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
|
4370 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
|
4371 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
|
4372 if (wrapped != NULL) |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4373 *wrapped = sia.sa_wrapped; |
7 | 4374 if (i == 0) |
4375 clearop(cap->oap); | |
4376 else | |
4377 { | |
4378 if (i == 2) | |
4379 cap->oap->motion_type = MLINE; | |
4380 curwin->w_cursor.coladd = 0; | |
4381 #ifdef FEAT_FOLDING | |
4382 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4383 foldOpenCursor(); | |
4384 #endif | |
4385 } | |
4386 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4387 // "/$" 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
|
4388 // correct that here |
7 | 4389 check_cursor(); |
6620 | 4390 return i; |
7 | 4391 } |
4392 | |
4393 /* | |
4394 * Character search commands. | |
4395 * cap->arg is BACKWARD for 'F' and 'T', FORWARD for 'f' and 't', TRUE for | |
4396 * ',' and FALSE for ';'. | |
4397 * cap->nchar is NUL for ',' and ';' (repeat the search) | |
4398 */ | |
4399 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4400 nv_csearch(cmdarg_T *cap) |
7 | 4401 { |
4402 int t_cmd; | |
4403 | |
4404 if (cap->cmdchar == 't' || cap->cmdchar == 'T') | |
4405 t_cmd = TRUE; | |
4406 else | |
4407 t_cmd = FALSE; | |
4408 | |
4409 cap->oap->motion_type = MCHAR; | |
4410 if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL) | |
4411 clearopbeep(cap->oap); | |
4412 else | |
4413 { | |
4414 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
|
4415 // Include a Tab for "tx" and for "dfx". |
7 | 4416 if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD |
4417 && (t_cmd || cap->oap->op_type != OP_NOP)) | |
4418 { | |
4419 colnr_T scol, ecol; | |
4420 | |
4421 getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); | |
4422 curwin->w_cursor.coladd = ecol - scol; | |
4423 } | |
4424 else | |
4425 curwin->w_cursor.coladd = 0; | |
4426 adjust_for_sel(cap); | |
4427 #ifdef FEAT_FOLDING | |
4428 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4429 foldOpenCursor(); | |
4430 #endif | |
4431 } | |
4432 } | |
4433 | |
4434 /* | |
4435 * "[" and "]" commands. | |
4436 * cap->arg is BACKWARD for "[" and FORWARD for "]". | |
4437 */ | |
4438 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4439 nv_brackets(cmdarg_T *cap) |
7 | 4440 { |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4441 pos_T new_pos = {0, 0, 0}; |
7 | 4442 pos_T prev_pos; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4443 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
|
4444 pos_T old_pos; // cursor position before command |
7 | 4445 int flag; |
4446 long n; | |
4447 int findc; | |
4448 int c; | |
4449 | |
4450 cap->oap->motion_type = MCHAR; | |
4451 cap->oap->inclusive = FALSE; | |
4452 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
|
4453 curwin->w_cursor.coladd = 0; // TODO: don't do this for an error. |
7 | 4454 |
4455 #ifdef FEAT_SEARCHPATH | |
4456 /* | |
4457 * "[f" or "]f" : Edit file under the cursor (same as "gf") | |
4458 */ | |
4459 if (cap->nchar == 'f') | |
4460 nv_gotofile(cap); | |
4461 else | |
4462 #endif | |
4463 | |
4464 #ifdef FEAT_FIND_ID | |
4465 /* | |
1188 | 4466 * Find the occurrence(s) of the identifier or define under cursor |
4467 * in current and included files or jump to the first occurrence. | |
7 | 4468 * |
4469 * search list jump | |
4470 * fwd bwd fwd bwd fwd bwd | |
4471 * identifier "]i" "[i" "]I" "[I" "]^I" "[^I" | |
4472 * define "]d" "[d" "]D" "[D" "]^D" "[^D" | |
4473 */ | |
4474 if (vim_strchr((char_u *) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4475 # ifdef EBCDIC |
7 | 4476 "iI\005dD\067", |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4477 # else |
7 | 4478 "iI\011dD\004", |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4479 # endif |
7 | 4480 cap->nchar) != NULL) |
4481 { | |
4482 char_u *ptr; | |
4483 int len; | |
4484 | |
4485 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) | |
4486 clearop(cap->oap); | |
4487 else | |
4488 { | |
4489 find_pattern_in_path(ptr, 0, len, TRUE, | |
4490 cap->count0 == 0 ? !isupper(cap->nchar) : FALSE, | |
4491 ((cap->nchar & 0xf) == ('d' & 0xf)) ? FIND_DEFINE : FIND_ANY, | |
4492 cap->count1, | |
4493 isupper(cap->nchar) ? ACTION_SHOW_ALL : | |
4494 islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO, | |
4495 cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1, | |
4496 (linenr_T)MAXLNUM); | |
4497 curwin->w_set_curswant = TRUE; | |
4498 } | |
4499 } | |
4500 else | |
4501 #endif | |
4502 | |
4503 /* | |
4504 * "[{", "[(", "]}" or "])": go to Nth unclosed '{', '(', '}' or ')' | |
4505 * "[#", "]#": go to start/end of Nth innermost #if..#endif construct. | |
4506 * "[/", "[*", "]/", "]*": go to Nth comment start/end. | |
4507 * "[m" or "]m" search for prev/next start of (Java) method. | |
4508 * "[M" or "]M" search for prev/next end of (Java) method. | |
4509 */ | |
4510 if ( (cap->cmdchar == '[' | |
4511 && vim_strchr((char_u *)"{(*/#mM", cap->nchar) != NULL) | |
4512 || (cap->cmdchar == ']' | |
4513 && vim_strchr((char_u *)"})*/#mM", cap->nchar) != NULL)) | |
4514 { | |
4515 if (cap->nchar == '*') | |
4516 cap->nchar = '/'; | |
4517 prev_pos.lnum = 0; | |
4518 if (cap->nchar == 'm' || cap->nchar == 'M') | |
4519 { | |
4520 if (cap->cmdchar == '[') | |
4521 findc = '{'; | |
4522 else | |
4523 findc = '}'; | |
4524 n = 9999; | |
4525 } | |
4526 else | |
4527 { | |
4528 findc = cap->nchar; | |
4529 n = cap->count1; | |
4530 } | |
4531 for ( ; n > 0; --n) | |
4532 { | |
4533 if ((pos = findmatchlimit(cap->oap, findc, | |
4534 (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, 0)) == NULL) | |
4535 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4536 if (new_pos.lnum == 0) // nothing found |
7 | 4537 { |
4538 if (cap->nchar != 'm' && cap->nchar != 'M') | |
4539 clearopbeep(cap->oap); | |
4540 } | |
4541 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4542 pos = &new_pos; // use last one found |
7 | 4543 break; |
4544 } | |
4545 prev_pos = new_pos; | |
4546 curwin->w_cursor = *pos; | |
4547 new_pos = *pos; | |
4548 } | |
4549 curwin->w_cursor = old_pos; | |
4550 | |
4551 /* | |
4552 * Handle "[m", "]m", "[M" and "[M". The findmatchlimit() only | |
4553 * brought us to the match for "[m" and "]M" when inside a method. | |
4554 * Try finding the '{' or '}' we want to be at. | |
4555 * Also repeat for the given count. | |
4556 */ | |
4557 if (cap->nchar == 'm' || cap->nchar == 'M') | |
4558 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4559 // norm is TRUE for "]M" and "[m" |
7 | 4560 int norm = ((findc == '{') == (cap->nchar == 'm')); |
4561 | |
4562 n = cap->count1; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4563 // found a match: we were inside a method |
7 | 4564 if (prev_pos.lnum != 0) |
4565 { | |
4566 pos = &prev_pos; | |
4567 curwin->w_cursor = prev_pos; | |
4568 if (norm) | |
4569 --n; | |
4570 } | |
4571 else | |
4572 pos = NULL; | |
4573 while (n > 0) | |
4574 { | |
4575 for (;;) | |
4576 { | |
4577 if ((findc == '{' ? dec_cursor() : inc_cursor()) < 0) | |
4578 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4579 // if not found anything, that's an error |
7 | 4580 if (pos == NULL) |
4581 clearopbeep(cap->oap); | |
4582 n = 0; | |
4583 break; | |
4584 } | |
4585 c = gchar_cursor(); | |
4586 if (c == '{' || c == '}') | |
4587 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4588 // Must have found end/start of class: use it. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4589 // Or found the place to be at. |
7 | 4590 if ((c == findc && norm) || (n == 1 && !norm)) |
4591 { | |
4592 new_pos = curwin->w_cursor; | |
4593 pos = &new_pos; | |
4594 n = 0; | |
4595 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4596 // if no match found at all, we started outside of the |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4597 // class and we're inside now. Just go on. |
7 | 4598 else if (new_pos.lnum == 0) |
4599 { | |
4600 new_pos = curwin->w_cursor; | |
4601 pos = &new_pos; | |
4602 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4603 // found start/end of other method: go to match |
7 | 4604 else if ((pos = findmatchlimit(cap->oap, findc, |
4605 (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, | |
4606 0)) == NULL) | |
4607 n = 0; | |
4608 else | |
4609 curwin->w_cursor = *pos; | |
4610 break; | |
4611 } | |
4612 } | |
4613 --n; | |
4614 } | |
4615 curwin->w_cursor = old_pos; | |
4616 if (pos == NULL && new_pos.lnum != 0) | |
4617 clearopbeep(cap->oap); | |
4618 } | |
4619 if (pos != NULL) | |
4620 { | |
4621 setpcmark(); | |
4622 curwin->w_cursor = *pos; | |
4623 curwin->w_set_curswant = TRUE; | |
4624 #ifdef FEAT_FOLDING | |
4625 if ((fdo_flags & FDO_BLOCK) && KeyTyped | |
4626 && cap->oap->op_type == OP_NOP) | |
4627 foldOpenCursor(); | |
4628 #endif | |
4629 } | |
4630 } | |
4631 | |
4632 /* | |
4633 * "[[", "[]", "]]" and "][": move to start or end of function | |
4634 */ | |
4635 else if (cap->nchar == '[' || cap->nchar == ']') | |
4636 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4637 if (cap->nchar == cap->cmdchar) // "]]" or "[[" |
7 | 4638 flag = '{'; |
4639 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4640 flag = '}'; // "][" or "[]" |
7 | 4641 |
4642 curwin->w_set_curswant = TRUE; | |
4643 /* | |
4644 * Imitate strange Vi behaviour: When using "]]" with an operator | |
4645 * we also stop at '}'. | |
4646 */ | |
503 | 4647 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, flag, |
7 | 4648 (cap->oap->op_type != OP_NOP |
4649 && cap->arg == FORWARD && flag == '{'))) | |
4650 clearopbeep(cap->oap); | |
4651 else | |
4652 { | |
4653 if (cap->oap->op_type == OP_NOP) | |
4654 beginline(BL_WHITE | BL_FIX); | |
4655 #ifdef FEAT_FOLDING | |
4656 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4657 foldOpenCursor(); | |
4658 #endif | |
4659 } | |
4660 } | |
4661 | |
4662 /* | |
4663 * "[p", "[P", "]P" and "]p": put with indent adjustment | |
4664 */ | |
4665 else if (cap->nchar == 'p' || cap->nchar == 'P') | |
4666 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
4667 nv_put_opt(cap, TRUE); |
7 | 4668 } |
4669 | |
4670 /* | |
4671 * "['", "[`", "]'" and "]`": jump to next mark | |
4672 */ | |
4673 else if (cap->nchar == '\'' || cap->nchar == '`') | |
4674 { | |
4675 pos = &curwin->w_cursor; | |
4676 for (n = cap->count1; n > 0; --n) | |
4677 { | |
4678 prev_pos = *pos; | |
4679 pos = getnextmark(pos, cap->cmdchar == '[' ? BACKWARD : FORWARD, | |
4680 cap->nchar == '\''); | |
4681 if (pos == NULL) | |
4682 break; | |
4683 } | |
4684 if (pos == NULL) | |
4685 pos = &prev_pos; | |
4686 nv_cursormark(cap, cap->nchar == '\'', pos); | |
4687 } | |
4688 | |
4689 /* | |
4690 * [ or ] followed by a middle mouse click: put selected text with | |
4691 * indent adjustment. Any other button just does as usual. | |
4692 */ | |
2130
279380a812ad
updated for version 7.2.412
Bram Moolenaar <bram@zimbu.org>
parents:
2112
diff
changeset
|
4693 else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) |
7 | 4694 { |
4695 (void)do_mouse(cap->oap, cap->nchar, | |
4696 (cap->cmdchar == ']') ? FORWARD : BACKWARD, | |
4697 cap->count1, PUT_FIXINDENT); | |
4698 } | |
4699 | |
4700 #ifdef FEAT_FOLDING | |
4701 /* | |
4702 * "[z" and "]z": move to start or end of open fold. | |
4703 */ | |
4704 else if (cap->nchar == 'z') | |
4705 { | |
4706 if (foldMoveTo(FALSE, cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4707 cap->count1) == FAIL) | |
4708 clearopbeep(cap->oap); | |
4709 } | |
4710 #endif | |
4711 | |
4712 #ifdef FEAT_DIFF | |
4713 /* | |
4714 * "[c" and "]c": move to next or previous diff-change. | |
4715 */ | |
4716 else if (cap->nchar == 'c') | |
4717 { | |
4718 if (diff_move_to(cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4719 cap->count1) == FAIL) | |
4720 clearopbeep(cap->oap); | |
4721 } | |
4722 #endif | |
4723 | |
737 | 4724 #ifdef FEAT_SPELL |
236 | 4725 /* |
4726 * "[s", "[S", "]s" and "]S": move to next spell error. | |
4727 */ | |
4728 else if (cap->nchar == 's' || cap->nchar == 'S') | |
4729 { | |
249 | 4730 setpcmark(); |
4731 for (n = 0; n < cap->count1; ++n) | |
498 | 4732 if (spell_move_to(curwin, cap->cmdchar == ']' ? FORWARD : BACKWARD, |
4733 cap->nchar == 's' ? TRUE : FALSE, FALSE, NULL) == 0) | |
249 | 4734 { |
4735 clearopbeep(cap->oap); | |
4736 break; | |
4737 } | |
13088
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4738 else |
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4739 curwin->w_set_curswant = TRUE; |
819 | 4740 # ifdef FEAT_FOLDING |
4741 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4742 foldOpenCursor(); | |
4743 # endif | |
236 | 4744 } |
4745 #endif | |
4746 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4747 // Not a valid cap->nchar. |
7 | 4748 else |
4749 clearopbeep(cap->oap); | |
4750 } | |
4751 | |
4752 /* | |
4753 * Handle Normal mode "%" command. | |
4754 */ | |
4755 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4756 nv_percent(cmdarg_T *cap) |
7 | 4757 { |
4758 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
|
4759 #if defined(FEAT_FOLDING) |
7 | 4760 linenr_T lnum = curwin->w_cursor.lnum; |
4761 #endif | |
4762 | |
4763 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4764 if (cap->count0) // {cnt}% : goto {cnt} percentage in file |
7 | 4765 { |
4766 if (cap->count0 > 100) | |
4767 clearopbeep(cap->oap); | |
4768 else | |
4769 { | |
4770 cap->oap->motion_type = MLINE; | |
4771 setpcmark(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4772 // Round up, so CTRL-G will give same value. Watch out for a |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4773 // large line count, the line number must not go negative! |
7 | 4774 if (curbuf->b_ml.ml_line_count > 1000000) |
4775 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L) | |
4776 / 100L * cap->count0; | |
4777 else | |
4778 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count * | |
4779 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
|
4780 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
|
4781 curwin->w_cursor.lnum = 1; |
7 | 4782 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
4783 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
4784 beginline(BL_SOL | BL_FIX); | |
4785 } | |
4786 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4787 else // "%" : go to matching paren |
7 | 4788 { |
4789 cap->oap->motion_type = MCHAR; | |
4790 cap->oap->use_reg_one = TRUE; | |
4791 if ((pos = findmatch(cap->oap, NUL)) == NULL) | |
4792 clearopbeep(cap->oap); | |
4793 else | |
4794 { | |
4795 setpcmark(); | |
4796 curwin->w_cursor = *pos; | |
4797 curwin->w_set_curswant = TRUE; | |
4798 curwin->w_cursor.coladd = 0; | |
4799 adjust_for_sel(cap); | |
4800 } | |
4801 } | |
4802 #ifdef FEAT_FOLDING | |
4803 if (cap->oap->op_type == OP_NOP | |
4804 && lnum != curwin->w_cursor.lnum | |
4805 && (fdo_flags & FDO_PERCENT) | |
4806 && KeyTyped) | |
4807 foldOpenCursor(); | |
4808 #endif | |
4809 } | |
4810 | |
4811 /* | |
4812 * Handle "(" and ")" commands. | |
4813 * cap->arg is BACKWARD for "(" and FORWARD for ")". | |
4814 */ | |
4815 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4816 nv_brace(cmdarg_T *cap) |
7 | 4817 { |
4818 cap->oap->motion_type = MCHAR; | |
4819 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
|
4820 // The motion used to be inclusive for "(", but that is not what Vi does. |
620 | 4821 cap->oap->inclusive = FALSE; |
7 | 4822 curwin->w_set_curswant = TRUE; |
4823 | |
4824 if (findsent(cap->arg, cap->count1) == FAIL) | |
4825 clearopbeep(cap->oap); | |
4826 else | |
4827 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4828 // Don't leave the cursor on the NUL past end of line. |
1505 | 4829 adjust_cursor(cap->oap); |
7 | 4830 curwin->w_cursor.coladd = 0; |
4831 #ifdef FEAT_FOLDING | |
4832 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4833 foldOpenCursor(); | |
4834 #endif | |
4835 } | |
4836 } | |
4837 | |
4838 /* | |
4839 * "m" command: Mark a position. | |
4840 */ | |
4841 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4842 nv_mark(cmdarg_T *cap) |
7 | 4843 { |
4844 if (!checkclearop(cap->oap)) | |
4845 { | |
4846 if (setmark(cap->nchar) == FAIL) | |
4847 clearopbeep(cap->oap); | |
4848 } | |
4849 } | |
4850 | |
4851 /* | |
4852 * "{" and "}" commands. | |
4853 * cmd->arg is BACKWARD for "{" and FORWARD for "}". | |
4854 */ | |
4855 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4856 nv_findpar(cmdarg_T *cap) |
7 | 4857 { |
4858 cap->oap->motion_type = MCHAR; | |
4859 cap->oap->inclusive = FALSE; | |
4860 cap->oap->use_reg_one = TRUE; | |
4861 curwin->w_set_curswant = TRUE; | |
503 | 4862 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE)) |
7 | 4863 clearopbeep(cap->oap); |
4864 else | |
4865 { | |
4866 curwin->w_cursor.coladd = 0; | |
4867 #ifdef FEAT_FOLDING | |
4868 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4869 foldOpenCursor(); | |
4870 #endif | |
4871 } | |
4872 } | |
4873 | |
4874 /* | |
4875 * "u" command: Undo or make lower case. | |
4876 */ | |
4877 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4878 nv_undo(cmdarg_T *cap) |
7 | 4879 { |
5735 | 4880 if (cap->oap->op_type == OP_LOWER || VIsual_active) |
7 | 4881 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4882 // translate "<Visual>u" to "<Visual>gu" and "guu" to "gugu" |
7 | 4883 cap->cmdchar = 'g'; |
4884 cap->nchar = 'u'; | |
4885 nv_operator(cap); | |
4886 } | |
4887 else | |
4888 nv_kundo(cap); | |
4889 } | |
4890 | |
4891 /* | |
4892 * <Undo> command. | |
4893 */ | |
4894 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4895 nv_kundo(cmdarg_T *cap) |
7 | 4896 { |
4897 if (!checkclearopq(cap->oap)) | |
4898 { | |
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
|
4899 #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
|
4900 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
|
4901 { |
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
|
4902 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
|
4903 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
|
4904 } |
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
|
4905 #endif |
7 | 4906 u_undo((int)cap->count1); |
4907 curwin->w_set_curswant = TRUE; | |
4908 } | |
4909 } | |
4910 | |
4911 /* | |
4912 * Handle the "r" command. | |
4913 */ | |
4914 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4915 nv_replace(cmdarg_T *cap) |
7 | 4916 { |
4917 char_u *ptr; | |
4918 int had_ctrl_v; | |
4919 long n; | |
4920 | |
4921 if (checkclearop(cap->oap)) | |
4922 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
|
4923 #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
|
4924 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
|
4925 { |
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
|
4926 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
|
4927 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
|
4928 } |
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
|
4929 #endif |
7 | 4930 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4931 // get another character |
7 | 4932 if (cap->nchar == Ctrl_V) |
4933 { | |
4934 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
|
4935 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
|
4936 // Don't redo a multibyte character with CTRL-V. |
7 | 4937 if (cap->nchar > DEL) |
4938 had_ctrl_v = NUL; | |
4939 } | |
4940 else | |
4941 had_ctrl_v = NUL; | |
4942 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4943 // Abort if the character is a special key. |
1343 | 4944 if (IS_SPECIAL(cap->nchar)) |
4945 { | |
4946 clearopbeep(cap->oap); | |
4947 return; | |
4948 } | |
4949 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4950 // Visual mode "r" |
7 | 4951 if (VIsual_active) |
4952 { | |
1797 | 4953 if (got_int) |
4954 reset_VIsual(); | |
5428 | 4955 if (had_ctrl_v) |
4956 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4957 // 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
|
4958 // 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
|
4959 if (cap->nchar == CAR) |
2941a86f8aaa
patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents:
13088
diff
changeset
|
4960 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
|
4961 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
|
4962 cap->nchar = REPLACE_NL_NCHAR; |
5428 | 4963 } |
7 | 4964 nv_operator(cap); |
4965 return; | |
4966 } | |
4967 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4968 // Break tabs, etc. |
7 | 4969 if (virtual_active()) |
4970 { | |
4971 if (u_save_cursor() == FAIL) | |
4972 return; | |
4973 if (gchar_cursor() == NUL) | |
4974 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4975 // Add extra space and put the cursor on the first one. |
7 | 4976 coladvance_force((colnr_T)(getviscol() + cap->count1)); |
4977 curwin->w_cursor.col -= cap->count1; | |
4978 } | |
4979 else if (gchar_cursor() == TAB) | |
4980 coladvance_force(getviscol()); | |
4981 } | |
4982 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4983 // Abort if not enough characters to replace. |
7 | 4984 ptr = ml_get_cursor(); |
1343 | 4985 if (STRLEN(ptr) < (unsigned)cap->count1 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4986 || (has_mbyte && mb_charlen(ptr) < cap->count1)) |
7 | 4987 { |
4988 clearopbeep(cap->oap); | |
4989 return; | |
4990 } | |
4991 | |
4992 /* | |
4993 * Replacing with a TAB is done by edit() when it is complicated because | |
4994 * 'expandtab' or 'smarttab' is set. CTRL-V TAB inserts a literal TAB. | |
4995 * Other characters are done below to avoid problems with things like | |
4996 * CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC). | |
4997 */ | |
4998 if (had_ctrl_v != Ctrl_V && cap->nchar == '\t' && (curbuf->b_p_et || p_sta)) | |
4999 { | |
5000 stuffnumReadbuff(cap->count1); | |
5001 stuffcharReadbuff('R'); | |
5002 stuffcharReadbuff('\t'); | |
5003 stuffcharReadbuff(ESC); | |
5004 return; | |
5005 } | |
5006 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5007 // save line for undo |
7 | 5008 if (u_save_cursor() == FAIL) |
5009 return; | |
5010 | |
5011 if (had_ctrl_v != Ctrl_V && (cap->nchar == '\r' || cap->nchar == '\n')) | |
5012 { | |
5013 /* | |
5014 * Replace character(s) by a single newline. | |
5015 * Strange vi behaviour: Only one newline is inserted. | |
5016 * Delete the characters here. | |
5017 * Insert the newline with an insert command, takes care of | |
5018 * autoindent. The insert command depends on being on the last | |
5019 * character of a line or not. | |
5020 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5021 (void)del_chars(cap->count1, FALSE); // delete the characters |
7 | 5022 stuffcharReadbuff('\r'); |
5023 stuffcharReadbuff(ESC); | |
5024 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5025 // Give 'r' to edit(), to get the redo command right. |
7 | 5026 invoke_edit(cap, TRUE, 'r', FALSE); |
5027 } | |
5028 else | |
5029 { | |
5030 prep_redo(cap->oap->regname, cap->count1, | |
5031 NUL, 'r', NUL, had_ctrl_v, cap->nchar); | |
5032 | |
5033 curbuf->b_op_start = curwin->w_cursor; | |
5034 if (has_mbyte) | |
5035 { | |
5036 int old_State = State; | |
5037 | |
5038 if (cap->ncharC1 != 0) | |
5039 AppendCharToRedobuff(cap->ncharC1); | |
5040 if (cap->ncharC2 != 0) | |
5041 AppendCharToRedobuff(cap->ncharC2); | |
5042 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5043 // 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
|
5044 // 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
|
5045 // composing characters for utf-8. |
7 | 5046 for (n = cap->count1; n > 0; --n) |
5047 { | |
5048 State = REPLACE; | |
3501 | 5049 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
5050 { | |
5051 int c = ins_copychar(curwin->w_cursor.lnum | |
5052 + (cap->nchar == Ctrl_Y ? -1 : 1)); | |
5053 if (c != NUL) | |
5054 ins_char(c); | |
5055 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5056 // will be decremented further down |
3501 | 5057 ++curwin->w_cursor.col; |
5058 } | |
5059 else | |
5060 ins_char(cap->nchar); | |
7 | 5061 State = old_State; |
5062 if (cap->ncharC1 != 0) | |
5063 ins_char(cap->ncharC1); | |
5064 if (cap->ncharC2 != 0) | |
5065 ins_char(cap->ncharC2); | |
5066 } | |
5067 } | |
5068 else | |
5069 { | |
5070 /* | |
5071 * Replace the characters within one line. | |
5072 */ | |
5073 for (n = cap->count1; n > 0; --n) | |
5074 { | |
5075 /* | |
5076 * Get ptr again, because u_save and/or showmatch() will have | |
5077 * released the line. At the same time we let know that the | |
5078 * line will be changed. | |
5079 */ | |
5080 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); | |
3501 | 5081 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
5082 { | |
5083 int c = ins_copychar(curwin->w_cursor.lnum | |
5084 + (cap->nchar == Ctrl_Y ? -1 : 1)); | |
5085 if (c != NUL) | |
5086 ptr[curwin->w_cursor.col] = c; | |
5087 } | |
5088 else | |
5089 ptr[curwin->w_cursor.col] = cap->nchar; | |
7 | 5090 if (p_sm && msg_silent == 0) |
5091 showmatch(cap->nchar); | |
5092 ++curwin->w_cursor.col; | |
5093 } | |
5094 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5095 if (netbeans_active()) |
7 | 5096 { |
2210 | 5097 colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1); |
7 | 5098 |
33 | 5099 netbeans_removed(curbuf, curwin->w_cursor.lnum, start, |
2210 | 5100 (long)cap->count1); |
7 | 5101 netbeans_inserted(curbuf, curwin->w_cursor.lnum, start, |
33 | 5102 &ptr[start], (int)cap->count1); |
7 | 5103 } |
5104 #endif | |
5105 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5106 // mark the buffer as changed and prepare for displaying |
7 | 5107 changed_bytes(curwin->w_cursor.lnum, |
5108 (colnr_T)(curwin->w_cursor.col - cap->count1)); | |
5109 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5110 --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
|
5111 // 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
|
5112 // character, move two characters left |
7 | 5113 if (has_mbyte) |
5114 mb_adjust_cursor(); | |
5115 curbuf->b_op_end = curwin->w_cursor; | |
5116 curwin->w_set_curswant = TRUE; | |
5117 set_last_insert(cap->nchar); | |
5118 } | |
5119 } | |
5120 | |
5121 /* | |
5122 * 'o': Exchange start and end of Visual area. | |
5123 * 'O': same, but in block mode exchange left and right corners. | |
5124 */ | |
5125 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5126 v_swap_corners(int cmdchar) |
7 | 5127 { |
5128 pos_T old_cursor; | |
5129 colnr_T left, right; | |
5130 | |
5131 if (cmdchar == 'O' && VIsual_mode == Ctrl_V) | |
5132 { | |
5133 old_cursor = curwin->w_cursor; | |
5134 getvcols(curwin, &old_cursor, &VIsual, &left, &right); | |
5135 curwin->w_cursor.lnum = VIsual.lnum; | |
5136 coladvance(left); | |
5137 VIsual = curwin->w_cursor; | |
5138 | |
5139 curwin->w_cursor.lnum = old_cursor.lnum; | |
5140 curwin->w_curswant = right; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5141 // '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
|
5142 // right one column |
7 | 5143 if (old_cursor.lnum >= VIsual.lnum && *p_sel == 'e') |
5144 ++curwin->w_curswant; | |
5145 coladvance(curwin->w_curswant); | |
5146 if (curwin->w_cursor.col == old_cursor.col | |
5147 && (!virtual_active() | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5148 || curwin->w_cursor.coladd == old_cursor.coladd)) |
7 | 5149 { |
5150 curwin->w_cursor.lnum = VIsual.lnum; | |
5151 if (old_cursor.lnum <= VIsual.lnum && *p_sel == 'e') | |
5152 ++right; | |
5153 coladvance(right); | |
5154 VIsual = curwin->w_cursor; | |
5155 | |
5156 curwin->w_cursor.lnum = old_cursor.lnum; | |
5157 coladvance(left); | |
5158 curwin->w_curswant = left; | |
5159 } | |
5160 } | |
5161 else | |
5162 { | |
5163 old_cursor = curwin->w_cursor; | |
5164 curwin->w_cursor = VIsual; | |
5165 VIsual = old_cursor; | |
5166 curwin->w_set_curswant = TRUE; | |
5167 } | |
5168 } | |
5169 | |
5170 /* | |
5171 * "R" (cap->arg is FALSE) and "gR" (cap->arg is TRUE). | |
5172 */ | |
5173 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5174 nv_Replace(cmdarg_T *cap) |
7 | 5175 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5176 if (VIsual_active) // "R" is replace lines |
7 | 5177 { |
5178 cap->cmdchar = 'c'; | |
5179 cap->nchar = NUL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5180 VIsual_mode_orig = VIsual_mode; // remember original area for gv |
7 | 5181 VIsual_mode = 'V'; |
5182 nv_operator(cap); | |
5183 } | |
5735 | 5184 else if (!checkclearopq(cap->oap)) |
7 | 5185 { |
5186 if (!curbuf->b_p_ma) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
5187 emsg(_(e_modifiable)); |
7 | 5188 else |
5189 { | |
5190 if (virtual_active()) | |
5191 coladvance(getviscol()); | |
5192 invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE); | |
5193 } | |
5194 } | |
5195 } | |
5196 | |
5197 /* | |
5198 * "gr". | |
5199 */ | |
5200 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5201 nv_vreplace(cmdarg_T *cap) |
7 | 5202 { |
5203 if (VIsual_active) | |
5204 { | |
5205 cap->cmdchar = 'r'; | |
5206 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
|
5207 nv_replace(cap); // Do same as "r" in Visual mode for now |
7 | 5208 } |
5735 | 5209 else if (!checkclearopq(cap->oap)) |
7 | 5210 { |
5211 if (!curbuf->b_p_ma) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
5212 emsg(_(e_modifiable)); |
7 | 5213 else |
5214 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5215 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
|
5216 cap->extra_char = get_literal(FALSE); |
7 | 5217 stuffcharReadbuff(cap->extra_char); |
5218 stuffcharReadbuff(ESC); | |
5219 if (virtual_active()) | |
5220 coladvance(getviscol()); | |
5221 invoke_edit(cap, TRUE, 'v', FALSE); | |
5222 } | |
5223 } | |
5224 } | |
5225 | |
5226 /* | |
5227 * Swap case for "~" command, when it does not work like an operator. | |
5228 */ | |
5229 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5230 n_swapchar(cmdarg_T *cap) |
7 | 5231 { |
5232 long n; | |
5233 pos_T startpos; | |
5234 int did_change = 0; | |
5235 #ifdef FEAT_NETBEANS_INTG | |
5236 pos_T pos; | |
5237 char_u *ptr; | |
5238 int count; | |
5239 #endif | |
5240 | |
5241 if (checkclearopq(cap->oap)) | |
5242 return; | |
5243 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5244 if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) |
7 | 5245 { |
5246 clearopbeep(cap->oap); | |
5247 return; | |
5248 } | |
5249 | |
5250 prep_redo_cmd(cap); | |
5251 | |
5252 if (u_save_cursor() == FAIL) | |
5253 return; | |
5254 | |
5255 startpos = curwin->w_cursor; | |
5256 #ifdef FEAT_NETBEANS_INTG | |
5257 pos = startpos; | |
5258 #endif | |
5259 for (n = cap->count1; n > 0; --n) | |
5260 { | |
5261 did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); | |
5262 inc_cursor(); | |
5263 if (gchar_cursor() == NUL) | |
5264 { | |
5265 if (vim_strchr(p_ww, '~') != NULL | |
5266 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
5267 { | |
5268 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5269 if (netbeans_active()) |
7 | 5270 { |
5271 if (did_change) | |
5272 { | |
5273 ptr = ml_get(pos.lnum); | |
835 | 5274 count = (int)STRLEN(ptr) - pos.col; |
33 | 5275 netbeans_removed(curbuf, pos.lnum, pos.col, |
5276 (long)count); | |
7 | 5277 netbeans_inserted(curbuf, pos.lnum, pos.col, |
33 | 5278 &ptr[pos.col], count); |
7 | 5279 } |
5280 pos.col = 0; | |
5281 pos.lnum++; | |
5282 } | |
5283 #endif | |
5284 ++curwin->w_cursor.lnum; | |
5285 curwin->w_cursor.col = 0; | |
5286 if (n > 1) | |
5287 { | |
5288 if (u_savesub(curwin->w_cursor.lnum) == FAIL) | |
5289 break; | |
5290 u_clearline(); | |
5291 } | |
5292 } | |
5293 else | |
5294 break; | |
5295 } | |
5296 } | |
5297 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5298 if (did_change && netbeans_active()) |
7 | 5299 { |
5300 ptr = ml_get(pos.lnum); | |
5301 count = curwin->w_cursor.col - pos.col; | |
33 | 5302 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count); |
5303 netbeans_inserted(curbuf, pos.lnum, pos.col, &ptr[pos.col], count); | |
7 | 5304 } |
5305 #endif | |
5306 | |
5307 | |
5308 check_cursor(); | |
5309 curwin->w_set_curswant = TRUE; | |
5310 if (did_change) | |
5311 { | |
5312 changed_lines(startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1, | |
5313 0L); | |
5314 curbuf->b_op_start = startpos; | |
5315 curbuf->b_op_end = curwin->w_cursor; | |
5316 if (curbuf->b_op_end.col > 0) | |
5317 --curbuf->b_op_end.col; | |
5318 } | |
5319 } | |
5320 | |
5321 /* | |
5322 * Move cursor to mark. | |
5323 */ | |
5324 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5325 nv_cursormark(cmdarg_T *cap, int flag, pos_T *pos) |
7 | 5326 { |
5327 if (check_mark(pos) == FAIL) | |
5328 clearop(cap->oap); | |
5329 else | |
5330 { | |
5331 if (cap->cmdchar == '\'' | |
5332 || cap->cmdchar == '`' | |
5333 || cap->cmdchar == '[' | |
5334 || cap->cmdchar == ']') | |
5335 setpcmark(); | |
5336 curwin->w_cursor = *pos; | |
5337 if (flag) | |
5338 beginline(BL_WHITE | BL_FIX); | |
5339 else | |
5340 check_cursor(); | |
5341 } | |
5342 cap->oap->motion_type = flag ? MLINE : MCHAR; | |
5343 if (cap->cmdchar == '`') | |
5344 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
|
5345 cap->oap->inclusive = FALSE; // ignored if not MCHAR |
7 | 5346 curwin->w_set_curswant = TRUE; |
5347 } | |
5348 | |
5349 /* | |
5350 * Handle commands that are operators in Visual mode. | |
5351 */ | |
5352 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5353 v_visop(cmdarg_T *cap) |
7 | 5354 { |
5355 static char_u trans[] = "YyDdCcxdXdAAIIrr"; | |
5356 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5357 // 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
|
5358 // the end of the line, and "C" replaces till EOL |
7 | 5359 if (isupper(cap->cmdchar)) |
5360 { | |
5361 if (VIsual_mode != Ctrl_V) | |
4213 | 5362 { |
5363 VIsual_mode_orig = VIsual_mode; | |
7 | 5364 VIsual_mode = 'V'; |
4213 | 5365 } |
7 | 5366 else if (cap->cmdchar == 'C' || cap->cmdchar == 'D') |
5367 curwin->w_curswant = MAXCOL; | |
5368 } | |
5369 cap->cmdchar = *(vim_strchr(trans, cap->cmdchar) + 1); | |
5370 nv_operator(cap); | |
5371 } | |
5372 | |
5373 /* | |
5374 * "s" and "S" commands. | |
5375 */ | |
5376 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5377 nv_subst(cmdarg_T *cap) |
7 | 5378 { |
13298
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5379 #ifdef FEAT_TERMINAL |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
23165
diff
changeset
|
5380 // 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
|
5381 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
|
5382 return; |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5383 #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
|
5384 #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
|
5385 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
|
5386 { |
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
|
5387 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
|
5388 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
|
5389 } |
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
|
5390 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5391 if (VIsual_active) // "vs" and "vS" are the same as "vc" |
7 | 5392 { |
5393 if (cap->cmdchar == 'S') | |
4213 | 5394 { |
5395 VIsual_mode_orig = VIsual_mode; | |
7 | 5396 VIsual_mode = 'V'; |
4213 | 5397 } |
7 | 5398 cap->cmdchar = 'c'; |
5399 nv_operator(cap); | |
5400 } | |
5401 else | |
5402 nv_optrans(cap); | |
5403 } | |
5404 | |
5405 /* | |
5406 * Abbreviated commands. | |
5407 */ | |
5408 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5409 nv_abbrev(cmdarg_T *cap) |
7 | 5410 { |
5411 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
|
5412 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
|
5413 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5414 // in Visual mode these commands are operators |
7 | 5415 if (VIsual_active) |
5416 v_visop(cap); | |
5417 else | |
5418 nv_optrans(cap); | |
5419 } | |
5420 | |
5421 /* | |
5422 * Translate a command into another command. | |
5423 */ | |
5424 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5425 nv_optrans(cmdarg_T *cap) |
7 | 5426 { |
5427 static char_u *(ar[8]) = {(char_u *)"dl", (char_u *)"dh", | |
5428 (char_u *)"d$", (char_u *)"c$", | |
5429 (char_u *)"cl", (char_u *)"cc", | |
5430 (char_u *)"yy", (char_u *)":s\r"}; | |
5431 static char_u *str = (char_u *)"xXDCsSY&"; | |
5432 | |
5433 if (!checkclearopq(cap->oap)) | |
5434 { | |
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
|
5435 // 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
|
5436 // either, because "2." should also not use the count. |
164 | 5437 if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL) |
5438 { | |
5439 cap->oap->start = curwin->w_cursor; | |
5440 cap->oap->op_type = OP_DELETE; | |
1490 | 5441 #ifdef FEAT_EVAL |
5442 set_op_var(OP_DELETE); | |
5443 #endif | |
164 | 5444 cap->count1 = 1; |
5445 nv_dollar(cap); | |
5446 finish_op = TRUE; | |
5447 ResetRedobuff(); | |
5448 AppendCharToRedobuff('D'); | |
5449 } | |
5450 else | |
5451 { | |
5452 if (cap->count0) | |
5453 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
|
5454 stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]); |
164 | 5455 } |
7 | 5456 } |
5457 cap->opcount = 0; | |
5458 } | |
5459 | |
5460 /* | |
5461 * "'" and "`" commands. Also for "g'" and "g`". | |
5462 * cap->arg is TRUE for "'" and "g'". | |
5463 */ | |
5464 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5465 nv_gomark(cmdarg_T *cap) |
7 | 5466 { |
5467 pos_T *pos; | |
5468 int c; | |
5469 #ifdef FEAT_FOLDING | |
4017 | 5470 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
|
5471 int old_KeyTyped = KeyTyped; // getting file may reset it |
7 | 5472 #endif |
5473 | |
5474 if (cap->cmdchar == 'g') | |
5475 c = cap->extra_char; | |
5476 else | |
5477 c = cap->nchar; | |
5478 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
|
5479 if (pos == (pos_T *)-1) // jumped to other file |
7 | 5480 { |
5481 if (cap->arg) | |
5482 { | |
5483 check_cursor_lnum(); | |
5484 beginline(BL_WHITE | BL_FIX); | |
5485 } | |
5486 else | |
5487 check_cursor(); | |
5488 } | |
5489 else | |
5490 nv_cursormark(cap, cap->arg, pos); | |
5491 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5492 // May need to clear the coladd that a mark includes. |
7 | 5493 if (!virtual_active()) |
5494 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
|
5495 check_cursor_col(); |
7 | 5496 #ifdef FEAT_FOLDING |
5497 if (cap->oap->op_type == OP_NOP | |
4057 | 5498 && pos != NULL |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5499 && (pos == (pos_T *)-1 || !EQUAL_POS(old_cursor, *pos)) |
7 | 5500 && (fdo_flags & FDO_MARK) |
5501 && old_KeyTyped) | |
5502 foldOpenCursor(); | |
5503 #endif | |
5504 } | |
5505 | |
5506 /* | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5507 * Handle CTRL-O, CTRL-I, "g;", "g," and "CTRL-Tab" commands. |
7 | 5508 */ |
5509 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5510 nv_pcmark(cmdarg_T *cap) |
7 | 5511 { |
5512 #ifdef FEAT_JUMPLIST | |
5513 pos_T *pos; | |
5514 # ifdef FEAT_FOLDING | |
5515 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
|
5516 int old_KeyTyped = KeyTyped; // getting file may reset it |
7 | 5517 # endif |
5518 | |
5519 if (!checkclearopq(cap->oap)) | |
5520 { | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5521 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
|
5522 { |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5523 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
|
5524 clearopbeep(cap->oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5525 return; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5526 } |
7 | 5527 if (cap->cmdchar == 'g') |
5528 pos = movechangelist((int)cap->count1); | |
5529 else | |
5530 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
|
5531 if (pos == (pos_T *)-1) // jump to other file |
7 | 5532 { |
5533 curwin->w_set_curswant = TRUE; | |
5534 check_cursor(); | |
5535 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5536 else if (pos != NULL) // can jump |
7 | 5537 nv_cursormark(cap, FALSE, pos); |
5538 else if (cap->cmdchar == 'g') | |
5539 { | |
5540 if (curbuf->b_changelistlen == 0) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
5541 emsg(_("E664: changelist is empty")); |
7 | 5542 else if (cap->count1 < 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
5543 emsg(_("E662: At start of changelist")); |
7 | 5544 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
5545 emsg(_("E663: At end of changelist")); |
7 | 5546 } |
5547 else | |
5548 clearopbeep(cap->oap); | |
5549 # ifdef FEAT_FOLDING | |
5550 if (cap->oap->op_type == OP_NOP | |
5551 && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum) | |
5552 && (fdo_flags & FDO_MARK) | |
5553 && old_KeyTyped) | |
5554 foldOpenCursor(); | |
5555 # endif | |
5556 } | |
5557 #else | |
5558 clearopbeep(cap->oap); | |
5559 #endif | |
5560 } | |
5561 | |
5562 /* | |
5563 * Handle '"' command. | |
5564 */ | |
5565 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5566 nv_regname(cmdarg_T *cap) |
7 | 5567 { |
5568 if (checkclearop(cap->oap)) | |
5569 return; | |
5570 #ifdef FEAT_EVAL | |
5571 if (cap->nchar == '=') | |
5572 cap->nchar = get_expr_register(); | |
5573 #endif | |
5574 if (cap->nchar != NUL && valid_yank_reg(cap->nchar, FALSE)) | |
5575 { | |
5576 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
|
5577 cap->opcount = cap->count0; // remember count before '"' |
7 | 5578 #ifdef FEAT_EVAL |
5579 set_reg_var(cap->oap->regname); | |
5580 #endif | |
5581 } | |
5582 else | |
5583 clearopbeep(cap->oap); | |
5584 } | |
5585 | |
5586 /* | |
5587 * Handle "v", "V" and "CTRL-V" commands. | |
5588 * Also for "gh", "gH" and "g^H" commands: Always start Select mode, cap->arg | |
5589 * is TRUE. | |
167 | 5590 * Handle CTRL-Q just like CTRL-V. |
7 | 5591 */ |
5592 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5593 nv_visual(cmdarg_T *cap) |
7 | 5594 { |
167 | 5595 if (cap->cmdchar == Ctrl_Q) |
5596 cap->cmdchar = Ctrl_V; | |
5597 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5598 // '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
|
5599 // characterwise, linewise, or blockwise. |
7 | 5600 if (cap->oap->op_type != OP_NOP) |
5601 { | |
15279
54457fc4af0b
patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
5602 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
|
5603 finish_op = FALSE; // operator doesn't finish now but later |
7 | 5604 return; |
5605 } | |
5606 | |
5607 VIsual_select = cap->arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5608 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
|
5609 { |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5610 if (VIsual_mode == cap->cmdchar) // stop visual mode |
7 | 5611 end_visual_mode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5612 else // toggle char/block mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5613 { // or char/line mode |
7 | 5614 VIsual_mode = cap->cmdchar; |
5615 showmode(); | |
5616 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5617 redraw_curbuf_later(INVERTED); // update the inversion |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5618 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5619 else // start Visual mode |
7 | 5620 { |
5621 check_visual_highlight(); | |
3537 | 5622 if (cap->count0 > 0 && resel_VIsual_mode != NUL) |
5623 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5624 // use previously selected part |
7 | 5625 VIsual = curwin->w_cursor; |
5626 | |
5627 VIsual_active = TRUE; | |
5628 VIsual_reselect = TRUE; | |
5629 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5630 // start Select mode when 'selectmode' contains "cmd" |
7 | 5631 may_start_select('c'); |
5632 setmouse(); | |
641 | 5633 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
|
5634 redraw_cmdline = TRUE; // show visual mode later |
7 | 5635 /* |
5636 * For V and ^V, we multiply the number of lines even if there | |
5637 * was only one -- webb | |
5638 */ | |
5639 if (resel_VIsual_mode != 'v' || resel_VIsual_line_count > 1) | |
5640 { | |
5641 curwin->w_cursor.lnum += | |
5642 resel_VIsual_line_count * cap->count0 - 1; | |
5643 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
5644 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
5645 } | |
5646 VIsual_mode = resel_VIsual_mode; | |
5647 if (VIsual_mode == 'v') | |
5648 { | |
5649 if (resel_VIsual_line_count <= 1) | |
3125 | 5650 { |
5651 validate_virtcol(); | |
5652 curwin->w_curswant = curwin->w_virtcol | |
5653 + resel_VIsual_vcol * cap->count0 - 1; | |
5654 } | |
7 | 5655 else |
3125 | 5656 curwin->w_curswant = resel_VIsual_vcol; |
5657 coladvance(curwin->w_curswant); | |
7 | 5658 } |
3125 | 5659 if (resel_VIsual_vcol == MAXCOL) |
7 | 5660 { |
5661 curwin->w_curswant = MAXCOL; | |
5662 coladvance((colnr_T)MAXCOL); | |
5663 } | |
5664 else if (VIsual_mode == Ctrl_V) | |
5665 { | |
5666 validate_virtcol(); | |
5667 curwin->w_curswant = curwin->w_virtcol | |
3125 | 5668 + resel_VIsual_vcol * cap->count0 - 1; |
7 | 5669 coladvance(curwin->w_curswant); |
5670 } | |
5671 else | |
5672 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
|
5673 redraw_curbuf_later(INVERTED); // show the inversion |
7 | 5674 } |
5675 else | |
5676 { | |
5677 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5678 // start Select mode when 'selectmode' contains "cmd" |
7 | 5679 may_start_select('c'); |
5680 n_start_visual_mode(cap->cmdchar); | |
3537 | 5681 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
|
5682 ++cap->count1; // include one more char |
3537 | 5683 if (cap->count0 > 0 && --cap->count1 > 0) |
5684 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5685 // With a count select that many characters or lines. |
3537 | 5686 if (VIsual_mode == 'v' || VIsual_mode == Ctrl_V) |
5687 nv_right(cap); | |
5688 else if (VIsual_mode == 'V') | |
5689 nv_down(cap); | |
5690 } | |
7 | 5691 } |
5692 } | |
5693 } | |
5694 | |
5695 /* | |
5696 * Start selection for Shift-movement keys. | |
5697 */ | |
5698 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5699 start_selection(void) |
7 | 5700 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5701 // if 'selectmode' contains "key", start Select mode |
7 | 5702 may_start_select('k'); |
5703 n_start_visual_mode('v'); | |
5704 } | |
5705 | |
5706 /* | |
5707 * Start Select mode, if "c" is in 'selectmode' and not in a mapping or menu. | |
5708 */ | |
5709 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5710 may_start_select(int c) |
7 | 5711 { |
5712 VIsual_select = (stuff_empty() && typebuf_typed() | |
5713 && (vim_strchr(p_slm, c) != NULL)); | |
5714 } | |
5715 | |
5716 /* | |
5717 * Start Visual mode "c". | |
5718 * Should set VIsual_select before calling this. | |
5719 */ | |
5720 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5721 n_start_visual_mode(int c) |
7 | 5722 { |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5723 #ifdef FEAT_CONCEAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5724 // Check for redraw before changing the state. |
13876
156ebdcb8ef5
patch 8.0.1809: various typos
Christian Brabandt <cb@256bit.org>
parents:
13772
diff
changeset
|
5725 conceal_check_cursor_line(); |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5726 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5727 |
7 | 5728 VIsual_mode = c; |
5729 VIsual_active = TRUE; | |
5730 VIsual_reselect = TRUE; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5731 |
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5732 // 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
|
5733 // virtualedit. Recalculate curwin->w_cursor to avoid bad highlighting. |
7 | 5734 if (c == Ctrl_V && (ve_flags & VE_BLOCK) && gchar_cursor() == TAB) |
3742 | 5735 { |
5736 validate_virtcol(); | |
7 | 5737 coladvance(curwin->w_virtcol); |
3742 | 5738 } |
7 | 5739 VIsual = curwin->w_cursor; |
5740 | |
5741 #ifdef FEAT_FOLDING | |
5742 foldAdjustVisual(); | |
5743 #endif | |
5744 | |
5745 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
|
5746 #ifdef FEAT_CONCEAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5747 // Check for redraw after changing the state. |
13876
156ebdcb8ef5
patch 8.0.1809: various typos
Christian Brabandt <cb@256bit.org>
parents:
13772
diff
changeset
|
5748 conceal_check_cursor_line(); |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5749 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5750 |
641 | 5751 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
|
5752 redraw_cmdline = TRUE; // show visual mode later |
7 | 5753 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5754 // 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
|
5755 // end may still be the same, and the selection needs to be owned |
7 | 5756 clip_star.vmode = NUL; |
5757 #endif | |
5758 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5759 // 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
|
5760 // Visual area (when 'lazyredraw' is set). |
7 | 5761 if (curwin->w_redr_type < INVERTED) |
5762 { | |
5763 curwin->w_old_cursor_lnum = curwin->w_cursor.lnum; | |
5764 curwin->w_old_visual_lnum = curwin->w_cursor.lnum; | |
5765 } | |
5766 } | |
5767 | |
5768 | |
5769 /* | |
5770 * CTRL-W: Window commands | |
5771 */ | |
5772 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5773 nv_window(cmdarg_T *cap) |
7 | 5774 { |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5775 if (cap->nchar == ':') |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5776 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5777 // "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
|
5778 cap->cmdchar = ':'; |
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5779 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
|
5780 nv_colon(cap); |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5781 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5782 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
|
5783 do_window(cap->nchar, cap->count0, NUL); // everything is in window.c |
7 | 5784 } |
5785 | |
5786 /* | |
5787 * CTRL-Z: Suspend | |
5788 */ | |
5789 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5790 nv_suspend(cmdarg_T *cap) |
7 | 5791 { |
5792 clearop(cap->oap); | |
5793 if (VIsual_active) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5794 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
|
5795 do_cmdline_cmd((char_u *)"stop"); |
7 | 5796 } |
5797 | |
5798 /* | |
5799 * Commands starting with "g". | |
5800 */ | |
5801 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5802 nv_g_cmd(cmdarg_T *cap) |
7 | 5803 { |
5804 oparg_T *oap = cap->oap; | |
5805 pos_T tpos; | |
5806 int i; | |
5807 int flag = FALSE; | |
5808 | |
5809 switch (cap->nchar) | |
5810 { | |
6868 | 5811 case Ctrl_A: |
5812 case Ctrl_X: | |
7 | 5813 #ifdef MEM_PROFILE |
5814 /* | |
5815 * "g^A": dump log of used memory. | |
5816 */ | |
6868 | 5817 if (!VIsual_active && cap->nchar == Ctrl_A) |
5818 vim_mem_profile_dump(); | |
5819 else | |
5820 #endif | |
5821 /* | |
5822 * "g^A/g^X": sequentially increment visually selected region | |
5823 */ | |
5824 if (VIsual_active) | |
5825 { | |
5826 cap->arg = TRUE; | |
5827 cap->cmdchar = cap->nchar; | |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
5828 cap->nchar = NUL; |
6868 | 5829 nv_addsub(cap); |
5830 } | |
5831 else | |
5832 clearopbeep(oap); | |
7 | 5833 break; |
5834 | |
5835 /* | |
5836 * "gR": Enter virtual replace mode. | |
5837 */ | |
5838 case 'R': | |
5839 cap->arg = TRUE; | |
5840 nv_Replace(cap); | |
5841 break; | |
5842 | |
5843 case 'r': | |
5844 nv_vreplace(cap); | |
5845 break; | |
5846 | |
5847 case '&': | |
5848 do_cmdline_cmd((char_u *)"%s//~/&"); | |
5849 break; | |
5850 | |
5851 /* | |
5852 * "gv": Reselect the previous Visual area. If Visual already active, | |
5853 * exchange previous and current Visual area. | |
5854 */ | |
5855 case 'v': | |
5856 if (checkclearop(oap)) | |
5857 break; | |
5858 | |
690 | 5859 if ( curbuf->b_visual.vi_start.lnum == 0 |
5860 || curbuf->b_visual.vi_start.lnum > curbuf->b_ml.ml_line_count | |
5861 || curbuf->b_visual.vi_end.lnum == 0) | |
7 | 5862 beep_flush(); |
5863 else | |
5864 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5865 // set w_cursor to the start of the Visual area, tpos to the end |
7 | 5866 if (VIsual_active) |
5867 { | |
5868 i = VIsual_mode; | |
690 | 5869 VIsual_mode = curbuf->b_visual.vi_mode; |
5870 curbuf->b_visual.vi_mode = i; | |
7 | 5871 # ifdef FEAT_EVAL |
5872 curbuf->b_visual_mode_eval = i; | |
5873 # endif | |
5874 i = curwin->w_curswant; | |
690 | 5875 curwin->w_curswant = curbuf->b_visual.vi_curswant; |
5876 curbuf->b_visual.vi_curswant = i; | |
5877 | |
5878 tpos = curbuf->b_visual.vi_end; | |
5879 curbuf->b_visual.vi_end = curwin->w_cursor; | |
5880 curwin->w_cursor = curbuf->b_visual.vi_start; | |
5881 curbuf->b_visual.vi_start = VIsual; | |
7 | 5882 } |
5883 else | |
5884 { | |
690 | 5885 VIsual_mode = curbuf->b_visual.vi_mode; |
5886 curwin->w_curswant = curbuf->b_visual.vi_curswant; | |
5887 tpos = curbuf->b_visual.vi_end; | |
5888 curwin->w_cursor = curbuf->b_visual.vi_start; | |
7 | 5889 } |
5890 | |
5891 VIsual_active = TRUE; | |
5892 VIsual_reselect = TRUE; | |
5893 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5894 // Set Visual to the start and w_cursor to the end of the Visual |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5895 // area. Make sure they are on an existing character. |
7 | 5896 check_cursor(); |
5897 VIsual = curwin->w_cursor; | |
5898 curwin->w_cursor = tpos; | |
5899 check_cursor(); | |
5900 update_topline(); | |
5901 /* | |
5902 * When called from normal "g" command: start Select mode when | |
5903 * 'selectmode' contains "cmd". When called for K_SELECT, always | |
5904 * start Select mode. | |
5905 */ | |
5906 if (cap->arg) | |
5907 VIsual_select = TRUE; | |
5908 else | |
5909 may_start_select('c'); | |
5910 setmouse(); | |
5911 #ifdef FEAT_CLIPBOARD | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5912 // 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
|
5913 // end are still the same, and the selection needs to be owned |
7 | 5914 clip_star.vmode = NUL; |
5915 #endif | |
5916 redraw_curbuf_later(INVERTED); | |
5917 showmode(); | |
5918 } | |
5919 break; | |
5920 /* | |
5921 * "gV": Don't reselect the previous Visual area after a Select mode | |
5922 * mapping of menu. | |
5923 */ | |
5924 case 'V': | |
5925 VIsual_reselect = FALSE; | |
5926 break; | |
5927 | |
5928 /* | |
5929 * "gh": start Select mode. | |
5930 * "gH": start Select line mode. | |
5931 * "g^H": start Select block mode. | |
5932 */ | |
5933 case K_BS: | |
5934 cap->nchar = Ctrl_H; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5935 // FALLTHROUGH |
7 | 5936 case 'h': |
5937 case 'H': | |
5938 case Ctrl_H: | |
5939 # ifdef EBCDIC | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5940 // EBCDIC: 'v'-'h' != '^v'-'^h' |
7 | 5941 if (cap->nchar == Ctrl_H) |
5942 cap->cmdchar = Ctrl_V; | |
5943 else | |
5944 # endif | |
5945 cap->cmdchar = cap->nchar + ('v' - 'h'); | |
5946 cap->arg = TRUE; | |
5947 nv_visual(cap); | |
5948 break; | |
3701 | 5949 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5950 // "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
|
5951 // "gn" selects next match |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5952 // "gN" selects previous match |
3701 | 5953 case 'N': |
5954 case 'n': | |
5955 if (!current_search(cap->count1, cap->nchar == 'n')) | |
3896 | 5956 clearopbeep(oap); |
3701 | 5957 break; |
7 | 5958 |
5959 /* | |
5960 * "gj" and "gk" two new funny movement keys -- up and down | |
5961 * movement based on *screen* line rather than *file* line. | |
5962 */ | |
5963 case 'j': | |
5964 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
|
5965 // 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
|
5966 if (!curwin->w_p_wrap) |
7 | 5967 { |
5968 oap->motion_type = MLINE; | |
5969 i = cursor_down(cap->count1, oap->op_type == OP_NOP); | |
5970 } | |
5971 else | |
5972 i = nv_screengo(oap, FORWARD, cap->count1); | |
5973 if (i == FAIL) | |
5974 clearopbeep(oap); | |
5975 break; | |
5976 | |
5977 case 'k': | |
5978 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
|
5979 // 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
|
5980 if (!curwin->w_p_wrap) |
7 | 5981 { |
5982 oap->motion_type = MLINE; | |
5983 i = cursor_up(cap->count1, oap->op_type == OP_NOP); | |
5984 } | |
5985 else | |
5986 i = nv_screengo(oap, BACKWARD, cap->count1); | |
5987 if (i == FAIL) | |
5988 clearopbeep(oap); | |
5989 break; | |
5990 | |
5991 /* | |
5992 * "gJ": join two lines without inserting a space. | |
5993 */ | |
5994 case 'J': | |
5995 nv_join(cap); | |
5996 break; | |
5997 | |
5998 /* | |
5999 * "g0", "g^" and "g$": Like "0", "^" and "$" but for screen lines. | |
6000 * "gm": middle of "g0" and "g$". | |
6001 */ | |
6002 case '^': | |
6003 flag = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6004 // FALLTHROUGH |
7 | 6005 |
6006 case '0': | |
6007 case 'm': | |
6008 case K_HOME: | |
6009 case K_KHOME: | |
6010 oap->motion_type = MCHAR; | |
6011 oap->inclusive = FALSE; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12467
diff
changeset
|
6012 if (curwin->w_p_wrap && curwin->w_width != 0) |
7 | 6013 { |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6014 int width1 = curwin->w_width - curwin_col_off(); |
7 | 6015 int width2 = width1 + curwin_col_off2(); |
6016 | |
6017 validate_virtcol(); | |
6018 i = 0; | |
6019 if (curwin->w_virtcol >= (colnr_T)width1 && width2 > 0) | |
6020 i = (curwin->w_virtcol - width1) / width2 * width2 + width1; | |
6021 } | |
6022 else | |
6023 i = curwin->w_leftcol; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6024 // Go to the middle of the screen line. When 'number' or |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6025 // 'relativenumber' is on and lines are wrapping the middle can be more |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6026 // to the left. |
7 | 6027 if (cap->nchar == 'm') |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6028 i += (curwin->w_width - curwin_col_off() |
7 | 6029 + ((curwin->w_p_wrap && i > 0) |
6030 ? curwin_col_off2() : 0)) / 2; | |
6031 coladvance((colnr_T)i); | |
6032 if (flag) | |
6033 { | |
6034 do | |
6035 i = gchar_cursor(); | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6036 while (VIM_ISWHITE(i) && oneright() == OK); |
15062
3a94f7918980
patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6037 curwin->w_valid &= ~VALID_WCOL; |
7 | 6038 } |
6039 curwin->w_set_curswant = TRUE; | |
6040 break; | |
6041 | |
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
|
6042 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
|
6043 { |
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
|
6044 char_u *ptr = ml_get_curline(); |
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
|
6045 |
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
|
6046 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
|
6047 oap->inclusive = FALSE; |
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
|
6048 if (has_mbyte) |
18477
e93cab5d0f0f
patch 8.1.2233: cannot get the Vim command line arguments
Bram Moolenaar <Bram@vim.org>
parents:
18475
diff
changeset
|
6049 i = mb_string2cells(ptr, (int)STRLEN(ptr)); |
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
|
6050 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
|
6051 i = (int)STRLEN(ptr); |
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
|
6052 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
|
6053 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
|
6054 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
|
6055 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
|
6056 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
|
6057 } |
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
|
6058 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
|
6059 |
7 | 6060 case '_': |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6061 // "g_": to the last non-blank character in the line or <count> lines |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6062 // downward. |
7 | 6063 cap->oap->motion_type = MCHAR; |
6064 cap->oap->inclusive = TRUE; | |
6065 curwin->w_curswant = MAXCOL; | |
6066 if (cursor_down((long)(cap->count1 - 1), | |
6067 cap->oap->op_type == OP_NOP) == FAIL) | |
6068 clearopbeep(cap->oap); | |
6069 else | |
6070 { | |
6071 char_u *ptr = ml_get_curline(); | |
6072 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6073 // In Visual mode we may end up after the line. |
7 | 6074 if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) |
6075 --curwin->w_cursor.col; | |
6076 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6077 // Decrease the cursor column until it's on a non-blank. |
7 | 6078 while (curwin->w_cursor.col > 0 |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6079 && VIM_ISWHITE(ptr[curwin->w_cursor.col])) |
7 | 6080 --curwin->w_cursor.col; |
6081 curwin->w_set_curswant = TRUE; | |
2040
70c67b1bb1f1
updated for version 7.2.329
Bram Moolenaar <bram@zimbu.org>
parents:
2024
diff
changeset
|
6082 adjust_for_sel(cap); |
7 | 6083 } |
6084 break; | |
6085 | |
6086 case '$': | |
6087 case K_END: | |
6088 case K_KEND: | |
6089 { | |
6090 int col_off = curwin_col_off(); | |
6091 | |
6092 oap->motion_type = MCHAR; | |
6093 oap->inclusive = TRUE; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12467
diff
changeset
|
6094 if (curwin->w_p_wrap && curwin->w_width != 0) |
7 | 6095 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6096 curwin->w_curswant = MAXCOL; // so we stay at the end |
7 | 6097 if (cap->count1 == 1) |
6098 { | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6099 int width1 = curwin->w_width - col_off; |
7 | 6100 int width2 = width1 + curwin_col_off2(); |
6101 | |
6102 validate_virtcol(); | |
6103 i = width1 - 1; | |
6104 if (curwin->w_virtcol >= (colnr_T)width1) | |
6105 i += ((curwin->w_virtcol - width1) / width2 + 1) | |
6106 * width2; | |
6107 coladvance((colnr_T)i); | |
5162
c624928fbc49
updated for version 7.4a.007
Bram Moolenaar <bram@vim.org>
parents:
4472
diff
changeset
|
6108 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6109 // Make sure we stick in this column. |
5162
c624928fbc49
updated for version 7.4a.007
Bram Moolenaar <bram@vim.org>
parents:
4472
diff
changeset
|
6110 validate_virtcol(); |
c624928fbc49
updated for version 7.4a.007
Bram Moolenaar <bram@vim.org>
parents:
4472
diff
changeset
|
6111 curwin->w_curswant = curwin->w_virtcol; |
c624928fbc49
updated for version 7.4a.007
Bram Moolenaar <bram@vim.org>
parents:
4472
diff
changeset
|
6112 curwin->w_set_curswant = FALSE; |
7 | 6113 if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) |
6114 { | |
6115 /* | |
6116 * Check for landing on a character that got split at | |
6117 * the end of the line. We do not want to advance to | |
6118 * the next screen line. | |
6119 */ | |
6120 if (curwin->w_virtcol > (colnr_T)i) | |
6121 --curwin->w_cursor.col; | |
6122 } | |
6123 } | |
6124 else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == FAIL) | |
6125 clearopbeep(oap); | |
6126 } | |
6127 else | |
6128 { | |
17520
827d29c8f7e8
patch 8.1.1758: count of g$ not used correctly when text is not wrapped
Bram Moolenaar <Bram@vim.org>
parents:
17318
diff
changeset
|
6129 if (cap->count1 > 1) |
827d29c8f7e8
patch 8.1.1758: count of g$ not used correctly when text is not wrapped
Bram Moolenaar <Bram@vim.org>
parents:
17318
diff
changeset
|
6130 // if it fails, let the cursor still move to the last char |
17730
2fe133c7e972
patch 8.1.1862: Coverity warns for not using return value
Bram Moolenaar <Bram@vim.org>
parents:
17682
diff
changeset
|
6131 (void)cursor_down(cap->count1 - 1, FALSE); |
17520
827d29c8f7e8
patch 8.1.1758: count of g$ not used correctly when text is not wrapped
Bram Moolenaar <Bram@vim.org>
parents:
17318
diff
changeset
|
6132 |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6133 i = curwin->w_leftcol + curwin->w_width - col_off - 1; |
7 | 6134 coladvance((colnr_T)i); |
40 | 6135 |
17520
827d29c8f7e8
patch 8.1.1758: count of g$ not used correctly when text is not wrapped
Bram Moolenaar <Bram@vim.org>
parents:
17318
diff
changeset
|
6136 // Make sure we stick in this column. |
40 | 6137 validate_virtcol(); |
6138 curwin->w_curswant = curwin->w_virtcol; | |
6139 curwin->w_set_curswant = FALSE; | |
7 | 6140 } |
6141 } | |
6142 break; | |
6143 | |
6144 /* | |
6145 * "g*" and "g#", like "*" and "#" but without using "\<" and "\>" | |
6146 */ | |
6147 case '*': | |
6148 case '#': | |
6149 #if POUND != '#' | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6150 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
|
6151 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6152 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
|
6153 case ']': // :tselect for current identifier |
7 | 6154 nv_ident(cap); |
6155 break; | |
6156 | |
6157 /* | |
6158 * ge and gE: go back to end of word | |
6159 */ | |
6160 case 'e': | |
6161 case 'E': | |
6162 oap->motion_type = MCHAR; | |
6163 curwin->w_set_curswant = TRUE; | |
6164 oap->inclusive = TRUE; | |
6165 if (bckend_word(cap->count1, cap->nchar == 'E', FALSE) == FAIL) | |
6166 clearopbeep(oap); | |
6167 break; | |
6168 | |
6169 /* | |
6170 * "g CTRL-G": display info about cursor position | |
6171 */ | |
6172 case Ctrl_G: | |
7480
a49163681559
commit https://github.com/vim/vim/commit/ed767a2073ef150971b0439a58e7ee582af6984e
Christian Brabandt <cb@256bit.org>
parents:
7311
diff
changeset
|
6173 cursor_pos_info(NULL); |
7 | 6174 break; |
6175 | |
6176 /* | |
6177 * "gi": start Insert at the last position. | |
6178 */ | |
6179 case 'i': | |
6180 if (curbuf->b_last_insert.lnum != 0) | |
6181 { | |
6182 curwin->w_cursor = curbuf->b_last_insert; | |
6183 check_cursor_lnum(); | |
6184 i = (int)STRLEN(ml_get_curline()); | |
6185 if (curwin->w_cursor.col > (colnr_T)i) | |
6186 { | |
6187 if (virtual_active()) | |
6188 curwin->w_cursor.coladd += curwin->w_cursor.col - i; | |
6189 curwin->w_cursor.col = i; | |
6190 } | |
6191 } | |
6192 cap->cmdchar = 'i'; | |
6193 nv_edit(cap); | |
6194 break; | |
6195 | |
6196 /* | |
6197 * "gI": Start insert in column 1. | |
6198 */ | |
6199 case 'I': | |
6200 beginline(0); | |
6201 if (!checkclearopq(oap)) | |
6202 invoke_edit(cap, FALSE, 'g', FALSE); | |
6203 break; | |
6204 | |
6205 #ifdef FEAT_SEARCHPATH | |
6206 /* | |
6207 * "gf": goto file, edit file under cursor | |
6208 * "]f" and "[f": can also be used. | |
6209 */ | |
6210 case 'f': | |
681 | 6211 case 'F': |
7 | 6212 nv_gotofile(cap); |
6213 break; | |
6214 #endif | |
6215 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6216 // "g'm" and "g`m": jump to mark without setting pcmark |
7 | 6217 case '\'': |
6218 cap->arg = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6219 // FALLTHROUGH |
7 | 6220 case '`': |
6221 nv_gomark(cap); | |
6222 break; | |
6223 | |
6224 /* | |
6225 * "gs": Goto sleep. | |
6226 */ | |
6227 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
|
6228 do_sleep(cap->count1 * 1000L, FALSE); |
7 | 6229 break; |
6230 | |
6231 /* | |
6232 * "ga": Display the ascii value of the character under the | |
6233 * cursor. It is displayed in decimal, hex, and octal. -- webb | |
6234 */ | |
6235 case 'a': | |
6236 do_ascii(NULL); | |
6237 break; | |
6238 | |
6239 /* | |
6240 * "g8": Display the bytes used for the UTF-8 character under the | |
6241 * cursor. It is displayed in hex. | |
775 | 6242 * "8g8" finds illegal byte sequence. |
7 | 6243 */ |
6244 case '8': | |
775 | 6245 if (cap->count0 == 8) |
6246 utf_find_illegal(); | |
6247 else | |
6248 show_utf8(); | |
7 | 6249 break; |
6250 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6251 // "g<": show scrollback text |
447 | 6252 case '<': |
6253 show_sb_text(); | |
6254 break; | |
6255 | |
7 | 6256 /* |
6257 * "gg": Goto the first line in file. With a count it goes to | |
6258 * that line number like for "G". -- webb | |
6259 */ | |
6260 case 'g': | |
6261 cap->arg = FALSE; | |
6262 nv_goto(cap); | |
6263 break; | |
6264 | |
6265 /* | |
6266 * Two-character operators: | |
6267 * "gq" Format text | |
6268 * "gw" Format text and keep cursor position | |
6269 * "g~" Toggle the case of the text. | |
6270 * "gu" Change text to lower case. | |
6271 * "gU" Change text to upper case. | |
6272 * "g?" rot13 encoding | |
602 | 6273 * "g@" call 'operatorfunc' |
7 | 6274 */ |
6275 case 'q': | |
6276 case 'w': | |
6277 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
|
6278 // FALLTHROUGH |
7 | 6279 case '~': |
6280 case 'u': | |
6281 case 'U': | |
6282 case '?': | |
602 | 6283 case '@': |
7 | 6284 nv_operator(cap); |
6285 break; | |
6286 | |
6287 /* | |
1188 | 6288 * "gd": Find first occurrence of pattern under the cursor in the |
7 | 6289 * current function |
6290 * "gD": idem, but in the current file. | |
6291 */ | |
6292 case 'd': | |
6293 case 'D': | |
523 | 6294 nv_gd(oap, cap->nchar, (int)cap->count0); |
7 | 6295 break; |
6296 | |
6297 /* | |
6298 * g<*Mouse> : <C-*mouse> | |
6299 */ | |
6300 case K_MIDDLEMOUSE: | |
6301 case K_MIDDLEDRAG: | |
6302 case K_MIDDLERELEASE: | |
6303 case K_LEFTMOUSE: | |
6304 case K_LEFTDRAG: | |
6305 case K_LEFTRELEASE: | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
6306 case K_MOUSEMOVE: |
7 | 6307 case K_RIGHTMOUSE: |
6308 case K_RIGHTDRAG: | |
6309 case K_RIGHTRELEASE: | |
6310 case K_X1MOUSE: | |
6311 case K_X1DRAG: | |
6312 case K_X1RELEASE: | |
6313 case K_X2MOUSE: | |
6314 case K_X2DRAG: | |
6315 case K_X2RELEASE: | |
6316 mod_mask = MOD_MASK_CTRL; | |
6317 (void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); | |
6318 break; | |
6319 | |
6320 case K_IGNORE: | |
6321 break; | |
6322 | |
6323 /* | |
6324 * "gP" and "gp": same as "P" and "p" but leave cursor just after new text | |
6325 */ | |
6326 case 'p': | |
6327 case 'P': | |
6328 nv_put(cap); | |
6329 break; | |
6330 | |
6331 #ifdef FEAT_BYTEOFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6332 // "go": goto byte count from start of buffer |
7 | 6333 case 'o': |
6334 goto_byte(cap->count0); | |
6335 break; | |
6336 #endif | |
6337 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6338 // "gQ": improved Ex mode |
7 | 6339 case 'Q': |
633 | 6340 if (text_locked()) |
7 | 6341 { |
6342 clearopbeep(cap->oap); | |
633 | 6343 text_locked_msg(); |
7 | 6344 break; |
6345 } | |
631 | 6346 |
7 | 6347 if (!checkclearopq(oap)) |
6348 do_exmode(TRUE); | |
6349 break; | |
6350 | |
6351 #ifdef FEAT_JUMPLIST | |
6352 case ',': | |
6353 nv_pcmark(cap); | |
6354 break; | |
6355 | |
6356 case ';': | |
6357 cap->count1 = -cap->count1; | |
6358 nv_pcmark(cap); | |
6359 break; | |
6360 #endif | |
6361 | |
667 | 6362 case 't': |
3630 | 6363 if (!checkclearop(oap)) |
6364 goto_tabpage((int)cap->count0); | |
667 | 6365 break; |
682 | 6366 case 'T': |
3630 | 6367 if (!checkclearop(oap)) |
6368 goto_tabpage(-(int)cap->count1); | |
682 | 6369 break; |
667 | 6370 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6371 case TAB: |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6372 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
|
6373 clearopbeep(oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6374 break; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6375 |
750 | 6376 case '+': |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6377 case '-': // "g+" and "g-": undo or redo along the timeline |
750 | 6378 if (!checkclearopq(oap)) |
771 | 6379 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
|
6380 FALSE, FALSE, FALSE); |
750 | 6381 break; |
6382 | |
7 | 6383 default: |
6384 clearopbeep(oap); | |
6385 break; | |
6386 } | |
6387 } | |
6388 | |
6389 /* | |
6390 * Handle "o" and "O" commands. | |
6391 */ | |
6392 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6393 n_opencmd(cmdarg_T *cap) |
7 | 6394 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6395 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6396 linenr_T oldline = curwin->w_cursor.lnum; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6397 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6398 |
7 | 6399 if (!checkclearopq(cap->oap)) |
6400 { | |
6401 #ifdef FEAT_FOLDING | |
6402 if (cap->cmdchar == 'O') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6403 // Open above the first line of a folded sequence of lines |
7 | 6404 (void)hasFolding(curwin->w_cursor.lnum, |
6405 &curwin->w_cursor.lnum, NULL); | |
6406 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6407 // Open below the last line of a folded sequence of lines |
7 | 6408 (void)hasFolding(curwin->w_cursor.lnum, |
6409 NULL, &curwin->w_cursor.lnum); | |
6410 #endif | |
6411 if (u_save((linenr_T)(curwin->w_cursor.lnum - | |
6412 (cap->cmdchar == 'O' ? 1 : 0)), | |
6413 (linenr_T)(curwin->w_cursor.lnum + | |
6414 (cap->cmdchar == 'o' ? 1 : 0)) | |
6415 ) == OK | |
6416 && 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
|
6417 has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, |
e0ec4cd7a865
patch 8.1.2096: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
18154
diff
changeset
|
6418 0) == OK) |
7 | 6419 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6420 #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
|
6421 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
|
6422 redrawWinline(curwin, oldline); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6423 #endif |
6834 | 6424 #ifdef FEAT_SYN_HL |
6821 | 6425 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
|
6426 // force redraw of cursorline |
6821 | 6427 curwin->w_valid &= ~VALID_CROW; |
6834 | 6428 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6429 // 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
|
6430 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
|
6431 cap->count1 = 1; |
7 | 6432 invoke_edit(cap, FALSE, cap->cmdchar, TRUE); |
6433 } | |
6434 } | |
6435 } | |
6436 | |
6437 /* | |
6438 * "." command: redo last change. | |
6439 */ | |
6440 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6441 nv_dot(cmdarg_T *cap) |
7 | 6442 { |
6443 if (!checkclearopq(cap->oap)) | |
6444 { | |
6445 /* | |
6446 * If "restart_edit" is TRUE, the last but one command is repeated | |
6447 * instead of the last command (inserting text). This is used for | |
6448 * CTRL-O <.> in insert mode. | |
6449 */ | |
6450 if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) | |
6451 clearopbeep(cap->oap); | |
6452 } | |
6453 } | |
6454 | |
6455 /* | |
6456 * CTRL-R: undo undo | |
6457 */ | |
6458 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6459 nv_redo(cmdarg_T *cap) |
7 | 6460 { |
6461 if (!checkclearopq(cap->oap)) | |
6462 { | |
6463 u_redo((int)cap->count1); | |
6464 curwin->w_set_curswant = TRUE; | |
6465 } | |
6466 } | |
6467 | |
6468 /* | |
6469 * Handle "U" command. | |
6470 */ | |
6471 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6472 nv_Undo(cmdarg_T *cap) |
7 | 6473 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6474 // In Visual mode and typing "gUU" triggers an operator |
5735 | 6475 if (cap->oap->op_type == OP_UPPER || VIsual_active) |
7 | 6476 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6477 // translate "gUU" to "gUgU" |
7 | 6478 cap->cmdchar = 'g'; |
6479 cap->nchar = 'U'; | |
6480 nv_operator(cap); | |
6481 } | |
6482 else if (!checkclearopq(cap->oap)) | |
6483 { | |
6484 u_undoline(); | |
6485 curwin->w_set_curswant = TRUE; | |
6486 } | |
6487 } | |
6488 | |
6489 /* | |
6490 * '~' command: If tilde is not an operator and Visual is off: swap case of a | |
6491 * single character. | |
6492 */ | |
6493 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6494 nv_tilde(cmdarg_T *cap) |
7 | 6495 { |
5735 | 6496 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
|
6497 { |
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
|
6498 #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
|
6499 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
|
6500 { |
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
|
6501 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
|
6502 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
|
6503 } |
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
|
6504 #endif |
7 | 6505 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
|
6506 } |
7 | 6507 else |
6508 nv_operator(cap); | |
6509 } | |
6510 | |
6511 /* | |
6512 * Handle an operator command. | |
6513 * The actual work is done by do_pending_operator(). | |
6514 */ | |
6515 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6516 nv_operator(cmdarg_T *cap) |
7 | 6517 { |
6518 int op_type; | |
6519 | |
6520 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
|
6521 #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
|
6522 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
|
6523 { |
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
|
6524 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
|
6525 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
|
6526 } |
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
|
6527 #endif |
7 | 6528 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6529 if (op_type == cap->oap->op_type) // double operator works on lines |
7 | 6530 nv_lineop(cap); |
6531 else if (!checkclearop(cap->oap)) | |
6532 { | |
6533 cap->oap->start = curwin->w_cursor; | |
6534 cap->oap->op_type = op_type; | |
1490 | 6535 #ifdef FEAT_EVAL |
6536 set_op_var(op_type); | |
6537 #endif | |
6538 } | |
6539 } | |
6540 | |
6541 #ifdef FEAT_EVAL | |
6542 /* | |
6543 * Set v:operator to the characters for "optype". | |
6544 */ | |
6545 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6546 set_op_var(int optype) |
1490 | 6547 { |
6548 char_u opchars[3]; | |
6549 | |
6550 if (optype == OP_NOP) | |
6551 set_vim_var_string(VV_OP, NULL, 0); | |
6552 else | |
6553 { | |
6554 opchars[0] = get_op_char(optype); | |
6555 opchars[1] = get_extra_op_char(optype); | |
6556 opchars[2] = NUL; | |
6557 set_vim_var_string(VV_OP, opchars, -1); | |
6558 } | |
6559 } | |
6560 #endif | |
7 | 6561 |
6562 /* | |
6563 * Handle linewise operator "dd", "yy", etc. | |
6564 * | |
6565 * "_" is is a strange motion command that helps make operators more logical. | |
6566 * It is actually implemented, but not documented in the real Vi. This motion | |
6567 * command actually refers to "the current line". Commands like "dd" and "yy" | |
6568 * are really an alternate form of "d_" and "y_". It does accept a count, so | |
6569 * "d3_" works to delete 3 lines. | |
6570 */ | |
6571 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6572 nv_lineop(cmdarg_T *cap) |
7 | 6573 { |
6574 cap->oap->motion_type = MLINE; | |
6575 if (cursor_down(cap->count1 - 1L, cap->oap->op_type == OP_NOP) == FAIL) | |
6576 clearopbeep(cap->oap); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6577 else if ( (cap->oap->op_type == OP_DELETE // only with linewise motions |
4011 | 6578 && cap->oap->motion_force != 'v' |
6579 && cap->oap->motion_force != Ctrl_V) | |
7 | 6580 || cap->oap->op_type == OP_LSHIFT |
6581 || cap->oap->op_type == OP_RSHIFT) | |
6582 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
|
6583 else if (cap->oap->op_type != OP_YANK) // 'Y' does not move cursor |
7 | 6584 beginline(BL_WHITE | BL_FIX); |
6585 } | |
6586 | |
6587 /* | |
6588 * <Home> command. | |
6589 */ | |
6590 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6591 nv_home(cmdarg_T *cap) |
7 | 6592 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6593 // CTRL-HOME is like "gg" |
180 | 6594 if (mod_mask & MOD_MASK_CTRL) |
6595 nv_goto(cap); | |
6596 else | |
6597 { | |
6598 cap->count0 = 1; | |
6599 nv_pipe(cap); | |
6600 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6601 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
|
6602 // one-character line). |
7 | 6603 } |
6604 | |
6605 /* | |
6606 * "|" command. | |
6607 */ | |
6608 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6609 nv_pipe(cmdarg_T *cap) |
7 | 6610 { |
6611 cap->oap->motion_type = MCHAR; | |
6612 cap->oap->inclusive = FALSE; | |
6613 beginline(0); | |
6614 if (cap->count0 > 0) | |
6615 { | |
6616 coladvance((colnr_T)(cap->count0 - 1)); | |
6617 curwin->w_curswant = (colnr_T)(cap->count0 - 1); | |
6618 } | |
6619 else | |
6620 curwin->w_curswant = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6621 // 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
|
6622 // we ended; differs if line is too short |
7 | 6623 curwin->w_set_curswant = FALSE; |
6624 } | |
6625 | |
6626 /* | |
6627 * Handle back-word command "b" and "B". | |
6628 * cap->arg is 1 for "B" | |
6629 */ | |
6630 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6631 nv_bck_word(cmdarg_T *cap) |
7 | 6632 { |
6633 cap->oap->motion_type = MCHAR; | |
6634 cap->oap->inclusive = FALSE; | |
6635 curwin->w_set_curswant = TRUE; | |
6636 if (bck_word(cap->count1, cap->arg, FALSE) == FAIL) | |
6637 clearopbeep(cap->oap); | |
6638 #ifdef FEAT_FOLDING | |
6639 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6640 foldOpenCursor(); | |
6641 #endif | |
6642 } | |
6643 | |
6644 /* | |
6645 * Handle word motion commands "e", "E", "w" and "W". | |
6646 * cap->arg is TRUE for "E" and "W". | |
6647 */ | |
6648 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6649 nv_wordcmd(cmdarg_T *cap) |
7 | 6650 { |
6651 int n; | |
6652 int word_end; | |
6653 int flag = FALSE; | |
1573 | 6654 pos_T startpos = curwin->w_cursor; |
7 | 6655 |
6656 /* | |
6657 * Set inclusive for the "E" and "e" command. | |
6658 */ | |
6659 if (cap->cmdchar == 'e' || cap->cmdchar == 'E') | |
6660 word_end = TRUE; | |
6661 else | |
6662 word_end = FALSE; | |
6663 cap->oap->inclusive = word_end; | |
6664 | |
6665 /* | |
6666 * "cw" and "cW" are a special case. | |
6667 */ | |
6668 if (!word_end && cap->oap->op_type == OP_CHANGE) | |
6669 { | |
6670 n = gchar_cursor(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6671 if (n != NUL) // not an empty line |
7 | 6672 { |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6673 if (VIM_ISWHITE(n)) |
7 | 6674 { |
6675 /* | |
6676 * Reproduce a funny Vi behaviour: "cw" on a blank only | |
6677 * changes one character, not all blanks until the start of | |
6678 * the next word. Only do this when the 'w' flag is included | |
6679 * in 'cpoptions'. | |
6680 */ | |
6681 if (cap->count1 == 1 && vim_strchr(p_cpo, CPO_CW) != NULL) | |
6682 { | |
6683 cap->oap->inclusive = TRUE; | |
6684 cap->oap->motion_type = MCHAR; | |
6685 return; | |
6686 } | |
6687 } | |
6688 else | |
6689 { | |
6690 /* | |
6691 * This is a little strange. To match what the real Vi does, | |
6692 * we effectively map 'cw' to 'ce', and 'cW' to 'cE', provided | |
6693 * that we are not on a space or a TAB. This seems impolite | |
6694 * at first, but it's really more what we mean when we say | |
6695 * 'cw'. | |
6696 * Another strangeness: When standing on the end of a word | |
4352 | 6697 * "ce" will change until the end of the next word, but "cw" |
7 | 6698 * will change only one character! This is done by setting |
6699 * flag. | |
6700 */ | |
6701 cap->oap->inclusive = TRUE; | |
6702 word_end = TRUE; | |
6703 flag = TRUE; | |
6704 } | |
6705 } | |
6706 } | |
6707 | |
6708 cap->oap->motion_type = MCHAR; | |
6709 curwin->w_set_curswant = TRUE; | |
6710 if (word_end) | |
6711 n = end_word(cap->count1, cap->arg, flag, FALSE); | |
6712 else | |
6713 n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP); | |
6714 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6715 // 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
|
6716 // 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
|
6717 if (LT_POS(startpos, curwin->w_cursor)) |
1505 | 6718 adjust_cursor(cap->oap); |
7 | 6719 |
6720 if (n == FAIL && cap->oap->op_type == OP_NOP) | |
6721 clearopbeep(cap->oap); | |
6722 else | |
6723 { | |
6724 adjust_for_sel(cap); | |
6725 #ifdef FEAT_FOLDING | |
6726 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6727 foldOpenCursor(); | |
6728 #endif | |
6729 } | |
6730 } | |
6731 | |
6732 /* | |
1505 | 6733 * Used after a movement command: If the cursor ends up on the NUL after the |
6734 * end of the line, may move it back to the last character and make the motion | |
6735 * inclusive. | |
6736 */ | |
6737 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6738 adjust_cursor(oparg_T *oap) |
1505 | 6739 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6740 // 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
|
6741 // - the column is > 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6742 // - 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
|
6743 // - 'virtualedit' is not "all" and not "onemore". |
1505 | 6744 if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL |
6745 && (!VIsual_active || *p_sel == 'o') | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
6746 && !virtual_active() && (ve_flags & VE_ONEMORE) == 0) |
1505 | 6747 { |
6748 --curwin->w_cursor.col; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6749 // prevent cursor from moving on the trail byte |
1505 | 6750 if (has_mbyte) |
6751 mb_adjust_cursor(); | |
6752 oap->inclusive = TRUE; | |
6753 } | |
6754 } | |
6755 | |
6756 /* | |
7 | 6757 * "0" and "^" commands. |
6758 * cap->arg is the argument for beginline(). | |
6759 */ | |
6760 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6761 nv_beginline(cmdarg_T *cap) |
7 | 6762 { |
6763 cap->oap->motion_type = MCHAR; | |
6764 cap->oap->inclusive = FALSE; | |
6765 beginline(cap->arg); | |
6766 #ifdef FEAT_FOLDING | |
6767 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6768 foldOpenCursor(); | |
6769 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6770 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
|
6771 // one-character line). |
7 | 6772 } |
6773 | |
6774 /* | |
6775 * In exclusive Visual mode, may include the last character. | |
6776 */ | |
6777 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6778 adjust_for_sel(cmdarg_T *cap) |
7 | 6779 { |
6780 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
|
6781 && gchar_cursor() != NUL && LT_POS(VIsual, curwin->w_cursor)) |
7 | 6782 { |
6783 if (has_mbyte) | |
6784 inc_cursor(); | |
6785 else | |
6786 ++curwin->w_cursor.col; | |
6787 cap->oap->inclusive = FALSE; | |
6788 } | |
6789 } | |
6790 | |
6791 /* | |
6792 * Exclude last character at end of Visual area for 'selection' == "exclusive". | |
6793 * Should check VIsual_mode before calling this. | |
6794 * Returns TRUE when backed up to the previous line. | |
6795 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
6796 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6797 unadjust_for_sel(void) |
7 | 6798 { |
6799 pos_T *pp; | |
6800 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6801 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
|
6802 { |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6803 if (LT_POS(VIsual, curwin->w_cursor)) |
7 | 6804 pp = &curwin->w_cursor; |
6805 else | |
6806 pp = &VIsual; | |
6807 if (pp->coladd > 0) | |
6808 --pp->coladd; | |
6809 else | |
6810 if (pp->col > 0) | |
6811 { | |
6812 --pp->col; | |
2933 | 6813 mb_adjustpos(curbuf, pp); |
7 | 6814 } |
6815 else if (pp->lnum > 1) | |
6816 { | |
6817 --pp->lnum; | |
6818 pp->col = (colnr_T)STRLEN(ml_get(pp->lnum)); | |
6819 return TRUE; | |
6820 } | |
6821 } | |
6822 return FALSE; | |
6823 } | |
6824 | |
6825 /* | |
6826 * SELECT key in Normal or Visual mode: end of Select mode mapping. | |
6827 */ | |
6828 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6829 nv_select(cmdarg_T *cap) |
7 | 6830 { |
6831 if (VIsual_active) | |
6832 VIsual_select = TRUE; | |
6833 else if (VIsual_reselect) | |
6834 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6835 cap->nchar = 'v'; // fake "gv" command |
7 | 6836 cap->arg = TRUE; |
6837 nv_g_cmd(cap); | |
6838 } | |
6839 } | |
6840 | |
6841 | |
6842 /* | |
6843 * "G", "gg", CTRL-END, CTRL-HOME. | |
6844 * cap->arg is TRUE for "G". | |
6845 */ | |
6846 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6847 nv_goto(cmdarg_T *cap) |
7 | 6848 { |
6849 linenr_T lnum; | |
6850 | |
6851 if (cap->arg) | |
6852 lnum = curbuf->b_ml.ml_line_count; | |
6853 else | |
6854 lnum = 1L; | |
6855 cap->oap->motion_type = MLINE; | |
6856 setpcmark(); | |
6857 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6858 // When a count is given, use it instead of the default lnum |
7 | 6859 if (cap->count0 != 0) |
6860 lnum = cap->count0; | |
6861 if (lnum < 1L) | |
6862 lnum = 1L; | |
6863 else if (lnum > curbuf->b_ml.ml_line_count) | |
6864 lnum = curbuf->b_ml.ml_line_count; | |
6865 curwin->w_cursor.lnum = lnum; | |
6866 beginline(BL_SOL | BL_FIX); | |
6867 #ifdef FEAT_FOLDING | |
6868 if ((fdo_flags & FDO_JUMP) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6869 foldOpenCursor(); | |
6870 #endif | |
6871 } | |
6872 | |
6873 /* | |
6874 * CTRL-\ in Normal mode. | |
6875 */ | |
6876 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6877 nv_normal(cmdarg_T *cap) |
7 | 6878 { |
6879 if (cap->nchar == Ctrl_N || cap->nchar == Ctrl_G) | |
6880 { | |
6881 clearop(cap->oap); | |
643 | 6882 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
|
6883 clear_cmdline = TRUE; // unshow mode later |
7 | 6884 restart_edit = 0; |
6885 #ifdef FEAT_CMDWIN | |
6886 if (cmdwin_type != 0) | |
6887 cmdwin_result = Ctrl_C; | |
6888 #endif | |
6889 if (VIsual_active) | |
6890 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6891 end_visual_mode(); // stop Visual |
7 | 6892 redraw_curbuf_later(INVERTED); |
6893 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6894 // CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. |
7 | 6895 if (cap->nchar == Ctrl_G && p_im) |
6896 restart_edit = 'a'; | |
6897 } | |
6898 else | |
6899 clearopbeep(cap->oap); | |
6900 } | |
6901 | |
6902 /* | |
6903 * ESC in Normal mode: beep, but don't flush buffers. | |
6904 * Don't even beep if we are canceling a command. | |
6905 */ | |
6906 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6907 nv_esc(cmdarg_T *cap) |
7 | 6908 { |
6909 int no_reason; | |
6910 | |
6911 no_reason = (cap->oap->op_type == OP_NOP | |
6912 && cap->opcount == 0 | |
6913 && cap->count0 == 0 | |
6914 && cap->oap->regname == 0 | |
6915 && !p_im); | |
6916 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6917 if (cap->arg) // TRUE for CTRL-C |
7 | 6918 { |
6919 if (restart_edit == 0 | |
6920 #ifdef FEAT_CMDWIN | |
6921 && cmdwin_type == 0 | |
6922 #endif | |
6923 && !VIsual_active | |
6924 && 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
|
6925 { |
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
|
6926 if (anyBufIsChanged()) |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6927 msg(_("Type :qa! and press <Enter> to abandon all changes and exit Vim")); |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6928 else |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6929 msg(_("Type :qa and press <Enter> to exit Vim")); |
4411c38f3d16
patch 8.1.1049: when user tries to exit with CTRL-C message is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
6930 } |
7 | 6931 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6932 // 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
|
6933 // set again below when halfway a mapping. |
7 | 6934 if (!p_im) |
6935 restart_edit = 0; | |
6936 #ifdef FEAT_CMDWIN | |
6937 if (cmdwin_type != 0) | |
6938 { | |
6939 cmdwin_result = K_IGNORE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6940 got_int = FALSE; // don't stop executing autocommands et al. |
7 | 6941 return; |
6942 } | |
6943 #endif | |
6944 } | |
6945 | |
6946 if (VIsual_active) | |
6947 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6948 end_visual_mode(); // stop Visual |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6949 check_cursor_col(); // make sure cursor is not beyond EOL |
7 | 6950 curwin->w_set_curswant = TRUE; |
6951 redraw_curbuf_later(INVERTED); | |
6952 } | |
5735 | 6953 else if (no_reason) |
6949 | 6954 vim_beep(BO_ESC); |
7 | 6955 clearop(cap->oap); |
6956 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6957 // 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
|
6958 // 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
|
6959 if (restart_edit == 0 && goto_im() && ex_normal_busy == 0) |
7 | 6960 restart_edit = 'a'; |
6961 } | |
6962 | |
6963 /* | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6964 * 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
|
6965 */ |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6966 void |
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(void) |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6968 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6969 curwin->w_set_curswant = TRUE; |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6970 if (ve_flags == VE_ALL) |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6971 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6972 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
|
6973 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6974 // 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
|
6975 // character past the end of the line |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6976 State = INSERT; |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6977 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
|
6978 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
|
6979 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6980 else |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6981 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
|
6982 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6983 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
6984 /* |
7 | 6985 * 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
|
6986 * Also handle K_PS, start bracketed paste. |
7 | 6987 */ |
6988 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6989 nv_edit(cmdarg_T *cap) |
7 | 6990 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6991 // <Insert> is equal to "i" |
7 | 6992 if (cap->cmdchar == K_INS || cap->cmdchar == K_KINS) |
6993 cap->cmdchar = 'i'; | |
6994 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6995 // in Visual mode "A" and "I" are an operator |
7 | 6996 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
|
6997 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
6998 #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
|
6999 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
|
7000 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
7001 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
|
7002 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
|
7003 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
|
7004 return; |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
7005 } |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
7006 #endif |
7 | 7007 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
|
7008 } |
7 | 7009 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7010 // in Visual mode and after an operator "a" and "i" are for text objects |
5735 | 7011 else if ((cap->cmdchar == 'a' || cap->cmdchar == 'i') |
7012 && (cap->oap->op_type != OP_NOP || VIsual_active)) | |
7 | 7013 { |
7014 #ifdef FEAT_TEXTOBJ | |
7015 nv_object(cap); | |
7016 #else | |
7017 clearopbeep(cap->oap); | |
7018 #endif | |
7019 } | |
11892
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
7020 #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
|
7021 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
|
7022 { |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
7023 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
|
7024 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
|
7025 return; |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
7026 } |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
7027 #endif |
7 | 7028 else if (!curbuf->b_p_ma && !p_im) |
7029 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7030 // Only give this error when 'insertmode' is off. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
7031 emsg(_(e_modifiable)); |
7 | 7032 clearop(cap->oap); |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7033 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
|
7034 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7035 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 7036 } |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7037 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
|
7038 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7039 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
|
7040 pos_T old_visual = VIsual; |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7041 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7042 // 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
|
7043 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
|
7044 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7045 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
|
7046 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
|
7047 } |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7048 else |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7049 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
|
7050 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
|
7051 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
|
7052 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
|
7053 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
|
7054 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
|
7055 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7056 // When the last char in the line was deleted then append. Detect this |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7057 // by checking if the cursor moved to before the Visual area. |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
7058 if (*ml_get_cursor() != NUL && LT_POS(curwin->w_cursor, old_pos) |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
7059 && LT_POS(curwin->w_cursor, old_visual)) |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7060 inc_cursor(); |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7061 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7062 // 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
|
7063 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
|
7064 } |
7 | 7065 else if (!checkclearopq(cap->oap)) |
7066 { | |
7067 switch (cap->cmdchar) | |
7068 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7069 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
|
7070 set_cursor_for_append_to_line(); |
7 | 7071 break; |
7072 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7073 case 'I': // "I"nsert before the first non-blank |
164 | 7074 if (vim_strchr(p_cpo, CPO_INSEND) == NULL) |
7075 beginline(BL_WHITE); | |
7076 else | |
7077 beginline(BL_WHITE|BL_FIX); | |
7 | 7078 break; |
7079 | |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7080 case K_PS: |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7081 // 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
|
7082 // 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
|
7083 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
|
7084 break; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7085 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7086 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7087 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
|
7088 // 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
|
7089 // column otherwise, also to append after an unprintable char |
7 | 7090 if (virtual_active() |
7091 && (curwin->w_cursor.coladd > 0 | |
7092 || *ml_get_cursor() == NUL | |
7093 || *ml_get_cursor() == TAB)) | |
7094 curwin->w_cursor.coladd++; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7095 else if (*ml_get_cursor() != NUL) |
7 | 7096 inc_cursor(); |
7097 break; | |
7098 } | |
7099 | |
7100 if (curwin->w_cursor.coladd && cap->cmdchar != 'A') | |
7101 { | |
7102 int save_State = State; | |
7103 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7104 // 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
|
7105 // character past the end of the line |
7 | 7106 State = INSERT; |
7107 coladvance(getviscol()); | |
7108 State = save_State; | |
7109 } | |
7110 | |
7111 invoke_edit(cap, FALSE, cap->cmdchar, FALSE); | |
7112 } | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7113 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
|
7114 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7115 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 7116 } |
7117 | |
7118 /* | |
7119 * Invoke edit() and take care of "restart_edit" and the return value. | |
7120 */ | |
7121 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7122 invoke_edit( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7123 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7124 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
|
7125 int cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7126 int startln) |
7 | 7127 { |
7128 int restart_edit_save = 0; | |
7129 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7130 // 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
|
7131 // 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
|
7132 // it. |
7 | 7133 if (repl || !stuff_empty()) |
7134 restart_edit_save = restart_edit; | |
7135 else | |
7136 restart_edit_save = 0; | |
7137 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7138 // Always reset "restart_edit", this is not a restarted edit. |
7 | 7139 restart_edit = 0; |
7140 | |
7141 if (edit(cmd, startln, cap->count1)) | |
7142 cap->retval |= CA_COMMAND_BUSY; | |
7143 | |
7144 if (restart_edit == 0) | |
7145 restart_edit = restart_edit_save; | |
7146 } | |
7147 | |
7148 #ifdef FEAT_TEXTOBJ | |
7149 /* | |
7150 * "a" or "i" while an operator is pending or in Visual mode: object motion. | |
7151 */ | |
7152 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7153 nv_object( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7154 cmdarg_T *cap) |
7 | 7155 { |
7156 int flag; | |
7157 int include; | |
7158 char_u *mps_save; | |
7159 | |
7160 if (cap->cmdchar == 'i') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7161 include = FALSE; // "ix" = inner object: exclude white space |
7 | 7162 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7163 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
|
7164 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7165 // Make sure (), [], {} and <> are in 'matchpairs' |
7 | 7166 mps_save = curbuf->b_p_mps; |
7167 curbuf->b_p_mps = (char_u *)"(:),{:},[:],<:>"; | |
7168 | |
7169 switch (cap->nchar) | |
7170 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7171 case 'w': // "aw" = a word |
7 | 7172 flag = current_word(cap->oap, cap->count1, include, FALSE); |
7173 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7174 case 'W': // "aW" = a WORD |
7 | 7175 flag = current_word(cap->oap, cap->count1, include, TRUE); |
7176 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7177 case 'b': // "ab" = a braces block |
7 | 7178 case '(': |
7179 case ')': | |
7180 flag = current_block(cap->oap, cap->count1, include, '(', ')'); | |
7181 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7182 case 'B': // "aB" = a Brackets block |
7 | 7183 case '{': |
7184 case '}': | |
7185 flag = current_block(cap->oap, cap->count1, include, '{', '}'); | |
7186 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7187 case '[': // "a[" = a [] block |
7 | 7188 case ']': |
7189 flag = current_block(cap->oap, cap->count1, include, '[', ']'); | |
7190 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7191 case '<': // "a<" = a <> block |
7 | 7192 case '>': |
7193 flag = current_block(cap->oap, cap->count1, include, '<', '>'); | |
7194 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7195 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
|
7196 // 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
|
7197 // 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
|
7198 // (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
|
7199 // 1) <b> 2) <b> |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7200 // foobar foobar |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7201 // </b> </b> |
6661 | 7202 cap->retval |= CA_NO_ADJ_OP_END; |
420 | 7203 flag = current_tagblock(cap->oap, cap->count1, include); |
7204 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7205 case 'p': // "ap" = a paragraph |
7 | 7206 flag = current_par(cap->oap, cap->count1, include, 'p'); |
7207 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7208 case 's': // "as" = a sentence |
7 | 7209 flag = current_sent(cap->oap, cap->count1, include); |
7210 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7211 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
|
7212 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
|
7213 case '`': // "a`" = a backtick quoted string |
12 | 7214 flag = current_quote(cap->oap, cap->count1, include, |
7215 cap->nchar); | |
7216 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7217 #if 0 // TODO |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7218 case 'S': // "aS" = a section |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7219 case 'f': // "af" = a filename |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7220 case 'u': // "au" = a URL |
7 | 7221 #endif |
7222 default: | |
7223 flag = FAIL; | |
7224 break; | |
7225 } | |
7226 | |
7227 curbuf->b_p_mps = mps_save; | |
7228 if (flag == FAIL) | |
7229 clearopbeep(cap->oap); | |
7230 adjust_cursor_col(); | |
7231 curwin->w_set_curswant = TRUE; | |
7232 } | |
7233 #endif | |
7234 | |
7235 /* | |
7236 * "q" command: Start/stop recording. | |
7237 * "q:", "q/", "q?": edit command-line in command-line window. | |
7238 */ | |
7239 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7240 nv_record(cmdarg_T *cap) |
7 | 7241 { |
7242 if (cap->oap->op_type == OP_FORMAT) | |
7243 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7244 // "gqq" is the same as "gqgq": format line |
7 | 7245 cap->cmdchar = 'g'; |
7246 cap->nchar = 'q'; | |
7247 nv_operator(cap); | |
7248 } | |
7249 else if (!checkclearop(cap->oap)) | |
7250 { | |
7251 #ifdef FEAT_CMDWIN | |
7252 if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') | |
7253 { | |
7254 stuffcharReadbuff(cap->nchar); | |
7255 stuffcharReadbuff(K_CMDWIN); | |
7256 } | |
7257 else | |
7258 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7259 // (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
|
7260 // 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
|
7261 if (reg_executing == 0 && do_record(cap->nchar) == FAIL) |
7 | 7262 clearopbeep(cap->oap); |
7263 } | |
7264 } | |
7265 | |
7266 /* | |
7267 * Handle the "@r" command. | |
7268 */ | |
7269 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7270 nv_at(cmdarg_T *cap) |
7 | 7271 { |
7272 if (checkclearop(cap->oap)) | |
7273 return; | |
7274 #ifdef FEAT_EVAL | |
7275 if (cap->nchar == '=') | |
7276 { | |
7277 if (get_expr_register() == NUL) | |
7278 return; | |
7279 } | |
7280 #endif | |
7281 while (cap->count1-- && !got_int) | |
7282 { | |
1034 | 7283 if (do_execreg(cap->nchar, FALSE, FALSE, FALSE) == FAIL) |
7 | 7284 { |
7285 clearopbeep(cap->oap); | |
7286 break; | |
7287 } | |
7288 line_breakcheck(); | |
7289 } | |
7290 } | |
7291 | |
7292 /* | |
7293 * Handle the CTRL-U and CTRL-D commands. | |
7294 */ | |
7295 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7296 nv_halfpage(cmdarg_T *cap) |
7 | 7297 { |
7298 if ((cap->cmdchar == Ctrl_U && curwin->w_cursor.lnum == 1) | |
7299 || (cap->cmdchar == Ctrl_D | |
7300 && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)) | |
7301 clearopbeep(cap->oap); | |
7302 else if (!checkclearop(cap->oap)) | |
7303 halfpage(cap->cmdchar == Ctrl_D, cap->count0); | |
7304 } | |
7305 | |
7306 /* | |
7307 * Handle "J" or "gJ" command. | |
7308 */ | |
7309 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7310 nv_join(cmdarg_T *cap) |
7 | 7311 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7312 if (VIsual_active) // join the visual lines |
7 | 7313 nv_operator(cap); |
5735 | 7314 else if (!checkclearop(cap->oap)) |
7 | 7315 { |
7316 if (cap->count0 <= 1) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7317 cap->count0 = 2; // default for join is two lines! |
7 | 7318 if (curwin->w_cursor.lnum + cap->count0 - 1 > |
7319 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
|
7320 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7321 // 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
|
7322 if (cap->count0 <= 2) |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7323 { |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7324 clearopbeep(cap->oap); |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7325 return; |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7326 } |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7327 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
|
7328 - curwin->w_cursor.lnum + 1; |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7329 } |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7330 |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7331 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
|
7332 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
|
7333 (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); |
7 | 7334 } |
7335 } | |
7336 | |
7337 /* | |
7338 * "P", "gP", "p" and "gp" commands. | |
7339 */ | |
7340 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7341 nv_put(cmdarg_T *cap) |
7 | 7342 { |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7343 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
|
7344 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7345 |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7346 /* |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7347 * "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
|
7348 * "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
|
7349 */ |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7350 static void |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7351 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
|
7352 { |
7 | 7353 int regname = 0; |
7354 void *reg1 = NULL, *reg2 = NULL; | |
84 | 7355 int empty = FALSE; |
236 | 7356 int was_visual = FALSE; |
7 | 7357 int dir; |
7358 int flags = 0; | |
7359 | |
7360 if (cap->oap->op_type != OP_NOP) | |
7361 { | |
7362 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7363 // "dp" is ":diffput" |
7 | 7364 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'p') |
7365 { | |
7366 clearop(cap->oap); | |
6314 | 7367 nv_diffgetput(TRUE, cap->opcount); |
7 | 7368 } |
7369 else | |
7370 #endif | |
7371 clearopbeep(cap->oap); | |
7372 } | |
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
|
7373 #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
|
7374 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
|
7375 { |
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
|
7376 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
|
7377 } |
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
|
7378 #endif |
7 | 7379 else |
7380 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7381 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
|
7382 { |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7383 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
|
7384 ? FORWARD : BACKWARD; |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7385 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
|
7386 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7387 else |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7388 dir = (cap->cmdchar == 'P' |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7389 || (cap->cmdchar == 'g' && cap->nchar == 'P')) |
7 | 7390 ? BACKWARD : FORWARD; |
7391 prep_redo_cmd(cap); | |
7392 if (cap->cmdchar == 'g') | |
7393 flags |= PUT_CURSEND; | |
7394 | |
7395 if (VIsual_active) | |
7396 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7397 // 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
|
7398 // 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
|
7399 // 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
|
7400 // overwrites if the old contents is being put. |
236 | 7401 was_visual = TRUE; |
7 | 7402 regname = cap->oap->regname; |
5735 | 7403 #ifdef FEAT_CLIPBOARD |
7 | 7404 adjust_clip_reg(®name); |
5735 | 7405 #endif |
5682 | 7406 if (regname == 0 || regname == '"' |
4013 | 7407 || VIM_ISDIGIT(regname) || regname == '-' |
5735 | 7408 #ifdef FEAT_CLIPBOARD |
7 | 7409 || (clip_unnamed && (regname == '*' || regname == '+')) |
5735 | 7410 #endif |
7 | 7411 |
7412 ) | |
7413 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7414 // 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
|
7415 // put, save it first. |
7 | 7416 reg1 = get_register(regname, TRUE); |
7417 } | |
7418 | |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7419 // Now delete the selected text. Avoid messages here. |
7 | 7420 cap->cmdchar = 'd'; |
7421 cap->nchar = NUL; | |
7422 cap->oap->regname = NUL; | |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7423 ++msg_silent; |
7 | 7424 nv_operator(cap); |
7425 do_pending_operator(cap, 0, FALSE); | |
84 | 7426 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
|
7427 --msg_silent; |
7 | 7428 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7429 // delete PUT_LINE_BACKWARD; |
7 | 7430 cap->oap->regname = regname; |
7431 | |
7432 if (reg1 != NULL) | |
7433 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7434 // 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
|
7435 // it first. Then put back what was there before the delete. |
7 | 7436 reg2 = get_register(regname, FALSE); |
7437 put_register(regname, reg1); | |
7438 } | |
7439 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7440 // 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
|
7441 // 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
|
7442 // characterwise, split a line when putting lines. |
7 | 7443 if (VIsual_mode == 'V') |
7444 flags |= PUT_LINE; | |
7445 else if (VIsual_mode == 'v') | |
7446 flags |= PUT_LINE_SPLIT; | |
7447 if (VIsual_mode == Ctrl_V && dir == FORWARD) | |
7448 flags |= PUT_LINE_FORWARD; | |
7449 dir = BACKWARD; | |
7450 if ((VIsual_mode != 'V' | |
7451 && curwin->w_cursor.col < curbuf->b_op_start.col) | |
7452 || (VIsual_mode == 'V' | |
7453 && 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
|
7454 // 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
|
7455 // forward. |
7 | 7456 dir = FORWARD; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7457 // May have been reset in do_put(). |
5365 | 7458 VIsual_active = TRUE; |
7 | 7459 } |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7460 do_put(cap->oap->regname, NULL, dir, cap->count1, flags); |
7 | 7461 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7462 // If a register was saved, put it back now. |
7 | 7463 if (reg2 != NULL) |
7464 put_register(regname, reg2); | |
236 | 7465 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7466 // 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
|
7467 // be the most useful, since the original text was removed. |
236 | 7468 if (was_visual) |
7469 { | |
690 | 7470 curbuf->b_visual.vi_start = curbuf->b_op_start; |
7471 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
|
7472 // need to adjust cursor position |
7241
0c1278704b5c
commit https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27
Christian Brabandt <cb@256bit.org>
parents:
7143
diff
changeset
|
7473 if (*p_sel == 'e') |
0c1278704b5c
commit https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27
Christian Brabandt <cb@256bit.org>
parents:
7143
diff
changeset
|
7474 inc(&curbuf->b_visual.vi_end); |
236 | 7475 } |
7476 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7477 // 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
|
7478 // line that needs to be deleted now. |
84 | 7479 if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) |
817 | 7480 { |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
7481 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
|
7482 deleted_lines(curbuf->b_ml.ml_line_count + 1, 1); |
817 | 7483 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7484 // 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
|
7485 // line. |
817 | 7486 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
7487 { | |
7488 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
7489 coladvance((colnr_T)MAXCOL); | |
7490 } | |
7491 } | |
7 | 7492 auto_format(FALSE, TRUE); |
7493 } | |
7494 } | |
7495 | |
7496 /* | |
7497 * "o" and "O" commands. | |
7498 */ | |
7499 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7500 nv_open(cmdarg_T *cap) |
7 | 7501 { |
7502 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7503 // "do" is ":diffget" |
7 | 7504 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'o') |
7505 { | |
7506 clearop(cap->oap); | |
6314 | 7507 nv_diffgetput(FALSE, cap->opcount); |
7 | 7508 } |
7509 else | |
7510 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7511 if (VIsual_active) // switch start and end of visual |
7 | 7512 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
|
7513 #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
|
7514 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
|
7515 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
|
7516 #endif |
7 | 7517 else |
7518 n_opencmd(cap); | |
7519 } | |
7520 | |
7521 #ifdef FEAT_NETBEANS_INTG | |
7522 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7523 nv_nbcmd(cmdarg_T *cap) |
7 | 7524 { |
7525 netbeans_keycommand(cap->nchar); | |
7526 } | |
7527 #endif | |
7528 | |
7529 #ifdef FEAT_DND | |
7530 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7531 nv_drop(cmdarg_T *cap UNUSED) |
7 | 7532 { |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7533 do_put('~', NULL, BACKWARD, 1L, PUT_CURSEND); |
7 | 7534 } |
7535 #endif | |
203 | 7536 |
7537 /* | |
7538 * Trigger CursorHold event. | |
7539 * When waiting for a character for 'updatetime' K_CURSORHOLD is put in the | |
7540 * input buffer. "did_cursorhold" is set to avoid retriggering. | |
7541 */ | |
7542 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7543 nv_cursorhold(cmdarg_T *cap) |
203 | 7544 { |
7545 apply_autocmds(EVENT_CURSORHOLD, NULL, NULL, FALSE, curbuf); | |
7546 did_cursorhold = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7547 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
226 | 7548 } |