Mercurial > vim
annotate src/normal.c @ 27263:93d4ee1e6113 v8.2.4160
patch 8.2.4160: cannot change the register used for Select mode delete
Commit: https://github.com/vim/vim/commit/4ede01f18884961f2e008880b4964e5d61ea5c36
Author: Shougo Matsushita <Shougo.Matsu@gmail.com>
Date: Thu Jan 20 15:26:03 2022 +0000
patch 8.2.4160: cannot change the register used for Select mode delete
Problem: Cannot change the register used for Select mode delete.
Solution: Make CTRL-R set the register to be used when deleting text for
Select mode. (Shougo Matsushita, closes #9531)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 20 Jan 2022 16:30:04 +0100 |
parents | a9eeb18e749c |
children | a9f0c1f06c84 |
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 |
2667 | 19 #ifdef FEAT_EVAL |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
20 static void set_vcount_ca(cmdarg_T *cap, int *set_prevcount); |
2667 | 21 #endif |
16606
7e733046db1d
patch 8.1.1306: Borland support is outdated and doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16598
diff
changeset
|
22 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
|
23 static void unshift_special(cmdarg_T *cap); |
7 | 24 #ifdef FEAT_CMDL_INFO |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
25 static void del_from_showcmd(int); |
7 | 26 #endif |
27 | |
28 /* | |
29 * nv_*(): functions called to handle Normal and Visual mode commands. | |
30 * n_*(): functions called to handle Normal mode commands. | |
31 * v_*(): functions called to handle Visual mode commands. | |
32 */ | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 static void nv_zet(cmdarg_T *cap); |
7 | 40 #ifdef FEAT_GUI |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
41 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
|
42 static void nv_hor_scrollbar(cmdarg_T *cap); |
7 | 43 #endif |
685 | 44 #ifdef FEAT_GUI_TABLINE |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
45 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
|
46 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
|
47 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 static void nv_Replace(cmdarg_T *cap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
77 static void nv_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_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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 static void nv_dot(cmdarg_T *cap); |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
92 static void nv_redo_or_register(cmdarg_T *cap); |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
93 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
|
94 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
|
95 static void nv_operator(cmdarg_T *cap); |
1490 | 96 #ifdef FEAT_EVAL |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
97 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
|
98 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 static void invoke_edit(cmdarg_T *cap, int repl, int cmd, int startln); |
7 | 113 #ifdef FEAT_TEXTOBJ |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
114 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
|
115 #endif |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 static void nv_open(cmdarg_T *cap); |
7 | 123 #ifdef FEAT_NETBEANS_INTG |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
124 static void nv_nbcmd(cmdarg_T *cap); |
7 | 125 #endif |
126 #ifdef FEAT_DND | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
127 static void nv_drop(cmdarg_T *cap); |
7 | 128 #endif |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
129 static void nv_cursorhold(cmdarg_T *cap); |
7 | 130 |
131 /* | |
132 * Function to be called for a Normal or Visual mode command. | |
133 * The argument is a cmdarg_T. | |
134 */ | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
135 typedef void (*nv_func_T)(cmdarg_T *cap); |
7 | 136 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
137 // Values for cmd_flags. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
138 #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
|
139 #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
|
140 #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
|
141 #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
|
142 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
143 #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
|
144 #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
|
145 #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
|
146 #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
|
147 #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
|
148 #define NV_NCW 0x200 // not allowed in command-line window |
7 | 149 |
150 /* | |
151 * Generally speaking, every Normal mode command should either clear any | |
152 * pending operator (with *clearop*()), or set the motion type variable | |
153 * oap->motion_type. | |
154 * | |
155 * When a cursor motion command is made, it is marked as being a character or | |
156 * line oriented motion. Then, if an operator is in effect, the operation | |
157 * becomes character or line oriented accordingly. | |
158 */ | |
159 | |
160 /* | |
161 * This table contains one entry for every Normal or Visual mode command. | |
162 * The order doesn't matter, init_normal_cmds() will create a sorted index. | |
163 * It is faster when all keys from zero to '~' are present. | |
164 */ | |
165 static const struct nv_cmd | |
166 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 short cmd_arg; // value for ca.arg |
7 | 171 } nv_cmds[] = |
172 { | |
173 {NUL, nv_error, 0, 0}, | |
174 {Ctrl_A, nv_addsub, 0, 0}, | |
175 {Ctrl_B, nv_page, NV_STS, BACKWARD}, | |
176 {Ctrl_C, nv_esc, 0, TRUE}, | |
177 {Ctrl_D, nv_halfpage, 0, 0}, | |
178 {Ctrl_E, nv_scroll_line, 0, TRUE}, | |
179 {Ctrl_F, nv_page, NV_STS, FORWARD}, | |
180 {Ctrl_G, nv_ctrlg, 0, 0}, | |
181 {Ctrl_H, nv_ctrlh, 0, 0}, | |
182 {Ctrl_I, nv_pcmark, 0, 0}, | |
183 {NL, nv_down, 0, FALSE}, | |
184 {Ctrl_K, nv_error, 0, 0}, | |
185 {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
|
186 {CAR, nv_down, 0, TRUE}, |
7 | 187 {Ctrl_N, nv_down, NV_STS, FALSE}, |
188 {Ctrl_O, nv_ctrlo, 0, 0}, | |
189 {Ctrl_P, nv_up, NV_STS, FALSE}, | |
167 | 190 {Ctrl_Q, nv_visual, 0, FALSE}, |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
191 {Ctrl_R, nv_redo_or_register, 0, 0}, |
7 | 192 {Ctrl_S, nv_ignore, 0, 0}, |
193 {Ctrl_T, nv_tagpop, NV_NCW, 0}, | |
194 {Ctrl_U, nv_halfpage, 0, 0}, | |
195 {Ctrl_V, nv_visual, 0, FALSE}, | |
196 {'V', nv_visual, 0, FALSE}, | |
197 {'v', nv_visual, 0, FALSE}, | |
198 {Ctrl_W, nv_window, 0, 0}, | |
199 {Ctrl_X, nv_addsub, 0, 0}, | |
200 {Ctrl_Y, nv_scroll_line, 0, FALSE}, | |
201 {Ctrl_Z, nv_suspend, 0, 0}, | |
202 {ESC, nv_esc, 0, FALSE}, | |
203 {Ctrl_BSL, nv_normal, NV_NCH_ALW, 0}, | |
204 {Ctrl_RSB, nv_ident, NV_NCW, 0}, | |
205 {Ctrl_HAT, nv_hat, NV_NCW, 0}, | |
206 {Ctrl__, nv_error, 0, 0}, | |
207 {' ', nv_right, 0, 0}, | |
208 {'!', nv_operator, 0, 0}, | |
209 {'"', nv_regname, NV_NCH_NOP|NV_KEEPREG, 0}, | |
210 {'#', nv_ident, 0, 0}, | |
211 {'$', nv_dollar, 0, 0}, | |
212 {'%', nv_percent, 0, 0}, | |
213 {'&', nv_optrans, 0, 0}, | |
214 {'\'', nv_gomark, NV_NCH_ALW, TRUE}, | |
215 {'(', nv_brace, 0, BACKWARD}, | |
216 {')', nv_brace, 0, FORWARD}, | |
217 {'*', nv_ident, 0, 0}, | |
218 {'+', nv_down, 0, TRUE}, | |
219 {',', nv_csearch, 0, TRUE}, | |
220 {'-', nv_up, 0, TRUE}, | |
221 {'.', nv_dot, NV_KEEPREG, 0}, | |
222 {'/', nv_search, 0, FALSE}, | |
223 {'0', nv_beginline, 0, 0}, | |
224 {'1', nv_ignore, 0, 0}, | |
225 {'2', nv_ignore, 0, 0}, | |
226 {'3', nv_ignore, 0, 0}, | |
227 {'4', nv_ignore, 0, 0}, | |
228 {'5', nv_ignore, 0, 0}, | |
229 {'6', nv_ignore, 0, 0}, | |
230 {'7', nv_ignore, 0, 0}, | |
231 {'8', nv_ignore, 0, 0}, | |
232 {'9', nv_ignore, 0, 0}, | |
233 {':', nv_colon, 0, 0}, | |
234 {';', nv_csearch, 0, FALSE}, | |
235 {'<', nv_operator, NV_RL, 0}, | |
236 {'=', nv_operator, 0, 0}, | |
237 {'>', nv_operator, NV_RL, 0}, | |
238 {'?', nv_search, 0, FALSE}, | |
239 {'@', nv_at, NV_NCH_NOP, FALSE}, | |
240 {'A', nv_edit, 0, 0}, | |
241 {'B', nv_bck_word, 0, 1}, | |
242 {'C', nv_abbrev, NV_KEEPREG, 0}, | |
243 {'D', nv_abbrev, NV_KEEPREG, 0}, | |
244 {'E', nv_wordcmd, 0, TRUE}, | |
245 {'F', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD}, | |
246 {'G', nv_goto, 0, TRUE}, | |
247 {'H', nv_scroll, 0, 0}, | |
248 {'I', nv_edit, 0, 0}, | |
249 {'J', nv_join, 0, 0}, | |
250 {'K', nv_ident, 0, 0}, | |
251 {'L', nv_scroll, 0, 0}, | |
252 {'M', nv_scroll, 0, 0}, | |
253 {'N', nv_next, 0, SEARCH_REV}, | |
254 {'O', nv_open, 0, 0}, | |
255 {'P', nv_put, 0, 0}, | |
256 {'Q', nv_exmode, NV_NCW, 0}, | |
257 {'R', nv_Replace, 0, FALSE}, | |
258 {'S', nv_subst, NV_KEEPREG, 0}, | |
259 {'T', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD}, | |
260 {'U', nv_Undo, 0, 0}, | |
261 {'W', nv_wordcmd, 0, TRUE}, | |
262 {'X', nv_abbrev, NV_KEEPREG, 0}, | |
263 {'Y', nv_abbrev, NV_KEEPREG, 0}, | |
264 {'Z', nv_Zet, NV_NCH_NOP|NV_NCW, 0}, | |
265 {'[', nv_brackets, NV_NCH_ALW, BACKWARD}, | |
266 {'\\', nv_error, 0, 0}, | |
267 {']', nv_brackets, NV_NCH_ALW, FORWARD}, | |
268 {'^', nv_beginline, 0, BL_WHITE | BL_FIX}, | |
269 {'_', nv_lineop, 0, 0}, | |
270 {'`', nv_gomark, NV_NCH_ALW, FALSE}, | |
271 {'a', nv_edit, NV_NCH, 0}, | |
272 {'b', nv_bck_word, 0, 0}, | |
273 {'c', nv_operator, 0, 0}, | |
274 {'d', nv_operator, 0, 0}, | |
275 {'e', nv_wordcmd, 0, FALSE}, | |
276 {'f', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD}, | |
277 {'g', nv_g_cmd, NV_NCH_ALW, FALSE}, | |
278 {'h', nv_left, NV_RL, 0}, | |
279 {'i', nv_edit, NV_NCH, 0}, | |
280 {'j', nv_down, 0, FALSE}, | |
281 {'k', nv_up, 0, FALSE}, | |
282 {'l', nv_right, NV_RL, 0}, | |
283 {'m', nv_mark, NV_NCH_NOP, 0}, | |
284 {'n', nv_next, 0, 0}, | |
285 {'o', nv_open, 0, 0}, | |
286 {'p', nv_put, 0, 0}, | |
287 {'q', nv_record, NV_NCH, 0}, | |
288 {'r', nv_replace, NV_NCH_NOP|NV_LANG, 0}, | |
289 {'s', nv_subst, NV_KEEPREG, 0}, | |
290 {'t', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD}, | |
291 {'u', nv_undo, 0, 0}, | |
292 {'w', nv_wordcmd, 0, FALSE}, | |
293 {'x', nv_abbrev, NV_KEEPREG, 0}, | |
294 {'y', nv_operator, 0, 0}, | |
295 {'z', nv_zet, NV_NCH_ALW, 0}, | |
296 {'{', nv_findpar, 0, BACKWARD}, | |
297 {'|', nv_pipe, 0, 0}, | |
298 {'}', nv_findpar, 0, FORWARD}, | |
299 {'~', nv_tilde, 0, 0}, | |
300 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
301 // pound sign |
7 | 302 {POUND, nv_ident, 0, 0}, |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
303 {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
|
304 {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
|
305 {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
|
306 {K_MOUSERIGHT, nv_mousescroll, 0, MSCR_RIGHT}, |
7 | 307 {K_LEFTMOUSE, nv_mouse, 0, 0}, |
308 {K_LEFTMOUSE_NM, nv_mouse, 0, 0}, | |
309 {K_LEFTDRAG, nv_mouse, 0, 0}, | |
310 {K_LEFTRELEASE, nv_mouse, 0, 0}, | |
311 {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
|
312 {K_MOUSEMOVE, nv_mouse, 0, 0}, |
7 | 313 {K_MIDDLEMOUSE, nv_mouse, 0, 0}, |
314 {K_MIDDLEDRAG, nv_mouse, 0, 0}, | |
315 {K_MIDDLERELEASE, nv_mouse, 0, 0}, | |
316 {K_RIGHTMOUSE, nv_mouse, 0, 0}, | |
317 {K_RIGHTDRAG, nv_mouse, 0, 0}, | |
318 {K_RIGHTRELEASE, nv_mouse, 0, 0}, | |
319 {K_X1MOUSE, nv_mouse, 0, 0}, | |
320 {K_X1DRAG, nv_mouse, 0, 0}, | |
321 {K_X1RELEASE, nv_mouse, 0, 0}, | |
322 {K_X2MOUSE, nv_mouse, 0, 0}, | |
323 {K_X2DRAG, nv_mouse, 0, 0}, | |
324 {K_X2RELEASE, nv_mouse, 0, 0}, | |
819 | 325 {K_IGNORE, nv_ignore, NV_KEEPREG, 0}, |
620 | 326 {K_NOP, nv_nop, 0, 0}, |
7 | 327 {K_INS, nv_edit, 0, 0}, |
328 {K_KINS, nv_edit, 0, 0}, | |
329 {K_BS, nv_ctrlh, 0, 0}, | |
330 {K_UP, nv_up, NV_SSS|NV_STS, FALSE}, | |
331 {K_S_UP, nv_page, NV_SS, BACKWARD}, | |
332 {K_DOWN, nv_down, NV_SSS|NV_STS, FALSE}, | |
333 {K_S_DOWN, nv_page, NV_SS, FORWARD}, | |
334 {K_LEFT, nv_left, NV_SSS|NV_STS|NV_RL, 0}, | |
335 {K_S_LEFT, nv_bck_word, NV_SS|NV_RL, 0}, | |
336 {K_C_LEFT, nv_bck_word, NV_SSS|NV_RL|NV_STS, 1}, | |
337 {K_RIGHT, nv_right, NV_SSS|NV_STS|NV_RL, 0}, | |
338 {K_S_RIGHT, nv_wordcmd, NV_SS|NV_RL, FALSE}, | |
339 {K_C_RIGHT, nv_wordcmd, NV_SSS|NV_RL|NV_STS, TRUE}, | |
340 {K_PAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD}, | |
341 {K_KPAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD}, | |
342 {K_PAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD}, | |
343 {K_KPAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD}, | |
344 {K_END, nv_end, NV_SSS|NV_STS, FALSE}, | |
345 {K_KEND, nv_end, NV_SSS|NV_STS, FALSE}, | |
346 {K_S_END, nv_end, NV_SS, FALSE}, | |
347 {K_C_END, nv_end, NV_SSS|NV_STS, TRUE}, | |
348 {K_HOME, nv_home, NV_SSS|NV_STS, 0}, | |
349 {K_KHOME, nv_home, NV_SSS|NV_STS, 0}, | |
350 {K_S_HOME, nv_home, NV_SS, 0}, | |
351 {K_C_HOME, nv_goto, NV_SSS|NV_STS, FALSE}, | |
352 {K_DEL, nv_abbrev, 0, 0}, | |
353 {K_KDEL, nv_abbrev, 0, 0}, | |
354 {K_UNDO, nv_kundo, 0, 0}, | |
355 {K_HELP, nv_help, NV_NCW, 0}, | |
356 {K_F1, nv_help, NV_NCW, 0}, | |
357 {K_XF1, nv_help, NV_NCW, 0}, | |
358 {K_SELECT, nv_select, 0, 0}, | |
359 #ifdef FEAT_GUI | |
360 {K_VER_SCROLLBAR, nv_ver_scrollbar, 0, 0}, | |
361 {K_HOR_SCROLLBAR, nv_hor_scrollbar, 0, 0}, | |
362 #endif | |
685 | 363 #ifdef FEAT_GUI_TABLINE |
364 {K_TABLINE, nv_tabline, 0, 0}, | |
686 | 365 {K_TABMENU, nv_tabmenu, 0, 0}, |
685 | 366 #endif |
7 | 367 #ifdef FEAT_NETBEANS_INTG |
368 {K_F21, nv_nbcmd, NV_NCH_ALW, 0}, | |
369 #endif | |
370 #ifdef FEAT_DND | |
371 {K_DROP, nv_drop, NV_STS, 0}, | |
372 #endif | |
819 | 373 {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
|
374 {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
|
375 {K_COMMAND, nv_colon, 0, 0}, |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
376 {K_SCRIPT_COMMAND, nv_colon, 0, 0}, |
7 | 377 }; |
378 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
379 // Number of commands in nv_cmds[]. |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24752
diff
changeset
|
380 #define NV_CMDS_SIZE ARRAY_LENGTH(nv_cmds) |
7 | 381 |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
382 #ifndef PROTO // cproto doesn't like this |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
383 // Sorted index of commands in nv_cmds[]. |
7 | 384 static short nv_cmd_idx[NV_CMDS_SIZE]; |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
385 #endif |
7 | 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 | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
531 trigger_modechanged(); |
7 | 532 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
533 // 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
|
534 // count. |
7 | 535 if (!finish_op && !oap->regname) |
1751 | 536 { |
7 | 537 ca.opcount = 0; |
1751 | 538 #ifdef FEAT_EVAL |
539 set_prevcount = TRUE; | |
540 #endif | |
541 } | |
7 | 542 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
543 // 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
|
544 // 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
|
545 // "3 * 2". |
1692 | 546 if (oap->prev_opcount > 0 || oap->prev_count0 > 0) |
547 { | |
548 ca.opcount = oap->prev_opcount; | |
549 ca.count0 = oap->prev_count0; | |
550 oap->prev_opcount = 0; | |
551 oap->prev_count0 = 0; | |
552 } | |
553 | |
7 | 554 mapped_len = typebuf_maplen(); |
555 | |
556 State = NORMAL_BUSY; | |
557 #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
|
558 dont_scroll = FALSE; // allow scrolling here |
7 | 559 #endif |
560 | |
2667 | 561 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
562 // 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
|
563 // 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
|
564 // when there is no count. Do set it for redo. |
5649 | 565 if (toplevel && readbuf1_empty()) |
2667 | 566 set_vcount_ca(&ca, &set_prevcount); |
567 #endif | |
568 | |
7 | 569 /* |
570 * Get the command character from the user. | |
571 */ | |
572 c = safe_vgetc(); | |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7578
diff
changeset
|
573 LANGMAP_ADJUST(c, get_real_state() != SELECTMODE); |
7 | 574 |
575 /* | |
576 * If a mapping was started in Visual or Select mode, remember the length | |
577 * of the mapping. This is used below to not return to Insert mode for as | |
578 * long as the mapping is being executed. | |
579 */ | |
580 if (restart_edit == 0) | |
581 old_mapped_len = 0; | |
582 else if (old_mapped_len | |
819 | 583 || (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0)) |
7 | 584 old_mapped_len = typebuf_maplen(); |
585 | |
586 if (c == NUL) | |
587 c = K_ZERO; | |
588 | |
589 /* | |
590 * In Select mode, typed text replaces the selection. | |
591 */ | |
592 if (VIsual_active | |
593 && VIsual_select | |
594 && (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER)) | |
595 { | |
26929
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
596 int len; |
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
597 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
598 // 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
|
599 // '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
|
600 // restart automatically. |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
601 // 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
|
602 // be mapped in Insert mode. Required for ":lmap" to work. |
26929
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
603 len = ins_char_typebuf(vgetc_char, vgetc_mod_mask); |
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
604 |
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
605 // When recording the character will be recorded again, remove the |
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
606 // previously recording. |
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
607 ungetchars(len); |
9975bd408d6c
patch 8.2.3993: when recording a change in Select mode char appears twice
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
608 |
275 | 609 if (restart_edit != 0) |
610 c = 'd'; | |
611 else | |
612 c = 'c'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
613 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
|
614 old_mapped_len = 0; // do go to Insert mode |
7 | 615 } |
616 | |
26468
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
617 // If the window was made so small that nothing shows, make it at least one |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
618 // line and one column when typing a command. |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
619 if (KeyTyped && !KeyStuffed) |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
620 win_ensure_size(); |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26258
diff
changeset
|
621 |
7 | 622 #ifdef FEAT_CMDL_INFO |
623 need_flushbuf = add_to_showcmd(c); | |
624 #endif | |
625 | |
626 getcount: | |
627 if (!(VIsual_active && VIsual_select)) | |
628 { | |
629 /* | |
630 * Handle a count before a command and compute ca.count0. | |
631 * Note that '0' is a command and not the start of a count, but it's | |
632 * part of a count after other digits. | |
633 */ | |
634 while ( (c >= '1' && c <= '9') | |
635 || (ca.count0 != 0 && (c == K_DEL || c == K_KDEL || c == '0'))) | |
636 { | |
637 if (c == K_DEL || c == K_KDEL) | |
638 { | |
639 ca.count0 /= 10; | |
640 #ifdef FEAT_CMDL_INFO | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
641 del_from_showcmd(4); // delete the digit and ~@% |
7 | 642 #endif |
643 } | |
26258
a74c8936794a
patch 8.2.3660: overflow check uses wrong number
Bram Moolenaar <Bram@vim.org>
parents:
26256
diff
changeset
|
644 else if (ca.count0 > 99999999L) |
26256
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
645 { |
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
646 ca.count0 = 999999999L; |
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
647 } |
7 | 648 else |
26256
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
649 { |
7 | 650 ca.count0 = ca.count0 * 10 + (c - '0'); |
26256
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
651 } |
1425 | 652 #ifdef FEAT_EVAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
653 // 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
|
654 // 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
|
655 // right after the count. Do set it for redo. |
5649 | 656 if (toplevel && readbuf1_empty()) |
2667 | 657 set_vcount_ca(&ca, &set_prevcount); |
1425 | 658 #endif |
7 | 659 if (ctrl_w) |
660 { | |
661 ++no_mapping; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
662 ++allow_keys; // no mapping for nchar, but keys |
7 | 663 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
664 ++no_zero_mapping; // don't map zero here |
1389 | 665 c = plain_vgetc(); |
7 | 666 LANGMAP_ADJUST(c, TRUE); |
667 --no_zero_mapping; | |
668 if (ctrl_w) | |
669 { | |
670 --no_mapping; | |
671 --allow_keys; | |
672 } | |
673 #ifdef FEAT_CMDL_INFO | |
674 need_flushbuf |= add_to_showcmd(c); | |
675 #endif | |
676 } | |
677 | |
678 /* | |
679 * If we got CTRL-W there may be a/another count | |
680 */ | |
681 if (c == Ctrl_W && !ctrl_w && oap->op_type == OP_NOP) | |
682 { | |
683 ctrl_w = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
684 ca.opcount = ca.count0; // remember first count |
7 | 685 ca.count0 = 0; |
686 ++no_mapping; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
687 ++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
|
688 c = plain_vgetc(); // get next character |
7 | 689 LANGMAP_ADJUST(c, TRUE); |
690 --no_mapping; | |
691 --allow_keys; | |
692 #ifdef FEAT_CMDL_INFO | |
693 need_flushbuf |= add_to_showcmd(c); | |
694 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
695 goto getcount; // jump back |
7 | 696 } |
697 } | |
698 | |
1692 | 699 if (c == K_CURSORHOLD) |
700 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
701 // 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
|
702 // the same when coming back here after handling K_CURSORHOLD. |
1692 | 703 oap->prev_opcount = ca.opcount; |
704 oap->prev_count0 = ca.count0; | |
705 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
706 else if (ca.opcount != 0) |
1692 | 707 { |
708 /* | |
709 * If we're in the middle of an operator (including after entering a | |
710 * yank buffer with '"') AND we had a count before the operator, then | |
711 * that count overrides the current value of ca.count0. | |
712 * What this means effectively, is that commands like "3dw" get turned | |
713 * into "d3w" which makes things fall into place pretty neatly. | |
714 * If you give a count before AND after the operator, they are | |
715 * multiplied. | |
716 */ | |
7 | 717 if (ca.count0) |
26256
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
718 { |
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
719 if (ca.opcount >= 999999999L / ca.count0) |
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
720 ca.count0 = 999999999L; |
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
721 else |
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
722 ca.count0 *= ca.opcount; |
92fbed13ca4d
patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents:
26226
diff
changeset
|
723 } |
7 | 724 else |
725 ca.count0 = ca.opcount; | |
726 } | |
727 | |
728 /* | |
729 * Always remember the count. It will be set to zero (on the next call, | |
730 * above) when there is no pending operator. | |
731 * When called from main(), save the count for use by the "count" built-in | |
732 * variable. | |
733 */ | |
734 ca.opcount = ca.count0; | |
735 ca.count1 = (ca.count0 == 0 ? 1 : ca.count0); | |
736 | |
737 #ifdef FEAT_EVAL | |
738 /* | |
739 * Only set v:count when called from main() and not a stuffed command. | |
5649 | 740 * Do set it for redo. |
7 | 741 */ |
5649 | 742 if (toplevel && readbuf1_empty()) |
1751 | 743 set_vcount(ca.count0, ca.count1, set_prevcount); |
7 | 744 #endif |
745 | |
746 /* | |
747 * Find the command character in the table of commands. | |
748 * For CTRL-W we already got nchar when looking for a count. | |
749 */ | |
750 if (ctrl_w) | |
751 { | |
752 ca.nchar = c; | |
753 ca.cmdchar = Ctrl_W; | |
754 } | |
755 else | |
756 ca.cmdchar = c; | |
757 idx = find_command(ca.cmdchar); | |
758 if (idx < 0) | |
759 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
760 // Not a known command: beep. |
7 | 761 clearopbeep(oap); |
762 goto normal_end; | |
763 } | |
631 | 764 |
633 | 765 if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW)) |
631 | 766 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
767 // This command is not allowed while editing a cmdline: beep. |
7 | 768 clearopbeep(oap); |
633 | 769 text_locked_msg(); |
7 | 770 goto normal_end; |
771 } | |
819 | 772 if ((nv_cmds[idx].cmd_flags & NV_NCW) && curbuf_locked()) |
773 goto normal_end; | |
7 | 774 |
775 /* | |
776 * In Visual/Select mode, a few keys are handled in a special way. | |
777 */ | |
778 if (VIsual_active) | |
779 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
780 // when 'keymodel' contains "stopsel" may stop Select/Visual mode |
7 | 781 if (km_stopsel |
782 && (nv_cmds[idx].cmd_flags & NV_STS) | |
783 && !(mod_mask & MOD_MASK_SHIFT)) | |
784 { | |
785 end_visual_mode(); | |
786 redraw_curbuf_later(INVERTED); | |
787 } | |
788 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
789 // Keys that work different when 'keymodel' contains "startsel" |
7 | 790 if (km_startsel) |
791 { | |
792 if (nv_cmds[idx].cmd_flags & NV_SS) | |
793 { | |
794 unshift_special(&ca); | |
795 idx = find_command(ca.cmdchar); | |
840 | 796 if (idx < 0) |
797 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
798 // Just in case |
840 | 799 clearopbeep(oap); |
800 goto normal_end; | |
801 } | |
7 | 802 } |
803 else if ((nv_cmds[idx].cmd_flags & NV_SSS) | |
804 && (mod_mask & MOD_MASK_SHIFT)) | |
805 mod_mask &= ~MOD_MASK_SHIFT; | |
806 } | |
807 } | |
808 | |
809 #ifdef FEAT_RIGHTLEFT | |
810 if (curwin->w_p_rl && KeyTyped && !KeyStuffed | |
811 && (nv_cmds[idx].cmd_flags & NV_RL)) | |
812 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
813 // 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
|
814 // 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
|
815 // to "dl". |
7 | 816 switch (ca.cmdchar) |
817 { | |
818 case 'l': ca.cmdchar = 'h'; break; | |
819 case K_RIGHT: ca.cmdchar = K_LEFT; break; | |
820 case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break; | |
821 case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break; | |
822 case 'h': ca.cmdchar = 'l'; break; | |
823 case K_LEFT: ca.cmdchar = K_RIGHT; break; | |
824 case K_S_LEFT: ca.cmdchar = K_S_RIGHT; break; | |
825 case K_C_LEFT: ca.cmdchar = K_C_RIGHT; break; | |
826 case '>': ca.cmdchar = '<'; break; | |
827 case '<': ca.cmdchar = '>'; break; | |
828 } | |
829 idx = find_command(ca.cmdchar); | |
830 } | |
831 #endif | |
832 | |
833 /* | |
834 * Get an additional character if we need one. | |
835 */ | |
836 if ((nv_cmds[idx].cmd_flags & NV_NCH) | |
837 && (((nv_cmds[idx].cmd_flags & NV_NCH_NOP) == NV_NCH_NOP | |
838 && oap->op_type == OP_NOP) | |
839 || (nv_cmds[idx].cmd_flags & NV_NCH_ALW) == NV_NCH_ALW | |
840 || (ca.cmdchar == 'q' | |
841 && 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
|
842 && 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
|
843 && reg_executing == 0) |
7 | 844 || ((ca.cmdchar == 'a' || ca.cmdchar == 'i') |
5735 | 845 && (oap->op_type != OP_NOP || VIsual_active)))) |
7 | 846 { |
847 int *cp; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
848 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
|
849 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
|
850 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
|
851 int lang; // getting a text character |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
852 #ifdef HAVE_INPUT_METHOD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
853 int save_smd; // saved value of p_smd |
7 | 854 #endif |
855 | |
856 ++no_mapping; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
857 ++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
|
858 // 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
|
859 // it, e.g., nv_replace(), nv_csearch(). |
1343 | 860 did_cursorhold = TRUE; |
7 | 861 if (ca.cmdchar == 'g') |
862 { | |
863 /* | |
864 * For 'g' get the next character now, so that we can check for | |
865 * "gr", "g'" and "g`". | |
866 */ | |
1389 | 867 ca.nchar = plain_vgetc(); |
7 | 868 LANGMAP_ADJUST(ca.nchar, TRUE); |
869 #ifdef FEAT_CMDL_INFO | |
870 need_flushbuf |= add_to_showcmd(ca.nchar); | |
871 #endif | |
872 if (ca.nchar == 'r' || ca.nchar == '\'' || ca.nchar == '`' | |
5523 | 873 || ca.nchar == Ctrl_BSL) |
7 | 874 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
875 cp = &ca.extra_char; // need to get a third character |
7 | 876 if (ca.nchar != 'r') |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
877 lit = TRUE; // get it literally |
7 | 878 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
879 repl = TRUE; // get it in replace mode |
7 | 880 } |
881 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
882 cp = NULL; // no third character needed |
7 | 883 } |
884 else | |
885 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
886 if (ca.cmdchar == 'r') // get it in replace mode |
7 | 887 repl = TRUE; |
888 cp = &ca.nchar; | |
889 } | |
890 lang = (repl || (nv_cmds[idx].cmd_flags & NV_LANG)); | |
891 | |
892 /* | |
893 * Get a second or third character. | |
894 */ | |
895 if (cp != NULL) | |
896 { | |
897 if (repl) | |
898 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
899 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
|
900 #ifdef CURSOR_SHAPE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
901 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
|
902 #endif |
7 | 903 } |
904 if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) | |
905 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
906 // Allow mappings defined with ":lmap". |
7 | 907 --no_mapping; |
908 --allow_keys; | |
909 if (repl) | |
910 State = LREPLACE; | |
911 else | |
912 State = LANGMAP; | |
913 langmap_active = TRUE; | |
914 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
915 #ifdef HAVE_INPUT_METHOD |
7 | 916 save_smd = p_smd; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
917 p_smd = FALSE; // Don't let the IM code show the mode here |
7 | 918 if (lang && curbuf->b_p_iminsert == B_IMODE_IM) |
919 im_set_active(TRUE); | |
920 #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
|
921 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
|
922 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
22000
diff
changeset
|
923 #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
|
924 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
|
925 #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
|
926 // 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
|
927 // 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
|
928 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
|
929 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
|
930 } |
7 | 931 |
1389 | 932 *cp = plain_vgetc(); |
7 | 933 |
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
|
934 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
|
935 { |
22091
9bb1c984c4da
patch 8.2.1595: cannot easily see what Vim sends to the terminal
Bram Moolenaar <Bram@vim.org>
parents:
22000
diff
changeset
|
936 #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
|
937 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
|
938 #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
|
939 // 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
|
940 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
|
941 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
|
942 } |
afa3080a96ae
patch 8.2.1549: "r" fails if 'esckeys' is off and modifyOtherKeys is used
Bram Moolenaar <Bram@vim.org>
parents:
21941
diff
changeset
|
943 |
7 | 944 if (langmap_active) |
945 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
946 // Undo the decrement done above |
7 | 947 ++no_mapping; |
948 ++allow_keys; | |
949 State = NORMAL_BUSY; | |
950 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
951 #ifdef HAVE_INPUT_METHOD |
7 | 952 if (lang) |
953 { | |
954 if (curbuf->b_p_iminsert != B_IMODE_LMAP) | |
955 im_save_status(&curbuf->b_p_iminsert); | |
956 im_set_active(FALSE); | |
957 } | |
958 p_smd = save_smd; | |
959 #endif | |
960 State = NORMAL_BUSY; | |
961 #ifdef FEAT_CMDL_INFO | |
962 need_flushbuf |= add_to_showcmd(*cp); | |
963 #endif | |
964 | |
965 if (!lit) | |
966 { | |
967 #ifdef FEAT_DIGRAPHS | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
968 // Typing CTRL-K gets a digraph. |
7 | 969 if (*cp == Ctrl_K |
970 && ((nv_cmds[idx].cmd_flags & NV_LANG) | |
971 || cp == &ca.extra_char) | |
972 && vim_strchr(p_cpo, CPO_DIGRAPH) == NULL) | |
973 { | |
974 c = get_digraph(FALSE); | |
975 if (c > 0) | |
976 { | |
977 *cp = c; | |
978 # ifdef FEAT_CMDL_INFO | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
979 // Guessing how to update showcmd here... |
7 | 980 del_from_showcmd(3); |
981 need_flushbuf |= add_to_showcmd(*cp); | |
982 # endif | |
983 } | |
984 } | |
985 #endif | |
986 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
987 // adjust chars > 127, except after "tTfFr" commands |
7 | 988 LANGMAP_ADJUST(*cp, !lang); |
989 #ifdef FEAT_RIGHTLEFT | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
990 // adjust Hebrew mapped char |
7 | 991 if (p_hkmap && lang && KeyTyped) |
992 *cp = hkmap(*cp); | |
993 #endif | |
994 } | |
995 | |
996 /* | |
997 * When the next character is CTRL-\ a following CTRL-N means the | |
998 * command is aborted and we go to Normal mode. | |
999 */ | |
1000 if (cp == &ca.extra_char | |
1001 && ca.nchar == Ctrl_BSL | |
1002 && (ca.extra_char == Ctrl_N || ca.extra_char == Ctrl_G)) | |
1003 { | |
1004 ca.cmdchar = Ctrl_BSL; | |
1005 ca.nchar = ca.extra_char; | |
1006 idx = find_command(ca.cmdchar); | |
1007 } | |
3908 | 1008 else if ((ca.nchar == 'n' || ca.nchar == 'N') && ca.cmdchar == 'g') |
3896 | 1009 ca.oap->op_type = get_op_type(*cp, NUL); |
7 | 1010 else if (*cp == Ctrl_BSL) |
1011 { | |
1012 long towait = (p_ttm >= 0 ? p_ttm : p_tm); | |
1013 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1014 // 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
|
1015 // something different from CTRL-N. Can't be avoided. |
7 | 1016 while ((c = vpeekc()) <= 0 && towait > 0L) |
1017 { | |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
1018 do_sleep(towait > 50L ? 50L : towait, FALSE); |
7 | 1019 towait -= 50L; |
1020 } | |
1021 if (c > 0) | |
1022 { | |
1389 | 1023 c = plain_vgetc(); |
7 | 1024 if (c != Ctrl_N && c != Ctrl_G) |
1025 vungetc(c); | |
1026 else | |
1027 { | |
1028 ca.cmdchar = Ctrl_BSL; | |
1029 ca.nchar = c; | |
1030 idx = find_command(ca.cmdchar); | |
1031 } | |
1032 } | |
1033 } | |
1034 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1035 // 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
|
1036 // 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
|
1037 // 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
|
1038 // 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
|
1039 // mapping. |
6071 | 1040 --no_mapping; |
7 | 1041 while (enc_utf8 && lang && (c = vpeekc()) > 0 |
1042 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) | |
1043 { | |
1389 | 1044 c = plain_vgetc(); |
7 | 1045 if (!utf_iscomposing(c)) |
1046 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1047 vungetc(c); // it wasn't, put it back |
7 | 1048 break; |
1049 } | |
1050 else if (ca.ncharC1 == 0) | |
1051 ca.ncharC1 = c; | |
1052 else | |
1053 ca.ncharC2 = c; | |
1054 } | |
6071 | 1055 ++no_mapping; |
7 | 1056 } |
1057 --no_mapping; | |
1058 --allow_keys; | |
1059 } | |
1060 | |
1061 #ifdef FEAT_CMDL_INFO | |
1062 /* | |
1063 * Flush the showcmd characters onto the screen so we can see them while | |
1064 * the command is being executed. Only do this when the shown command was | |
1065 * actually displayed, otherwise this will slow down a lot when executing | |
1066 * mappings. | |
1067 */ | |
1068 if (need_flushbuf) | |
1069 out_flush(); | |
1070 #endif | |
1727 | 1071 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
|
1072 { |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1073 if (ex_normal_busy) |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1074 did_cursorhold = save_did_cursorhold; |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1075 else |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1076 did_cursorhold = FALSE; |
b530a433fe7d
patch 8.2.1258: CursorHold does not work well
Bram Moolenaar <Bram@vim.org>
parents:
21405
diff
changeset
|
1077 } |
7 | 1078 |
1079 State = NORMAL; | |
1080 | |
1081 if (ca.nchar == ESC) | |
1082 { | |
1083 clearop(oap); | |
1084 if (restart_edit == 0 && goto_im()) | |
1085 restart_edit = 'a'; | |
1086 goto normal_end; | |
1087 } | |
1088 | |
24 | 1089 if (ca.cmdchar != K_IGNORE) |
1090 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1091 msg_didout = FALSE; // don't scroll screen up for normal command |
24 | 1092 msg_col = 0; |
1093 } | |
7 | 1094 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1095 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
|
1096 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1097 // 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
|
1098 // mode. |
7 | 1099 if (!VIsual_active && km_startsel) |
1100 { | |
1101 if (nv_cmds[idx].cmd_flags & NV_SS) | |
1102 { | |
1103 start_selection(); | |
1104 unshift_special(&ca); | |
1105 idx = find_command(ca.cmdchar); | |
1106 } | |
1107 else if ((nv_cmds[idx].cmd_flags & NV_SSS) | |
1108 && (mod_mask & MOD_MASK_SHIFT)) | |
1109 { | |
1110 start_selection(); | |
1111 mod_mask &= ~MOD_MASK_SHIFT; | |
1112 } | |
1113 } | |
1114 | |
1115 /* | |
1116 * Execute the command! | |
1117 * Call the command function found in the commands table. | |
1118 */ | |
1119 ca.arg = nv_cmds[idx].cmd_arg; | |
1120 (nv_cmds[idx].cmd_func)(&ca); | |
1121 | |
1122 /* | |
1123 * If we didn't start or finish an operator, reset oap->regname, unless we | |
1124 * need it later. | |
1125 */ | |
1126 if (!finish_op | |
1127 && !oap->op_type | |
1128 && (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG))) | |
1129 { | |
1130 clearop(oap); | |
1131 #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
|
1132 reset_reg_var(); |
7 | 1133 #endif |
1134 } | |
1135 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1136 // 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
|
1137 // character or "z333<cr>". |
36 | 1138 if (old_mapped_len > 0) |
1139 old_mapped_len = typebuf_maplen(); | |
1140 | |
7 | 1141 /* |
24586
b7f58be68c02
patch 8.2.2832: operator cancelled by moving mouse when using popup
Bram Moolenaar <Bram@vim.org>
parents:
24341
diff
changeset
|
1142 * If an operation is pending, handle it. But not for K_IGNORE or |
b7f58be68c02
patch 8.2.2832: operator cancelled by moving mouse when using popup
Bram Moolenaar <Bram@vim.org>
parents:
24341
diff
changeset
|
1143 * K_MOUSEMOVE. |
7 | 1144 */ |
24586
b7f58be68c02
patch 8.2.2832: operator cancelled by moving mouse when using popup
Bram Moolenaar <Bram@vim.org>
parents:
24341
diff
changeset
|
1145 if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE) |
18775
5da1ad9165f0
patch 8.1.2377: GUI: when losing focus a pending operator is executed
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
1146 do_pending_operator(&ca, old_col, FALSE); |
7 | 1147 |
1148 /* | |
1149 * Wait for a moment when a message is displayed that will be overwritten | |
1150 * by the mode message. | |
1151 * In Visual mode and with "^O" in Insert mode, a short message will be | |
1152 * overwritten by the mode message. Wait a bit, until a key is hit. | |
1153 * In Visual mode, it's more important to keep the Visual area updated | |
1154 * than keeping a message (e.g. from a /pat search). | |
1155 * Only do this if the command was typed, not from a mapping. | |
1156 * Don't wait when emsg_silent is non-zero. | |
1157 * Also wait a bit after an error message, e.g. for "^O:". | |
1158 * Don't redraw the screen, it would remove the message. | |
1159 */ | |
1160 if ( ((p_smd | |
641 | 1161 && msg_silent == 0 |
7 | 1162 && (restart_edit != 0 |
1163 || (VIsual_active | |
1164 && old_pos.lnum == curwin->w_cursor.lnum | |
1165 && old_pos.col == curwin->w_cursor.col) | |
1166 ) | |
1167 && (clear_cmdline | |
1168 || redraw_cmdline) | |
1169 && (msg_didout || (msg_didany && msg_scroll)) | |
1170 && !msg_nowait | |
1171 && KeyTyped) | |
1172 || (restart_edit != 0 | |
1173 && !VIsual_active | |
1174 && (msg_scroll | |
1175 || emsg_on_display))) | |
1176 && oap->regname == 0 | |
1177 && !(ca.retval & CA_COMMAND_BUSY) | |
1178 && stuff_empty() | |
1179 && typebuf_typed() | |
1180 && 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
|
1181 && !in_assert_fails |
7 | 1182 && !did_wait_return |
1183 && oap->op_type == OP_NOP) | |
1184 { | |
1185 int save_State = State; | |
1186 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1187 // Draw the cursor with the right shape here |
7 | 1188 if (restart_edit != 0) |
1189 State = INSERT; | |
1190 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1191 // 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
|
1192 // delay |
7 | 1193 if (must_redraw && keep_msg != NULL && !emsg_on_display) |
1194 { | |
1195 char_u *kmsg; | |
1196 | |
1197 kmsg = keep_msg; | |
1198 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
|
1199 // 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
|
1200 // 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
|
1201 setcursor(); |
7 | 1202 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
|
1203 // now reset it, otherwise it's put in the history again |
7 | 1204 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
|
1205 |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1206 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
|
1207 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
|
1208 { |
af0b4ffab794
patch 8.1.2018: using freed memory when out of memory and displaying message
Bram Moolenaar <Bram@vim.org>
parents:
17984
diff
changeset
|
1209 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
|
1210 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
|
1211 } |
7 | 1212 } |
1213 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
|
1214 #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
|
1215 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
|
1216 #endif |
7 | 1217 cursor_on(); |
1218 out_flush(); | |
1219 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
|
1220 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
|
1221 ui_delay(3003L, FALSE); // wait up to three seconds |
7 | 1222 State = save_State; |
1223 | |
1224 msg_scroll = FALSE; | |
1225 emsg_on_display = FALSE; | |
1226 } | |
1227 | |
1228 /* | |
1229 * Finish up after executing a Normal mode command. | |
1230 */ | |
1231 normal_end: | |
1232 | |
1233 msg_nowait = FALSE; | |
1234 | |
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
|
1235 #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
|
1236 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
|
1237 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
|
1238 #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
|
1239 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1240 // Reset finish_op, in case it was set |
7 | 1241 #ifdef CURSOR_SHAPE |
1242 c = finish_op; | |
1243 #endif | |
1244 finish_op = FALSE; | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
1245 trigger_modechanged(); |
7 | 1246 #ifdef CURSOR_SHAPE |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1247 // 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
|
1248 // mode or did a replace command. |
7 | 1249 if (c || ca.cmdchar == 'r') |
1250 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1251 ui_cursor_shape(); // may show different cursor shape |
7 | 1252 # ifdef FEAT_MOUSESHAPE |
1253 update_mouseshape(-1); | |
1254 # endif | |
1255 } | |
1256 #endif | |
1257 | |
1258 #ifdef FEAT_CMDL_INFO | |
1692 | 1259 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
|
1260 && ca.cmdchar != K_CURSORHOLD) |
7 | 1261 clear_showcmd(); |
1262 #endif | |
1263 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1264 checkpcmark(); // check if we moved since setting pcmark |
7 | 1265 vim_free(ca.searchbuf); |
1266 | |
1267 if (has_mbyte) | |
1268 mb_adjust_cursor(); | |
1269 | |
1270 if (curwin->w_p_scb && toplevel) | |
1271 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1272 validate_cursor(); // may need to update w_leftcol |
7 | 1273 do_check_scrollbind(TRUE); |
1274 } | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
1275 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1276 if (curwin->w_p_crb && toplevel) |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1277 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1278 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
|
1279 do_check_cursorbind(); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1280 } |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
1281 |
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
|
1282 #ifdef FEAT_TERMINAL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1283 // 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
|
1284 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
|
1285 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
|
1286 #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
|
1287 |
7 | 1288 /* |
1289 * May restart edit(), if we got here with CTRL-O in Insert mode (but not | |
1290 * if still inside a mapping that started in Visual mode). | |
1291 * May switch from Visual to Select mode after CTRL-O command. | |
1292 */ | |
1293 if ( oap->op_type == OP_NOP | |
1294 && ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0) | |
1295 || restart_VIsual_select == 1) | |
1296 && !(ca.retval & CA_COMMAND_BUSY) | |
1297 && stuff_empty() | |
1298 && oap->regname == 0) | |
1299 { | |
1300 if (restart_VIsual_select == 1) | |
1301 { | |
1302 VIsual_select = TRUE; | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
1303 trigger_modechanged(); |
7 | 1304 showmode(); |
1305 restart_VIsual_select = 0; | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
1306 VIsual_select_reg = 0; |
7 | 1307 } |
5735 | 1308 if (restart_edit != 0 && !VIsual_active && old_mapped_len == 0) |
7 | 1309 (void)edit(restart_edit, FALSE, 1L); |
1310 } | |
1311 | |
1312 if (restart_VIsual_select == 2) | |
1313 restart_VIsual_select = 1; | |
1314 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1315 // Save count before an operator for next time. |
7 | 1316 opcount = ca.opcount; |
1317 } | |
1318 | |
2667 | 1319 #ifdef FEAT_EVAL |
1320 /* | |
1321 * Set v:count and v:count1 according to "cap". | |
1322 * Set v:prevcount only when "set_prevcount" is TRUE. | |
1323 */ | |
1324 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1325 set_vcount_ca(cmdarg_T *cap, int *set_prevcount) |
2667 | 1326 { |
1327 long count = cap->count0; | |
1328 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1329 // multiply with cap->opcount the same way as above |
2667 | 1330 if (cap->opcount != 0) |
1331 count = cap->opcount * (count == 0 ? 1 : count); | |
1332 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
|
1333 *set_prevcount = FALSE; // only set v:prevcount once |
2667 | 1334 } |
1335 #endif | |
1336 | |
7 | 1337 /* |
19681
e21c22c58e2b
patch 8.2.0397: delayed screen update when using undo from Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
1338 * Check if highlighting for Visual mode is possible, give a warning message |
7 | 1339 * if not. |
1340 */ | |
1341 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1342 check_visual_highlight(void) |
7 | 1343 { |
1344 static int did_check = FALSE; | |
1345 | |
1346 if (full_screen) | |
1347 { | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
1348 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
|
1349 msg(_("Warning: terminal cannot highlight")); |
7 | 1350 did_check = TRUE; |
1351 } | |
1352 } | |
1353 | |
23021
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1354 #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
|
1355 /* |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1356 * 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
|
1357 */ |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1358 static void |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1359 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
|
1360 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1361 oparg_T oa; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1362 yankreg_T *reg; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1363 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1364 clear_oparg(&oa); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1365 oa.regname = regname; |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1366 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
|
1367 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
|
1368 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
|
1369 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
|
1370 free_register(reg); |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1371 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1372 #endif |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1373 |
7 | 1374 /* |
638 | 1375 * End Visual mode. |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1376 * This function or the next should ALWAYS be called to end Visual mode, except |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1377 * from do_pending_operator(). |
7 | 1378 */ |
1379 void | |
24788
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1380 end_visual_mode() |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1381 { |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1382 end_visual_mode_keep_button(); |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1383 reset_held_button(); |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1384 } |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1385 |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1386 void |
b36ceac30454
patch 8.2.2932: select mode test fails
Bram Moolenaar <Bram@vim.org>
parents:
24784
diff
changeset
|
1387 end_visual_mode_keep_button() |
7 | 1388 { |
1389 #ifdef FEAT_CLIPBOARD | |
1390 /* | |
1391 * If we are using the clipboard, then remember what was selected in case | |
1392 * we need to paste it somewhere while we still own the selection. | |
1393 * Only do this when the clipboard is already owned. Don't want to grab | |
1394 * the selection when hitting ESC. | |
1395 */ | |
1396 if (clip_star.available && clip_star.owned) | |
1397 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
|
1398 |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1399 # 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
|
1400 // 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
|
1401 // 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
|
1402 if (has_textyankpost()) |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1403 { |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1404 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
|
1405 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
|
1406 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
|
1407 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
|
1408 } |
d10a37eb91ee
patch 8.2.2057: getting the selection may trigger TextYankPost autocmd
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1409 # endif |
7 | 1410 #endif |
1411 | |
1412 VIsual_active = FALSE; | |
1413 setmouse(); | |
1414 mouse_dragging = 0; | |
1415 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1416 // Save the current VIsual area for '< and '> marks, and "gv" |
690 | 1417 curbuf->b_visual.vi_mode = VIsual_mode; |
1418 curbuf->b_visual.vi_start = VIsual; | |
1419 curbuf->b_visual.vi_end = curwin->w_cursor; | |
1420 curbuf->b_visual.vi_curswant = curwin->w_curswant; | |
7 | 1421 #ifdef FEAT_EVAL |
1422 curbuf->b_visual_mode_eval = VIsual_mode; | |
1423 #endif | |
1424 if (!virtual_active()) | |
1425 curwin->w_cursor.coladd = 0; | |
6979 | 1426 may_clear_cmdline(); |
7 | 1427 |
844 | 1428 adjust_cursor_eol(); |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
1429 trigger_modechanged(); |
7 | 1430 } |
1431 | |
1432 /* | |
1433 * Reset VIsual_active and VIsual_reselect. | |
1434 */ | |
1435 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1436 reset_VIsual_and_resel(void) |
7 | 1437 { |
1438 if (VIsual_active) | |
1439 { | |
1440 end_visual_mode(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1441 redraw_curbuf_later(INVERTED); // delete the inversion later |
7 | 1442 } |
1443 VIsual_reselect = FALSE; | |
1444 } | |
1445 | |
1446 /* | |
1447 * Reset VIsual_active and VIsual_reselect if it's set. | |
1448 */ | |
1449 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1450 reset_VIsual(void) |
7 | 1451 { |
1452 if (VIsual_active) | |
1453 { | |
1454 end_visual_mode(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1455 redraw_curbuf_later(INVERTED); // delete the inversion later |
7 | 1456 VIsual_reselect = FALSE; |
1457 } | |
1458 } | |
1459 | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1460 void |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1461 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
|
1462 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1463 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
|
1464 { |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1465 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
|
1466 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
|
1467 } |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1468 } |
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1469 |
7 | 1470 /* |
1471 * Check for a balloon-eval special item to include when searching for an | |
1472 * identifier. When "dir" is BACKWARD "ptr[-1]" must be valid! | |
1473 * Returns TRUE if the character at "*ptr" should be included. | |
1474 * "dir" is FORWARD or BACKWARD, the direction of searching. | |
1475 * "*colp" is in/decremented if "ptr[-dir]" should also be included. | |
1476 * "bnp" points to a counter for square brackets. | |
1477 */ | |
1478 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1479 find_is_eval_item( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1480 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1481 int *colp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1482 int *bnp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1483 int dir) |
7 | 1484 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1485 // Accept everything inside []. |
7 | 1486 if ((*ptr == ']' && dir == BACKWARD) || (*ptr == '[' && dir == FORWARD)) |
1487 ++*bnp; | |
1488 if (*bnp > 0) | |
1489 { | |
1490 if ((*ptr == '[' && dir == BACKWARD) || (*ptr == ']' && dir == FORWARD)) | |
1491 --*bnp; | |
1492 return TRUE; | |
1493 } | |
1494 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1495 // skip over "s.var" |
7 | 1496 if (*ptr == '.') |
1497 return TRUE; | |
1498 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1499 // two-character item: s->var |
7 | 1500 if (ptr[dir == BACKWARD ? 0 : 1] == '>' |
1501 && ptr[dir == BACKWARD ? -1 : 0] == '-') | |
1502 { | |
1503 *colp += dir; | |
1504 return TRUE; | |
1505 } | |
1506 return FALSE; | |
1507 } | |
1508 | |
1509 /* | |
1510 * Find the identifier under or to the right of the cursor. | |
1511 * "find_type" can have one of three values: | |
1512 * 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
|
1513 * 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
|
1514 * FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred. |
184 | 1515 * FIND_EVAL: find text useful for C program debugging |
7 | 1516 * |
1517 * 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
|
1518 * 1. Search forward for the start of an identifier/text. Doesn't move if |
7 | 1519 * 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
|
1520 * 2. Search backward for the start of this identifier/text. |
7 | 1521 * This doesn't match the real Vi but I like it a little better and it |
1522 * 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
|
1523 * 3. Search forward to the end of this identifier/text. |
7 | 1524 * When FIND_IDENT isn't defined, we backup until a blank. |
1525 * | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1526 * 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
|
1527 * 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
|
1528 * points into the current buffer line and is not always NUL terminated. |
7 | 1529 */ |
1530 int | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1531 find_ident_under_cursor(char_u **text, int find_type) |
7 | 1532 { |
1533 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
|
1534 curwin->w_cursor.col, text, NULL, find_type); |
7 | 1535 } |
1536 | |
1537 /* | |
1538 * Like find_ident_under_cursor(), but for any window and any position. | |
1539 * However: Uses 'iskeyword' from the current window!. | |
1540 */ | |
1541 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1542 find_ident_at_pos( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1543 win_T *wp, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1544 linenr_T lnum, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1545 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
|
1546 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
|
1547 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
|
1548 int find_type) |
7 | 1549 { |
1550 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
|
1551 int col = 0; // init to shut up GCC |
7 | 1552 int i; |
1553 int this_class = 0; | |
1554 int prev_class; | |
1555 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
|
1556 int bn = 0; // bracket nesting |
7 | 1557 |
1558 /* | |
1559 * 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
|
1560 * if i == 1: try to find any non-white text |
7 | 1561 */ |
1562 ptr = ml_get_buf(wp->w_buffer, lnum, FALSE); | |
1563 for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i) | |
1564 { | |
1565 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1566 * 1. skip to start of identifier/text |
7 | 1567 */ |
1568 col = startcol; | |
1569 if (has_mbyte) | |
1570 { | |
1571 while (ptr[col] != NUL) | |
1572 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1573 // Stop at a ']' to evaluate "a[x]". |
7 | 1574 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1575 break; | |
1576 this_class = mb_get_class(ptr + col); | |
1577 if (this_class != 0 && (i == 1 || this_class != 1)) | |
1578 break; | |
474 | 1579 col += (*mb_ptr2len)(ptr + col); |
7 | 1580 } |
1581 } | |
1582 else | |
1583 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
|
1584 && (i == 0 ? !vim_iswordc(ptr[col]) : VIM_ISWHITE(ptr[col])) |
7 | 1585 && (!(find_type & FIND_EVAL) || ptr[col] != ']') |
1586 ) | |
1587 ++col; | |
1588 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1589 // When starting on a ']' count it, so that we include the '['. |
7 | 1590 bn = ptr[col] == ']'; |
1591 | |
1592 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1593 * 2. Back up to start of identifier/text. |
7 | 1594 */ |
1595 if (has_mbyte) | |
1596 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1597 // Remember class of character under cursor. |
7 | 1598 if ((find_type & FIND_EVAL) && ptr[col] == ']') |
1599 this_class = mb_get_class((char_u *)"a"); | |
1600 else | |
1601 this_class = mb_get_class(ptr + col); | |
835 | 1602 while (col > 0 && this_class != 0) |
7 | 1603 { |
1604 prevcol = col - 1 - (*mb_head_off)(ptr, ptr + col - 1); | |
1605 prev_class = mb_get_class(ptr + prevcol); | |
1606 if (this_class != prev_class | |
1607 && (i == 0 | |
1608 || prev_class == 0 | |
1609 || (find_type & FIND_IDENT)) | |
1610 && (!(find_type & FIND_EVAL) | |
1611 || prevcol == 0 | |
1612 || !find_is_eval_item(ptr + prevcol, &prevcol, | |
1613 &bn, BACKWARD)) | |
1614 ) | |
1615 break; | |
1616 col = prevcol; | |
1617 } | |
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 // 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
|
1620 // identifier, stop searching. |
7 | 1621 if (this_class > 2) |
1622 this_class = 2; | |
1623 if (!(find_type & FIND_STRING) || this_class == 2) | |
1624 break; | |
1625 } | |
1626 else | |
1627 { | |
1628 while (col > 0 | |
1629 && ((i == 0 | |
1630 ? 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
|
1631 : (!VIM_ISWHITE(ptr[col - 1]) |
7 | 1632 && (!(find_type & FIND_IDENT) |
1633 || !vim_iswordc(ptr[col - 1])))) | |
1634 || ((find_type & FIND_EVAL) | |
1635 && col > 1 | |
1636 && find_is_eval_item(ptr + col - 1, &col, | |
1637 &bn, BACKWARD)) | |
1638 )) | |
1639 --col; | |
1640 | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1641 // 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
|
1642 // identifier, stop searching. |
7 | 1643 if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col])) |
1644 break; | |
1645 } | |
1646 } | |
1647 | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1648 if (ptr[col] == NUL || (i == 0 |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1649 && (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col])))) |
7 | 1650 { |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1651 // 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
|
1652 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
|
1653 { |
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1654 if (find_type & FIND_STRING) |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
1655 emsg(_(e_no_string_under_cursor)); |
16908
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1656 else |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
1657 emsg(_(e_no_identifier_under_cursor)); |
16908
df06694b761b
patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1658 } |
7 | 1659 return 0; |
1660 } | |
1661 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
|
1662 *text = ptr; |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1663 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
|
1664 *textcol = col; |
7 | 1665 |
1666 /* | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1667 * 3. Find the end if the identifier/text. |
7 | 1668 */ |
1669 bn = 0; | |
1670 startcol -= col; | |
1671 col = 0; | |
1672 if (has_mbyte) | |
1673 { | |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1674 // Search for point of changing multibyte character class. |
7 | 1675 this_class = mb_get_class(ptr); |
1676 while (ptr[col] != NUL | |
1677 && ((i == 0 ? mb_get_class(ptr + col) == this_class | |
1678 : mb_get_class(ptr + col) != 0) | |
1679 || ((find_type & FIND_EVAL) | |
1680 && col <= (int)startcol | |
1681 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1682 )) | |
474 | 1683 col += (*mb_ptr2len)(ptr + col); |
7 | 1684 } |
1685 else | |
1686 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
|
1687 : (ptr[col] != NUL && !VIM_ISWHITE(ptr[col]))) |
7 | 1688 || ((find_type & FIND_EVAL) |
1689 && col <= (int)startcol | |
1690 && find_is_eval_item(ptr + col, &col, &bn, FORWARD)) | |
1691 ) | |
1692 ++col; | |
1693 | |
1694 return col; | |
1695 } | |
1696 | |
1697 /* | |
1698 * Prepare for redo of a normal command. | |
1699 */ | |
1700 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1701 prep_redo_cmd(cmdarg_T *cap) |
7 | 1702 { |
1703 prep_redo(cap->oap->regname, cap->count0, | |
1704 NUL, cap->cmdchar, NUL, NUL, cap->nchar); | |
1705 } | |
1706 | |
1707 /* | |
1708 * Prepare for redo of any command. | |
1709 * Note that only the last argument can be a multi-byte char. | |
1710 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1711 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1712 prep_redo( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1713 int regname, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1714 long num, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1715 int cmd1, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1716 int cmd2, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1717 int cmd3, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1718 int cmd4, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1719 int cmd5) |
7 | 1720 { |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1721 prep_redo_num2(regname, num, cmd1, cmd2, 0L, cmd3, cmd4, cmd5); |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1722 } |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1723 |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1724 /* |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1725 * Prepare for redo of any command with extra count after "cmd2". |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1726 */ |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1727 void |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1728 prep_redo_num2( |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1729 int regname, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1730 long num1, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1731 int cmd1, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1732 int cmd2, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1733 long num2, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1734 int cmd3, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1735 int cmd4, |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1736 int cmd5) |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1737 { |
7 | 1738 ResetRedobuff(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1739 if (regname != 0) // yank from specified buffer |
7 | 1740 { |
1741 AppendCharToRedobuff('"'); | |
1742 AppendCharToRedobuff(regname); | |
1743 } | |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1744 if (num1 != 0) |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1745 AppendNumberToRedobuff(num1); |
7 | 1746 if (cmd1 != NUL) |
1747 AppendCharToRedobuff(cmd1); | |
1748 if (cmd2 != NUL) | |
1749 AppendCharToRedobuff(cmd2); | |
26226
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1750 if (num2 != 0) |
9a8e9383e4cd
patch 8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Bram Moolenaar <Bram@vim.org>
parents:
26159
diff
changeset
|
1751 AppendNumberToRedobuff(num2); |
7 | 1752 if (cmd3 != NUL) |
1753 AppendCharToRedobuff(cmd3); | |
1754 if (cmd4 != NUL) | |
1755 AppendCharToRedobuff(cmd4); | |
1756 if (cmd5 != NUL) | |
1757 AppendCharToRedobuff(cmd5); | |
1758 } | |
1759 | |
1760 /* | |
1761 * check for operator active and clear it | |
1762 * | |
1763 * return TRUE if operator was active | |
1764 */ | |
1765 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1766 checkclearop(oparg_T *oap) |
7 | 1767 { |
1768 if (oap->op_type == OP_NOP) | |
1769 return FALSE; | |
1770 clearopbeep(oap); | |
1771 return TRUE; | |
1772 } | |
1773 | |
1774 /* | |
1131 | 1775 * Check for operator or Visual active. Clear active operator. |
7 | 1776 * |
1131 | 1777 * Return TRUE if operator or Visual was active. |
7 | 1778 */ |
1779 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1780 checkclearopq(oparg_T *oap) |
7 | 1781 { |
5735 | 1782 if (oap->op_type == OP_NOP && !VIsual_active) |
7 | 1783 return FALSE; |
1784 clearopbeep(oap); | |
1785 return TRUE; | |
1786 } | |
1787 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1788 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1789 clearop(oparg_T *oap) |
7 | 1790 { |
1791 oap->op_type = OP_NOP; | |
1792 oap->regname = 0; | |
1793 oap->motion_force = NUL; | |
1794 oap->use_reg_one = FALSE; | |
24800
b032da736676
patch 8.2.2938: after using motion force from feedkeys() it sticks
Bram Moolenaar <Bram@vim.org>
parents:
24788
diff
changeset
|
1795 motion_force = NUL; |
7 | 1796 } |
1797 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
1798 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1799 clearopbeep(oparg_T *oap) |
7 | 1800 { |
1801 clearop(oap); | |
1802 beep_flush(); | |
1803 } | |
1804 | |
1805 /* | |
1806 * Remove the shift modifier from a special key. | |
1807 */ | |
1808 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1809 unshift_special(cmdarg_T *cap) |
7 | 1810 { |
1811 switch (cap->cmdchar) | |
1812 { | |
1813 case K_S_RIGHT: cap->cmdchar = K_RIGHT; break; | |
1814 case K_S_LEFT: cap->cmdchar = K_LEFT; break; | |
1815 case K_S_UP: cap->cmdchar = K_UP; break; | |
1816 case K_S_DOWN: cap->cmdchar = K_DOWN; break; | |
1817 case K_S_HOME: cap->cmdchar = K_HOME; break; | |
1818 case K_S_END: cap->cmdchar = K_END; break; | |
1819 } | |
1820 cap->cmdchar = simplify_key(cap->cmdchar, &mod_mask); | |
1821 } | |
1822 | |
6979 | 1823 /* |
1824 * If the mode is currently displayed clear the command line or update the | |
1825 * command displayed. | |
1826 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
1827 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1828 may_clear_cmdline(void) |
6979 | 1829 { |
1830 if (mode_displayed) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1831 clear_cmdline = TRUE; // unshow visual mode later |
6979 | 1832 #ifdef FEAT_CMDL_INFO |
1833 else | |
1834 clear_showcmd(); | |
1835 #endif | |
1836 } | |
1837 | |
7 | 1838 #if defined(FEAT_CMDL_INFO) || defined(PROTO) |
1839 /* | |
1840 * Routines for displaying a partly typed command | |
1841 */ | |
1842 | |
5735 | 1843 #define SHOWCMD_BUFLEN SHOWCMD_COLS + 1 + 30 |
7 | 1844 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
|
1845 static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd() |
7 | 1846 static int showcmd_is_clear = TRUE; |
1847 static int showcmd_visual = FALSE; | |
1848 | |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
1849 static void display_showcmd(void); |
7 | 1850 |
1851 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1852 clear_showcmd(void) |
7 | 1853 { |
1854 if (!p_sc) | |
1855 return; | |
1856 | |
1857 if (VIsual_active && !char_avail()) | |
1858 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
1859 int cursor_bot = LT_POS(VIsual, curwin->w_cursor); |
7 | 1860 long lines; |
1861 colnr_T leftcol, rightcol; | |
1862 linenr_T top, bot; | |
1863 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1864 // Show the size of the Visual area. |
1866 | 1865 if (cursor_bot) |
7 | 1866 { |
1867 top = VIsual.lnum; | |
1868 bot = curwin->w_cursor.lnum; | |
1869 } | |
1870 else | |
1871 { | |
1872 top = curwin->w_cursor.lnum; | |
1873 bot = VIsual.lnum; | |
1874 } | |
1875 # ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1876 // Include closed folds as a whole. |
7009 | 1877 (void)hasFolding(top, &top, NULL); |
1878 (void)hasFolding(bot, NULL, &bot); | |
7 | 1879 # endif |
1880 lines = bot - top + 1; | |
1881 | |
1882 if (VIsual_mode == Ctrl_V) | |
1883 { | |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1884 # ifdef FEAT_LINEBREAK |
1866 | 1885 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
|
1886 char_u *saved_w_sbr = curwin->w_p_sbr; |
1866 | 1887 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1888 // Make 'sbr' empty for a moment to get the correct size. |
1866 | 1889 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
|
1890 curwin->w_p_sbr = empty_option; |
2335
2a5478294078
Fix build broken without multi-byte feature.
Bram Moolenaar <bram@vim.org>
parents:
2326
diff
changeset
|
1891 # endif |
7 | 1892 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
|
1893 # ifdef FEAT_LINEBREAK |
1866 | 1894 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
|
1895 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
|
1896 # endif |
7 | 1897 sprintf((char *)showcmd_buf, "%ldx%ld", lines, |
1898 (long)(rightcol - leftcol + 1)); | |
1899 } | |
1900 else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) | |
1901 sprintf((char *)showcmd_buf, "%ld", lines); | |
1902 else | |
2324
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1903 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1904 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
|
1905 int l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1906 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
|
1907 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
|
1908 |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1909 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
|
1910 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1911 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
|
1912 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
|
1913 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1914 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1915 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1916 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
|
1917 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
|
1918 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1919 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
|
1920 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1921 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
|
1922 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
|
1923 { |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1924 ++bytes; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1925 ++chars; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1926 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
|
1927 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1928 bytes += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1929 ++chars; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1930 s += l; |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1931 } |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1932 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
|
1933 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
|
1934 else |
0a258a67051d
In Visual mode with 'showcmd' display the number of bytes and characters.
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
1935 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
|
1936 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1937 showcmd_buf[SHOWCMD_COLS] = NUL; // truncate |
7 | 1938 showcmd_visual = TRUE; |
1939 } | |
1940 else | |
1941 { | |
1942 showcmd_buf[0] = NUL; | |
1943 showcmd_visual = FALSE; | |
1944 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1945 // Don't actually display something if there is nothing to clear. |
7 | 1946 if (showcmd_is_clear) |
1947 return; | |
1948 } | |
1949 | |
1950 display_showcmd(); | |
1951 } | |
1952 | |
1953 /* | |
1954 * Add 'c' to string of shown command chars. | |
1955 * Return TRUE if output has been written (and setcursor() has been called). | |
1956 */ | |
1957 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1958 add_to_showcmd(int c) |
7 | 1959 { |
1960 char_u *p; | |
1961 int old_len; | |
1962 int extra_len; | |
1963 int overflow; | |
1964 int i; | |
1965 static int ignore[] = | |
1966 { | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18291
diff
changeset
|
1967 #ifdef FEAT_GUI |
7 | 1968 K_VER_SCROLLBAR, K_HOR_SCROLLBAR, |
1969 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
|
1970 #endif |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
1971 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
|
1972 K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE, |
7 | 1973 K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE, |
1974 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
|
1975 K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT, |
7 | 1976 K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE, |
631 | 1977 K_CURSORHOLD, |
7 | 1978 0 |
1979 }; | |
1980 | |
641 | 1981 if (!p_sc || msg_silent != 0) |
7 | 1982 return FALSE; |
1983 | |
1984 if (showcmd_visual) | |
1985 { | |
1986 showcmd_buf[0] = NUL; | |
1987 showcmd_visual = FALSE; | |
1988 } | |
1989 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
1990 // Ignore keys that are scrollbar updates and mouse clicks |
7 | 1991 if (IS_SPECIAL(c)) |
1992 for (i = 0; ignore[i] != 0; ++i) | |
1993 if (ignore[i] == c) | |
1994 return FALSE; | |
1995 | |
1996 p = transchar(c); | |
5535 | 1997 if (*p == ' ') |
1998 STRCPY(p, "<20>"); | |
7 | 1999 old_len = (int)STRLEN(showcmd_buf); |
2000 extra_len = (int)STRLEN(p); | |
2001 overflow = old_len + extra_len - SHOWCMD_COLS; | |
2002 if (overflow > 0) | |
1362 | 2003 mch_memmove(showcmd_buf, showcmd_buf + overflow, |
2004 old_len - overflow + 1); | |
7 | 2005 STRCAT(showcmd_buf, p); |
2006 | |
2007 if (char_avail()) | |
2008 return FALSE; | |
2009 | |
2010 display_showcmd(); | |
2011 | |
2012 return TRUE; | |
2013 } | |
2014 | |
2015 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2016 add_to_showcmd_c(int c) |
7 | 2017 { |
2018 if (!add_to_showcmd(c)) | |
2019 setcursor(); | |
2020 } | |
2021 | |
2022 /* | |
2023 * Delete 'len' characters from the end of the shown command. | |
2024 */ | |
2025 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2026 del_from_showcmd(int len) |
7 | 2027 { |
2028 int old_len; | |
2029 | |
2030 if (!p_sc) | |
2031 return; | |
2032 | |
2033 old_len = (int)STRLEN(showcmd_buf); | |
2034 if (len > old_len) | |
2035 len = old_len; | |
2036 showcmd_buf[old_len - len] = NUL; | |
2037 | |
2038 if (!char_avail()) | |
2039 display_showcmd(); | |
2040 } | |
2041 | |
2042 /* | |
2043 * push_showcmd() and pop_showcmd() are used when waiting for the user to type | |
2044 * something and there is a partial mapping. | |
2045 */ | |
2046 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2047 push_showcmd(void) |
7 | 2048 { |
2049 if (p_sc) | |
2050 STRCPY(old_showcmd_buf, showcmd_buf); | |
2051 } | |
2052 | |
2053 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2054 pop_showcmd(void) |
7 | 2055 { |
2056 if (!p_sc) | |
2057 return; | |
2058 | |
2059 STRCPY(showcmd_buf, old_showcmd_buf); | |
2060 | |
2061 display_showcmd(); | |
2062 } | |
2063 | |
2064 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2065 display_showcmd(void) |
7 | 2066 { |
2067 int len; | |
2068 | |
2069 cursor_off(); | |
2070 | |
2071 len = (int)STRLEN(showcmd_buf); | |
2072 if (len == 0) | |
2073 showcmd_is_clear = TRUE; | |
2074 else | |
2075 { | |
2076 screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0); | |
2077 showcmd_is_clear = FALSE; | |
2078 } | |
2079 | |
2080 /* | |
1188 | 2081 * clear the rest of an old message by outputting up to SHOWCMD_COLS |
2082 * spaces | |
7 | 2083 */ |
2084 screen_puts((char_u *)" " + len, (int)Rows - 1, sc_col + len, 0); | |
2085 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2086 setcursor(); // put cursor back where it belongs |
7 | 2087 } |
2088 #endif | |
2089 | |
2090 /* | |
2091 * When "check" is FALSE, prepare for commands that scroll the window. | |
2092 * When "check" is TRUE, take care of scroll-binding after the window has | |
2093 * scrolled. Called from normal_cmd() and edit(). | |
2094 */ | |
2095 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2096 do_check_scrollbind(int check) |
7 | 2097 { |
2098 static win_T *old_curwin = NULL; | |
2099 static linenr_T old_topline = 0; | |
2100 #ifdef FEAT_DIFF | |
2101 static int old_topfill = 0; | |
2102 #endif | |
2103 static buf_T *old_buf = NULL; | |
2104 static colnr_T old_leftcol = 0; | |
2105 | |
2106 if (check && curwin->w_p_scb) | |
2107 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2108 // 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
|
2109 // the values. |
7 | 2110 if (did_syncbind) |
2111 did_syncbind = FALSE; | |
2112 else if (curwin == old_curwin) | |
2113 { | |
2114 /* | |
2115 * Synchronize other windows, as necessary according to | |
2116 * 'scrollbind'. Don't do this after an ":edit" command, except | |
2117 * when 'diff' is set. | |
2118 */ | |
2119 if ((curwin->w_buffer == old_buf | |
2120 #ifdef FEAT_DIFF | |
2121 || curwin->w_p_diff | |
2122 #endif | |
2123 ) | |
2124 && (curwin->w_topline != old_topline | |
2125 #ifdef FEAT_DIFF | |
2126 || curwin->w_topfill != old_topfill | |
2127 #endif | |
2128 || curwin->w_leftcol != old_leftcol)) | |
2129 { | |
2130 check_scrollbind(curwin->w_topline - old_topline, | |
2131 (long)(curwin->w_leftcol - old_leftcol)); | |
2132 } | |
2133 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2134 else if (vim_strchr(p_sbo, 'j')) // jump flag set in 'scrollopt' |
7 | 2135 { |
2136 /* | |
2137 * When switching between windows, make sure that the relative | |
2138 * vertical offset is valid for the new window. The relative | |
2139 * offset is invalid whenever another 'scrollbind' window has | |
2140 * scrolled to a point that would force the current window to | |
2141 * scroll past the beginning or end of its buffer. When the | |
2142 * resync is performed, some of the other 'scrollbind' windows may | |
2143 * need to jump so that the current window's relative position is | |
2144 * visible on-screen. | |
2145 */ | |
2146 check_scrollbind(curwin->w_topline - curwin->w_scbind_pos, 0L); | |
2147 } | |
2148 curwin->w_scbind_pos = curwin->w_topline; | |
2149 } | |
2150 | |
2151 old_curwin = curwin; | |
2152 old_topline = curwin->w_topline; | |
2153 #ifdef FEAT_DIFF | |
2154 old_topfill = curwin->w_topfill; | |
2155 #endif | |
2156 old_buf = curwin->w_buffer; | |
2157 old_leftcol = curwin->w_leftcol; | |
2158 } | |
2159 | |
2160 /* | |
2161 * Synchronize any windows that have "scrollbind" set, based on the | |
2162 * number of rows by which the current window has changed | |
2163 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
2164 */ | |
2165 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2166 check_scrollbind(linenr_T topline_diff, long leftcol_diff) |
7 | 2167 { |
2168 int want_ver; | |
2169 int want_hor; | |
2170 win_T *old_curwin = curwin; | |
2171 buf_T *old_curbuf = curbuf; | |
2172 int old_VIsual_select = VIsual_select; | |
2173 int old_VIsual_active = VIsual_active; | |
2174 colnr_T tgt_leftcol = curwin->w_leftcol; | |
2175 long topline; | |
2176 long y; | |
2177 | |
2178 /* | |
2179 * check 'scrollopt' string for vertical and horizontal scroll options | |
2180 */ | |
2181 want_ver = (vim_strchr(p_sbo, 'v') && topline_diff != 0); | |
2182 #ifdef FEAT_DIFF | |
2183 want_ver |= old_curwin->w_p_diff; | |
2184 #endif | |
2185 want_hor = (vim_strchr(p_sbo, 'h') && (leftcol_diff || topline_diff != 0)); | |
2186 | |
2187 /* | |
2188 * loop through the scrollbound windows and scroll accordingly | |
2189 */ | |
2190 VIsual_select = VIsual_active = 0; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
2191 FOR_ALL_WINDOWS(curwin) |
7 | 2192 { |
2193 curbuf = curwin->w_buffer; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2194 // skip original window and windows with 'noscrollbind' |
7 | 2195 if (curwin != old_curwin && curwin->w_p_scb) |
2196 { | |
2197 /* | |
2198 * do the vertical scroll | |
2199 */ | |
2200 if (want_ver) | |
2201 { | |
2202 #ifdef FEAT_DIFF | |
2203 if (old_curwin->w_p_diff && curwin->w_p_diff) | |
2204 { | |
2205 diff_set_topline(old_curwin, curwin); | |
2206 } | |
2207 else | |
2208 #endif | |
2209 { | |
2210 curwin->w_scbind_pos += topline_diff; | |
2211 topline = curwin->w_scbind_pos; | |
2212 if (topline > curbuf->b_ml.ml_line_count) | |
2213 topline = curbuf->b_ml.ml_line_count; | |
2214 if (topline < 1) | |
2215 topline = 1; | |
2216 | |
2217 y = topline - curwin->w_topline; | |
2218 if (y > 0) | |
2219 scrollup(y, FALSE); | |
2220 else | |
2221 scrolldown(-y, FALSE); | |
2222 } | |
2223 | |
2224 redraw_later(VALID); | |
2225 cursor_correct(); | |
2226 curwin->w_redr_status = TRUE; | |
2227 } | |
2228 | |
2229 /* | |
2230 * do the horizontal scroll | |
2231 */ | |
2232 if (want_hor && curwin->w_leftcol != tgt_leftcol) | |
2233 { | |
2234 curwin->w_leftcol = tgt_leftcol; | |
2235 leftcol_changed(); | |
2236 } | |
2237 } | |
2238 } | |
2239 | |
2240 /* | |
2241 * reset current-window | |
2242 */ | |
2243 VIsual_select = old_VIsual_select; | |
2244 VIsual_active = old_VIsual_active; | |
2245 curwin = old_curwin; | |
2246 curbuf = old_curbuf; | |
2247 } | |
2248 | |
2249 /* | |
2250 * Command character that's ignored. | |
2251 * 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
|
2252 * xon/xoff. |
7 | 2253 */ |
2254 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2255 nv_ignore(cmdarg_T *cap) |
7 | 2256 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2257 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
7 | 2258 } |
2259 | |
2260 /* | |
620 | 2261 * Command character that doesn't do anything, but unlike nv_ignore() does |
2262 * start edit(). Used for "startinsert" executed while starting up. | |
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_nop(cmdarg_T *cap UNUSED) |
620 | 2266 { |
2267 } | |
2268 | |
2269 /* | |
7 | 2270 * Command character doesn't exist. |
2271 */ | |
2272 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2273 nv_error(cmdarg_T *cap) |
7 | 2274 { |
2275 clearopbeep(cap->oap); | |
2276 } | |
2277 | |
2278 /* | |
2279 * <Help> and <F1> commands. | |
2280 */ | |
2281 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2282 nv_help(cmdarg_T *cap) |
7 | 2283 { |
2284 if (!checkclearopq(cap->oap)) | |
2285 ex_help(NULL); | |
2286 } | |
2287 | |
2288 /* | |
2289 * CTRL-A and CTRL-X: Add or subtract from letter or number under cursor. | |
2290 */ | |
2291 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2292 nv_addsub(cmdarg_T *cap) |
7 | 2293 { |
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
|
2294 #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
|
2295 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
|
2296 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
|
2297 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
|
2298 #endif |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2299 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
|
2300 { |
7578
fdae4c496775
commit https://github.com/vim/vim/commit/ef2b5036b3005f1ce15d146dce72379a9834c56d
Christian Brabandt <cb@256bit.org>
parents:
7574
diff
changeset
|
2301 prep_redo_cmd(cap); |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2302 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
|
2303 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
|
2304 cap->oap->op_type = OP_NOP; |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2305 } |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2306 else if (VIsual_active) |
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2307 nv_operator(cap); |
6868 | 2308 else |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
2309 clearop(cap->oap); |
7 | 2310 } |
2311 | |
2312 /* | |
2313 * CTRL-F, CTRL-B, etc: Scroll page up or down. | |
2314 */ | |
2315 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2316 nv_page(cmdarg_T *cap) |
7 | 2317 { |
2318 if (!checkclearop(cap->oap)) | |
819 | 2319 { |
2320 if (mod_mask & MOD_MASK_CTRL) | |
2321 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2322 // <C-PageUp>: tab page back; <C-PageDown>: tab page forward |
819 | 2323 if (cap->arg == BACKWARD) |
2324 goto_tabpage(-(int)cap->count1); | |
2325 else | |
2326 goto_tabpage((int)cap->count0); | |
2327 } | |
2328 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12467
diff
changeset
|
2329 (void)onepage(cap->arg, cap->count1); |
819 | 2330 } |
7 | 2331 } |
2332 | |
2333 /* | |
2334 * Implementation of "gd" and "gD" command. | |
2335 */ | |
2336 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2337 nv_gd( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2338 oparg_T *oap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2339 int nchar, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2340 int thisblock) // 1 for "1gd" and "1gD" |
7 | 2341 { |
2342 int len; | |
503 | 2343 char_u *ptr; |
2344 | |
2345 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
|
2346 || find_decl(ptr, len, nchar == 'd', thisblock, SEARCH_START) |
26101
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2347 == FAIL) |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2348 { |
503 | 2349 clearopbeep(oap); |
26101
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2350 } |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2351 else |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2352 { |
503 | 2353 #ifdef FEAT_FOLDING |
26101
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2354 if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2355 foldOpenCursor(); |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2356 #endif |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2357 // clear any search statistics |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2358 if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT)) |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2359 clear_cmdline = TRUE; |
5317b0ae4893
patch 8.2.3583: the "gd" and "gD" commands do not update search stats
Bram Moolenaar <Bram@vim.org>
parents:
26094
diff
changeset
|
2360 } |
503 | 2361 } |
2362 | |
2363 /* | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2364 * 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
|
2365 * otherwise. |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2366 */ |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2367 static int |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2368 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
|
2369 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2370 int i; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2371 int incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2372 int instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2373 int prev = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2374 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2375 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
|
2376 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2377 if (instring != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2378 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2379 if (prev != '\\' && line[i] == instring) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2380 instring = 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2381 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2382 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
|
2383 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2384 instring = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2385 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2386 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2387 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2388 if (incomment) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2389 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2390 if (prev == '*' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2391 incomment = FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2392 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2393 else if (prev == '/' && line[i] == '*') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2394 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2395 incomment = TRUE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2396 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2397 else if (prev == '/' && line[i] == '/') |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2398 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2399 return FALSE; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2400 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2401 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2402 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2403 prev = line[i]; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2404 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2405 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2406 return incomment == FALSE && instring == 0; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2407 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2408 |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2409 /* |
523 | 2410 * Search for variable declaration of "ptr[len]". |
2411 * When "locally" is TRUE in the current function ("gd"), otherwise in the | |
2412 * current file ("gD"). | |
2413 * When "thisblock" is TRUE check the {} block scope. | |
503 | 2414 * Return FAIL when not found. |
2415 */ | |
2416 int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2417 find_decl( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2418 char_u *ptr, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2419 int len, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2420 int locally, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2421 int thisblock, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2422 int flags_arg) // flags passed to searchit() |
503 | 2423 { |
7 | 2424 char_u *pat; |
2425 pos_T old_pos; | |
503 | 2426 pos_T par_pos; |
2427 pos_T found_pos; | |
7 | 2428 int t; |
2429 int save_p_ws; | |
2430 int save_p_scs; | |
503 | 2431 int retval = OK; |
944 | 2432 int incll; |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2433 int searchflags = flags_arg; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2434 int valid; |
503 | 2435 |
2436 if ((pat = alloc(len + 7)) == NULL) | |
2437 return FAIL; | |
268 | 2438 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2439 // 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
|
2440 // and "~" causes trouble. |
268 | 2441 sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", |
2442 len, ptr); | |
7 | 2443 old_pos = curwin->w_cursor; |
2444 save_p_ws = p_ws; | |
2445 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
|
2446 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
|
2447 p_scs = FALSE; // don't switch ignorecase off now |
7 | 2448 |
2449 /* | |
2450 * With "gD" go to line 1. | |
2451 * With "gd" Search back for the start of the current function, then go | |
2452 * back until a blank line. If this fails go to line 1. | |
2453 */ | |
944 | 2454 if (!locally || !findpar(&incll, BACKWARD, 1L, '{', FALSE)) |
7 | 2455 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2456 setpcmark(); // Set in findpar() otherwise |
7 | 2457 curwin->w_cursor.lnum = 1; |
539 | 2458 par_pos = curwin->w_cursor; |
7 | 2459 } |
2460 else | |
2461 { | |
539 | 2462 par_pos = curwin->w_cursor; |
7 | 2463 while (curwin->w_cursor.lnum > 1 && *skipwhite(ml_get_curline()) != NUL) |
2464 --curwin->w_cursor.lnum; | |
2465 } | |
2466 curwin->w_cursor.col = 0; | |
2467 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2468 // 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
|
2469 CLEAR_POS(&found_pos); |
503 | 2470 for (;;) |
2471 { | |
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
|
2472 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
|
2473 pat, 1L, searchflags, RE_LAST, NULL); |
503 | 2474 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
|
2475 t = FAIL; // match after start is failure too |
523 | 2476 |
718 | 2477 if (thisblock && t != FAIL) |
523 | 2478 { |
2479 pos_T *pos; | |
2480 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2481 // 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
|
2482 // position where we started the search from. |
523 | 2483 if ((pos = findmatchlimit(NULL, '}', FM_FORWARD, |
2484 (int)(old_pos.lnum - curwin->w_cursor.lnum + 1))) != NULL | |
2485 && pos->lnum < old_pos.lnum) | |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2486 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2487 // 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
|
2488 // Skip to the end. |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2489 curwin->w_cursor = *pos; |
523 | 2490 continue; |
11366
b16bc115a270
patch 8.0.0568: 1gd may hang
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2491 } |
523 | 2492 } |
2493 | |
503 | 2494 if (t == FAIL) |
2495 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2496 // If we previously found a valid position, use it. |
503 | 2497 if (found_pos.lnum != 0) |
2498 { | |
2499 curwin->w_cursor = found_pos; | |
2500 t = OK; | |
2501 } | |
2502 break; | |
2503 } | |
3562 | 2504 if (get_leader_len(ml_get_curline(), NULL, FALSE, TRUE) > 0) |
503 | 2505 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2506 // Ignore this line, continue at start of next line. |
503 | 2507 ++curwin->w_cursor.lnum; |
2508 curwin->w_cursor.col = 0; | |
2509 continue; | |
2510 } | |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2511 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
|
2512 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2513 // 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
|
2514 // 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
|
2515 if (!valid && found_pos.lnum != 0) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2516 { |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2517 curwin->w_cursor = found_pos; |
503 | 2518 break; |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2519 } |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2520 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2521 // 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
|
2522 if (valid && !locally) |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2523 break; |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2524 if (valid && curwin->w_cursor.lnum >= par_pos.lnum) |
503 | 2525 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2526 // If we previously found a valid position, use it. |
503 | 2527 if (found_pos.lnum != 0) |
2528 curwin->w_cursor = found_pos; | |
2529 break; | |
2530 } | |
2531 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2532 // 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
|
2533 // 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
|
2534 // 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
|
2535 if (!valid) |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
2536 CLEAR_POS(&found_pos); |
10251
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2537 else |
bc442c2296a7
commit https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d
Christian Brabandt <cb@256bit.org>
parents:
10192
diff
changeset
|
2538 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
|
2539 // 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
|
2540 // position. |
9315
1b4946fa3777
commit https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
Christian Brabandt <cb@256bit.org>
parents:
9098
diff
changeset
|
2541 searchflags &= ~SEARCH_START; |
503 | 2542 } |
2543 | |
2544 if (t == FAIL) | |
2545 { | |
2546 retval = FAIL; | |
7 | 2547 curwin->w_cursor = old_pos; |
2548 } | |
2549 else | |
2550 { | |
2551 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
|
2552 // "n" searches forward now |
7 | 2553 reset_search_dir(); |
2554 } | |
2555 | |
2556 vim_free(pat); | |
2557 p_ws = save_p_ws; | |
2558 p_scs = save_p_scs; | |
503 | 2559 |
2560 return retval; | |
7 | 2561 } |
2562 | |
2563 /* | |
2564 * Move 'dist' lines in direction 'dir', counting lines by *screen* | |
2565 * lines rather than lines in the file. | |
2566 * 'dist' must be positive. | |
2567 * | |
2568 * Return OK if able to move cursor, FAIL otherwise. | |
2569 */ | |
2570 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2571 nv_screengo(oparg_T *oap, int dir, long dist) |
7 | 2572 { |
2573 int linelen = linetabsize(ml_get_curline()); | |
2574 int retval = OK; | |
2575 int atend = FALSE; | |
2576 int n; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2577 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
|
2578 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
|
2579 int width1; // text width for first screen line |
26094
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2580 int width2; // text width for wrapped screen line |
7 | 2581 |
2582 oap->motion_type = MCHAR; | |
5192
c28202427d71
updated for version 7.4a.022
Bram Moolenaar <bram@vim.org>
parents:
5162
diff
changeset
|
2583 oap->inclusive = (curwin->w_curswant == MAXCOL); |
7 | 2584 |
2585 col_off1 = curwin_col_off(); | |
2586 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
|
2587 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
|
2588 width2 = curwin->w_width - col_off2; |
6559 | 2589 if (width2 == 0) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2590 width2 = 1; // avoid divide by zero |
7 | 2591 |
2592 if (curwin->w_width != 0) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2593 { |
7 | 2594 /* |
2595 * Instead of sticking at the last character of the buffer line we | |
2596 * try to stick in the last column of the screen. | |
2597 */ | |
2598 if (curwin->w_curswant == MAXCOL) | |
2599 { | |
2600 atend = TRUE; | |
2601 validate_virtcol(); | |
2602 if (width1 <= 0) | |
2603 curwin->w_curswant = 0; | |
2604 else | |
2605 { | |
2606 curwin->w_curswant = width1 - 1; | |
2607 if (curwin->w_virtcol > curwin->w_curswant) | |
2608 curwin->w_curswant += ((curwin->w_virtcol | |
2609 - curwin->w_curswant - 1) / width2 + 1) * width2; | |
2610 } | |
2611 } | |
2612 else | |
2613 { | |
2614 if (linelen > width1) | |
2615 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2616 else | |
2617 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
|
2618 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
|
2619 curwin->w_curswant = n - 1; |
7 | 2620 } |
2621 | |
2622 while (dist--) | |
2623 { | |
2624 if (dir == BACKWARD) | |
2625 { | |
24341
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2626 if ((long)curwin->w_curswant >= width1 |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2627 #ifdef FEAT_FOLDING |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2628 && !hasFolding(curwin->w_cursor.lnum, NULL, NULL) |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2629 #endif |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2630 ) |
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
|
2631 // 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
|
2632 // 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
|
2633 // which will get clipped to column 0. |
7 | 2634 curwin->w_curswant -= width2; |
2635 else | |
2636 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2637 // 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
|
2638 #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
|
2639 // 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
|
2640 // '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
|
2641 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
|
2642 (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
|
2643 &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
|
2644 #endif |
7 | 2645 if (curwin->w_cursor.lnum == 1) |
2646 { | |
2647 retval = FAIL; | |
2648 break; | |
2649 } | |
2650 --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
|
2651 |
7 | 2652 linelen = linetabsize(ml_get_curline()); |
2653 if (linelen > width1) | |
2654 curwin->w_curswant += (((linelen - width1 - 1) / width2) | |
2655 + 1) * width2; | |
2656 } | |
2657 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2658 else // dir == FORWARD |
7 | 2659 { |
2660 if (linelen > width1) | |
2661 n = ((linelen - width1 - 1) / width2 + 1) * width2 + width1; | |
2662 else | |
2663 n = width1; | |
24341
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2664 if (curwin->w_curswant + width2 < (colnr_T)n |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2665 #ifdef FEAT_FOLDING |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2666 && !hasFolding(curwin->w_cursor.lnum, NULL, NULL) |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2667 #endif |
0e1b8b98f9f4
patch 8.2.2711: "gj" in a closed fold does not move out of the fold
Bram Moolenaar <Bram@vim.org>
parents:
24012
diff
changeset
|
2668 ) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2669 // move forward within line |
7 | 2670 curwin->w_curswant += width2; |
2671 else | |
2672 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2673 // to next line |
7 | 2674 #ifdef FEAT_FOLDING |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2675 // Move to the end of a closed fold. |
7 | 2676 (void)hasFolding(curwin->w_cursor.lnum, NULL, |
2677 &curwin->w_cursor.lnum); | |
2678 #endif | |
2679 if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) | |
2680 { | |
2681 retval = FAIL; | |
2682 break; | |
2683 } | |
2684 curwin->w_cursor.lnum++; | |
2685 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
|
2686 // 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
|
2687 // 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
|
2688 // 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
|
2689 // 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
|
2690 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
|
2691 curwin->w_curswant -= width2; |
2911 | 2692 linelen = linetabsize(ml_get_curline()); |
7 | 2693 } |
2694 } | |
2695 } | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8445
diff
changeset
|
2696 } |
7 | 2697 |
5600 | 2698 if (virtual_active() && atend) |
2699 coladvance(MAXCOL); | |
2700 else | |
2701 coladvance(curwin->w_curswant); | |
7 | 2702 |
2703 if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) | |
2704 { | |
6178 | 2705 colnr_T virtcol; |
26094
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2706 int c; |
6178 | 2707 |
7 | 2708 /* |
2709 * Check for landing on a character that got split at the end of the | |
2710 * last line. We want to advance a screenline, not end up in the same | |
2711 * screenline or move two screenlines. | |
2712 */ | |
2713 validate_virtcol(); | |
6178 | 2714 virtcol = curwin->w_virtcol; |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2715 #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
|
2716 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
|
2717 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
|
2718 #endif |
6178 | 2719 |
26094
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2720 c = (*mb_ptr2char)(ml_get_cursor()); |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2721 if (dir == FORWARD && virtcol < curwin->w_curswant |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2722 && (curwin->w_curswant <= (colnr_T)width1) |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2723 && !vim_isprintc(c) && c > 255) |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2724 oneright(); |
f53f365078dd
patch 8.2.3580: gj does not move properly with a wide character
Bram Moolenaar <Bram@vim.org>
parents:
26042
diff
changeset
|
2725 |
6178 | 2726 if (virtcol > curwin->w_curswant |
7 | 2727 && (curwin->w_curswant < (colnr_T)width1 |
2728 ? (curwin->w_curswant > (colnr_T)width1 / 2) | |
2729 : ((curwin->w_curswant - width1) % width2 | |
2730 > (colnr_T)width2 / 2))) | |
2731 --curwin->w_cursor.col; | |
2732 } | |
2733 | |
2734 if (atend) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2735 curwin->w_curswant = MAXCOL; // stick in the last column |
7 | 2736 |
2737 return retval; | |
2738 } | |
2739 | |
2740 /* | |
2741 * Handle CTRL-E and CTRL-Y commands: scroll a line up or down. | |
2742 * cap->arg must be TRUE for CTRL-E. | |
2743 */ | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18128
diff
changeset
|
2744 void |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2745 nv_scroll_line(cmdarg_T *cap) |
7 | 2746 { |
2747 if (!checkclearop(cap->oap)) | |
2748 scroll_redraw(cap->arg, cap->count1); | |
2749 } | |
2750 | |
2751 /* | |
2752 * Scroll "count" lines up or down, and redraw. | |
2753 */ | |
2754 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2755 scroll_redraw(int up, long count) |
7 | 2756 { |
2757 linenr_T prev_topline = curwin->w_topline; | |
2758 #ifdef FEAT_DIFF | |
2759 int prev_topfill = curwin->w_topfill; | |
2760 #endif | |
2761 linenr_T prev_lnum = curwin->w_cursor.lnum; | |
2762 | |
2763 if (up) | |
2764 scrollup(count, TRUE); | |
2765 else | |
2766 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
|
2767 if (get_scrolloff_value()) |
7 | 2768 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2769 // 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
|
2770 // valid, otherwise the screen jumps back at the end of the file. |
7 | 2771 cursor_correct(); |
2772 check_cursor_moved(curwin); | |
2773 curwin->w_valid |= VALID_TOPLINE; | |
2774 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2775 // 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
|
2776 // 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
|
2777 // first line of the buffer is already on the screen |
7 | 2778 while (curwin->w_topline == prev_topline |
2779 #ifdef FEAT_DIFF | |
2780 && curwin->w_topfill == prev_topfill | |
2781 #endif | |
2782 ) | |
2783 { | |
2784 if (up) | |
2785 { | |
2786 if (curwin->w_cursor.lnum > prev_lnum | |
2787 || cursor_down(1L, FALSE) == FAIL) | |
2788 break; | |
2789 } | |
2790 else | |
2791 { | |
2792 if (curwin->w_cursor.lnum < prev_lnum | |
2793 || prev_topline == 1L | |
2794 || cursor_up(1L, FALSE) == FAIL) | |
2795 break; | |
2796 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2797 // 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
|
2798 // end of the file. |
7 | 2799 check_cursor_moved(curwin); |
2800 curwin->w_valid |= VALID_TOPLINE; | |
2801 } | |
2802 } | |
2803 if (curwin->w_cursor.lnum != prev_lnum) | |
2804 coladvance(curwin->w_curswant); | |
2805 redraw_later(VALID); | |
2806 } | |
2807 | |
2808 /* | |
2809 * Commands that start with "z". | |
2810 */ | |
2811 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2812 nv_zet(cmdarg_T *cap) |
7 | 2813 { |
2814 long n; | |
2815 colnr_T col; | |
2816 int nchar = cap->nchar; | |
2817 #ifdef FEAT_FOLDING | |
2818 long old_fdl = curwin->w_p_fdl; | |
2819 int old_fen = curwin->w_p_fen; | |
2820 #endif | |
737 | 2821 #ifdef FEAT_SPELL |
710 | 2822 int undo = FALSE; |
2823 #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
|
2824 long siso = get_sidescrolloff_value(); |
7 | 2825 |
2826 if (VIM_ISDIGIT(nchar)) | |
2827 { | |
2828 /* | |
2829 * "z123{nchar}": edit the count before obtaining {nchar} | |
2830 */ | |
2831 if (checkclearop(cap->oap)) | |
2832 return; | |
2833 n = nchar - '0'; | |
2834 for (;;) | |
2835 { | |
2836 #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
|
2837 dont_scroll = TRUE; // disallow scrolling here |
7 | 2838 #endif |
2839 ++no_mapping; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2840 ++allow_keys; // no mapping for nchar, but allow key codes |
1389 | 2841 nchar = plain_vgetc(); |
7 | 2842 LANGMAP_ADJUST(nchar, TRUE); |
2843 --no_mapping; | |
2844 --allow_keys; | |
2845 #ifdef FEAT_CMDL_INFO | |
2846 (void)add_to_showcmd(nchar); | |
2847 #endif | |
2848 if (nchar == K_DEL || nchar == K_KDEL) | |
2849 n /= 10; | |
2850 else if (VIM_ISDIGIT(nchar)) | |
2851 n = n * 10 + (nchar - '0'); | |
2852 else if (nchar == CAR) | |
2853 { | |
2854 #ifdef FEAT_GUI | |
2855 need_mouse_correct = TRUE; | |
2856 #endif | |
2857 win_setheight((int)n); | |
2858 break; | |
2859 } | |
2860 else if (nchar == 'l' | |
2861 || nchar == 'h' | |
2862 || nchar == K_LEFT | |
229 | 2863 || nchar == K_RIGHT) |
7 | 2864 { |
2865 cap->count1 = n ? n * cap->count1 : cap->count1; | |
2866 goto dozet; | |
2867 } | |
2868 else | |
2869 { | |
2870 clearopbeep(cap->oap); | |
2871 break; | |
2872 } | |
2873 } | |
2874 cap->oap->op_type = OP_NOP; | |
2875 return; | |
2876 } | |
2877 | |
2878 dozet: | |
2879 if ( | |
2880 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2881 // "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
|
2882 // 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
|
2883 // commands. |
7 | 2884 cap->nchar != 'f' && cap->nchar != 'F' |
2885 && !(VIsual_active && vim_strchr((char_u *)"dcCoO", cap->nchar)) | |
2886 && cap->nchar != 'j' && cap->nchar != 'k' | |
2887 && | |
2888 #endif | |
2889 checkclearop(cap->oap)) | |
2890 return; | |
2891 | |
2892 /* | |
2893 * For "z+", "z<CR>", "zt", "z.", "zz", "z^", "z-", "zb": | |
2894 * If line number given, set cursor. | |
2895 */ | |
2896 if ((vim_strchr((char_u *)"+\r\nt.z^-b", nchar) != NULL) | |
2897 && cap->count0 | |
2898 && cap->count0 != curwin->w_cursor.lnum) | |
2899 { | |
2900 setpcmark(); | |
2901 if (cap->count0 > curbuf->b_ml.ml_line_count) | |
2902 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2903 else | |
2904 curwin->w_cursor.lnum = cap->count0; | |
22 | 2905 check_cursor_col(); |
7 | 2906 } |
2907 | |
2908 switch (nchar) | |
2909 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2910 // "z+", "z<CR>" and "zt": put cursor at top of screen |
7 | 2911 case '+': |
2912 if (cap->count0 == 0) | |
2913 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2914 // 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
|
2915 validate_botline(); // make sure w_botline is valid |
7 | 2916 if (curwin->w_botline > curbuf->b_ml.ml_line_count) |
2917 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
2918 else | |
2919 curwin->w_cursor.lnum = curwin->w_botline; | |
2920 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2921 // FALLTHROUGH |
7 | 2922 case NL: |
2923 case CAR: | |
2924 case K_KENTER: | |
2925 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
|
2926 // FALLTHROUGH |
7 | 2927 |
2928 case 't': scroll_cursor_top(0, TRUE); | |
2929 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2930 set_fraction(curwin); |
7 | 2931 break; |
2932 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2933 // "z." and "zz": put cursor in middle of screen |
7 | 2934 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
|
2935 // FALLTHROUGH |
7 | 2936 |
2937 case 'z': scroll_cursor_halfway(TRUE); | |
2938 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2939 set_fraction(curwin); |
7 | 2940 break; |
2941 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2942 // "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
|
2943 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
|
2944 // 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
|
2945 // bottom of window. |
7 | 2946 if (cap->count0 != 0) |
2947 { | |
2948 scroll_cursor_bot(0, TRUE); | |
2949 curwin->w_cursor.lnum = curwin->w_topline; | |
2950 } | |
2951 else if (curwin->w_topline == 1) | |
2952 curwin->w_cursor.lnum = 1; | |
2953 else | |
2954 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
|
2955 // FALLTHROUGH |
7 | 2956 case '-': |
2957 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
|
2958 // FALLTHROUGH |
7 | 2959 |
2960 case 'b': scroll_cursor_bot(0, TRUE); | |
2961 redraw_later(VALID); | |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7241
diff
changeset
|
2962 set_fraction(curwin); |
7 | 2963 break; |
2964 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2965 // "zH" - scroll screen right half-page |
7 | 2966 case 'H': |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
2967 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
|
2968 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2969 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2970 // "zh" - scroll screen to the right |
7 | 2971 case 'h': |
2972 case K_LEFT: | |
2973 if (!curwin->w_p_wrap) | |
2974 { | |
2975 if ((colnr_T)cap->count1 > curwin->w_leftcol) | |
2976 curwin->w_leftcol = 0; | |
2977 else | |
2978 curwin->w_leftcol -= (colnr_T)cap->count1; | |
2979 leftcol_changed(); | |
2980 } | |
2981 break; | |
2982 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2983 // "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
|
2984 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
|
2985 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2986 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2987 // "zl" - scroll screen to the left |
7 | 2988 case 'l': |
2989 case K_RIGHT: | |
2990 if (!curwin->w_p_wrap) | |
2991 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2992 // scroll the window left |
7 | 2993 curwin->w_leftcol += (colnr_T)cap->count1; |
2994 leftcol_changed(); | |
2995 } | |
2996 break; | |
2997 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
2998 // "zs" - scroll screen, cursor at the start |
7 | 2999 case 's': if (!curwin->w_p_wrap) |
3000 { | |
3001 #ifdef FEAT_FOLDING | |
3002 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
|
3003 col = 0; // like the cursor is in col 0 |
7 | 3004 else |
3005 #endif | |
3006 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
|
3007 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
|
3008 col -= siso; |
7 | 3009 else |
3010 col = 0; | |
3011 if (curwin->w_leftcol != col) | |
3012 { | |
3013 curwin->w_leftcol = col; | |
3014 redraw_later(NOT_VALID); | |
3015 } | |
3016 } | |
3017 break; | |
3018 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3019 // "ze" - scroll screen, cursor at the end |
7 | 3020 case 'e': if (!curwin->w_p_wrap) |
3021 { | |
3022 #ifdef FEAT_FOLDING | |
3023 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
|
3024 col = 0; // like the cursor is in col 0 |
7 | 3025 else |
3026 #endif | |
3027 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
|
3028 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
|
3029 if ((long)col + siso < n) |
7 | 3030 col = 0; |
3031 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
|
3032 col = col + siso - n + 1; |
7 | 3033 if (curwin->w_leftcol != col) |
3034 { | |
3035 curwin->w_leftcol = col; | |
3036 redraw_later(NOT_VALID); | |
3037 } | |
3038 } | |
3039 break; | |
3040 | |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
3041 // "zp", "zP" in block mode put without addind trailing spaces |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
3042 case 'P': |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
3043 case 'p': nv_put(cap); |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
3044 break; |
24866
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24800
diff
changeset
|
3045 // "zy" Yank without trailing spaces |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24800
diff
changeset
|
3046 case 'y': nv_operator(cap); |
f1121eb17e14
patch 8.2.2971: cannot yank a block without trailing spaces
Bram Moolenaar <Bram@vim.org>
parents:
24800
diff
changeset
|
3047 break; |
7 | 3048 #ifdef FEAT_FOLDING |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3049 // "zF": create fold command |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3050 // "zf": create fold operator |
7 | 3051 case 'F': |
3052 case 'f': if (foldManualAllowed(TRUE)) | |
3053 { | |
3054 cap->nchar = 'f'; | |
3055 nv_operator(cap); | |
3056 curwin->w_p_fen = TRUE; | |
3057 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3058 // "zF" is like "zfzf" |
7 | 3059 if (nchar == 'F' && cap->oap->op_type == OP_FOLD) |
3060 { | |
3061 nv_operator(cap); | |
3062 finish_op = TRUE; | |
3063 } | |
3064 } | |
3065 else | |
3066 clearopbeep(cap->oap); | |
3067 break; | |
3068 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3069 // "zd": delete fold at cursor |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3070 // "zD": delete fold at cursor recursively |
7 | 3071 case 'd': |
3072 case 'D': if (foldManualAllowed(FALSE)) | |
3073 { | |
3074 if (VIsual_active) | |
3075 nv_operator(cap); | |
3076 else | |
3077 deleteFold(curwin->w_cursor.lnum, | |
3078 curwin->w_cursor.lnum, nchar == 'D', FALSE); | |
3079 } | |
3080 break; | |
3081 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3082 // "zE": erase all folds |
7 | 3083 case 'E': if (foldmethodIsManual(curwin)) |
3084 { | |
3085 clearFolding(curwin); | |
3086 changed_window_setting(); | |
3087 } | |
3088 else if (foldmethodIsMarker(curwin)) | |
3089 deleteFold((linenr_T)1, curbuf->b_ml.ml_line_count, | |
3090 TRUE, FALSE); | |
3091 else | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26909
diff
changeset
|
3092 emsg(_(e_cannot_erase_folds_with_current_foldmethod)); |
7 | 3093 break; |
3094 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3095 // "zn": fold none: reset 'foldenable' |
7 | 3096 case 'n': curwin->w_p_fen = FALSE; |
3097 break; | |
3098 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3099 // "zN": fold Normal: set 'foldenable' |
7 | 3100 case 'N': curwin->w_p_fen = TRUE; |
3101 break; | |
3102 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3103 // "zi": invert folding: toggle 'foldenable' |
7 | 3104 case 'i': curwin->w_p_fen = !curwin->w_p_fen; |
3105 break; | |
3106 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3107 // "za": open closed fold or close open fold at cursor |
7 | 3108 case 'a': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
3109 openFold(curwin->w_cursor.lnum, cap->count1); | |
3110 else | |
3111 { | |
3112 closeFold(curwin->w_cursor.lnum, cap->count1); | |
3113 curwin->w_p_fen = TRUE; | |
3114 } | |
3115 break; | |
3116 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3117 // "zA": open fold at cursor recursively |
7 | 3118 case 'A': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) |
3119 openFoldRecurse(curwin->w_cursor.lnum); | |
3120 else | |
3121 { | |
3122 closeFoldRecurse(curwin->w_cursor.lnum); | |
3123 curwin->w_p_fen = TRUE; | |
3124 } | |
3125 break; | |
3126 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3127 // "zo": open fold at cursor or Visual area |
7 | 3128 case 'o': if (VIsual_active) |
3129 nv_operator(cap); | |
3130 else | |
3131 openFold(curwin->w_cursor.lnum, cap->count1); | |
3132 break; | |
3133 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3134 // "zO": open fold recursively |
7 | 3135 case 'O': if (VIsual_active) |
3136 nv_operator(cap); | |
3137 else | |
3138 openFoldRecurse(curwin->w_cursor.lnum); | |
3139 break; | |
3140 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3141 // "zc": close fold at cursor or Visual area |
7 | 3142 case 'c': if (VIsual_active) |
3143 nv_operator(cap); | |
3144 else | |
3145 closeFold(curwin->w_cursor.lnum, cap->count1); | |
3146 curwin->w_p_fen = TRUE; | |
3147 break; | |
3148 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3149 // "zC": close fold recursively |
7 | 3150 case 'C': if (VIsual_active) |
3151 nv_operator(cap); | |
3152 else | |
3153 closeFoldRecurse(curwin->w_cursor.lnum); | |
3154 curwin->w_p_fen = TRUE; | |
3155 break; | |
3156 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3157 // "zv": open folds at the cursor |
7 | 3158 case 'v': foldOpenCursor(); |
3159 break; | |
3160 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3161 // "zx": re-apply 'foldlevel' and open folds at the cursor |
7 | 3162 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
|
3163 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
|
3164 newFoldLevel(); // update right now |
7 | 3165 foldOpenCursor(); |
3166 break; | |
3167 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3168 // "zX": undo manual opens/closes, re-apply 'foldlevel' |
7 | 3169 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
|
3170 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
|
3171 old_fdl = -1; // force an update |
7 | 3172 break; |
3173 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3174 // "zm": fold more |
7 | 3175 case 'm': if (curwin->w_p_fdl > 0) |
6725 | 3176 { |
3177 curwin->w_p_fdl -= cap->count1; | |
3178 if (curwin->w_p_fdl < 0) | |
3179 curwin->w_p_fdl = 0; | |
3180 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3181 old_fdl = -1; // force an update |
7 | 3182 curwin->w_p_fen = TRUE; |
3183 break; | |
3184 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3185 // "zM": close all folds |
7 | 3186 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
|
3187 old_fdl = -1; // force an update |
7 | 3188 curwin->w_p_fen = TRUE; |
3189 break; | |
3190 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3191 // "zr": reduce folding |
6725 | 3192 case 'r': curwin->w_p_fdl += cap->count1; |
3193 { | |
3194 int d = getDeepestNesting(); | |
3195 | |
3196 if (curwin->w_p_fdl >= d) | |
3197 curwin->w_p_fdl = d; | |
3198 } | |
7 | 3199 break; |
3200 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3201 // "zR": open all folds |
7 | 3202 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
|
3203 old_fdl = -1; // force an update |
7 | 3204 break; |
3205 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3206 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
|
3207 case 'k': // "zk" move to next fold upwards |
7 | 3208 if (foldMoveTo(TRUE, nchar == 'j' ? FORWARD : BACKWARD, |
3209 cap->count1) == FAIL) | |
3210 clearopbeep(cap->oap); | |
3211 break; | |
3212 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3213 #endif // FEAT_FOLDING |
7 | 3214 |
737 | 3215 #ifdef FEAT_SPELL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3216 case 'u': // "zug" and "zuw": undo "zg" and "zw" |
710 | 3217 ++no_mapping; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3218 ++allow_keys; // no mapping for nchar, but allow key codes |
1389 | 3219 nchar = plain_vgetc(); |
710 | 3220 LANGMAP_ADJUST(nchar, TRUE); |
3221 --no_mapping; | |
3222 --allow_keys; | |
3223 #ifdef FEAT_CMDL_INFO | |
3224 (void)add_to_showcmd(nchar); | |
3225 #endif | |
3226 if (vim_strchr((char_u *)"gGwW", nchar) == NULL) | |
3227 { | |
3228 clearopbeep(cap->oap); | |
3229 break; | |
3230 } | |
3231 undo = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3232 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3233 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3234 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
|
3235 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
|
3236 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
|
3237 case 'W': // "zW": add wrong word to temp word list |
310 | 3238 { |
3239 char_u *ptr = NULL; | |
3240 int len; | |
3241 | |
3242 if (checkclearop(cap->oap)) | |
3243 break; | |
3244 if (VIsual_active && get_visual_text(cap, &ptr, &len) | |
3245 == FAIL) | |
3246 return; | |
501 | 3247 if (ptr == NULL) |
3248 { | |
3249 pos_T pos = curwin->w_cursor; | |
3250 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3251 // 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
|
3252 // 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
|
3253 // used below. |
5374 | 3254 emsg_off++; |
534 | 3255 len = spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL); |
5374 | 3256 emsg_off--; |
501 | 3257 if (len != 0 && curwin->w_cursor.col <= pos.col) |
3258 ptr = ml_get_pos(&curwin->w_cursor); | |
3259 curwin->w_cursor = pos; | |
3260 } | |
3261 | |
310 | 3262 if (ptr == NULL && (len = find_ident_under_cursor(&ptr, |
3263 FIND_IDENT)) == 0) | |
3264 return; | |
17682
3dbff5d37520
patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3265 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
|
3266 ? SPELL_ADD_BAD : SPELL_ADD_GOOD, |
710 | 3267 (nchar == 'G' || nchar == 'W') |
3268 ? 0 : (int)cap->count1, | |
3269 undo); | |
310 | 3270 } |
316 | 3271 break; |
323 | 3272 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3273 case '=': // "z=": suggestions for a badly spelled word |
638 | 3274 if (!checkclearop(cap->oap)) |
485 | 3275 spell_suggest((int)cap->count0); |
323 | 3276 break; |
310 | 3277 #endif |
3278 | |
7 | 3279 default: clearopbeep(cap->oap); |
3280 } | |
3281 | |
3282 #ifdef FEAT_FOLDING | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3283 // Redraw when 'foldenable' changed |
7 | 3284 if (old_fen != curwin->w_p_fen) |
3285 { | |
3286 # ifdef FEAT_DIFF | |
3287 win_T *wp; | |
3288 | |
3289 if (foldmethodIsDiff(curwin) && curwin->w_p_scb) | |
3290 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3291 // Adjust 'foldenable' in diff-synced windows. |
7 | 3292 FOR_ALL_WINDOWS(wp) |
3293 { | |
3294 if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) | |
3295 { | |
3296 wp->w_p_fen = curwin->w_p_fen; | |
3297 changed_window_setting_win(wp); | |
3298 } | |
3299 } | |
3300 } | |
3301 # endif | |
3302 changed_window_setting(); | |
3303 } | |
3304 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3305 // Redraw when 'foldlevel' changed. |
7 | 3306 if (old_fdl != curwin->w_p_fdl) |
3307 newFoldLevel(); | |
3308 #endif | |
3309 } | |
3310 | |
3311 #ifdef FEAT_GUI | |
3312 /* | |
3313 * Vertical scrollbar movement. | |
3314 */ | |
3315 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3316 nv_ver_scrollbar(cmdarg_T *cap) |
7 | 3317 { |
3318 if (cap->oap->op_type != OP_NOP) | |
3319 clearopbeep(cap->oap); | |
3320 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3321 // Even if an operator was pending, we still want to scroll |
7 | 3322 gui_do_scroll(); |
3323 } | |
3324 | |
3325 /* | |
3326 * Horizontal scrollbar movement. | |
3327 */ | |
3328 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3329 nv_hor_scrollbar(cmdarg_T *cap) |
7 | 3330 { |
3331 if (cap->oap->op_type != OP_NOP) | |
3332 clearopbeep(cap->oap); | |
3333 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3334 // 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
|
3335 gui_do_horiz_scroll(scrollbar_value, FALSE); |
7 | 3336 } |
3337 #endif | |
3338 | |
690 | 3339 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
685 | 3340 /* |
3341 * Click in GUI tab. | |
3342 */ | |
3343 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3344 nv_tabline(cmdarg_T *cap) |
685 | 3345 { |
3346 if (cap->oap->op_type != OP_NOP) | |
3347 clearopbeep(cap->oap); | |
3348 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3349 // Even if an operator was pending, we still want to jump tabs. |
685 | 3350 goto_tabpage(current_tab); |
3351 } | |
686 | 3352 |
3353 /* | |
3354 * Selected item in tab line menu. | |
3355 */ | |
3356 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3357 nv_tabmenu(cmdarg_T *cap) |
686 | 3358 { |
3359 if (cap->oap->op_type != OP_NOP) | |
3360 clearopbeep(cap->oap); | |
3361 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3362 // Even if an operator was pending, we still want to jump tabs. |
690 | 3363 handle_tabmenu(); |
3364 } | |
3365 | |
3366 /* | |
3367 * Handle selecting an item of the GUI tab line menu. | |
3368 * Used in Normal and Insert mode. | |
3369 */ | |
3370 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3371 handle_tabmenu(void) |
690 | 3372 { |
686 | 3373 switch (current_tabmenu) |
3374 { | |
3375 case TABLINE_MENU_CLOSE: | |
3376 if (current_tab == 0) | |
3377 do_cmdline_cmd((char_u *)"tabclose"); | |
3378 else | |
3379 { | |
3380 vim_snprintf((char *)IObuff, IOSIZE, "tabclose %d", | |
3381 current_tab); | |
3382 do_cmdline_cmd(IObuff); | |
3383 } | |
3384 break; | |
3385 | |
3386 case TABLINE_MENU_NEW: | |
6631 | 3387 if (current_tab == 0) |
3388 do_cmdline_cmd((char_u *)"$tabnew"); | |
3389 else | |
3390 { | |
3391 vim_snprintf((char *)IObuff, IOSIZE, "%dtabnew", | |
3392 current_tab - 1); | |
3393 do_cmdline_cmd(IObuff); | |
3394 } | |
686 | 3395 break; |
3396 | |
3397 case TABLINE_MENU_OPEN: | |
6631 | 3398 if (current_tab == 0) |
3399 do_cmdline_cmd((char_u *)"browse $tabnew"); | |
3400 else | |
3401 { | |
3402 vim_snprintf((char *)IObuff, IOSIZE, "browse %dtabnew", | |
3403 current_tab - 1); | |
3404 do_cmdline_cmd(IObuff); | |
3405 } | |
686 | 3406 break; |
3407 } | |
3408 } | |
685 | 3409 #endif |
3410 | |
7 | 3411 /* |
3412 * "Q" command. | |
3413 */ | |
3414 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3415 nv_exmode(cmdarg_T *cap) |
7 | 3416 { |
3417 /* | |
3418 * Ignore 'Q' in Visual mode, just give a beep. | |
3419 */ | |
3420 if (VIsual_active) | |
6949 | 3421 vim_beep(BO_EX); |
5735 | 3422 else if (!checkclearop(cap->oap)) |
7 | 3423 do_exmode(FALSE); |
3424 } | |
3425 | |
3426 /* | |
3427 * Handle a ":" command. | |
3428 */ | |
3429 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3430 nv_colon(cmdarg_T *cap) |
7 | 3431 { |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3432 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
|
3433 int cmd_result; |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3434 int is_cmdkey = cap->cmdchar == K_COMMAND |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3435 || cap->cmdchar == K_SCRIPT_COMMAND; |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3436 int flags; |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3437 |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3438 if (VIsual_active && !is_cmdkey) |
7 | 3439 nv_operator(cap); |
3440 else | |
3441 { | |
3442 if (cap->oap->op_type != OP_NOP) | |
3443 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3444 // Using ":" as a movement is characterwise exclusive. |
7 | 3445 cap->oap->motion_type = MCHAR; |
3446 cap->oap->inclusive = FALSE; | |
3447 } | |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3448 else if (cap->count0 && !is_cmdkey) |
7 | 3449 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3450 // translate "count:" into ":.,.+(count - 1)" |
7 | 3451 stuffcharReadbuff('.'); |
3452 if (cap->count0 > 1) | |
3453 { | |
3454 stuffReadbuff((char_u *)",.+"); | |
3455 stuffnumReadbuff((long)cap->count0 - 1L); | |
3456 } | |
3457 } | |
3458 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3459 // When typing, don't type below an old message |
7 | 3460 if (KeyTyped) |
3461 compute_cmdrow(); | |
3462 | |
3463 old_p_im = p_im; | |
3464 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3465 // get a command line and execute it |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3466 flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0; |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3467 if (is_cmdkey) |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3468 cmd_result = do_cmdkey_command(cap->cmdchar, flags); |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3469 else |
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
3470 cmd_result = do_cmdline(NULL, getexline, NULL, flags); |
7 | 3471 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3472 // If 'insertmode' changed, enter or exit Insert mode |
7 | 3473 if (p_im != old_p_im) |
3474 { | |
3475 if (p_im) | |
3476 restart_edit = 'i'; | |
3477 else | |
3478 restart_edit = 0; | |
3479 } | |
3480 | |
4256 | 3481 if (cmd_result == FAIL) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3482 // The Ex command failed, do not execute the operator. |
4256 | 3483 clearop(cap->oap); |
3484 else if (cap->oap->op_type != OP_NOP | |
7 | 3485 && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count |
3486 || cap->oap->start.col > | |
4256 | 3487 (colnr_T)STRLEN(ml_get(cap->oap->start.lnum)) |
3488 || did_emsg | |
3489 )) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3490 // The start of the operator has become invalid by the Ex command. |
7 | 3491 clearopbeep(cap->oap); |
3492 } | |
3493 } | |
3494 | |
3495 /* | |
3496 * Handle CTRL-G command. | |
3497 */ | |
3498 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3499 nv_ctrlg(cmdarg_T *cap) |
7 | 3500 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3501 if (VIsual_active) // toggle Selection/Visual mode |
7 | 3502 { |
3503 VIsual_select = !VIsual_select; | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
3504 trigger_modechanged(); |
7 | 3505 showmode(); |
3506 } | |
5735 | 3507 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
|
3508 // print full name if count given or :cd used |
7 | 3509 fileinfo((int)cap->count0, FALSE, TRUE); |
3510 } | |
3511 | |
3512 /* | |
3513 * Handle CTRL-H <Backspace> command. | |
3514 */ | |
3515 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3516 nv_ctrlh(cmdarg_T *cap) |
7 | 3517 { |
3518 if (VIsual_active && VIsual_select) | |
3519 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3520 cap->cmdchar = 'x'; // BS key behaves like 'x' in Select mode |
7 | 3521 v_visop(cap); |
3522 } | |
3523 else | |
3524 nv_left(cap); | |
3525 } | |
3526 | |
3527 /* | |
3528 * CTRL-L: clear screen and redraw. | |
3529 */ | |
3530 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3531 nv_clear(cmdarg_T *cap) |
7 | 3532 { |
3533 if (!checkclearop(cap->oap)) | |
3534 { | |
3535 #ifdef FEAT_SYN_HL | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3536 // 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
|
3537 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
|
3538 # ifdef FEAT_RELTIME |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3539 { |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3540 win_T *wp; |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3541 |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3542 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
|
3543 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
|
3544 } |
998d2cf59caa
patch 8.0.0647: syntax highlighting can make cause a freeze
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
3545 # endif |
7 | 3546 #endif |
3547 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
|
3548 #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
|
3549 # 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
|
3550 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
|
3551 # 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
|
3552 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
|
3553 #endif |
7 | 3554 } |
3555 } | |
3556 | |
3557 /* | |
3558 * CTRL-O: In Select mode: switch to Visual mode for one command. | |
3559 * Otherwise: Go to older pcmark. | |
3560 */ | |
3561 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3562 nv_ctrlo(cmdarg_T *cap) |
7 | 3563 { |
3564 if (VIsual_active && VIsual_select) | |
3565 { | |
3566 VIsual_select = FALSE; | |
26042
6b39ab99e367
patch 8.2.3555: ModeChanged is not triggered on every mode change
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
3567 trigger_modechanged(); |
7 | 3568 showmode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3569 restart_VIsual_select = 2; // restart Select mode later |
7 | 3570 } |
3571 else | |
3572 { | |
3573 cap->count1 = -cap->count1; | |
3574 nv_pcmark(cap); | |
3575 } | |
3576 } | |
3577 | |
3578 /* | |
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
|
3579 * 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
|
3580 * not named. |
7 | 3581 */ |
3582 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3583 nv_hat(cmdarg_T *cap) |
7 | 3584 { |
3585 if (!checkclearopq(cap->oap)) | |
3586 (void)buflist_getfile((int)cap->count0, (linenr_T)0, | |
3587 GETF_SETMARK|GETF_ALT, FALSE); | |
3588 } | |
3589 | |
3590 /* | |
3591 * "Z" commands. | |
3592 */ | |
3593 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3594 nv_Zet(cmdarg_T *cap) |
7 | 3595 { |
3596 if (!checkclearopq(cap->oap)) | |
3597 { | |
3598 switch (cap->nchar) | |
3599 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3600 // "ZZ": equivalent to ":x". |
7 | 3601 case 'Z': do_cmdline_cmd((char_u *)"x"); |
3602 break; | |
3603 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3604 // "ZQ": equivalent to ":q!" (Elvis compatible). |
7 | 3605 case 'Q': do_cmdline_cmd((char_u *)"q!"); |
3606 break; | |
3607 | |
3608 default: clearopbeep(cap->oap); | |
3609 } | |
3610 } | |
3611 } | |
3612 | |
3613 /* | |
3614 * Call nv_ident() as if "c1" was used, with "c2" as next character. | |
3615 */ | |
3616 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3617 do_nv_ident(int c1, int c2) |
7 | 3618 { |
3619 oparg_T oa; | |
3620 cmdarg_T ca; | |
3621 | |
3622 clear_oparg(&oa); | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
3623 CLEAR_FIELD(ca); |
7 | 3624 ca.oap = &oa; |
3625 ca.cmdchar = c1; | |
3626 ca.nchar = c2; | |
3627 nv_ident(&ca); | |
3628 } | |
3629 | |
3630 /* | |
3631 * Handle the commands that use the word under the cursor. | |
3632 * [g] CTRL-] :ta to current identifier | |
3633 * [g] 'K' run program for current identifier | |
3634 * [g] '*' / to current identifier or string | |
3635 * [g] '#' ? to current identifier or string | |
3636 * g ']' :tselect for current identifier | |
3637 */ | |
3638 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3639 nv_ident(cmdarg_T *cap) |
7 | 3640 { |
3641 char_u *ptr = NULL; | |
3642 char_u *buf; | |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3643 unsigned buflen; |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3644 char_u *newbuf; |
7 | 3645 char_u *p; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3646 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
|
3647 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
|
3648 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
|
3649 int n = 0; // init for GCC |
7 | 3650 int cmdchar; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3651 int g_cmd; // "g" command |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3652 int tag_cmd = FALSE; |
7 | 3653 char_u *aux_ptr; |
3654 int isman; | |
3655 int isman_s; | |
3656 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3657 if (cap->cmdchar == 'g') // "g*", "g#", "g]" and "gCTRL-]" |
7 | 3658 { |
3659 cmdchar = cap->nchar; | |
3660 g_cmd = TRUE; | |
3661 } | |
3662 else | |
3663 { | |
3664 cmdchar = cap->cmdchar; | |
3665 g_cmd = FALSE; | |
3666 } | |
3667 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3668 if (cmdchar == POUND) // the pound sign, '#' for English keyboards |
7 | 3669 cmdchar = '#'; |
3670 | |
3671 /* | |
3672 * The "]", "CTRL-]" and "K" commands accept an argument in Visual mode. | |
3673 */ | |
3674 if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K') | |
3675 { | |
3676 if (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL) | |
3677 return; | |
3678 if (checkclearopq(cap->oap)) | |
3679 return; | |
3680 } | |
3681 | |
3682 if (ptr == NULL && (n = find_ident_under_cursor(&ptr, | |
3683 (cmdchar == '*' || cmdchar == '#') | |
3684 ? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0) | |
3685 { | |
3686 clearop(cap->oap); | |
3687 return; | |
3688 } | |
3689 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3690 // 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
|
3691 // 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
|
3692 // and some numbers. |
7 | 3693 kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp); |
3694 kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 | |
3695 || 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
|
3696 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
|
3697 { |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
3698 emsg(_(e_no_identifier_under_cursor)); // found white space only |
12236
55cf556d8ce1
patch 8.0.0998: strange error when using K while only spaces are selected
Christian Brabandt <cb@256bit.org>
parents:
12164
diff
changeset
|
3699 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
|
3700 } |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3701 kp_ex = (*kp == ':'); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3702 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
|
3703 buf = alloc(buflen); |
7 | 3704 if (buf == NULL) |
3705 return; | |
3706 buf[0] = NUL; | |
3707 | |
3708 switch (cmdchar) | |
3709 { | |
3710 case '*': | |
3711 case '#': | |
3712 /* | |
3713 * Put cursor at start of word, makes search skip the word | |
3714 * under the cursor. | |
3715 * Call setpcmark() first, so "*``" puts the cursor back where | |
3716 * it was. | |
3717 */ | |
3718 setpcmark(); | |
3719 curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline()); | |
3720 | |
3721 if (!g_cmd && vim_iswordp(ptr)) | |
3722 STRCPY(buf, "\\<"); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3723 no_smartcase = TRUE; // don't use 'smartcase' now |
7 | 3724 break; |
3725 | |
3726 case 'K': | |
3727 if (kp_help) | |
3728 STRCPY(buf, "he! "); | |
9098
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3729 else if (kp_ex) |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3730 { |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3731 if (cap->count0 != 0) |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3732 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
|
3733 kp, cap->count0); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3734 else |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3735 STRCPY(buf, kp); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3736 STRCAT(buf, " "); |
0d52ddff8db4
commit https://github.com/vim/vim/commit/2ff8b64679242e73248774a388d54931c9ce49bd
Christian Brabandt <cb@256bit.org>
parents:
8923
diff
changeset
|
3737 } |
7 | 3738 else |
3739 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3740 // 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
|
3741 // with "-" as an option. To avoid trouble we skip the "-". |
1728 | 3742 while (*ptr == '-' && n > 0) |
3743 { | |
1712 | 3744 ++ptr; |
1728 | 3745 --n; |
3746 } | |
3747 if (n == 0) | |
3748 { | |
26909
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
3749 // found dashes only |
aa65d1808bd0
patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
3750 emsg(_(e_no_identifier_under_cursor)); |
1728 | 3751 vim_free(buf); |
3752 return; | |
3753 } | |
1712 | 3754 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3755 // 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
|
3756 // really what we want? |
7 | 3757 isman = (STRCMP(kp, "man") == 0); |
3758 isman_s = (STRCMP(kp, "man -s") == 0); | |
3759 if (cap->count0 != 0 && !(isman || isman_s)) | |
3760 sprintf((char *)buf, ".,.+%ld", cap->count0 - 1); | |
3761 | |
3762 STRCAT(buf, "! "); | |
3763 if (cap->count0 == 0 && isman_s) | |
3764 STRCAT(buf, "man"); | |
3765 else | |
3766 STRCAT(buf, kp); | |
3767 STRCAT(buf, " "); | |
3768 if (cap->count0 != 0 && (isman || isman_s)) | |
3769 { | |
3770 sprintf((char *)buf + STRLEN(buf), "%ld", cap->count0); | |
3771 STRCAT(buf, " "); | |
3772 } | |
3773 } | |
3774 break; | |
3775 | |
3776 case ']': | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3777 tag_cmd = TRUE; |
7 | 3778 #ifdef FEAT_CSCOPE |
3779 if (p_cst) | |
3780 STRCPY(buf, "cstag "); | |
3781 else | |
3782 #endif | |
3783 STRCPY(buf, "ts "); | |
3784 break; | |
3785 | |
3786 default: | |
2112
6b5d641bcdd4
updated for version 7.2.395
Bram Moolenaar <bram@zimbu.org>
parents:
2049
diff
changeset
|
3787 tag_cmd = TRUE; |
7 | 3788 if (curbuf->b_help) |
3789 STRCPY(buf, "he! "); | |
3790 else | |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3791 { |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3792 if (g_cmd) |
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3793 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
|
3794 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
|
3795 STRCPY(buf, "ta "); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3796 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
|
3797 sprintf((char *)buf, ":%ldta ", cap->count0); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3798 } |
7 | 3799 } |
3800 | |
3801 /* | |
3802 * Now grab the chars in the identifier | |
3803 */ | |
1712 | 3804 if (cmdchar == 'K' && !kp_help) |
3805 { | |
1728 | 3806 ptr = vim_strnsave(ptr, n); |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3807 if (kp_ex) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3808 // Escape the argument properly for an Ex command |
25994
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25921
diff
changeset
|
3809 p = vim_strsave_fnameescape(ptr, VSE_NONE); |
10330
71ca6a16e818
commit https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
Christian Brabandt <cb@256bit.org>
parents:
10251
diff
changeset
|
3810 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3811 // 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
|
3812 p = vim_strsave_shellescape(ptr, TRUE, TRUE); |
1728 | 3813 vim_free(ptr); |
1712 | 3814 if (p == NULL) |
3815 { | |
3816 vim_free(buf); | |
3817 return; | |
3818 } | |
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
|
3819 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
|
3820 if (newbuf == NULL) |
1712 | 3821 { |
3822 vim_free(buf); | |
3823 vim_free(p); | |
3824 return; | |
3825 } | |
2290
22529abcd646
Fixed ":s" message. Docs updates.
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
3826 buf = newbuf; |
1712 | 3827 STRCAT(buf, p); |
3828 vim_free(p); | |
3829 } | |
7 | 3830 else |
1712 | 3831 { |
3832 if (cmdchar == '*') | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
3833 aux_ptr = (char_u *)(magic_isset() ? "/.*~[^$\\" : "/^$\\"); |
1712 | 3834 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
|
3835 aux_ptr = (char_u *)(magic_isset() ? "/?.*~[^$\\" : "/?^$\\"); |
2049
23d366df1938
updated for version 7.2.335
Bram Moolenaar <bram@zimbu.org>
parents:
2040
diff
changeset
|
3836 else if (tag_cmd) |
2603 | 3837 { |
3838 if (curbuf->b_help) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3839 // ":help" handles unescaped argument |
2603 | 3840 aux_ptr = (char_u *)""; |
3841 else | |
3842 aux_ptr = (char_u *)"\\|\"\n["; | |
3843 } | |
1712 | 3844 else |
3845 aux_ptr = (char_u *)"\\|\"\n*?["; | |
3846 | |
3847 p = buf + STRLEN(buf); | |
3848 while (n-- > 0) | |
3849 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3850 // put a backslash before \ and some others |
1712 | 3851 if (vim_strchr(aux_ptr, *ptr) != NULL) |
3852 *p++ = '\\'; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3853 // 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
|
3854 // bytes of that character. |
1712 | 3855 if (has_mbyte) |
3856 { | |
3857 int i; | |
3858 int len = (*mb_ptr2len)(ptr) - 1; | |
3859 | |
3860 for (i = 0; i < len && n >= 1; ++i, --n) | |
3861 *p++ = *ptr++; | |
3862 } | |
3863 *p++ = *ptr++; | |
3864 } | |
3865 *p = NUL; | |
3866 } | |
7 | 3867 |
3868 /* | |
3869 * Execute the command. | |
3870 */ | |
3871 if (cmdchar == '*' || cmdchar == '#') | |
3872 { | |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3873 if (!g_cmd && (has_mbyte |
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
3874 ? 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
|
3875 : vim_iswordc(ptr[-1]))) |
7 | 3876 STRCAT(buf, "\\>"); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3877 |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17520
diff
changeset
|
3878 // put pattern in search history |
2024 | 3879 init_history(); |
7 | 3880 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
|
3881 |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
3882 (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL); |
7 | 3883 } |
3884 else | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3885 { |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
3886 g_tag_at_cursor = TRUE; |
7 | 3887 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
|
3888 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
|
3889 } |
7 | 3890 |
3891 vim_free(buf); | |
3892 } | |
3893 | |
3894 /* | |
3895 * Get visually selected text, within one line only. | |
3896 * Returns FAIL if more than one line selected. | |
3897 */ | |
344 | 3898 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3899 get_visual_text( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3900 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3901 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
|
3902 int *lenp) // return: length of selected text |
7 | 3903 { |
3904 if (VIsual_mode != 'V') | |
3905 unadjust_for_sel(); | |
3906 if (VIsual.lnum != curwin->w_cursor.lnum) | |
3907 { | |
344 | 3908 if (cap != NULL) |
3909 clearopbeep(cap->oap); | |
7 | 3910 return FAIL; |
3911 } | |
3912 if (VIsual_mode == 'V') | |
3913 { | |
3914 *pp = ml_get_curline(); | |
3915 *lenp = (int)STRLEN(*pp); | |
3916 } | |
3917 else | |
3918 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
3919 if (LT_POS(curwin->w_cursor, VIsual)) |
7 | 3920 { |
3921 *pp = ml_get_pos(&curwin->w_cursor); | |
3922 *lenp = VIsual.col - curwin->w_cursor.col + 1; | |
3923 } | |
3924 else | |
3925 { | |
3926 *pp = ml_get_pos(&VIsual); | |
3927 *lenp = curwin->w_cursor.col - VIsual.col + 1; | |
3928 } | |
26159
34606aec52b3
patch 8.2.3611: crash when using CTRL-W f without finding a file name
Bram Moolenaar <Bram@vim.org>
parents:
26157
diff
changeset
|
3929 if (**pp == NUL) |
34606aec52b3
patch 8.2.3611: crash when using CTRL-W f without finding a file name
Bram Moolenaar <Bram@vim.org>
parents:
26157
diff
changeset
|
3930 *lenp = 0; |
34606aec52b3
patch 8.2.3611: crash when using CTRL-W f without finding a file name
Bram Moolenaar <Bram@vim.org>
parents:
26157
diff
changeset
|
3931 if (has_mbyte && *lenp > 0) |
34606aec52b3
patch 8.2.3611: crash when using CTRL-W f without finding a file name
Bram Moolenaar <Bram@vim.org>
parents:
26157
diff
changeset
|
3932 // Correct the length to include all bytes of the last character. |
474 | 3933 *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1; |
7 | 3934 } |
3935 reset_VIsual_and_resel(); | |
3936 return OK; | |
3937 } | |
3938 | |
3939 /* | |
3940 * CTRL-T: backwards in tag stack | |
3941 */ | |
3942 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3943 nv_tagpop(cmdarg_T *cap) |
7 | 3944 { |
3945 if (!checkclearopq(cap->oap)) | |
3946 do_tag((char_u *)"", DT_POP, (int)cap->count1, FALSE, TRUE); | |
3947 } | |
3948 | |
3949 /* | |
3950 * Handle scrolling command 'H', 'L' and 'M'. | |
3951 */ | |
3952 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
3953 nv_scroll(cmdarg_T *cap) |
7 | 3954 { |
3955 int used = 0; | |
3956 long n; | |
3957 #ifdef FEAT_FOLDING | |
3958 linenr_T lnum; | |
3959 #endif | |
3960 int half; | |
3961 | |
3962 cap->oap->motion_type = MLINE; | |
3963 setpcmark(); | |
3964 | |
3965 if (cap->cmdchar == 'L') | |
3966 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3967 validate_botline(); // make sure curwin->w_botline is valid |
7 | 3968 curwin->w_cursor.lnum = curwin->w_botline - 1; |
3969 if (cap->count1 - 1 >= curwin->w_cursor.lnum) | |
3970 curwin->w_cursor.lnum = 1; | |
3971 else | |
9 | 3972 { |
3973 #ifdef FEAT_FOLDING | |
3974 if (hasAnyFolding(curwin)) | |
3975 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3976 // Count a fold for one screen line. |
9 | 3977 for (n = cap->count1 - 1; n > 0 |
3978 && curwin->w_cursor.lnum > curwin->w_topline; --n) | |
3979 { | |
3980 (void)hasFolding(curwin->w_cursor.lnum, | |
3981 &curwin->w_cursor.lnum, NULL); | |
3982 --curwin->w_cursor.lnum; | |
3983 } | |
3984 } | |
3985 else | |
3986 #endif | |
3987 curwin->w_cursor.lnum -= cap->count1 - 1; | |
3988 } | |
7 | 3989 } |
3990 else | |
3991 { | |
3992 if (cap->cmdchar == 'M') | |
3993 { | |
3994 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3995 // Don't count filler lines above the window. |
7 | 3996 used -= diff_check_fill(curwin, curwin->w_topline) |
3997 - curwin->w_topfill; | |
3998 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
3999 validate_botline(); // make sure w_empty_rows is valid |
7 | 4000 half = (curwin->w_height - curwin->w_empty_rows + 1) / 2; |
4001 for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; ++n) | |
4002 { | |
4003 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4004 // 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
|
4005 // line" and half to be "above the next line". |
7 | 4006 if (n > 0 && used + diff_check_fill(curwin, curwin->w_topline |
4007 + n) / 2 >= half) | |
4008 { | |
4009 --n; | |
4010 break; | |
4011 } | |
4012 #endif | |
4013 used += plines(curwin->w_topline + n); | |
4014 if (used >= half) | |
4015 break; | |
4016 #ifdef FEAT_FOLDING | |
4017 if (hasFolding(curwin->w_topline + n, NULL, &lnum)) | |
4018 n = lnum - curwin->w_topline; | |
4019 #endif | |
4020 } | |
4021 if (n > 0 && used > curwin->w_height) | |
4022 --n; | |
4023 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4024 else // (cap->cmdchar == 'H') |
9 | 4025 { |
7 | 4026 n = cap->count1 - 1; |
9 | 4027 #ifdef FEAT_FOLDING |
4028 if (hasAnyFolding(curwin)) | |
4029 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4030 // Count a fold for one screen line. |
9 | 4031 lnum = curwin->w_topline; |
4032 while (n-- > 0 && lnum < curwin->w_botline - 1) | |
4033 { | |
7009 | 4034 (void)hasFolding(lnum, NULL, &lnum); |
9 | 4035 ++lnum; |
4036 } | |
4037 n = lnum - curwin->w_topline; | |
4038 } | |
4039 #endif | |
4040 } | |
7 | 4041 curwin->w_cursor.lnum = curwin->w_topline + n; |
4042 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
4043 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
4044 } | |
4045 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4046 // 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
|
4047 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
|
4048 cursor_correct(); |
7 | 4049 beginline(BL_SOL | BL_FIX); |
4050 } | |
4051 | |
4052 /* | |
4053 * Cursor right commands. | |
4054 */ | |
4055 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4056 nv_right(cmdarg_T *cap) |
7 | 4057 { |
4058 long n; | |
5735 | 4059 int past_line; |
7 | 4060 |
180 | 4061 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
4062 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4063 // <C-Right> and <S-Right> move a word or WORD right |
180 | 4064 if (mod_mask & MOD_MASK_CTRL) |
4065 cap->arg = TRUE; | |
4066 nv_wordcmd(cap); | |
4067 return; | |
4068 } | |
4069 | |
7 | 4070 cap->oap->motion_type = MCHAR; |
4071 cap->oap->inclusive = FALSE; | |
5735 | 4072 past_line = (VIsual_active && *p_sel != 'o'); |
4073 | |
7 | 4074 /* |
5735 | 4075 * In virtual edit mode, there's no such thing as "past_line", as lines |
4076 * are (theoretically) infinitely long. | |
7 | 4077 */ |
4078 if (virtual_active()) | |
5735 | 4079 past_line = 0; |
7 | 4080 |
4081 for (n = cap->count1; n > 0; --n) | |
4082 { | |
5735 | 4083 if ((!past_line && oneright() == FAIL) |
4084 || (past_line && *ml_get_cursor() == NUL) | |
1877 | 4085 ) |
7 | 4086 { |
4087 /* | |
714 | 4088 * <Space> wraps to next line if 'whichwrap' has 's'. |
4089 * 'l' wraps to next line if 'whichwrap' has 'l'. | |
4090 * CURS_RIGHT wraps to next line if 'whichwrap' has '>'. | |
7 | 4091 */ |
4092 if ( ((cap->cmdchar == ' ' | |
4093 && vim_strchr(p_ww, 's') != NULL) | |
4094 || (cap->cmdchar == 'l' | |
4095 && vim_strchr(p_ww, 'l') != NULL) | |
229 | 4096 || (cap->cmdchar == K_RIGHT |
7 | 4097 && vim_strchr(p_ww, '>') != NULL)) |
4098 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
4099 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4100 // 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
|
4101 // 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
|
4102 // included, move to next line after that |
714 | 4103 if ( cap->oap->op_type != OP_NOP |
7 | 4104 && !cap->oap->inclusive |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
4105 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 4106 cap->oap->inclusive = TRUE; |
4107 else | |
4108 { | |
4109 ++curwin->w_cursor.lnum; | |
4110 curwin->w_cursor.col = 0; | |
4111 curwin->w_cursor.coladd = 0; | |
4112 curwin->w_set_curswant = TRUE; | |
4113 cap->oap->inclusive = FALSE; | |
4114 } | |
4115 continue; | |
4116 } | |
4117 if (cap->oap->op_type == OP_NOP) | |
4118 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4119 // Only beep and flush if not moved at all |
7 | 4120 if (n == cap->count1) |
4121 beep_flush(); | |
4122 } | |
4123 else | |
4124 { | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
4125 if (!LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 4126 cap->oap->inclusive = TRUE; |
4127 } | |
4128 break; | |
4129 } | |
5735 | 4130 else if (past_line) |
7 | 4131 { |
4132 curwin->w_set_curswant = TRUE; | |
4133 if (virtual_active()) | |
4134 oneright(); | |
4135 else | |
5735 | 4136 { |
7 | 4137 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
|
4138 curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor()); |
7 | 4139 else |
4140 ++curwin->w_cursor.col; | |
4141 } | |
4142 } | |
4143 } | |
4144 #ifdef FEAT_FOLDING | |
4145 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
4146 && cap->oap->op_type == OP_NOP) | |
4147 foldOpenCursor(); | |
4148 #endif | |
4149 } | |
4150 | |
4151 /* | |
4152 * Cursor left commands. | |
4153 * | |
4154 * Returns TRUE when operator end should not be adjusted. | |
4155 */ | |
4156 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4157 nv_left(cmdarg_T *cap) |
7 | 4158 { |
4159 long n; | |
4160 | |
180 | 4161 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
4162 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4163 // <C-Left> and <S-Left> move a word or WORD left |
180 | 4164 if (mod_mask & MOD_MASK_CTRL) |
4165 cap->arg = 1; | |
4166 nv_bck_word(cap); | |
4167 return; | |
4168 } | |
4169 | |
7 | 4170 cap->oap->motion_type = MCHAR; |
4171 cap->oap->inclusive = FALSE; | |
4172 for (n = cap->count1; n > 0; --n) | |
4173 { | |
4174 if (oneleft() == FAIL) | |
4175 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4176 // <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
|
4177 // '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
|
4178 // CURS_LEFT wraps to previous line if 'whichwrap' has '<'. |
7 | 4179 if ( (((cap->cmdchar == K_BS |
4180 || cap->cmdchar == Ctrl_H) | |
4181 && vim_strchr(p_ww, 'b') != NULL) | |
4182 || (cap->cmdchar == 'h' | |
4183 && vim_strchr(p_ww, 'h') != NULL) | |
229 | 4184 || (cap->cmdchar == K_LEFT |
7 | 4185 && vim_strchr(p_ww, '<') != NULL)) |
4186 && curwin->w_cursor.lnum > 1) | |
4187 { | |
4188 --(curwin->w_cursor.lnum); | |
4189 coladvance((colnr_T)MAXCOL); | |
4190 curwin->w_set_curswant = TRUE; | |
4191 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4192 // 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
|
4193 // 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
|
4194 // 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
|
4195 // Don't adjust op_end now, otherwise it won't work. |
7 | 4196 if ( (cap->oap->op_type == OP_DELETE |
4197 || 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
|
4198 && !LINEEMPTY(curwin->w_cursor.lnum)) |
7 | 4199 { |
5682 | 4200 char_u *cp = ml_get_cursor(); |
4201 | |
4202 if (*cp != NUL) | |
4203 { | |
4204 if (has_mbyte) | |
4205 curwin->w_cursor.col += (*mb_ptr2len)(cp); | |
4206 else | |
4207 ++curwin->w_cursor.col; | |
4208 } | |
7 | 4209 cap->retval |= CA_NO_ADJ_OP_END; |
4210 } | |
4211 continue; | |
4212 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4213 // Only beep and flush if not moved at all |
7 | 4214 else if (cap->oap->op_type == OP_NOP && n == cap->count1) |
4215 beep_flush(); | |
4216 break; | |
4217 } | |
4218 } | |
4219 #ifdef FEAT_FOLDING | |
4220 if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped | |
4221 && cap->oap->op_type == OP_NOP) | |
4222 foldOpenCursor(); | |
4223 #endif | |
4224 } | |
4225 | |
4226 /* | |
4227 * Cursor up commands. | |
4228 * cap->arg is TRUE for "-": Move cursor to first non-blank. | |
4229 */ | |
4230 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4231 nv_up(cmdarg_T *cap) |
7 | 4232 { |
180 | 4233 if (mod_mask & MOD_MASK_SHIFT) |
4234 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4235 // <S-Up> is page up |
180 | 4236 cap->arg = BACKWARD; |
4237 nv_page(cap); | |
4238 } | |
4239 else | |
4240 { | |
4241 cap->oap->motion_type = MLINE; | |
4242 if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
4243 clearopbeep(cap->oap); | |
4244 else if (cap->arg) | |
4245 beginline(BL_WHITE | BL_FIX); | |
4246 } | |
7 | 4247 } |
4248 | |
4249 /* | |
4250 * Cursor down commands. | |
4251 * cap->arg is TRUE for CR and "+": Move cursor to first non-blank. | |
4252 */ | |
4253 static void | |
10192
758f3d5a463d
commit https://github.com/vim/vim/commit/1b010058235fb803c1d4f42a02d2883921be8ef4
Christian Brabandt <cb@256bit.org>
parents:
10154
diff
changeset
|
4254 nv_down(cmdarg_T *cap) |
7 | 4255 { |
180 | 4256 if (mod_mask & MOD_MASK_SHIFT) |
4257 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4258 // <S-Down> is page down |
180 | 4259 cap->arg = FORWARD; |
4260 nv_page(cap); | |
4261 } | |
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
|
4262 #if defined(FEAT_QUICKFIX) |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4263 // 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
|
4264 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
|
4265 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
|
4266 #endif |
180 | 4267 else |
7 | 4268 { |
4269 #ifdef FEAT_CMDWIN | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4270 // In the cmdline window a <CR> executes the command. |
170 | 4271 if (cmdwin_type != 0 && cap->cmdchar == CAR) |
7 | 4272 cmdwin_result = CAR; |
4273 else | |
4274 #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
|
4275 #ifdef FEAT_JOB_CHANNEL |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4276 // 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
|
4277 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
|
4278 && 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
|
4279 { |
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
|
4280 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
|
4281 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
|
4282 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
|
4283 } |
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
|
4284 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
|
4285 #endif |
7 | 4286 { |
4287 cap->oap->motion_type = MLINE; | |
4288 if (cursor_down(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) | |
4289 clearopbeep(cap->oap); | |
4290 else if (cap->arg) | |
4291 beginline(BL_WHITE | BL_FIX); | |
4292 } | |
4293 } | |
4294 } | |
4295 | |
4296 #ifdef FEAT_SEARCHPATH | |
4297 /* | |
4298 * Grab the file name under the cursor and edit it. | |
4299 */ | |
4300 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4301 nv_gotofile(cmdarg_T *cap) |
7 | 4302 { |
4303 char_u *ptr; | |
681 | 4304 linenr_T lnum = -1; |
7 | 4305 |
633 | 4306 if (text_locked()) |
7 | 4307 { |
4308 clearopbeep(cap->oap); | |
633 | 4309 text_locked_msg(); |
7 | 4310 return; |
4311 } | |
819 | 4312 if (curbuf_locked()) |
4313 { | |
4314 clearop(cap->oap); | |
4315 return; | |
4316 } | |
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
|
4317 #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
|
4318 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
|
4319 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
|
4320 #endif |
7 | 4321 |
681 | 4322 ptr = grab_file_name(cap->count1, &lnum); |
7 | 4323 |
4324 if (ptr != NULL) | |
4325 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4326 // 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
|
4327 if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !buf_hide(curbuf)) |
7009 | 4328 (void)autowrite(curbuf, FALSE); |
7 | 4329 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
|
4330 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
|
4331 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
|
4332 && cap->nchar == 'F' && lnum >= 0) |
681 | 4333 { |
4334 curwin->w_cursor.lnum = lnum; | |
4335 check_cursor_lnum(); | |
4336 beginline(BL_SOL | BL_FIX); | |
4337 } | |
7 | 4338 vim_free(ptr); |
4339 } | |
4340 else | |
4341 clearop(cap->oap); | |
4342 } | |
4343 #endif | |
4344 | |
4345 /* | |
4346 * <End> command: to end of current line or last line. | |
4347 */ | |
4348 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4349 nv_end(cmdarg_T *cap) |
7 | 4350 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4351 if (cap->arg || (mod_mask & MOD_MASK_CTRL)) // CTRL-END = goto last line |
180 | 4352 { |
4353 cap->arg = TRUE; | |
7 | 4354 nv_goto(cap); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4355 cap->count1 = 1; // to end of current line |
7 | 4356 } |
4357 nv_dollar(cap); | |
4358 } | |
4359 | |
4360 /* | |
4361 * Handle the "$" command. | |
4362 */ | |
4363 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4364 nv_dollar(cmdarg_T *cap) |
7 | 4365 { |
4366 cap->oap->motion_type = MCHAR; | |
4367 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4368 // 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
|
4369 // 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
|
4370 // Otherwise, send it to the end of the line. |
7 | 4371 if (!virtual_active() || gchar_cursor() != NUL |
4372 || 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
|
4373 curwin->w_curswant = MAXCOL; // so we stay at the end |
7 | 4374 if (cursor_down((long)(cap->count1 - 1), |
4375 cap->oap->op_type == OP_NOP) == FAIL) | |
4376 clearopbeep(cap->oap); | |
4377 #ifdef FEAT_FOLDING | |
4378 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4379 foldOpenCursor(); | |
4380 #endif | |
4381 } | |
4382 | |
4383 /* | |
4384 * Implementation of '?' and '/' commands. | |
4385 * If cap->arg is TRUE don't set PC mark. | |
4386 */ | |
4387 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4388 nv_search(cmdarg_T *cap) |
7 | 4389 { |
4390 oparg_T *oap = cap->oap; | |
10098
72e4b7f90465
commit https://github.com/vim/vim/commit/dda933d06c06c2792bd686d059f6ad19191ad30b
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4391 pos_T save_cursor = curwin->w_cursor; |
7 | 4392 |
4393 if (cap->cmdchar == '?' && cap->oap->op_type == OP_ROT13) | |
4394 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4395 // Translate "g??" to "g?g?" |
7 | 4396 cap->cmdchar = 'g'; |
4397 cap->nchar = '?'; | |
4398 nv_operator(cap); | |
4399 return; | |
4400 } | |
4401 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4402 // 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
|
4403 // start position. |
26804
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26749
diff
changeset
|
4404 cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, 0); |
7 | 4405 |
4406 if (cap->searchbuf == NULL) | |
4407 { | |
4408 clearop(oap); | |
4409 return; | |
4410 } | |
4411 | |
6620 | 4412 (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
|
4413 (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
|
4414 ? 0 : SEARCH_MARK, NULL); |
7 | 4415 } |
4416 | |
4417 /* | |
4418 * Handle "N" and "n" commands. | |
4419 * cap->arg is SEARCH_REV for "N", 0 for "n". | |
4420 */ | |
4421 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4422 nv_next(cmdarg_T *cap) |
7 | 4423 { |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4424 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
|
4425 int wrapped = FALSE; |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4426 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
|
4427 |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4428 if (i == 1 && !wrapped && EQUAL_POS(old, curwin->w_cursor)) |
6620 | 4429 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4430 // 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
|
4431 // 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
|
4432 // in the buffer: Repeat with count + 1. |
6620 | 4433 cap->count1 += 1; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4434 (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg, NULL); |
6620 | 4435 cap->count1 -= 1; |
4436 } | |
7 | 4437 } |
4438 | |
4439 /* | |
4440 * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat). | |
4441 * Uses only cap->count1 and cap->oap from "cap". | |
6620 | 4442 * Return 0 for failure, 1 for found, 2 for found and line offset added. |
4443 */ | |
4444 static int | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4445 normal_search( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4446 cmdarg_T *cap, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4447 int dir, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4448 char_u *pat, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4449 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
|
4450 int *wrapped) |
7 | 4451 { |
4452 int i; | |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4453 searchit_arg_T sia; |
7 | 4454 |
4455 cap->oap->motion_type = MCHAR; | |
4456 cap->oap->inclusive = FALSE; | |
4457 cap->oap->use_reg_one = TRUE; | |
4458 curwin->w_set_curswant = TRUE; | |
4459 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19681
diff
changeset
|
4460 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
|
4461 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
|
4462 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
|
4463 if (wrapped != NULL) |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
4464 *wrapped = sia.sa_wrapped; |
7 | 4465 if (i == 0) |
4466 clearop(cap->oap); | |
4467 else | |
4468 { | |
4469 if (i == 2) | |
4470 cap->oap->motion_type = MLINE; | |
4471 curwin->w_cursor.coladd = 0; | |
4472 #ifdef FEAT_FOLDING | |
4473 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4474 foldOpenCursor(); | |
4475 #endif | |
4476 } | |
4477 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4478 // "/$" 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
|
4479 // correct that here |
7 | 4480 check_cursor(); |
6620 | 4481 return i; |
7 | 4482 } |
4483 | |
4484 /* | |
4485 * Character search commands. | |
4486 * cap->arg is BACKWARD for 'F' and 'T', FORWARD for 'f' and 't', TRUE for | |
4487 * ',' and FALSE for ';'. | |
4488 * cap->nchar is NUL for ',' and ';' (repeat the search) | |
4489 */ | |
4490 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4491 nv_csearch(cmdarg_T *cap) |
7 | 4492 { |
4493 int t_cmd; | |
4494 | |
4495 if (cap->cmdchar == 't' || cap->cmdchar == 'T') | |
4496 t_cmd = TRUE; | |
4497 else | |
4498 t_cmd = FALSE; | |
4499 | |
4500 cap->oap->motion_type = MCHAR; | |
4501 if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL) | |
4502 clearopbeep(cap->oap); | |
4503 else | |
4504 { | |
4505 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
|
4506 // Include a Tab for "tx" and for "dfx". |
7 | 4507 if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD |
4508 && (t_cmd || cap->oap->op_type != OP_NOP)) | |
4509 { | |
4510 colnr_T scol, ecol; | |
4511 | |
4512 getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); | |
4513 curwin->w_cursor.coladd = ecol - scol; | |
4514 } | |
4515 else | |
4516 curwin->w_cursor.coladd = 0; | |
4517 adjust_for_sel(cap); | |
4518 #ifdef FEAT_FOLDING | |
4519 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4520 foldOpenCursor(); | |
4521 #endif | |
4522 } | |
4523 } | |
4524 | |
4525 /* | |
4526 * "[" and "]" commands. | |
4527 * cap->arg is BACKWARD for "[" and FORWARD for "]". | |
4528 */ | |
4529 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4530 nv_brackets(cmdarg_T *cap) |
7 | 4531 { |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
4532 pos_T new_pos = {0, 0, 0}; |
7 | 4533 pos_T prev_pos; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4534 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
|
4535 pos_T old_pos; // cursor position before command |
7 | 4536 int flag; |
4537 long n; | |
4538 int findc; | |
4539 int c; | |
4540 | |
4541 cap->oap->motion_type = MCHAR; | |
4542 cap->oap->inclusive = FALSE; | |
4543 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
|
4544 curwin->w_cursor.coladd = 0; // TODO: don't do this for an error. |
7 | 4545 |
4546 #ifdef FEAT_SEARCHPATH | |
4547 /* | |
4548 * "[f" or "]f" : Edit file under the cursor (same as "gf") | |
4549 */ | |
4550 if (cap->nchar == 'f') | |
4551 nv_gotofile(cap); | |
4552 else | |
4553 #endif | |
4554 | |
4555 #ifdef FEAT_FIND_ID | |
4556 /* | |
1188 | 4557 * Find the occurrence(s) of the identifier or define under cursor |
4558 * in current and included files or jump to the first occurrence. | |
7 | 4559 * |
4560 * search list jump | |
4561 * fwd bwd fwd bwd fwd bwd | |
4562 * identifier "]i" "[i" "]I" "[I" "]^I" "[^I" | |
4563 * define "]d" "[d" "]D" "[D" "]^D" "[^D" | |
4564 */ | |
4565 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
|
4566 # ifdef EBCDIC |
7 | 4567 "iI\005dD\067", |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4568 # else |
7 | 4569 "iI\011dD\004", |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
4570 # endif |
7 | 4571 cap->nchar) != NULL) |
4572 { | |
4573 char_u *ptr; | |
4574 int len; | |
4575 | |
4576 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) | |
4577 clearop(cap->oap); | |
4578 else | |
4579 { | |
4580 find_pattern_in_path(ptr, 0, len, TRUE, | |
4581 cap->count0 == 0 ? !isupper(cap->nchar) : FALSE, | |
4582 ((cap->nchar & 0xf) == ('d' & 0xf)) ? FIND_DEFINE : FIND_ANY, | |
4583 cap->count1, | |
4584 isupper(cap->nchar) ? ACTION_SHOW_ALL : | |
4585 islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO, | |
4586 cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1, | |
4587 (linenr_T)MAXLNUM); | |
4588 curwin->w_set_curswant = TRUE; | |
4589 } | |
4590 } | |
4591 else | |
4592 #endif | |
4593 | |
4594 /* | |
4595 * "[{", "[(", "]}" or "])": go to Nth unclosed '{', '(', '}' or ')' | |
4596 * "[#", "]#": go to start/end of Nth innermost #if..#endif construct. | |
4597 * "[/", "[*", "]/", "]*": go to Nth comment start/end. | |
4598 * "[m" or "]m" search for prev/next start of (Java) method. | |
4599 * "[M" or "]M" search for prev/next end of (Java) method. | |
4600 */ | |
4601 if ( (cap->cmdchar == '[' | |
4602 && vim_strchr((char_u *)"{(*/#mM", cap->nchar) != NULL) | |
4603 || (cap->cmdchar == ']' | |
4604 && vim_strchr((char_u *)"})*/#mM", cap->nchar) != NULL)) | |
4605 { | |
4606 if (cap->nchar == '*') | |
4607 cap->nchar = '/'; | |
4608 prev_pos.lnum = 0; | |
4609 if (cap->nchar == 'm' || cap->nchar == 'M') | |
4610 { | |
4611 if (cap->cmdchar == '[') | |
4612 findc = '{'; | |
4613 else | |
4614 findc = '}'; | |
4615 n = 9999; | |
4616 } | |
4617 else | |
4618 { | |
4619 findc = cap->nchar; | |
4620 n = cap->count1; | |
4621 } | |
4622 for ( ; n > 0; --n) | |
4623 { | |
4624 if ((pos = findmatchlimit(cap->oap, findc, | |
4625 (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, 0)) == NULL) | |
4626 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4627 if (new_pos.lnum == 0) // nothing found |
7 | 4628 { |
4629 if (cap->nchar != 'm' && cap->nchar != 'M') | |
4630 clearopbeep(cap->oap); | |
4631 } | |
4632 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4633 pos = &new_pos; // use last one found |
7 | 4634 break; |
4635 } | |
4636 prev_pos = new_pos; | |
4637 curwin->w_cursor = *pos; | |
4638 new_pos = *pos; | |
4639 } | |
4640 curwin->w_cursor = old_pos; | |
4641 | |
4642 /* | |
4643 * Handle "[m", "]m", "[M" and "[M". The findmatchlimit() only | |
4644 * brought us to the match for "[m" and "]M" when inside a method. | |
4645 * Try finding the '{' or '}' we want to be at. | |
4646 * Also repeat for the given count. | |
4647 */ | |
4648 if (cap->nchar == 'm' || cap->nchar == 'M') | |
4649 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4650 // norm is TRUE for "]M" and "[m" |
7 | 4651 int norm = ((findc == '{') == (cap->nchar == 'm')); |
4652 | |
4653 n = cap->count1; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4654 // found a match: we were inside a method |
7 | 4655 if (prev_pos.lnum != 0) |
4656 { | |
4657 pos = &prev_pos; | |
4658 curwin->w_cursor = prev_pos; | |
4659 if (norm) | |
4660 --n; | |
4661 } | |
4662 else | |
4663 pos = NULL; | |
4664 while (n > 0) | |
4665 { | |
4666 for (;;) | |
4667 { | |
4668 if ((findc == '{' ? dec_cursor() : inc_cursor()) < 0) | |
4669 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4670 // if not found anything, that's an error |
7 | 4671 if (pos == NULL) |
4672 clearopbeep(cap->oap); | |
4673 n = 0; | |
4674 break; | |
4675 } | |
4676 c = gchar_cursor(); | |
4677 if (c == '{' || c == '}') | |
4678 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4679 // 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
|
4680 // Or found the place to be at. |
7 | 4681 if ((c == findc && norm) || (n == 1 && !norm)) |
4682 { | |
4683 new_pos = curwin->w_cursor; | |
4684 pos = &new_pos; | |
4685 n = 0; | |
4686 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4687 // 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
|
4688 // class and we're inside now. Just go on. |
7 | 4689 else if (new_pos.lnum == 0) |
4690 { | |
4691 new_pos = curwin->w_cursor; | |
4692 pos = &new_pos; | |
4693 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4694 // found start/end of other method: go to match |
7 | 4695 else if ((pos = findmatchlimit(cap->oap, findc, |
4696 (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD, | |
4697 0)) == NULL) | |
4698 n = 0; | |
4699 else | |
4700 curwin->w_cursor = *pos; | |
4701 break; | |
4702 } | |
4703 } | |
4704 --n; | |
4705 } | |
4706 curwin->w_cursor = old_pos; | |
4707 if (pos == NULL && new_pos.lnum != 0) | |
4708 clearopbeep(cap->oap); | |
4709 } | |
4710 if (pos != NULL) | |
4711 { | |
4712 setpcmark(); | |
4713 curwin->w_cursor = *pos; | |
4714 curwin->w_set_curswant = TRUE; | |
4715 #ifdef FEAT_FOLDING | |
4716 if ((fdo_flags & FDO_BLOCK) && KeyTyped | |
4717 && cap->oap->op_type == OP_NOP) | |
4718 foldOpenCursor(); | |
4719 #endif | |
4720 } | |
4721 } | |
4722 | |
4723 /* | |
4724 * "[[", "[]", "]]" and "][": move to start or end of function | |
4725 */ | |
4726 else if (cap->nchar == '[' || cap->nchar == ']') | |
4727 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4728 if (cap->nchar == cap->cmdchar) // "]]" or "[[" |
7 | 4729 flag = '{'; |
4730 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4731 flag = '}'; // "][" or "[]" |
7 | 4732 |
4733 curwin->w_set_curswant = TRUE; | |
4734 /* | |
4735 * Imitate strange Vi behaviour: When using "]]" with an operator | |
4736 * we also stop at '}'. | |
4737 */ | |
503 | 4738 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, flag, |
7 | 4739 (cap->oap->op_type != OP_NOP |
4740 && cap->arg == FORWARD && flag == '{'))) | |
4741 clearopbeep(cap->oap); | |
4742 else | |
4743 { | |
4744 if (cap->oap->op_type == OP_NOP) | |
4745 beginline(BL_WHITE | BL_FIX); | |
4746 #ifdef FEAT_FOLDING | |
4747 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4748 foldOpenCursor(); | |
4749 #endif | |
4750 } | |
4751 } | |
4752 | |
4753 /* | |
4754 * "[p", "[P", "]P" and "]p": put with indent adjustment | |
4755 */ | |
4756 else if (cap->nchar == 'p' || cap->nchar == 'P') | |
4757 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
4758 nv_put_opt(cap, TRUE); |
7 | 4759 } |
4760 | |
4761 /* | |
4762 * "['", "[`", "]'" and "]`": jump to next mark | |
4763 */ | |
4764 else if (cap->nchar == '\'' || cap->nchar == '`') | |
4765 { | |
4766 pos = &curwin->w_cursor; | |
4767 for (n = cap->count1; n > 0; --n) | |
4768 { | |
4769 prev_pos = *pos; | |
4770 pos = getnextmark(pos, cap->cmdchar == '[' ? BACKWARD : FORWARD, | |
4771 cap->nchar == '\''); | |
4772 if (pos == NULL) | |
4773 break; | |
4774 } | |
4775 if (pos == NULL) | |
4776 pos = &prev_pos; | |
4777 nv_cursormark(cap, cap->nchar == '\'', pos); | |
4778 } | |
4779 | |
4780 /* | |
4781 * [ or ] followed by a middle mouse click: put selected text with | |
4782 * indent adjustment. Any other button just does as usual. | |
4783 */ | |
2130
279380a812ad
updated for version 7.2.412
Bram Moolenaar <bram@zimbu.org>
parents:
2112
diff
changeset
|
4784 else if (cap->nchar >= K_RIGHTRELEASE && cap->nchar <= K_LEFTMOUSE) |
7 | 4785 { |
4786 (void)do_mouse(cap->oap, cap->nchar, | |
4787 (cap->cmdchar == ']') ? FORWARD : BACKWARD, | |
4788 cap->count1, PUT_FIXINDENT); | |
4789 } | |
4790 | |
4791 #ifdef FEAT_FOLDING | |
4792 /* | |
4793 * "[z" and "]z": move to start or end of open fold. | |
4794 */ | |
4795 else if (cap->nchar == 'z') | |
4796 { | |
4797 if (foldMoveTo(FALSE, cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4798 cap->count1) == FAIL) | |
4799 clearopbeep(cap->oap); | |
4800 } | |
4801 #endif | |
4802 | |
4803 #ifdef FEAT_DIFF | |
4804 /* | |
4805 * "[c" and "]c": move to next or previous diff-change. | |
4806 */ | |
4807 else if (cap->nchar == 'c') | |
4808 { | |
4809 if (diff_move_to(cap->cmdchar == ']' ? FORWARD : BACKWARD, | |
4810 cap->count1) == FAIL) | |
4811 clearopbeep(cap->oap); | |
4812 } | |
4813 #endif | |
4814 | |
737 | 4815 #ifdef FEAT_SPELL |
236 | 4816 /* |
4817 * "[s", "[S", "]s" and "]S": move to next spell error. | |
4818 */ | |
4819 else if (cap->nchar == 's' || cap->nchar == 'S') | |
4820 { | |
249 | 4821 setpcmark(); |
4822 for (n = 0; n < cap->count1; ++n) | |
498 | 4823 if (spell_move_to(curwin, cap->cmdchar == ']' ? FORWARD : BACKWARD, |
4824 cap->nchar == 's' ? TRUE : FALSE, FALSE, NULL) == 0) | |
249 | 4825 { |
4826 clearopbeep(cap->oap); | |
4827 break; | |
4828 } | |
13088
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4829 else |
3dd37eec73f0
patch 8.0.1419: cursor column is not updated after ]s
Christian Brabandt <cb@256bit.org>
parents:
13072
diff
changeset
|
4830 curwin->w_set_curswant = TRUE; |
819 | 4831 # ifdef FEAT_FOLDING |
4832 if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped) | |
4833 foldOpenCursor(); | |
4834 # endif | |
236 | 4835 } |
4836 #endif | |
4837 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4838 // Not a valid cap->nchar. |
7 | 4839 else |
4840 clearopbeep(cap->oap); | |
4841 } | |
4842 | |
4843 /* | |
4844 * Handle Normal mode "%" command. | |
4845 */ | |
4846 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4847 nv_percent(cmdarg_T *cap) |
7 | 4848 { |
4849 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
|
4850 #if defined(FEAT_FOLDING) |
7 | 4851 linenr_T lnum = curwin->w_cursor.lnum; |
4852 #endif | |
4853 | |
4854 cap->oap->inclusive = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4855 if (cap->count0) // {cnt}% : goto {cnt} percentage in file |
7 | 4856 { |
4857 if (cap->count0 > 100) | |
4858 clearopbeep(cap->oap); | |
4859 else | |
4860 { | |
4861 cap->oap->motion_type = MLINE; | |
4862 setpcmark(); | |
24010
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4863 // Round up, so 'normal 100%' always jumps at the line line. |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4864 // Beyond 21474836 lines, (ml_line_count * 100 + 99) would |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4865 // overflow on 32-bits, so use a formula with less accuracy |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4866 // to avoid overflows. |
c9849ed1ce05
patch 8.2.2547: "%" command not accurate for big files
Bram Moolenaar <Bram@vim.org>
parents:
23762
diff
changeset
|
4867 if (curbuf->b_ml.ml_line_count >= 21474836) |
7 | 4868 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count + 99L) |
4869 / 100L * cap->count0; | |
4870 else | |
4871 curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count * | |
4872 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
|
4873 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
|
4874 curwin->w_cursor.lnum = 1; |
7 | 4875 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
4876 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
4877 beginline(BL_SOL | BL_FIX); | |
4878 } | |
4879 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4880 else // "%" : go to matching paren |
7 | 4881 { |
4882 cap->oap->motion_type = MCHAR; | |
4883 cap->oap->use_reg_one = TRUE; | |
4884 if ((pos = findmatch(cap->oap, NUL)) == NULL) | |
4885 clearopbeep(cap->oap); | |
4886 else | |
4887 { | |
4888 setpcmark(); | |
4889 curwin->w_cursor = *pos; | |
4890 curwin->w_set_curswant = TRUE; | |
4891 curwin->w_cursor.coladd = 0; | |
4892 adjust_for_sel(cap); | |
4893 } | |
4894 } | |
4895 #ifdef FEAT_FOLDING | |
4896 if (cap->oap->op_type == OP_NOP | |
4897 && lnum != curwin->w_cursor.lnum | |
4898 && (fdo_flags & FDO_PERCENT) | |
4899 && KeyTyped) | |
4900 foldOpenCursor(); | |
4901 #endif | |
4902 } | |
4903 | |
4904 /* | |
4905 * Handle "(" and ")" commands. | |
4906 * cap->arg is BACKWARD for "(" and FORWARD for ")". | |
4907 */ | |
4908 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4909 nv_brace(cmdarg_T *cap) |
7 | 4910 { |
4911 cap->oap->motion_type = MCHAR; | |
4912 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
|
4913 // The motion used to be inclusive for "(", but that is not what Vi does. |
620 | 4914 cap->oap->inclusive = FALSE; |
7 | 4915 curwin->w_set_curswant = TRUE; |
4916 | |
4917 if (findsent(cap->arg, cap->count1) == FAIL) | |
4918 clearopbeep(cap->oap); | |
4919 else | |
4920 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4921 // Don't leave the cursor on the NUL past end of line. |
1505 | 4922 adjust_cursor(cap->oap); |
7 | 4923 curwin->w_cursor.coladd = 0; |
4924 #ifdef FEAT_FOLDING | |
4925 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4926 foldOpenCursor(); | |
4927 #endif | |
4928 } | |
4929 } | |
4930 | |
4931 /* | |
4932 * "m" command: Mark a position. | |
4933 */ | |
4934 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4935 nv_mark(cmdarg_T *cap) |
7 | 4936 { |
4937 if (!checkclearop(cap->oap)) | |
4938 { | |
4939 if (setmark(cap->nchar) == FAIL) | |
4940 clearopbeep(cap->oap); | |
4941 } | |
4942 } | |
4943 | |
4944 /* | |
4945 * "{" and "}" commands. | |
4946 * cmd->arg is BACKWARD for "{" and FORWARD for "}". | |
4947 */ | |
4948 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4949 nv_findpar(cmdarg_T *cap) |
7 | 4950 { |
4951 cap->oap->motion_type = MCHAR; | |
4952 cap->oap->inclusive = FALSE; | |
4953 cap->oap->use_reg_one = TRUE; | |
4954 curwin->w_set_curswant = TRUE; | |
503 | 4955 if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE)) |
7 | 4956 clearopbeep(cap->oap); |
4957 else | |
4958 { | |
4959 curwin->w_cursor.coladd = 0; | |
4960 #ifdef FEAT_FOLDING | |
4961 if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) | |
4962 foldOpenCursor(); | |
4963 #endif | |
4964 } | |
4965 } | |
4966 | |
4967 /* | |
4968 * "u" command: Undo or make lower case. | |
4969 */ | |
4970 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4971 nv_undo(cmdarg_T *cap) |
7 | 4972 { |
5735 | 4973 if (cap->oap->op_type == OP_LOWER || VIsual_active) |
7 | 4974 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
4975 // translate "<Visual>u" to "<Visual>gu" and "guu" to "gugu" |
7 | 4976 cap->cmdchar = 'g'; |
4977 cap->nchar = 'u'; | |
4978 nv_operator(cap); | |
4979 } | |
4980 else | |
4981 nv_kundo(cap); | |
4982 } | |
4983 | |
4984 /* | |
4985 * <Undo> command. | |
4986 */ | |
4987 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
4988 nv_kundo(cmdarg_T *cap) |
7 | 4989 { |
4990 if (!checkclearopq(cap->oap)) | |
4991 { | |
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
|
4992 #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
|
4993 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
|
4994 { |
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
|
4995 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
|
4996 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
|
4997 } |
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
|
4998 #endif |
7 | 4999 u_undo((int)cap->count1); |
5000 curwin->w_set_curswant = TRUE; | |
5001 } | |
5002 } | |
5003 | |
5004 /* | |
5005 * Handle the "r" command. | |
5006 */ | |
5007 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5008 nv_replace(cmdarg_T *cap) |
7 | 5009 { |
5010 char_u *ptr; | |
5011 int had_ctrl_v; | |
5012 long n; | |
5013 | |
5014 if (checkclearop(cap->oap)) | |
5015 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
|
5016 #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
|
5017 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
|
5018 { |
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
|
5019 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
|
5020 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
|
5021 } |
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
|
5022 #endif |
7 | 5023 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5024 // get another character |
7 | 5025 if (cap->nchar == Ctrl_V) |
5026 { | |
5027 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
|
5028 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
|
5029 // Don't redo a multibyte character with CTRL-V. |
7 | 5030 if (cap->nchar > DEL) |
5031 had_ctrl_v = NUL; | |
5032 } | |
5033 else | |
5034 had_ctrl_v = NUL; | |
5035 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5036 // Abort if the character is a special key. |
1343 | 5037 if (IS_SPECIAL(cap->nchar)) |
5038 { | |
5039 clearopbeep(cap->oap); | |
5040 return; | |
5041 } | |
5042 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5043 // Visual mode "r" |
7 | 5044 if (VIsual_active) |
5045 { | |
1797 | 5046 if (got_int) |
5047 reset_VIsual(); | |
5428 | 5048 if (had_ctrl_v) |
5049 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5050 // 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
|
5051 // 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
|
5052 if (cap->nchar == CAR) |
2941a86f8aaa
patch 8.0.1475: invalid memory access in read_redo()
Christian Brabandt <cb@256bit.org>
parents:
13088
diff
changeset
|
5053 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
|
5054 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
|
5055 cap->nchar = REPLACE_NL_NCHAR; |
5428 | 5056 } |
7 | 5057 nv_operator(cap); |
5058 return; | |
5059 } | |
5060 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5061 // Break tabs, etc. |
7 | 5062 if (virtual_active()) |
5063 { | |
5064 if (u_save_cursor() == FAIL) | |
5065 return; | |
5066 if (gchar_cursor() == NUL) | |
5067 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5068 // Add extra space and put the cursor on the first one. |
7 | 5069 coladvance_force((colnr_T)(getviscol() + cap->count1)); |
5070 curwin->w_cursor.col -= cap->count1; | |
5071 } | |
5072 else if (gchar_cursor() == TAB) | |
5073 coladvance_force(getviscol()); | |
5074 } | |
5075 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5076 // Abort if not enough characters to replace. |
7 | 5077 ptr = ml_get_cursor(); |
1343 | 5078 if (STRLEN(ptr) < (unsigned)cap->count1 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
5079 || (has_mbyte && mb_charlen(ptr) < cap->count1)) |
7 | 5080 { |
5081 clearopbeep(cap->oap); | |
5082 return; | |
5083 } | |
5084 | |
5085 /* | |
5086 * Replacing with a TAB is done by edit() when it is complicated because | |
5087 * 'expandtab' or 'smarttab' is set. CTRL-V TAB inserts a literal TAB. | |
5088 * Other characters are done below to avoid problems with things like | |
5089 * CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC). | |
5090 */ | |
5091 if (had_ctrl_v != Ctrl_V && cap->nchar == '\t' && (curbuf->b_p_et || p_sta)) | |
5092 { | |
5093 stuffnumReadbuff(cap->count1); | |
5094 stuffcharReadbuff('R'); | |
5095 stuffcharReadbuff('\t'); | |
5096 stuffcharReadbuff(ESC); | |
5097 return; | |
5098 } | |
5099 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5100 // save line for undo |
7 | 5101 if (u_save_cursor() == FAIL) |
5102 return; | |
5103 | |
5104 if (had_ctrl_v != Ctrl_V && (cap->nchar == '\r' || cap->nchar == '\n')) | |
5105 { | |
5106 /* | |
5107 * Replace character(s) by a single newline. | |
5108 * Strange vi behaviour: Only one newline is inserted. | |
5109 * Delete the characters here. | |
5110 * Insert the newline with an insert command, takes care of | |
5111 * autoindent. The insert command depends on being on the last | |
5112 * character of a line or not. | |
5113 */ | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5114 (void)del_chars(cap->count1, FALSE); // delete the characters |
7 | 5115 stuffcharReadbuff('\r'); |
5116 stuffcharReadbuff(ESC); | |
5117 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5118 // Give 'r' to edit(), to get the redo command right. |
7 | 5119 invoke_edit(cap, TRUE, 'r', FALSE); |
5120 } | |
5121 else | |
5122 { | |
5123 prep_redo(cap->oap->regname, cap->count1, | |
5124 NUL, 'r', NUL, had_ctrl_v, cap->nchar); | |
5125 | |
5126 curbuf->b_op_start = curwin->w_cursor; | |
5127 if (has_mbyte) | |
5128 { | |
5129 int old_State = State; | |
5130 | |
5131 if (cap->ncharC1 != 0) | |
5132 AppendCharToRedobuff(cap->ncharC1); | |
5133 if (cap->ncharC2 != 0) | |
5134 AppendCharToRedobuff(cap->ncharC2); | |
5135 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5136 // 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
|
5137 // 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
|
5138 // composing characters for utf-8. |
7 | 5139 for (n = cap->count1; n > 0; --n) |
5140 { | |
5141 State = REPLACE; | |
3501 | 5142 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
5143 { | |
5144 int c = ins_copychar(curwin->w_cursor.lnum | |
5145 + (cap->nchar == Ctrl_Y ? -1 : 1)); | |
5146 if (c != NUL) | |
5147 ins_char(c); | |
5148 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5149 // will be decremented further down |
3501 | 5150 ++curwin->w_cursor.col; |
5151 } | |
5152 else | |
5153 ins_char(cap->nchar); | |
7 | 5154 State = old_State; |
5155 if (cap->ncharC1 != 0) | |
5156 ins_char(cap->ncharC1); | |
5157 if (cap->ncharC2 != 0) | |
5158 ins_char(cap->ncharC2); | |
5159 } | |
5160 } | |
5161 else | |
5162 { | |
5163 /* | |
5164 * Replace the characters within one line. | |
5165 */ | |
5166 for (n = cap->count1; n > 0; --n) | |
5167 { | |
5168 /* | |
5169 * Get ptr again, because u_save and/or showmatch() will have | |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
5170 * released the line. This may also happen in ins_copychar(). |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
5171 * At the same time we let know that the line will be changed. |
7 | 5172 */ |
3501 | 5173 if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y) |
5174 { | |
5175 int c = ins_copychar(curwin->w_cursor.lnum | |
5176 + (cap->nchar == Ctrl_Y ? -1 : 1)); | |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
5177 |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
5178 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); |
3501 | 5179 if (c != NUL) |
5180 ptr[curwin->w_cursor.col] = c; | |
5181 } | |
5182 else | |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
5183 { |
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
5184 ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); |
3501 | 5185 ptr[curwin->w_cursor.col] = cap->nchar; |
25786
ec62e0764ffa
patch 8.2.3428: using freed memory when replacing
Bram Moolenaar <Bram@vim.org>
parents:
25398
diff
changeset
|
5186 } |
7 | 5187 if (p_sm && msg_silent == 0) |
5188 showmatch(cap->nchar); | |
5189 ++curwin->w_cursor.col; | |
5190 } | |
5191 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5192 if (netbeans_active()) |
7 | 5193 { |
2210 | 5194 colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1); |
7 | 5195 |
33 | 5196 netbeans_removed(curbuf, curwin->w_cursor.lnum, start, |
2210 | 5197 (long)cap->count1); |
7 | 5198 netbeans_inserted(curbuf, curwin->w_cursor.lnum, start, |
33 | 5199 &ptr[start], (int)cap->count1); |
7 | 5200 } |
5201 #endif | |
5202 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5203 // mark the buffer as changed and prepare for displaying |
7 | 5204 changed_bytes(curwin->w_cursor.lnum, |
5205 (colnr_T)(curwin->w_cursor.col - cap->count1)); | |
5206 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5207 --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
|
5208 // 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
|
5209 // character, move two characters left |
7 | 5210 if (has_mbyte) |
5211 mb_adjust_cursor(); | |
5212 curbuf->b_op_end = curwin->w_cursor; | |
5213 curwin->w_set_curswant = TRUE; | |
5214 set_last_insert(cap->nchar); | |
5215 } | |
5216 } | |
5217 | |
5218 /* | |
5219 * 'o': Exchange start and end of Visual area. | |
5220 * 'O': same, but in block mode exchange left and right corners. | |
5221 */ | |
5222 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5223 v_swap_corners(int cmdchar) |
7 | 5224 { |
5225 pos_T old_cursor; | |
5226 colnr_T left, right; | |
5227 | |
5228 if (cmdchar == 'O' && VIsual_mode == Ctrl_V) | |
5229 { | |
5230 old_cursor = curwin->w_cursor; | |
5231 getvcols(curwin, &old_cursor, &VIsual, &left, &right); | |
5232 curwin->w_cursor.lnum = VIsual.lnum; | |
5233 coladvance(left); | |
5234 VIsual = curwin->w_cursor; | |
5235 | |
5236 curwin->w_cursor.lnum = old_cursor.lnum; | |
5237 curwin->w_curswant = right; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5238 // '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
|
5239 // right one column |
7 | 5240 if (old_cursor.lnum >= VIsual.lnum && *p_sel == 'e') |
5241 ++curwin->w_curswant; | |
5242 coladvance(curwin->w_curswant); | |
5243 if (curwin->w_cursor.col == old_cursor.col | |
5244 && (!virtual_active() | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5245 || curwin->w_cursor.coladd == old_cursor.coladd)) |
7 | 5246 { |
5247 curwin->w_cursor.lnum = VIsual.lnum; | |
5248 if (old_cursor.lnum <= VIsual.lnum && *p_sel == 'e') | |
5249 ++right; | |
5250 coladvance(right); | |
5251 VIsual = curwin->w_cursor; | |
5252 | |
5253 curwin->w_cursor.lnum = old_cursor.lnum; | |
5254 coladvance(left); | |
5255 curwin->w_curswant = left; | |
5256 } | |
5257 } | |
5258 else | |
5259 { | |
5260 old_cursor = curwin->w_cursor; | |
5261 curwin->w_cursor = VIsual; | |
5262 VIsual = old_cursor; | |
5263 curwin->w_set_curswant = TRUE; | |
5264 } | |
5265 } | |
5266 | |
5267 /* | |
5268 * "R" (cap->arg is FALSE) and "gR" (cap->arg is TRUE). | |
5269 */ | |
5270 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5271 nv_Replace(cmdarg_T *cap) |
7 | 5272 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5273 if (VIsual_active) // "R" is replace lines |
7 | 5274 { |
5275 cap->cmdchar = 'c'; | |
5276 cap->nchar = NUL; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5277 VIsual_mode_orig = VIsual_mode; // remember original area for gv |
7 | 5278 VIsual_mode = 'V'; |
5279 nv_operator(cap); | |
5280 } | |
5735 | 5281 else if (!checkclearopq(cap->oap)) |
7 | 5282 { |
5283 if (!curbuf->b_p_ma) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
5284 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 5285 else |
5286 { | |
5287 if (virtual_active()) | |
5288 coladvance(getviscol()); | |
5289 invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE); | |
5290 } | |
5291 } | |
5292 } | |
5293 | |
5294 /* | |
5295 * "gr". | |
5296 */ | |
5297 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5298 nv_vreplace(cmdarg_T *cap) |
7 | 5299 { |
5300 if (VIsual_active) | |
5301 { | |
5302 cap->cmdchar = 'r'; | |
5303 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
|
5304 nv_replace(cap); // Do same as "r" in Visual mode for now |
7 | 5305 } |
5735 | 5306 else if (!checkclearopq(cap->oap)) |
7 | 5307 { |
5308 if (!curbuf->b_p_ma) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
5309 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 5310 else |
5311 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5312 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
|
5313 cap->extra_char = get_literal(FALSE); |
7 | 5314 stuffcharReadbuff(cap->extra_char); |
5315 stuffcharReadbuff(ESC); | |
5316 if (virtual_active()) | |
5317 coladvance(getviscol()); | |
5318 invoke_edit(cap, TRUE, 'v', FALSE); | |
5319 } | |
5320 } | |
5321 } | |
5322 | |
5323 /* | |
5324 * Swap case for "~" command, when it does not work like an operator. | |
5325 */ | |
5326 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5327 n_swapchar(cmdarg_T *cap) |
7 | 5328 { |
5329 long n; | |
5330 pos_T startpos; | |
5331 int did_change = 0; | |
5332 #ifdef FEAT_NETBEANS_INTG | |
5333 pos_T pos; | |
5334 char_u *ptr; | |
5335 int count; | |
5336 #endif | |
5337 | |
5338 if (checkclearopq(cap->oap)) | |
5339 return; | |
5340 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5341 if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) |
7 | 5342 { |
5343 clearopbeep(cap->oap); | |
5344 return; | |
5345 } | |
5346 | |
5347 prep_redo_cmd(cap); | |
5348 | |
5349 if (u_save_cursor() == FAIL) | |
5350 return; | |
5351 | |
5352 startpos = curwin->w_cursor; | |
5353 #ifdef FEAT_NETBEANS_INTG | |
5354 pos = startpos; | |
5355 #endif | |
5356 for (n = cap->count1; n > 0; --n) | |
5357 { | |
5358 did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor); | |
5359 inc_cursor(); | |
5360 if (gchar_cursor() == NUL) | |
5361 { | |
5362 if (vim_strchr(p_ww, '~') != NULL | |
5363 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | |
5364 { | |
5365 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5366 if (netbeans_active()) |
7 | 5367 { |
5368 if (did_change) | |
5369 { | |
5370 ptr = ml_get(pos.lnum); | |
835 | 5371 count = (int)STRLEN(ptr) - pos.col; |
33 | 5372 netbeans_removed(curbuf, pos.lnum, pos.col, |
5373 (long)count); | |
7 | 5374 netbeans_inserted(curbuf, pos.lnum, pos.col, |
33 | 5375 &ptr[pos.col], count); |
7 | 5376 } |
5377 pos.col = 0; | |
5378 pos.lnum++; | |
5379 } | |
5380 #endif | |
5381 ++curwin->w_cursor.lnum; | |
5382 curwin->w_cursor.col = 0; | |
5383 if (n > 1) | |
5384 { | |
5385 if (u_savesub(curwin->w_cursor.lnum) == FAIL) | |
5386 break; | |
5387 u_clearline(); | |
5388 } | |
5389 } | |
5390 else | |
5391 break; | |
5392 } | |
5393 } | |
5394 #ifdef FEAT_NETBEANS_INTG | |
2210 | 5395 if (did_change && netbeans_active()) |
7 | 5396 { |
5397 ptr = ml_get(pos.lnum); | |
5398 count = curwin->w_cursor.col - pos.col; | |
33 | 5399 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count); |
5400 netbeans_inserted(curbuf, pos.lnum, pos.col, &ptr[pos.col], count); | |
7 | 5401 } |
5402 #endif | |
5403 | |
5404 | |
5405 check_cursor(); | |
5406 curwin->w_set_curswant = TRUE; | |
5407 if (did_change) | |
5408 { | |
5409 changed_lines(startpos.lnum, startpos.col, curwin->w_cursor.lnum + 1, | |
5410 0L); | |
5411 curbuf->b_op_start = startpos; | |
5412 curbuf->b_op_end = curwin->w_cursor; | |
5413 if (curbuf->b_op_end.col > 0) | |
5414 --curbuf->b_op_end.col; | |
5415 } | |
5416 } | |
5417 | |
5418 /* | |
5419 * Move cursor to mark. | |
5420 */ | |
5421 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5422 nv_cursormark(cmdarg_T *cap, int flag, pos_T *pos) |
7 | 5423 { |
5424 if (check_mark(pos) == FAIL) | |
5425 clearop(cap->oap); | |
5426 else | |
5427 { | |
5428 if (cap->cmdchar == '\'' | |
5429 || cap->cmdchar == '`' | |
5430 || cap->cmdchar == '[' | |
5431 || cap->cmdchar == ']') | |
5432 setpcmark(); | |
5433 curwin->w_cursor = *pos; | |
5434 if (flag) | |
5435 beginline(BL_WHITE | BL_FIX); | |
5436 else | |
5437 check_cursor(); | |
5438 } | |
5439 cap->oap->motion_type = flag ? MLINE : MCHAR; | |
5440 if (cap->cmdchar == '`') | |
5441 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
|
5442 cap->oap->inclusive = FALSE; // ignored if not MCHAR |
7 | 5443 curwin->w_set_curswant = TRUE; |
5444 } | |
5445 | |
5446 /* | |
5447 * Handle commands that are operators in Visual mode. | |
5448 */ | |
5449 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5450 v_visop(cmdarg_T *cap) |
7 | 5451 { |
5452 static char_u trans[] = "YyDdCcxdXdAAIIrr"; | |
5453 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5454 // 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
|
5455 // the end of the line, and "C" replaces till EOL |
7 | 5456 if (isupper(cap->cmdchar)) |
5457 { | |
5458 if (VIsual_mode != Ctrl_V) | |
4213 | 5459 { |
5460 VIsual_mode_orig = VIsual_mode; | |
7 | 5461 VIsual_mode = 'V'; |
4213 | 5462 } |
7 | 5463 else if (cap->cmdchar == 'C' || cap->cmdchar == 'D') |
5464 curwin->w_curswant = MAXCOL; | |
5465 } | |
5466 cap->cmdchar = *(vim_strchr(trans, cap->cmdchar) + 1); | |
5467 nv_operator(cap); | |
5468 } | |
5469 | |
5470 /* | |
5471 * "s" and "S" commands. | |
5472 */ | |
5473 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5474 nv_subst(cmdarg_T *cap) |
7 | 5475 { |
13298
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5476 #ifdef FEAT_TERMINAL |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
23165
diff
changeset
|
5477 // 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
|
5478 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
|
5479 return; |
a88c5e12b860
patch 8.0.1523: cannot write and read terminal screendumps
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
5480 #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
|
5481 #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
|
5482 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
|
5483 { |
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
|
5484 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
|
5485 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
|
5486 } |
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
|
5487 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5488 if (VIsual_active) // "vs" and "vS" are the same as "vc" |
7 | 5489 { |
5490 if (cap->cmdchar == 'S') | |
4213 | 5491 { |
5492 VIsual_mode_orig = VIsual_mode; | |
7 | 5493 VIsual_mode = 'V'; |
4213 | 5494 } |
7 | 5495 cap->cmdchar = 'c'; |
5496 nv_operator(cap); | |
5497 } | |
5498 else | |
5499 nv_optrans(cap); | |
5500 } | |
5501 | |
5502 /* | |
5503 * Abbreviated commands. | |
5504 */ | |
5505 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5506 nv_abbrev(cmdarg_T *cap) |
7 | 5507 { |
5508 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
|
5509 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
|
5510 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5511 // in Visual mode these commands are operators |
7 | 5512 if (VIsual_active) |
5513 v_visop(cap); | |
5514 else | |
5515 nv_optrans(cap); | |
5516 } | |
5517 | |
5518 /* | |
5519 * Translate a command into another command. | |
5520 */ | |
5521 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5522 nv_optrans(cmdarg_T *cap) |
7 | 5523 { |
5524 static char_u *(ar[8]) = {(char_u *)"dl", (char_u *)"dh", | |
5525 (char_u *)"d$", (char_u *)"c$", | |
5526 (char_u *)"cl", (char_u *)"cc", | |
5527 (char_u *)"yy", (char_u *)":s\r"}; | |
5528 static char_u *str = (char_u *)"xXDCsSY&"; | |
5529 | |
5530 if (!checkclearopq(cap->oap)) | |
5531 { | |
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
|
5532 // 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
|
5533 // either, because "2." should also not use the count. |
164 | 5534 if (cap->cmdchar == 'D' && vim_strchr(p_cpo, CPO_HASH) != NULL) |
5535 { | |
5536 cap->oap->start = curwin->w_cursor; | |
5537 cap->oap->op_type = OP_DELETE; | |
1490 | 5538 #ifdef FEAT_EVAL |
5539 set_op_var(OP_DELETE); | |
5540 #endif | |
164 | 5541 cap->count1 = 1; |
5542 nv_dollar(cap); | |
5543 finish_op = TRUE; | |
5544 ResetRedobuff(); | |
5545 AppendCharToRedobuff('D'); | |
5546 } | |
5547 else | |
5548 { | |
5549 if (cap->count0) | |
5550 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
|
5551 stuffReadbuff(ar[(int)(vim_strchr(str, cap->cmdchar) - str)]); |
164 | 5552 } |
7 | 5553 } |
5554 cap->opcount = 0; | |
5555 } | |
5556 | |
5557 /* | |
5558 * "'" and "`" commands. Also for "g'" and "g`". | |
5559 * cap->arg is TRUE for "'" and "g'". | |
5560 */ | |
5561 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5562 nv_gomark(cmdarg_T *cap) |
7 | 5563 { |
5564 pos_T *pos; | |
5565 int c; | |
5566 #ifdef FEAT_FOLDING | |
4017 | 5567 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
|
5568 int old_KeyTyped = KeyTyped; // getting file may reset it |
7 | 5569 #endif |
5570 | |
5571 if (cap->cmdchar == 'g') | |
5572 c = cap->extra_char; | |
5573 else | |
5574 c = cap->nchar; | |
5575 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
|
5576 if (pos == (pos_T *)-1) // jumped to other file |
7 | 5577 { |
5578 if (cap->arg) | |
5579 { | |
5580 check_cursor_lnum(); | |
5581 beginline(BL_WHITE | BL_FIX); | |
5582 } | |
5583 else | |
5584 check_cursor(); | |
5585 } | |
5586 else | |
5587 nv_cursormark(cap, cap->arg, pos); | |
5588 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5589 // May need to clear the coladd that a mark includes. |
7 | 5590 if (!virtual_active()) |
5591 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
|
5592 check_cursor_col(); |
7 | 5593 #ifdef FEAT_FOLDING |
5594 if (cap->oap->op_type == OP_NOP | |
4057 | 5595 && pos != NULL |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
5596 && (pos == (pos_T *)-1 || !EQUAL_POS(old_cursor, *pos)) |
7 | 5597 && (fdo_flags & FDO_MARK) |
5598 && old_KeyTyped) | |
5599 foldOpenCursor(); | |
5600 #endif | |
5601 } | |
5602 | |
5603 /* | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5604 * Handle CTRL-O, CTRL-I, "g;", "g," and "CTRL-Tab" commands. |
7 | 5605 */ |
5606 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5607 nv_pcmark(cmdarg_T *cap) |
7 | 5608 { |
5609 pos_T *pos; | |
26532
255bc9a08e58
patch 8.2.3795: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
26516
diff
changeset
|
5610 #ifdef FEAT_FOLDING |
7 | 5611 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
|
5612 int old_KeyTyped = KeyTyped; // getting file may reset it |
26532
255bc9a08e58
patch 8.2.3795: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
26516
diff
changeset
|
5613 #endif |
7 | 5614 |
5615 if (!checkclearopq(cap->oap)) | |
5616 { | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5617 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
|
5618 { |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5619 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
|
5620 clearopbeep(cap->oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5621 return; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
5622 } |
7 | 5623 if (cap->cmdchar == 'g') |
5624 pos = movechangelist((int)cap->count1); | |
5625 else | |
5626 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
|
5627 if (pos == (pos_T *)-1) // jump to other file |
7 | 5628 { |
5629 curwin->w_set_curswant = TRUE; | |
5630 check_cursor(); | |
5631 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5632 else if (pos != NULL) // can jump |
7 | 5633 nv_cursormark(cap, FALSE, pos); |
5634 else if (cap->cmdchar == 'g') | |
5635 { | |
5636 if (curbuf->b_changelistlen == 0) | |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5637 emsg(_(e_changelist_is_empty)); |
7 | 5638 else if (cap->count1 < 0) |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5639 emsg(_(e_at_start_of_changelist)); |
7 | 5640 else |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26929
diff
changeset
|
5641 emsg(_(e_at_end_of_changelist)); |
7 | 5642 } |
5643 else | |
5644 clearopbeep(cap->oap); | |
5645 # ifdef FEAT_FOLDING | |
5646 if (cap->oap->op_type == OP_NOP | |
5647 && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum) | |
5648 && (fdo_flags & FDO_MARK) | |
5649 && old_KeyTyped) | |
5650 foldOpenCursor(); | |
5651 # endif | |
5652 } | |
5653 } | |
5654 | |
5655 /* | |
5656 * Handle '"' command. | |
5657 */ | |
5658 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5659 nv_regname(cmdarg_T *cap) |
7 | 5660 { |
5661 if (checkclearop(cap->oap)) | |
5662 return; | |
5663 #ifdef FEAT_EVAL | |
5664 if (cap->nchar == '=') | |
5665 cap->nchar = get_expr_register(); | |
5666 #endif | |
5667 if (cap->nchar != NUL && valid_yank_reg(cap->nchar, FALSE)) | |
5668 { | |
5669 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
|
5670 cap->opcount = cap->count0; // remember count before '"' |
7 | 5671 #ifdef FEAT_EVAL |
5672 set_reg_var(cap->oap->regname); | |
5673 #endif | |
5674 } | |
5675 else | |
5676 clearopbeep(cap->oap); | |
5677 } | |
5678 | |
5679 /* | |
5680 * Handle "v", "V" and "CTRL-V" commands. | |
5681 * Also for "gh", "gH" and "g^H" commands: Always start Select mode, cap->arg | |
5682 * is TRUE. | |
167 | 5683 * Handle CTRL-Q just like CTRL-V. |
7 | 5684 */ |
5685 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5686 nv_visual(cmdarg_T *cap) |
7 | 5687 { |
167 | 5688 if (cap->cmdchar == Ctrl_Q) |
5689 cap->cmdchar = Ctrl_V; | |
5690 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5691 // '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
|
5692 // characterwise, linewise, or blockwise. |
7 | 5693 if (cap->oap->op_type != OP_NOP) |
5694 { | |
15279
54457fc4af0b
patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
5695 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
|
5696 finish_op = FALSE; // operator doesn't finish now but later |
7 | 5697 return; |
5698 } | |
5699 | |
5700 VIsual_select = cap->arg; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5701 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
|
5702 { |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5703 if (VIsual_mode == cap->cmdchar) // stop visual mode |
7 | 5704 end_visual_mode(); |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5705 else // toggle char/block mode |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5706 { // or char/line mode |
7 | 5707 VIsual_mode = cap->cmdchar; |
5708 showmode(); | |
25790
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25786
diff
changeset
|
5709 trigger_modechanged(); |
7 | 5710 } |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5711 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
|
5712 } |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5713 else // start Visual mode |
7 | 5714 { |
5715 check_visual_highlight(); | |
3537 | 5716 if (cap->count0 > 0 && resel_VIsual_mode != NUL) |
5717 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5718 // use previously selected part |
7 | 5719 VIsual = curwin->w_cursor; |
5720 | |
5721 VIsual_active = TRUE; | |
5722 VIsual_reselect = TRUE; | |
5723 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5724 // start Select mode when 'selectmode' contains "cmd" |
7 | 5725 may_start_select('c'); |
5726 setmouse(); | |
641 | 5727 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
|
5728 redraw_cmdline = TRUE; // show visual mode later |
7 | 5729 /* |
5730 * For V and ^V, we multiply the number of lines even if there | |
5731 * was only one -- webb | |
5732 */ | |
5733 if (resel_VIsual_mode != 'v' || resel_VIsual_line_count > 1) | |
5734 { | |
5735 curwin->w_cursor.lnum += | |
5736 resel_VIsual_line_count * cap->count0 - 1; | |
25921
203b0f3a741a
patch 8.2.3494: illegal memory access in utf_head_off
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
5737 check_cursor(); |
7 | 5738 } |
5739 VIsual_mode = resel_VIsual_mode; | |
5740 if (VIsual_mode == 'v') | |
5741 { | |
5742 if (resel_VIsual_line_count <= 1) | |
3125 | 5743 { |
5744 validate_virtcol(); | |
5745 curwin->w_curswant = curwin->w_virtcol | |
5746 + resel_VIsual_vcol * cap->count0 - 1; | |
5747 } | |
7 | 5748 else |
3125 | 5749 curwin->w_curswant = resel_VIsual_vcol; |
5750 coladvance(curwin->w_curswant); | |
7 | 5751 } |
3125 | 5752 if (resel_VIsual_vcol == MAXCOL) |
7 | 5753 { |
5754 curwin->w_curswant = MAXCOL; | |
5755 coladvance((colnr_T)MAXCOL); | |
5756 } | |
5757 else if (VIsual_mode == Ctrl_V) | |
5758 { | |
5759 validate_virtcol(); | |
5760 curwin->w_curswant = curwin->w_virtcol | |
3125 | 5761 + resel_VIsual_vcol * cap->count0 - 1; |
7 | 5762 coladvance(curwin->w_curswant); |
5763 } | |
5764 else | |
5765 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
|
5766 redraw_curbuf_later(INVERTED); // show the inversion |
7 | 5767 } |
5768 else | |
5769 { | |
5770 if (!cap->arg) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5771 // start Select mode when 'selectmode' contains "cmd" |
7 | 5772 may_start_select('c'); |
5773 n_start_visual_mode(cap->cmdchar); | |
3537 | 5774 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
|
5775 ++cap->count1; // include one more char |
3537 | 5776 if (cap->count0 > 0 && --cap->count1 > 0) |
5777 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5778 // With a count select that many characters or lines. |
3537 | 5779 if (VIsual_mode == 'v' || VIsual_mode == Ctrl_V) |
5780 nv_right(cap); | |
5781 else if (VIsual_mode == 'V') | |
5782 nv_down(cap); | |
5783 } | |
7 | 5784 } |
5785 } | |
5786 } | |
5787 | |
5788 /* | |
5789 * Start selection for Shift-movement keys. | |
5790 */ | |
5791 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5792 start_selection(void) |
7 | 5793 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5794 // if 'selectmode' contains "key", start Select mode |
7 | 5795 may_start_select('k'); |
5796 n_start_visual_mode('v'); | |
5797 } | |
5798 | |
5799 /* | |
5800 * Start Select mode, if "c" is in 'selectmode' and not in a mapping or menu. | |
5801 */ | |
5802 void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5803 may_start_select(int c) |
7 | 5804 { |
5805 VIsual_select = (stuff_empty() && typebuf_typed() | |
5806 && (vim_strchr(p_slm, c) != NULL)); | |
5807 } | |
5808 | |
5809 /* | |
5810 * Start Visual mode "c". | |
5811 * Should set VIsual_select before calling this. | |
5812 */ | |
5813 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5814 n_start_visual_mode(int c) |
7 | 5815 { |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5816 #ifdef FEAT_CONCEAL |
25074
aa55d6d17625
patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5817 int cursor_line_was_concealed = curwin->w_p_cole > 0 |
aa55d6d17625
patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5818 && conceal_cursor_line(curwin); |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5819 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5820 |
7 | 5821 VIsual_mode = c; |
5822 VIsual_active = TRUE; | |
5823 VIsual_reselect = TRUE; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5824 |
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
5825 // 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
|
5826 // virtualedit. Recalculate curwin->w_cursor to avoid bad highlighting. |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25074
diff
changeset
|
5827 if (c == Ctrl_V && (get_ve_flags() & VE_BLOCK) && gchar_cursor() == TAB) |
3742 | 5828 { |
5829 validate_virtcol(); | |
7 | 5830 coladvance(curwin->w_virtcol); |
3742 | 5831 } |
7 | 5832 VIsual = curwin->w_cursor; |
5833 | |
5834 #ifdef FEAT_FOLDING | |
5835 foldAdjustVisual(); | |
5836 #endif | |
5837 | |
26157
20200363816c
patch 8.2.3610: crash when ModeChanged triggered too early
Bram Moolenaar <Bram@vim.org>
parents:
26101
diff
changeset
|
5838 trigger_modechanged(); |
7 | 5839 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
|
5840 #ifdef FEAT_CONCEAL |
25074
aa55d6d17625
patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5841 // Check if redraw is needed after changing the state. |
aa55d6d17625
patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5842 conceal_check_cursor_line(cursor_line_was_concealed); |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5843 #endif |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5844 |
641 | 5845 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
|
5846 redraw_cmdline = TRUE; // show visual mode later |
7 | 5847 #ifdef FEAT_CLIPBOARD |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5848 // 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
|
5849 // end may still be the same, and the selection needs to be owned |
7 | 5850 clip_star.vmode = NUL; |
5851 #endif | |
5852 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5853 // 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
|
5854 // Visual area (when 'lazyredraw' is set). |
7 | 5855 if (curwin->w_redr_type < INVERTED) |
5856 { | |
5857 curwin->w_old_cursor_lnum = curwin->w_cursor.lnum; | |
5858 curwin->w_old_visual_lnum = curwin->w_cursor.lnum; | |
5859 } | |
5860 } | |
5861 | |
5862 | |
5863 /* | |
5864 * CTRL-W: Window commands | |
5865 */ | |
5866 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5867 nv_window(cmdarg_T *cap) |
7 | 5868 { |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5869 if (cap->nchar == ':') |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5870 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5871 // "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
|
5872 cap->cmdchar = ':'; |
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5873 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
|
5874 nv_colon(cap); |
13072
50aa6da392ce
patch 8.0.1411: reading invalid memory with CTRL-W :
Christian Brabandt <cb@256bit.org>
parents:
12924
diff
changeset
|
5875 } |
11684
1ce1376fbbf8
patch 8.0.0725: a terminal window does not handle keyboard input
Christian Brabandt <cb@256bit.org>
parents:
11529
diff
changeset
|
5876 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
|
5877 do_window(cap->nchar, cap->count0, NUL); // everything is in window.c |
7 | 5878 } |
5879 | |
5880 /* | |
5881 * CTRL-Z: Suspend | |
5882 */ | |
5883 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5884 nv_suspend(cmdarg_T *cap) |
7 | 5885 { |
5886 clearop(cap->oap); | |
5887 if (VIsual_active) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5888 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
|
5889 do_cmdline_cmd((char_u *)"stop"); |
7 | 5890 } |
5891 | |
5892 /* | |
5893 * Commands starting with "g". | |
5894 */ | |
5895 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
5896 nv_g_cmd(cmdarg_T *cap) |
7 | 5897 { |
5898 oparg_T *oap = cap->oap; | |
5899 pos_T tpos; | |
5900 int i; | |
5901 int flag = FALSE; | |
5902 | |
5903 switch (cap->nchar) | |
5904 { | |
6868 | 5905 case Ctrl_A: |
5906 case Ctrl_X: | |
7 | 5907 #ifdef MEM_PROFILE |
5908 /* | |
5909 * "g^A": dump log of used memory. | |
5910 */ | |
6868 | 5911 if (!VIsual_active && cap->nchar == Ctrl_A) |
5912 vim_mem_profile_dump(); | |
5913 else | |
5914 #endif | |
5915 /* | |
5916 * "g^A/g^X": sequentially increment visually selected region | |
5917 */ | |
5918 if (VIsual_active) | |
5919 { | |
5920 cap->arg = TRUE; | |
5921 cap->cmdchar = cap->nchar; | |
7574
b872724c37db
commit https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e
Christian Brabandt <cb@256bit.org>
parents:
7568
diff
changeset
|
5922 cap->nchar = NUL; |
6868 | 5923 nv_addsub(cap); |
5924 } | |
5925 else | |
5926 clearopbeep(oap); | |
7 | 5927 break; |
5928 | |
5929 /* | |
5930 * "gR": Enter virtual replace mode. | |
5931 */ | |
5932 case 'R': | |
5933 cap->arg = TRUE; | |
5934 nv_Replace(cap); | |
5935 break; | |
5936 | |
5937 case 'r': | |
5938 nv_vreplace(cap); | |
5939 break; | |
5940 | |
5941 case '&': | |
5942 do_cmdline_cmd((char_u *)"%s//~/&"); | |
5943 break; | |
5944 | |
5945 /* | |
5946 * "gv": Reselect the previous Visual area. If Visual already active, | |
5947 * exchange previous and current Visual area. | |
5948 */ | |
5949 case 'v': | |
5950 if (checkclearop(oap)) | |
5951 break; | |
5952 | |
690 | 5953 if ( curbuf->b_visual.vi_start.lnum == 0 |
5954 || curbuf->b_visual.vi_start.lnum > curbuf->b_ml.ml_line_count | |
5955 || curbuf->b_visual.vi_end.lnum == 0) | |
7 | 5956 beep_flush(); |
5957 else | |
5958 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5959 // set w_cursor to the start of the Visual area, tpos to the end |
7 | 5960 if (VIsual_active) |
5961 { | |
5962 i = VIsual_mode; | |
690 | 5963 VIsual_mode = curbuf->b_visual.vi_mode; |
5964 curbuf->b_visual.vi_mode = i; | |
7 | 5965 # ifdef FEAT_EVAL |
5966 curbuf->b_visual_mode_eval = i; | |
5967 # endif | |
5968 i = curwin->w_curswant; | |
690 | 5969 curwin->w_curswant = curbuf->b_visual.vi_curswant; |
5970 curbuf->b_visual.vi_curswant = i; | |
5971 | |
5972 tpos = curbuf->b_visual.vi_end; | |
5973 curbuf->b_visual.vi_end = curwin->w_cursor; | |
5974 curwin->w_cursor = curbuf->b_visual.vi_start; | |
5975 curbuf->b_visual.vi_start = VIsual; | |
7 | 5976 } |
5977 else | |
5978 { | |
690 | 5979 VIsual_mode = curbuf->b_visual.vi_mode; |
5980 curwin->w_curswant = curbuf->b_visual.vi_curswant; | |
5981 tpos = curbuf->b_visual.vi_end; | |
5982 curwin->w_cursor = curbuf->b_visual.vi_start; | |
7 | 5983 } |
5984 | |
5985 VIsual_active = TRUE; | |
5986 VIsual_reselect = TRUE; | |
5987 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
5988 // 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
|
5989 // area. Make sure they are on an existing character. |
7 | 5990 check_cursor(); |
5991 VIsual = curwin->w_cursor; | |
5992 curwin->w_cursor = tpos; | |
5993 check_cursor(); | |
5994 update_topline(); | |
5995 /* | |
5996 * When called from normal "g" command: start Select mode when | |
5997 * 'selectmode' contains "cmd". When called for K_SELECT, always | |
5998 * start Select mode. | |
5999 */ | |
6000 if (cap->arg) | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6001 { |
7 | 6002 VIsual_select = TRUE; |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6003 VIsual_select_reg = 0; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6004 } |
7 | 6005 else |
6006 may_start_select('c'); | |
6007 setmouse(); | |
6008 #ifdef FEAT_CLIPBOARD | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6009 // 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
|
6010 // end are still the same, and the selection needs to be owned |
7 | 6011 clip_star.vmode = NUL; |
6012 #endif | |
6013 redraw_curbuf_later(INVERTED); | |
6014 showmode(); | |
6015 } | |
6016 break; | |
6017 /* | |
6018 * "gV": Don't reselect the previous Visual area after a Select mode | |
6019 * mapping of menu. | |
6020 */ | |
6021 case 'V': | |
6022 VIsual_reselect = FALSE; | |
6023 break; | |
6024 | |
6025 /* | |
6026 * "gh": start Select mode. | |
6027 * "gH": start Select line mode. | |
6028 * "g^H": start Select block mode. | |
6029 */ | |
6030 case K_BS: | |
6031 cap->nchar = Ctrl_H; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6032 // FALLTHROUGH |
7 | 6033 case 'h': |
6034 case 'H': | |
6035 case Ctrl_H: | |
6036 # ifdef EBCDIC | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6037 // EBCDIC: 'v'-'h' != '^v'-'^h' |
7 | 6038 if (cap->nchar == Ctrl_H) |
6039 cap->cmdchar = Ctrl_V; | |
6040 else | |
6041 # endif | |
6042 cap->cmdchar = cap->nchar + ('v' - 'h'); | |
6043 cap->arg = TRUE; | |
6044 nv_visual(cap); | |
6045 break; | |
3701 | 6046 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6047 // "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
|
6048 // "gn" selects next match |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6049 // "gN" selects previous match |
3701 | 6050 case 'N': |
6051 case 'n': | |
6052 if (!current_search(cap->count1, cap->nchar == 'n')) | |
3896 | 6053 clearopbeep(oap); |
3701 | 6054 break; |
7 | 6055 |
6056 /* | |
6057 * "gj" and "gk" two new funny movement keys -- up and down | |
6058 * movement based on *screen* line rather than *file* line. | |
6059 */ | |
6060 case 'j': | |
6061 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
|
6062 // 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
|
6063 if (!curwin->w_p_wrap) |
7 | 6064 { |
6065 oap->motion_type = MLINE; | |
6066 i = cursor_down(cap->count1, oap->op_type == OP_NOP); | |
6067 } | |
6068 else | |
6069 i = nv_screengo(oap, FORWARD, cap->count1); | |
6070 if (i == FAIL) | |
6071 clearopbeep(oap); | |
6072 break; | |
6073 | |
6074 case 'k': | |
6075 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
|
6076 // 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
|
6077 if (!curwin->w_p_wrap) |
7 | 6078 { |
6079 oap->motion_type = MLINE; | |
6080 i = cursor_up(cap->count1, oap->op_type == OP_NOP); | |
6081 } | |
6082 else | |
6083 i = nv_screengo(oap, BACKWARD, cap->count1); | |
6084 if (i == FAIL) | |
6085 clearopbeep(oap); | |
6086 break; | |
6087 | |
6088 /* | |
6089 * "gJ": join two lines without inserting a space. | |
6090 */ | |
6091 case 'J': | |
6092 nv_join(cap); | |
6093 break; | |
6094 | |
6095 /* | |
6096 * "g0", "g^" and "g$": Like "0", "^" and "$" but for screen lines. | |
6097 * "gm": middle of "g0" and "g$". | |
6098 */ | |
6099 case '^': | |
6100 flag = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6101 // FALLTHROUGH |
7 | 6102 |
6103 case '0': | |
6104 case 'm': | |
6105 case K_HOME: | |
6106 case K_KHOME: | |
6107 oap->motion_type = MCHAR; | |
6108 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
|
6109 if (curwin->w_p_wrap && curwin->w_width != 0) |
7 | 6110 { |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6111 int width1 = curwin->w_width - curwin_col_off(); |
7 | 6112 int width2 = width1 + curwin_col_off2(); |
6113 | |
6114 validate_virtcol(); | |
6115 i = 0; | |
6116 if (curwin->w_virtcol >= (colnr_T)width1 && width2 > 0) | |
6117 i = (curwin->w_virtcol - width1) / width2 * width2 + width1; | |
6118 } | |
6119 else | |
6120 i = curwin->w_leftcol; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6121 // 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
|
6122 // '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
|
6123 // to the left. |
7 | 6124 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
|
6125 i += (curwin->w_width - curwin_col_off() |
7 | 6126 + ((curwin->w_p_wrap && i > 0) |
6127 ? curwin_col_off2() : 0)) / 2; | |
6128 coladvance((colnr_T)i); | |
6129 if (flag) | |
6130 { | |
6131 do | |
6132 i = gchar_cursor(); | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6133 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
|
6134 curwin->w_valid &= ~VALID_WCOL; |
7 | 6135 } |
6136 curwin->w_set_curswant = TRUE; | |
6137 break; | |
6138 | |
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
|
6139 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
|
6140 { |
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
|
6141 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
|
6142 oap->inclusive = FALSE; |
26749
efe4c8a79502
patch 8.2.3903: "gM" does not count tabs as expected
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
6143 i = linetabsize(ml_get_curline()); |
18475
709c6b0dc78f
patch 8.1.2231: not easy to move to the middle of a text line
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
6144 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
|
6145 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
|
6146 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
|
6147 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
|
6148 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
|
6149 } |
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
|
6150 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
|
6151 |
7 | 6152 case '_': |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6153 // "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
|
6154 // downward. |
7 | 6155 cap->oap->motion_type = MCHAR; |
6156 cap->oap->inclusive = TRUE; | |
6157 curwin->w_curswant = MAXCOL; | |
6158 if (cursor_down((long)(cap->count1 - 1), | |
6159 cap->oap->op_type == OP_NOP) == FAIL) | |
6160 clearopbeep(cap->oap); | |
6161 else | |
6162 { | |
6163 char_u *ptr = ml_get_curline(); | |
6164 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6165 // In Visual mode we may end up after the line. |
7 | 6166 if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) |
6167 --curwin->w_cursor.col; | |
6168 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6169 // Decrease the cursor column until it's on a non-blank. |
7 | 6170 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
|
6171 && VIM_ISWHITE(ptr[curwin->w_cursor.col])) |
7 | 6172 --curwin->w_cursor.col; |
6173 curwin->w_set_curswant = TRUE; | |
2040
70c67b1bb1f1
updated for version 7.2.329
Bram Moolenaar <bram@zimbu.org>
parents:
2024
diff
changeset
|
6174 adjust_for_sel(cap); |
7 | 6175 } |
6176 break; | |
6177 | |
6178 case '$': | |
6179 case K_END: | |
6180 case K_KEND: | |
6181 { | |
6182 int col_off = curwin_col_off(); | |
6183 | |
6184 oap->motion_type = MCHAR; | |
6185 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
|
6186 if (curwin->w_p_wrap && curwin->w_width != 0) |
7 | 6187 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6188 curwin->w_curswant = MAXCOL; // so we stay at the end |
7 | 6189 if (cap->count1 == 1) |
6190 { | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6191 int width1 = curwin->w_width - col_off; |
7 | 6192 int width2 = width1 + curwin_col_off2(); |
6193 | |
6194 validate_virtcol(); | |
6195 i = width1 - 1; | |
6196 if (curwin->w_virtcol >= (colnr_T)width1) | |
6197 i += ((curwin->w_virtcol - width1) / width2 + 1) | |
6198 * width2; | |
6199 coladvance((colnr_T)i); | |
5162
c624928fbc49
updated for version 7.4a.007
Bram Moolenaar <bram@vim.org>
parents:
4472
diff
changeset
|
6200 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6201 // Make sure we stick in this column. |
5162
c624928fbc49
updated for version 7.4a.007
Bram Moolenaar <bram@vim.org>
parents:
4472
diff
changeset
|
6202 validate_virtcol(); |
c624928fbc49
updated for version 7.4a.007
Bram Moolenaar <bram@vim.org>
parents:
4472
diff
changeset
|
6203 curwin->w_curswant = curwin->w_virtcol; |
c624928fbc49
updated for version 7.4a.007
Bram Moolenaar <bram@vim.org>
parents:
4472
diff
changeset
|
6204 curwin->w_set_curswant = FALSE; |
7 | 6205 if (curwin->w_cursor.col > 0 && curwin->w_p_wrap) |
6206 { | |
6207 /* | |
6208 * Check for landing on a character that got split at | |
6209 * the end of the line. We do not want to advance to | |
6210 * the next screen line. | |
6211 */ | |
6212 if (curwin->w_virtcol > (colnr_T)i) | |
6213 --curwin->w_cursor.col; | |
6214 } | |
6215 } | |
6216 else if (nv_screengo(oap, FORWARD, cap->count1 - 1) == FAIL) | |
6217 clearopbeep(oap); | |
6218 } | |
6219 else | |
6220 { | |
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
|
6221 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
|
6222 // 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
|
6223 (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
|
6224 |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
6225 i = curwin->w_leftcol + curwin->w_width - col_off - 1; |
7 | 6226 coladvance((colnr_T)i); |
40 | 6227 |
24731
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6228 // if the character doesn't fit move one back |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6229 if (curwin->w_cursor.col > 0 |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6230 && (*mb_ptr2cells)(ml_get_cursor()) > 1) |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6231 { |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6232 colnr_T vcol; |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6233 |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6234 getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol); |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6235 if (vcol >= curwin->w_leftcol + curwin->w_width - col_off) |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6236 --curwin->w_cursor.col; |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6237 } |
a6a4224902f5
patch 8.2.2904: "g$" causes scroll if half a double width char is visible
Bram Moolenaar <Bram@vim.org>
parents:
24586
diff
changeset
|
6238 |
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
|
6239 // Make sure we stick in this column. |
40 | 6240 validate_virtcol(); |
6241 curwin->w_curswant = curwin->w_virtcol; | |
6242 curwin->w_set_curswant = FALSE; | |
7 | 6243 } |
6244 } | |
6245 break; | |
6246 | |
6247 /* | |
6248 * "g*" and "g#", like "*" and "#" but without using "\<" and "\>" | |
6249 */ | |
6250 case '*': | |
6251 case '#': | |
6252 #if POUND != '#' | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6253 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
|
6254 #endif |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6255 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
|
6256 case ']': // :tselect for current identifier |
7 | 6257 nv_ident(cap); |
6258 break; | |
6259 | |
6260 /* | |
6261 * ge and gE: go back to end of word | |
6262 */ | |
6263 case 'e': | |
6264 case 'E': | |
6265 oap->motion_type = MCHAR; | |
6266 curwin->w_set_curswant = TRUE; | |
6267 oap->inclusive = TRUE; | |
6268 if (bckend_word(cap->count1, cap->nchar == 'E', FALSE) == FAIL) | |
6269 clearopbeep(oap); | |
6270 break; | |
6271 | |
6272 /* | |
6273 * "g CTRL-G": display info about cursor position | |
6274 */ | |
6275 case Ctrl_G: | |
7480
a49163681559
commit https://github.com/vim/vim/commit/ed767a2073ef150971b0439a58e7ee582af6984e
Christian Brabandt <cb@256bit.org>
parents:
7311
diff
changeset
|
6276 cursor_pos_info(NULL); |
7 | 6277 break; |
6278 | |
6279 /* | |
6280 * "gi": start Insert at the last position. | |
6281 */ | |
6282 case 'i': | |
6283 if (curbuf->b_last_insert.lnum != 0) | |
6284 { | |
6285 curwin->w_cursor = curbuf->b_last_insert; | |
6286 check_cursor_lnum(); | |
6287 i = (int)STRLEN(ml_get_curline()); | |
6288 if (curwin->w_cursor.col > (colnr_T)i) | |
6289 { | |
6290 if (virtual_active()) | |
6291 curwin->w_cursor.coladd += curwin->w_cursor.col - i; | |
6292 curwin->w_cursor.col = i; | |
6293 } | |
6294 } | |
6295 cap->cmdchar = 'i'; | |
6296 nv_edit(cap); | |
6297 break; | |
6298 | |
6299 /* | |
6300 * "gI": Start insert in column 1. | |
6301 */ | |
6302 case 'I': | |
6303 beginline(0); | |
6304 if (!checkclearopq(oap)) | |
6305 invoke_edit(cap, FALSE, 'g', FALSE); | |
6306 break; | |
6307 | |
6308 #ifdef FEAT_SEARCHPATH | |
6309 /* | |
6310 * "gf": goto file, edit file under cursor | |
6311 * "]f" and "[f": can also be used. | |
6312 */ | |
6313 case 'f': | |
681 | 6314 case 'F': |
7 | 6315 nv_gotofile(cap); |
6316 break; | |
6317 #endif | |
6318 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6319 // "g'm" and "g`m": jump to mark without setting pcmark |
7 | 6320 case '\'': |
6321 cap->arg = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6322 // FALLTHROUGH |
7 | 6323 case '`': |
6324 nv_gomark(cap); | |
6325 break; | |
6326 | |
6327 /* | |
6328 * "gs": Goto sleep. | |
6329 */ | |
6330 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
|
6331 do_sleep(cap->count1 * 1000L, FALSE); |
7 | 6332 break; |
6333 | |
6334 /* | |
6335 * "ga": Display the ascii value of the character under the | |
6336 * cursor. It is displayed in decimal, hex, and octal. -- webb | |
6337 */ | |
6338 case 'a': | |
6339 do_ascii(NULL); | |
6340 break; | |
6341 | |
6342 /* | |
6343 * "g8": Display the bytes used for the UTF-8 character under the | |
6344 * cursor. It is displayed in hex. | |
775 | 6345 * "8g8" finds illegal byte sequence. |
7 | 6346 */ |
6347 case '8': | |
775 | 6348 if (cap->count0 == 8) |
6349 utf_find_illegal(); | |
6350 else | |
6351 show_utf8(); | |
7 | 6352 break; |
6353 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6354 // "g<": show scrollback text |
447 | 6355 case '<': |
6356 show_sb_text(); | |
6357 break; | |
6358 | |
7 | 6359 /* |
6360 * "gg": Goto the first line in file. With a count it goes to | |
6361 * that line number like for "G". -- webb | |
6362 */ | |
6363 case 'g': | |
6364 cap->arg = FALSE; | |
6365 nv_goto(cap); | |
6366 break; | |
6367 | |
6368 /* | |
6369 * Two-character operators: | |
6370 * "gq" Format text | |
6371 * "gw" Format text and keep cursor position | |
6372 * "g~" Toggle the case of the text. | |
6373 * "gu" Change text to lower case. | |
6374 * "gU" Change text to upper case. | |
6375 * "g?" rot13 encoding | |
602 | 6376 * "g@" call 'operatorfunc' |
7 | 6377 */ |
6378 case 'q': | |
6379 case 'w': | |
6380 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
|
6381 // FALLTHROUGH |
7 | 6382 case '~': |
6383 case 'u': | |
6384 case 'U': | |
6385 case '?': | |
602 | 6386 case '@': |
7 | 6387 nv_operator(cap); |
6388 break; | |
6389 | |
6390 /* | |
1188 | 6391 * "gd": Find first occurrence of pattern under the cursor in the |
7 | 6392 * current function |
6393 * "gD": idem, but in the current file. | |
6394 */ | |
6395 case 'd': | |
6396 case 'D': | |
523 | 6397 nv_gd(oap, cap->nchar, (int)cap->count0); |
7 | 6398 break; |
6399 | |
6400 /* | |
6401 * g<*Mouse> : <C-*mouse> | |
6402 */ | |
6403 case K_MIDDLEMOUSE: | |
6404 case K_MIDDLEDRAG: | |
6405 case K_MIDDLERELEASE: | |
6406 case K_LEFTMOUSE: | |
6407 case K_LEFTDRAG: | |
6408 case K_LEFTRELEASE: | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
6409 case K_MOUSEMOVE: |
7 | 6410 case K_RIGHTMOUSE: |
6411 case K_RIGHTDRAG: | |
6412 case K_RIGHTRELEASE: | |
6413 case K_X1MOUSE: | |
6414 case K_X1DRAG: | |
6415 case K_X1RELEASE: | |
6416 case K_X2MOUSE: | |
6417 case K_X2DRAG: | |
6418 case K_X2RELEASE: | |
6419 mod_mask = MOD_MASK_CTRL; | |
6420 (void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0); | |
6421 break; | |
6422 | |
6423 case K_IGNORE: | |
6424 break; | |
6425 | |
6426 /* | |
6427 * "gP" and "gp": same as "P" and "p" but leave cursor just after new text | |
6428 */ | |
6429 case 'p': | |
6430 case 'P': | |
6431 nv_put(cap); | |
6432 break; | |
6433 | |
6434 #ifdef FEAT_BYTEOFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6435 // "go": goto byte count from start of buffer |
7 | 6436 case 'o': |
6437 goto_byte(cap->count0); | |
6438 break; | |
6439 #endif | |
6440 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6441 // "gQ": improved Ex mode |
7 | 6442 case 'Q': |
633 | 6443 if (text_locked()) |
7 | 6444 { |
6445 clearopbeep(cap->oap); | |
633 | 6446 text_locked_msg(); |
7 | 6447 break; |
6448 } | |
631 | 6449 |
7 | 6450 if (!checkclearopq(oap)) |
6451 do_exmode(TRUE); | |
6452 break; | |
6453 | |
6454 case ',': | |
6455 nv_pcmark(cap); | |
6456 break; | |
6457 | |
6458 case ';': | |
6459 cap->count1 = -cap->count1; | |
6460 nv_pcmark(cap); | |
6461 break; | |
6462 | |
667 | 6463 case 't': |
3630 | 6464 if (!checkclearop(oap)) |
6465 goto_tabpage((int)cap->count0); | |
667 | 6466 break; |
682 | 6467 case 'T': |
3630 | 6468 if (!checkclearop(oap)) |
6469 goto_tabpage(-(int)cap->count1); | |
682 | 6470 break; |
667 | 6471 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6472 case TAB: |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6473 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
|
6474 clearopbeep(oap); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6475 break; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21415
diff
changeset
|
6476 |
750 | 6477 case '+': |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6478 case '-': // "g+" and "g-": undo or redo along the timeline |
750 | 6479 if (!checkclearopq(oap)) |
771 | 6480 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
|
6481 FALSE, FALSE, FALSE); |
750 | 6482 break; |
6483 | |
7 | 6484 default: |
6485 clearopbeep(oap); | |
6486 break; | |
6487 } | |
6488 } | |
6489 | |
6490 /* | |
6491 * Handle "o" and "O" commands. | |
6492 */ | |
6493 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6494 n_opencmd(cmdarg_T *cap) |
7 | 6495 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6496 #ifdef FEAT_CONCEAL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6497 linenr_T oldline = curwin->w_cursor.lnum; |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6498 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6499 |
7 | 6500 if (!checkclearopq(cap->oap)) |
6501 { | |
6502 #ifdef FEAT_FOLDING | |
6503 if (cap->cmdchar == 'O') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6504 // Open above the first line of a folded sequence of lines |
7 | 6505 (void)hasFolding(curwin->w_cursor.lnum, |
6506 &curwin->w_cursor.lnum, NULL); | |
6507 else | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6508 // Open below the last line of a folded sequence of lines |
7 | 6509 (void)hasFolding(curwin->w_cursor.lnum, |
6510 NULL, &curwin->w_cursor.lnum); | |
6511 #endif | |
6512 if (u_save((linenr_T)(curwin->w_cursor.lnum - | |
6513 (cap->cmdchar == 'O' ? 1 : 0)), | |
6514 (linenr_T)(curwin->w_cursor.lnum + | |
6515 (cap->cmdchar == 'o' ? 1 : 0)) | |
6516 ) == OK | |
6517 && 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
|
6518 has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, |
26516
9596c652420b
patch 8.2.3787: no proper formatting of a C line comment after a statement
Bram Moolenaar <Bram@vim.org>
parents:
26468
diff
changeset
|
6519 0, NULL) == OK) |
7 | 6520 { |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6521 #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
|
6522 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
|
6523 redrawWinline(curwin, oldline); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
6524 #endif |
6834 | 6525 #ifdef FEAT_SYN_HL |
6821 | 6526 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
|
6527 // force redraw of cursorline |
6821 | 6528 curwin->w_valid &= ~VALID_CROW; |
6834 | 6529 #endif |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6530 // 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
|
6531 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
|
6532 cap->count1 = 1; |
7 | 6533 invoke_edit(cap, FALSE, cap->cmdchar, TRUE); |
6534 } | |
6535 } | |
6536 } | |
6537 | |
6538 /* | |
6539 * "." command: redo last change. | |
6540 */ | |
6541 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6542 nv_dot(cmdarg_T *cap) |
7 | 6543 { |
6544 if (!checkclearopq(cap->oap)) | |
6545 { | |
6546 /* | |
6547 * If "restart_edit" is TRUE, the last but one command is repeated | |
6548 * instead of the last command (inserting text). This is used for | |
6549 * CTRL-O <.> in insert mode. | |
6550 */ | |
6551 if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) | |
6552 clearopbeep(cap->oap); | |
6553 } | |
6554 } | |
6555 | |
6556 /* | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6557 * CTRL-R: undo undo or specify register in select mode |
7 | 6558 */ |
6559 static void | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6560 nv_redo_or_register(cmdarg_T *cap) |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6561 { |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6562 if (VIsual_select && VIsual_active) |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6563 { |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6564 int reg; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6565 // Get register name |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6566 ++no_mapping; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6567 ++allow_keys; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6568 reg = plain_vgetc(); |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6569 LANGMAP_ADJUST(reg, TRUE); |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6570 --no_mapping; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6571 --allow_keys; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6572 |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6573 if (reg == '"') |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6574 // the unnamed register is 0 |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6575 reg = 0; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6576 |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6577 VIsual_select_reg = valid_yank_reg(reg, TRUE) ? reg : 0; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6578 return; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6579 } |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6580 |
7 | 6581 if (!checkclearopq(cap->oap)) |
6582 { | |
6583 u_redo((int)cap->count1); | |
6584 curwin->w_set_curswant = TRUE; | |
6585 } | |
6586 } | |
6587 | |
6588 /* | |
6589 * Handle "U" command. | |
6590 */ | |
6591 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6592 nv_Undo(cmdarg_T *cap) |
7 | 6593 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6594 // In Visual mode and typing "gUU" triggers an operator |
5735 | 6595 if (cap->oap->op_type == OP_UPPER || VIsual_active) |
7 | 6596 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6597 // translate "gUU" to "gUgU" |
7 | 6598 cap->cmdchar = 'g'; |
6599 cap->nchar = 'U'; | |
6600 nv_operator(cap); | |
6601 } | |
6602 else if (!checkclearopq(cap->oap)) | |
6603 { | |
6604 u_undoline(); | |
6605 curwin->w_set_curswant = TRUE; | |
6606 } | |
6607 } | |
6608 | |
6609 /* | |
6610 * '~' command: If tilde is not an operator and Visual is off: swap case of a | |
6611 * single character. | |
6612 */ | |
6613 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6614 nv_tilde(cmdarg_T *cap) |
7 | 6615 { |
5735 | 6616 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
|
6617 { |
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
|
6618 #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
|
6619 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
|
6620 { |
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
|
6621 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
|
6622 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
|
6623 } |
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
|
6624 #endif |
7 | 6625 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
|
6626 } |
7 | 6627 else |
6628 nv_operator(cap); | |
6629 } | |
6630 | |
6631 /* | |
6632 * Handle an operator command. | |
6633 * The actual work is done by do_pending_operator(). | |
6634 */ | |
6635 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6636 nv_operator(cmdarg_T *cap) |
7 | 6637 { |
6638 int op_type; | |
6639 | |
6640 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
|
6641 #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
|
6642 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
|
6643 { |
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
|
6644 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
|
6645 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
|
6646 } |
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
|
6647 #endif |
7 | 6648 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6649 if (op_type == cap->oap->op_type) // double operator works on lines |
7 | 6650 nv_lineop(cap); |
6651 else if (!checkclearop(cap->oap)) | |
6652 { | |
6653 cap->oap->start = curwin->w_cursor; | |
6654 cap->oap->op_type = op_type; | |
1490 | 6655 #ifdef FEAT_EVAL |
6656 set_op_var(op_type); | |
6657 #endif | |
6658 } | |
6659 } | |
6660 | |
6661 #ifdef FEAT_EVAL | |
6662 /* | |
6663 * Set v:operator to the characters for "optype". | |
6664 */ | |
6665 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6666 set_op_var(int optype) |
1490 | 6667 { |
6668 char_u opchars[3]; | |
6669 | |
6670 if (optype == OP_NOP) | |
6671 set_vim_var_string(VV_OP, NULL, 0); | |
6672 else | |
6673 { | |
6674 opchars[0] = get_op_char(optype); | |
6675 opchars[1] = get_extra_op_char(optype); | |
6676 opchars[2] = NUL; | |
6677 set_vim_var_string(VV_OP, opchars, -1); | |
6678 } | |
6679 } | |
6680 #endif | |
7 | 6681 |
6682 /* | |
6683 * Handle linewise operator "dd", "yy", etc. | |
6684 * | |
6685 * "_" is is a strange motion command that helps make operators more logical. | |
6686 * It is actually implemented, but not documented in the real Vi. This motion | |
6687 * command actually refers to "the current line". Commands like "dd" and "yy" | |
6688 * are really an alternate form of "d_" and "y_". It does accept a count, so | |
6689 * "d3_" works to delete 3 lines. | |
6690 */ | |
6691 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6692 nv_lineop(cmdarg_T *cap) |
7 | 6693 { |
6694 cap->oap->motion_type = MLINE; | |
6695 if (cursor_down(cap->count1 - 1L, cap->oap->op_type == OP_NOP) == FAIL) | |
6696 clearopbeep(cap->oap); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6697 else if ( (cap->oap->op_type == OP_DELETE // only with linewise motions |
4011 | 6698 && cap->oap->motion_force != 'v' |
6699 && cap->oap->motion_force != Ctrl_V) | |
7 | 6700 || cap->oap->op_type == OP_LSHIFT |
6701 || cap->oap->op_type == OP_RSHIFT) | |
6702 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
|
6703 else if (cap->oap->op_type != OP_YANK) // 'Y' does not move cursor |
7 | 6704 beginline(BL_WHITE | BL_FIX); |
6705 } | |
6706 | |
6707 /* | |
6708 * <Home> command. | |
6709 */ | |
6710 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6711 nv_home(cmdarg_T *cap) |
7 | 6712 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6713 // CTRL-HOME is like "gg" |
180 | 6714 if (mod_mask & MOD_MASK_CTRL) |
6715 nv_goto(cap); | |
6716 else | |
6717 { | |
6718 cap->count0 = 1; | |
6719 nv_pipe(cap); | |
6720 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6721 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
|
6722 // one-character line). |
7 | 6723 } |
6724 | |
6725 /* | |
6726 * "|" command. | |
6727 */ | |
6728 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6729 nv_pipe(cmdarg_T *cap) |
7 | 6730 { |
6731 cap->oap->motion_type = MCHAR; | |
6732 cap->oap->inclusive = FALSE; | |
6733 beginline(0); | |
6734 if (cap->count0 > 0) | |
6735 { | |
6736 coladvance((colnr_T)(cap->count0 - 1)); | |
6737 curwin->w_curswant = (colnr_T)(cap->count0 - 1); | |
6738 } | |
6739 else | |
6740 curwin->w_curswant = 0; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6741 // 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
|
6742 // we ended; differs if line is too short |
7 | 6743 curwin->w_set_curswant = FALSE; |
6744 } | |
6745 | |
6746 /* | |
6747 * Handle back-word command "b" and "B". | |
6748 * cap->arg is 1 for "B" | |
6749 */ | |
6750 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6751 nv_bck_word(cmdarg_T *cap) |
7 | 6752 { |
6753 cap->oap->motion_type = MCHAR; | |
6754 cap->oap->inclusive = FALSE; | |
6755 curwin->w_set_curswant = TRUE; | |
6756 if (bck_word(cap->count1, cap->arg, FALSE) == FAIL) | |
6757 clearopbeep(cap->oap); | |
6758 #ifdef FEAT_FOLDING | |
6759 else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6760 foldOpenCursor(); | |
6761 #endif | |
6762 } | |
6763 | |
6764 /* | |
6765 * Handle word motion commands "e", "E", "w" and "W". | |
6766 * cap->arg is TRUE for "E" and "W". | |
6767 */ | |
6768 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6769 nv_wordcmd(cmdarg_T *cap) |
7 | 6770 { |
6771 int n; | |
6772 int word_end; | |
6773 int flag = FALSE; | |
1573 | 6774 pos_T startpos = curwin->w_cursor; |
7 | 6775 |
6776 /* | |
6777 * Set inclusive for the "E" and "e" command. | |
6778 */ | |
6779 if (cap->cmdchar == 'e' || cap->cmdchar == 'E') | |
6780 word_end = TRUE; | |
6781 else | |
6782 word_end = FALSE; | |
6783 cap->oap->inclusive = word_end; | |
6784 | |
6785 /* | |
6786 * "cw" and "cW" are a special case. | |
6787 */ | |
6788 if (!word_end && cap->oap->op_type == OP_CHANGE) | |
6789 { | |
6790 n = gchar_cursor(); | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6791 if (n != NUL) // not an empty line |
7 | 6792 { |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
6793 if (VIM_ISWHITE(n)) |
7 | 6794 { |
6795 /* | |
6796 * Reproduce a funny Vi behaviour: "cw" on a blank only | |
6797 * changes one character, not all blanks until the start of | |
6798 * the next word. Only do this when the 'w' flag is included | |
6799 * in 'cpoptions'. | |
6800 */ | |
6801 if (cap->count1 == 1 && vim_strchr(p_cpo, CPO_CW) != NULL) | |
6802 { | |
6803 cap->oap->inclusive = TRUE; | |
6804 cap->oap->motion_type = MCHAR; | |
6805 return; | |
6806 } | |
6807 } | |
6808 else | |
6809 { | |
6810 /* | |
6811 * This is a little strange. To match what the real Vi does, | |
6812 * we effectively map 'cw' to 'ce', and 'cW' to 'cE', provided | |
6813 * that we are not on a space or a TAB. This seems impolite | |
6814 * at first, but it's really more what we mean when we say | |
6815 * 'cw'. | |
6816 * Another strangeness: When standing on the end of a word | |
4352 | 6817 * "ce" will change until the end of the next word, but "cw" |
7 | 6818 * will change only one character! This is done by setting |
6819 * flag. | |
6820 */ | |
6821 cap->oap->inclusive = TRUE; | |
6822 word_end = TRUE; | |
6823 flag = TRUE; | |
6824 } | |
6825 } | |
6826 } | |
6827 | |
6828 cap->oap->motion_type = MCHAR; | |
6829 curwin->w_set_curswant = TRUE; | |
6830 if (word_end) | |
6831 n = end_word(cap->count1, cap->arg, flag, FALSE); | |
6832 else | |
6833 n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP); | |
6834 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6835 // 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
|
6836 // 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
|
6837 if (LT_POS(startpos, curwin->w_cursor)) |
1505 | 6838 adjust_cursor(cap->oap); |
7 | 6839 |
6840 if (n == FAIL && cap->oap->op_type == OP_NOP) | |
6841 clearopbeep(cap->oap); | |
6842 else | |
6843 { | |
6844 adjust_for_sel(cap); | |
6845 #ifdef FEAT_FOLDING | |
6846 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6847 foldOpenCursor(); | |
6848 #endif | |
6849 } | |
6850 } | |
6851 | |
6852 /* | |
1505 | 6853 * Used after a movement command: If the cursor ends up on the NUL after the |
6854 * end of the line, may move it back to the last character and make the motion | |
6855 * inclusive. | |
6856 */ | |
6857 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6858 adjust_cursor(oparg_T *oap) |
1505 | 6859 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6860 // 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
|
6861 // - the column is > 0 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6862 // - 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
|
6863 // - 'virtualedit' is not "all" and not "onemore". |
1505 | 6864 if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL |
6865 && (!VIsual_active || *p_sel == 'o') | |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25074
diff
changeset
|
6866 && !virtual_active() && (get_ve_flags() & VE_ONEMORE) == 0) |
1505 | 6867 { |
6868 --curwin->w_cursor.col; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6869 // prevent cursor from moving on the trail byte |
1505 | 6870 if (has_mbyte) |
6871 mb_adjust_cursor(); | |
6872 oap->inclusive = TRUE; | |
6873 } | |
6874 } | |
6875 | |
6876 /* | |
7 | 6877 * "0" and "^" commands. |
6878 * cap->arg is the argument for beginline(). | |
6879 */ | |
6880 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6881 nv_beginline(cmdarg_T *cap) |
7 | 6882 { |
6883 cap->oap->motion_type = MCHAR; | |
6884 cap->oap->inclusive = FALSE; | |
6885 beginline(cap->arg); | |
6886 #ifdef FEAT_FOLDING | |
6887 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6888 foldOpenCursor(); | |
6889 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6890 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
|
6891 // one-character line). |
7 | 6892 } |
6893 | |
6894 /* | |
6895 * In exclusive Visual mode, may include the last character. | |
6896 */ | |
6897 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6898 adjust_for_sel(cmdarg_T *cap) |
7 | 6899 { |
6900 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
|
6901 && gchar_cursor() != NUL && LT_POS(VIsual, curwin->w_cursor)) |
7 | 6902 { |
6903 if (has_mbyte) | |
6904 inc_cursor(); | |
6905 else | |
6906 ++curwin->w_cursor.col; | |
6907 cap->oap->inclusive = FALSE; | |
6908 } | |
6909 } | |
6910 | |
6911 /* | |
6912 * Exclude last character at end of Visual area for 'selection' == "exclusive". | |
6913 * Should check VIsual_mode before calling this. | |
6914 * Returns TRUE when backed up to the previous line. | |
6915 */ | |
18219
5d67f207f7c3
patch 8.1.2104: the normal.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
6916 int |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6917 unadjust_for_sel(void) |
7 | 6918 { |
6919 pos_T *pp; | |
6920 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6921 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
|
6922 { |
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10980
diff
changeset
|
6923 if (LT_POS(VIsual, curwin->w_cursor)) |
7 | 6924 pp = &curwin->w_cursor; |
6925 else | |
6926 pp = &VIsual; | |
6927 if (pp->coladd > 0) | |
6928 --pp->coladd; | |
6929 else | |
6930 if (pp->col > 0) | |
6931 { | |
6932 --pp->col; | |
2933 | 6933 mb_adjustpos(curbuf, pp); |
7 | 6934 } |
6935 else if (pp->lnum > 1) | |
6936 { | |
6937 --pp->lnum; | |
6938 pp->col = (colnr_T)STRLEN(ml_get(pp->lnum)); | |
6939 return TRUE; | |
6940 } | |
6941 } | |
6942 return FALSE; | |
6943 } | |
6944 | |
6945 /* | |
6946 * SELECT key in Normal or Visual mode: end of Select mode mapping. | |
6947 */ | |
6948 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6949 nv_select(cmdarg_T *cap) |
7 | 6950 { |
6951 if (VIsual_active) | |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6952 { |
7 | 6953 VIsual_select = TRUE; |
27263
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6954 VIsual_select_reg = 0; |
93d4ee1e6113
patch 8.2.4160: cannot change the register used for Select mode delete
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
6955 } |
7 | 6956 else if (VIsual_reselect) |
6957 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6958 cap->nchar = 'v'; // fake "gv" command |
7 | 6959 cap->arg = TRUE; |
6960 nv_g_cmd(cap); | |
6961 } | |
6962 } | |
6963 | |
6964 | |
6965 /* | |
6966 * "G", "gg", CTRL-END, CTRL-HOME. | |
6967 * cap->arg is TRUE for "G". | |
6968 */ | |
6969 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
6970 nv_goto(cmdarg_T *cap) |
7 | 6971 { |
6972 linenr_T lnum; | |
6973 | |
6974 if (cap->arg) | |
6975 lnum = curbuf->b_ml.ml_line_count; | |
6976 else | |
6977 lnum = 1L; | |
6978 cap->oap->motion_type = MLINE; | |
6979 setpcmark(); | |
6980 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
6981 // When a count is given, use it instead of the default lnum |
7 | 6982 if (cap->count0 != 0) |
6983 lnum = cap->count0; | |
6984 if (lnum < 1L) | |
6985 lnum = 1L; | |
6986 else if (lnum > curbuf->b_ml.ml_line_count) | |
6987 lnum = curbuf->b_ml.ml_line_count; | |
6988 curwin->w_cursor.lnum = lnum; | |
6989 beginline(BL_SOL | BL_FIX); | |
6990 #ifdef FEAT_FOLDING | |
6991 if ((fdo_flags & FDO_JUMP) && KeyTyped && cap->oap->op_type == OP_NOP) | |
6992 foldOpenCursor(); | |
6993 #endif | |
6994 } | |
6995 | |
6996 /* | |
6997 * CTRL-\ in Normal mode. | |
6998 */ | |
6999 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7000 nv_normal(cmdarg_T *cap) |
7 | 7001 { |
7002 if (cap->nchar == Ctrl_N || cap->nchar == Ctrl_G) | |
7003 { | |
7004 clearop(cap->oap); | |
643 | 7005 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
|
7006 clear_cmdline = TRUE; // unshow mode later |
7 | 7007 restart_edit = 0; |
7008 #ifdef FEAT_CMDWIN | |
7009 if (cmdwin_type != 0) | |
7010 cmdwin_result = Ctrl_C; | |
7011 #endif | |
7012 if (VIsual_active) | |
7013 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7014 end_visual_mode(); // stop Visual |
7 | 7015 redraw_curbuf_later(INVERTED); |
7016 } | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7017 // CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. |
7 | 7018 if (cap->nchar == Ctrl_G && p_im) |
7019 restart_edit = 'a'; | |
7020 } | |
7021 else | |
7022 clearopbeep(cap->oap); | |
7023 } | |
7024 | |
7025 /* | |
7026 * ESC in Normal mode: beep, but don't flush buffers. | |
7027 * Don't even beep if we are canceling a command. | |
7028 */ | |
7029 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7030 nv_esc(cmdarg_T *cap) |
7 | 7031 { |
7032 int no_reason; | |
7033 | |
7034 no_reason = (cap->oap->op_type == OP_NOP | |
7035 && cap->opcount == 0 | |
7036 && cap->count0 == 0 | |
7037 && cap->oap->regname == 0 | |
7038 && !p_im); | |
7039 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7040 if (cap->arg) // TRUE for CTRL-C |
7 | 7041 { |
7042 if (restart_edit == 0 | |
7043 #ifdef FEAT_CMDWIN | |
7044 && cmdwin_type == 0 | |
7045 #endif | |
7046 && !VIsual_active | |
7047 && 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
|
7048 { |
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
|
7049 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
|
7050 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
|
7051 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
|
7052 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
|
7053 } |
7 | 7054 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7055 // 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
|
7056 // set again below when halfway a mapping. |
7 | 7057 if (!p_im) |
7058 restart_edit = 0; | |
7059 #ifdef FEAT_CMDWIN | |
7060 if (cmdwin_type != 0) | |
7061 { | |
7062 cmdwin_result = K_IGNORE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7063 got_int = FALSE; // don't stop executing autocommands et al. |
7 | 7064 return; |
7065 } | |
7066 #endif | |
7067 } | |
24012
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7068 #ifdef FEAT_CMDWIN |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7069 else if (cmdwin_type != 0 && ex_normal_busy) |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7070 { |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7071 // When :normal runs out of characters while in the command line window |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7072 // vgetorpeek() will return ESC. Exit the cmdline window to break the |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7073 // loop. |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7074 cmdwin_result = K_IGNORE; |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7075 return; |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7076 } |
59b59a5f75d4
patch 8.2.2548: May get stuck in the cmdline window using :normal
Bram Moolenaar <Bram@vim.org>
parents:
24010
diff
changeset
|
7077 #endif |
7 | 7078 |
7079 if (VIsual_active) | |
7080 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7081 end_visual_mode(); // stop Visual |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7082 check_cursor_col(); // make sure cursor is not beyond EOL |
7 | 7083 curwin->w_set_curswant = TRUE; |
7084 redraw_curbuf_later(INVERTED); | |
7085 } | |
5735 | 7086 else if (no_reason) |
6949 | 7087 vim_beep(BO_ESC); |
7 | 7088 clearop(cap->oap); |
7089 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7090 // 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
|
7091 // 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
|
7092 if (restart_edit == 0 && goto_im() && ex_normal_busy == 0) |
7 | 7093 restart_edit = 'a'; |
7094 } | |
7095 | |
7096 /* | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7097 * 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
|
7098 */ |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7099 void |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7100 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
|
7101 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7102 curwin->w_set_curswant = TRUE; |
25380
ac88cd21ae88
patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents:
25074
diff
changeset
|
7103 if (get_ve_flags() == VE_ALL) |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7104 { |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7105 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
|
7106 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7107 // 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
|
7108 // 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
|
7109 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
|
7110 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
|
7111 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
|
7112 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7113 else |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7114 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
|
7115 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7116 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17787
diff
changeset
|
7117 /* |
7 | 7118 * 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
|
7119 * Also handle K_PS, start bracketed paste. |
7 | 7120 */ |
7121 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7122 nv_edit(cmdarg_T *cap) |
7 | 7123 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7124 // <Insert> is equal to "i" |
7 | 7125 if (cap->cmdchar == K_INS || cap->cmdchar == K_KINS) |
7126 cap->cmdchar = 'i'; | |
7127 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7128 // in Visual mode "A" and "I" are an operator |
7 | 7129 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
|
7130 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
7131 #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
|
7132 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
|
7133 { |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
7134 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
|
7135 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
|
7136 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
|
7137 return; |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
7138 } |
66fe20238c1d
patch 8.0.1113: can go to Insert mode from Terminal-Normal mode
Christian Brabandt <cb@256bit.org>
parents:
12423
diff
changeset
|
7139 #endif |
7 | 7140 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
|
7141 } |
7 | 7142 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7143 // in Visual mode and after an operator "a" and "i" are for text objects |
5735 | 7144 else if ((cap->cmdchar == 'a' || cap->cmdchar == 'i') |
7145 && (cap->oap->op_type != OP_NOP || VIsual_active)) | |
7 | 7146 { |
7147 #ifdef FEAT_TEXTOBJ | |
7148 nv_object(cap); | |
7149 #else | |
7150 clearopbeep(cap->oap); | |
7151 #endif | |
7152 } | |
11892
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
7153 #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
|
7154 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
|
7155 { |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
7156 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
|
7157 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
|
7158 return; |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
7159 } |
50ad151a7482
patch 8.0.0826: cannot use text objects in Terminal mode
Christian Brabandt <cb@256bit.org>
parents:
11866
diff
changeset
|
7160 #endif |
7 | 7161 else if (!curbuf->b_p_ma && !p_im) |
7162 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7163 // Only give this error when 'insertmode' is off. |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24866
diff
changeset
|
7164 emsg(_(e_cannot_make_changes_modifiable_is_off)); |
7 | 7165 clearop(cap->oap); |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7166 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
|
7167 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7168 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 7169 } |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7170 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
|
7171 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7172 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
|
7173 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
|
7174 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7175 // 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
|
7176 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
|
7177 { |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7178 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
|
7179 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
|
7180 } |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7181 else |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7182 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
|
7183 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
|
7184 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
|
7185 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
|
7186 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
|
7187 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
|
7188 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7189 // 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
|
7190 // 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
|
7191 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
|
7192 && 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
|
7193 inc_cursor(); |
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7194 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7195 // 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
|
7196 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
|
7197 } |
7 | 7198 else if (!checkclearopq(cap->oap)) |
7199 { | |
7200 switch (cap->cmdchar) | |
7201 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7202 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
|
7203 set_cursor_for_append_to_line(); |
7 | 7204 break; |
7205 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7206 case 'I': // "I"nsert before the first non-blank |
164 | 7207 if (vim_strchr(p_cpo, CPO_INSEND) == NULL) |
7208 beginline(BL_WHITE); | |
7209 else | |
7210 beginline(BL_WHITE|BL_FIX); | |
7 | 7211 break; |
7212 | |
10827
e366b968bf08
patch 8.0.0303: bracketed paste does not work in Visual mode
Christian Brabandt <cb@256bit.org>
parents:
10813
diff
changeset
|
7213 case K_PS: |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7214 // 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
|
7215 // 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
|
7216 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
|
7217 break; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7218 // FALLTHROUGH |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7219 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7220 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
|
7221 // 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
|
7222 // column otherwise, also to append after an unprintable char |
7 | 7223 if (virtual_active() |
7224 && (curwin->w_cursor.coladd > 0 | |
7225 || *ml_get_cursor() == NUL | |
7226 || *ml_get_cursor() == TAB)) | |
7227 curwin->w_cursor.coladd++; | |
15636
6f1c7e9a6393
patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
7228 else if (*ml_get_cursor() != NUL) |
7 | 7229 inc_cursor(); |
7230 break; | |
7231 } | |
7232 | |
7233 if (curwin->w_cursor.coladd && cap->cmdchar != 'A') | |
7234 { | |
7235 int save_State = State; | |
7236 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7237 // 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
|
7238 // character past the end of the line |
7 | 7239 State = INSERT; |
7240 coladvance(getviscol()); | |
7241 State = save_State; | |
7242 } | |
7243 | |
7244 invoke_edit(cap, FALSE, cap->cmdchar, FALSE); | |
7245 } | |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7246 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
|
7247 // drop the pasted text |
10640
27be410d6d29
patch 8.0.0210: no support for bracketed paste
Christian Brabandt <cb@256bit.org>
parents:
10636
diff
changeset
|
7248 bracketed_paste(PASTE_INSERT, TRUE, NULL); |
7 | 7249 } |
7250 | |
7251 /* | |
7252 * Invoke edit() and take care of "restart_edit" and the return value. | |
7253 */ | |
7254 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7255 invoke_edit( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7256 cmdarg_T *cap, |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7257 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
|
7258 int cmd, |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7259 int startln) |
7 | 7260 { |
7261 int restart_edit_save = 0; | |
7262 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7263 // 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
|
7264 // 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
|
7265 // it. |
7 | 7266 if (repl || !stuff_empty()) |
7267 restart_edit_save = restart_edit; | |
7268 else | |
7269 restart_edit_save = 0; | |
7270 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7271 // Always reset "restart_edit", this is not a restarted edit. |
7 | 7272 restart_edit = 0; |
7273 | |
7274 if (edit(cmd, startln, cap->count1)) | |
7275 cap->retval |= CA_COMMAND_BUSY; | |
7276 | |
7277 if (restart_edit == 0) | |
7278 restart_edit = restart_edit_save; | |
7279 } | |
7280 | |
7281 #ifdef FEAT_TEXTOBJ | |
7282 /* | |
7283 * "a" or "i" while an operator is pending or in Visual mode: object motion. | |
7284 */ | |
7285 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7286 nv_object( |
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7287 cmdarg_T *cap) |
7 | 7288 { |
7289 int flag; | |
7290 int include; | |
7291 char_u *mps_save; | |
7292 | |
7293 if (cap->cmdchar == 'i') | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7294 include = FALSE; // "ix" = inner object: exclude white space |
7 | 7295 else |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7296 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
|
7297 |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7298 // Make sure (), [], {} and <> are in 'matchpairs' |
7 | 7299 mps_save = curbuf->b_p_mps; |
7300 curbuf->b_p_mps = (char_u *)"(:),{:},[:],<:>"; | |
7301 | |
7302 switch (cap->nchar) | |
7303 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7304 case 'w': // "aw" = a word |
7 | 7305 flag = current_word(cap->oap, cap->count1, include, FALSE); |
7306 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7307 case 'W': // "aW" = a WORD |
7 | 7308 flag = current_word(cap->oap, cap->count1, include, TRUE); |
7309 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7310 case 'b': // "ab" = a braces block |
7 | 7311 case '(': |
7312 case ')': | |
7313 flag = current_block(cap->oap, cap->count1, include, '(', ')'); | |
7314 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7315 case 'B': // "aB" = a Brackets block |
7 | 7316 case '{': |
7317 case '}': | |
7318 flag = current_block(cap->oap, cap->count1, include, '{', '}'); | |
7319 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7320 case '[': // "a[" = a [] block |
7 | 7321 case ']': |
7322 flag = current_block(cap->oap, cap->count1, include, '[', ']'); | |
7323 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7324 case '<': // "a<" = a <> block |
7 | 7325 case '>': |
7326 flag = current_block(cap->oap, cap->count1, include, '<', '>'); | |
7327 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7328 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
|
7329 // 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
|
7330 // 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
|
7331 // (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
|
7332 // 1) <b> 2) <b> |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7333 // foobar foobar |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7334 // </b> </b> |
6661 | 7335 cap->retval |= CA_NO_ADJ_OP_END; |
420 | 7336 flag = current_tagblock(cap->oap, cap->count1, include); |
7337 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7338 case 'p': // "ap" = a paragraph |
7 | 7339 flag = current_par(cap->oap, cap->count1, include, 'p'); |
7340 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7341 case 's': // "as" = a sentence |
7 | 7342 flag = current_sent(cap->oap, cap->count1, include); |
7343 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7344 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
|
7345 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
|
7346 case '`': // "a`" = a backtick quoted string |
12 | 7347 flag = current_quote(cap->oap, cap->count1, include, |
7348 cap->nchar); | |
7349 break; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7350 #if 0 // TODO |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7351 case 'S': // "aS" = a section |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7352 case 'f': // "af" = a filename |
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7353 case 'u': // "au" = a URL |
7 | 7354 #endif |
7355 default: | |
7356 flag = FAIL; | |
7357 break; | |
7358 } | |
7359 | |
7360 curbuf->b_p_mps = mps_save; | |
7361 if (flag == FAIL) | |
7362 clearopbeep(cap->oap); | |
7363 adjust_cursor_col(); | |
7364 curwin->w_set_curswant = TRUE; | |
7365 } | |
7366 #endif | |
7367 | |
7368 /* | |
7369 * "q" command: Start/stop recording. | |
7370 * "q:", "q/", "q?": edit command-line in command-line window. | |
7371 */ | |
7372 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7373 nv_record(cmdarg_T *cap) |
7 | 7374 { |
7375 if (cap->oap->op_type == OP_FORMAT) | |
7376 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7377 // "gqq" is the same as "gqgq": format line |
7 | 7378 cap->cmdchar = 'g'; |
7379 cap->nchar = 'q'; | |
7380 nv_operator(cap); | |
7381 } | |
7382 else if (!checkclearop(cap->oap)) | |
7383 { | |
7384 #ifdef FEAT_CMDWIN | |
7385 if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') | |
7386 { | |
7387 stuffcharReadbuff(cap->nchar); | |
7388 stuffcharReadbuff(K_CMDWIN); | |
7389 } | |
7390 else | |
7391 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7392 // (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
|
7393 // 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
|
7394 if (reg_executing == 0 && do_record(cap->nchar) == FAIL) |
7 | 7395 clearopbeep(cap->oap); |
7396 } | |
7397 } | |
7398 | |
7399 /* | |
7400 * Handle the "@r" command. | |
7401 */ | |
7402 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7403 nv_at(cmdarg_T *cap) |
7 | 7404 { |
7405 if (checkclearop(cap->oap)) | |
7406 return; | |
7407 #ifdef FEAT_EVAL | |
7408 if (cap->nchar == '=') | |
7409 { | |
7410 if (get_expr_register() == NUL) | |
7411 return; | |
7412 } | |
7413 #endif | |
7414 while (cap->count1-- && !got_int) | |
7415 { | |
1034 | 7416 if (do_execreg(cap->nchar, FALSE, FALSE, FALSE) == FAIL) |
7 | 7417 { |
7418 clearopbeep(cap->oap); | |
7419 break; | |
7420 } | |
7421 line_breakcheck(); | |
7422 } | |
7423 } | |
7424 | |
7425 /* | |
7426 * Handle the CTRL-U and CTRL-D commands. | |
7427 */ | |
7428 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7429 nv_halfpage(cmdarg_T *cap) |
7 | 7430 { |
7431 if ((cap->cmdchar == Ctrl_U && curwin->w_cursor.lnum == 1) | |
7432 || (cap->cmdchar == Ctrl_D | |
7433 && curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count)) | |
7434 clearopbeep(cap->oap); | |
7435 else if (!checkclearop(cap->oap)) | |
7436 halfpage(cap->cmdchar == Ctrl_D, cap->count0); | |
7437 } | |
7438 | |
7439 /* | |
7440 * Handle "J" or "gJ" command. | |
7441 */ | |
7442 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7443 nv_join(cmdarg_T *cap) |
7 | 7444 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7445 if (VIsual_active) // join the visual lines |
7 | 7446 nv_operator(cap); |
5735 | 7447 else if (!checkclearop(cap->oap)) |
7 | 7448 { |
7449 if (cap->count0 <= 1) | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7450 cap->count0 = 2; // default for join is two lines! |
7 | 7451 if (curwin->w_cursor.lnum + cap->count0 - 1 > |
7452 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
|
7453 { |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7454 // 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
|
7455 if (cap->count0 <= 2) |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7456 { |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7457 clearopbeep(cap->oap); |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7458 return; |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7459 } |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7460 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
|
7461 - curwin->w_cursor.lnum + 1; |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7462 } |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7463 |
dd2e2bd69d0e
commit https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7464 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
|
7465 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
|
7466 (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); |
7 | 7467 } |
7468 } | |
7469 | |
7470 /* | |
7471 * "P", "gP", "p" and "gp" commands. | |
7472 */ | |
7473 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7474 nv_put(cmdarg_T *cap) |
7 | 7475 { |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7476 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
|
7477 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7478 |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7479 /* |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7480 * "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
|
7481 * "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
|
7482 */ |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7483 static void |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7484 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
|
7485 { |
7 | 7486 int regname = 0; |
7487 void *reg1 = NULL, *reg2 = NULL; | |
84 | 7488 int empty = FALSE; |
236 | 7489 int was_visual = FALSE; |
7 | 7490 int dir; |
7491 int flags = 0; | |
7492 | |
7493 if (cap->oap->op_type != OP_NOP) | |
7494 { | |
7495 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7496 // "dp" is ":diffput" |
7 | 7497 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'p') |
7498 { | |
7499 clearop(cap->oap); | |
6314 | 7500 nv_diffgetput(TRUE, cap->opcount); |
7 | 7501 } |
7502 else | |
7503 #endif | |
7504 clearopbeep(cap->oap); | |
7505 } | |
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
|
7506 #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
|
7507 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
|
7508 { |
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
|
7509 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
|
7510 } |
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
|
7511 #endif |
7 | 7512 else |
7513 { | |
16742
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7514 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
|
7515 { |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7516 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
|
7517 ? FORWARD : BACKWARD; |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7518 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
|
7519 } |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7520 else |
75b5d77bbbab
patch 8.1.1373: "[p" in Visual mode puts in wrong line
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
7521 dir = (cap->cmdchar == 'P' |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7522 || ((cap->cmdchar == 'g' || cap->cmdchar == 'z') |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7523 && cap->nchar == 'P')) ? BACKWARD : FORWARD; |
7 | 7524 prep_redo_cmd(cap); |
7525 if (cap->cmdchar == 'g') | |
7526 flags |= PUT_CURSEND; | |
24752
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7527 else if (cap->cmdchar == 'z') |
1ce39e257f1b
patch 8.2.2914: cannot paste a block without adding padding
Bram Moolenaar <Bram@vim.org>
parents:
24731
diff
changeset
|
7528 flags |= PUT_BLOCK_INNER; |
7 | 7529 |
7530 if (VIsual_active) | |
7531 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7532 // 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
|
7533 // 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
|
7534 // 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
|
7535 // overwrites if the old contents is being put. |
236 | 7536 was_visual = TRUE; |
7 | 7537 regname = cap->oap->regname; |
5735 | 7538 #ifdef FEAT_CLIPBOARD |
7 | 7539 adjust_clip_reg(®name); |
5735 | 7540 #endif |
5682 | 7541 if (regname == 0 || regname == '"' |
4013 | 7542 || VIM_ISDIGIT(regname) || regname == '-' |
5735 | 7543 #ifdef FEAT_CLIPBOARD |
7 | 7544 || (clip_unnamed && (regname == '*' || regname == '+')) |
5735 | 7545 #endif |
7 | 7546 |
7547 ) | |
7548 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7549 // 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
|
7550 // put, save it first. |
7 | 7551 reg1 = get_register(regname, TRUE); |
7552 } | |
7553 | |
17787
92e0996e1cb8
patch 8.1.1890: ml_get error when deleting fold marker
Bram Moolenaar <Bram@vim.org>
parents:
17730
diff
changeset
|
7554 // Now delete the selected text. Avoid messages here. |
7 | 7555 cap->cmdchar = 'd'; |
7556 cap->nchar = NUL; | |
7557 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
|
7558 ++msg_silent; |
7 | 7559 nv_operator(cap); |
7560 do_pending_operator(cap, 0, FALSE); | |
84 | 7561 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
|
7562 --msg_silent; |
7 | 7563 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7564 // delete PUT_LINE_BACKWARD; |
7 | 7565 cap->oap->regname = regname; |
7566 | |
7567 if (reg1 != NULL) | |
7568 { | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7569 // 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
|
7570 // it first. Then put back what was there before the delete. |
7 | 7571 reg2 = get_register(regname, FALSE); |
7572 put_register(regname, reg1); | |
7573 } | |
7574 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7575 // 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
|
7576 // 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
|
7577 // characterwise, split a line when putting lines. |
7 | 7578 if (VIsual_mode == 'V') |
7579 flags |= PUT_LINE; | |
7580 else if (VIsual_mode == 'v') | |
7581 flags |= PUT_LINE_SPLIT; | |
7582 if (VIsual_mode == Ctrl_V && dir == FORWARD) | |
7583 flags |= PUT_LINE_FORWARD; | |
7584 dir = BACKWARD; | |
7585 if ((VIsual_mode != 'V' | |
7586 && curwin->w_cursor.col < curbuf->b_op_start.col) | |
7587 || (VIsual_mode == 'V' | |
7588 && 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
|
7589 // 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
|
7590 // forward. |
7 | 7591 dir = FORWARD; |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7592 // May have been reset in do_put(). |
5365 | 7593 VIsual_active = TRUE; |
7 | 7594 } |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7595 do_put(cap->oap->regname, NULL, dir, cap->count1, flags); |
7 | 7596 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7597 // If a register was saved, put it back now. |
7 | 7598 if (reg2 != NULL) |
7599 put_register(regname, reg2); | |
236 | 7600 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7601 // 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
|
7602 // be the most useful, since the original text was removed. |
236 | 7603 if (was_visual) |
7604 { | |
690 | 7605 curbuf->b_visual.vi_start = curbuf->b_op_start; |
7606 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
|
7607 // need to adjust cursor position |
7241
0c1278704b5c
commit https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27
Christian Brabandt <cb@256bit.org>
parents:
7143
diff
changeset
|
7608 if (*p_sel == 'e') |
0c1278704b5c
commit https://github.com/vim/vim/commit/d29c6fea94947b3f4b54fbd5a6f832a7d744bf27
Christian Brabandt <cb@256bit.org>
parents:
7143
diff
changeset
|
7609 inc(&curbuf->b_visual.vi_end); |
236 | 7610 } |
7611 | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7612 // 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
|
7613 // line that needs to be deleted now. |
84 | 7614 if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) |
817 | 7615 { |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20591
diff
changeset
|
7616 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
|
7617 deleted_lines(curbuf->b_ml.ml_line_count + 1, 1); |
817 | 7618 |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7619 // 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
|
7620 // line. |
817 | 7621 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
7622 { | |
7623 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
7624 coladvance((colnr_T)MAXCOL); | |
7625 } | |
7626 } | |
7 | 7627 auto_format(FALSE, TRUE); |
7628 } | |
7629 } | |
7630 | |
7631 /* | |
7632 * "o" and "O" commands. | |
7633 */ | |
7634 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7635 nv_open(cmdarg_T *cap) |
7 | 7636 { |
7637 #ifdef FEAT_DIFF | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7638 // "do" is ":diffget" |
7 | 7639 if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'o') |
7640 { | |
7641 clearop(cap->oap); | |
6314 | 7642 nv_diffgetput(FALSE, cap->opcount); |
7 | 7643 } |
7644 else | |
7645 #endif | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7646 if (VIsual_active) // switch start and end of visual |
7 | 7647 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
|
7648 #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
|
7649 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
|
7650 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
|
7651 #endif |
7 | 7652 else |
7653 n_opencmd(cap); | |
7654 } | |
7655 | |
7656 #ifdef FEAT_NETBEANS_INTG | |
7657 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7658 nv_nbcmd(cmdarg_T *cap) |
7 | 7659 { |
7660 netbeans_keycommand(cap->nchar); | |
7661 } | |
7662 #endif | |
7663 | |
7664 #ifdef FEAT_DND | |
7665 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7666 nv_drop(cmdarg_T *cap UNUSED) |
7 | 7667 { |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
22091
diff
changeset
|
7668 do_put('~', NULL, BACKWARD, 1L, PUT_CURSEND); |
7 | 7669 } |
7670 #endif | |
203 | 7671 |
7672 /* | |
7673 * Trigger CursorHold event. | |
7674 * When waiting for a character for 'updatetime' K_CURSORHOLD is put in the | |
7675 * input buffer. "did_cursorhold" is set to avoid retriggering. | |
7676 */ | |
7677 static void | |
7829
2a8d6b2dd925
commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
7678 nv_cursorhold(cmdarg_T *cap) |
203 | 7679 { |
7680 apply_autocmds(EVENT_CURSORHOLD, NULL, NULL, FALSE, curbuf); | |
7681 did_cursorhold = TRUE; | |
18808
7982f65d8f54
patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18775
diff
changeset
|
7682 cap->retval |= CA_COMMAND_BUSY; // don't call edit() now |
226 | 7683 } |