Mercurial > vim
annotate src/insexpand.c @ 22002:c9517003821d v8.2.1550
patch 8.2.1550: Vim9: bufname('%') gives an error
Commit: https://github.com/vim/vim/commit/02aaad91094939758e053588dd23ebda467eea29
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 30 21:26:57 2020 +0200
patch 8.2.1550: Vim9: bufname('%') gives an error
Problem: Vim9: bufname('%') gives an error.
Solution: Only give an error for wrong argument type. (closes https://github.com/vim/vim/issues/6807)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 30 Aug 2020 21:30:03 +0200 |
parents | 9064044fd4f6 |
children | 80a000b09cb0 |
rev | line source |
---|---|
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * insexpand.c: functions for Insert mode completion |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 * Definitions used for CTRL-X submode. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 * Note: If you change CTRL-X submode, you must also maintain ctrl_x_msgs[] and |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 * ctrl_x_mode_names[] below. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 # define CTRL_X_WANT_IDENT 0x100 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18872
diff
changeset
|
23 # define CTRL_X_NORMAL 0 // CTRL-N CTRL-P completion, default |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 # define CTRL_X_NOT_DEFINED_YET 1 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 # define CTRL_X_SCROLL 2 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 # define CTRL_X_WHOLE_LINE 3 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 # define CTRL_X_FILES 4 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 # define CTRL_X_TAGS (5 + CTRL_X_WANT_IDENT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 # define CTRL_X_PATH_PATTERNS (6 + CTRL_X_WANT_IDENT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 # define CTRL_X_PATH_DEFINES (7 + CTRL_X_WANT_IDENT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 # define CTRL_X_FINISHED 8 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 # define CTRL_X_DICTIONARY (9 + CTRL_X_WANT_IDENT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 # define CTRL_X_THESAURUS (10 + CTRL_X_WANT_IDENT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 # define CTRL_X_CMDLINE 11 |
18872
410155e75efa
patch 8.1.2422: "make depend" does not work correctly for libvterm
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
35 # define CTRL_X_FUNCTION 12 |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 # define CTRL_X_OMNI 13 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 # define CTRL_X_SPELL 14 |
18933
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18872
diff
changeset
|
38 # define CTRL_X_LOCAL_MSG 15 // only used in "ctrl_x_msgs" |
82c732e8d23d
patch 8.2.0027: still some /* */ comments
Bram Moolenaar <Bram@vim.org>
parents:
18872
diff
changeset
|
39 # define CTRL_X_EVAL 16 // for builtin function complete() |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 # define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT] |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 // Message for CTRL-X mode, index is ctrl_x_mode. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 static char *ctrl_x_msgs[] = |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 N_(" Keyword completion (^N^P)"), // CTRL_X_NORMAL, ^P/^N compl. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 N_(" ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 NULL, // CTRL_X_SCROLL: depends on state |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 N_(" Whole line completion (^L^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 N_(" File name completion (^F^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 N_(" Tag completion (^]^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 N_(" Path pattern completion (^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 N_(" Definition completion (^D^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 NULL, // CTRL_X_FINISHED |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 N_(" Dictionary completion (^K^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 N_(" Thesaurus completion (^T^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 N_(" Command-line completion (^V^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 N_(" User defined completion (^U^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 N_(" Omni completion (^O^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 N_(" Spelling suggestion (s^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 N_(" Keyword Local completion (^N^P)"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 NULL, // CTRL_X_EVAL doesn't use msg. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 }; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
65 #if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 static char *ctrl_x_mode_names[] = { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 "keyword", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 "ctrl_x", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 "unknown", // CTRL_X_SCROLL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 "whole_line", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 "files", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 "tags", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 "path_patterns", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 "path_defines", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 "unknown", // CTRL_X_FINISHED |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 "dictionary", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 "thesaurus", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 "cmdline", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 "function", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 "omni", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 "spell", |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 NULL, // CTRL_X_LOCAL_MSG only used in "ctrl_x_msgs" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 "eval" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 }; |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
85 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 * Array indexes used for cp_text[]. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 #define CPT_ABBR 0 // "abbr" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 #define CPT_MENU 1 // "menu" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 #define CPT_KIND 2 // "kind" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 #define CPT_INFO 3 // "info" |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
94 #define CPT_COUNT 4 // Number of entries |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 * Structure used to store one match for insert completion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 typedef struct compl_S compl_T; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 struct compl_S |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 compl_T *cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 compl_T *cp_prev; |
16237
56451a2677dc
patch 8.1.1123: no way to avoid filtering for autocomplete function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
104 char_u *cp_str; // matched text |
56451a2677dc
patch 8.1.1123: no way to avoid filtering for autocomplete function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
105 char_u *(cp_text[CPT_COUNT]); // text for the menu |
19051
c6248ef5b41b
patch 8.2.0086: build error for small version
Bram Moolenaar <Bram@vim.org>
parents:
19047
diff
changeset
|
106 #ifdef FEAT_EVAL |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
107 typval_T cp_user_data; |
19051
c6248ef5b41b
patch 8.2.0086: build error for small version
Bram Moolenaar <Bram@vim.org>
parents:
19047
diff
changeset
|
108 #endif |
16237
56451a2677dc
patch 8.1.1123: no way to avoid filtering for autocomplete function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
109 char_u *cp_fname; // file containing the match, allocated when |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
110 // cp_flags has CP_FREE_FNAME |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
111 int cp_flags; // CP_ values |
16237
56451a2677dc
patch 8.1.1123: no way to avoid filtering for autocomplete function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
112 int cp_number; // sequence number |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 }; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
115 // values for cp_flags |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
116 # define CP_ORIGINAL_TEXT 1 // the original text when the expansion begun |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
117 # define CP_FREE_FNAME 2 // cp_fname is allocated |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
118 # define CP_CONT_S_IPOS 4 // use CONT_S_IPOS for compl_cont_status |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
119 # define CP_EQUAL 8 // ins_compl_equal() always returns TRUE |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
120 # define CP_ICASE 16 // ins_compl_equal() ignores case |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 static char e_hitend[] = N_("Hit end of paragraph"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 # ifdef FEAT_COMPL_FUNC |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 static char e_complwin[] = N_("E839: Completion function changed window"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 static char e_compldel[] = N_("E840: Completion function deleted text"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 # endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 * All the current matches are stored in a list. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 * "compl_first_match" points to the start of the list. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 * "compl_curr_match" points to the currently selected entry. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 * "compl_shown_match" is different from compl_curr_match during |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 * ins_compl_get_exp(). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 static compl_T *compl_first_match = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 static compl_T *compl_curr_match = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 static compl_T *compl_shown_match = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 static compl_T *compl_old_match = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 // After using a cursor key <Enter> selects a match in the popup menu, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 // otherwise it inserts a line break. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 static int compl_enter_selects = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 // When "compl_leader" is not NULL only matches that start with this string |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 // are used. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 static char_u *compl_leader = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 static int compl_get_longest = FALSE; // put longest common string |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 // in compl_leader |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 static int compl_no_insert = FALSE; // FALSE: select & insert |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 // TRUE: noinsert |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 static int compl_no_select = FALSE; // FALSE: select & insert |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 // TRUE: noselect |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 // Selected one of the matches. When FALSE the match was edited or using the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 // longest common string. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 static int compl_used_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 // didn't finish finding completions. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 static int compl_was_interrupted = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 // Set when character typed while looking for matches and it means we should |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 // stop looking for matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 static int compl_interrupted = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 static int compl_restarting = FALSE; // don't insert match |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 // When the first completion is done "compl_started" is set. When it's |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 // FALSE the word to be completed must be located. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 static int compl_started = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 // Which Ctrl-X mode are we in? |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 static int ctrl_x_mode = CTRL_X_NORMAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 static int compl_matches = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 static char_u *compl_pattern = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 static int compl_direction = FORWARD; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 static int compl_shows_dir = FORWARD; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 static int compl_pending = 0; // > 1 for postponed CTRL-N |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 static pos_T compl_startpos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 static colnr_T compl_col = 0; // column where the text starts |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 // that is being completed |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 static char_u *compl_orig_text = NULL; // text as it was before |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 // completion started |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 static int compl_cont_mode = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 static expand_T compl_xp; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 static int compl_opt_refresh_always = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 static int compl_opt_suppress_empty = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
192 static int ins_compl_add(char_u *str, int len, char_u *fname, char_u **cptext, typval_T *user_data, int cdir, int flags, int adup); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 static void ins_compl_longest_match(compl_T *match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 static void ins_compl_del_pum(void); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, regmatch_T *regmatch, char_u *buf, int *dir); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 static char_u *find_line_end(char_u *ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 static void ins_compl_free(void); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 static int ins_compl_need_restart(void); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 static void ins_compl_new_leader(void); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 static int ins_compl_len(void); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 static void ins_compl_restart(void); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 static void ins_compl_set_original_text(char_u *str); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 # if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 static void ins_compl_add_list(list_T *list); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 static void ins_compl_add_dict(dict_T *dict); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 # endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 static int ins_compl_key2dir(int c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 static int ins_compl_pum_key(int c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 static int ins_compl_key2count(int c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 static void show_pum(int prev_w_wrow, int prev_w_leftcol); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 static unsigned quote_meta(char_u *dest, char_u *str, int len); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 #ifdef FEAT_SPELL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 static void spell_back_to_badword(void); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 static int spell_bad_len = 0; // length of located bad word |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 * CTRL-X pressed in Insert mode. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 ins_ctrl_x(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 // CTRL-X after CTRL-X CTRL-V doesn't do anything, so that CTRL-X |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 // CTRL-V works like CTRL-N |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 if (ctrl_x_mode != CTRL_X_CMDLINE) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 // if the next ^X<> won't ADD nothing, then reset |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 // compl_cont_status |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 if (compl_cont_status & CONT_N_ADDS) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 compl_cont_status |= CONT_INTRPT; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 compl_cont_status = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 // We're not sure which CTRL-X mode it will be yet |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 ctrl_x_mode = CTRL_X_NOT_DEFINED_YET; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 edit_submode_pre = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 showmode(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 * Functions to check the current CTRL-X mode. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 int ctrl_x_mode_none(void) { return ctrl_x_mode == 0; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 int ctrl_x_mode_normal(void) { return ctrl_x_mode == CTRL_X_NORMAL; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 int ctrl_x_mode_scroll(void) { return ctrl_x_mode == CTRL_X_SCROLL; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 int ctrl_x_mode_whole_line(void) { return ctrl_x_mode == CTRL_X_WHOLE_LINE; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 int ctrl_x_mode_files(void) { return ctrl_x_mode == CTRL_X_FILES; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 int ctrl_x_mode_tags(void) { return ctrl_x_mode == CTRL_X_TAGS; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 int ctrl_x_mode_path_patterns(void) { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 return ctrl_x_mode == CTRL_X_PATH_PATTERNS; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 int ctrl_x_mode_path_defines(void) { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 return ctrl_x_mode == CTRL_X_PATH_DEFINES; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 int ctrl_x_mode_dictionary(void) { return ctrl_x_mode == CTRL_X_DICTIONARY; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 int ctrl_x_mode_thesaurus(void) { return ctrl_x_mode == CTRL_X_THESAURUS; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 int ctrl_x_mode_cmdline(void) { return ctrl_x_mode == CTRL_X_CMDLINE; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 int ctrl_x_mode_function(void) { return ctrl_x_mode == CTRL_X_FUNCTION; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 int ctrl_x_mode_omni(void) { return ctrl_x_mode == CTRL_X_OMNI; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 int ctrl_x_mode_spell(void) { return ctrl_x_mode == CTRL_X_SPELL; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 int ctrl_x_mode_line_or_eval(void) { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 return ctrl_x_mode == CTRL_X_WHOLE_LINE || ctrl_x_mode == CTRL_X_EVAL; } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 * Whether other than default completion has been selected. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 ctrl_x_mode_not_default(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 return ctrl_x_mode != CTRL_X_NORMAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 * Whether CTRL-X was typed without a following character. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 ctrl_x_mode_not_defined_yet(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 return ctrl_x_mode == CTRL_X_NOT_DEFINED_YET; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 * Return TRUE if the 'dict' or 'tsr' option can be used. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 has_compl_option(int dict_opt) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 if (dict_opt ? (*curbuf->b_p_dict == NUL && *p_dict == NUL |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
290 #ifdef FEAT_SPELL |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 && !curwin->w_p_spell |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
292 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 ) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 : (*curbuf->b_p_tsr == NUL && *p_tsr == NUL)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 ctrl_x_mode = CTRL_X_NORMAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 edit_submode = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 msg_attr(dict_opt ? _("'dictionary' option is empty") |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 : _("'thesaurus' option is empty"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 HL_ATTR(HLF_E)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 if (emsg_silent == 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 vim_beep(BO_COMPL); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 setcursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 out_flush(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 #ifdef FEAT_EVAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 if (!get_vim_var_nr(VV_TESTING)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 #endif |
18642
bbea1f108187
patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
309 ui_delay(2004L, FALSE); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 return FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 return TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 * Is the character 'c' a valid key to go to or keep us in CTRL-X mode? |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 * This depends on the current mode. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 vim_is_ctrl_x_key(int c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 // Always allow ^R - let its results then be checked |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 if (c == Ctrl_R) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 return TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 // Accept <PageUp> and <PageDown> if the popup menu is visible. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 if (ins_compl_pum_key(c)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 return TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 switch (ctrl_x_mode) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 case 0: // Not in any CTRL-X mode |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 return (c == Ctrl_N || c == Ctrl_P || c == Ctrl_X); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 case CTRL_X_NOT_DEFINED_YET: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 return ( c == Ctrl_X || c == Ctrl_Y || c == Ctrl_E |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 || c == Ctrl_L || c == Ctrl_F || c == Ctrl_RSB |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 || c == Ctrl_I || c == Ctrl_D || c == Ctrl_P |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 || c == Ctrl_N || c == Ctrl_T || c == Ctrl_V |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 || c == Ctrl_Q || c == Ctrl_U || c == Ctrl_O |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 || c == Ctrl_S || c == Ctrl_K || c == 's'); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 case CTRL_X_SCROLL: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 return (c == Ctrl_Y || c == Ctrl_E); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 case CTRL_X_WHOLE_LINE: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 return (c == Ctrl_L || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 case CTRL_X_FILES: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 return (c == Ctrl_F || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 case CTRL_X_DICTIONARY: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 return (c == Ctrl_K || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 case CTRL_X_THESAURUS: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 return (c == Ctrl_T || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 case CTRL_X_TAGS: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 return (c == Ctrl_RSB || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 #ifdef FEAT_FIND_ID |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 case CTRL_X_PATH_PATTERNS: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 return (c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 case CTRL_X_PATH_DEFINES: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 return (c == Ctrl_D || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 case CTRL_X_CMDLINE: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 return (c == Ctrl_V || c == Ctrl_Q || c == Ctrl_P || c == Ctrl_N |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 || c == Ctrl_X); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 #ifdef FEAT_COMPL_FUNC |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 case CTRL_X_FUNCTION: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 return (c == Ctrl_U || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 case CTRL_X_OMNI: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 return (c == Ctrl_O || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 case CTRL_X_SPELL: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 return (c == Ctrl_S || c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 case CTRL_X_EVAL: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 return (c == Ctrl_P || c == Ctrl_N); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 internal_error("vim_is_ctrl_x_key()"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 return FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 * Return TRUE when character "c" is part of the item currently being |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 * completed. Used to decide whether to abandon complete mode when the menu |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 * is visible. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 ins_compl_accept_char(int c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 if (ctrl_x_mode & CTRL_X_WANT_IDENT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 // When expanding an identifier only accept identifier chars. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 return vim_isIDc(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 switch (ctrl_x_mode) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 case CTRL_X_FILES: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 // When expanding file name only accept file name chars. But not |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 // path separators, so that "proto/<Tab>" expands files in |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 // "proto", not "proto/" as a whole |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 return vim_isfilec(c) && !vim_ispathsep(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 case CTRL_X_CMDLINE: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 case CTRL_X_OMNI: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 // Command line and Omni completion can work with just about any |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 // printable character, but do stop at white space. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 return vim_isprintc(c) && !VIM_ISWHITE(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 case CTRL_X_WHOLE_LINE: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 // For while line completion a space can be part of the line. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 return vim_isprintc(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 return vim_iswordc(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 * This is like ins_compl_add(), but if 'ic' and 'inf' are set, then the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 * case of the originally typed text is used, and the case of the completed |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 * text is inferred, ie this tries to work out what case you probably wanted |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 * the rest of the word to be in -- webb |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 ins_compl_add_infercase( |
16237
56451a2677dc
patch 8.1.1123: no way to avoid filtering for autocomplete function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
419 char_u *str_arg, |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 int len, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 int icase, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 char_u *fname, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 int dir, |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
424 int cont_s_ipos) // next ^X<> will set initial_pos |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 { |
16237
56451a2677dc
patch 8.1.1123: no way to avoid filtering for autocomplete function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
426 char_u *str = str_arg; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 char_u *p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 int i, c; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 int actual_len; // Take multi-byte characters |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 int actual_compl_length; // into account. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 int min_len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 int *wca; // Wide character array. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 int has_lower = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 int was_letter = FALSE; |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
435 int flags = 0; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 if (p_ic && curbuf->b_p_inf && len > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 // Infer case of completed part. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 // Find actual length of completion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 p = str; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 actual_len = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 while (*p != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 MB_PTR_ADV(p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 ++actual_len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 actual_len = len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 // Find actual length of original text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 p = compl_orig_text; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 actual_compl_length = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 while (*p != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 MB_PTR_ADV(p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 ++actual_compl_length; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 actual_compl_length = compl_length; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 // "actual_len" may be smaller than "actual_compl_length" when using |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 // thesaurus, only use the minimum when comparing. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 min_len = actual_len < actual_compl_length |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 ? actual_len : actual_compl_length; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 // Allocate wide character array for the completion and fill it. |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
475 wca = ALLOC_MULT(int, actual_len); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 if (wca != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 p = str; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 for (i = 0; i < actual_len; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 wca[i] = mb_ptr2char_adv(&p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 wca[i] = *(p++); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 // Rule 1: Were any chars converted to lower? |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 p = compl_orig_text; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 for (i = 0; i < min_len; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 c = mb_ptr2char_adv(&p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 c = *(p++); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
493 if (MB_ISLOWER(c)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 has_lower = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 if (MB_ISUPPER(wca[i])) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 // Rule 1 is satisfied. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 for (i = actual_compl_length; i < actual_len; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 wca[i] = MB_TOLOWER(wca[i]); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 // Rule 2: No lower case, 2nd consecutive letter converted to |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 // upper case. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 if (!has_lower) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 p = compl_orig_text; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 for (i = 0; i < min_len; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 c = mb_ptr2char_adv(&p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 c = *(p++); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i])) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 // Rule 2 is satisfied. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 for (i = actual_compl_length; i < actual_len; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 wca[i] = MB_TOUPPER(wca[i]); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 was_letter = MB_ISLOWER(c) || MB_ISUPPER(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 // Copy the original case of the part we typed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 p = compl_orig_text; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 for (i = 0; i < min_len; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 c = mb_ptr2char_adv(&p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 c = *(p++); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 if (MB_ISLOWER(c)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 wca[i] = MB_TOLOWER(wca[i]); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 else if (MB_ISUPPER(c)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 wca[i] = MB_TOUPPER(wca[i]); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 // Generate encoding specific output from wide character array. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 // Multi-byte characters can occupy up to five bytes more than |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 // ASCII characters, and we also need one byte for NUL, so stay |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 // six bytes away from the edge of IObuff. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 p = IObuff; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 i = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 while (i < actual_len && (p - IObuff + 6) < IOSIZE) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 p += (*mb_char2bytes)(wca[i++], p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 *(p++) = wca[i++]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 *p = NUL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 vim_free(wca); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 |
16237
56451a2677dc
patch 8.1.1123: no way to avoid filtering for autocomplete function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
558 str = IObuff; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 } |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
560 if (cont_s_ipos) |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
561 flags |= CP_CONT_S_IPOS; |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
562 if (icase) |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
563 flags |= CP_ICASE; |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
564 |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
565 return ins_compl_add(str, len, fname, NULL, NULL, dir, flags, FALSE); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 * Add a match to the list of matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 * If the given string is already in the list of completions, then return |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 * NOTDONE, otherwise add it to the list and return OK. If there is an error, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 * maybe because alloc() returns NULL, then FAIL is returned. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 ins_compl_add( |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 char_u *str, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 int len, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 char_u *fname, |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19127
diff
changeset
|
579 char_u **cptext, // extra text for popup menu or NULL |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19127
diff
changeset
|
580 typval_T *user_data UNUSED, // "user_data" entry or NULL |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 int cdir, |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
582 int flags_arg, |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
583 int adup) // accept duplicate match |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 compl_T *match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 int dir = (cdir == 0 ? compl_direction : cdir); |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
587 int flags = flags_arg; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 ui_breakcheck(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 if (got_int) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 if (len < 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 len = (int)STRLEN(str); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 // If the same match is already present, don't add it. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 if (compl_first_match != NULL && !adup) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 match = compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 do |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 { |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
601 if ( !(match->cp_flags & CP_ORIGINAL_TEXT) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
602 && STRNCMP(match->cp_str, str, len) == 0 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 && match->cp_str[len] == NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
604 return NOTDONE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 match = match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 } while (match != NULL && match != compl_first_match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 // Remove any popup menu before changing the list of matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 ins_compl_del_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
612 // Allocate a new match structure. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 // Copy the values to the new match structure. |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
614 match = ALLOC_CLEAR_ONE(compl_T); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 if (match == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 match->cp_number = -1; |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
618 if (flags & CP_ORIGINAL_TEXT) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 match->cp_number = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 if ((match->cp_str = vim_strnsave(str, len)) == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 vim_free(match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 // match-fname is: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 // - compl_curr_match->cp_fname if it is a string equal to fname. |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
628 // - a copy of fname, CP_FREE_FNAME is set to free later THE allocated mem. |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 // - NULL otherwise. --Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 if (fname != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 && compl_curr_match != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 && compl_curr_match->cp_fname != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 && STRCMP(fname, compl_curr_match->cp_fname) == 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 match->cp_fname = compl_curr_match->cp_fname; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 else if (fname != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 match->cp_fname = vim_strsave(fname); |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
638 flags |= CP_FREE_FNAME; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 match->cp_fname = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 match->cp_flags = flags; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 if (cptext != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 int i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 for (i = 0; i < CPT_COUNT; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 if (cptext[i] != NULL && *cptext[i] != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 match->cp_text[i] = vim_strsave(cptext[i]); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 } |
19051
c6248ef5b41b
patch 8.2.0086: build error for small version
Bram Moolenaar <Bram@vim.org>
parents:
19047
diff
changeset
|
652 #ifdef FEAT_EVAL |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
653 if (user_data != NULL) |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
654 match->cp_user_data = *user_data; |
19051
c6248ef5b41b
patch 8.2.0086: build error for small version
Bram Moolenaar <Bram@vim.org>
parents:
19047
diff
changeset
|
655 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 // Link the new match structure in the list of matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 if (compl_first_match == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 match->cp_next = match->cp_prev = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 else if (dir == FORWARD) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 match->cp_next = compl_curr_match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 match->cp_prev = compl_curr_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 else // BACKWARD |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 match->cp_next = compl_curr_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 match->cp_prev = compl_curr_match->cp_prev; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 if (match->cp_next) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 match->cp_next->cp_prev = match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 if (match->cp_prev) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 match->cp_prev->cp_next = match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 else // if there's nothing before, it is the first match |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 compl_first_match = match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 compl_curr_match = match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 // Find the longest common string if still doing that. |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
679 if (compl_get_longest && (flags & CP_ORIGINAL_TEXT) == 0) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 ins_compl_longest_match(match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 return OK; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 * Return TRUE if "str[len]" matches with match->cp_str, considering |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
687 * match->cp_flags. |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 ins_compl_equal(compl_T *match, char_u *str, int len) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 { |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
692 if (match->cp_flags & CP_EQUAL) |
16237
56451a2677dc
patch 8.1.1123: no way to avoid filtering for autocomplete function
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
693 return TRUE; |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
694 if (match->cp_flags & CP_ICASE) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 return STRNICMP(match->cp_str, str, (size_t)len) == 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 return STRNCMP(match->cp_str, str, (size_t)len) == 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 * Reduce the longest common string for match "match". |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 ins_compl_longest_match(compl_T *match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 char_u *p, *s; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 int c1, c2; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 int had_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 if (compl_leader == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 // First match, use it as a whole. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 compl_leader = vim_strsave(match->cp_str); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 if (compl_leader != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 had_match = (curwin->w_cursor.col > compl_col); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 ins_compl_delete(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 ins_bytes(compl_leader + ins_compl_len()); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 ins_redraw(FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 // When the match isn't there (to avoid matching itself) remove it |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 // again after redrawing. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 if (!had_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 ins_compl_delete(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 compl_used_match = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 // Reduce the text if this match differs from compl_leader. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 p = compl_leader; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 s = match->cp_str; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 while (*p != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 c1 = mb_ptr2char(p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 c2 = mb_ptr2char(s); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 c1 = *p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 c2 = *s; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 } |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
744 if ((match->cp_flags & CP_ICASE) |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
745 ? (MB_TOLOWER(c1) != MB_TOLOWER(c2)) : (c1 != c2)) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 MB_PTR_ADV(p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 MB_PTR_ADV(s); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 ++p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 ++s; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 if (*p != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 // Leader was shortened, need to change the inserted text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 *p = NUL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 had_match = (curwin->w_cursor.col > compl_col); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 ins_compl_delete(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 ins_bytes(compl_leader + ins_compl_len()); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 ins_redraw(FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 // When the match isn't there (to avoid matching itself) remove it |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 // again after redrawing. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 if (!had_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 ins_compl_delete(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 compl_used_match = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 * Add an array of matches to the list of matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 * Frees matches[]. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 ins_compl_add_matches( |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 int num_matches, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 char_u **matches, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 int icase) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 int i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 int add_r = OK; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 int dir = compl_direction; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 for (i = 0; i < num_matches && add_r != FAIL; i++) |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
793 if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, NULL, dir, |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
794 icase ? CP_ICASE : 0, FALSE)) == OK) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 // if dir was BACKWARD then honor it just once |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 dir = FORWARD; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 FreeWild(num_matches, matches); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 * Make the completion list cyclic. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 * Return the number of matches (excluding the original). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 ins_compl_make_cyclic(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 compl_T *match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 int count = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 if (compl_first_match != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 // Find the end of the list. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 match = compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 // there's always an entry for the compl_orig_text, it doesn't count. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 while (match->cp_next != NULL && match->cp_next != compl_first_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 match = match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 ++count; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 match->cp_next = compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 compl_first_match->cp_prev = match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 return count; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 * Return whether there currently is a shown match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 ins_compl_has_shown_match(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 return compl_shown_match == NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 || compl_shown_match != compl_shown_match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 * Return whether the shown match is long enough. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 ins_compl_long_shown_match(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 return (int)STRLEN(compl_shown_match->cp_str) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 > curwin->w_cursor.col - compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 * Set variables that store noselect and noinsert behavior from the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 * 'completeopt' value. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 completeopt_was_set(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 compl_no_insert = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 compl_no_select = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 if (strstr((char *)p_cot, "noselect") != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 compl_no_select = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 if (strstr((char *)p_cot, "noinsert") != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 compl_no_insert = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 // "compl_match_array" points the currently displayed list of entries in the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 // popup menu. It is NULL when there is no popup menu. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 static pumitem_T *compl_match_array = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 static int compl_match_arraysize; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 * Update the screen and when there is any scrolling remove the popup menu. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 ins_compl_upd_pum(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 int h; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 if (compl_match_array != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 h = curwin->w_cline_height; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 // Update the screen later, before drawing the popup menu over it. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 pum_call_update_screen(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 if (h != curwin->w_cline_height) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 ins_compl_del_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 * Remove any popup menu. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 ins_compl_del_pum(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 if (compl_match_array != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 pum_undisplay(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 VIM_CLEAR(compl_match_array); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 * Return TRUE if the popup menu should be displayed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 pum_wanted(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 // 'completeopt' must contain "menu" or "menuone" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 if (vim_strchr(p_cot, 'm') == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 return FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 // The display looks bad on a B&W display. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 if (t_colors < 8 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 #ifdef FEAT_GUI |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 && !gui.in_use |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 ) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 return FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 return TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 * Return TRUE if there are two or more matches to be shown in the popup menu. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 * One if 'completopt' contains "menuone". |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 pum_enough_matches(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 compl_T *compl; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 int i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 // Don't display the popup menu if there are no matches or there is only |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 // one (ignoring the original text). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 compl = compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 i = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 do |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 if (compl == NULL |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
935 || ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0 && ++i == 2)) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 compl = compl->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 } while (compl != compl_first_match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 if (strstr((char *)p_cot, "menuone") != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 return (i >= 1); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 return (i >= 2); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
945 #ifdef FEAT_EVAL |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
946 /* |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
947 * Allocate Dict for the completed item. |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
948 * { word, abbr, menu, kind, info } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
949 */ |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
950 static dict_T * |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
951 ins_compl_dict_alloc(compl_T *match) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
952 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
953 dict_T *dict = dict_alloc_lock(VAR_FIXED); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
954 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
955 if (dict != NULL) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
956 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
957 dict_add_string(dict, "word", match->cp_str); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
958 dict_add_string(dict, "abbr", match->cp_text[CPT_ABBR]); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
959 dict_add_string(dict, "menu", match->cp_text[CPT_MENU]); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
960 dict_add_string(dict, "kind", match->cp_text[CPT_KIND]); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
961 dict_add_string(dict, "info", match->cp_text[CPT_INFO]); |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
962 if (match->cp_user_data.v_type == VAR_UNKNOWN) |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
963 dict_add_string(dict, "user_data", (char_u *)""); |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
964 else |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
965 dict_add_tv(dict, "user_data", &match->cp_user_data); |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
966 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
967 return dict; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
968 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
969 |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
970 static void |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
971 trigger_complete_changed_event(int cur) |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
972 { |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
973 dict_T *v_event; |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
974 dict_T *item; |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
975 static int recursive = FALSE; |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
976 |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
977 if (recursive) |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
978 return; |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
979 |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
980 v_event = get_vim_var_dict(VV_EVENT); |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
981 if (cur < 0) |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
982 item = dict_alloc(); |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
983 else |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
984 item = ins_compl_dict_alloc(compl_curr_match); |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
985 if (item == NULL) |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
986 return; |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
987 dict_add_dict(v_event, "completed_item", item); |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
988 pum_set_event_info(v_event); |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
989 dict_set_items_ro(v_event); |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
990 |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
991 recursive = TRUE; |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
992 textwinlock++; |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
993 apply_autocmds(EVENT_COMPLETECHANGED, NULL, NULL, FALSE, curbuf); |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
994 textwinlock--; |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
995 recursive = FALSE; |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
996 |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
997 dict_free_contents(v_event); |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
998 hash_init(&v_event->dv_hashtab); |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
999 } |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1000 #endif |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
1001 |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 * Show the popup menu for the list of matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 * Also adjusts "compl_shown_match" to an entry that is actually displayed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 ins_compl_show_pum(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 compl_T *compl; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 compl_T *shown_compl = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 int did_find_shown_match = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 int shown_match_ok = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 int i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 int cur = -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 colnr_T col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 int lead_len = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 if (!pum_wanted() || !pum_enough_matches()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 #if defined(FEAT_EVAL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 // Dirty hard-coded hack: remove any matchparen highlighting. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 do_cmdline_cmd((char_u *)"if exists('g:loaded_matchparen')|3match none|endif"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 // Update the screen later, before drawing the popup menu over it. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 pum_call_update_screen(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 if (compl_match_array == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 // Need to build the popup menu list. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 compl_match_arraysize = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 compl = compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 if (compl_leader != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 lead_len = (int)STRLEN(compl_leader); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 do |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 { |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1038 if ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0 |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 && (compl_leader == NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 || ins_compl_equal(compl, compl_leader, lead_len))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 ++compl_match_arraysize; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 compl = compl->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 } while (compl != NULL && compl != compl_first_match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 if (compl_match_arraysize == 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 return; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1046 compl_match_array = ALLOC_CLEAR_MULT(pumitem_T, compl_match_arraysize); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 if (compl_match_array != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 // If the current match is the original text don't find the first |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 // match after it, don't highlight anything. |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1051 if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 shown_match_ok = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 i = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 compl = compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 do |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 { |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1058 if ((compl->cp_flags & CP_ORIGINAL_TEXT) == 0 |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 && (compl_leader == NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 || ins_compl_equal(compl, compl_leader, lead_len))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 if (!shown_match_ok) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 if (compl == compl_shown_match || did_find_shown_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 // This item is the shown match or this is the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 // first displayed item after the shown match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 compl_shown_match = compl; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 did_find_shown_match = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 shown_match_ok = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 // Remember this displayed match for when the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 // shown match is just below it. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 shown_compl = compl; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 cur = i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 if (compl->cp_text[CPT_ABBR] != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 compl_match_array[i].pum_text = |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 compl->cp_text[CPT_ABBR]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 compl_match_array[i].pum_text = compl->cp_str; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 compl_match_array[i].pum_kind = compl->cp_text[CPT_KIND]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 compl_match_array[i].pum_info = compl->cp_text[CPT_INFO]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 if (compl->cp_text[CPT_MENU] != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 compl_match_array[i++].pum_extra = |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 compl->cp_text[CPT_MENU]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 compl_match_array[i++].pum_extra = compl->cp_fname; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 if (compl == compl_shown_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 did_find_shown_match = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 // When the original text is the shown match don't set |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 // compl_shown_match. |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1099 if (compl->cp_flags & CP_ORIGINAL_TEXT) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 shown_match_ok = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 if (!shown_match_ok && shown_compl != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 // The shown match isn't displayed, set it to the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 // previously displayed match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 compl_shown_match = shown_compl; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 shown_match_ok = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 compl = compl->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1111 } while (compl != NULL && compl != compl_first_match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 if (!shown_match_ok) // no displayed match at all |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 cur = -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1115 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 // popup menu already exists, only need to find the current item. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 for (i = 0; i < compl_match_arraysize; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 if (compl_match_array[i].pum_text == compl_shown_match->cp_str |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 || compl_match_array[i].pum_text |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 == compl_shown_match->cp_text[CPT_ABBR]) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 cur = i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1130 if (compl_match_array != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 // In Replace mode when a $ is displayed at the end of the line only |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 // part of the screen would be updated. We do need to redraw here. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 dollar_vcol = -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 // Compute the screen column of the start of the completed text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 // Use the cursor to get all wrapping and other settings right. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 col = curwin->w_cursor.col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 curwin->w_cursor.col = compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 pum_display(compl_match_array, compl_match_arraysize, cur); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 curwin->w_cursor.col = col; |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
1142 |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1143 #ifdef FEAT_EVAL |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
1144 if (has_completechanged()) |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
16239
diff
changeset
|
1145 trigger_complete_changed_event(cur); |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1146 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 #define DICT_FIRST (1) // use just first element in "dict" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 #define DICT_EXACT (2) // "dict" is the exact name of a file |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 * Add any identifiers that match the given pattern in the list of dictionary |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 * files "dict_start" to the list of completions. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 ins_compl_dictionaries( |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 char_u *dict_start, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 char_u *pat, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 int flags, // DICT_FIRST and/or DICT_EXACT |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 int thesaurus) // Thesaurus completion |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 char_u *dict = dict_start; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 char_u *ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 char_u *buf; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 regmatch_T regmatch; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 char_u **files; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 int count; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1170 int save_p_scs; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 int dir = compl_direction; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 if (*dict == NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 #ifdef FEAT_SPELL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 // When 'dictionary' is empty and spell checking is enabled use |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 // "spell". |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 if (!thesaurus && curwin->w_p_spell) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 dict = (char_u *)"spell"; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 buf = alloc(LSIZE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 if (buf == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 regmatch.regprog = NULL; // so that we can goto theend |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 // If 'infercase' is set, don't use 'smartcase' here |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 save_p_scs = p_scs; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 if (curbuf->b_p_inf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 p_scs = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 // When invoked to match whole lines for CTRL-X CTRL-L adjust the pattern |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 // to only match at the start of a line. Otherwise just match the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 // pattern. Also need to double backslashes. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 if (ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 char_u *pat_esc = vim_strsave_escaped(pat, (char_u *)"\\"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 size_t len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 if (pat_esc == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 goto theend; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 len = STRLEN(pat_esc) + 10; |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
1206 ptr = alloc(len); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 if (ptr == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 vim_free(pat_esc); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 goto theend; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 regmatch.regprog = vim_regcomp(ptr, RE_MAGIC); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 vim_free(pat_esc); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 vim_free(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 if (regmatch.regprog == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 goto theend; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 // ignore case depends on 'ignorecase', 'smartcase' and "pat" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 regmatch.rm_ic = ignorecase(pat); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 while (*dict != NUL && !got_int && !compl_interrupted) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 // copy one dictionary file name into buf |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 if (flags == DICT_EXACT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 count = 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 files = &dict; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 // Expand wildcards in the dictionary name, but do not allow |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 // backticks (for security, the 'dict' option may have been set in |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 // a modeline). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 copy_option_part(&dict, buf, LSIZE, ","); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 # ifdef FEAT_SPELL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 if (!thesaurus && STRCMP(buf, "spell") == 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 count = -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 # endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 if (vim_strchr(buf, '`') != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 || expand_wildcards(1, &buf, &count, &files, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 EW_FILE|EW_SILENT) != OK) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 count = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 # ifdef FEAT_SPELL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 if (count == -1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 // Complete from active spelling. Skip "\<" in the pattern, we |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 // don't use it as a RE. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 if (pat[0] == '\\' && pat[1] == '<') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 ptr = pat + 2; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 ptr = pat; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 spell_dump_compl(ptr, regmatch.rm_ic, &dir, 0); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 # endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 if (count > 0) // avoid warning for using "files" uninit |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 ins_compl_files(count, files, thesaurus, flags, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 ®match, buf, &dir); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 if (flags != DICT_EXACT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 FreeWild(count, files); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 if (flags != 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 theend: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 p_scs = save_p_scs; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 vim_regfree(regmatch.regprog); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 vim_free(buf); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 ins_compl_files( |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 int count, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 char_u **files, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 int thesaurus, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 int flags, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 regmatch_T *regmatch, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 char_u *buf, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 int *dir) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 char_u *ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 int i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 FILE *fp; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 int add_r; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 for (i = 0; i < count && !got_int && !compl_interrupted; i++) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 fp = mch_fopen((char *)files[i], "r"); // open dictionary file |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 if (flags != DICT_EXACT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 vim_snprintf((char *)IObuff, IOSIZE, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 _("Scanning dictionary: %s"), (char *)files[i]); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 (void)msg_trunc_attr((char *)IObuff, TRUE, HL_ATTR(HLF_R)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 if (fp != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 // Read dictionary file line by line. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 // Check each line for a match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 while (!got_int && !compl_interrupted |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 && !vim_fgets(buf, LSIZE, fp)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 ptr = buf; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 while (vim_regexec(regmatch, buf, (colnr_T)(ptr - buf))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 ptr = regmatch->startp[0]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 if (ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 ptr = find_line_end(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 ptr = find_word_end(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 add_r = ins_compl_add_infercase(regmatch->startp[0], |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 (int)(ptr - regmatch->startp[0]), |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1323 p_ic, files[i], *dir, FALSE); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 if (thesaurus) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 char_u *wstart; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 // Add the other matches on the line |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 ptr = buf; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 while (!got_int) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 // Find start of the next word. Skip white |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 // space and punctuation. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 ptr = find_word_start(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 if (*ptr == NUL || *ptr == NL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 wstart = ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 // Find end of the word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 // Japanese words may have characters in |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 // different classes, only separate words |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 // with single-byte non-word characters. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 while (*ptr != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 int l = (*mb_ptr2len)(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 if (l < 2 && !vim_iswordc(*ptr)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 ptr += l; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 ptr = find_word_end(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1355 // Add the word. Skip the regexp match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 if (wstart != regmatch->startp[0]) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 add_r = ins_compl_add_infercase(wstart, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 (int)(ptr - wstart), |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1359 p_ic, files[i], *dir, FALSE); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 if (add_r == OK) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 // if dir was BACKWARD then honor it just once |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 *dir = FORWARD; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 else if (add_r == FAIL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 // avoid expensive call to vim_regexec() when at end |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 // of line |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 if (*ptr == '\n' || got_int) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 line_breakcheck(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 ins_compl_check_keys(50, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 fclose(fp); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 * Find the start of the next word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 * Returns a pointer to the first char of the word. Also stops at a NUL. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 char_u * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 find_word_start(char_u *ptr) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 while (*ptr != NUL && *ptr != '\n' && mb_get_class(ptr) <= 1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 ptr += (*mb_ptr2len)(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 while (*ptr != NUL && *ptr != '\n' && !vim_iswordc(*ptr)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 ++ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 return ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1394 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 * Find the end of the word. Assumes it starts inside a word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 * Returns a pointer to just after the word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 char_u * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 find_word_end(char_u *ptr) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 int start_class; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 start_class = mb_get_class(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 if (start_class > 1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 while (*ptr != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 ptr += (*mb_ptr2len)(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 if (mb_get_class(ptr) != start_class) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 while (vim_iswordc(*ptr)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 ++ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 return ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 * Find the end of the line, omitting CR and NL at the end. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 * Returns a pointer to just after the line. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 static char_u * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 find_line_end(char_u *ptr) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1429 char_u *s; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1430 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 s = ptr + STRLEN(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 while (s > ptr && (s[-1] == CAR || s[-1] == NL)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 --s; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 return s; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 * Free the list of completions |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 ins_compl_free(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 compl_T *match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 int i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 VIM_CLEAR(compl_pattern); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 VIM_CLEAR(compl_leader); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 if (compl_first_match == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 ins_compl_del_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 pum_clear(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 compl_curr_match = compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 do |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 match = compl_curr_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 compl_curr_match = compl_curr_match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 vim_free(match->cp_str); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 // several entries may use the same fname, free it just once. |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1462 if (match->cp_flags & CP_FREE_FNAME) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 vim_free(match->cp_fname); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 for (i = 0; i < CPT_COUNT; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 vim_free(match->cp_text[i]); |
19051
c6248ef5b41b
patch 8.2.0086: build error for small version
Bram Moolenaar <Bram@vim.org>
parents:
19047
diff
changeset
|
1466 #ifdef FEAT_EVAL |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
1467 clear_tv(&match->cp_user_data); |
19051
c6248ef5b41b
patch 8.2.0086: build error for small version
Bram Moolenaar <Bram@vim.org>
parents:
19047
diff
changeset
|
1468 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 vim_free(match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 } while (compl_curr_match != NULL && compl_curr_match != compl_first_match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 compl_first_match = compl_curr_match = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 compl_shown_match = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 compl_old_match = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1477 ins_compl_clear(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1478 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 compl_cont_status = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 compl_started = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1481 compl_matches = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 VIM_CLEAR(compl_pattern); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 VIM_CLEAR(compl_leader); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 edit_submode_extra = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 VIM_CLEAR(compl_orig_text); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 compl_enter_selects = FALSE; |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1487 #ifdef FEAT_EVAL |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 // clear v:completed_item |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED)); |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1490 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 * Return TRUE when Insert completion is active. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 ins_compl_active(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 return compl_started; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1501 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 * Selected one of the matches. When FALSE the match was edited or using the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 * longest common string. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1505 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1506 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 ins_compl_used_match(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1509 return compl_used_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 * Initialize get longest common string. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 ins_compl_init_get_longest(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 compl_get_longest = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 * Returns TRUE when insert completion is interrupted. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 ins_compl_interrupted(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 return compl_interrupted; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 * Returns TRUE if the <Enter> key selects a match in the completion popup |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 * menu. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 ins_compl_enter_selects(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 return compl_enter_selects; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 * Return the column where the text starts that is being completed |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 colnr_T |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 ins_compl_col(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 return compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 * Delete one character before the cursor and show the subset of the matches |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 * that match the word that is now before the cursor. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 * Returns the character to be used, NUL if the work is done and another char |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 * to be got from the user. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 ins_compl_bs(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 char_u *line; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 char_u *p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 line = ml_get_curline(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 p = line + curwin->w_cursor.col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 MB_PTR_BACK(line, p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 // Stop completion when the whole word was deleted. For Omni completion |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 // allow the word to be deleted, we won't match everything. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 // Respect the 'backspace' option. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 if ((int)(p - line) - (int)compl_col < 0 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 || ((int)(p - line) - (int)compl_col == 0 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 && ctrl_x_mode != CTRL_X_OMNI) || ctrl_x_mode == CTRL_X_EVAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 || (!can_bs(BS_START) && (int)(p - line) - (int)compl_col |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 - compl_length < 0)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 return K_BS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 // Deleted more than what was used to find matches or didn't finish |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 // finding all matches: need to look for matches all over again. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1577 if (curwin->w_cursor.col <= compl_col + compl_length |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 || ins_compl_need_restart()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 ins_compl_restart(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1581 vim_free(compl_leader); |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20392
diff
changeset
|
1582 compl_leader = vim_strnsave(line + compl_col, (p - line) - compl_col); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 if (compl_leader != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 ins_compl_new_leader(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1586 if (compl_shown_match != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1587 // Make sure current match is not a hidden item. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1588 compl_curr_match = compl_shown_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1589 return NUL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1590 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1591 return K_BS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1592 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1595 * Return TRUE when we need to find matches again, ins_compl_restart() is to |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1596 * be called. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1597 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1598 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1599 ins_compl_need_restart(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1600 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1601 // Return TRUE if we didn't complete finding matches or when the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1602 // 'completefunc' returned "always" in the "refresh" dictionary item. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1603 return compl_was_interrupted |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1604 || ((ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 && compl_opt_refresh_always); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1606 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1607 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1608 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1609 * Called after changing "compl_leader". |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 * Show the popup menu with a different set of matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1611 * May also search for matches again if the previous search was interrupted. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1612 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 ins_compl_new_leader(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1615 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1616 ins_compl_del_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 ins_compl_delete(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1618 ins_bytes(compl_leader + ins_compl_len()); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1619 compl_used_match = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1620 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 if (compl_started) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 ins_compl_set_original_text(compl_leader); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 #ifdef FEAT_SPELL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1626 spell_bad_len = 0; // need to redetect bad word |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 #endif |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
1628 // Matches were cleared, need to search for them now. Before drawing |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1629 // the popup menu display the changed text before the cursor. Set |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1630 // "compl_restarting" to avoid that the first match is inserted. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 pum_call_update_screen(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 #ifdef FEAT_GUI |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 if (gui.in_use) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1634 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1635 // Show the cursor after the match, not after the redrawn text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1636 setcursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1637 out_flush_cursor(FALSE, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1638 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1639 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1640 compl_restarting = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 if (ins_complete(Ctrl_N, TRUE) == FAIL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1642 compl_cont_status = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1643 compl_restarting = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1644 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1645 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1646 compl_enter_selects = !compl_used_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1648 // Show the popup menu with a different set of matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 ins_compl_show_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1650 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1651 // Don't let Enter select the original text when there is no popup menu. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1652 if (compl_match_array == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1653 compl_enter_selects = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1654 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1655 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1656 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1657 * Return the length of the completion, from the completion start column to |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1658 * the cursor column. Making sure it never goes below zero. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1660 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 ins_compl_len(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1662 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1663 int off = (int)curwin->w_cursor.col - (int)compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1664 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 if (off < 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1666 return 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1667 return off; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1670 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1671 * Append one character to the match leader. May reduce the number of |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 * matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1673 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1674 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 ins_compl_addleader(int c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1676 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1677 int cc; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1679 if (stop_arrow() == FAIL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1680 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1681 if (has_mbyte && (cc = (*mb_char2len)(c)) > 1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1682 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1683 char_u buf[MB_MAXBYTES + 1]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1684 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1685 (*mb_char2bytes)(c, buf); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1686 buf[cc] = NUL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1687 ins_char_bytes(buf, cc); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1688 if (compl_opt_refresh_always) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1689 AppendToRedobuff(buf); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1690 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1691 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1692 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1693 ins_char(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1694 if (compl_opt_refresh_always) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 AppendCharToRedobuff(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1696 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1697 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 // If we didn't complete finding matches we must search again. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1699 if (ins_compl_need_restart()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1700 ins_compl_restart(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1701 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1702 // When 'always' is set, don't reset compl_leader. While completing, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1703 // cursor doesn't point original position, changing compl_leader would |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1704 // break redo. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1705 if (!compl_opt_refresh_always) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1706 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1707 vim_free(compl_leader); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1708 compl_leader = vim_strnsave(ml_get_curline() + compl_col, |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20392
diff
changeset
|
1709 curwin->w_cursor.col - compl_col); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1710 if (compl_leader != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1711 ins_compl_new_leader(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1713 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1714 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1715 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1716 * Setup for finding completions again without leaving CTRL-X mode. Used when |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1717 * BS or a key was typed while still searching for matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1718 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1720 ins_compl_restart(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1721 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1722 ins_compl_free(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1723 compl_started = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 compl_matches = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1725 compl_cont_status = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1726 compl_cont_mode = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1727 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1728 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1729 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1730 * Set the first match, the original text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1731 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1732 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1733 ins_compl_set_original_text(char_u *str) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1734 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1735 char_u *p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1736 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 // Replace the original text entry. |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1738 // The CP_ORIGINAL_TEXT flag is either at the first item or might possibly be |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1739 // at the last item for backward completion |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1740 if (compl_first_match->cp_flags & CP_ORIGINAL_TEXT) // safety check |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1742 p = vim_strsave(str); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1743 if (p != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1744 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 vim_free(compl_first_match->cp_str); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1746 compl_first_match->cp_str = p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1748 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 else if (compl_first_match->cp_prev != NULL |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1750 && (compl_first_match->cp_prev->cp_flags & CP_ORIGINAL_TEXT)) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1751 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1752 p = vim_strsave(str); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1753 if (p != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1754 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1755 vim_free(compl_first_match->cp_prev->cp_str); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1756 compl_first_match->cp_prev->cp_str = p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1757 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1758 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1760 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1761 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1762 * Append one character to the match leader. May reduce the number of |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1763 * matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1764 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1765 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1766 ins_compl_addfrommatch(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1767 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1768 char_u *p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1769 int len = (int)curwin->w_cursor.col - (int)compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 int c; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1771 compl_T *cp; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1772 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 p = compl_shown_match->cp_str; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 if ((int)STRLEN(p) <= len) // the match is too short |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1775 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1776 // When still at the original match use the first entry that matches |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1777 // the leader. |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
1778 if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1779 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1780 p = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 for (cp = compl_shown_match->cp_next; cp != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1782 && cp != compl_first_match; cp = cp->cp_next) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1784 if (compl_leader == NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 || ins_compl_equal(cp, compl_leader, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1786 (int)STRLEN(compl_leader))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1788 p = cp->cp_str; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1789 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1790 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1792 if (p == NULL || (int)STRLEN(p) <= len) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1795 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1796 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1798 p += len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 c = PTR2CHAR(p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 ins_compl_addleader(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1803 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1804 * Prepare for Insert mode completion, or stop it. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 * Called just after typing a character in Insert mode. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1806 * Returns TRUE when the character is not to be inserted; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 ins_compl_prep(int c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 char_u *ptr; |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1812 #ifdef FEAT_CINDENT |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 int want_cindent; |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
1814 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1815 int retval = FALSE; |
19127
0ee48dc3f8bc
patch 8.2.0123: complete_info() does not work when CompleteDone is triggered
Bram Moolenaar <Bram@vim.org>
parents:
19051
diff
changeset
|
1816 int prev_mode = ctrl_x_mode; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1818 // Forget any previous 'special' messages if this is actually |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1819 // a ^X mode key - bar ^R, in which case we wait to see what it gives us. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 if (c != Ctrl_R && vim_is_ctrl_x_key(c)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1821 edit_submode_extra = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1823 // Ignore end of Select mode mapping and mouse scroll buttons. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 if (c == K_SELECT || c == K_MOUSEDOWN || c == K_MOUSEUP |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 || c == K_MOUSELEFT || c == K_MOUSERIGHT) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1826 return retval; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1827 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
1828 #ifdef FEAT_PROP_POPUP |
17775
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1829 // Ignore mouse events in a popup window |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1830 if (is_mouse_key(c)) |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1831 { |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1832 // Ignore drag and release events, the position does not need to be in |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1833 // the popup and it may have just closed. |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1834 if (c == K_LEFTRELEASE |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1835 || c == K_LEFTRELEASE_NM |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1836 || c == K_MIDDLERELEASE |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1837 || c == K_RIGHTRELEASE |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1838 || c == K_X1RELEASE |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1839 || c == K_X2RELEASE |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1840 || c == K_LEFTDRAG |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1841 || c == K_MIDDLEDRAG |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1842 || c == K_RIGHTDRAG |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1843 || c == K_X1DRAG |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1844 || c == K_X2DRAG) |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1845 return retval; |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1846 if (popup_visible) |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1847 { |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1848 int row = mouse_row; |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1849 int col = mouse_col; |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1850 win_T *wp = mouse_find_win(&row, &col, FIND_POPUP); |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1851 |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1852 if (wp != NULL && WIN_IS_POPUP(wp)) |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1853 return retval; |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1854 } |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1855 } |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1856 #endif |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17704
diff
changeset
|
1857 |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1858 // Set "compl_get_longest" when finding the first matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 || (ctrl_x_mode == CTRL_X_NORMAL && !compl_started)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1862 compl_get_longest = (strstr((char *)p_cot, "longest") != NULL); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 compl_used_match = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1868 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1869 // We have just typed CTRL-X and aren't quite sure which CTRL-X mode |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 // it will be yet. Now we decide. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 switch (c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1872 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1873 case Ctrl_E: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1874 case Ctrl_Y: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 ctrl_x_mode = CTRL_X_SCROLL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 if (!(State & REPLACE_FLAG)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 edit_submode = (char_u *)_(" (insert) Scroll (^E/^Y)"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 edit_submode = (char_u *)_(" (replace) Scroll (^E/^Y)"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 edit_submode_pre = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1881 showmode(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1883 case Ctrl_L: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1884 ctrl_x_mode = CTRL_X_WHOLE_LINE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1885 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1886 case Ctrl_F: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1887 ctrl_x_mode = CTRL_X_FILES; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1888 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1889 case Ctrl_K: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1890 ctrl_x_mode = CTRL_X_DICTIONARY; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1891 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1892 case Ctrl_R: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1893 // Simply allow ^R to happen without affecting ^X mode |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1894 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1895 case Ctrl_T: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1896 ctrl_x_mode = CTRL_X_THESAURUS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1897 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1898 #ifdef FEAT_COMPL_FUNC |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1899 case Ctrl_U: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1900 ctrl_x_mode = CTRL_X_FUNCTION; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1902 case Ctrl_O: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1903 ctrl_x_mode = CTRL_X_OMNI; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1904 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1905 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1906 case 's': |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1907 case Ctrl_S: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1908 ctrl_x_mode = CTRL_X_SPELL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1909 #ifdef FEAT_SPELL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1910 ++emsg_off; // Avoid getting the E756 error twice. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1911 spell_back_to_badword(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 --emsg_off; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1913 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1914 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1915 case Ctrl_RSB: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1916 ctrl_x_mode = CTRL_X_TAGS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 #ifdef FEAT_FIND_ID |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1919 case Ctrl_I: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1920 case K_S_TAB: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1921 ctrl_x_mode = CTRL_X_PATH_PATTERNS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 case Ctrl_D: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1924 ctrl_x_mode = CTRL_X_PATH_DEFINES; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1925 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1926 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1927 case Ctrl_V: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1928 case Ctrl_Q: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 ctrl_x_mode = CTRL_X_CMDLINE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1930 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1931 case Ctrl_P: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 case Ctrl_N: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1933 // ^X^P means LOCAL expansion if nothing interrupted (eg we |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1934 // just started ^X mode, or there were enough ^X's to cancel |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1935 // the previous mode, say ^X^F^X^X^P or ^P^X^X^X^P, see below) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1936 // do normal expansion when interrupting a different mode (say |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1937 // ^X^F^X^P or ^P^X^X^P, see below) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1938 // nothing changes if interrupting mode 0, (eg, the flag |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1939 // doesn't change when going to ADDING mode -- Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 if (!(compl_cont_status & CONT_INTRPT)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1941 compl_cont_status |= CONT_LOCAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1942 else if (compl_cont_mode != 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 compl_cont_status &= ~CONT_LOCAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 // FALLTHROUGH |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1945 default: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1946 // If we have typed at least 2 ^X's... for modes != 0, we set |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 // compl_cont_status = 0 (eg, as if we had just started ^X |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1948 // mode). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1949 // For mode 0, we set "compl_cont_mode" to an impossible |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1950 // value, in both cases ^X^X can be used to restart the same |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1951 // mode (avoiding ADDING mode). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1952 // Undocumented feature: In a mode != 0 ^X^P and ^X^X^P start |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1953 // 'complete' and local ^P expansions respectively. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1954 // In mode 0 an extra ^X is needed since ^X^P goes to ADDING |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1955 // mode -- Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1956 if (c == Ctrl_X) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1957 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1958 if (compl_cont_mode != 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1959 compl_cont_status = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1961 compl_cont_mode = CTRL_X_NOT_DEFINED_YET; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1962 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 ctrl_x_mode = CTRL_X_NORMAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1964 edit_submode = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1965 showmode(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1966 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1967 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 else if (ctrl_x_mode != CTRL_X_NORMAL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 // We're already in CTRL-X mode, do we stay in it? |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 if (!vim_is_ctrl_x_key(c)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 if (ctrl_x_mode == CTRL_X_SCROLL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1975 ctrl_x_mode = CTRL_X_NORMAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 ctrl_x_mode = CTRL_X_FINISHED; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1978 edit_submode = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1979 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1980 showmode(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1982 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 if (compl_started || ctrl_x_mode == CTRL_X_FINISHED) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1984 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1985 // Show error message from attempted keyword completion (probably |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1986 // 'Pattern not found') until another key is hit, then go back to |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1987 // showing what mode we are in. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1988 showmode(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1989 if ((ctrl_x_mode == CTRL_X_NORMAL && c != Ctrl_N && c != Ctrl_P |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1990 && c != Ctrl_R && !ins_compl_pum_key(c)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1991 || ctrl_x_mode == CTRL_X_FINISHED) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1992 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1993 // Get here when we have finished typing a sequence of ^N and |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1994 // ^P or other completion characters in CTRL-X mode. Free up |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1995 // memory that was used, and make sure we can redo the insert. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1996 if (compl_curr_match != NULL || compl_leader != NULL || c == Ctrl_E) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1997 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1998 // If any of the original typed text has been changed, eg when |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1999 // ignorecase is set, we must add back-spaces to the redo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2000 // buffer. We add as few as necessary to delete just the part |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2001 // of the original text that has changed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2002 // When using the longest match, edited the match or used |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2003 // CTRL-E then don't use the current match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 if (compl_curr_match != NULL && compl_used_match && c != Ctrl_E) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2005 ptr = compl_curr_match->cp_str; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2006 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2007 ptr = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2008 ins_compl_fixRedoBufForLeader(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2009 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2010 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2011 #ifdef FEAT_CINDENT |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17813
diff
changeset
|
2012 want_cindent = (get_can_cindent() && cindent_on()); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2013 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2014 // When completing whole lines: fix indent for 'cindent'. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2015 // Otherwise, break line if it's too long. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2016 if (compl_cont_mode == CTRL_X_WHOLE_LINE) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2017 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2018 #ifdef FEAT_CINDENT |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2019 // re-indent the current line |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 if (want_cindent) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2021 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 do_c_expr_indent(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2023 want_cindent = FALSE; // don't do it again |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2024 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2026 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2027 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2029 int prev_col = curwin->w_cursor.col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2030 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2031 // put the cursor on the last char, for 'tw' formatting |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2032 if (prev_col > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2033 dec_cursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2034 // only format when something was inserted |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2035 if (!arrow_used && !ins_need_undo_get() && c != Ctrl_E) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2036 insertchar(NUL, 0, -1); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2037 if (prev_col > 0 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2038 && ml_get_curline()[curwin->w_cursor.col] != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2039 inc_cursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2040 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2041 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2042 // If the popup menu is displayed pressing CTRL-Y means accepting |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2043 // the selection without inserting anything. When |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2044 // compl_enter_selects is set the Enter key does the same. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2045 if ((c == Ctrl_Y || (compl_enter_selects |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2046 && (c == CAR || c == K_KENTER || c == NL))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2047 && pum_visible()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2048 retval = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2049 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2050 // CTRL-E means completion is Ended, go back to the typed text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2051 // but only do this, if the Popup is still visible |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2052 if (c == Ctrl_E) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2053 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2054 ins_compl_delete(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2055 if (compl_leader != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2056 ins_bytes(compl_leader + ins_compl_len()); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2057 else if (compl_first_match != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2058 ins_bytes(compl_orig_text + ins_compl_len()); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2059 retval = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2060 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2061 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2062 auto_format(FALSE, TRUE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2063 |
19199
8cbadf7fb9d4
patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
19187
diff
changeset
|
2064 // Trigger the CompleteDonePre event to give scripts a chance to |
8cbadf7fb9d4
patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
19187
diff
changeset
|
2065 // act upon the completion before clearing the info, and restore |
8cbadf7fb9d4
patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
19187
diff
changeset
|
2066 // ctrl_x_mode, so that complete_info() can be used. |
19187
1f67e58e7f8c
patch 8.2.0152: restoring ctrl_x_mode is not needed
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
2067 ctrl_x_mode = prev_mode; |
19199
8cbadf7fb9d4
patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
19187
diff
changeset
|
2068 ins_apply_autocmds(EVENT_COMPLETEDONEPRE); |
19127
0ee48dc3f8bc
patch 8.2.0123: complete_info() does not work when CompleteDone is triggered
Bram Moolenaar <Bram@vim.org>
parents:
19051
diff
changeset
|
2069 |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2070 ins_compl_free(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2071 compl_started = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2072 compl_matches = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2073 if (!shortmess(SHM_COMPLETIONMENU)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2074 msg_clr_cmdline(); // necessary for "noshowmode" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2075 ctrl_x_mode = CTRL_X_NORMAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2076 compl_enter_selects = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2077 if (edit_submode != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2078 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2079 edit_submode = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2080 showmode(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2081 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2082 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2083 #ifdef FEAT_CMDWIN |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2084 if (c == Ctrl_C && cmdwin_type != 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2085 // Avoid the popup menu remains displayed when leaving the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2086 // command line window. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2087 update_screen(0); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2088 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2089 #ifdef FEAT_CINDENT |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2090 // Indent now if a key was typed that is in 'cinkeys'. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2091 if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 do_c_expr_indent(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2093 #endif |
19199
8cbadf7fb9d4
patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
19187
diff
changeset
|
2094 // Trigger the CompleteDone event to give scripts a chance to act |
8cbadf7fb9d4
patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
19187
diff
changeset
|
2095 // upon the end of completion. |
8cbadf7fb9d4
patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
19187
diff
changeset
|
2096 ins_apply_autocmds(EVENT_COMPLETEDONE); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2097 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2098 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2099 else if (ctrl_x_mode == CTRL_X_LOCAL_MSG) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2100 // Trigger the CompleteDone event to give scripts a chance to act |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2101 // upon the (possibly failed) completion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2102 ins_apply_autocmds(EVENT_COMPLETEDONE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2103 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2104 // reset continue_* if we left expansion-mode, if we stay they'll be |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2105 // (re)set properly in ins_complete() |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2106 if (!vim_is_ctrl_x_key(c)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2107 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2108 compl_cont_status = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2109 compl_cont_mode = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2110 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2111 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2112 return retval; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2113 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2114 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2115 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2116 * Fix the redo buffer for the completion leader replacing some of the typed |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2117 * text. This inserts backspaces and appends the changed text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2118 * "ptr" is the known leader text or NUL. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2119 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2120 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2121 ins_compl_fixRedoBufForLeader(char_u *ptr_arg) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2122 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2123 int len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2124 char_u *p; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2125 char_u *ptr = ptr_arg; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2126 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2127 if (ptr == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2128 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2129 if (compl_leader != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2130 ptr = compl_leader; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2131 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2132 return; // nothing to do |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2133 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2134 if (compl_orig_text != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2135 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2136 p = compl_orig_text; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2138 ; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 if (len > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2140 len -= (*mb_head_off)(p, p + len); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2141 for (p += len; *p != NUL; MB_PTR_ADV(p)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2142 AppendCharToRedobuff(K_BS); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2143 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2144 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2145 len = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2146 if (ptr != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2147 AppendToRedobuffLit(ptr + len, -1); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2148 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2149 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2150 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2151 * Loops through the list of windows, loaded-buffers or non-loaded-buffers |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2152 * (depending on flag) starting from buf and looking for a non-scanned |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2153 * buffer (other than curbuf). curbuf is special, if it is called with |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2154 * buf=curbuf then it has to be the first call for a given flag/expansion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2155 * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2156 * Returns the buffer to scan, if any, otherwise returns curbuf -- Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2158 static buf_T * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2159 ins_compl_next_buf(buf_T *buf, int flag) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2160 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2161 static win_T *wp = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2162 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2163 if (flag == 'w') // just windows |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2164 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2165 if (buf == curbuf || wp == NULL) // first call for this flag/expansion |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2166 wp = curwin; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2167 while ((wp = (wp->w_next != NULL ? wp->w_next : firstwin)) != curwin |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2168 && wp->w_buffer->b_scanned) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2169 ; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2170 buf = wp->w_buffer; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2171 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2173 // 'b' (just loaded buffers), 'u' (just non-loaded buffers) or 'U' |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 // (unlisted buffers) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2175 // When completing whole lines skip unloaded buffers. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2176 while ((buf = (buf->b_next != NULL ? buf->b_next : firstbuf)) != curbuf |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 && ((flag == 'U' |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2178 ? buf->b_p_bl |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2179 : (!buf->b_p_bl |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2180 || (buf->b_ml.ml_mfp == NULL) != (flag == 'u'))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2181 || buf->b_scanned)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2182 ; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2183 return buf; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2184 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2185 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2186 #ifdef FEAT_COMPL_FUNC |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2187 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 * Execute user defined complete function 'completefunc' or 'omnifunc', and |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2189 * get matches in "matches". |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2190 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2191 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2192 expand_by_function( |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2193 int type, // CTRL_X_OMNI or CTRL_X_FUNCTION |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2194 char_u *base) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2195 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2196 list_T *matchlist = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2197 dict_T *matchdict = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2198 typval_T args[3]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2199 char_u *funcname; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2200 pos_T pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2201 win_T *curwin_save; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2202 buf_T *curbuf_save; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2203 typval_T rettv; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2204 int save_State = State; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2205 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2206 funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2207 if (*funcname == NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2208 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2209 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2210 // Call 'completefunc' to obtain the list of matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2211 args[0].v_type = VAR_NUMBER; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2212 args[0].vval.v_number = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2213 args[1].v_type = VAR_STRING; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2214 args[1].vval.v_string = base != NULL ? base : (char_u *)""; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2215 args[2].v_type = VAR_UNKNOWN; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2216 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2217 pos = curwin->w_cursor; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2218 curwin_save = curwin; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2219 curbuf_save = curbuf; |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
2220 // Lock the text to avoid weird things from happening. Do allow switching |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
2221 // to another window temporarily. |
20118
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2222 ++textlock; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2223 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2224 // Call a function, which returns a list or dict. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2225 if (call_vim_function(funcname, 2, args, &rettv) == OK) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2226 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2227 switch (rettv.v_type) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2228 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2229 case VAR_LIST: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2230 matchlist = rettv.vval.v_list; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2231 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2232 case VAR_DICT: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 matchdict = rettv.vval.v_dict; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2234 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2235 case VAR_SPECIAL: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2236 if (rettv.vval.v_number == VVAL_NONE) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2237 compl_opt_suppress_empty = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2238 // FALLTHROUGH |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2239 default: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2240 // TODO: Give error message? |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2241 clear_tv(&rettv); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2242 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2243 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2244 } |
20118
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2245 --textlock; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2246 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2247 if (curwin_save != curwin || curbuf_save != curbuf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2248 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2249 emsg(_(e_complwin)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2250 goto theend; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2251 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2252 curwin->w_cursor = pos; // restore the cursor position |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2253 validate_cursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2254 if (!EQUAL_POS(curwin->w_cursor, pos)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2255 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2256 emsg(_(e_compldel)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2257 goto theend; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2258 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2259 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2260 if (matchlist != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2261 ins_compl_add_list(matchlist); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2262 else if (matchdict != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2263 ins_compl_add_dict(matchdict); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2264 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2265 theend: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2266 // Restore State, it might have been changed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2267 State = save_State; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2268 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2269 if (matchdict != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2270 dict_unref(matchdict); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2271 if (matchlist != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2272 list_unref(matchlist); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2273 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2274 #endif // FEAT_COMPL_FUNC |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2275 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2276 #if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) || defined(PROTO) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2277 /* |
17704 | 2278 * Add a match to the list of matches from a typeval_T. |
2279 * If the given string is already in the list of completions, then return | |
2280 * NOTDONE, otherwise add it to the list and return OK. If there is an error, | |
2281 * maybe because alloc() returns NULL, then FAIL is returned. | |
2282 */ | |
2283 static int | |
2284 ins_compl_add_tv(typval_T *tv, int dir) | |
2285 { | |
2286 char_u *word; | |
2287 int dup = FALSE; | |
2288 int empty = FALSE; | |
2289 int flags = 0; | |
2290 char_u *(cptext[CPT_COUNT]); | |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2291 typval_T user_data; |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2292 |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2293 user_data.v_type = VAR_UNKNOWN; |
17704 | 2294 if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL) |
2295 { | |
2296 word = dict_get_string(tv->vval.v_dict, (char_u *)"word", FALSE); | |
2297 cptext[CPT_ABBR] = dict_get_string(tv->vval.v_dict, | |
2298 (char_u *)"abbr", FALSE); | |
2299 cptext[CPT_MENU] = dict_get_string(tv->vval.v_dict, | |
2300 (char_u *)"menu", FALSE); | |
2301 cptext[CPT_KIND] = dict_get_string(tv->vval.v_dict, | |
2302 (char_u *)"kind", FALSE); | |
2303 cptext[CPT_INFO] = dict_get_string(tv->vval.v_dict, | |
2304 (char_u *)"info", FALSE); | |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2305 dict_get_tv(tv->vval.v_dict, (char_u *)"user_data", &user_data); |
17704 | 2306 if (dict_get_string(tv->vval.v_dict, (char_u *)"icase", FALSE) != NULL |
2307 && dict_get_number(tv->vval.v_dict, (char_u *)"icase")) | |
2308 flags |= CP_ICASE; | |
2309 if (dict_get_string(tv->vval.v_dict, (char_u *)"dup", FALSE) != NULL) | |
2310 dup = dict_get_number(tv->vval.v_dict, (char_u *)"dup"); | |
2311 if (dict_get_string(tv->vval.v_dict, (char_u *)"empty", FALSE) != NULL) | |
2312 empty = dict_get_number(tv->vval.v_dict, (char_u *)"empty"); | |
2313 if (dict_get_string(tv->vval.v_dict, (char_u *)"equal", FALSE) != NULL | |
2314 && dict_get_number(tv->vval.v_dict, (char_u *)"equal")) | |
2315 flags |= CP_EQUAL; | |
2316 } | |
2317 else | |
2318 { | |
2319 word = tv_get_string_chk(tv); | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
2320 CLEAR_FIELD(cptext); |
17704 | 2321 } |
2322 if (word == NULL || (!empty && *word == NUL)) | |
2323 return FAIL; | |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2324 return ins_compl_add(word, -1, NULL, cptext, &user_data, dir, flags, dup); |
17704 | 2325 } |
2326 | |
2327 /* | |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2328 * Add completions from a list. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2329 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2330 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2331 ins_compl_add_list(list_T *list) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2332 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2333 listitem_T *li; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2334 int dir = compl_direction; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2335 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2336 // Go through the List with matches and add each of them. |
20392
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2337 CHECK_LIST_MATERIALIZE(list); |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
2338 FOR_ALL_LIST_ITEMS(list, li) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2339 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2340 if (ins_compl_add_tv(&li->li_tv, dir) == OK) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2341 // if dir was BACKWARD then honor it just once |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2342 dir = FORWARD; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2343 else if (did_emsg) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2344 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2345 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2346 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2347 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2348 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2349 * Add completions from a dict. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2350 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2351 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2352 ins_compl_add_dict(dict_T *dict) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2353 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2354 dictitem_T *di_refresh; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2355 dictitem_T *di_words; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2356 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2357 // Check for optional "refresh" item. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2358 compl_opt_refresh_always = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2359 di_refresh = dict_find(dict, (char_u *)"refresh", 7); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2360 if (di_refresh != NULL && di_refresh->di_tv.v_type == VAR_STRING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2361 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2362 char_u *v = di_refresh->di_tv.vval.v_string; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2363 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2364 if (v != NULL && STRCMP(v, (char_u *)"always") == 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2365 compl_opt_refresh_always = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2366 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2367 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2368 // Add completions from a "words" list. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2369 di_words = dict_find(dict, (char_u *)"words", 5); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2370 if (di_words != NULL && di_words->di_tv.v_type == VAR_LIST) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2371 ins_compl_add_list(di_words->di_tv.vval.v_list); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2372 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2373 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2374 /* |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2375 * Start completion for the complete() function. |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2376 * "startcol" is where the matched text starts (1 is first column). |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2377 * "list" is the list of matches. |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2378 */ |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2379 static void |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2380 set_completion(colnr_T startcol, list_T *list) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2381 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2382 int save_w_wrow = curwin->w_wrow; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2383 int save_w_leftcol = curwin->w_leftcol; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2384 int flags = CP_ORIGINAL_TEXT; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2385 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2386 // If already doing completions stop it. |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2387 if (ctrl_x_mode != CTRL_X_NORMAL) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2388 ins_compl_prep(' '); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2389 ins_compl_clear(); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2390 ins_compl_free(); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2391 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2392 compl_direction = FORWARD; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2393 if (startcol > curwin->w_cursor.col) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2394 startcol = curwin->w_cursor.col; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2395 compl_col = startcol; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2396 compl_length = (int)curwin->w_cursor.col - (int)startcol; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2397 // compl_pattern doesn't need to be set |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2398 compl_orig_text = vim_strnsave(ml_get_curline() + compl_col, compl_length); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2399 if (p_ic) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2400 flags |= CP_ICASE; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2401 if (compl_orig_text == NULL || ins_compl_add(compl_orig_text, |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2402 -1, NULL, NULL, NULL, 0, flags, FALSE) != OK) |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2403 return; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2404 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2405 ctrl_x_mode = CTRL_X_EVAL; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2406 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2407 ins_compl_add_list(list); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2408 compl_matches = ins_compl_make_cyclic(); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2409 compl_started = TRUE; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2410 compl_used_match = TRUE; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2411 compl_cont_status = 0; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2412 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2413 compl_curr_match = compl_first_match; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2414 if (compl_no_insert || compl_no_select) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2415 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2416 ins_complete(K_DOWN, FALSE); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2417 if (compl_no_select) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2418 // Down/Up has no real effect. |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2419 ins_complete(K_UP, FALSE); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2420 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2421 else |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2422 ins_complete(Ctrl_N, FALSE); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2423 compl_enter_selects = compl_no_insert; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2424 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2425 // Lazily show the popup menu, unless we got interrupted. |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2426 if (!compl_interrupted) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2427 show_pum(save_w_wrow, save_w_leftcol); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2428 out_flush(); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2429 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2430 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2431 /* |
17704 | 2432 * "complete()" function |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2433 */ |
17704 | 2434 void |
2435 f_complete(typval_T *argvars, typval_T *rettv UNUSED) | |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2436 { |
17704 | 2437 int startcol; |
20118
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2438 int save_textlock = textlock; |
17704 | 2439 |
2440 if ((State & INSERT) == 0) | |
2441 { | |
2442 emsg(_("E785: complete() can only be used in Insert mode")); | |
2443 return; | |
2444 } | |
2445 | |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
2446 // "textlock" is set when evaluating 'completefunc' but we can change |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
2447 // text here. |
20118
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2448 textlock = 0; |
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2449 |
17704 | 2450 // Check for undo allowed here, because if something was already inserted |
2451 // the line was already saved for undo and this check isn't done. | |
2452 if (!undo_allowed()) | |
2453 return; | |
2454 | |
2455 if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL) | |
20118
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2456 emsg(_(e_invarg)); |
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2457 else |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2458 { |
20118
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2459 startcol = (int)tv_get_number_chk(&argvars[0], NULL); |
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2460 if (startcol > 0) |
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2461 set_completion(startcol - 1, argvars[1].vval.v_list); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2462 } |
20118
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2463 textlock = save_textlock; |
17704 | 2464 } |
2465 | |
2466 /* | |
2467 * "complete_add()" function | |
2468 */ | |
2469 void | |
2470 f_complete_add(typval_T *argvars, typval_T *rettv) | |
2471 { | |
2472 rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0); | |
2473 } | |
2474 | |
2475 /* | |
2476 * "complete_check()" function | |
2477 */ | |
2478 void | |
2479 f_complete_check(typval_T *argvars UNUSED, typval_T *rettv) | |
2480 { | |
2481 int saved = RedrawingDisabled; | |
2482 | |
2483 RedrawingDisabled = 0; | |
2484 ins_compl_check_keys(0, TRUE); | |
2485 rettv->vval.v_number = ins_compl_interrupted(); | |
2486 RedrawingDisabled = saved; | |
2487 } | |
2488 | |
2489 /* | |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2490 * Return Insert completion mode name string |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2491 */ |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2492 static char_u * |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2493 ins_compl_mode(void) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2494 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2495 if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET || compl_started) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2496 return (char_u *)ctrl_x_mode_names[ctrl_x_mode & ~CTRL_X_WANT_IDENT]; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2497 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2498 return (char_u *)""; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2499 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2500 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2501 /* |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2502 * Get complete information |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2503 */ |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2504 static void |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2505 get_complete_info(list_T *what_list, dict_T *retdict) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2506 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2507 int ret = OK; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2508 listitem_T *item; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2509 #define CI_WHAT_MODE 0x01 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2510 #define CI_WHAT_PUM_VISIBLE 0x02 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2511 #define CI_WHAT_ITEMS 0x04 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2512 #define CI_WHAT_SELECTED 0x08 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2513 #define CI_WHAT_INSERTED 0x10 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2514 #define CI_WHAT_ALL 0xff |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2515 int what_flag; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2516 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2517 if (what_list == NULL) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2518 what_flag = CI_WHAT_ALL; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2519 else |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2520 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2521 what_flag = 0; |
20392
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2522 CHECK_LIST_MATERIALIZE(what_list); |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
2523 FOR_ALL_LIST_ITEMS(what_list, item) |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2524 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2525 char_u *what = tv_get_string(&item->li_tv); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2526 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2527 if (STRCMP(what, "mode") == 0) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2528 what_flag |= CI_WHAT_MODE; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2529 else if (STRCMP(what, "pum_visible") == 0) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2530 what_flag |= CI_WHAT_PUM_VISIBLE; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2531 else if (STRCMP(what, "items") == 0) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2532 what_flag |= CI_WHAT_ITEMS; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2533 else if (STRCMP(what, "selected") == 0) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2534 what_flag |= CI_WHAT_SELECTED; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2535 else if (STRCMP(what, "inserted") == 0) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2536 what_flag |= CI_WHAT_INSERTED; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2537 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2538 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2539 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2540 if (ret == OK && (what_flag & CI_WHAT_MODE)) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2541 ret = dict_add_string(retdict, "mode", ins_compl_mode()); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2542 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2543 if (ret == OK && (what_flag & CI_WHAT_PUM_VISIBLE)) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2544 ret = dict_add_number(retdict, "pum_visible", pum_visible()); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2545 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2546 if (ret == OK && (what_flag & CI_WHAT_ITEMS)) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2547 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2548 list_T *li; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2549 dict_T *di; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2550 compl_T *match; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2551 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2552 li = list_alloc(); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2553 if (li == NULL) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2554 return; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2555 ret = dict_add_list(retdict, "items", li); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2556 if (ret == OK && compl_first_match != NULL) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2557 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2558 match = compl_first_match; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2559 do |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2560 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2561 if (!(match->cp_flags & CP_ORIGINAL_TEXT)) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2562 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2563 di = dict_alloc(); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2564 if (di == NULL) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2565 return; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2566 ret = list_append_dict(li, di); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2567 if (ret != OK) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2568 return; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2569 dict_add_string(di, "word", match->cp_str); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2570 dict_add_string(di, "abbr", match->cp_text[CPT_ABBR]); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2571 dict_add_string(di, "menu", match->cp_text[CPT_MENU]); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2572 dict_add_string(di, "kind", match->cp_text[CPT_KIND]); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2573 dict_add_string(di, "info", match->cp_text[CPT_INFO]); |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2574 if (match->cp_user_data.v_type == VAR_UNKNOWN) |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2575 // Add an empty string for backwards compatibility |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2576 dict_add_string(di, "user_data", (char_u *)""); |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2577 else |
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
2578 dict_add_tv(di, "user_data", &match->cp_user_data); |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2579 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2580 match = match->cp_next; |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2581 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2582 while (match != NULL && match != compl_first_match); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2583 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2584 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2585 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2586 if (ret == OK && (what_flag & CI_WHAT_SELECTED)) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2587 ret = dict_add_number(retdict, "selected", (compl_curr_match != NULL) ? |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2588 compl_curr_match->cp_number - 1 : -1); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2589 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2590 // TODO |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2591 // if (ret == OK && (what_flag & CI_WHAT_INSERTED)) |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2592 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2593 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
2594 /* |
17704 | 2595 * "complete_info()" function |
2596 */ | |
2597 void | |
2598 f_complete_info(typval_T *argvars, typval_T *rettv) | |
2599 { | |
2600 list_T *what_list = NULL; | |
2601 | |
2602 if (rettv_dict_alloc(rettv) != OK) | |
2603 return; | |
2604 | |
2605 if (argvars[0].v_type != VAR_UNKNOWN) | |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2606 { |
17704 | 2607 if (argvars[0].v_type != VAR_LIST) |
2608 { | |
2609 emsg(_(e_listreq)); | |
2610 return; | |
2611 } | |
2612 what_list = argvars[0].vval.v_list; | |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2613 } |
17704 | 2614 get_complete_info(what_list, rettv->vval.v_dict); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2615 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2616 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2617 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2618 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2619 * Get the next expansion(s), using "compl_pattern". |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2620 * The search starts at position "ini" in curbuf and in the direction |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2621 * compl_direction. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2622 * When "compl_started" is FALSE start at that position, otherwise continue |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2623 * where we stopped searching before. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2624 * This may return before finding all the matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2625 * Return the total number of matches or -1 if still unknown -- Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2626 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2627 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2628 ins_compl_get_exp(pos_T *ini) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2629 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2630 static pos_T first_match_pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2631 static pos_T last_match_pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2632 static char_u *e_cpt = (char_u *)""; // curr. entry in 'complete' |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2633 static int found_all = FALSE; // Found all matches of a |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2634 // certain type. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2635 static buf_T *ins_buf = NULL; // buffer being scanned |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2636 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2637 pos_T *pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2638 char_u **matches; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2639 int save_p_scs; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2640 int save_p_ws; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2641 int save_p_ic; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2642 int i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2643 int num_matches; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2644 int len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2645 int found_new_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2646 int type = ctrl_x_mode; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2647 char_u *ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2648 char_u *dict = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2649 int dict_f = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2650 int set_match_pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2651 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2652 if (!compl_started) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2653 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2654 FOR_ALL_BUFFERS(ins_buf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2655 ins_buf->b_scanned = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2656 found_all = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2657 ins_buf = curbuf; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2658 e_cpt = (compl_cont_status & CONT_LOCAL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2659 ? (char_u *)"." : curbuf->b_p_cpt; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2660 last_match_pos = first_match_pos = *ini; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2661 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2662 else if (ins_buf != curbuf && !buf_valid(ins_buf)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2663 ins_buf = curbuf; // In case the buffer was wiped out. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2664 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2665 compl_old_match = compl_curr_match; // remember the last current match |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2666 pos = (compl_direction == FORWARD) ? &last_match_pos : &first_match_pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2667 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2668 // For ^N/^P loop over all the flags/windows/buffers in 'complete'. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2669 for (;;) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2670 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2671 found_new_match = FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2672 set_match_pos = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2673 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2674 // For ^N/^P pick a new entry from e_cpt if compl_started is off, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2675 // or if found_all says this entry is done. For ^X^L only use the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2676 // entries from 'complete' that look in loaded buffers. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2677 if ((ctrl_x_mode == CTRL_X_NORMAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2678 || ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2679 && (!compl_started || found_all)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2680 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2681 found_all = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2682 while (*e_cpt == ',' || *e_cpt == ' ') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2683 e_cpt++; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 if (*e_cpt == '.' && !curbuf->b_scanned) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2685 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2686 ins_buf = curbuf; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2687 first_match_pos = *ini; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2688 // Move the cursor back one character so that ^N can match the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2689 // word immediately after the cursor. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2690 if (ctrl_x_mode == CTRL_X_NORMAL && dec(&first_match_pos) < 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2691 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2692 // Move the cursor to after the last character in the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2693 // buffer, so that word at start of buffer is found |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2694 // correctly. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2695 first_match_pos.lnum = ins_buf->b_ml.ml_line_count; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2696 first_match_pos.col = |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2697 (colnr_T)STRLEN(ml_get(first_match_pos.lnum)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2698 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2699 last_match_pos = first_match_pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2700 type = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2701 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2702 // Remember the first match so that the loop stops when we |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2703 // wrap and come back there a second time. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2704 set_match_pos = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2705 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2706 else if (vim_strchr((char_u *)"buwU", *e_cpt) != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 && (ins_buf = ins_compl_next_buf(ins_buf, *e_cpt)) != curbuf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2708 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2709 // Scan a buffer, but not the current one. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2710 if (ins_buf->b_ml.ml_mfp != NULL) // loaded buffer |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2711 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2712 compl_started = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2713 first_match_pos.col = last_match_pos.col = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2714 first_match_pos.lnum = ins_buf->b_ml.ml_line_count + 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2715 last_match_pos.lnum = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2716 type = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2717 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2718 else // unloaded buffer, scan like dictionary |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2719 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2720 found_all = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2721 if (ins_buf->b_fname == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2722 continue; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2723 type = CTRL_X_DICTIONARY; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2724 dict = ins_buf->b_fname; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2725 dict_f = DICT_EXACT; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2726 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2727 vim_snprintf((char *)IObuff, IOSIZE, _("Scanning: %s"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2728 ins_buf->b_fname == NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2729 ? buf_spname(ins_buf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2730 : ins_buf->b_sfname == NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2731 ? ins_buf->b_fname |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2732 : ins_buf->b_sfname); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2733 (void)msg_trunc_attr((char *)IObuff, TRUE, HL_ATTR(HLF_R)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2734 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2735 else if (*e_cpt == NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2736 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2737 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2738 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2739 if (ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2740 type = -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2741 else if (*e_cpt == 'k' || *e_cpt == 's') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2742 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2743 if (*e_cpt == 'k') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2744 type = CTRL_X_DICTIONARY; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2745 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2746 type = CTRL_X_THESAURUS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2747 if (*++e_cpt != ',' && *e_cpt != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2748 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2749 dict = e_cpt; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2750 dict_f = DICT_FIRST; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2751 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2752 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2753 #ifdef FEAT_FIND_ID |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2754 else if (*e_cpt == 'i') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2755 type = CTRL_X_PATH_PATTERNS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2756 else if (*e_cpt == 'd') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2757 type = CTRL_X_PATH_DEFINES; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2758 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2759 else if (*e_cpt == ']' || *e_cpt == 't') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2760 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2761 type = CTRL_X_TAGS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2762 vim_snprintf((char *)IObuff, IOSIZE, _("Scanning tags.")); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2763 (void)msg_trunc_attr((char *)IObuff, TRUE, HL_ATTR(HLF_R)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2764 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2765 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2766 type = -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2767 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2768 // in any case e_cpt is advanced to the next entry |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2769 (void)copy_option_part(&e_cpt, IObuff, IOSIZE, ","); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2770 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2771 found_all = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2772 if (type == -1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2773 continue; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2774 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2775 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2776 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2777 // If complete() was called then compl_pattern has been reset. The |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2778 // following won't work then, bail out. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2779 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2780 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2781 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2782 switch (type) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2783 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2784 case -1: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2785 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2786 #ifdef FEAT_FIND_ID |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2787 case CTRL_X_PATH_PATTERNS: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2788 case CTRL_X_PATH_DEFINES: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2789 find_pattern_in_path(compl_pattern, compl_direction, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2790 (int)STRLEN(compl_pattern), FALSE, FALSE, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2791 (type == CTRL_X_PATH_DEFINES |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2792 && !(compl_cont_status & CONT_SOL)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2793 ? FIND_DEFINE : FIND_ANY, 1L, ACTION_EXPAND, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2794 (linenr_T)1, (linenr_T)MAXLNUM); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2795 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2796 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2797 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2798 case CTRL_X_DICTIONARY: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2799 case CTRL_X_THESAURUS: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2800 ins_compl_dictionaries( |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2801 dict != NULL ? dict |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2802 : (type == CTRL_X_THESAURUS |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2803 ? (*curbuf->b_p_tsr == NUL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2804 ? p_tsr |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2805 : curbuf->b_p_tsr) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2806 : (*curbuf->b_p_dict == NUL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2807 ? p_dict |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2808 : curbuf->b_p_dict)), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2809 compl_pattern, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2810 dict != NULL ? dict_f |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2811 : 0, type == CTRL_X_THESAURUS); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2812 dict = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2813 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2814 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2815 case CTRL_X_TAGS: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2816 // set p_ic according to p_ic, p_scs and pat for find_tags(). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2817 save_p_ic = p_ic; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2818 p_ic = ignorecase(compl_pattern); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2819 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2820 // Find up to TAG_MANY matches. Avoids that an enormous number |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2821 // of matches is found when compl_pattern is empty |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16268
diff
changeset
|
2822 g_tag_at_cursor = TRUE; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2823 if (find_tags(compl_pattern, &num_matches, &matches, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2824 TAG_REGEXP | TAG_NAMES | TAG_NOIC | TAG_INS_COMP |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2825 | (ctrl_x_mode != CTRL_X_NORMAL ? TAG_VERBOSE : 0), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2826 TAG_MANY, curbuf->b_ffname) == OK && num_matches > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2827 ins_compl_add_matches(num_matches, matches, p_ic); |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16268
diff
changeset
|
2828 g_tag_at_cursor = FALSE; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2829 p_ic = save_p_ic; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2830 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2831 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2832 case CTRL_X_FILES: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2833 if (expand_wildcards(1, &compl_pattern, &num_matches, &matches, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2834 EW_FILE|EW_DIR|EW_ADDSLASH|EW_SILENT) == OK) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2835 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2836 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2837 // May change home directory back to "~". |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2838 tilde_replace(compl_pattern, num_matches, matches); |
17543
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2839 #ifdef BACKSLASH_IN_FILENAME |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2840 if (curbuf->b_p_csl[0] != NUL) |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2841 { |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2842 int i; |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2843 |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2844 for (i = 0; i < num_matches; ++i) |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2845 { |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2846 char_u *ptr = matches[i]; |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2847 |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2848 while (*ptr != NUL) |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2849 { |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2850 if (curbuf->b_p_csl[0] == 's' && *ptr == '\\') |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2851 *ptr = '/'; |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2852 else if (curbuf->b_p_csl[0] == 'b' && *ptr == '/') |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2853 *ptr = '\\'; |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2854 ptr += (*mb_ptr2len)(ptr); |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2855 } |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2856 } |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2857 } |
77c3f6428b6c
patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2858 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2859 ins_compl_add_matches(num_matches, matches, p_fic || p_wic); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2860 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2861 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2862 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2863 case CTRL_X_CMDLINE: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2864 if (expand_cmdline(&compl_xp, compl_pattern, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2865 (int)STRLEN(compl_pattern), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2866 &num_matches, &matches) == EXPAND_OK) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2867 ins_compl_add_matches(num_matches, matches, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2868 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2869 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2870 #ifdef FEAT_COMPL_FUNC |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2871 case CTRL_X_FUNCTION: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2872 case CTRL_X_OMNI: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2873 expand_by_function(type, compl_pattern); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2874 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2875 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2876 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2877 case CTRL_X_SPELL: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2878 #ifdef FEAT_SPELL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2879 num_matches = expand_spelling(first_match_pos.lnum, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2880 compl_pattern, &matches); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2881 if (num_matches > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2882 ins_compl_add_matches(num_matches, matches, p_ic); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2883 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2884 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2885 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2886 default: // normal ^P/^N and ^X^L |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2887 // If 'infercase' is set, don't use 'smartcase' here |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2888 save_p_scs = p_scs; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2889 if (ins_buf->b_p_inf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2890 p_scs = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2891 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2892 // Buffers other than curbuf are scanned from the beginning or the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2893 // end but never from the middle, thus setting nowrapscan in this |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
2894 // buffer is a good idea, on the other hand, we always set |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2895 // wrapscan for curbuf to avoid missing matches -- Acevedo,Webb |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2896 save_p_ws = p_ws; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2897 if (ins_buf != curbuf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2898 p_ws = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2899 else if (*e_cpt == '.') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2900 p_ws = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2901 for (;;) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2902 { |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
2903 int cont_s_ipos = FALSE; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2904 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2905 ++msg_silent; // Don't want messages for wrapscan. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2906 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2907 // ctrl_x_mode_line_or_eval() || word-wise search that |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2908 // has added a word that was at the beginning of the line |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2909 if (ctrl_x_mode_line_or_eval() |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2910 || (compl_cont_status & CONT_SOL)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2911 found_new_match = search_for_exact_line(ins_buf, pos, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2912 compl_direction, compl_pattern); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2913 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2914 found_new_match = searchit(NULL, ins_buf, pos, NULL, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2915 compl_direction, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2916 compl_pattern, 1L, SEARCH_KEEP + SEARCH_NFMSG, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18203
diff
changeset
|
2917 RE_LAST, NULL); |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2918 --msg_silent; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2919 if (!compl_started || set_match_pos) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2920 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2921 // set "compl_started" even on fail |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2922 compl_started = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2923 first_match_pos = *pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2924 last_match_pos = *pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2925 set_match_pos = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2926 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2927 else if (first_match_pos.lnum == last_match_pos.lnum |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2928 && first_match_pos.col == last_match_pos.col) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2929 found_new_match = FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2930 if (found_new_match == FAIL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2931 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2932 if (ins_buf == curbuf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2933 found_all = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2934 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2935 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2936 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2937 // when ADDING, the text before the cursor matches, skip it |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2938 if ( (compl_cont_status & CONT_ADDING) && ins_buf == curbuf |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2939 && ini->lnum == pos->lnum |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2940 && ini->col == pos->col) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2941 continue; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2942 ptr = ml_get_buf(ins_buf, pos->lnum, FALSE) + pos->col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2943 if (ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2944 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2945 if (compl_cont_status & CONT_ADDING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2946 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2947 if (pos->lnum >= ins_buf->b_ml.ml_line_count) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2948 continue; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2949 ptr = ml_get_buf(ins_buf, pos->lnum + 1, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2950 if (!p_paste) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2951 ptr = skipwhite(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2952 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2953 len = (int)STRLEN(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2954 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2955 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2956 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2957 char_u *tmp_ptr = ptr; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2958 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2959 if (compl_cont_status & CONT_ADDING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2960 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2961 tmp_ptr += compl_length; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2962 // Skip if already inside a word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2963 if (vim_iswordp(tmp_ptr)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2964 continue; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2965 // Find start of next word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2966 tmp_ptr = find_word_start(tmp_ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2967 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2968 // Find end of this word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2969 tmp_ptr = find_word_end(tmp_ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2970 len = (int)(tmp_ptr - ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2971 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2972 if ((compl_cont_status & CONT_ADDING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2973 && len == compl_length) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2974 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2975 if (pos->lnum < ins_buf->b_ml.ml_line_count) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2976 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2977 // Try next line, if any. the new word will be |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2978 // "join" as if the normal command "J" was used. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2979 // IOSIZE is always greater than |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2980 // compl_length, so the next STRNCPY always |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2981 // works -- Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2982 STRNCPY(IObuff, ptr, len); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2983 ptr = ml_get_buf(ins_buf, pos->lnum + 1, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2984 tmp_ptr = ptr = skipwhite(ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2985 // Find start of next word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2986 tmp_ptr = find_word_start(tmp_ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2987 // Find end of next word. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2988 tmp_ptr = find_word_end(tmp_ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2989 if (tmp_ptr > ptr) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2990 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2991 if (*ptr != ')' && IObuff[len - 1] != TAB) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2992 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2993 if (IObuff[len - 1] != ' ') |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2994 IObuff[len++] = ' '; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2995 // IObuf =~ "\k.* ", thus len >= 2 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2996 if (p_js |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2997 && (IObuff[len - 2] == '.' |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2998 || (vim_strchr(p_cpo, CPO_JOINSP) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2999 == NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3000 && (IObuff[len - 2] == '?' |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3001 || IObuff[len - 2] == '!')))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3002 IObuff[len++] = ' '; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3003 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3004 // copy as much as possible of the new word |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3005 if (tmp_ptr - ptr >= IOSIZE - len) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3006 tmp_ptr = ptr + IOSIZE - len - 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3007 STRNCPY(IObuff + len, ptr, tmp_ptr - ptr); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3008 len += (int)(tmp_ptr - ptr); |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3009 cont_s_ipos = TRUE; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3010 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3011 IObuff[len] = NUL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3012 ptr = IObuff; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3013 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3014 if (len == compl_length) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3015 continue; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3016 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3017 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3018 if (ins_compl_add_infercase(ptr, len, p_ic, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3019 ins_buf == curbuf ? NULL : ins_buf->b_sfname, |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3020 0, cont_s_ipos) != NOTDONE) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3021 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3022 found_new_match = OK; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3023 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3024 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3025 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3026 p_scs = save_p_scs; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3027 p_ws = save_p_ws; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3028 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3029 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3030 // check if compl_curr_match has changed, (e.g. other type of |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3031 // expansion added something) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3032 if (type != 0 && compl_curr_match != compl_old_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3033 found_new_match = OK; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3034 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3035 // break the loop for specialized modes (use 'complete' just for the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3036 // generic ctrl_x_mode == CTRL_X_NORMAL) or when we've found a new |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3037 // match |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3038 if ((ctrl_x_mode != CTRL_X_NORMAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3039 && !ctrl_x_mode_line_or_eval()) || found_new_match != FAIL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3040 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3041 if (got_int) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3042 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3043 // Fill the popup menu as soon as possible. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3044 if (type != -1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3045 ins_compl_check_keys(0, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3046 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3047 if ((ctrl_x_mode != CTRL_X_NORMAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3048 && !ctrl_x_mode_line_or_eval()) || compl_interrupted) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3049 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3050 compl_started = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3051 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3052 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3053 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3054 // Mark a buffer scanned when it has been scanned completely |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3055 if (type == 0 || type == CTRL_X_PATH_PATTERNS) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3056 ins_buf->b_scanned = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3057 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3058 compl_started = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3059 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3060 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3061 compl_started = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3062 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3063 if ((ctrl_x_mode == CTRL_X_NORMAL || ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3064 && *e_cpt == NUL) // Got to end of 'complete' |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3065 found_new_match = FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3066 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3067 i = -1; // total of matches, unknown |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3068 if (found_new_match == FAIL || (ctrl_x_mode != CTRL_X_NORMAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3069 && !ctrl_x_mode_line_or_eval())) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3070 i = ins_compl_make_cyclic(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3071 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3072 if (compl_old_match != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3073 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3074 // If several matches were added (FORWARD) or the search failed and has |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3075 // just been made cyclic then we have to move compl_curr_match to the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3076 // next or previous entry (if any) -- Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3077 compl_curr_match = compl_direction == FORWARD ? compl_old_match->cp_next |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3078 : compl_old_match->cp_prev; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3079 if (compl_curr_match == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3080 compl_curr_match = compl_old_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3081 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3082 return i; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3083 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3084 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3085 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3086 * Delete the old text being completed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3087 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3088 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3089 ins_compl_delete(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3090 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3091 int col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3092 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3093 // In insert mode: Delete the typed part. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3094 // In replace mode: Put the old characters back, if any. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3095 col = compl_col + (compl_cont_status & CONT_ADDING ? compl_length : 0); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3096 if ((int)curwin->w_cursor.col > col) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3097 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3098 if (stop_arrow() == FAIL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3099 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3100 backspace_until_column(col); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3101 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3102 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3103 // TODO: is this sufficient for redrawing? Redrawing everything causes |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3104 // flicker, thus we can't do that. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3105 changed_cline_bef_curs(); |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3106 #ifdef FEAT_EVAL |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3107 // clear v:completed_item |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3108 set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED)); |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3109 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3110 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3111 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3112 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3113 * Insert the new text being completed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3114 * "in_compl_func" is TRUE when called from complete_check(). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3115 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3116 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3117 ins_compl_insert(int in_compl_func) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3118 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3119 ins_bytes(compl_shown_match->cp_str + ins_compl_len()); |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3120 if (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3121 compl_used_match = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3122 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3123 compl_used_match = TRUE; |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3124 #ifdef FEAT_EVAL |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3125 { |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3126 dict_T *dict = ins_compl_dict_alloc(compl_shown_match); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3127 |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3128 set_vim_var_dict(VV_COMPLETED_ITEM, dict); |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3129 } |
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3130 #endif |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3131 if (!in_compl_func) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3132 compl_curr_match = compl_shown_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3133 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3134 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3135 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3136 * Fill in the next completion in the current direction. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3137 * If "allow_get_expansion" is TRUE, then we may call ins_compl_get_exp() to |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3138 * get more completions. If it is FALSE, then we just do nothing when there |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3139 * are no more completions in a given direction. The latter case is used when |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3140 * we are still in the middle of finding completions, to allow browsing |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3141 * through the ones found so far. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3142 * Return the total number of matches, or -1 if still unknown -- webb. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3143 * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3144 * compl_curr_match is currently being used by ins_compl_get_exp(), so we use |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3145 * compl_shown_match here. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3146 * |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3147 * Note that this function may be called recursively once only. First with |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3148 * "allow_get_expansion" TRUE, which calls ins_compl_get_exp(), which in turn |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3149 * calls this function with "allow_get_expansion" FALSE. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3150 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3151 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3152 ins_compl_next( |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3153 int allow_get_expansion, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3154 int count, // repeat completion this many times; should |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3155 // be at least 1 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3156 int insert_match, // Insert the newly selected match |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3157 int in_compl_func) // called from complete_check() |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3158 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3159 int num_matches = -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3160 int todo = count; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3161 compl_T *found_compl = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3162 int found_end = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3163 int advance; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3164 int started = compl_started; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3165 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3166 // When user complete function return -1 for findstart which is next |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3167 // time of 'always', compl_shown_match become NULL. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3168 if (compl_shown_match == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3169 return -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3170 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3171 if (compl_leader != NULL |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3172 && (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) == 0) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3173 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3174 // Set "compl_shown_match" to the actually shown match, it may differ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3175 // when "compl_leader" is used to omit some of the matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3176 while (!ins_compl_equal(compl_shown_match, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3177 compl_leader, (int)STRLEN(compl_leader)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3178 && compl_shown_match->cp_next != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3179 && compl_shown_match->cp_next != compl_first_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3180 compl_shown_match = compl_shown_match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3181 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3182 // If we didn't find it searching forward, and compl_shows_dir is |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3183 // backward, find the last match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3184 if (compl_shows_dir == BACKWARD |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3185 && !ins_compl_equal(compl_shown_match, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3186 compl_leader, (int)STRLEN(compl_leader)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3187 && (compl_shown_match->cp_next == NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3188 || compl_shown_match->cp_next == compl_first_match)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3189 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3190 while (!ins_compl_equal(compl_shown_match, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3191 compl_leader, (int)STRLEN(compl_leader)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3192 && compl_shown_match->cp_prev != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3193 && compl_shown_match->cp_prev != compl_first_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3194 compl_shown_match = compl_shown_match->cp_prev; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3195 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3196 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3197 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3198 if (allow_get_expansion && insert_match |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3199 && (!(compl_get_longest || compl_restarting) || compl_used_match)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3200 // Delete old text to be replaced |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3201 ins_compl_delete(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3202 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3203 // When finding the longest common text we stick at the original text, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3204 // don't let CTRL-N or CTRL-P move to the first match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3205 advance = count != 1 || !allow_get_expansion || !compl_get_longest; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3206 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3207 // When restarting the search don't insert the first match either. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3208 if (compl_restarting) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3209 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3210 advance = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3211 compl_restarting = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3212 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3213 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3214 // Repeat this for when <PageUp> or <PageDown> is typed. But don't wrap |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3215 // around. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3216 while (--todo >= 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3217 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3218 if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3219 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3220 compl_shown_match = compl_shown_match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3221 found_end = (compl_first_match != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3222 && (compl_shown_match->cp_next == compl_first_match |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3223 || compl_shown_match == compl_first_match)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3224 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3225 else if (compl_shows_dir == BACKWARD |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3226 && compl_shown_match->cp_prev != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3227 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3228 found_end = (compl_shown_match == compl_first_match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3229 compl_shown_match = compl_shown_match->cp_prev; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3230 found_end |= (compl_shown_match == compl_first_match); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3231 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3232 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3233 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3234 if (!allow_get_expansion) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3235 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3236 if (advance) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3237 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3238 if (compl_shows_dir == BACKWARD) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3239 compl_pending -= todo + 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3240 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3241 compl_pending += todo + 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3242 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3243 return -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3244 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3245 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3246 if (!compl_no_select && advance) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3247 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3248 if (compl_shows_dir == BACKWARD) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3249 --compl_pending; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3250 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3251 ++compl_pending; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3252 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3253 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3254 // Find matches. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3255 num_matches = ins_compl_get_exp(&compl_startpos); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3256 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3257 // handle any pending completions |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3258 while (compl_pending != 0 && compl_direction == compl_shows_dir |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3259 && advance) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3260 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3261 if (compl_pending > 0 && compl_shown_match->cp_next != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3262 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3263 compl_shown_match = compl_shown_match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3264 --compl_pending; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3265 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3266 if (compl_pending < 0 && compl_shown_match->cp_prev != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3267 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3268 compl_shown_match = compl_shown_match->cp_prev; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3269 ++compl_pending; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3270 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3271 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3272 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3273 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3274 found_end = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3275 } |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3276 if ((compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) == 0 |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3277 && compl_leader != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3278 && !ins_compl_equal(compl_shown_match, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3279 compl_leader, (int)STRLEN(compl_leader))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3280 ++todo; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3281 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3282 // Remember a matching item. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3283 found_compl = compl_shown_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3284 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3285 // Stop at the end of the list when we found a usable match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3286 if (found_end) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3287 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3288 if (found_compl != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3289 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3290 compl_shown_match = found_compl; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3291 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3292 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3293 todo = 1; // use first usable match after wrapping around |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3294 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3295 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3296 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3297 // Insert the text of the new completion, or the compl_leader. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3298 if (compl_no_insert && !started) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3299 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3300 ins_bytes(compl_orig_text + ins_compl_len()); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3301 compl_used_match = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3302 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3303 else if (insert_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3304 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3305 if (!compl_get_longest || compl_used_match) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3306 ins_compl_insert(in_compl_func); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3307 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3308 ins_bytes(compl_leader + ins_compl_len()); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3309 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3310 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3311 compl_used_match = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3312 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3313 if (!allow_get_expansion) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3314 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3315 // may undisplay the popup menu first |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3316 ins_compl_upd_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3317 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3318 if (pum_enough_matches()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3319 // Will display the popup menu, don't redraw yet to avoid flicker. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3320 pum_call_update_screen(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3321 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3322 // Not showing the popup menu yet, redraw to show the user what was |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3323 // inserted. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3324 update_screen(0); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3325 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3326 // display the updated popup menu |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3327 ins_compl_show_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3328 #ifdef FEAT_GUI |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3329 if (gui.in_use) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3330 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3331 // Show the cursor after the match, not after the redrawn text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3332 setcursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3333 out_flush_cursor(FALSE, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3334 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3335 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3336 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3337 // Delete old text to be replaced, since we're still searching and |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3338 // don't want to match ourselves! |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3339 ins_compl_delete(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3340 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3341 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3342 // Enter will select a match when the match wasn't inserted and the popup |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3343 // menu is visible. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3344 if (compl_no_insert && !started) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3345 compl_enter_selects = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3346 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3347 compl_enter_selects = !insert_match && compl_match_array != NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3348 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3349 // Show the file name for the match (if any) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3350 // Truncate the file name to avoid a wait for return. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3351 if (compl_shown_match->cp_fname != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3352 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3353 char *lead = _("match in file"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3354 int space = sc_col - vim_strsize((char_u *)lead) - 2; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3355 char_u *s; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3356 char_u *e; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3357 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3358 if (space > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3359 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3360 // We need the tail that fits. With double-byte encoding going |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3361 // back from the end is very slow, thus go from the start and keep |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3362 // the text that fits in "space" between "s" and "e". |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3363 for (s = e = compl_shown_match->cp_fname; *e != NUL; MB_PTR_ADV(e)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3364 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3365 space -= ptr2cells(e); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3366 while (space < 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3367 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3368 space += ptr2cells(s); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3369 MB_PTR_ADV(s); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3370 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3371 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3372 vim_snprintf((char *)IObuff, IOSIZE, "%s %s%s", lead, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3373 s > compl_shown_match->cp_fname ? "<" : "", s); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3374 msg((char *)IObuff); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3375 redraw_cmdline = FALSE; // don't overwrite! |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3376 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3377 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3378 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3379 return num_matches; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3380 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3381 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3382 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3383 * Call this while finding completions, to check whether the user has hit a key |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3384 * that should change the currently displayed completion, or exit completion |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3385 * mode. Also, when compl_pending is not zero, show a completion as soon as |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3386 * possible. -- webb |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3387 * "frequency" specifies out of how many calls we actually check. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3388 * "in_compl_func" is TRUE when called from complete_check(), don't set |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3389 * compl_curr_match. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3390 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3391 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3392 ins_compl_check_keys(int frequency, int in_compl_func) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3393 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3394 static int count = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3395 int c; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3396 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3397 // Don't check when reading keys from a script, :normal or feedkeys(). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3398 // That would break the test scripts. But do check for keys when called |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3399 // from complete_check(). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3400 if (!in_compl_func && (using_script() || ex_normal_busy)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3401 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3402 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3403 // Only do this at regular intervals |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3404 if (++count < frequency) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3405 return; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3406 count = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3407 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3408 // Check for a typed key. Do use mappings, otherwise vim_is_ctrl_x_key() |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3409 // can't do its work correctly. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3410 c = vpeekc_any(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3411 if (c != NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3412 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3413 if (vim_is_ctrl_x_key(c) && c != Ctrl_X && c != Ctrl_R) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3414 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3415 c = safe_vgetc(); // Eat the character |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3416 compl_shows_dir = ins_compl_key2dir(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3417 (void)ins_compl_next(FALSE, ins_compl_key2count(c), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3418 c != K_UP && c != K_DOWN, in_compl_func); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3419 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3420 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3421 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3422 // Need to get the character to have KeyTyped set. We'll put it |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3423 // back with vungetc() below. But skip K_IGNORE. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3424 c = safe_vgetc(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3425 if (c != K_IGNORE) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3426 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3427 // Don't interrupt completion when the character wasn't typed, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3428 // e.g., when doing @q to replay keys. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3429 if (c != Ctrl_R && KeyTyped) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3430 compl_interrupted = TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3431 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3432 vungetc(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3433 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3434 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3435 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3436 if (compl_pending != 0 && !got_int && !compl_no_insert) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3437 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3438 int todo = compl_pending > 0 ? compl_pending : -compl_pending; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3439 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3440 compl_pending = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3441 (void)ins_compl_next(FALSE, todo, TRUE, in_compl_func); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3442 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3443 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3444 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3445 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3446 * Decide the direction of Insert mode complete from the key typed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3447 * Returns BACKWARD or FORWARD. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3448 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3449 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3450 ins_compl_key2dir(int c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3451 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3452 if (c == Ctrl_P || c == Ctrl_L |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3453 || c == K_PAGEUP || c == K_KPAGEUP || c == K_S_UP || c == K_UP) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3454 return BACKWARD; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3455 return FORWARD; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3456 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3457 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3458 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3459 * Return TRUE for keys that are used for completion only when the popup menu |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3460 * is visible. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3461 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3462 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3463 ins_compl_pum_key(int c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3464 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3465 return pum_visible() && (c == K_PAGEUP || c == K_KPAGEUP || c == K_S_UP |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3466 || c == K_PAGEDOWN || c == K_KPAGEDOWN || c == K_S_DOWN |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3467 || c == K_UP || c == K_DOWN); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3468 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3469 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3470 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3471 * Decide the number of completions to move forward. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3472 * Returns 1 for most keys, height of the popup menu for page-up/down keys. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3473 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3474 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3475 ins_compl_key2count(int c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3476 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3477 int h; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3478 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3479 if (ins_compl_pum_key(c) && c != K_UP && c != K_DOWN) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3480 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3481 h = pum_get_height(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3482 if (h > 3) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3483 h -= 2; // keep some context |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3484 return h; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3485 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3486 return 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3487 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3488 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3489 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3490 * Return TRUE if completion with "c" should insert the match, FALSE if only |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3491 * to change the currently selected completion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3492 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3493 static int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3494 ins_compl_use_match(int c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3495 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3496 switch (c) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3497 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3498 case K_UP: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3499 case K_DOWN: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3500 case K_PAGEDOWN: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3501 case K_KPAGEDOWN: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3502 case K_S_DOWN: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3503 case K_PAGEUP: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3504 case K_KPAGEUP: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3505 case K_S_UP: |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3506 return FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3507 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3508 return TRUE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3509 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3510 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3511 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3512 * Do Insert mode completion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3513 * Called when character "c" was typed, which has a meaning for completion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3514 * Returns OK if completion was done, FAIL if something failed (out of mem). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3515 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3516 int |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3517 ins_complete(int c, int enable_pum) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3518 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3519 char_u *line; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3520 int startcol = 0; // column where searched text starts |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3521 colnr_T curs_col; // cursor column |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3522 int n; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3523 int save_w_wrow; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3524 int save_w_leftcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3525 int insert_match; |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3526 #ifdef FEAT_COMPL_FUNC |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3527 int save_did_ai = did_ai; |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3528 #endif |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3529 int flags = CP_ORIGINAL_TEXT; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3530 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3531 compl_direction = ins_compl_key2dir(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3532 insert_match = ins_compl_use_match(c); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3533 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3534 if (!compl_started) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3535 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3536 // First time we hit ^N or ^P (in a row, I mean) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3537 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3538 did_ai = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3539 #ifdef FEAT_SMARTINDENT |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3540 did_si = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3541 can_si = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3542 can_si_back = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3543 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3544 if (stop_arrow() == FAIL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3545 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3546 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3547 line = ml_get(curwin->w_cursor.lnum); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3548 curs_col = curwin->w_cursor.col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3549 compl_pending = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3550 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3551 // If this same ctrl_x_mode has been interrupted use the text from |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3552 // "compl_startpos" to the cursor as a pattern to add a new word |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3553 // instead of expand the one before the cursor, in word-wise if |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3554 // "compl_startpos" is not in the same line as the cursor then fix it |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3555 // (the line has been split because it was longer than 'tw'). if SOL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3556 // is set then skip the previous pattern, a word at the beginning of |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3557 // the line has been inserted, we'll look for that -- Acevedo. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3558 if ((compl_cont_status & CONT_INTRPT) == CONT_INTRPT |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3559 && compl_cont_mode == ctrl_x_mode) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3560 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3561 // it is a continued search |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3562 compl_cont_status &= ~CONT_INTRPT; // remove INTRPT |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3563 if (ctrl_x_mode == CTRL_X_NORMAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3564 || ctrl_x_mode == CTRL_X_PATH_PATTERNS |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3565 || ctrl_x_mode == CTRL_X_PATH_DEFINES) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3566 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3567 if (compl_startpos.lnum != curwin->w_cursor.lnum) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3568 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3569 // line (probably) wrapped, set compl_startpos to the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3570 // first non_blank in the line, if it is not a wordchar |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3571 // include it to get a better pattern, but then we don't |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3572 // want the "\\<" prefix, check it bellow |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3573 compl_col = (colnr_T)getwhitecols(line); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3574 compl_startpos.col = compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3575 compl_startpos.lnum = curwin->w_cursor.lnum; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3576 compl_cont_status &= ~CONT_SOL; // clear SOL if present |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3577 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3578 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3579 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3580 // S_IPOS was set when we inserted a word that was at the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3581 // beginning of the line, which means that we'll go to SOL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3582 // mode but first we need to redefine compl_startpos |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3583 if (compl_cont_status & CONT_S_IPOS) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3584 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3585 compl_cont_status |= CONT_SOL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3586 compl_startpos.col = (colnr_T)(skipwhite( |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3587 line + compl_length |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3588 + compl_startpos.col) - line); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3589 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3590 compl_col = compl_startpos.col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3591 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3592 compl_length = curwin->w_cursor.col - (int)compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3593 // IObuff is used to add a "word from the next line" would we |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3594 // have enough space? just being paranoid |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3595 #define MIN_SPACE 75 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3596 if (compl_length > (IOSIZE - MIN_SPACE)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3597 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3598 compl_cont_status &= ~CONT_SOL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3599 compl_length = (IOSIZE - MIN_SPACE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3600 compl_col = curwin->w_cursor.col - compl_length; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3601 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3602 compl_cont_status |= CONT_ADDING | CONT_N_ADDS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3603 if (compl_length < 1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3604 compl_cont_status &= CONT_LOCAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3605 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3606 else if (ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3607 compl_cont_status = CONT_ADDING | CONT_N_ADDS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3608 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3609 compl_cont_status = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3610 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3611 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3612 compl_cont_status &= CONT_LOCAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3613 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3614 if (!(compl_cont_status & CONT_ADDING)) // normal expansion |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3615 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3616 compl_cont_mode = ctrl_x_mode; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3617 if (ctrl_x_mode != CTRL_X_NORMAL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3618 // Remove LOCAL if ctrl_x_mode != CTRL_X_NORMAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3619 compl_cont_status = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3620 compl_cont_status |= CONT_N_ADDS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3621 compl_startpos = curwin->w_cursor; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3622 startcol = (int)curs_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3623 compl_col = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3624 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3625 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3626 // Work out completion pattern and original text -- webb |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3627 if (ctrl_x_mode == CTRL_X_NORMAL || (ctrl_x_mode & CTRL_X_WANT_IDENT)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3628 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3629 if ((compl_cont_status & CONT_SOL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3630 || ctrl_x_mode == CTRL_X_PATH_DEFINES) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3631 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3632 if (!(compl_cont_status & CONT_ADDING)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3633 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3634 while (--startcol >= 0 && vim_isIDc(line[startcol])) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3635 ; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3636 compl_col += ++startcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3637 compl_length = curs_col - startcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3638 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3639 if (p_ic) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3640 compl_pattern = str_foldcase(line + compl_col, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3641 compl_length, NULL, 0); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3642 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3643 compl_pattern = vim_strnsave(line + compl_col, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3644 compl_length); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3645 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3646 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3647 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3648 else if (compl_cont_status & CONT_ADDING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3649 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3650 char_u *prefix = (char_u *)"\\<"; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3651 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3652 // we need up to 2 extra chars for the prefix |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3653 compl_pattern = alloc(quote_meta(NULL, line + compl_col, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3654 compl_length) + 2); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3655 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3656 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3657 if (!vim_iswordp(line + compl_col) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3658 || (compl_col > 0 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3659 && (vim_iswordp(mb_prevptr(line, line + compl_col))))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3660 prefix = (char_u *)""; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3661 STRCPY((char *)compl_pattern, prefix); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3662 (void)quote_meta(compl_pattern + STRLEN(prefix), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3663 line + compl_col, compl_length); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3664 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3665 else if (--startcol < 0 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3666 || !vim_iswordp(mb_prevptr(line, line + startcol + 1))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3667 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3668 // Match any word of at least two chars |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3669 compl_pattern = vim_strsave((char_u *)"\\<\\k\\k"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3670 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3671 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3672 compl_col += curs_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3673 compl_length = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3674 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3675 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3676 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3677 // Search the point of change class of multibyte character |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3678 // or not a word single byte character backward. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3679 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3680 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3681 int base_class; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3682 int head_off; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3683 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3684 startcol -= (*mb_head_off)(line, line + startcol); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3685 base_class = mb_get_class(line + startcol); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3686 while (--startcol >= 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3687 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3688 head_off = (*mb_head_off)(line, line + startcol); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3689 if (base_class != mb_get_class(line + startcol |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3690 - head_off)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3691 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3692 startcol -= head_off; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3693 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3694 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3695 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3696 while (--startcol >= 0 && vim_iswordc(line[startcol])) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3697 ; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3698 compl_col += ++startcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3699 compl_length = (int)curs_col - startcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3700 if (compl_length == 1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3701 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3702 // Only match word with at least two chars -- webb |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3703 // there's no need to call quote_meta, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3704 // alloc(7) is enough -- Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3705 compl_pattern = alloc(7); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3706 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3707 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3708 STRCPY((char *)compl_pattern, "\\<"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3709 (void)quote_meta(compl_pattern + 2, line + compl_col, 1); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3710 STRCAT((char *)compl_pattern, "\\k"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3711 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3712 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3713 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3714 compl_pattern = alloc(quote_meta(NULL, line + compl_col, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3715 compl_length) + 2); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3716 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3717 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3718 STRCPY((char *)compl_pattern, "\\<"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3719 (void)quote_meta(compl_pattern + 2, line + compl_col, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3720 compl_length); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3721 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3722 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3723 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3724 else if (ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3725 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3726 compl_col = (colnr_T)getwhitecols(line); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3727 compl_length = (int)curs_col - (int)compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3728 if (compl_length < 0) // cursor in indent: empty pattern |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3729 compl_length = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3730 if (p_ic) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3731 compl_pattern = str_foldcase(line + compl_col, compl_length, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3732 NULL, 0); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3733 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3734 compl_pattern = vim_strnsave(line + compl_col, compl_length); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3735 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3736 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3737 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3738 else if (ctrl_x_mode == CTRL_X_FILES) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3739 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3740 // Go back to just before the first filename character. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3741 if (startcol > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3742 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3743 char_u *p = line + startcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3744 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3745 MB_PTR_BACK(line, p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3746 while (p > line && vim_isfilec(PTR2CHAR(p))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3747 MB_PTR_BACK(line, p); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3748 if (p == line && vim_isfilec(PTR2CHAR(p))) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3749 startcol = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3750 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3751 startcol = (int)(p - line) + 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3752 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3753 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3754 compl_col += startcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3755 compl_length = (int)curs_col - startcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3756 compl_pattern = addstar(line + compl_col, compl_length, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3757 EXPAND_FILES); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3758 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3759 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3760 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3761 else if (ctrl_x_mode == CTRL_X_CMDLINE) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3762 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3763 compl_pattern = vim_strnsave(line, curs_col); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3764 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3765 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3766 set_cmd_context(&compl_xp, compl_pattern, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3767 (int)STRLEN(compl_pattern), curs_col, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3768 if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3769 || compl_xp.xp_context == EXPAND_NOTHING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3770 // No completion possible, use an empty pattern to get a |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3771 // "pattern not found" message. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3772 compl_col = curs_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3773 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3774 compl_col = (int)(compl_xp.xp_pattern - compl_pattern); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3775 compl_length = curs_col - compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3776 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3777 else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3778 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3779 #ifdef FEAT_COMPL_FUNC |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3780 // Call user defined function 'completefunc' with "a:findstart" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3781 // set to 1 to obtain the length of text to use for completion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3782 typval_T args[3]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3783 int col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3784 char_u *funcname; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3785 pos_T pos; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3786 win_T *curwin_save; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3787 buf_T *curbuf_save; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3788 int save_State = State; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3789 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3790 // Call 'completefunc' or 'omnifunc' and get pattern length as a |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3791 // string |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3792 funcname = ctrl_x_mode == CTRL_X_FUNCTION |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3793 ? curbuf->b_p_cfu : curbuf->b_p_ofu; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3794 if (*funcname == NUL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3795 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3796 semsg(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3797 ? "completefunc" : "omnifunc"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3798 // restore did_ai, so that adding comment leader works |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3799 did_ai = save_did_ai; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3800 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3801 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3802 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3803 args[0].v_type = VAR_NUMBER; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3804 args[0].vval.v_number = 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3805 args[1].v_type = VAR_STRING; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3806 args[1].vval.v_string = (char_u *)""; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3807 args[2].v_type = VAR_UNKNOWN; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3808 pos = curwin->w_cursor; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3809 curwin_save = curwin; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3810 curbuf_save = curbuf; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3811 col = call_func_retnr(funcname, 2, args); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3812 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3813 State = save_State; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3814 if (curwin_save != curwin || curbuf_save != curbuf) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3815 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3816 emsg(_(e_complwin)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3817 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3818 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3819 curwin->w_cursor = pos; // restore the cursor position |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3820 validate_cursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3821 if (!EQUAL_POS(curwin->w_cursor, pos)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3822 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3823 emsg(_(e_compldel)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3824 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3825 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3826 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3827 // Return value -2 means the user complete function wants to |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3828 // cancel the complete without an error. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3829 // Return value -3 does the same as -2 and leaves CTRL-X mode. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3830 if (col == -2) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3831 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3832 if (col == -3) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3833 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3834 ctrl_x_mode = CTRL_X_NORMAL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3835 edit_submode = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3836 if (!shortmess(SHM_COMPLETIONMENU)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3837 msg_clr_cmdline(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3838 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3839 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3840 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3841 // Reset extended parameters of completion, when start new |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3842 // completion. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3843 compl_opt_refresh_always = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3844 compl_opt_suppress_empty = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3845 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3846 if (col < 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3847 col = curs_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3848 compl_col = col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3849 if (compl_col > curs_col) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3850 compl_col = curs_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3851 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3852 // Setup variables for completion. Need to obtain "line" again, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3853 // it may have become invalid. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3854 line = ml_get(curwin->w_cursor.lnum); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3855 compl_length = curs_col - compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3856 compl_pattern = vim_strnsave(line + compl_col, compl_length); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3857 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3858 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3859 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3860 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3861 else if (ctrl_x_mode == CTRL_X_SPELL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3862 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3863 #ifdef FEAT_SPELL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3864 if (spell_bad_len > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3865 compl_col = curs_col - spell_bad_len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3866 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3867 compl_col = spell_word_start(startcol); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3868 if (compl_col >= (colnr_T)startcol) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3869 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3870 compl_length = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3871 compl_col = curs_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3872 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3873 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3874 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3875 spell_expand_check_cap(compl_col); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3876 compl_length = (int)curs_col - compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3877 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3878 // Need to obtain "line" again, it may have become invalid. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3879 line = ml_get(curwin->w_cursor.lnum); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3880 compl_pattern = vim_strnsave(line + compl_col, compl_length); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3881 if (compl_pattern == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3882 #endif |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3883 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3884 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3885 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3886 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3887 internal_error("ins_complete()"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3888 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3889 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3890 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3891 if (compl_cont_status & CONT_ADDING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3892 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3893 edit_submode_pre = (char_u *)_(" Adding"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3894 if (ctrl_x_mode_line_or_eval()) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3895 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3896 // Insert a new line, keep indentation but ignore 'comments' |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3897 char_u *old = curbuf->b_p_com; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3898 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3899 curbuf->b_p_com = (char_u *)""; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3900 compl_startpos.lnum = curwin->w_cursor.lnum; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3901 compl_startpos.col = compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3902 ins_eol('\r'); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3903 curbuf->b_p_com = old; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3904 compl_length = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3905 compl_col = curwin->w_cursor.col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3906 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3907 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3908 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3909 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3910 edit_submode_pre = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3911 compl_startpos.col = compl_col; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3912 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3913 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3914 if (compl_cont_status & CONT_LOCAL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3915 edit_submode = (char_u *)_(ctrl_x_msgs[CTRL_X_LOCAL_MSG]); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3916 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3917 edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode)); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3918 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3919 // If any of the original typed text has been changed we need to fix |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3920 // the redo buffer. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3921 ins_compl_fixRedoBufForLeader(NULL); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3922 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3923 // Always add completion for the original text. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3924 vim_free(compl_orig_text); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3925 compl_orig_text = vim_strnsave(line + compl_col, compl_length); |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3926 if (p_ic) |
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3927 flags |= CP_ICASE; |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3928 if (compl_orig_text == NULL || ins_compl_add(compl_orig_text, |
19047
a3fce2763e83
patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents:
18933
diff
changeset
|
3929 -1, NULL, NULL, NULL, 0, flags, FALSE) != OK) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3930 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3931 VIM_CLEAR(compl_pattern); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3932 VIM_CLEAR(compl_orig_text); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3933 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3934 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3935 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3936 // showmode might reset the internal line pointers, so it must |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3937 // be called before line = ml_get(), or when this address is no |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3938 // longer needed. -- Acevedo. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3939 edit_submode_extra = (char_u *)_("-- Searching..."); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3940 edit_submode_highl = HLF_COUNT; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3941 showmode(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3942 edit_submode_extra = NULL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3943 out_flush(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3944 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3945 else if (insert_match && stop_arrow() == FAIL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3946 return FAIL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3947 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3948 compl_shown_match = compl_curr_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3949 compl_shows_dir = compl_direction; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3950 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3951 // Find next match (and following matches). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3952 save_w_wrow = curwin->w_wrow; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3953 save_w_leftcol = curwin->w_leftcol; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3954 n = ins_compl_next(TRUE, ins_compl_key2count(c), insert_match, FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3955 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3956 // may undisplay the popup menu |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3957 ins_compl_upd_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3958 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3959 if (n > 1) // all matches have been found |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3960 compl_matches = n; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3961 compl_curr_match = compl_shown_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3962 compl_direction = compl_shows_dir; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3963 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3964 // Eat the ESC that vgetc() returns after a CTRL-C to avoid leaving Insert |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3965 // mode. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3966 if (got_int && !global_busy) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3967 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3968 (void)vgetc(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3969 got_int = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3970 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3971 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3972 // we found no match if the list has only the "compl_orig_text"-entry |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3973 if (compl_first_match == compl_first_match->cp_next) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3974 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3975 edit_submode_extra = (compl_cont_status & CONT_ADDING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3976 && compl_length > 1 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3977 ? (char_u *)_(e_hitend) : (char_u *)_(e_patnotf); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3978 edit_submode_highl = HLF_E; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3979 // remove N_ADDS flag, so next ^X<> won't try to go to ADDING mode, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3980 // because we couldn't expand anything at first place, but if we used |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3981 // ^P, ^N, ^X^I or ^X^D we might want to add-expand a single-char-word |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3982 // (such as M in M'exico) if not tried already. -- Acevedo |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3983 if ( compl_length > 1 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3984 || (compl_cont_status & CONT_ADDING) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3985 || (ctrl_x_mode != CTRL_X_NORMAL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3986 && ctrl_x_mode != CTRL_X_PATH_PATTERNS |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3987 && ctrl_x_mode != CTRL_X_PATH_DEFINES)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3988 compl_cont_status &= ~CONT_N_ADDS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3989 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3990 |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3991 if (compl_curr_match->cp_flags & CP_CONT_S_IPOS) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3992 compl_cont_status |= CONT_S_IPOS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3993 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3994 compl_cont_status &= ~CONT_S_IPOS; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3995 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3996 if (edit_submode_extra == NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3997 { |
16239
5df26b29e809
patch 8.1.1124: insert completion flags are mixed up
Bram Moolenaar <Bram@vim.org>
parents:
16237
diff
changeset
|
3998 if (compl_curr_match->cp_flags & CP_ORIGINAL_TEXT) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3999 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4000 edit_submode_extra = (char_u *)_("Back at original"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4001 edit_submode_highl = HLF_W; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4002 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4003 else if (compl_cont_status & CONT_S_IPOS) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4004 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4005 edit_submode_extra = (char_u *)_("Word from other line"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4006 edit_submode_highl = HLF_COUNT; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4007 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4008 else if (compl_curr_match->cp_next == compl_curr_match->cp_prev) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4009 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4010 edit_submode_extra = (char_u *)_("The only match"); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4011 edit_submode_highl = HLF_COUNT; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4012 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4013 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4014 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4015 // Update completion sequence number when needed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4016 if (compl_curr_match->cp_number == -1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4017 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4018 int number = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4019 compl_T *match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4020 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4021 if (compl_direction == FORWARD) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4022 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4023 // search backwards for the first valid (!= -1) number. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4024 // This should normally succeed already at the first loop |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4025 // cycle, so it's fast! |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4026 for (match = compl_curr_match->cp_prev; match != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4027 && match != compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4028 match = match->cp_prev) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4029 if (match->cp_number != -1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4030 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4031 number = match->cp_number; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4032 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4033 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4034 if (match != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4035 // go up and assign all numbers which are not assigned |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4036 // yet |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4037 for (match = match->cp_next; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4038 match != NULL && match->cp_number == -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4039 match = match->cp_next) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4040 match->cp_number = ++number; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4041 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4042 else // BACKWARD |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4043 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4044 // search forwards (upwards) for the first valid (!= -1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4045 // number. This should normally succeed already at the |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4046 // first loop cycle, so it's fast! |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4047 for (match = compl_curr_match->cp_next; match != NULL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4048 && match != compl_first_match; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4049 match = match->cp_next) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4050 if (match->cp_number != -1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4051 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4052 number = match->cp_number; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4053 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4054 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4055 if (match != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4056 // go down and assign all numbers which are not |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4057 // assigned yet |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4058 for (match = match->cp_prev; match |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4059 && match->cp_number == -1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4060 match = match->cp_prev) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4061 match->cp_number = ++number; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4062 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4063 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4064 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4065 // The match should always have a sequence number now, this is |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4066 // just a safety check. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4067 if (compl_curr_match->cp_number != -1) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4068 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4069 // Space for 10 text chars. + 2x10-digit no.s = 31. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4070 // Translations may need more than twice that. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4071 static char_u match_ref[81]; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4072 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4073 if (compl_matches > 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4074 vim_snprintf((char *)match_ref, sizeof(match_ref), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4075 _("match %d of %d"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4076 compl_curr_match->cp_number, compl_matches); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4077 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4078 vim_snprintf((char *)match_ref, sizeof(match_ref), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4079 _("match %d"), |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4080 compl_curr_match->cp_number); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4081 edit_submode_extra = match_ref; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4082 edit_submode_highl = HLF_R; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4083 if (dollar_vcol >= 0) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4084 curs_columns(FALSE); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4085 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4086 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4087 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4088 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4089 // Show a message about what (completion) mode we're in. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4090 if (!compl_opt_suppress_empty) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4091 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4092 showmode(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4093 if (!shortmess(SHM_COMPLETIONMENU)) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4094 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4095 if (edit_submode_extra != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4096 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4097 if (!p_smd) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4098 msg_attr((char *)edit_submode_extra, |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4099 edit_submode_highl < HLF_COUNT |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4100 ? HL_ATTR(edit_submode_highl) : 0); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4101 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4102 else |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4103 msg_clr_cmdline(); // necessary for "noshowmode" |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4104 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4105 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4106 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4107 // Show the popup menu, unless we got interrupted. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4108 if (enable_pum && !compl_interrupted) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4109 show_pum(save_w_wrow, save_w_leftcol); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4110 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4111 compl_was_interrupted = compl_interrupted; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4112 compl_interrupted = FALSE; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4113 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4114 return OK; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4115 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4116 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4117 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4118 show_pum(int prev_w_wrow, int prev_w_leftcol) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4119 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4120 // RedrawingDisabled may be set when invoked through complete(). |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4121 int n = RedrawingDisabled; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4122 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4123 RedrawingDisabled = 0; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4124 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4125 // If the cursor moved or the display scrolled we need to remove the pum |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4126 // first. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4127 setcursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4128 if (prev_w_wrow != curwin->w_wrow || prev_w_leftcol != curwin->w_leftcol) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4129 ins_compl_del_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4130 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4131 ins_compl_show_pum(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4132 setcursor(); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4133 RedrawingDisabled = n; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4134 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4135 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4136 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4137 * Looks in the first "len" chars. of "src" for search-metachars. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4138 * If dest is not NULL the chars. are copied there quoting (with |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4139 * a backslash) the metachars, and dest would be NUL terminated. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4140 * Returns the length (needed) of dest |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4141 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4142 static unsigned |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4143 quote_meta(char_u *dest, char_u *src, int len) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4144 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4145 unsigned m = (unsigned)len + 1; // one extra for the NUL |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4146 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4147 for ( ; --len >= 0; src++) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4148 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4149 switch (*src) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4150 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4151 case '.': |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4152 case '*': |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4153 case '[': |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4154 if (ctrl_x_mode == CTRL_X_DICTIONARY |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4155 || ctrl_x_mode == CTRL_X_THESAURUS) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4156 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4157 // FALLTHROUGH |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4158 case '~': |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4159 if (!p_magic) // quote these only if magic is set |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4160 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4161 // FALLTHROUGH |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4162 case '\\': |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4163 if (ctrl_x_mode == CTRL_X_DICTIONARY |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4164 || ctrl_x_mode == CTRL_X_THESAURUS) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4165 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4166 // FALLTHROUGH |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4167 case '^': // currently it's not needed. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4168 case '$': |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4169 m++; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4170 if (dest != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4171 *dest++ = '\\'; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4172 break; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4173 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4174 if (dest != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4175 *dest++ = *src; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4176 // Copy remaining bytes of a multibyte character. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4177 if (has_mbyte) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4178 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4179 int i, mb_len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4180 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4181 mb_len = (*mb_ptr2len)(src) - 1; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4182 if (mb_len > 0 && len >= mb_len) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4183 for (i = 0; i < mb_len; ++i) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4184 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4185 --len; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4186 ++src; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4187 if (dest != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4188 *dest++ = *src; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4189 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4190 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4191 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4192 if (dest != NULL) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4193 *dest = NUL; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4194 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4195 return m; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4196 } |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4197 |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
4198 #if defined(EXITFREE) || defined(PROTO) |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4199 void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4200 free_insexpand_stuff(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4201 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4202 VIM_CLEAR(compl_orig_text); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4203 } |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
4204 #endif |
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
4205 |
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
4206 #ifdef FEAT_SPELL |
16142
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4207 /* |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4208 * Called when starting CTRL_X_SPELL mode: Move backwards to a previous badly |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4209 * spelled word, if there is one. |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4210 */ |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4211 static void |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4212 spell_back_to_badword(void) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4213 { |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4214 pos_T tpos = curwin->w_cursor; |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4215 |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4216 spell_bad_len = spell_move_to(curwin, BACKWARD, TRUE, TRUE, NULL); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4217 if (curwin->w_cursor.col != tpos.col) |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4218 start_arrow(&tpos); |
570a296aa0b4
patch 8.1.1076: file for Insert mode is much too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4219 } |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
4220 #endif |