annotate src/ui.c @ 22361:00f2eebe74d9 v8.2.1729

patch 8.2.1729: endless loop when ":normal" feeds popup window filter Commit: https://github.com/vim/vim/commit/189832bf661168df7ebd428e4088737718775fbd Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 23 12:29:11 2020 +0200 patch 8.2.1729: endless loop when ":normal" feeds popup window filter Problem: Endless loop when ":normal" feeds popup window filter. Solution: Add the ex_normal_busy_done flag.
author Bram Moolenaar <Bram@vim.org>
date Wed, 23 Sep 2020 12:30:04 +0200
parents d8b95a9cdaaa
children a0fc14114576
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
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
21 ui_write(char_u *s, int len)
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 if (gui.in_use && !gui.dying && !gui.starting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 gui_write(s, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 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
28 gui_wait_for_chars(p_wd, typebuf.tb_change_cnt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 #ifndef NO_CONSOLE
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
33 // Don't output anything in silent mode ("ex -s") unless 'verbose' set
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 if (!(silent_mode && p_verbose == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 {
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15665
diff changeset
36 #if !defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 char_u *tofree = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
41 // Convert characters from 'encoding' to 'termencoding'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 tofree = string_convert(&output_conv, s, &len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 if (tofree != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 s = tofree;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 mch_write(s, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15665
diff changeset
50 # if !defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 vim_free(tofree);
15605
62b3805506b3 patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15555
diff changeset
53 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 }
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(UNIX) || defined(VMS) || defined(PROTO) || defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 * When executing an external program, there may be some typed characters that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 * 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
62 * here for the next call.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 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
65 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
66 static int ta_len; // length of ta_str when it's not NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
69 ui_inchar_undo(char_u *s, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 char_u *new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 int newlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 newlen = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 if (ta_str != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 newlen += ta_len - ta_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 new = alloc(newlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 if (new != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 if (ta_str != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 mch_memmove(new, ta_str + ta_off, (size_t)(ta_len - ta_off));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 mch_memmove(new + ta_len - ta_off, s, (size_t)len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 vim_free(ta_str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 mch_memmove(new, s, (size_t)len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 ta_str = new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 ta_len = newlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 ta_off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 /*
3877
cd6c420e31d6 updated for version 7.3.695
Bram Moolenaar <bram@vim.org>
parents: 3770
diff changeset
96 * ui_inchar(): low level input function.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 * Get characters from the keyboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 * Return the number of characters that are available.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 * If "wtime" == 0 do not wait for characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 * If "wtime" == -1 wait forever for characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 * If "wtime" > 0 wait "wtime" milliseconds for a character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 * "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
104 * it. When typebuf.tb_change_cnt changes (e.g., when a message is received
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 * 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
106 * otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
109 ui_inchar(
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
110 char_u *buf,
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
111 int maxlen,
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
112 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
113 int tb_change_cnt)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 int retval = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 #if defined(FEAT_GUI) && (defined(UNIX) || defined(VMS))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 * Use the typeahead if there is any.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 if (ta_str != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 if (maxlen >= ta_len - ta_off)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 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
126 VIM_CLEAR(ta_str);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 return ta_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 mch_memmove(buf, ta_str + ta_off, (size_t)maxlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 ta_off += maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 return maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
135 #ifdef FEAT_PROFILE
791
98a88a884610 updated for version 7.0230
vimboss
parents: 761
diff changeset
136 if (do_profiling == PROF_YES && wtime != 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
137 prof_inchar_enter();
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
138 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
139
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 #ifdef NO_CONSOLE_INPUT
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
141 // 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
142 // 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
143 // 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
144 // this very often we probably got stuck, exit Vim.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 if (no_console_input())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 static int count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 # 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
150 retval = mch_inchar(buf, maxlen, wtime, tb_change_cnt);
228
d97518d6b325 updated for version 7.0063
vimboss
parents: 170
diff changeset
151 if (retval > 0 || typebuf_changed(tb_change_cnt) || wtime >= 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
152 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 if (wtime == -1 && ++count == 1000)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 read_error_exit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 buf[0] = CAR;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
157 retval = 1;
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
158 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
162 // If we are going to wait for some time or block...
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
163 if (wtime == -1 || wtime > 100L)
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
164 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
165 // ... allow signals to kill us.
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
166 (void)vim_handle_signal(SIGNAL_UNBLOCK);
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
167
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
168 // ... 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
169 // 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
170 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
171 ctrl_c_interrupts = FALSE;
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
172 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
15653
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
174 /*
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
175 * 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
176 * 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
177 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
178 * 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
179 * {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
180 * 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
181 * 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
182 * 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
183 * 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
184 * 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
185 * 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
186 * break;
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 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
189 * 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
190 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
191 * 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
192 * {
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 (any-timer-triggered)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
194 * invoke-timer-callback;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
195 * 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
196 * 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
197 * break;
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 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
200 * 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
201 * 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
202 * {
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 event;
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 (something on channel)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
205 * read/write channel;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
206 * else if (resized)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
207 * 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
208 * else if (system event)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
209 * deal-with-system-event;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
210 * else 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
211 * break;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
212 * }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
213 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
214 */
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
215
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 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
218 retval = gui_inchar(buf, maxlen, wtime, tb_change_cnt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 #ifndef NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 retval = mch_inchar(buf, maxlen, wtime, tb_change_cnt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
227 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
228 // block SIGHUP et al.
1086
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
229 (void)vim_handle_signal(SIGNAL_BLOCK);
1a511b7b69eb updated for version 7.0-212
vimboss
parents: 944
diff changeset
230
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 ctrl_c_interrupts = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
233 #ifdef NO_CONSOLE_INPUT
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
234 theend:
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
235 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
236 #ifdef FEAT_PROFILE
791
98a88a884610 updated for version 7.0230
vimboss
parents: 761
diff changeset
237 if (do_profiling == PROF_YES && wtime != 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
238 prof_inchar_exit();
8c60f65311fa updated for version 7.0052
vimboss
parents: 169
diff changeset
239 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242
18896
4481f3b29fc5 patch 8.2.0009: VMS: terminal version doesn't build
Bram Moolenaar <Bram@vim.org>
parents: 18880
diff changeset
243 #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
244 /*
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
245 * 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
246 * 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
247 * 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
248 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
249 * "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
250 * 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
251 *
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
252 * 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
253 * 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
254 * 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
255 * 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
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 int
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
266 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
267 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
268 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
269 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
270 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
271 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
272 #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
273 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
274
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
275 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
276 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
277
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
278 // 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
279 for (;;)
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
280 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
281 // 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
282 // 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
283 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
284 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
285
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
286 #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
287 // 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
288 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
289 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
290 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
291 // 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
292 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
293 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
294 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
295 #endif
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 && 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
297 // 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
298 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
299 else
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
300 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
301 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
302 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
303 else
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
304 // 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
305 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
306 #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
307 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
308 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
309 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
310
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15655
diff changeset
311 // 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
312 // 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
313 // 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
314 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
315 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
316 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
317 // 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
318 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
319
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
320 // 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
321 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
322 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
323 && !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
324 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
325 // 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
326 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
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 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
329
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
330 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
331 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
332 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
333 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
334 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
335 else
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
336 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
337 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
338 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
339 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
340 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
341 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
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
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
344 // 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
345 // 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
346 // 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
347 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
348 continue;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
349 }
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 #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
353 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
354 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
355 // 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
356 // 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
357 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
358 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
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 // 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
361 // 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
362 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
363 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
364 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
365 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
366 #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
367 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
368 // 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
369 // 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
370 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
371 #endif
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 // 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
374 // 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
375 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
376 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
377 {
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
378 // 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
379 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
380 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
381
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
382 // 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
383 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
384 // "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
385 // input.
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
386 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
387
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
388 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
389 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
390 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
391 continue;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
392 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
393 // 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
394
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
395 #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
396 // 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
397 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
398 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
399
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
400 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
401 #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
402 || 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
403 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
404 #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
405 || interrupted
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 || 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
408 || (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
409 // 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
410 continue;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
411
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
412 // 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
413 break;
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
414 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
415 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
416 }
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
417 #endif
59a1ff689b4d patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
418
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
419 #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
420 /*
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
421 * 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
422 * 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
423 * 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
424 */
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
425 int
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
426 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
427 long wtime,
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
428 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
429 int *interrupted,
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
430 int ignore_input)
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
431 {
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
432 int due_time;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
433 long remaining = wtime;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
434 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
435 # 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
436 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
437 # 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
438
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
439 // 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
440 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
441 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
442
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
443 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
444 {
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 // 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
446 // 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
447 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
448 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
449 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
450 // 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
451 return FAIL;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
452 }
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
453 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
454 due_time = remaining;
17708
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
455 # if defined(FEAT_JOB_CHANNEL) || defined(FEAT_SOUND_CANBERRA)
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
456 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
457 # 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
458 (
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
459 # 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
460 !gui.in_use &&
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
461 # endif
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
462 (has_pending_job() || channel_any_readahead()))
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
463 # ifdef FEAT_SOUND_CANBERRA
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
464 ||
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
465 # 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
466 # endif
17708
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
467 # ifdef FEAT_SOUND_CANBERRA
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
468 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
469 # endif
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
470 ))
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
471 {
440e5071f3f8 patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents: 15075
diff changeset
472 // 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
473 // 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
474 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
475 # 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
476 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
477 # 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
478 }
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 # endif
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
480 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
481 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
482 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
483 # 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
484 || 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
485 # 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
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 // 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
488 // 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
489 return FAIL;
13060
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
490 if (wtime > 0)
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
491 remaining -= due_time;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
492 }
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
493 return FAIL;
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
494 }
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
495 #endif
1bdc12630fc0 patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
496
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 /*
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
498 * Return non-zero if a character is available.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
501 ui_char_avail(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 return input_available();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 #ifndef NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 # ifdef NO_CONSOLE_INPUT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 if (no_console_input())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 return mch_char_avail();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 * Delay for the given number of milliseconds. If ignoreinput is FALSE then we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 * cancel the delay if a key is hit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 void
20861
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
526 ui_delay(long msec_arg, int ignoreinput)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 {
20861
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
528 long msec = msec_arg;
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
529
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
530 #ifdef FEAT_EVAL
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
531 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
532 msec = ui_delay_for_testing;
1725bb56178a patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents: 20591
diff changeset
533 #endif
18642
bbea1f108187 patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
534 #ifdef FEAT_JOB_CHANNEL
bbea1f108187 patch 8.1.2313: debugging where a delay comes from is not easy
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
535 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
536 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 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
539 gui_wait_for_chars(msec, typebuf.tb_change_cnt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 #endif
21927
88070e222e82 patch 8.2.1513: cannot interrupt shell used for filename expansion
Bram Moolenaar <Bram@vim.org>
parents: 20861
diff changeset
542 mch_delay(msec, ignoreinput ? MCH_DELAY_IGNOREINPUT : 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 * If the machine has job control, use it to suspend the program,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 * otherwise fake it by starting a new shell.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 * When running the GUI iconify the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
551 ui_suspend(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 gui_mch_iconify();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 mch_suspend();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562
20591
4411c2b96af9 patch 8.2.0849: BeOS code is not maintained and probably unused
Bram Moolenaar <Bram@vim.org>
parents: 19774
diff changeset
563 #if !defined(UNIX) || !defined(SIGTSTP) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 * When the OS can't really suspend, call this function to start a shell.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 * This is never called in the GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
569 suspend_shell(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 if (*p_sh == NUL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15404
diff changeset
572 emsg(_(e_shellempty));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
575 msg_puts(_("new shell started\n"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 do_shell(NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 * 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
583 * Use the new sizes as defaults for 'columns' and 'lines'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 * Return OK when size could be determined, FAIL otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
587 ui_get_shellsize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 retval = gui_get_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 retval = mch_get_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 check_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
600 // adjust the default for 'lines' and 'columns'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 if (retval == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 set_number_default("lines", Rows);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 set_number_default("columns", Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 * Set the size of the Vim shell according to Rows and Columns, if possible.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 * The gui_set_shellsize() or mch_set_shellsize() function will try to set the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 * new size. If this is not possible, it will adjust Rows and Columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
615 ui_set_shellsize(
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
616 int mustset UNUSED) // set by the user
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 if (gui.in_use)
5106
c3a82208e143 updated for version 7.3.1296
Bram Moolenaar <bram@vim.org>
parents: 5037
diff changeset
620 gui_set_shellsize(mustset, TRUE, RESIZE_BOTH);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 mch_set_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 * Called when Rows and/or Columns changed. Adjust scroll region and mouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 * region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
631 ui_new_shellsize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 if (full_screen && !exiting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 gui_new_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 mch_new_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643
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
644 #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
645 && (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
646 || defined(MSWIN) \
16243
3b79a3029947 patch 8.1.1126: build failure with +terminal but without tgetent
Bram Moolenaar <Bram@vim.org>
parents: 16241
diff changeset
647 || (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
648 || defined(PROTO)
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
649 /*
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
650 * 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
651 * 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
652 */
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
653 int
18139
59bc3cd42cf5 patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents: 18135
diff changeset
654 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
655 {
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
656 # 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
657 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
658 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
659 # 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
660 # 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
661 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
662 # else
f28ef3d27f91 patch 8.1.1131: getwinpos() does not work in the MS-Windows console
Bram Moolenaar <Bram@vim.org>
parents: 16245
diff changeset
663 # 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
664 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
665 # 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
666 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
667 # endif
16241
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
668 # endif
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
669 }
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
670 #endif
c1698187c482 patch 8.1.1125: libvterm does not handle the window position report
Bram Moolenaar <Bram@vim.org>
parents: 15967
diff changeset
671
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
673 ui_breakcheck(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 {
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
675 ui_breakcheck_force(FALSE);
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
676 }
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
677
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
678 /*
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
679 * 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
680 * 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
681 */
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
682 void
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
683 ui_breakcheck_force(int force)
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
684 {
15052
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
685 static int recursive = FALSE;
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
686 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
687
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
688 // 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
689 // 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
690 // 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
691 if (recursive)
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
692 return;
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
693 recursive = TRUE;
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
694
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
695 // 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
696 ++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
697
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 #endif
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
703 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
704
14730
193471015e1a patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents: 13888
diff changeset
705 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
706 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
707 else
16835
7cade95272c4 patch 8.1.1419: listener callbacks may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
708 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
709
35c2d164a630 patch 8.1.0537: ui_breakcheck() may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
710 recursive = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
713 //////////////////////////////////////////////////////////////////////////////
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
714 // 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
715 // 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
716 //
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
717 // 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
718 // 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
719 // 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
720 //
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
721 // 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
722 // input buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 #if defined(USE_INPUT_BUF) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 * Internal typeahead buffer. Includes extra space for long key code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 * descriptions which would otherwise overflow. The buffer is considered full
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 * when only this extra space (or part of it) remains.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 */
15510
41fbbcea0f1b patch 8.1.0763: nobody is using the Sun Workshop support
Bram Moolenaar <Bram@vim.org>
parents: 15506
diff changeset
731 #if defined(FEAT_JOB_CHANNEL) || defined(FEAT_CLIENTSERVER)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 /*
15510
41fbbcea0f1b patch 8.1.0763: nobody is using the Sun Workshop support
Bram Moolenaar <Bram@vim.org>
parents: 15506
diff changeset
733 * NetBeans stuffs debugger commands into the input buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 * This requires a larger buffer...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 * (Madsen) Go with this for remote input as well ...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 # define INBUFLEN 4096
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 # define INBUFLEN 250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 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
743 static int inbufcount = 0; // number of chars in inbuf[]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 * 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
747 * trash_input_buf() are functions for manipulating the input buffer. These
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 * 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
749 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
752 vim_is_input_buf_full(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 return (inbufcount >= INBUFLEN);
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_empty(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 == 0);
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 #if defined(FEAT_OLE) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
765 vim_free_in_input_buf(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 return (INBUFLEN - inbufcount);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770
575
f1d46f948241 updated for version 7.0163
vimboss
parents: 534
diff changeset
771 #if defined(FEAT_GUI_GTK) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
773 vim_used_in_input_buf(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 return inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 * Return the current contents of the input buffer and make it empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 * The returned pointer must be passed to set_input_buf() later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 char_u *
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
784 get_input_buf(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 garray_T *gap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
788 // 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
789 gap = ALLOC_ONE(garray_T);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 if (gap != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
792 // 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
793 gap->ga_data = alloc(inbufcount + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 if (gap->ga_data != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 mch_memmove(gap->ga_data, inbuf, (size_t)inbufcount);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 gap->ga_len = inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 trash_input_buf();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 return (char_u *)gap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 * Restore the input buffer with a pointer returned from get_input_buf().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 * The allocated memory is freed, this only works once!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
807 set_input_buf(char_u *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 garray_T *gap = (garray_T *)p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 if (gap != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 if (gap->ga_data != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 mch_memmove(inbuf, gap->ga_data, gap->ga_len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 inbufcount = gap->ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 vim_free(gap->ga_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 vim_free(gap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 * Add the given bytes to the input buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 * Special keys start with CSI. A real CSI must have been translated to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 * CSI KS_EXTRA KE_CSI. K_SPECIAL doesn't require translation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
829 add_to_input_buf(char_u *s, int len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 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
832 return; // Shouldn't ever happen!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 while (len--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 inbuf[inbufcount++] = *s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 }
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 * Add "str[len]" to the input buffer while escaping CSI bytes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 add_to_input_buf_csi(char_u *str, int len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 char_u buf[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 for (i = 0; i < len; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 add_to_input_buf(str + i, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 if (str[i] == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
852 // Turn CSI into K_CSI.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 buf[0] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 buf[1] = (int)KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 add_to_input_buf(buf, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
860 /*
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
861 * 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
862 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
864 trash_input_buf(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 inbufcount = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 * 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
871 * it in buf.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
874 read_from_input_buf(char_u *buf, long maxlen)
7
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 if (inbufcount == 0) // if the buffer is empty, fill it
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 fill_input_buf(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 if (maxlen > inbufcount)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 maxlen = inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 mch_memmove(buf, inbuf, (size_t)maxlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 inbufcount -= maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 if (inbufcount)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 mch_memmove(inbuf, inbuf + maxlen, (size_t)inbufcount);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 return (int)maxlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
888 fill_input_buf(int exit_on_error UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 {
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12519
diff changeset
890 #if defined(UNIX) || defined(VMS) || defined(MACOS_X)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 int try;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 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
894 static char_u *rest = NULL; // unconverted rest of previous read
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 static int restlen = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 int unconverted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 #ifdef FEAT_GUI
294
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
900 if (gui.in_use
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
901 # ifdef NO_CONSOLE_INPUT
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
902 // 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
903 // 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
904 && !no_console_input()
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
905 # endif
1c1cbdc42f75 updated for version 7.0077
vimboss
parents: 274
diff changeset
906 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 gui_mch_update();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 #endif
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12519
diff changeset
912 #if defined(UNIX) || defined(VMS) || defined(MACOS_X)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 if (vim_is_input_buf_full())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 * Fill_input_buf() is only called when we really need a character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 * 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
918 * 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
919 * exit Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 if (rest != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
923 // 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
924 // that may become valid when reading more.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 if (restlen > INBUFLEN - inbufcount)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 unconverted = INBUFLEN - inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 unconverted = restlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 mch_memmove(inbuf + inbufcount, rest, unconverted);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 if (unconverted == restlen)
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
931 VIM_CLEAR(rest);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 restlen -= unconverted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 mch_memmove(rest, rest + unconverted, restlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 inbufcount += unconverted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 unconverted = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
942 len = 0; // to avoid gcc warning
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 for (try = 0; try < 100; ++try)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 {
13758
63679d671ced patch 8.0.1751: #ifdef causes bad highlighting
Christian Brabandt <cb@256bit.org>
parents: 13448
diff changeset
945 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
946 / input_conv.vc_factor);
13758
63679d671ced patch 8.0.1751: #ifdef causes bad highlighting
Christian Brabandt <cb@256bit.org>
parents: 13448
diff changeset
947 # ifdef VMS
13776
ef6de4674811 patch 8.0.1760: wrong number of arguments to vms_read()
Christian Brabandt <cb@256bit.org>
parents: 13758
diff changeset
948 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
949 # else
63679d671ced patch 8.0.1751: #ifdef causes bad highlighting
Christian Brabandt <cb@256bit.org>
parents: 13448
diff changeset
950 len = read(read_cmd_fd, (char *)inbuf + inbufcount, readlen);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 # endif
22065
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
952 # ifdef FEAT_JOB_CHANNEL
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
953 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
954 {
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
955 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
956 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
957 }
d8b95a9cdaaa patch 8.2.1582: the channel log does not show typed text
Bram Moolenaar <Bram@vim.org>
parents: 21927
diff changeset
958 # endif
169
0e902b8f511f updated for version 7.0051
vimboss
parents: 39
diff changeset
959
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 if (len > 0 || got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 * If reading stdin results in an error, continue reading stderr.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 * This helps when using "foo | xargs vim".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 if (!did_read_something && !isatty(read_cmd_fd) && read_cmd_fd == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 int m = cur_tmode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
970 // 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
971 // 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
972 // what it was.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 settmode(TMODE_COOK);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 #ifdef HAVE_DUP
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
975 // Use stderr for stdin, also works for shell commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 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
977 vim_ignored = dup(2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 #else
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
979 read_cmd_fd = 2; // read from stderr instead of stdin
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 settmode(m);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 if (!exit_on_error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 if (len <= 0 && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 read_error_exit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 if (len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 did_read_something = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 if (got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
992 // Interrupted, pretend a CTRL-C was typed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 inbuf[0] = 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 inbufcount = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 * May perform conversion on the input characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 * Include the unconverted rest of the previous call.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 * 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
1002 * time, reading more bytes should make conversion possible.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 * Don't do this in the unlikely event that the input buffer is too
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 * small ("rest" still contains more bytes).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 if (input_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 inbufcount -= unconverted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 len = convert_input_safe(inbuf + inbufcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 len + unconverted, INBUFLEN - inbufcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 rest == NULL ? &rest : NULL, &restlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 while (len-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 /*
19730
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
1016 * If a CTRL-C was typed, remove it from the buffer and set
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
1017 * got_int. Also recognize CTRL-C with modifyOtherKeys set.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 */
19730
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
1019 if (ctrl_c_interrupts && (inbuf[inbufcount] == 3
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
1020 || (len >= 9 && STRNCMP(inbuf + inbufcount,
19750
aa674de6d813 patch 8.2.0431: some compilers don't support using e for Esc
Bram Moolenaar <Bram@vim.org>
parents: 19738
diff changeset
1021 "\033[27;5;99~", 10) == 0)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1023 // remove everything typed before the CTRL-C
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 mch_memmove(inbuf, inbuf + inbufcount, (size_t)(len + 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 inbufcount = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 ++inbufcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 }
18880
18a4871332ce patch 8.2.0001: #endif comments do reflect corresponding #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
1031 #endif // UNIX || VMS || MACOS_X
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 }
18880
18a4871332ce patch 8.2.0001: #endif comments do reflect corresponding #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
1033 #endif // USE_INPUT_BUF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 * Exit because of an input read error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1039 read_error_exit(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1041 if (silent_mode) // Normal way to exit for "ex -s"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 getout(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 STRCPY(IObuff, _("Vim: Error reading input, exiting...\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 preserve_exit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 #if defined(CURSOR_SHAPE) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 * May update the shape of the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 void
12076
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1052 ui_cursor_shape_forced(int forced)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 gui_update_cursor_later();
36
125e80798a85 updated for version 7.0021
vimboss
parents: 11
diff changeset
1057 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 # endif
12076
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1059 term_cursor_mode(forced);
36
125e80798a85 updated for version 7.0021
vimboss
parents: 11
diff changeset
1060
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 # ifdef MCH_CURSOR_SHAPE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 mch_update_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 # 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
1064
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
1065 # ifdef FEAT_CONCEAL
13876
156ebdcb8ef5 patch 8.0.1809: various typos
Christian Brabandt <cb@256bit.org>
parents: 13776
diff changeset
1066 conceal_check_cursor_line();
2378
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
1067 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 }
12076
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1069
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1070 void
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1071 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
1072 {
ca4931a20f8c patch 8.0.0918: cannot get terminal window cursor shape or attributes
Christian Brabandt <cb@256bit.org>
parents: 11709
diff changeset
1073 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
1074 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 * Check bounds for column number
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1081 check_col(int col)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 if (col < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 if (col >= (int)screen_Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 return (int)screen_Columns - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 return col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 * Check bounds for row number
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 int
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1094 check_row(int row)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 if (row < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 if (row >= (int)screen_Rows)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 return (int)screen_Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 return row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15665
diff changeset
1103 #if defined(FEAT_GUI) || defined(MSWIN) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 * Called when focus changed. Used for the GUI or for systems where this can
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 * be done in the console (Win32).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1109 ui_focus_change(
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1110 int in_focus) // TRUE if focus gained.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 static time_t last_time = (time_t)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 int need_redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1115 // 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
1116 // 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
1117 // several events in a row).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 if (in_focus && last_time + 2 < time(NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 need_redraw = check_timestamps(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 gui.in_use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 last_time = time(NULL);
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 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 * Fire the focus gained/lost autocommand.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 need_redraw |= apply_autocmds(in_focus ? EVENT_FOCUSGAINED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 : EVENT_FOCUSLOST, NULL, NULL, FALSE, curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 if (need_redraw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1138 // Something was executed, make sure the cursor is put back where it
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1139 // belongs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 if (State & CMDLINE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 redrawcmdline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 else if (State == HITRETURN || State == SETWSIZE || State == ASKMORE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 || State == EXTERNCMD || State == CONFIRM || exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 repeat_message();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 else if ((State & NORMAL) || (State & INSERT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 if (must_redraw != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 update_screen(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 setcursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 }
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1153 cursor_on(); // redrawing may have switched it off
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13060
diff changeset
1154 out_flush_cursor(FALSE, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 gui_update_scrollbars(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 #ifdef FEAT_TITLE
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1161 // File may have been changed from 'readonly' to 'noreadonly'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 if (need_maketitle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 maketitle();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13373
diff changeset
1168 #if defined(HAVE_INPUT_METHOD) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 * Save current Input Method status to specified place.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 void
7835
4d7ce6c03fda commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1173 im_save_status(long *psave)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1175 // 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
1176 // 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
1177 // 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
1178 // then.
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1179 // 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
1180 // 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
1181 // input focus (e.g., when a find dialog is open).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 if (!p_imdisable && KeyTyped && !KeyStuffed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 # ifdef FEAT_XIM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 && xic != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 && (!gui.in_use || gui.in_focus)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1191 // 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
1192 if (vgetc_im_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 *psave = B_IMODE_IM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 else if (*psave == B_IMODE_IM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 *psave = B_IMODE_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 #endif