annotate src/ui.c @ 35039:fbdb6aeca2e2

runtime(java): Improve the recognition of the "style" method declarations Commit: https://github.com/vim/vim/commit/a4c085a3e607bd01d34e1db600b6460fc35fb0a3 Author: Aliaksei Budavei <0x000c70@gmail.com> Date: Wed Apr 24 21:04:25 2024 +0200 runtime(java): Improve the recognition of the "style" method declarations - Request the new regexp engine (v7.3.970) for [:upper:] and [:lower:]. - Recognise declarations of in-line annotated methods. - Recognise declarations of _strictfp_ methods. - Establish partial order for method modifiers as shown in the MethodModifier production; namely, _public_ and friends should be written the leftmost, possibly followed by _abstract_ or _default_, or possibly followed by other modifiers. - Stop looking for parameterisable primitive types (void<?>, int<Object>, etc., are malformed). - Stop looking for arrays of _void_. - Acknowledge the prevailing convention for method names to begin with a small letter and for class/interface names to begin with a capital letter; and, therefore, desist from claiming declarations of enum constants and constructors with javaFuncDef. Rationale: + Constructor is distinct from method: * its (overloaded) name is not arbitrary; * its return type is implicit; * its _throws_ clause depends on indirect vagaries of instance (variable) initialisers; * its invocation makes other constructors of its type hierarchy invoked one by one, concluding with the primordial constructor; * its explicit invocation, via _this_ or _super_, can only appear as the first statement in a constructor (not anymore, see JEP 447); else, its _super_ call cannot appear in constructors of _record_ or _enum_; and neither invocation is allowed for the primordial constructor; * it is not a member of its class, like initialisers, and is never inherited; * it is never _abstract_ or _native_. + Constructor declarations tend to be few in number and merit visual recognition from method declarations. + Enum constants define a fixed set of type instances and more resemble class variable initialisers. Note that the code duplicated for @javaFuncParams is written keeping in mind for g:java_highlight_functions a pending 3rd variant, which would require none of the :syn-cluster added groups. closes: #14620 Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 24 Apr 2024 21:15:02 +0200
parents 664ee4c0daca
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * ui.c: functions that handle the user interface.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * 1. Keyboard input stuff, and a bit of windowing stuff. These are called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * before the machine specific stuff (mch_*) so that we can call the GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * stuff instead if the GUI is running.
19774
00a1b89256ea patch 8.2.0443: clipboard code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 19750
diff changeset
15 * 2. Input buffer stuff.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 void
24194
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
21 ui_write(char_u *s, int len, int console UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 #ifdef FEAT_GUI
24194
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
24 if (gui.in_use && !gui.dying && !gui.starting
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
25 # ifndef NO_CONSOLE
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
26 && !console
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
27 # endif
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
28 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 gui_write(s, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 if (p_wd)
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
32 gui_wait_for_chars(p_wd, typebuf.tb_change_cnt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 #ifndef NO_CONSOLE
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
37 // Don't output anything in silent mode ("ex -s") unless 'verbose' set
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 if (!(silent_mode && p_verbose == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 {
24194
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
40 # if !defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 char_u *tofree = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
45 // Convert characters from 'encoding' to 'termencoding'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 tofree = string_convert(&output_conv, s, &len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 if (tofree != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 s = tofree;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 }
24194
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
50 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 mch_write(s, len);
24196
1040b294bfd3 patch 8.2.2639: build failure when fsync() is not available
Bram Moolenaar <Bram@vim.org>
parents: 24194
diff changeset
53 # if defined(HAVE_FSYNC)
24194
9f64c420f280 patch 8.2.2638: cannot write a message to the terminal from the GUI
Bram Moolenaar <Bram@vim.org>
parents: 23612
diff changeset
54 if (console && s[len - 1] == '\n')
24196
1040b294bfd3 patch 8.2.2639: build failure when fsync() is not available
Bram Moolenaar <Bram@vim.org>
parents: 24194
diff changeset
55 vim_fsync(1);
1040b294bfd3 patch 8.2.2639: build failure when fsync() is not available
Bram Moolenaar <Bram@vim.org>
parents: 24194
diff changeset
56 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15665
diff changeset
58 # if !defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 vim_free(tofree);
15605
62b3805506b3 patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15555
diff changeset
61 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15665
diff changeset
66 #if defined(UNIX) || defined(VMS) || defined(PROTO) || defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 * When executing an external program, there may be some typed characters that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 * are not consumed by it. Give them back to ui_inchar() and they are stored
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 * here for the next call.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 static char_u *ta_str = NULL;
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
73 static int ta_off; // offset for next char to use when ta_str != NULL
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
74 static int ta_len; // length of ta_str when it's not NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
77 ui_inchar_undo(char_u *s, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 char_u *new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 int newlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 newlen = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 if (ta_str != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 newlen += ta_len - ta_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 new = alloc(newlen);
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
86 if (new == NULL)
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
87 return;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
88
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
89 if (ta_str != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 {
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
91 mch_memmove(new, ta_str + ta_off, (size_t)(ta_len - ta_off));
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
92 mch_memmove(new + ta_len - ta_off, s, (size_t)len);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
93 vim_free(ta_str);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 }
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
95 else
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
96 mch_memmove(new, s, (size_t)len);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
97 ta_str = new;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
98 ta_len = newlen;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
99 ta_off = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 /*
3877
cd6c420e31d6 updated for version 7.3.695
Bram Moolenaar <bram@vim.org>
parents: 3770
diff changeset
104 * ui_inchar(): low level input function.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 * Get characters from the keyboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 * Return the number of characters that are available.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 * If "wtime" == 0 do not wait for characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 * If "wtime" == -1 wait forever for characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 * If "wtime" > 0 wait "wtime" milliseconds for a character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 * "tb_change_cnt" is the value of typebuf.tb_change_cnt if "buf" points into
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 * it. When typebuf.tb_change_cnt changes (e.g., when a message is received
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 * from a remote client) "buf" can no longer be used. "tb_change_cnt" is NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 * otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
117 ui_inchar(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
118 char_u *buf,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
119 int maxlen,
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
120 long wtime, // don't use "time", MIPS cannot handle it
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
121 int tb_change_cnt)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 int retval = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 #if defined(FEAT_GUI) && (defined(UNIX) || defined(VMS))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 * Use the typeahead if there is any.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 if (ta_str != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 if (maxlen >= ta_len - ta_off)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 mch_memmove(buf, ta_str + ta_off, (size_t)ta_len);
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
134 VIM_CLEAR(ta_str);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 return ta_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 mch_memmove(buf, ta_str + ta_off, (size_t)maxlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 ta_off += maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 return maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
143 #ifdef FEAT_PROFILE
791
98a88a884610 updated for version 7.0230
vimboss
parents: 761
diff changeset
144 if (do_profiling == PROF_YES && wtime != 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
145 prof_inchar_enter();
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
146 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
147
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 #ifdef NO_CONSOLE_INPUT
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
149 // Don't wait for character input when the window hasn't been opened yet.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
150 // Do try reading, this works when redirecting stdin from a file.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
151 // Must return something, otherwise we'll loop forever. If we run into
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
152 // this very often we probably got stuck, exit Vim.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 if (no_console_input())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 static int count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 # ifndef NO_CONSOLE
15075
fd9c4b1a71aa patch 8.1.0548: crash when job callback unloads a buffer
Bram Moolenaar <Bram@vim.org>
parents: 15052
diff changeset
158 retval = mch_inchar(buf, maxlen, wtime, tb_change_cnt);
228
d97518d6b325 updated for version 7.0063
vimboss
parents: 170
diff changeset
159 if (retval > 0 || typebuf_changed(tb_change_cnt) || wtime >= 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
160 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 if (wtime == -1 && ++count == 1000)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 read_error_exit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 buf[0] = CAR;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
165 retval = 1;
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
166 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
170 // If we are going to wait for some time or block...
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
171 if (wtime == -1 || wtime > 100L)
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
172 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
173 // ... allow signals to kill us.
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
174 (void)vim_handle_signal(SIGNAL_UNBLOCK);
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
175
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
176 // ... there is no need for CTRL-C to interrupt something, don't let
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
177 // it set got_int when it was mapped.
6491
8cfbc34ae4aa updated for version 7.4.573
Bram Moolenaar <bram@vim.org>
parents: 6482
diff changeset
178 if ((mapped_ctrl_c | curbuf->b_mapped_ctrl_c) & get_real_state())
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
179 ctrl_c_interrupts = FALSE;
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
180 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
182 /*
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
183 * Here we call gui_inchar() or mch_inchar(), the GUI or machine-dependent
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
184 * input function. The functionality they implement is like this:
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
185 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
186 * while (not timed out)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
187 * {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
188 * handle-resize;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
189 * parse-queued-messages;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
190 * if (waited for 'updatetime')
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
191 * trigger-cursorhold;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
192 * ui_wait_for_chars_or_timer()
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
193 * if (character available)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
194 * break;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
195 * }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
196 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
197 * ui_wait_for_chars_or_timer() does:
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
198 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
199 * while (not timed out)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
200 * {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
201 * if (any-timer-triggered)
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
202 * invoke-timer-callback;
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
203 * wait-for-character();
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
204 * if (character available)
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
205 * break;
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
206 * }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
207 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
208 * wait-for-character() does:
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
209 * while (not timed out)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
210 * {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
211 * Wait for event;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
212 * if (something on channel)
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
213 * read/write channel;
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
214 * else if (resized)
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
215 * handle_resize();
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
216 * else if (system event)
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
217 * deal-with-system-event;
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
218 * else if (character available)
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 27857
diff changeset
219 * break;
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
220 * }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
221 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
222 */
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
223
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 if (gui.in_use)
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
226 retval = gui_inchar(buf, maxlen, wtime, tb_change_cnt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 #ifndef NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 retval = mch_inchar(buf, maxlen, wtime, tb_change_cnt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
235 if (wtime == -1 || wtime > 100L)
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
236 // block SIGHUP et al.
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
237 (void)vim_handle_signal(SIGNAL_BLOCK);
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
238
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 ctrl_c_interrupts = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
241 #ifdef NO_CONSOLE_INPUT
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
242 theend:
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
243 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
244 #ifdef FEAT_PROFILE
791
98a88a884610 updated for version 7.0230
vimboss
parents: 761
diff changeset
245 if (do_profiling == PROF_YES && wtime != 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
246 prof_inchar_exit();
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
247 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250
18896
4481f3b29fc5 patch 8.2.0009: VMS: terminal version doesn't build
Bram Moolenaar <Bram@vim.org>
parents: 18880
diff changeset
251 #if defined(UNIX) || defined(VMS) || defined(FEAT_GUI) || defined(PROTO)
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
252 /*
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
253 * Common code for mch_inchar() and gui_inchar(): Wait for a while or
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
254 * indefinitely until characters are available, dealing with timers and
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
255 * messages on channels.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
256 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
257 * "buf" may be NULL if the available characters are not to be returned, only
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
258 * check if they are available.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
259 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
260 * Return the number of characters that are available.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
261 * If "wtime" == 0 do not wait for characters.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
262 * If "wtime" == n wait a short time for characters.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
263 * If "wtime" == -1 wait forever for characters.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
264 */
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
265 int
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
266 inchar_loop(
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
267 char_u *buf,
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
268 int maxlen,
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
269 long wtime, // don't use "time", MIPS cannot handle it
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
270 int tb_change_cnt,
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
271 int (*wait_func)(long wtime, int *interrupted, int ignore_input),
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
272 int (*resize_func)(int check_only))
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
273 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
274 int len;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
275 int interrupted = FALSE;
15665
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15655
diff changeset
276 int did_call_wait_func = FALSE;
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
277 int did_start_blocking = FALSE;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
278 long wait_time;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
279 long elapsed_time = 0;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
280 #ifdef ELAPSED_FUNC
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
281 elapsed_T start_tv;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
282
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
283 ELAPSED_INIT(start_tv);
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
284 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
285
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
286 // repeat until we got a character or waited long enough
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
287 for (;;)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
288 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
289 // Check if window changed size while we were busy, perhaps the ":set
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
290 // columns=99" command was used.
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
291 if (resize_func != NULL)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
292 resize_func(FALSE);
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
293
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
294 #ifdef MESSAGE_QUEUE
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
295 // Only process messages when waiting.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
296 if (wtime != 0)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
297 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
298 parse_queued_messages();
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
299 // If input was put directly in typeahead buffer bail out here.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
300 if (typebuf_changed(tb_change_cnt))
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
301 return 0;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
302 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
303 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
304 if (wtime < 0 && did_start_blocking)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
305 // blocking and already waited for p_ut
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
306 wait_time = -1;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
307 else
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
308 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
309 if (wtime >= 0)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
310 wait_time = wtime;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
311 else
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
312 // going to block after p_ut
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
313 wait_time = p_ut;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
314 #ifdef ELAPSED_FUNC
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
315 elapsed_time = ELAPSED_FUNC(start_tv);
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
316 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
317 wait_time -= elapsed_time;
15665
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15655
diff changeset
318
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15655
diff changeset
319 // If the waiting time is now zero or less, we timed out. However,
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15655
diff changeset
320 // loop at least once to check for characters and events. Matters
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15655
diff changeset
321 // when "wtime" is zero.
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15655
diff changeset
322 if (wait_time <= 0 && did_call_wait_func)
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
323 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
324 if (wtime >= 0)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
325 // no character available within "wtime"
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
326 return 0;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
327
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
328 // No character available within 'updatetime'.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
329 did_start_blocking = TRUE;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
330 if (trigger_cursorhold() && maxlen >= 3
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
331 && !typebuf_changed(tb_change_cnt))
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
332 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
333 // Put K_CURSORHOLD in the input buffer or return it.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
334 if (buf == NULL)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
335 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
336 char_u ibuf[3];
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
337
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
338 ibuf[0] = CSI;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
339 ibuf[1] = KS_EXTRA;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
340 ibuf[2] = (int)KE_CURSORHOLD;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
341 add_to_input_buf(ibuf, 3);
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
342 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
343 else
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
344 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
345 buf[0] = K_SPECIAL;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
346 buf[1] = KS_EXTRA;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
347 buf[2] = (int)KE_CURSORHOLD;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
348 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
349 return 3;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
350 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
351
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
352 // There is no character available within 'updatetime' seconds:
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
353 // flush all the swap files to disk. Also done when
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
354 // interrupted by SIGWINCH.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
355 before_blocking();
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
356 continue;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
357 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
358 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
359
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
360 #ifdef FEAT_JOB_CHANNEL
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
361 if (wait_time < 0 || wait_time > 100L)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
362 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
363 // Checking if a job ended requires polling. Do this at least
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
364 // every 100 msec.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
365 if (has_pending_job())
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
366 wait_time = 100L;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
367
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
368 // If there is readahead then parse_queued_messages() timed out and
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
369 // we should call it again soon.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
370 if (channel_any_readahead())
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
371 wait_time = 10L;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
372 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
373 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
374 #ifdef FEAT_BEVAL_GUI
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
375 if (p_beval && wait_time > 100L)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
376 // The 'balloonexpr' may indirectly invoke a callback while waiting
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
377 // for a character, need to check often.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
378 wait_time = 100L;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
379 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
380
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
381 // Wait for a character to be typed or another event, such as the winch
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
382 // signal or an event on the monitored file descriptors.
15665
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15655
diff changeset
383 did_call_wait_func = TRUE;
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
384 if (wait_func(wait_time, &interrupted, FALSE))
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
385 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
386 // If input was put directly in typeahead buffer bail out here.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
387 if (typebuf_changed(tb_change_cnt))
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
388 return 0;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
389
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
390 // We might have something to return now.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
391 if (buf == NULL)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
392 // "buf" is NULL, we were just waiting, not actually getting
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
393 // input.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
394 return input_available();
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
395
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
396 len = read_from_input_buf(buf, (long)maxlen);
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
397 if (len > 0)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
398 return len;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
399 continue;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
400 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
401 // Timed out or interrupted with no character available.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
402
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
403 #ifndef ELAPSED_FUNC
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
404 // estimate the elapsed time
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
405 elapsed_time += wait_time;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
406 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
407
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
408 if ((resize_func != NULL && resize_func(TRUE))
15655
2202ab00e9f9 patch 8.1.0835: GUI build fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 15653
diff changeset
409 #if defined(FEAT_CLIENTSERVER) && defined(UNIX)
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
410 || server_waiting()
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
411 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
412 #ifdef MESSAGE_QUEUE
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
413 || interrupted
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
414 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
415 || wait_time > 0
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
416 || (wtime < 0 && !did_start_blocking))
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
417 // no character available, but something to be done, keep going
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
418 continue;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
419
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
420 // no character available or interrupted, return zero
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
421 break;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
422 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
423 return 0;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
424 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
425 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
426
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
427 #if defined(FEAT_TIMERS) || defined(PROTO)
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
428 /*
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
429 * Wait for a timer to fire or "wait_func" to return non-zero.
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
430 * Returns OK when something was read.
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
431 * Returns FAIL when it timed out or was interrupted.
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
432 */
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
433 int
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
434 ui_wait_for_chars_or_timer(
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
435 long wtime,
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
436 int (*wait_func)(long wtime, int *interrupted, int ignore_input),
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
437 int *interrupted,
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
438 int ignore_input)
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
439 {
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
440 int due_time;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
441 long remaining = wtime;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
442 int tb_change_cnt = typebuf.tb_change_cnt;
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
443 # ifdef FEAT_JOB_CHANNEL
15506
8b508af36a80 patch 8.1.0761: default value for brief_wait is wrong
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
444 int brief_wait = FALSE;
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
445 # endif
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
446
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
447 // When waiting very briefly don't trigger timers.
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
448 if (wtime >= 0 && wtime < 10L)
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
449 return wait_func(wtime, NULL, ignore_input);
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
450
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
451 while (wtime < 0 || remaining > 0)
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
452 {
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
453 // Trigger timers and then get the time in wtime until the next one is
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
454 // due. Wait up to that time.
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
455 due_time = check_due_timer();
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
456 if (typebuf.tb_change_cnt != tb_change_cnt)
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
457 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
458 // timer may have used feedkeys()
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
459 return FAIL;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
460 }
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
461 if (due_time <= 0 || (wtime > 0 && due_time > remaining))
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
462 due_time = remaining;
30719
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29109
diff changeset
463 # if defined(FEAT_JOB_CHANNEL) || defined(FEAT_SOUND_CANBERRA) || defined(FEAT_SOUND_MACOSX)
17708
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
464 if ((due_time < 0 || due_time > 10L) && (
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
465 # if defined(FEAT_JOB_CHANNEL)
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
466 (
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
467 # if defined(FEAT_GUI)
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
468 !gui.in_use &&
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
469 # endif
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
470 (has_pending_job() || channel_any_readahead()))
30719
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29109
diff changeset
471 # if defined(FEAT_SOUND_CANBERRA) || defined(FEAT_SOUND_MACOSX)
17708
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
472 ||
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
473 # endif
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
474 # endif
30719
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29109
diff changeset
475 # if defined(FEAT_SOUND_CANBERRA) || defined(FEAT_SOUND_MACOSX)
17708
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
476 has_any_sound_callback()
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
477 # endif
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
478 ))
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
479 {
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
480 // There is a pending job or channel, should return soon in order
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
481 // to handle them ASAP. Do check for input briefly.
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
482 due_time = 10L;
18021
e273e489acdf patch 8.1.2006: build failure with huge features but without channel feature
Bram Moolenaar <Bram@vim.org>
parents: 17950
diff changeset
483 # ifdef FEAT_JOB_CHANNEL
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
484 brief_wait = TRUE;
18021
e273e489acdf patch 8.1.2006: build failure with huge features but without channel feature
Bram Moolenaar <Bram@vim.org>
parents: 17950
diff changeset
485 # endif
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
486 }
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
487 # endif
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
488 if (wait_func(due_time, interrupted, ignore_input))
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
489 return OK;
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
490 if ((interrupted != NULL && *interrupted)
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
491 # ifdef FEAT_JOB_CHANNEL
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
492 || brief_wait
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
493 # endif
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
494 )
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
495 // Nothing available, but need to return so that side effects get
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
496 // handled, such as handling a message on a channel.
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13060
diff changeset
497 return FAIL;
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
498 if (wtime > 0)
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
499 remaining -= due_time;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
500 }
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
501 return FAIL;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
502 }
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
503 #endif
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
504
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 /*
15404
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
506 * Return non-zero if a character is available.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
509 ui_char_avail(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 return input_available();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 #ifndef NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 # ifdef NO_CONSOLE_INPUT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 if (no_console_input())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 return mch_char_avail();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 * Delay for the given number of milliseconds. If ignoreinput is FALSE then we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 * cancel the delay if a key is hit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 void
20861
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
534 ui_delay(long msec_arg, int ignoreinput)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 {
20861
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
536 long msec = msec_arg;
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
537
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
538 #ifdef FEAT_EVAL
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
539 if (ui_delay_for_testing > 0)
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
540 msec = ui_delay_for_testing;
18642
bbea1f108187 patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
541 ch_log(NULL, "ui_delay(%ld)", msec);
bbea1f108187 patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
542 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 if (gui.in_use && !ignoreinput)
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
545 gui_wait_for_chars(msec, typebuf.tb_change_cnt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 #endif
21927
88070e222e82 patch 8.2.1513: cannot interrupt shell used for filename expansion
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
548 mch_delay(msec, ignoreinput ? MCH_DELAY_IGNOREINPUT : 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 * If the machine has job control, use it to suspend the program,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 * otherwise fake it by starting a new shell.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 * When running the GUI iconify the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
557 ui_suspend(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 gui_mch_iconify();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 mch_suspend();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568
20591
4411c2b96af9 patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents: 19774
diff changeset
569 #if !defined(UNIX) || !defined(SIGTSTP) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 * When the OS can't really suspend, call this function to start a shell.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 * This is never called in the GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
575 suspend_shell(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 if (*p_sh == NUL)
26602
fac6673086df patch 8.2.3830: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26466
diff changeset
578 emsg(_(e_shell_option_is_empty));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
581 msg_puts(_("new shell started\n"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 do_shell(NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 * Try to get the current Vim shell size. Put the result in Rows and Columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 * Use the new sizes as defaults for 'columns' and 'lines'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 * Return OK when size could be determined, FAIL otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
593 ui_get_shellsize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 retval = gui_get_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 retval = mch_get_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 check_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
606 // adjust the default for 'lines' and 'columns'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 if (retval == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 set_number_default("lines", Rows);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 set_number_default("columns", Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 * Set the size of the Vim shell according to Rows and Columns, if possible.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 * The gui_set_shellsize() or mch_set_shellsize() function will try to set the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 * new size. If this is not possible, it will adjust Rows and Columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
621 ui_set_shellsize(
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
622 int mustset UNUSED) // set by the user
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 if (gui.in_use)
5106
c3a82208e143 updated for version 7.3.1296
Bram Moolenaar <bram@vim.org>
parents: 5037
diff changeset
626 gui_set_shellsize(mustset, TRUE, RESIZE_BOTH);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 mch_set_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 * Called when Rows and/or Columns changed. Adjust scroll region and mouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 * region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
637 ui_new_shellsize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 if (full_screen && !exiting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 gui_new_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 mch_new_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649
16245
e0a6298bd70f patch 8.1.1127: getwinpos() doesn't work in terminal on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16243
diff changeset
650 #if ((defined(FEAT_EVAL) || defined(FEAT_TERMINAL)) \
16243
3b79a3029947 patch 8.1.1126: build failure with +terminal but without tgetent
Bram Moolenaar <Bram@vim.org>
parents: 16241
diff changeset
651 && (defined(FEAT_GUI) \
16253
f28ef3d27f91 patch 8.1.1131: getwinpos() does not work in the MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16245
diff changeset
652 || defined(MSWIN) \
16243
3b79a3029947 patch 8.1.1126: build failure with +terminal but without tgetent
Bram Moolenaar <Bram@vim.org>
parents: 16241
diff changeset
653 || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)))) \
16241
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
654 || defined(PROTO)
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
655 /*
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
656 * Get the window position in pixels, if possible.
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
657 * Return FAIL when not possible.
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
658 */
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
659 int
18139
59bc3cd42cf5 patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents: 18135
diff changeset
660 ui_get_winpos(int *x, int *y, varnumber_T timeout UNUSED)
16241
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
661 {
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
662 # ifdef FEAT_GUI
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
663 if (gui.in_use)
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
664 return gui_mch_get_winpos(x, y);
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
665 # endif
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16253
diff changeset
666 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))
16253
f28ef3d27f91 patch 8.1.1131: getwinpos() does not work in the MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16245
diff changeset
667 return mch_get_winpos(x, y);
f28ef3d27f91 patch 8.1.1131: getwinpos() does not work in the MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16245
diff changeset
668 # else
f28ef3d27f91 patch 8.1.1131: getwinpos() does not work in the MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16245
diff changeset
669 # if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
16241
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
670 return term_get_winpos(x, y, timeout);
16253
f28ef3d27f91 patch 8.1.1131: getwinpos() does not work in the MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16245
diff changeset
671 # else
16245
e0a6298bd70f patch 8.1.1127: getwinpos() doesn't work in terminal on MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16243
diff changeset
672 return FAIL;
16253
f28ef3d27f91 patch 8.1.1131: getwinpos() does not work in the MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16245
diff changeset
673 # endif
16241
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
674 # endif
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
675 }
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
676 #endif
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
677
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
679 ui_breakcheck(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 {
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
681 ui_breakcheck_force(FALSE);
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
682 }
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
683
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
684 /*
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
685 * When "force" is true also check when the terminal is not in raw mode.
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
686 * This is useful to read input on channels.
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
687 */
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
688 void
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
689 ui_breakcheck_force(int force)
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
690 {
15052
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
691 static int recursive = FALSE;
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
692 int save_updating_screen = updating_screen;
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
693
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
694 // We could be called recursively if stderr is redirected, calling
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
695 // fill_input_buf() calls settmode() when stdin isn't a tty. settmode()
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
696 // calls vgetorpeek() which calls ui_breakcheck() again.
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
697 if (recursive)
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
698 return;
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
699 recursive = TRUE;
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
700
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
701 // We do not want gui_resize_shell() to redraw the screen here.
10771
abc27e523e2a patch 8.0.0275: the screen may be updated at the wrong time
Christian Brabandt <cb@256bit.org>
parents: 10240
diff changeset
702 ++updating_screen;
abc27e523e2a patch 8.0.0275: the screen may be updated at the wrong time
Christian Brabandt <cb@256bit.org>
parents: 10240
diff changeset
703
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 #endif
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
709 mch_breakcheck(force);
10771
abc27e523e2a patch 8.0.0275: the screen may be updated at the wrong time
Christian Brabandt <cb@256bit.org>
parents: 10240
diff changeset
710
14730
193471015e1a patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents: 13888
diff changeset
711 if (save_updating_screen)
193471015e1a patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents: 13888
diff changeset
712 updating_screen = TRUE;
13888
81e8e6181aeb patch 8.0.1815: crash with terminal window and with 'lazyredraw' set
Christian Brabandt <cb@256bit.org>
parents: 13876
diff changeset
713 else
16835
7cade95272c4 patch 8.1.1419: listener callbacks may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
714 after_updating_screen(FALSE);
15052
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
715
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
716 recursive = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
719 //////////////////////////////////////////////////////////////////////////////
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
720 // Functions that handle the input buffer.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
721 // This is used for any GUI version, and the unix terminal version.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
722 //
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
723 // For Unix, the input characters are buffered to be able to check for a
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
724 // CTRL-C. This should be done with signals, but I don't know how to do that
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
725 // in a portable way for a tty in RAW mode.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
726 //
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
727 // For the client-server code in the console the received keys are put in the
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
728 // input buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 #if defined(USE_INPUT_BUF) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 * Internal typeahead buffer. Includes extra space for long key code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 * descriptions which would otherwise overflow. The buffer is considered full
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 * when only this extra space (or part of it) remains.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 */
15510
41fbbcea0f1b patch 8.1.0763: nobody is using the Sun Workshop support
Bram Moolenaar <Bram@vim.org>
parents: 15506
diff changeset
737 #if defined(FEAT_JOB_CHANNEL) || defined(FEAT_CLIENTSERVER)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 /*
15510
41fbbcea0f1b patch 8.1.0763: nobody is using the Sun Workshop support
Bram Moolenaar <Bram@vim.org>
parents: 15506
diff changeset
739 * NetBeans stuffs debugger commands into the input buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 * This requires a larger buffer...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 * (Madsen) Go with this for remote input as well ...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 # define INBUFLEN 4096
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 # define INBUFLEN 250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 static char_u inbuf[INBUFLEN + MAX_KEY_CODE_LEN];
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
749 static int inbufcount = 0; // number of chars in inbuf[]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 * vim_is_input_buf_full(), vim_is_input_buf_empty(), add_to_input_buf(), and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 * trash_input_buf() are functions for manipulating the input buffer. These
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 * are used by the gui_* calls when a GUI is used to handle keyboard input.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
758 vim_is_input_buf_full(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 return (inbufcount >= INBUFLEN);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
764 vim_is_input_buf_empty(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 return (inbufcount == 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 #if defined(FEAT_OLE) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
771 vim_free_in_input_buf(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 return (INBUFLEN - inbufcount);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776
575
f1d46f948241 updated for version 7.0163
vimboss
parents: 534
diff changeset
777 #if defined(FEAT_GUI_GTK) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
779 vim_used_in_input_buf(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 return inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 * Return the current contents of the input buffer and make it empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 * The returned pointer must be passed to set_input_buf() later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 char_u *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
790 get_input_buf(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 garray_T *gap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
794 // We use a growarray to store the data pointer and the length.
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
795 gap = ALLOC_ONE(garray_T);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 if (gap != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
798 // Add one to avoid a zero size.
16768
695d9ef00b03 patch 8.1.1386: unessesary type casts for lalloc()
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
799 gap->ga_data = alloc(inbufcount + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 if (gap->ga_data != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 mch_memmove(gap->ga_data, inbuf, (size_t)inbufcount);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 gap->ga_len = inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 trash_input_buf();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 return (char_u *)gap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 * Restore the input buffer with a pointer returned from get_input_buf().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 * The allocated memory is freed, this only works once!
24846
fdc6a7769045 patch 8.2.2961: keys typed during a :normal command are discarded
Bram Moolenaar <Bram@vim.org>
parents: 24196
diff changeset
811 * When "overwrite" is FALSE input typed later is kept.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 void
24846
fdc6a7769045 patch 8.2.2961: keys typed during a :normal command are discarded
Bram Moolenaar <Bram@vim.org>
parents: 24196
diff changeset
814 set_input_buf(char_u *p, int overwrite)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 garray_T *gap = (garray_T *)p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
818 if (gap == NULL)
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
819 return;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
820
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
821 if (gap->ga_data != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 {
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
823 if (overwrite || inbufcount + gap->ga_len >= INBUFLEN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 {
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
825 mch_memmove(inbuf, gap->ga_data, gap->ga_len);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
826 inbufcount = gap->ga_len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 }
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
828 else
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
829 {
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
830 mch_memmove(inbuf + gap->ga_len, inbuf, inbufcount);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
831 mch_memmove(inbuf, gap->ga_data, gap->ga_len);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
832 inbufcount += gap->ga_len;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
833 }
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
834 vim_free(gap->ga_data);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 }
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31287
diff changeset
836 vim_free(gap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 * Add the given bytes to the input buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 * Special keys start with CSI. A real CSI must have been translated to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 * CSI KS_EXTRA KE_CSI. K_SPECIAL doesn't require translation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
845 add_to_input_buf(char_u *s, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 if (inbufcount + len > INBUFLEN + MAX_KEY_CODE_LEN)
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
848 return; // Shouldn't ever happen!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 while (len--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 inbuf[inbufcount++] = *s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 * Add "str[len]" to the input buffer while escaping CSI bytes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 add_to_input_buf_csi(char_u *str, int len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 char_u buf[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 for (i = 0; i < len; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 add_to_input_buf(str + i, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 if (str[i] == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
868 // Turn CSI into K_CSI.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 buf[0] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 buf[1] = (int)KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 add_to_input_buf(buf, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
876 /*
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
877 * Remove everything from the input buffer. Called when ^C is found.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
878 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
880 trash_input_buf(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 inbufcount = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 * Read as much data from the input buffer as possible up to maxlen, and store
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 * it in buf.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
890 read_from_input_buf(char_u *buf, long maxlen)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
892 if (inbufcount == 0) // if the buffer is empty, fill it
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 fill_input_buf(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 if (maxlen > inbufcount)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 maxlen = inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 mch_memmove(buf, inbuf, (size_t)maxlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 inbufcount -= maxlen;
29109
c1c795a61545 patch 8.2.5075: clang gives an out of bounds warning
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
898 // check "maxlen" to avoid clang warning
c1c795a61545 patch 8.2.5075: clang gives an out of bounds warning
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
899 if (inbufcount > 0 && maxlen > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 mch_memmove(inbuf, inbuf + maxlen, (size_t)inbufcount);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 return (int)maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
905 fill_input_buf(int exit_on_error UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 {
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12519
diff changeset
907 #if defined(UNIX) || defined(VMS) || defined(MACOS_X)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 int try;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 static int did_read_something = FALSE;
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
911 static char_u *rest = NULL; // unconverted rest of previous read
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 static int restlen = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 int unconverted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 #ifdef FEAT_GUI
294
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
917 if (gui.in_use
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
918 # ifdef NO_CONSOLE_INPUT
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
919 // Don't use the GUI input when the window hasn't been opened yet.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
920 // We get here from ui_inchar() when we should try reading from stdin.
294
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
921 && !no_console_input()
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
922 # endif
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
923 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 #endif
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12519
diff changeset
929 #if defined(UNIX) || defined(VMS) || defined(MACOS_X)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 if (vim_is_input_buf_full())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 * Fill_input_buf() is only called when we really need a character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 * If we can't get any, but there is some in the buffer, just return.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 * If we can't get any, and there isn't any in the buffer, we give up and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 * exit Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 if (rest != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
940 // Use remainder of previous call, starts with an invalid character
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
941 // that may become valid when reading more.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 if (restlen > INBUFLEN - inbufcount)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 unconverted = INBUFLEN - inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 unconverted = restlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 mch_memmove(inbuf + inbufcount, rest, unconverted);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 if (unconverted == restlen)
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
948 VIM_CLEAR(rest);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 restlen -= unconverted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 mch_memmove(rest, rest + unconverted, restlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 inbufcount += unconverted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 unconverted = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
959 len = 0; // to avoid gcc warning
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 for (try = 0; try < 100; ++try)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 {
13758
63679d671ced patch 8.0.1751: #ifdef causes bad highlighting
Christian Brabandt <cb@256bit.org>
parents: 13448
diff changeset
962 size_t readlen = (size_t)((INBUFLEN - inbufcount)
19730
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
963 / input_conv.vc_factor);
13758
63679d671ced patch 8.0.1751: #ifdef causes bad highlighting
Christian Brabandt <cb@256bit.org>
parents: 13448
diff changeset
964 # ifdef VMS
13776
ef6de4674811 patch 8.0.1760: wrong number of arguments to vms_read()
Christian Brabandt <cb@256bit.org>
parents: 13758
diff changeset
965 len = vms_read((char *)inbuf + inbufcount, readlen);
13758
63679d671ced patch 8.0.1751: #ifdef causes bad highlighting
Christian Brabandt <cb@256bit.org>
parents: 13448
diff changeset
966 # else
63679d671ced patch 8.0.1751: #ifdef causes bad highlighting
Christian Brabandt <cb@256bit.org>
parents: 13448
diff changeset
967 len = read(read_cmd_fd, (char *)inbuf + inbufcount, readlen);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 # endif
31287
fa309d9af73c patch 9.0.0977: it is not easy to see what client-server commands are doing
Bram Moolenaar <Bram@vim.org>
parents: 31103
diff changeset
969 # ifdef FEAT_EVAL
22065
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
970 if (len > 0)
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
971 {
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
972 inbuf[inbufcount + len] = NUL;
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
973 ch_log(NULL, "raw key input: \"%s\"", inbuf + inbufcount);
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
974 }
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
975 # endif
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 39
diff changeset
976
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 if (len > 0 || got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 * If reading stdin results in an error, continue reading stderr.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 * This helps when using "foo | xargs vim".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 if (!did_read_something && !isatty(read_cmd_fd) && read_cmd_fd == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 int m = cur_tmode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
987 // We probably set the wrong file descriptor to raw mode. Switch
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
988 // back to cooked mode, use another descriptor and set the mode to
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
989 // what it was.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 settmode(TMODE_COOK);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 #ifdef HAVE_DUP
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
992 // Use stderr for stdin, also works for shell commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 close(0);
14730
193471015e1a patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents: 13888
diff changeset
994 vim_ignored = dup(2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 #else
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
996 read_cmd_fd = 2; // read from stderr instead of stdin
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 settmode(m);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 if (!exit_on_error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 if (len <= 0 && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 read_error_exit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 if (len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 did_read_something = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 if (got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1009 // Interrupted, pretend a CTRL-C was typed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 inbuf[0] = 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 inbufcount = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 * May perform conversion on the input characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 * Include the unconverted rest of the previous call.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 * If there is an incomplete char at the end it is kept for the next
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 * time, reading more bytes should make conversion possible.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 * Don't do this in the unlikely event that the input buffer is too
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 * small ("rest" still contains more bytes).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 if (input_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 inbufcount -= unconverted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 len = convert_input_safe(inbuf + inbufcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 len + unconverted, INBUFLEN - inbufcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 rest == NULL ? &rest : NULL, &restlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 }
26727
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1030 while (len > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 {
23479
39d62cdde492 patch 8.2.2282: length check mismatch with argument of strncmp()
Bram Moolenaar <Bram@vim.org>
parents: 23464
diff changeset
1032 // If a CTRL-C was typed, remove it from the buffer and set
26727
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1033 // got_int. Also recognize CTRL-C with modifyOtherKeys set, lower
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1034 // and upper case, in two forms.
33662
664ee4c0daca patch 9.0.2069: possible to escape bracketed paste mode with Ctrl-C
Christian Brabandt <cb@256bit.org>
parents: 31827
diff changeset
1035 // If terminal key protocols are in use, we expect to receive
664ee4c0daca patch 9.0.2069: possible to escape bracketed paste mode with Ctrl-C
Christian Brabandt <cb@256bit.org>
parents: 31827
diff changeset
1036 // Ctrl_C as an escape sequence, ignore a raw Ctrl_C as this could
664ee4c0daca patch 9.0.2069: possible to escape bracketed paste mode with Ctrl-C
Christian Brabandt <cb@256bit.org>
parents: 31827
diff changeset
1037 // be paste data.
664ee4c0daca patch 9.0.2069: possible to escape bracketed paste mode with Ctrl-C
Christian Brabandt <cb@256bit.org>
parents: 31827
diff changeset
1038 if (ctrl_c_interrupts
664ee4c0daca patch 9.0.2069: possible to escape bracketed paste mode with Ctrl-C
Christian Brabandt <cb@256bit.org>
parents: 31827
diff changeset
1039 && ((inbuf[inbufcount] == Ctrl_C && !key_protocol_enabled())
23479
39d62cdde492 patch 8.2.2282: length check mismatch with argument of strncmp()
Bram Moolenaar <Bram@vim.org>
parents: 23464
diff changeset
1040 || (len >= 10 && STRNCMP(inbuf + inbufcount,
23464
a0fc14114576 patch 8.2.2275: CTRL-C not recognized in Mintty
Bram Moolenaar <Bram@vim.org>
parents: 22065
diff changeset
1041 "\033[27;5;99~", 10) == 0)
26727
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1042 || (len >= 10 && STRNCMP(inbuf + inbufcount,
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1043 "\033[27;5;67~", 10) == 0)
23464
a0fc14114576 patch 8.2.2275: CTRL-C not recognized in Mintty
Bram Moolenaar <Bram@vim.org>
parents: 22065
diff changeset
1044 || (len >= 7 && STRNCMP(inbuf + inbufcount,
26727
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1045 "\033[99;5u", 7) == 0)
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1046 || (len >= 7 && STRNCMP(inbuf + inbufcount,
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1047 "\033[67;5u", 7) == 0)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1049 // remove everything typed before the CTRL-C
26727
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1050 mch_memmove(inbuf, inbuf + inbufcount, (size_t)(len));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 inbufcount = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 }
26727
077277ee1626 patch 8.2.3892: when modifyOtherKeys is used CTRL-C is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26602
diff changeset
1054 --len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 ++inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 }
18880
18a4871332ce patch 8.2.0001: #endif comments do reflect corresponding #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
1058 #endif // UNIX || VMS || MACOS_X
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 }
18880
18a4871332ce patch 8.2.0001: #endif comments do reflect corresponding #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
1060 #endif // USE_INPUT_BUF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 * Exit because of an input read error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1066 read_error_exit(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1068 if (silent_mode) // Normal way to exit for "ex -s"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 getout(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 STRCPY(IObuff, _("Vim: Error reading input, exiting...\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 preserve_exit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 #if defined(CURSOR_SHAPE) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 * May update the shape of the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 void
12076
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1079 ui_cursor_shape_forced(int forced)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 gui_update_cursor_later();
36
125e80798a85 updated for version 7.0021
vimboss
parents: 11
diff changeset
1084 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 # endif
12076
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1086 term_cursor_mode(forced);
36
125e80798a85 updated for version 7.0021
vimboss
parents: 11
diff changeset
1087
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 # ifdef MCH_CURSOR_SHAPE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 mch_update_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 # endif
2378
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
1091
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
1092 # ifdef FEAT_CONCEAL
25074
aa55d6d17625 patch 8.2.3074: popup_atcursor() uses wrong position with concealing
Bram Moolenaar <Bram@vim.org>
parents: 24846
diff changeset
1093 conceal_check_cursor_line(FALSE);
2378
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
1094 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 }
12076
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1096
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1097 void
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1098 ui_cursor_shape(void)
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1099 {
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1100 ui_cursor_shape_forced(FALSE);
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1101 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 * Check bounds for column number
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1108 check_col(int col)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 if (col < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 return 0;
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26727
diff changeset
1112 if (col >= screen_Columns)
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26727
diff changeset
1113 return screen_Columns - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 return col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 * Check bounds for row number
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1121 check_row(int row)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 if (row < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 return 0;
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26727
diff changeset
1125 if (row >= screen_Rows)
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26727
diff changeset
1126 return screen_Rows - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 return row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 /*
31103
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1131 * Return length of line "lnum" in screen cells for horizontal scrolling.
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1132 */
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1133 long
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1134 scroll_line_len(linenr_T lnum)
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1135 {
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1136 char_u *p = ml_get(lnum);
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1137 colnr_T col = 0;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1138
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1139 if (*p != NUL)
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1140 for (;;)
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1141 {
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1142 int w = chartabsize(p, col);
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1143 MB_PTR_ADV(p);
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1144 if (*p == NUL) // don't count the last character
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1145 break;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1146 col += w;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1147 }
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1148 return col;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1149 }
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1150
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1151 /*
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1152 * Find the longest visible line number. This is used for horizontal
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1153 * scrolling. If this is not possible (or not desired, by setting 'h' in
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1154 * "guioptions") then the current line number is returned.
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1155 */
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1156 linenr_T
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1157 ui_find_longest_lnum(void)
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1158 {
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1159 linenr_T ret = 0;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1160
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1161 // Calculate maximum for horizontal scrollbar. Check for reasonable
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1162 // line numbers, topline and botline can be invalid when displaying is
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1163 // postponed.
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1164 if (
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1165 # ifdef FEAT_GUI
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1166 (!gui.in_use || vim_strchr(p_go, GO_HORSCROLL) == NULL) &&
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1167 # endif
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1168 curwin->w_topline <= curwin->w_cursor.lnum
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1169 && curwin->w_botline > curwin->w_cursor.lnum
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1170 && curwin->w_botline <= curbuf->b_ml.ml_line_count + 1)
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1171 {
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1172 linenr_T lnum;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1173 long n;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1174 long max = 0;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1175
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1176 // Use maximum of all visible lines. Remember the lnum of the
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1177 // longest line, closest to the cursor line. Used when scrolling
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1178 // below.
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1179 for (lnum = curwin->w_topline; lnum < curwin->w_botline; ++lnum)
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1180 {
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1181 n = scroll_line_len(lnum);
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1182 if (n > max)
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1183 {
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1184 max = n;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1185 ret = lnum;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1186 }
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1187 else if (n == max && abs((int)(lnum - curwin->w_cursor.lnum))
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1188 < abs((int)(ret - curwin->w_cursor.lnum)))
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1189 ret = lnum;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1190 }
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1191 }
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1192 else
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1193 // Use cursor line only.
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1194 ret = curwin->w_cursor.lnum;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1195
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1196 return ret;
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1197 }
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1198
33ca088dbd3e patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
1199 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 * Called when focus changed. Used for the GUI or for systems where this can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 * be done in the console (Win32).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1204 ui_focus_change(
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1205 int in_focus) // TRUE if focus gained.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 static time_t last_time = (time_t)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 int need_redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1210 // When activated: Check if any file was modified outside of Vim.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1211 // Only do this when not done within the last two seconds (could get
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1212 // several events in a row).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 if (in_focus && last_time + 2 < time(NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 need_redraw = check_timestamps(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 last_time = time(NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224
26462
3af56224dca6 patch 8.2.3761: focus change is not passed on to a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
1225 #ifdef FEAT_TERMINAL
3af56224dca6 patch 8.2.3761: focus change is not passed on to a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
1226 term_focus_change(in_focus);
3af56224dca6 patch 8.2.3761: focus change is not passed on to a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
1227 #endif
3af56224dca6 patch 8.2.3761: focus change is not passed on to a terminal window
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
1228
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 * Fire the focus gained/lost autocommand.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 need_redraw |= apply_autocmds(in_focus ? EVENT_FOCUSGAINED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 : EVENT_FOCUSLOST, NULL, NULL, FALSE, curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 if (need_redraw)
26466
d413104a94c8 patch 8.2.3763: when editing the cmdline a callback may cause a scroll up
Bram Moolenaar <Bram@vim.org>
parents: 26462
diff changeset
1236 redraw_after_callback(TRUE, TRUE);
26336
a2e6da79274d patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Bram Moolenaar <Bram@vim.org>
parents: 25074
diff changeset
1237
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1238 // File may have been changed from 'readonly' to 'noreadonly'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 if (need_maketitle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 maketitle();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13373
diff changeset
1243 #if defined(HAVE_INPUT_METHOD) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 * Save current Input Method status to specified place.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1248 im_save_status(long *psave)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1250 // Don't save when 'imdisable' is set or "xic" is NULL, IM is always
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1251 // disabled then (but might start later).
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1252 // Also don't save when inside a mapping, vgetc_im_active has not been set
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1253 // then.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1254 // And don't save when the keys were stuffed (e.g., for a "." command).
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1255 // And don't save when the GUI is running but our window doesn't have
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1256 // input focus (e.g., when a find dialog is open).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 if (!p_imdisable && KeyTyped && !KeyStuffed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 # ifdef FEAT_XIM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 && xic != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 && (!gui.in_use || gui.in_focus)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1266 // Do save when IM is on, or IM is off and saved status is on.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 if (vgetc_im_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 *psave = B_IMODE_IM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 else if (*psave == B_IMODE_IM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 *psave = B_IMODE_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 #endif