Mercurial > vim
annotate src/gui.c @ 13684:1651a4c5c27a v8.0.1714
patch 8.0.1714: term_setsize() does not give an error in a normal buffer
commit https://github.com/vim/vim/commit/6e72cd0d7267b9545ef966a53e62706914a96042
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 14 21:31:35 2018 +0200
patch 8.0.1714: term_setsize() does not give an error in a normal buffer
Problem: Term_setsize() does not give an error in a normal buffer.
Solution: Add an error message.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 14 Apr 2018 21:45:07 +0200 |
parents | bf3de2fd98fa |
children | fa0dcdaec6a3 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9939
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * GUI/Motif support by Robert Webb | |
5 * | |
6 * Do ":help uganda" in Vim to read copying and usage conditions. | |
7 * Do ":help credits" in Vim to see a list of people who contributed. | |
8 * See README.txt for an overview of the Vim source code. | |
9 */ | |
10 | |
11 #include "vim.h" | |
12 | |
13 /* Structure containing all the GUI information */ | |
14 gui_T gui; | |
15 | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
16 #if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK) |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
17 static void set_guifontwide(char_u *font_name); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
18 #endif |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
19 static void gui_check_pos(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
20 static void gui_position_components(int); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
21 static void gui_outstr(char_u *, int); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
22 static int gui_screenchar(int off, int flags, guicolor_T fg, guicolor_T bg, int back); |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
23 #ifdef FEAT_GUI_GTK |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
24 static int gui_screenstr(int off, int len, int flags, guicolor_T fg, guicolor_T bg, int back); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
25 #endif |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
26 static void gui_delete_lines(int row, int count); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
27 static void gui_insert_lines(int row, int count); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
28 static void fill_mouse_coord(char_u *p, int col, int row); |
685 | 29 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
30 static int gui_has_tabline(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
31 #endif |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
32 static void gui_do_scrollbar(win_T *wp, int which, int enable); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
33 static colnr_T scroll_line_len(linenr_T lnum); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
34 static linenr_T gui_find_longest_lnum(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
35 static void gui_update_horiz_scrollbar(int); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
36 static void gui_set_fg_color(char_u *name); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
37 static void gui_set_bg_color(char_u *name); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
38 static win_T *xy2win(int x, int y); |
7 | 39 |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12712
diff
changeset
|
40 #if defined(UNIX) && !defined(FEAT_GUI_MAC) |
3087 | 41 # define MAY_FORK |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
42 static void gui_do_fork(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
43 |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
44 static int gui_read_child_pipe(int fd); |
3087 | 45 |
46 /* Return values for gui_read_child_pipe */ | |
47 enum { | |
48 GUI_CHILD_IO_ERROR, | |
49 GUI_CHILD_OK, | |
50 GUI_CHILD_FAILED | |
51 }; | |
52 | |
53 #endif /* MAY_FORK */ | |
54 | |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
55 static void gui_attempt_start(void); |
3087 | 56 |
7 | 57 static int can_update_cursor = TRUE; /* can display the cursor */ |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
58 static int disable_flush = 0; /* If > 0, gui_mch_flush() is disabled. */ |
7 | 59 |
60 /* | |
61 * The Athena scrollbars can move the thumb to after the end of the scrollbar, | |
62 * this makes the thumb indicate the part of the text that is shown. Motif | |
63 * can't do this. | |
64 */ | |
65 #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MAC) | |
66 # define SCROLL_PAST_END | |
67 #endif | |
68 | |
69 /* | |
70 * gui_start -- Called when user wants to start the GUI. | |
71 * | |
72 * Careful: This function can be called recursively when there is a ":gui" | |
73 * command in the .gvimrc file. Only the first call should fork, not the | |
74 * recursive call. | |
75 */ | |
76 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
77 gui_start(void) |
7 | 78 { |
79 char_u *old_term; | |
80 static int recursive = 0; | |
81 | |
82 old_term = vim_strsave(T_NAME); | |
83 | |
84 settmode(TMODE_COOK); /* stop RAW mode */ | |
85 if (full_screen) | |
86 cursor_on(); /* needed for ":gui" in .vimrc */ | |
87 full_screen = FALSE; | |
88 | |
3087 | 89 ++recursive; |
2923 | 90 |
7 | 91 #ifdef MAY_FORK |
3087 | 92 /* |
93 * Quit the current process and continue in the child. | |
94 * Makes "gvim file" disconnect from the shell it was started in. | |
95 * Don't do this when Vim was started with "-f" or the 'f' flag is present | |
96 * in 'guioptions'. | |
97 */ | |
98 if (gui.dofork && !vim_strchr(p_go, GO_FORG) && recursive <= 1) | |
99 { | |
100 gui_do_fork(); | |
101 } | |
102 else | |
103 #endif | |
104 { | |
3541 | 105 #ifdef FEAT_GUI_GTK |
3539 | 106 /* If there is 'f' in 'guioptions' and specify -g argument, |
107 * gui_mch_init_check() was not called yet. */ | |
108 if (gui_mch_init_check() != OK) | |
8617
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
109 getout_preserve_modified(1); |
3541 | 110 #endif |
3087 | 111 gui_attempt_start(); |
112 } | |
7 | 113 |
114 if (!gui.in_use) /* failed to start GUI */ | |
115 { | |
3087 | 116 /* Back to old term settings |
117 * | |
118 * FIXME: If we got here because a child process failed and flagged to | |
119 * the parent to resume, and X11 is enabled with FEAT_TITLE, this will | |
120 * hit an X11 I/O error and do a longjmp(), leaving recursive | |
121 * permanently set to 1. This is probably not as big a problem as it | |
122 * sounds, because gui_mch_init() in both gui_x11.c and gui_gtk_x11.c | |
123 * return "OK" unconditionally, so it would be very difficult to | |
124 * actually hit this case. | |
125 */ | |
126 termcapinit(old_term); | |
7 | 127 settmode(TMODE_RAW); /* restart RAW mode */ |
128 #ifdef FEAT_TITLE | |
129 set_title_defaults(); /* set 'title' and 'icon' again */ | |
130 #endif | |
131 } | |
132 | |
133 vim_free(old_term); | |
134 | |
3087 | 135 /* If the GUI started successfully, trigger the GUIEnter event, otherwise |
136 * the GUIFailed event. */ | |
137 gui_mch_update(); | |
138 apply_autocmds(gui.in_use ? EVENT_GUIENTER : EVENT_GUIFAILED, | |
139 NULL, NULL, FALSE, curbuf); | |
140 --recursive; | |
141 } | |
142 | |
143 /* | |
144 * Set_termname() will call gui_init() to start the GUI. | |
145 * Set the "starting" flag, to indicate that the GUI will start. | |
146 * | |
147 * We don't want to open the GUI shell until after we've read .gvimrc, | |
148 * otherwise we don't know what font we will use, and hence we don't know | |
149 * what size the shell should be. So if there are errors in the .gvimrc | |
150 * file, they will have to go to the terminal: Set full_screen to FALSE. | |
151 * full_screen will be set to TRUE again by a successful termcapinit(). | |
152 */ | |
153 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
154 gui_attempt_start(void) |
3087 | 155 { |
156 static int recursive = 0; | |
157 | |
158 ++recursive; | |
159 gui.starting = TRUE; | |
160 | |
161 #ifdef FEAT_GUI_GTK | |
162 gui.event_time = GDK_CURRENT_TIME; | |
163 #endif | |
164 | |
165 termcapinit((char_u *)"builtin_gui"); | |
166 gui.starting = recursive - 1; | |
167 | |
574 | 168 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) |
7 | 169 if (gui.in_use) |
2609 | 170 { |
171 # ifdef FEAT_EVAL | |
172 Window x11_window; | |
173 Display *x11_display; | |
174 | |
175 if (gui_get_x11_windis(&x11_window, &x11_display) == OK) | |
176 set_vim_var_nr(VV_WINDOWID, (long)x11_window); | |
177 # endif | |
178 | |
7 | 179 /* Display error messages in a dialog now. */ |
180 display_errors(); | |
2609 | 181 } |
7 | 182 #endif |
3087 | 183 --recursive; |
184 } | |
185 | |
186 #ifdef MAY_FORK | |
187 | |
188 /* for waitpid() */ | |
189 # if defined(HAVE_SYS_WAIT_H) || defined(HAVE_UNION_WAIT) | |
190 # include <sys/wait.h> | |
191 # endif | |
192 | |
193 /* | |
194 * Create a new process, by forking. In the child, start the GUI, and in | |
195 * the parent, exit. | |
196 * | |
197 * If something goes wrong, this will return with gui.in_use still set | |
198 * to FALSE, in which case the caller should continue execution without | |
199 * the GUI. | |
200 * | |
201 * If the child fails to start the GUI, then the child will exit and the | |
202 * parent will return. If the child succeeds, then the parent will exit | |
203 * and the child will return. | |
204 */ | |
205 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
206 gui_do_fork(void) |
3087 | 207 { |
208 int pipefd[2]; /* pipe between parent and child */ | |
209 int pipe_error; | |
210 int status; | |
211 int exit_status; | |
212 pid_t pid = -1; | |
213 | |
214 /* Setup a pipe between the child and the parent, so that the parent | |
215 * knows when the child has done the setsid() call and is allowed to | |
216 * exit. */ | |
217 pipe_error = (pipe(pipefd) < 0); | |
218 pid = fork(); | |
219 if (pid < 0) /* Fork error */ | |
7 | 220 { |
3087 | 221 EMSG(_("E851: Failed to create a new process for the GUI")); |
222 return; | |
223 } | |
224 else if (pid > 0) /* Parent */ | |
225 { | |
226 /* Give the child some time to do the setsid(), otherwise the | |
227 * exit() may kill the child too (when starting gvim from inside a | |
228 * gvim). */ | |
229 if (!pipe_error) | |
7 | 230 { |
3087 | 231 /* The read returns when the child closes the pipe (or when |
232 * the child dies for some reason). */ | |
233 close(pipefd[1]); | |
234 status = gui_read_child_pipe(pipefd[0]); | |
235 if (status == GUI_CHILD_FAILED) | |
7 | 236 { |
3087 | 237 /* The child failed to start the GUI, so the caller must |
238 * continue. There may be more error information written | |
239 * to stderr by the child. */ | |
240 # ifdef __NeXT__ | |
241 wait4(pid, &exit_status, 0, (struct rusage *)0); | |
242 # else | |
243 waitpid(pid, &exit_status, 0); | |
244 # endif | |
245 EMSG(_("E852: The child process failed to start the GUI")); | |
246 return; | |
7 | 247 } |
3087 | 248 else if (status == GUI_CHILD_IO_ERROR) |
249 { | |
250 pipe_error = TRUE; | |
251 } | |
252 /* else GUI_CHILD_OK: parent exit */ | |
7 | 253 } |
254 | |
3087 | 255 if (pipe_error) |
256 ui_delay(300L, TRUE); | |
257 | |
258 /* When swapping screens we may need to go to the next line, e.g., | |
259 * after a hit-enter prompt and using ":gui". */ | |
260 if (newline_on_exit) | |
261 mch_errmsg("\r\n"); | |
262 | |
263 /* | |
264 * The parent must skip the normal exit() processing, the child | |
265 * will do it. For example, GTK messes up signals when exiting. | |
266 */ | |
267 _exit(0); | |
268 } | |
269 /* Child */ | |
270 | |
3518 | 271 #ifdef FEAT_GUI_GTK |
272 /* Call gtk_init_check() here after fork(). See gui_init_check(). */ | |
273 if (gui_mch_init_check() != OK) | |
8617
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
274 getout_preserve_modified(1); |
3518 | 275 #endif |
276 | |
7 | 277 # if defined(HAVE_SETSID) || defined(HAVE_SETPGID) |
3087 | 278 /* |
279 * Change our process group. On some systems/shells a CTRL-C in the | |
280 * shell where Vim was started would otherwise kill gvim! | |
281 */ | |
7 | 282 # if defined(HAVE_SETSID) |
3087 | 283 (void)setsid(); |
7 | 284 # else |
3087 | 285 (void)setpgid(0, 0); |
7 | 286 # endif |
287 # endif | |
3087 | 288 if (!pipe_error) |
289 close(pipefd[0]); | |
7 | 290 |
291 # if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION) | |
3087 | 292 /* Tell the session manager our new PID */ |
293 gui_mch_forked(); | |
7 | 294 # endif |
3087 | 295 |
296 /* Try to start the GUI */ | |
297 gui_attempt_start(); | |
298 | |
299 /* Notify the parent */ | |
3147 | 300 if (!pipe_error) |
3087 | 301 { |
3147 | 302 if (gui.in_use) |
303 write_eintr(pipefd[1], "ok", 3); | |
304 else | |
305 write_eintr(pipefd[1], "fail", 5); | |
306 close(pipefd[1]); | |
3087 | 307 } |
308 | |
309 /* If we failed to start the GUI, exit now. */ | |
310 if (!gui.in_use) | |
8617
eab968bf3ce7
commit https://github.com/vim/vim/commit/6d8d849f5ac8a3a228c62fd29e8f40ae1b8381fc
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
311 getout_preserve_modified(1); |
7 | 312 } |
313 | |
314 /* | |
3087 | 315 * Read from a pipe assumed to be connected to the child process (this |
316 * function is called from the parent). | |
317 * Return GUI_CHILD_OK if the child successfully started the GUI, | |
318 * GUY_CHILD_FAILED if the child failed, or GUI_CHILD_IO_ERROR if there was | |
319 * some other error. | |
320 * | |
321 * The file descriptor will be closed before the function returns. | |
322 */ | |
323 static int | |
324 gui_read_child_pipe(int fd) | |
325 { | |
3147 | 326 long bytes_read; |
327 #define READ_BUFFER_SIZE 10 | |
328 char buffer[READ_BUFFER_SIZE]; | |
329 | |
330 bytes_read = read_eintr(fd, buffer, READ_BUFFER_SIZE - 1); | |
331 #undef READ_BUFFER_SIZE | |
332 close(fd); | |
333 if (bytes_read < 0) | |
3087 | 334 return GUI_CHILD_IO_ERROR; |
3147 | 335 buffer[bytes_read] = NUL; |
3087 | 336 if (strcmp(buffer, "ok") == 0) |
337 return GUI_CHILD_OK; | |
338 return GUI_CHILD_FAILED; | |
339 } | |
340 | |
341 #endif /* MAY_FORK */ | |
342 | |
343 /* | |
7 | 344 * Call this when vim starts up, whether or not the GUI is started |
345 */ | |
346 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
347 gui_prepare(int *argc, char **argv) |
7 | 348 { |
349 gui.in_use = FALSE; /* No GUI yet (maybe later) */ | |
350 gui.starting = FALSE; /* No GUI yet (maybe later) */ | |
351 gui_mch_prepare(argc, argv); | |
352 } | |
353 | |
354 /* | |
355 * Try initializing the GUI and check if it can be started. | |
356 * Used from main() to check early if "vim -g" can start the GUI. | |
357 * Used from gui_init() to prepare for starting the GUI. | |
358 * Returns FAIL or OK. | |
359 */ | |
360 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
361 gui_init_check(void) |
7 | 362 { |
363 static int result = MAYBE; | |
364 | |
365 if (result != MAYBE) | |
366 { | |
367 if (result == FAIL) | |
368 EMSG(_("E229: Cannot start the GUI")); | |
369 return result; | |
370 } | |
371 | |
372 gui.shell_created = FALSE; | |
373 gui.dying = FALSE; | |
374 gui.in_focus = TRUE; /* so the guicursor setting works */ | |
375 gui.dragged_sb = SBAR_NONE; | |
376 gui.dragged_wp = NULL; | |
377 gui.pointer_hidden = FALSE; | |
378 gui.col = 0; | |
379 gui.row = 0; | |
380 gui.num_cols = Columns; | |
381 gui.num_rows = Rows; | |
382 | |
383 gui.cursor_is_valid = FALSE; | |
384 gui.scroll_region_top = 0; | |
385 gui.scroll_region_bot = Rows - 1; | |
386 gui.scroll_region_left = 0; | |
387 gui.scroll_region_right = Columns - 1; | |
388 gui.highlight_mask = HL_NORMAL; | |
389 gui.char_width = 1; | |
390 gui.char_height = 1; | |
391 gui.char_ascent = 0; | |
392 gui.border_width = 0; | |
393 | |
394 gui.norm_font = NOFONT; | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
395 #ifndef FEAT_GUI_GTK |
7 | 396 gui.bold_font = NOFONT; |
397 gui.ital_font = NOFONT; | |
398 gui.boldital_font = NOFONT; | |
399 # ifdef FEAT_XFONTSET | |
400 gui.fontset = NOFONTSET; | |
401 # endif | |
402 #endif | |
4950
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
403 #ifdef FEAT_MBYTE |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
404 gui.wide_font = NOFONT; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
405 # ifndef FEAT_GUI_GTK |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
406 gui.wide_bold_font = NOFONT; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
407 gui.wide_ital_font = NOFONT; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
408 gui.wide_boldital_font = NOFONT; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
409 # endif |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
410 #endif |
7 | 411 |
412 #ifdef FEAT_MENU | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
413 # ifndef FEAT_GUI_GTK |
7 | 414 # ifdef FONTSET_ALWAYS |
415 gui.menu_fontset = NOFONTSET; | |
416 # else | |
417 gui.menu_font = NOFONT; | |
418 # endif | |
419 # endif | |
420 gui.menu_is_active = TRUE; /* default: include menu */ | |
421 # ifndef FEAT_GUI_GTK | |
422 gui.menu_height = MENU_DEFAULT_HEIGHT; | |
423 gui.menu_width = 0; | |
424 # endif | |
425 #endif | |
426 #if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) | |
427 gui.toolbar_height = 0; | |
428 #endif | |
429 #if defined(FEAT_FOOTER) && defined(FEAT_GUI_MOTIF) | |
430 gui.footer_height = 0; | |
431 #endif | |
432 #ifdef FEAT_BEVAL_TIP | |
433 gui.tooltip_fontset = NOFONTSET; | |
434 #endif | |
435 | |
436 gui.scrollbar_width = gui.scrollbar_height = SB_DEFAULT_WIDTH; | |
437 gui.prev_wrap = -1; | |
438 | |
439 #ifdef ALWAYS_USE_GUI | |
440 result = OK; | |
441 #else | |
3518 | 442 # ifdef FEAT_GUI_GTK |
443 /* | |
444 * Note: Don't call gtk_init_check() before fork, it will be called after | |
445 * the fork. When calling it before fork, it make vim hang for a while. | |
446 * See gui_do_fork(). | |
447 * Use a simpler check if the GUI window can probably be opened. | |
448 */ | |
9836
bc591685594a
commit https://github.com/vim/vim/commit/717e196060d946fe20bb0f0307f417dc4d0e9b17
Christian Brabandt <cb@256bit.org>
parents:
9651
diff
changeset
|
449 result = gui.dofork ? gui_mch_early_init_check(TRUE) : gui_mch_init_check(); |
3518 | 450 # else |
7 | 451 result = gui_mch_init_check(); |
3518 | 452 # endif |
7 | 453 #endif |
454 return result; | |
455 } | |
456 | |
457 /* | |
458 * This is the call which starts the GUI. | |
459 */ | |
460 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
461 gui_init(void) |
7 | 462 { |
463 win_T *wp; | |
464 static int recursive = 0; | |
465 | |
466 /* | |
467 * It's possible to use ":gui" in a .gvimrc file. The first halve of this | |
468 * function will then be executed at the first call, the rest by the | |
469 * recursive call. This allow the shell to be opened halfway reading a | |
470 * gvimrc file. | |
471 */ | |
472 if (!recursive) | |
473 { | |
474 ++recursive; | |
475 | |
476 clip_init(TRUE); | |
477 | |
478 /* If can't initialize, don't try doing the rest */ | |
479 if (gui_init_check() == FAIL) | |
480 { | |
481 --recursive; | |
482 clip_init(FALSE); | |
483 return; | |
484 } | |
485 | |
486 /* | |
147 | 487 * Reset 'paste'. It's useful in the terminal, but not in the GUI. It |
488 * breaks the Paste toolbar button. | |
489 */ | |
490 set_option_value((char_u *)"paste", 0L, NULL, 0); | |
491 | |
492 /* | |
7 | 493 * Set up system-wide default menus. |
494 */ | |
495 #if defined(SYS_MENU_FILE) && defined(FEAT_MENU) | |
496 if (vim_strchr(p_go, GO_NOSYSMENU) == NULL) | |
497 { | |
498 sys_menu = TRUE; | |
819 | 499 do_source((char_u *)SYS_MENU_FILE, FALSE, DOSO_NONE); |
7 | 500 sys_menu = FALSE; |
501 } | |
502 #endif | |
503 | |
504 /* | |
505 * Switch on the mouse by default, unless the user changed it already. | |
506 * This can then be changed in the .gvimrc. | |
507 */ | |
508 if (!option_was_set((char_u *)"mouse")) | |
509 set_string_option_direct((char_u *)"mouse", -1, | |
694 | 510 (char_u *)"a", OPT_FREE, SID_NONE); |
7 | 511 |
512 /* | |
513 * If -U option given, use only the initializations from that file and | |
514 * nothing else. Skip all initializations for "-U NONE" or "-u NORC". | |
515 */ | |
516 if (use_gvimrc != NULL) | |
517 { | |
518 if (STRCMP(use_gvimrc, "NONE") != 0 | |
519 && STRCMP(use_gvimrc, "NORC") != 0 | |
819 | 520 && do_source(use_gvimrc, FALSE, DOSO_NONE) != OK) |
7 | 521 EMSG2(_("E230: Cannot read from \"%s\""), use_gvimrc); |
522 } | |
523 else | |
524 { | |
525 /* | |
526 * Get system wide defaults for gvim, only when file name defined. | |
527 */ | |
528 #ifdef SYS_GVIMRC_FILE | |
819 | 529 do_source((char_u *)SYS_GVIMRC_FILE, FALSE, DOSO_NONE); |
7 | 530 #endif |
531 | |
532 /* | |
533 * Try to read GUI initialization commands from the following | |
534 * places: | |
535 * - environment variable GVIMINIT | |
536 * - the user gvimrc file (~/.gvimrc) | |
537 * - the second user gvimrc file ($VIM/.gvimrc for Dos) | |
538 * - the third user gvimrc file ($VIM/.gvimrc for Amiga) | |
539 * The first that exists is used, the rest is ignored. | |
540 */ | |
541 if (process_env((char_u *)"GVIMINIT", FALSE) == FAIL | |
819 | 542 && do_source((char_u *)USR_GVIMRC_FILE, TRUE, |
543 DOSO_GVIMRC) == FAIL | |
7 | 544 #ifdef USR_GVIMRC_FILE2 |
819 | 545 && do_source((char_u *)USR_GVIMRC_FILE2, TRUE, |
546 DOSO_GVIMRC) == FAIL | |
7 | 547 #endif |
4863
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
548 #ifdef USR_GVIMRC_FILE3 |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
549 && do_source((char_u *)USR_GVIMRC_FILE3, TRUE, |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
550 DOSO_GVIMRC) == FAIL |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
551 #endif |
7 | 552 ) |
553 { | |
4863
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
554 #ifdef USR_GVIMRC_FILE4 |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
555 (void)do_source((char_u *)USR_GVIMRC_FILE4, TRUE, DOSO_GVIMRC); |
7 | 556 #endif |
557 } | |
558 | |
559 /* | |
560 * Read initialization commands from ".gvimrc" in current | |
561 * directory. This is only done if the 'exrc' option is set. | |
562 * Because of security reasons we disallow shell and write | |
563 * commands now, except for unix if the file is owned by the user | |
564 * or 'secure' option has been reset in environment of global | |
565 * ".gvimrc". | |
566 * Only do this if GVIMRC_FILE is not the same as USR_GVIMRC_FILE, | |
567 * USR_GVIMRC_FILE2, USR_GVIMRC_FILE3 or SYS_GVIMRC_FILE. | |
568 */ | |
569 if (p_exrc) | |
570 { | |
571 #ifdef UNIX | |
572 { | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9385
diff
changeset
|
573 stat_T s; |
7 | 574 |
575 /* if ".gvimrc" file is not owned by user, set 'secure' | |
576 * mode */ | |
577 if (mch_stat(GVIMRC_FILE, &s) || s.st_uid != getuid()) | |
578 secure = p_secure; | |
579 } | |
580 #else | |
581 secure = p_secure; | |
582 #endif | |
583 | |
584 if ( fullpathcmp((char_u *)USR_GVIMRC_FILE, | |
585 (char_u *)GVIMRC_FILE, FALSE) != FPC_SAME | |
586 #ifdef SYS_GVIMRC_FILE | |
587 && fullpathcmp((char_u *)SYS_GVIMRC_FILE, | |
588 (char_u *)GVIMRC_FILE, FALSE) != FPC_SAME | |
589 #endif | |
590 #ifdef USR_GVIMRC_FILE2 | |
591 && fullpathcmp((char_u *)USR_GVIMRC_FILE2, | |
592 (char_u *)GVIMRC_FILE, FALSE) != FPC_SAME | |
593 #endif | |
594 #ifdef USR_GVIMRC_FILE3 | |
595 && fullpathcmp((char_u *)USR_GVIMRC_FILE3, | |
596 (char_u *)GVIMRC_FILE, FALSE) != FPC_SAME | |
597 #endif | |
4863
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
598 #ifdef USR_GVIMRC_FILE4 |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
599 && fullpathcmp((char_u *)USR_GVIMRC_FILE4, |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
600 (char_u *)GVIMRC_FILE, FALSE) != FPC_SAME |
c4d4f0fc12b9
updated for version 7.3.1178
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
601 #endif |
7 | 602 ) |
819 | 603 do_source((char_u *)GVIMRC_FILE, TRUE, DOSO_GVIMRC); |
7 | 604 |
605 if (secure == 2) | |
606 need_wait_return = TRUE; | |
607 secure = 0; | |
608 } | |
609 } | |
610 | |
611 if (need_wait_return || msg_didany) | |
612 wait_return(TRUE); | |
613 | |
614 --recursive; | |
615 } | |
616 | |
617 /* If recursive call opened the shell, return here from the first call */ | |
618 if (gui.in_use) | |
619 return; | |
620 | |
621 /* | |
622 * Create the GUI shell. | |
623 */ | |
624 gui.in_use = TRUE; /* Must be set after menus have been set up */ | |
625 if (gui_mch_init() == FAIL) | |
626 goto error; | |
627 | |
628 /* Avoid a delay for an error message that was printed in the terminal | |
629 * where Vim was started. */ | |
630 emsg_on_display = FALSE; | |
631 msg_scrolled = 0; | |
11163
f4d1fad4ac00
patch 8.0.0468: after aborting an Ex command g< does not work
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
632 clear_sb_text(TRUE); |
7 | 633 need_wait_return = FALSE; |
634 msg_didany = FALSE; | |
635 | |
636 /* | |
637 * Check validity of any generic resources that may have been loaded. | |
638 */ | |
639 if (gui.border_width < 0) | |
640 gui.border_width = 0; | |
641 | |
642 /* | |
643 * Set up the fonts. First use a font specified with "-fn" or "-font". | |
644 */ | |
645 if (font_argument != NULL) | |
646 set_option_value((char_u *)"gfn", 0L, (char_u *)font_argument, 0); | |
647 if ( | |
648 #ifdef FEAT_XFONTSET | |
649 (*p_guifontset == NUL | |
650 || gui_init_font(p_guifontset, TRUE) == FAIL) && | |
651 #endif | |
652 gui_init_font(*p_guifont == NUL ? hl_get_font_name() | |
653 : p_guifont, FALSE) == FAIL) | |
654 { | |
655 EMSG(_("E665: Cannot start GUI, no valid font found")); | |
656 goto error2; | |
657 } | |
658 #ifdef FEAT_MBYTE | |
659 if (gui_get_wide_font() == FAIL) | |
660 EMSG(_("E231: 'guifontwide' invalid")); | |
661 #endif | |
662 | |
663 gui.num_cols = Columns; | |
664 gui.num_rows = Rows; | |
665 gui_reset_scroll_region(); | |
666 | |
667 /* Create initial scrollbars */ | |
668 FOR_ALL_WINDOWS(wp) | |
669 { | |
670 gui_create_scrollbar(&wp->w_scrollbars[SBAR_LEFT], SBAR_LEFT, wp); | |
671 gui_create_scrollbar(&wp->w_scrollbars[SBAR_RIGHT], SBAR_RIGHT, wp); | |
672 } | |
673 gui_create_scrollbar(&gui.bottom_sbar, SBAR_BOTTOM, NULL); | |
674 | |
675 #ifdef FEAT_MENU | |
676 gui_create_initial_menus(root_menu); | |
677 #endif | |
678 #ifdef FEAT_SUN_WORKSHOP | |
679 if (usingSunWorkShop) | |
680 workshop_init(); | |
681 #endif | |
682 #ifdef FEAT_SIGN_ICONS | |
683 sign_gui_started(); | |
684 #endif | |
685 | |
686 /* Configure the desired menu and scrollbars */ | |
687 gui_init_which_components(NULL); | |
688 | |
689 /* All components of the GUI have been created now */ | |
690 gui.shell_created = TRUE; | |
691 | |
692 #ifndef FEAT_GUI_GTK | |
693 /* Set the shell size, adjusted for the screen size. For GTK this only | |
694 * works after the shell has been opened, thus it is further down. */ | |
12802
29a728529f92
patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
695 gui_set_shellsize(TRUE, TRUE, RESIZE_BOTH); |
7 | 696 #endif |
697 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) | |
698 /* Need to set the size of the menubar after all the menus have been | |
699 * created. */ | |
700 gui_mch_compute_menu_height((Widget)0); | |
701 #endif | |
702 | |
703 /* | |
704 * Actually open the GUI shell. | |
705 */ | |
706 if (gui_mch_open() != FAIL) | |
707 { | |
708 #ifdef FEAT_TITLE | |
709 maketitle(); | |
710 resettitle(); | |
711 #endif | |
712 init_gui_options(); | |
713 #ifdef FEAT_ARABIC | |
714 /* Our GUI can't do bidi. */ | |
715 p_tbidi = FALSE; | |
716 #endif | |
574 | 717 #if defined(FEAT_GUI_GTK) |
7 | 718 /* Give GTK+ a chance to put all widget's into place. */ |
719 gui_mch_update(); | |
827 | 720 |
721 # ifdef FEAT_MENU | |
722 /* If there is no 'm' in 'guioptions' we need to remove the menu now. | |
723 * It was still there to make F10 work. */ | |
724 if (vim_strchr(p_go, GO_MENUS) == NULL) | |
725 { | |
726 --gui.starting; | |
727 gui_mch_enable_menu(FALSE); | |
728 ++gui.starting; | |
729 gui_mch_update(); | |
730 } | |
731 # endif | |
732 | |
7 | 733 /* Now make sure the shell fits on the screen. */ |
12802
29a728529f92
patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
734 gui_set_shellsize(TRUE, TRUE, RESIZE_BOTH); |
7 | 735 #endif |
261 | 736 /* When 'lines' was set while starting up the topframe may have to be |
737 * resized. */ | |
738 win_new_shellsize(); | |
187 | 739 |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
12865
diff
changeset
|
740 #ifdef FEAT_BEVAL_GUI |
187 | 741 /* Always create the Balloon Evaluation area, but disable it when |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12839
diff
changeset
|
742 * 'ballooneval' is off. */ |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12839
diff
changeset
|
743 if (balloonEval != NULL) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12839
diff
changeset
|
744 vim_free(balloonEval); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12839
diff
changeset
|
745 balloonEvalForTerm = FALSE; |
187 | 746 # ifdef FEAT_GUI_GTK |
747 balloonEval = gui_mch_create_beval_area(gui.drawarea, NULL, | |
748 &general_beval_cb, NULL); | |
749 # else | |
216 | 750 # if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) |
187 | 751 { |
752 extern Widget textArea; | |
753 balloonEval = gui_mch_create_beval_area(textArea, NULL, | |
216 | 754 &general_beval_cb, NULL); |
187 | 755 } |
756 # else | |
757 # ifdef FEAT_GUI_W32 | |
758 balloonEval = gui_mch_create_beval_area(NULL, NULL, | |
759 &general_beval_cb, NULL); | |
760 # endif | |
761 # endif | |
762 # endif | |
763 if (!p_beval) | |
764 gui_mch_disable_beval_area(balloonEval); | |
765 #endif | |
766 | |
7 | 767 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
768 if (!im_xim_isvalid_imactivate()) | |
769 EMSG(_("E599: Value of 'imactivatekey' is invalid")); | |
770 #endif | |
37 | 771 /* When 'cmdheight' was set during startup it may not have taken |
772 * effect yet. */ | |
773 if (p_ch != 1L) | |
824 | 774 command_height(); |
7 | 775 |
776 return; | |
777 } | |
778 | |
779 error2: | |
780 #ifdef FEAT_GUI_X11 | |
781 /* undo gui_mch_init() */ | |
782 gui_mch_uninit(); | |
783 #endif | |
784 | |
785 error: | |
786 gui.in_use = FALSE; | |
787 clip_init(FALSE); | |
788 } | |
789 | |
790 | |
791 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
792 gui_exit(int rc) |
7 | 793 { |
794 /* don't free the fonts, it leads to a BUS error | |
795 * richard@whitequeen.com Jul 99 */ | |
796 free_highlight_fonts(); | |
797 gui.in_use = FALSE; | |
798 gui_mch_exit(rc); | |
799 } | |
800 | |
574 | 801 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_MSWIN) \ |
7 | 802 || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC) || defined(PROTO) |
1002 | 803 # define NEED_GUI_UPDATE_SCREEN 1 |
7 | 804 /* |
805 * Called when the GUI shell is closed by the user. If there are no changed | |
806 * files Vim exits, otherwise there will be a dialog to ask the user what to | |
807 * do. | |
808 * When this function returns, Vim should NOT exit! | |
809 */ | |
810 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
811 gui_shell_closed(void) |
7 | 812 { |
813 cmdmod_T save_cmdmod; | |
814 | |
815 save_cmdmod = cmdmod; | |
816 | |
817 /* Only exit when there are no changed files */ | |
818 exiting = TRUE; | |
819 # ifdef FEAT_BROWSE | |
820 cmdmod.browse = TRUE; | |
821 # endif | |
822 # if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
823 cmdmod.confirm = TRUE; | |
824 # endif | |
825 /* If there are changed buffers, present the user with a dialog if | |
826 * possible, otherwise give an error message. */ | |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7208
diff
changeset
|
827 if (!check_changed_any(FALSE, FALSE)) |
7 | 828 getout(0); |
829 | |
830 exiting = FALSE; | |
831 cmdmod = save_cmdmod; | |
1002 | 832 gui_update_screen(); /* redraw, window may show changed buffer */ |
7 | 833 } |
834 #endif | |
835 | |
836 /* | |
4352 | 837 * Set the font. "font_list" is a comma separated list of font names. The |
7 | 838 * first font name that works is used. If none is found, use the default |
839 * font. | |
840 * If "fontset" is TRUE, the "font_list" is used as one name for the fontset. | |
841 * Return OK when able to set the font. When it failed FAIL is returned and | |
842 * the fonts are unchanged. | |
843 */ | |
844 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
845 gui_init_font(char_u *font_list, int fontset UNUSED) |
7 | 846 { |
847 #define FONTLEN 320 | |
848 char_u font_name[FONTLEN]; | |
849 int font_list_empty = FALSE; | |
850 int ret = FAIL; | |
851 | |
852 if (!gui.in_use) | |
853 return FAIL; | |
854 | |
855 font_name[0] = NUL; | |
856 if (*font_list == NUL) | |
857 font_list_empty = TRUE; | |
858 else | |
859 { | |
860 #ifdef FEAT_XFONTSET | |
861 /* When using a fontset, the whole list of fonts is one name. */ | |
862 if (fontset) | |
863 ret = gui_mch_init_font(font_list, TRUE); | |
864 else | |
865 #endif | |
866 while (*font_list != NUL) | |
867 { | |
868 /* Isolate one comma separated font name. */ | |
869 (void)copy_option_part(&font_list, font_name, FONTLEN, ","); | |
870 | |
871 /* Careful!!! The Win32 version of gui_mch_init_font(), when | |
872 * called with "*" will change p_guifont to the selected font | |
873 * name, which frees the old value. This makes font_list | |
874 * invalid. Thus when OK is returned here, font_list must no | |
875 * longer be used! */ | |
876 if (gui_mch_init_font(font_name, FALSE) == OK) | |
877 { | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
878 #if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK) |
7 | 879 /* If it's a Unicode font, try setting 'guifontwide' to a |
880 * similar double-width font. */ | |
881 if ((p_guifontwide == NULL || *p_guifontwide == NUL) | |
882 && strstr((char *)font_name, "10646") != NULL) | |
883 set_guifontwide(font_name); | |
884 #endif | |
885 ret = OK; | |
886 break; | |
887 } | |
888 } | |
889 } | |
890 | |
891 if (ret != OK | |
892 && STRCMP(font_list, "*") != 0 | |
893 && (font_list_empty || gui.norm_font == NOFONT)) | |
894 { | |
895 /* | |
896 * Couldn't load any font in 'font_list', keep the current font if | |
897 * there is one. If 'font_list' is empty, or if there is no current | |
898 * font, tell gui_mch_init_font() to try to find a font we can load. | |
899 */ | |
900 ret = gui_mch_init_font(NULL, FALSE); | |
901 } | |
902 | |
903 if (ret == OK) | |
904 { | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
905 #ifndef FEAT_GUI_GTK |
7 | 906 /* Set normal font as current font */ |
907 # ifdef FEAT_XFONTSET | |
908 if (gui.fontset != NOFONTSET) | |
909 gui_mch_set_fontset(gui.fontset); | |
910 else | |
911 # endif | |
912 gui_mch_set_font(gui.norm_font); | |
913 #endif | |
12802
29a728529f92
patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
914 gui_set_shellsize(TRUE, TRUE, RESIZE_BOTH); |
7 | 915 } |
916 | |
917 return ret; | |
918 } | |
919 | |
920 #if defined(FEAT_MBYTE) || defined(PROTO) | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
921 # ifndef FEAT_GUI_GTK |
7 | 922 /* |
923 * Try setting 'guifontwide' to a font twice as wide as "name". | |
924 */ | |
925 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
926 set_guifontwide(char_u *name) |
7 | 927 { |
928 int i = 0; | |
929 char_u wide_name[FONTLEN + 10]; /* room for 2 * width and '*' */ | |
930 char_u *wp = NULL; | |
931 char_u *p; | |
932 GuiFont font; | |
933 | |
934 wp = wide_name; | |
935 for (p = name; *p != NUL; ++p) | |
936 { | |
937 *wp++ = *p; | |
938 if (*p == '-') | |
939 { | |
940 ++i; | |
941 if (i == 6) /* font type: change "--" to "-*-" */ | |
942 { | |
943 if (p[1] == '-') | |
944 *wp++ = '*'; | |
945 } | |
946 else if (i == 12) /* found the width */ | |
947 { | |
948 ++p; | |
949 i = getdigits(&p); | |
950 if (i != 0) | |
951 { | |
952 /* Double the width specification. */ | |
953 sprintf((char *)wp, "%d%s", i * 2, p); | |
954 font = gui_mch_get_font(wide_name, FALSE); | |
955 if (font != NOFONT) | |
956 { | |
37 | 957 gui_mch_free_font(gui.wide_font); |
7 | 958 gui.wide_font = font; |
959 set_string_option_direct((char_u *)"gfw", -1, | |
694 | 960 wide_name, OPT_FREE, 0); |
7 | 961 } |
962 } | |
963 break; | |
964 } | |
965 } | |
966 } | |
967 } | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
968 # endif /* !FEAT_GUI_GTK */ |
7 | 969 |
970 /* | |
971 * Get the font for 'guifontwide'. | |
972 * Return FAIL for an invalid font name. | |
973 */ | |
974 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
975 gui_get_wide_font(void) |
7 | 976 { |
977 GuiFont font = NOFONT; | |
978 char_u font_name[FONTLEN]; | |
979 char_u *p; | |
980 | |
981 if (!gui.in_use) /* Can't allocate font yet, assume it's OK. */ | |
982 return OK; /* Will give an error message later. */ | |
983 | |
984 if (p_guifontwide != NULL && *p_guifontwide != NUL) | |
985 { | |
986 for (p = p_guifontwide; *p != NUL; ) | |
987 { | |
988 /* Isolate one comma separated font name. */ | |
989 (void)copy_option_part(&p, font_name, FONTLEN, ","); | |
990 font = gui_mch_get_font(font_name, FALSE); | |
991 if (font != NOFONT) | |
992 break; | |
993 } | |
994 if (font == NOFONT) | |
995 return FAIL; | |
996 } | |
997 | |
998 gui_mch_free_font(gui.wide_font); | |
4250 | 999 # ifdef FEAT_GUI_GTK |
7 | 1000 /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */ |
1001 if (font != NOFONT && gui.norm_font != NOFONT | |
1002 && pango_font_description_equal(font, gui.norm_font)) | |
1003 { | |
1004 gui.wide_font = NOFONT; | |
1005 gui_mch_free_font(font); | |
1006 } | |
1007 else | |
4250 | 1008 # endif |
7 | 1009 gui.wide_font = font; |
4250 | 1010 # ifdef FEAT_GUI_MSWIN |
4055 | 1011 gui_mch_wide_font_changed(); |
4950
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
1012 # else |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
1013 /* |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
1014 * TODO: setup wide_bold_font, wide_ital_font and wide_boldital_font to |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
1015 * support those fonts for 'guifontwide'. |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
1016 */ |
4250 | 1017 # endif |
7 | 1018 return OK; |
1019 } | |
1020 #endif | |
1021 | |
1022 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1023 gui_set_cursor(int row, int col) |
7 | 1024 { |
1025 gui.row = row; | |
1026 gui.col = col; | |
1027 } | |
1028 | |
1029 /* | |
1030 * gui_check_pos - check if the cursor is on the screen. | |
1031 */ | |
1032 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1033 gui_check_pos(void) |
7 | 1034 { |
1035 if (gui.row >= screen_Rows) | |
1036 gui.row = screen_Rows - 1; | |
1037 if (gui.col >= screen_Columns) | |
1038 gui.col = screen_Columns - 1; | |
1039 if (gui.cursor_row >= screen_Rows || gui.cursor_col >= screen_Columns) | |
1040 gui.cursor_is_valid = FALSE; | |
1041 } | |
1042 | |
1043 /* | |
1044 * Redraw the cursor if necessary or when forced. | |
1045 * Careful: The contents of ScreenLines[] must match what is on the screen, | |
1046 * otherwise this goes wrong. May need to call out_flush() first. | |
1047 */ | |
1048 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1049 gui_update_cursor( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1050 int force, /* when TRUE, update even when not moved */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1051 int clear_selection)/* clear selection under cursor */ |
7 | 1052 { |
1053 int cur_width = 0; | |
1054 int cur_height = 0; | |
1055 int old_hl_mask; | |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1056 cursorentry_T *shape; |
7 | 1057 int id; |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1058 #ifdef FEAT_TERMINAL |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1059 guicolor_T shape_fg = INVALCOLOR; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1060 guicolor_T shape_bg = INVALCOLOR; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1061 #endif |
7 | 1062 guicolor_T cfg, cbg, cc; /* cursor fore-/background color */ |
1063 int cattr; /* cursor attributes */ | |
1064 int attr; | |
1065 attrentry_T *aep = NULL; | |
1066 | |
1695 | 1067 /* Don't update the cursor when halfway busy scrolling or the screen size |
1068 * doesn't match 'columns' and 'lines. ScreenLines[] isn't valid then. */ | |
1069 if (!can_update_cursor || screen_Columns != gui.num_cols | |
1070 || screen_Rows != gui.num_rows) | |
7 | 1071 return; |
1072 | |
1073 gui_check_pos(); | |
1074 if (!gui.cursor_is_valid || force | |
1075 || gui.row != gui.cursor_row || gui.col != gui.cursor_col) | |
1076 { | |
1077 gui_undraw_cursor(); | |
1078 if (gui.row < 0) | |
1079 return; | |
13386
bf3de2fd98fa
patch 8.0.1567: cannot build Win32 GUI without IME
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
1080 #ifdef HAVE_INPUT_METHOD |
7 | 1081 if (gui.row != gui.cursor_row || gui.col != gui.cursor_col) |
1082 im_set_position(gui.row, gui.col); | |
1083 #endif | |
1084 gui.cursor_row = gui.row; | |
1085 gui.cursor_col = gui.col; | |
1086 | |
1087 /* Only write to the screen after ScreenLines[] has been initialized */ | |
1088 if (!screen_cleared || ScreenLines == NULL) | |
1089 return; | |
1090 | |
1091 /* Clear the selection if we are about to write over it */ | |
1092 if (clear_selection) | |
1093 clip_may_clear_selection(gui.row, gui.row); | |
1094 /* Check that the cursor is inside the shell (resizing may have made | |
1095 * it invalid) */ | |
1096 if (gui.row >= screen_Rows || gui.col >= screen_Columns) | |
1097 return; | |
1098 | |
1099 gui.cursor_is_valid = TRUE; | |
1100 | |
1101 /* | |
1102 * How the cursor is drawn depends on the current mode. | |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1103 * When in a terminal window use the shape/color specified there. |
7 | 1104 */ |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1105 #ifdef FEAT_TERMINAL |
12457
dfb8254aa735
patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12317
diff
changeset
|
1106 if (terminal_is_active()) |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1107 shape = term_get_cursor_shape(&shape_fg, &shape_bg); |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1108 else |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1109 #endif |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1110 shape = &shape_table[get_shape_idx(FALSE)]; |
7 | 1111 if (State & LANGMAP) |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1112 id = shape->id_lm; |
7 | 1113 else |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1114 id = shape->id; |
7 | 1115 |
1116 /* get the colors and attributes for the cursor. Default is inverted */ | |
1117 cfg = INVALCOLOR; | |
1118 cbg = INVALCOLOR; | |
1119 cattr = HL_INVERSE; | |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1120 gui_mch_set_blinking(shape->blinkwait, |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1121 shape->blinkon, |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1122 shape->blinkoff); |
12839
9ac41c3148ce
patch 8.0.1296: checking the same condition twice
Christian Brabandt <cb@256bit.org>
parents:
12835
diff
changeset
|
1123 if (shape->blinkwait == 0 || shape->blinkon == 0 |
9ac41c3148ce
patch 8.0.1296: checking the same condition twice
Christian Brabandt <cb@256bit.org>
parents:
12835
diff
changeset
|
1124 || shape->blinkoff == 0) |
13152
f4c3a7f410f4
patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
1125 gui_mch_stop_blink(FALSE); |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1126 #ifdef FEAT_TERMINAL |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1127 if (shape_bg != INVALCOLOR) |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1128 { |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1129 cattr = 0; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1130 cfg = shape_fg; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1131 cbg = shape_bg; |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1132 } |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1133 else |
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1134 #endif |
7 | 1135 if (id > 0) |
1136 { | |
1137 cattr = syn_id2colors(id, &cfg, &cbg); | |
13386
bf3de2fd98fa
patch 8.0.1567: cannot build Win32 GUI without IME
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
1138 #if defined(HAVE_INPUT_METHOD) || defined(FEAT_HANGULIN) |
7 | 1139 { |
1140 static int iid; | |
1141 guicolor_T fg, bg; | |
1142 | |
1668 | 1143 if ( |
13194
3efdd2ae3717
patch 8.0.1471: on MS-Windows CursorIM highlighting no longer works
Christian Brabandt <cb@256bit.org>
parents:
13176
diff
changeset
|
1144 # if defined(FEAT_GUI_GTK) && defined(FEAT_XIM) && !defined(FEAT_HANGULIN) |
1668 | 1145 preedit_get_status() |
1146 # else | |
1147 im_get_status() | |
1148 # endif | |
1149 ) | |
7 | 1150 { |
1151 iid = syn_name2id((char_u *)"CursorIM"); | |
1152 if (iid > 0) | |
1153 { | |
1154 syn_id2colors(iid, &fg, &bg); | |
1155 if (bg != INVALCOLOR) | |
1156 cbg = bg; | |
1157 if (fg != INVALCOLOR) | |
1158 cfg = fg; | |
1159 } | |
1160 } | |
1161 } | |
1162 #endif | |
1163 } | |
1164 | |
1165 /* | |
1166 * Get the attributes for the character under the cursor. | |
1167 * When no cursor color was given, use the character color. | |
1168 */ | |
1169 attr = ScreenAttrs[LineOffset[gui.row] + gui.col]; | |
1170 if (attr > HL_ALL) | |
1171 aep = syn_gui_attr2entry(attr); | |
1172 if (aep != NULL) | |
1173 { | |
1174 attr = aep->ae_attr; | |
1175 if (cfg == INVALCOLOR) | |
1176 cfg = ((attr & HL_INVERSE) ? aep->ae_u.gui.bg_color | |
1177 : aep->ae_u.gui.fg_color); | |
1178 if (cbg == INVALCOLOR) | |
1179 cbg = ((attr & HL_INVERSE) ? aep->ae_u.gui.fg_color | |
1180 : aep->ae_u.gui.bg_color); | |
1181 } | |
1182 if (cfg == INVALCOLOR) | |
1183 cfg = (attr & HL_INVERSE) ? gui.back_pixel : gui.norm_pixel; | |
1184 if (cbg == INVALCOLOR) | |
1185 cbg = (attr & HL_INVERSE) ? gui.norm_pixel : gui.back_pixel; | |
1186 | |
1187 #ifdef FEAT_XIM | |
1188 if (aep != NULL) | |
1189 { | |
1190 xim_bg_color = ((attr & HL_INVERSE) ? aep->ae_u.gui.fg_color | |
1191 : aep->ae_u.gui.bg_color); | |
1192 xim_fg_color = ((attr & HL_INVERSE) ? aep->ae_u.gui.bg_color | |
1193 : aep->ae_u.gui.fg_color); | |
1194 if (xim_bg_color == INVALCOLOR) | |
1195 xim_bg_color = (attr & HL_INVERSE) ? gui.norm_pixel | |
1196 : gui.back_pixel; | |
1197 if (xim_fg_color == INVALCOLOR) | |
1198 xim_fg_color = (attr & HL_INVERSE) ? gui.back_pixel | |
1199 : gui.norm_pixel; | |
1200 } | |
1201 else | |
1202 { | |
1203 xim_bg_color = (attr & HL_INVERSE) ? gui.norm_pixel | |
1204 : gui.back_pixel; | |
1205 xim_fg_color = (attr & HL_INVERSE) ? gui.back_pixel | |
1206 : gui.norm_pixel; | |
1207 } | |
1208 #endif | |
1209 | |
1210 attr &= ~HL_INVERSE; | |
1211 if (cattr & HL_INVERSE) | |
1212 { | |
1213 cc = cbg; | |
1214 cbg = cfg; | |
1215 cfg = cc; | |
1216 } | |
1217 cattr &= ~HL_INVERSE; | |
1218 | |
1219 /* | |
1220 * When we don't have window focus, draw a hollow cursor. | |
1221 */ | |
1222 if (!gui.in_focus) | |
1223 { | |
1224 gui_mch_draw_hollow_cursor(cbg); | |
1225 return; | |
1226 } | |
1227 | |
1228 old_hl_mask = gui.highlight_mask; | |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1229 if (shape->shape == SHAPE_BLOCK |
7 | 1230 #ifdef FEAT_HANGULIN |
1231 || composing_hangul | |
1232 #endif | |
1233 ) | |
1234 { | |
1235 /* | |
1236 * Draw the text character with the cursor colors. Use the | |
1237 * character attributes plus the cursor attributes. | |
1238 */ | |
1239 gui.highlight_mask = (cattr | attr); | |
1240 #ifdef FEAT_HANGULIN | |
1241 if (composing_hangul) | |
7208
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1242 { |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1243 char_u *comp_buf; |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1244 int comp_len; |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1245 |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1246 comp_buf = hangul_composing_buffer_get(&comp_len); |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1247 if (comp_buf) |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1248 { |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1249 (void)gui_outstr_nowrap(comp_buf, comp_len, |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1250 GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR, |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1251 cfg, cbg, 0); |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1252 vim_free(comp_buf); |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1253 } |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
1254 } |
7 | 1255 else |
1256 #endif | |
1257 (void)gui_screenchar(LineOffset[gui.row] + gui.col, | |
1258 GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR, cfg, cbg, 0); | |
1259 } | |
1260 else | |
1261 { | |
1262 #if defined(FEAT_MBYTE) && defined(FEAT_RIGHTLEFT) | |
1263 int col_off = FALSE; | |
1264 #endif | |
1265 /* | |
1266 * First draw the partial cursor, then overwrite with the text | |
1267 * character, using a transparent background. | |
1268 */ | |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1269 if (shape->shape == SHAPE_VER) |
7 | 1270 { |
1271 cur_height = gui.char_height; | |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1272 cur_width = (gui.char_width * shape->percentage + 99) / 100; |
7 | 1273 } |
1274 else | |
1275 { | |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1276 cur_height = (gui.char_height * shape->percentage + 99) / 100; |
7 | 1277 cur_width = gui.char_width; |
1278 } | |
1279 #ifdef FEAT_MBYTE | |
1378 | 1280 if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col, |
1281 LineOffset[gui.row] + screen_Columns) > 1) | |
7 | 1282 { |
1283 /* Double wide character. */ | |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1284 if (shape->shape != SHAPE_VER) |
7 | 1285 cur_width += gui.char_width; |
1286 # ifdef FEAT_RIGHTLEFT | |
1287 if (CURSOR_BAR_RIGHT) | |
1288 { | |
1289 /* gui.col points to the left halve of the character but | |
1290 * the vertical line needs to be on the right halve. | |
1291 * A double-wide horizontal line is also drawn from the | |
1292 * right halve in gui_mch_draw_part_cursor(). */ | |
1293 col_off = TRUE; | |
1294 ++gui.col; | |
1295 } | |
1296 # endif | |
1297 } | |
1298 #endif | |
1299 gui_mch_draw_part_cursor(cur_width, cur_height, cbg); | |
1300 #if defined(FEAT_MBYTE) && defined(FEAT_RIGHTLEFT) | |
1301 if (col_off) | |
1302 --gui.col; | |
1303 #endif | |
1304 | |
1305 #ifndef FEAT_GUI_MSWIN /* doesn't seem to work for MSWindows */ | |
1306 gui.highlight_mask = ScreenAttrs[LineOffset[gui.row] + gui.col]; | |
1307 (void)gui_screenchar(LineOffset[gui.row] + gui.col, | |
1308 GUI_MON_TRS_CURSOR | GUI_MON_NOCLEAR, | |
1309 (guicolor_T)0, (guicolor_T)0, 0); | |
1310 #endif | |
1311 } | |
1312 gui.highlight_mask = old_hl_mask; | |
1313 } | |
1314 } | |
1315 | |
1316 #if defined(FEAT_MENU) || defined(PROTO) | |
1317 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1318 gui_position_menu(void) |
7 | 1319 { |
574 | 1320 # if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) |
7 | 1321 if (gui.menu_is_active && gui.in_use) |
1322 gui_mch_set_menu_pos(0, 0, gui.menu_width, gui.menu_height); | |
1323 # endif | |
1324 } | |
1325 #endif | |
1326 | |
1327 /* | |
1328 * Position the various GUI components (text area, menu). The vertical | |
1329 * scrollbars are NOT handled here. See gui_update_scrollbars(). | |
1330 */ | |
1331 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1332 gui_position_components(int total_width UNUSED) |
7 | 1333 { |
1334 int text_area_x; | |
1335 int text_area_y; | |
1336 int text_area_width; | |
1337 int text_area_height; | |
1338 | |
1339 /* avoid that moving components around generates events */ | |
1340 ++hold_gui_events; | |
1341 | |
1342 text_area_x = 0; | |
1343 if (gui.which_scrollbars[SBAR_LEFT]) | |
1344 text_area_x += gui.scrollbar_width; | |
1345 | |
1346 text_area_y = 0; | |
1347 #if defined(FEAT_MENU) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON)) | |
1348 gui.menu_width = total_width; | |
1349 if (gui.menu_is_active) | |
1350 text_area_y += gui.menu_height; | |
1351 #endif | |
1352 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_MSWIN) | |
1353 if (vim_strchr(p_go, GO_TOOLBAR) != NULL) | |
1354 text_area_y = TOOLBAR_BUTTON_HEIGHT + TOOLBAR_BORDER_HEIGHT; | |
1355 #endif | |
1356 | |
819 | 1357 # if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \ |
1378 | 1358 || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC)) |
810 | 1359 if (gui_has_tabline()) |
843 | 1360 text_area_y += gui.tabline_height; |
810 | 1361 #endif |
1362 | |
7 | 1363 #if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) |
1364 if (vim_strchr(p_go, GO_TOOLBAR) != NULL) | |
1365 { | |
1366 # ifdef FEAT_GUI_ATHENA | |
1367 gui_mch_set_toolbar_pos(0, text_area_y, | |
1368 gui.menu_width, gui.toolbar_height); | |
1369 # endif | |
1370 text_area_y += gui.toolbar_height; | |
1371 } | |
1372 #endif | |
1373 | |
1374 text_area_width = gui.num_cols * gui.char_width + gui.border_offset * 2; | |
1375 text_area_height = gui.num_rows * gui.char_height + gui.border_offset * 2; | |
1376 | |
1377 gui_mch_set_text_area_pos(text_area_x, | |
1378 text_area_y, | |
1379 text_area_width, | |
1380 text_area_height | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1381 #if defined(FEAT_XIM) && !defined(FEAT_GUI_GTK) |
7 | 1382 + xim_get_status_area_height() |
1383 #endif | |
1384 ); | |
1385 #ifdef FEAT_MENU | |
1386 gui_position_menu(); | |
1387 #endif | |
1388 if (gui.which_scrollbars[SBAR_BOTTOM]) | |
1389 gui_mch_set_scrollbar_pos(&gui.bottom_sbar, | |
1390 text_area_x, | |
1391 text_area_y + text_area_height, | |
1392 text_area_width, | |
1393 gui.scrollbar_height); | |
1394 gui.left_sbar_x = 0; | |
1395 gui.right_sbar_x = text_area_x + text_area_width; | |
1396 | |
1397 --hold_gui_events; | |
1398 } | |
1399 | |
444 | 1400 /* |
1401 * Get the width of the widgets and decorations to the side of the text area. | |
1402 */ | |
7 | 1403 int |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1404 gui_get_base_width(void) |
7 | 1405 { |
1406 int base_width; | |
1407 | |
1408 base_width = 2 * gui.border_offset; | |
1409 if (gui.which_scrollbars[SBAR_LEFT]) | |
1410 base_width += gui.scrollbar_width; | |
1411 if (gui.which_scrollbars[SBAR_RIGHT]) | |
1412 base_width += gui.scrollbar_width; | |
1413 return base_width; | |
1414 } | |
1415 | |
444 | 1416 /* |
1417 * Get the height of the widgets and decorations above and below the text area. | |
1418 */ | |
7 | 1419 int |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1420 gui_get_base_height(void) |
7 | 1421 { |
1422 int base_height; | |
1423 | |
1424 base_height = 2 * gui.border_offset; | |
1425 if (gui.which_scrollbars[SBAR_BOTTOM]) | |
1426 base_height += gui.scrollbar_height; | |
1427 #ifdef FEAT_GUI_GTK | |
1428 /* We can't take the sizes properly into account until anything is | |
1429 * realized. Therefore we recalculate all the values here just before | |
1430 * setting the size. (--mdcki) */ | |
1431 #else | |
1432 # ifdef FEAT_MENU | |
1433 if (gui.menu_is_active) | |
1434 base_height += gui.menu_height; | |
1435 # endif | |
1436 # ifdef FEAT_TOOLBAR | |
1437 if (vim_strchr(p_go, GO_TOOLBAR) != NULL) | |
1438 # if defined(FEAT_GUI_MSWIN) && defined(FEAT_TOOLBAR) | |
1439 base_height += (TOOLBAR_BUTTON_HEIGHT + TOOLBAR_BORDER_HEIGHT); | |
1440 # else | |
1441 base_height += gui.toolbar_height; | |
1442 # endif | |
1443 # endif | |
819 | 1444 # if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \ |
1445 || defined(FEAT_GUI_MOTIF)) | |
810 | 1446 if (gui_has_tabline()) |
843 | 1447 base_height += gui.tabline_height; |
810 | 1448 # endif |
7 | 1449 # ifdef FEAT_FOOTER |
1450 if (vim_strchr(p_go, GO_FOOTER) != NULL) | |
1451 base_height += gui.footer_height; | |
1452 # endif | |
1453 # if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) | |
1454 base_height += gui_mch_text_area_extra_height(); | |
1455 # endif | |
1456 #endif | |
1457 return base_height; | |
1458 } | |
1459 | |
1460 /* | |
1461 * Should be called after the GUI shell has been resized. Its arguments are | |
1462 * the new width and height of the shell in pixels. | |
1463 */ | |
1464 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1465 gui_resize_shell(int pixel_width, int pixel_height) |
7 | 1466 { |
1467 static int busy = FALSE; | |
1468 | |
1469 if (!gui.shell_created) /* ignore when still initializing */ | |
1470 return; | |
1471 | |
1472 /* | |
1473 * Can't resize the screen while it is being redrawn. Remember the new | |
1474 * size and handle it later. | |
1475 */ | |
1476 if (updating_screen || busy) | |
1477 { | |
1478 new_pixel_width = pixel_width; | |
1479 new_pixel_height = pixel_height; | |
1480 return; | |
1481 } | |
1482 | |
1483 again: | |
10819
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1484 new_pixel_width = 0; |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1485 new_pixel_height = 0; |
7 | 1486 busy = TRUE; |
1487 | |
1488 /* Flush pending output before redrawing */ | |
1489 out_flush(); | |
1490 | |
1491 gui.num_cols = (pixel_width - gui_get_base_width()) / gui.char_width; | |
1529 | 1492 gui.num_rows = (pixel_height - gui_get_base_height()) / gui.char_height; |
7 | 1493 |
1494 gui_position_components(pixel_width); | |
1495 gui_reset_scroll_region(); | |
10819
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1496 |
7 | 1497 /* |
1498 * At the "more" and ":confirm" prompt there is no redraw, put the cursor | |
1499 * at the last line here (why does it have to be one row too low?). | |
1500 */ | |
1501 if (State == ASKMORE || State == CONFIRM) | |
1502 gui.row = gui.num_rows; | |
1503 | |
1504 /* Only comparing Rows and Columns may be sufficient, but let's stay on | |
1505 * the safe side. */ | |
1506 if (gui.num_rows != screen_Rows || gui.num_cols != screen_Columns | |
1507 || gui.num_rows != Rows || gui.num_cols != Columns) | |
1508 shell_resized(); | |
1509 | |
1510 gui_update_scrollbars(TRUE); | |
1511 gui_update_cursor(FALSE, TRUE); | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1512 #if defined(FEAT_XIM) && !defined(FEAT_GUI_GTK) |
7 | 1513 xim_set_status_area(); |
1514 #endif | |
1515 | |
1516 busy = FALSE; | |
669 | 1517 |
10819
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1518 /* We may have been called again while redrawing the screen. |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1519 * Need to do it all again with the latest size then. But only if the size |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1520 * actually changed. */ |
7 | 1521 if (new_pixel_height) |
1522 { | |
10819
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1523 if (pixel_width == new_pixel_width && pixel_height == new_pixel_height) |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1524 { |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1525 new_pixel_width = 0; |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1526 new_pixel_height = 0; |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1527 } |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1528 else |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1529 { |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1530 pixel_width = new_pixel_width; |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1531 pixel_height = new_pixel_height; |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1532 goto again; |
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1533 } |
7 | 1534 } |
1535 } | |
1536 | |
1537 /* | |
1538 * Check if gui_resize_shell() must be called. | |
1539 */ | |
1540 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1541 gui_may_resize_shell(void) |
7 | 1542 { |
1543 if (new_pixel_height) | |
1544 /* careful: gui_resize_shell() may postpone the resize again if we | |
1545 * were called indirectly by it */ | |
10819
cd179d7d0b5d
patch 8.0.0299: a window resize is sometimes not taking effect
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1546 gui_resize_shell(new_pixel_width, new_pixel_height); |
7 | 1547 } |
1548 | |
1549 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1550 gui_get_shellsize(void) |
7 | 1551 { |
1552 Rows = gui.num_rows; | |
1553 Columns = gui.num_cols; | |
1554 return OK; | |
1555 } | |
1556 | |
1557 /* | |
1558 * Set the size of the Vim shell according to Rows and Columns. | |
444 | 1559 * If "fit_to_display" is TRUE then the size may be reduced to fit the window |
1560 * on the screen. | |
12802
29a728529f92
patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1561 * When "mustset" is TRUE the size was set by the user. When FALSE a UI |
29a728529f92
patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1562 * component was added or removed (e.g., a scrollbar). |
7 | 1563 */ |
1564 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1565 gui_set_shellsize( |
12802
29a728529f92
patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1566 int mustset UNUSED, |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1567 int fit_to_display, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1568 int direction) /* RESIZE_HOR, RESIZE_VER */ |
7 | 1569 { |
1570 int base_width; | |
1571 int base_height; | |
1572 int width; | |
1573 int height; | |
1574 int min_width; | |
1575 int min_height; | |
1576 int screen_w; | |
1577 int screen_h; | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1578 #ifdef FEAT_GUI_GTK |
1967 | 1579 int un_maximize = mustset; |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2282
diff
changeset
|
1580 int did_adjust = 0; |
1967 | 1581 #endif |
2065
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1582 int x = -1, y = -1; |
7 | 1583 |
1584 if (!gui.shell_created) | |
1585 return; | |
1586 | |
3014 | 1587 #if defined(MSWIN) || defined(FEAT_GUI_GTK) |
7 | 1588 /* If not setting to a user specified size and maximized, calculate the |
1589 * number of characters that fit in the maximized window. */ | |
12802
29a728529f92
patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1590 if (!mustset && (vim_strchr(p_go, GO_KEEPWINSIZE) != NULL |
29a728529f92
patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
1591 || gui_mch_maximized())) |
7 | 1592 { |
1593 gui_mch_newfont(); | |
1594 return; | |
1595 } | |
1596 #endif | |
1597 | |
1598 base_width = gui_get_base_width(); | |
1599 base_height = gui_get_base_height(); | |
2065
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1600 if (fit_to_display) |
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1601 /* Remember the original window position. */ |
7009 | 1602 (void)gui_mch_get_winpos(&x, &y); |
2065
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1603 |
7 | 1604 #ifdef USE_SUN_WORKSHOP |
1605 if (!mustset && usingSunWorkShop | |
1606 && workshop_get_width_height(&width, &height)) | |
1607 { | |
1608 Columns = (width - base_width + gui.char_width - 1) / gui.char_width; | |
1609 Rows = (height - base_height + gui.char_height - 1) / gui.char_height; | |
1610 } | |
1611 else | |
1612 #endif | |
1613 { | |
1614 width = Columns * gui.char_width + base_width; | |
1615 height = Rows * gui.char_height + base_height; | |
1616 } | |
1617 | |
1618 if (fit_to_display) | |
1619 { | |
1620 gui_mch_get_screen_dimensions(&screen_w, &screen_h); | |
811 | 1621 if ((direction & RESIZE_HOR) && width > screen_w) |
7 | 1622 { |
1623 Columns = (screen_w - base_width) / gui.char_width; | |
1624 if (Columns < MIN_COLUMNS) | |
1625 Columns = MIN_COLUMNS; | |
1626 width = Columns * gui.char_width + base_width; | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1627 #ifdef FEAT_GUI_GTK |
1967 | 1628 ++did_adjust; |
1629 #endif | |
7 | 1630 } |
811 | 1631 if ((direction & RESIZE_VERT) && height > screen_h) |
7 | 1632 { |
1633 Rows = (screen_h - base_height) / gui.char_height; | |
1634 check_shellsize(); | |
1635 height = Rows * gui.char_height + base_height; | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1636 #ifdef FEAT_GUI_GTK |
1967 | 1637 ++did_adjust; |
1638 #endif | |
7 | 1639 } |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1640 #ifdef FEAT_GUI_GTK |
1967 | 1641 if (did_adjust == 2 || (width + gui.char_width >= screen_w |
1642 && height + gui.char_height >= screen_h)) | |
1643 /* don't unmaximize if at maximum size */ | |
1644 un_maximize = FALSE; | |
1645 #endif | |
7 | 1646 } |
5070
cf52d2a8c05c
updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents:
5045
diff
changeset
|
1647 limit_screen_size(); |
7 | 1648 gui.num_cols = Columns; |
1649 gui.num_rows = Rows; | |
1650 | |
1651 min_width = base_width + MIN_COLUMNS * gui.char_width; | |
1652 min_height = base_height + MIN_LINES * gui.char_height; | |
685 | 1653 min_height += tabline_height() * gui.char_height; |
1967 | 1654 |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
1655 #ifdef FEAT_GUI_GTK |
1967 | 1656 if (un_maximize) |
1657 { | |
1658 /* If the window size is smaller than the screen unmaximize the | |
1659 * window, otherwise resizing won't work. */ | |
1660 gui_mch_get_screen_dimensions(&screen_w, &screen_h); | |
1661 if ((width + gui.char_width < screen_w | |
1662 || height + gui.char_height * 2 < screen_h) | |
1663 && gui_mch_maximized()) | |
1664 gui_mch_unmaximize(); | |
1665 } | |
1666 #endif | |
7 | 1667 |
1668 gui_mch_set_shellsize(width, height, min_width, min_height, | |
811 | 1669 base_width, base_height, direction); |
2065
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1670 |
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1671 if (fit_to_display && x >= 0 && y >= 0) |
7 | 1672 { |
2065
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1673 /* Some window managers put the Vim window left of/above the screen. |
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1674 * Only change the position if it wasn't already negative before |
9b78bb3794ba
updated for version 7.2.350
Bram Moolenaar <bram@zimbu.org>
parents:
1967
diff
changeset
|
1675 * (happens on MS-Windows with a secondary monitor). */ |
7 | 1676 gui_mch_update(); |
1677 if (gui_mch_get_winpos(&x, &y) == OK && (x < 0 || y < 0)) | |
1678 gui_mch_set_winpos(x < 0 ? 0 : x, y < 0 ? 0 : y); | |
1679 } | |
1680 | |
1681 gui_position_components(width); | |
1682 gui_update_scrollbars(TRUE); | |
1683 gui_reset_scroll_region(); | |
1684 } | |
1685 | |
1686 /* | |
1687 * Called when Rows and/or Columns has changed. | |
1688 */ | |
1689 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1690 gui_new_shellsize(void) |
7 | 1691 { |
1692 gui_reset_scroll_region(); | |
1693 } | |
1694 | |
1695 /* | |
1696 * Make scroll region cover whole screen. | |
1697 */ | |
1698 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1699 gui_reset_scroll_region(void) |
7 | 1700 { |
1701 gui.scroll_region_top = 0; | |
1702 gui.scroll_region_bot = gui.num_rows - 1; | |
1703 gui.scroll_region_left = 0; | |
1704 gui.scroll_region_right = gui.num_cols - 1; | |
1705 } | |
1706 | |
1707 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1708 gui_start_highlight(int mask) |
7 | 1709 { |
1710 if (mask > HL_ALL) /* highlight code */ | |
1711 gui.highlight_mask = mask; | |
1712 else /* mask */ | |
1713 gui.highlight_mask |= mask; | |
1714 } | |
1715 | |
1716 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1717 gui_stop_highlight(int mask) |
7 | 1718 { |
1719 if (mask > HL_ALL) /* highlight code */ | |
1720 gui.highlight_mask = HL_NORMAL; | |
1721 else /* mask */ | |
1722 gui.highlight_mask &= ~mask; | |
1723 } | |
1724 | |
1725 /* | |
1726 * Clear a rectangular region of the screen from text pos (row1, col1) to | |
1727 * (row2, col2) inclusive. | |
1728 */ | |
1729 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1730 gui_clear_block( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1731 int row1, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1732 int col1, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1733 int row2, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1734 int col2) |
7 | 1735 { |
1736 /* Clear the selection if we are about to write over it */ | |
1737 clip_may_clear_selection(row1, row2); | |
1738 | |
1739 gui_mch_clear_block(row1, col1, row2, col2); | |
1740 | |
1741 /* Invalidate cursor if it was in this block */ | |
1742 if ( gui.cursor_row >= row1 && gui.cursor_row <= row2 | |
1743 && gui.cursor_col >= col1 && gui.cursor_col <= col2) | |
1744 gui.cursor_is_valid = FALSE; | |
1745 } | |
1746 | |
1747 /* | |
1748 * Write code to update the cursor later. This avoids the need to flush the | |
1749 * output buffer before calling gui_update_cursor(). | |
1750 */ | |
1751 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1752 gui_update_cursor_later(void) |
7 | 1753 { |
12082
504df4aa84c6
patch 8.0.0921: terminal window cursor shape not supported in the GUI
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1754 OUT_STR(IF_EB("\033|s", ESC_STR "|s")); |
7 | 1755 } |
1756 | |
1757 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1758 gui_write( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1759 char_u *s, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1760 int len) |
7 | 1761 { |
1762 char_u *p; | |
1763 int arg1 = 0, arg2 = 0; | |
1764 int force_cursor = FALSE; /* force cursor update */ | |
1765 int force_scrollbar = FALSE; | |
1766 static win_T *old_curwin = NULL; | |
1767 | |
1768 /* #define DEBUG_GUI_WRITE */ | |
1769 #ifdef DEBUG_GUI_WRITE | |
1770 { | |
1771 int i; | |
1772 char_u *str; | |
1773 | |
1774 printf("gui_write(%d):\n ", len); | |
1775 for (i = 0; i < len; i++) | |
1776 if (s[i] == ESC) | |
1777 { | |
1778 if (i != 0) | |
1779 printf("\n "); | |
1780 printf("<ESC>"); | |
1781 } | |
1782 else | |
1783 { | |
1784 str = transchar_byte(s[i]); | |
1785 if (str[0] && str[1]) | |
1786 printf("<%s>", (char *)str); | |
1787 else | |
1788 printf("%s", (char *)str); | |
1789 } | |
1790 printf("\n"); | |
1791 } | |
1792 #endif | |
1793 while (len) | |
1794 { | |
1795 if (s[0] == ESC && s[1] == '|') | |
1796 { | |
1797 p = s + 2; | |
9385
60db35a20823
commit https://github.com/vim/vim/commit/4a6c670b844a3ef9aec865a8216eaf363bab8721
Christian Brabandt <cb@256bit.org>
parents:
9305
diff
changeset
|
1798 if (VIM_ISDIGIT(*p) || (*p == '-' && VIM_ISDIGIT(*(p + 1)))) |
7 | 1799 { |
1800 arg1 = getdigits(&p); | |
1801 if (p > s + len) | |
1802 break; | |
1803 if (*p == ';') | |
1804 { | |
1805 ++p; | |
1806 arg2 = getdigits(&p); | |
1807 if (p > s + len) | |
1808 break; | |
1809 } | |
1810 } | |
1811 switch (*p) | |
1812 { | |
1813 case 'C': /* Clear screen */ | |
1814 clip_scroll_selection(9999); | |
1815 gui_mch_clear_all(); | |
1816 gui.cursor_is_valid = FALSE; | |
1817 force_scrollbar = TRUE; | |
1818 break; | |
1819 case 'M': /* Move cursor */ | |
1820 gui_set_cursor(arg1, arg2); | |
1821 break; | |
1822 case 's': /* force cursor (shape) update */ | |
1823 force_cursor = TRUE; | |
1824 break; | |
1825 case 'R': /* Set scroll region */ | |
1826 if (arg1 < arg2) | |
1827 { | |
1828 gui.scroll_region_top = arg1; | |
1829 gui.scroll_region_bot = arg2; | |
1830 } | |
1831 else | |
1832 { | |
1833 gui.scroll_region_top = arg2; | |
1834 gui.scroll_region_bot = arg1; | |
1835 } | |
1836 break; | |
1837 case 'V': /* Set vertical scroll region */ | |
1838 if (arg1 < arg2) | |
1839 { | |
1840 gui.scroll_region_left = arg1; | |
1841 gui.scroll_region_right = arg2; | |
1842 } | |
1843 else | |
1844 { | |
1845 gui.scroll_region_left = arg2; | |
1846 gui.scroll_region_right = arg1; | |
1847 } | |
1848 break; | |
1849 case 'd': /* Delete line */ | |
1850 gui_delete_lines(gui.row, 1); | |
1851 break; | |
1852 case 'D': /* Delete lines */ | |
1853 gui_delete_lines(gui.row, arg1); | |
1854 break; | |
1855 case 'i': /* Insert line */ | |
1856 gui_insert_lines(gui.row, 1); | |
1857 break; | |
1858 case 'I': /* Insert lines */ | |
1859 gui_insert_lines(gui.row, arg1); | |
1860 break; | |
1861 case '$': /* Clear to end-of-line */ | |
1862 gui_clear_block(gui.row, gui.col, gui.row, | |
1863 (int)Columns - 1); | |
1864 break; | |
1865 case 'h': /* Turn on highlighting */ | |
1866 gui_start_highlight(arg1); | |
1867 break; | |
1868 case 'H': /* Turn off highlighting */ | |
1869 gui_stop_highlight(arg1); | |
1870 break; | |
1871 case 'f': /* flash the window (visual bell) */ | |
1872 gui_mch_flash(arg1 == 0 ? 20 : arg1); | |
1873 break; | |
1874 default: | |
1875 p = s + 1; /* Skip the ESC */ | |
1876 break; | |
1877 } | |
1878 len -= (int)(++p - s); | |
1879 s = p; | |
1880 } | |
1881 else if ( | |
1882 #ifdef EBCDIC | |
1883 CtrlChar(s[0]) != 0 /* Ctrl character */ | |
1884 #else | |
1885 s[0] < 0x20 /* Ctrl character */ | |
1886 #endif | |
1887 #ifdef FEAT_SIGN_ICONS | |
1888 && s[0] != SIGN_BYTE | |
1889 # ifdef FEAT_NETBEANS_INTG | |
1890 && s[0] != MULTISIGN_BYTE | |
1891 # endif | |
1892 #endif | |
1893 ) | |
1894 { | |
1895 if (s[0] == '\n') /* NL */ | |
1896 { | |
1897 gui.col = 0; | |
1898 if (gui.row < gui.scroll_region_bot) | |
1899 gui.row++; | |
1900 else | |
1901 gui_delete_lines(gui.scroll_region_top, 1); | |
1902 } | |
1903 else if (s[0] == '\r') /* CR */ | |
1904 { | |
1905 gui.col = 0; | |
1906 } | |
1907 else if (s[0] == '\b') /* Backspace */ | |
1908 { | |
1909 if (gui.col) | |
1910 --gui.col; | |
1911 } | |
1912 else if (s[0] == Ctrl_L) /* cursor-right */ | |
1913 { | |
1914 ++gui.col; | |
1915 } | |
1916 else if (s[0] == Ctrl_G) /* Beep */ | |
1917 { | |
1918 gui_mch_beep(); | |
1919 } | |
1920 /* Other Ctrl character: shouldn't happen! */ | |
1921 | |
1922 --len; /* Skip this char */ | |
1923 ++s; | |
1924 } | |
1925 else | |
1926 { | |
1927 p = s; | |
1928 while (len > 0 && ( | |
1929 #ifdef EBCDIC | |
1930 CtrlChar(*p) == 0 | |
1931 #else | |
1932 *p >= 0x20 | |
1933 #endif | |
1934 #ifdef FEAT_SIGN_ICONS | |
1935 || *p == SIGN_BYTE | |
1936 # ifdef FEAT_NETBEANS_INTG | |
1937 || *p == MULTISIGN_BYTE | |
1938 # endif | |
1939 #endif | |
1940 )) | |
1941 { | |
1942 len--; | |
1943 p++; | |
1944 } | |
1945 gui_outstr(s, (int)(p - s)); | |
1946 s = p; | |
1947 } | |
1948 } | |
1949 | |
1950 /* Postponed update of the cursor (won't work if "can_update_cursor" isn't | |
1951 * set). */ | |
1952 if (force_cursor) | |
1953 gui_update_cursor(TRUE, TRUE); | |
1954 | |
1955 /* When switching to another window the dragging must have stopped. | |
1956 * Required for GTK, dragged_sb isn't reset. */ | |
1957 if (old_curwin != curwin) | |
1958 gui.dragged_sb = SBAR_NONE; | |
1959 | |
1960 /* Update the scrollbars after clearing the screen or when switched | |
1961 * to another window. | |
1962 * Update the horizontal scrollbar always, it's difficult to check all | |
1963 * situations where it might change. */ | |
1964 if (force_scrollbar || old_curwin != curwin) | |
1965 gui_update_scrollbars(force_scrollbar); | |
1966 else | |
1967 gui_update_horiz_scrollbar(FALSE); | |
1968 old_curwin = curwin; | |
1969 | |
1970 /* | |
1971 * We need to make sure this is cleared since Athena doesn't tell us when | |
1972 * he is done dragging. Do the same for GTK. | |
1973 */ | |
574 | 1974 #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) |
7 | 1975 gui.dragged_sb = SBAR_NONE; |
1976 #endif | |
1977 | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
1978 gui_may_flush(); /* In case vim decides to take a nap */ |
7 | 1979 } |
1980 | |
1981 /* | |
1982 * When ScreenLines[] is invalid, updating the cursor should not be done, it | |
1983 * produces wrong results. Call gui_dont_update_cursor() before that code and | |
1984 * gui_can_update_cursor() afterwards. | |
1985 */ | |
1986 void | |
9848
664276833670
commit https://github.com/vim/vim/commit/107abd2ca53c31fd3bb40d77ff296e98eaae2975
Christian Brabandt <cb@256bit.org>
parents:
9836
diff
changeset
|
1987 gui_dont_update_cursor(int undraw) |
7 | 1988 { |
1989 if (gui.in_use) | |
1990 { | |
1991 /* Undraw the cursor now, we probably can't do it after the change. */ | |
9848
664276833670
commit https://github.com/vim/vim/commit/107abd2ca53c31fd3bb40d77ff296e98eaae2975
Christian Brabandt <cb@256bit.org>
parents:
9836
diff
changeset
|
1992 if (undraw) |
664276833670
commit https://github.com/vim/vim/commit/107abd2ca53c31fd3bb40d77ff296e98eaae2975
Christian Brabandt <cb@256bit.org>
parents:
9836
diff
changeset
|
1993 gui_undraw_cursor(); |
7 | 1994 can_update_cursor = FALSE; |
1995 } | |
1996 } | |
1997 | |
1998 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1999 gui_can_update_cursor(void) |
7 | 2000 { |
2001 can_update_cursor = TRUE; | |
2002 /* No need to update the cursor right now, there is always more output | |
2003 * after scrolling. */ | |
2004 } | |
2005 | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2006 /* |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2007 * Disable issuing gui_mch_flush(). |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2008 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2009 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2010 gui_disable_flush(void) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2011 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2012 ++disable_flush; |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2013 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2014 |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2015 /* |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2016 * Enable issuing gui_mch_flush(). |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2017 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2018 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2019 gui_enable_flush(void) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2020 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2021 --disable_flush; |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2022 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2023 |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2024 /* |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2025 * Issue gui_mch_flush() if it is not disabled. |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2026 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2027 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2028 gui_may_flush(void) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2029 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2030 if (disable_flush == 0) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2031 gui_mch_flush(); |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2032 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2033 |
7 | 2034 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2035 gui_outstr(char_u *s, int len) |
7 | 2036 { |
2037 int this_len; | |
2038 #ifdef FEAT_MBYTE | |
2039 int cells; | |
2040 #endif | |
2041 | |
2042 if (len == 0) | |
2043 return; | |
2044 | |
2045 if (len < 0) | |
2046 len = (int)STRLEN(s); | |
2047 | |
2048 while (len > 0) | |
2049 { | |
2050 #ifdef FEAT_MBYTE | |
2051 if (has_mbyte) | |
2052 { | |
2053 /* Find out how many chars fit in the current line. */ | |
2054 cells = 0; | |
2055 for (this_len = 0; this_len < len; ) | |
2056 { | |
2057 cells += (*mb_ptr2cells)(s + this_len); | |
2058 if (gui.col + cells > Columns) | |
2059 break; | |
474 | 2060 this_len += (*mb_ptr2len)(s + this_len); |
7 | 2061 } |
2062 if (this_len > len) | |
2063 this_len = len; /* don't include following composing char */ | |
2064 } | |
2065 else | |
2066 #endif | |
2067 if (gui.col + len > Columns) | |
2068 this_len = Columns - gui.col; | |
2069 else | |
2070 this_len = len; | |
2071 | |
2072 (void)gui_outstr_nowrap(s, this_len, | |
2073 0, (guicolor_T)0, (guicolor_T)0, 0); | |
2074 s += this_len; | |
2075 len -= this_len; | |
2076 #ifdef FEAT_MBYTE | |
2077 /* fill up for a double-width char that doesn't fit. */ | |
2078 if (len > 0 && gui.col < Columns) | |
2079 (void)gui_outstr_nowrap((char_u *)" ", 1, | |
2080 0, (guicolor_T)0, (guicolor_T)0, 0); | |
2081 #endif | |
2082 /* The cursor may wrap to the next line. */ | |
2083 if (gui.col >= Columns) | |
2084 { | |
2085 gui.col = 0; | |
2086 gui.row++; | |
2087 } | |
2088 } | |
2089 } | |
2090 | |
2091 /* | |
2092 * Output one character (may be one or two display cells). | |
2093 * Caller must check for valid "off". | |
2094 * Returns FAIL or OK, just like gui_outstr_nowrap(). | |
2095 */ | |
2096 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2097 gui_screenchar( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2098 int off, /* Offset from start of screen */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2099 int flags, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2100 guicolor_T fg, /* colors for cursor */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2101 guicolor_T bg, /* colors for cursor */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2102 int back) /* backup this many chars when using bold trick */ |
7 | 2103 { |
2104 #ifdef FEAT_MBYTE | |
2105 char_u buf[MB_MAXBYTES + 1]; | |
2106 | |
2107 /* Don't draw right halve of a double-width UTF-8 char. "cannot happen" */ | |
2108 if (enc_utf8 && ScreenLines[off] == 0) | |
2109 return OK; | |
2110 | |
2111 if (enc_utf8 && ScreenLinesUC[off] != 0) | |
2112 /* Draw UTF-8 multi-byte character. */ | |
2113 return gui_outstr_nowrap(buf, utfc_char2bytes(off, buf), | |
2114 flags, fg, bg, back); | |
2115 | |
2116 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) | |
2117 { | |
2118 buf[0] = ScreenLines[off]; | |
2119 buf[1] = ScreenLines2[off]; | |
2120 return gui_outstr_nowrap(buf, 2, flags, fg, bg, back); | |
2121 } | |
2122 | |
2123 /* Draw non-multi-byte character or DBCS character. */ | |
2124 return gui_outstr_nowrap(ScreenLines + off, | |
474 | 2125 enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1, |
7 | 2126 flags, fg, bg, back); |
2127 #else | |
2128 return gui_outstr_nowrap(ScreenLines + off, 1, flags, fg, bg, back); | |
2129 #endif | |
2130 } | |
2131 | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2132 #ifdef FEAT_GUI_GTK |
7 | 2133 /* |
2134 * Output the string at the given screen position. This is used in place | |
2135 * of gui_screenchar() where possible because Pango needs as much context | |
2136 * as possible to work nicely. It's a lot faster as well. | |
2137 */ | |
2138 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2139 gui_screenstr( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2140 int off, /* Offset from start of screen */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2141 int len, /* string length in screen cells */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2142 int flags, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2143 guicolor_T fg, /* colors for cursor */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2144 guicolor_T bg, /* colors for cursor */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2145 int back) /* backup this many chars when using bold trick */ |
7 | 2146 { |
2147 char_u *buf; | |
2148 int outlen = 0; | |
2149 int i; | |
2150 int retval; | |
2151 | |
2152 if (len <= 0) /* "cannot happen"? */ | |
2153 return OK; | |
2154 | |
2155 if (enc_utf8) | |
2156 { | |
2157 buf = alloc((unsigned)(len * MB_MAXBYTES + 1)); | |
2158 if (buf == NULL) | |
2159 return OK; /* not much we could do here... */ | |
2160 | |
2161 for (i = off; i < off + len; ++i) | |
2162 { | |
2163 if (ScreenLines[i] == 0) | |
2164 continue; /* skip second half of double-width char */ | |
2165 | |
2166 if (ScreenLinesUC[i] == 0) | |
2167 buf[outlen++] = ScreenLines[i]; | |
2168 else | |
2169 outlen += utfc_char2bytes(i, buf + outlen); | |
2170 } | |
2171 | |
2172 buf[outlen] = NUL; /* only to aid debugging */ | |
2173 retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back); | |
2174 vim_free(buf); | |
2175 | |
2176 return retval; | |
2177 } | |
2178 else if (enc_dbcs == DBCS_JPNU) | |
2179 { | |
2180 buf = alloc((unsigned)(len * 2 + 1)); | |
2181 if (buf == NULL) | |
2182 return OK; /* not much we could do here... */ | |
2183 | |
2184 for (i = off; i < off + len; ++i) | |
2185 { | |
2186 buf[outlen++] = ScreenLines[i]; | |
2187 | |
2188 /* handle double-byte single-width char */ | |
2189 if (ScreenLines[i] == 0x8e) | |
2190 buf[outlen++] = ScreenLines2[i]; | |
2191 else if (MB_BYTE2LEN(ScreenLines[i]) == 2) | |
2192 buf[outlen++] = ScreenLines[++i]; | |
2193 } | |
2194 | |
2195 buf[outlen] = NUL; /* only to aid debugging */ | |
2196 retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back); | |
2197 vim_free(buf); | |
2198 | |
2199 return retval; | |
2200 } | |
2201 else | |
2202 { | |
2203 return gui_outstr_nowrap(&ScreenLines[off], len, | |
2204 flags, fg, bg, back); | |
2205 } | |
2206 } | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2207 #endif /* FEAT_GUI_GTK */ |
7 | 2208 |
2209 /* | |
2210 * Output the given string at the current cursor position. If the string is | |
2211 * too long to fit on the line, then it is truncated. | |
2212 * "flags": | |
2213 * GUI_MON_IS_CURSOR should only be used when this function is being called to | |
2214 * actually draw (an inverted) cursor. | |
1199 | 2215 * GUI_MON_TRS_CURSOR is used to draw the cursor text with a transparent |
7 | 2216 * background. |
2217 * GUI_MON_NOCLEAR is used to avoid clearing the selection when drawing over | |
2218 * it. | |
2219 * Returns OK, unless "back" is non-zero and using the bold trick, then return | |
2220 * FAIL (the caller should start drawing "back" chars back). | |
2221 */ | |
2222 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2223 gui_outstr_nowrap( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2224 char_u *s, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2225 int len, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2226 int flags, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2227 guicolor_T fg, /* colors for cursor */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2228 guicolor_T bg, /* colors for cursor */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2229 int back) /* backup this many chars when using bold trick */ |
7 | 2230 { |
2231 long_u highlight_mask; | |
2232 long_u hl_mask_todo; | |
2233 guicolor_T fg_color; | |
2234 guicolor_T bg_color; | |
203 | 2235 guicolor_T sp_color; |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2236 #if !defined(FEAT_GUI_GTK) |
7 | 2237 GuiFont font = NOFONT; |
4950
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2238 # ifdef FEAT_MBYTE |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2239 GuiFont wide_font = NOFONT; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2240 # endif |
7 | 2241 # ifdef FEAT_XFONTSET |
2242 GuiFontset fontset = NOFONTSET; | |
2243 # endif | |
2244 #endif | |
2245 attrentry_T *aep = NULL; | |
2246 int draw_flags; | |
2247 int col = gui.col; | |
2248 #ifdef FEAT_SIGN_ICONS | |
2249 int draw_sign = FALSE; | |
2250 # ifdef FEAT_NETBEANS_INTG | |
2251 int multi_sign = FALSE; | |
2252 # endif | |
2253 #endif | |
2254 | |
2255 if (len < 0) | |
2256 len = (int)STRLEN(s); | |
2257 if (len == 0) | |
2258 return OK; | |
2259 | |
2260 #ifdef FEAT_SIGN_ICONS | |
2261 if (*s == SIGN_BYTE | |
2262 # ifdef FEAT_NETBEANS_INTG | |
2263 || *s == MULTISIGN_BYTE | |
2264 # endif | |
2265 ) | |
2266 { | |
2267 # ifdef FEAT_NETBEANS_INTG | |
2268 if (*s == MULTISIGN_BYTE) | |
2269 multi_sign = TRUE; | |
2270 # endif | |
2271 /* draw spaces instead */ | |
2272 s = (char_u *)" "; | |
2273 if (len == 1 && col > 0) | |
2274 --col; | |
2275 len = 2; | |
2276 draw_sign = TRUE; | |
2277 highlight_mask = 0; | |
2278 } | |
2279 else | |
2280 #endif | |
2281 if (gui.highlight_mask > HL_ALL) | |
2282 { | |
2283 aep = syn_gui_attr2entry(gui.highlight_mask); | |
2284 if (aep == NULL) /* highlighting not set */ | |
2285 highlight_mask = 0; | |
2286 else | |
2287 highlight_mask = aep->ae_attr; | |
2288 } | |
2289 else | |
2290 highlight_mask = gui.highlight_mask; | |
2291 hl_mask_todo = highlight_mask; | |
2292 | |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2293 #if !defined(FEAT_GUI_GTK) |
7 | 2294 /* Set the font */ |
2295 if (aep != NULL && aep->ae_u.gui.font != NOFONT) | |
2296 font = aep->ae_u.gui.font; | |
2297 # ifdef FEAT_XFONTSET | |
2298 else if (aep != NULL && aep->ae_u.gui.fontset != NOFONTSET) | |
2299 fontset = aep->ae_u.gui.fontset; | |
2300 # endif | |
2301 else | |
2302 { | |
2303 # ifdef FEAT_XFONTSET | |
2304 if (gui.fontset != NOFONTSET) | |
2305 fontset = gui.fontset; | |
2306 else | |
2307 # endif | |
2308 if (hl_mask_todo & (HL_BOLD | HL_STANDOUT)) | |
2309 { | |
2310 if ((hl_mask_todo & HL_ITALIC) && gui.boldital_font != NOFONT) | |
2311 { | |
2312 font = gui.boldital_font; | |
2313 hl_mask_todo &= ~(HL_BOLD | HL_STANDOUT | HL_ITALIC); | |
2314 } | |
2315 else if (gui.bold_font != NOFONT) | |
2316 { | |
2317 font = gui.bold_font; | |
2318 hl_mask_todo &= ~(HL_BOLD | HL_STANDOUT); | |
2319 } | |
2320 else | |
2321 font = gui.norm_font; | |
2322 } | |
2323 else if ((hl_mask_todo & HL_ITALIC) && gui.ital_font != NOFONT) | |
2324 { | |
2325 font = gui.ital_font; | |
2326 hl_mask_todo &= ~HL_ITALIC; | |
2327 } | |
2328 else | |
2329 font = gui.norm_font; | |
4950
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2330 |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2331 # ifdef FEAT_MBYTE |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2332 /* |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2333 * Choose correct wide_font by font. wide_font should be set with font |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2334 * at same time in above block. But it will make many "ifdef" nasty |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2335 * blocks. So we do it here. |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2336 */ |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2337 if (font == gui.boldital_font && gui.wide_boldital_font) |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2338 wide_font = gui.wide_boldital_font; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2339 else if (font == gui.bold_font && gui.wide_bold_font) |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2340 wide_font = gui.wide_bold_font; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2341 else if (font == gui.ital_font && gui.wide_ital_font) |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2342 wide_font = gui.wide_ital_font; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2343 else if (font == gui.norm_font && gui.wide_font) |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2344 wide_font = gui.wide_font; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2345 # endif |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2346 |
7 | 2347 } |
2348 # ifdef FEAT_XFONTSET | |
2349 if (fontset != NOFONTSET) | |
2350 gui_mch_set_fontset(fontset); | |
2351 else | |
2352 # endif | |
2353 gui_mch_set_font(font); | |
2354 #endif | |
2355 | |
2356 draw_flags = 0; | |
2357 | |
2358 /* Set the color */ | |
2359 bg_color = gui.back_pixel; | |
2360 if ((flags & GUI_MON_IS_CURSOR) && gui.in_focus) | |
2361 { | |
2362 draw_flags |= DRAW_CURSOR; | |
2363 fg_color = fg; | |
2364 bg_color = bg; | |
203 | 2365 sp_color = fg; |
7 | 2366 } |
2367 else if (aep != NULL) | |
2368 { | |
2369 fg_color = aep->ae_u.gui.fg_color; | |
2370 if (fg_color == INVALCOLOR) | |
2371 fg_color = gui.norm_pixel; | |
2372 bg_color = aep->ae_u.gui.bg_color; | |
2373 if (bg_color == INVALCOLOR) | |
2374 bg_color = gui.back_pixel; | |
203 | 2375 sp_color = aep->ae_u.gui.sp_color; |
2376 if (sp_color == INVALCOLOR) | |
2377 sp_color = fg_color; | |
7 | 2378 } |
2379 else | |
203 | 2380 { |
7 | 2381 fg_color = gui.norm_pixel; |
203 | 2382 sp_color = fg_color; |
2383 } | |
7 | 2384 |
2385 if (highlight_mask & (HL_INVERSE | HL_STANDOUT)) | |
2386 { | |
2823 | 2387 #if defined(AMIGA) |
7 | 2388 gui_mch_set_colors(bg_color, fg_color); |
2389 #else | |
2390 gui_mch_set_fg_color(bg_color); | |
2391 gui_mch_set_bg_color(fg_color); | |
2392 #endif | |
2393 } | |
2394 else | |
2395 { | |
2823 | 2396 #if defined(AMIGA) |
7 | 2397 gui_mch_set_colors(fg_color, bg_color); |
2398 #else | |
2399 gui_mch_set_fg_color(fg_color); | |
2400 gui_mch_set_bg_color(bg_color); | |
2401 #endif | |
2402 } | |
203 | 2403 gui_mch_set_sp_color(sp_color); |
7 | 2404 |
2405 /* Clear the selection if we are about to write over it */ | |
2406 if (!(flags & GUI_MON_NOCLEAR)) | |
2407 clip_may_clear_selection(gui.row, gui.row); | |
2408 | |
2409 | |
2410 /* If there's no bold font, then fake it */ | |
2411 if (hl_mask_todo & (HL_BOLD | HL_STANDOUT)) | |
2412 draw_flags |= DRAW_BOLD; | |
2413 | |
2414 /* | |
2415 * When drawing bold or italic characters the spill-over from the left | |
2416 * neighbor may be destroyed. Let the caller backup to start redrawing | |
2417 * just after a blank. | |
2418 */ | |
2419 if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC))) | |
2420 return FAIL; | |
2421 | |
2823 | 2422 #if defined(FEAT_GUI_GTK) |
7 | 2423 /* If there's no italic font, then fake it. |
2424 * For GTK2, we don't need a different font for italic style. */ | |
2425 if (hl_mask_todo & HL_ITALIC) | |
2426 draw_flags |= DRAW_ITALIC; | |
2427 | |
2428 /* Do we underline the text? */ | |
2429 if (hl_mask_todo & HL_UNDERLINE) | |
2430 draw_flags |= DRAW_UNDERL; | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12136
diff
changeset
|
2431 |
7 | 2432 #else |
2433 /* Do we underline the text? */ | |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2434 if ((hl_mask_todo & HL_UNDERLINE) || (hl_mask_todo & HL_ITALIC)) |
7 | 2435 draw_flags |= DRAW_UNDERL; |
2436 #endif | |
203 | 2437 /* Do we undercurl the text? */ |
2438 if (hl_mask_todo & HL_UNDERCURL) | |
2439 draw_flags |= DRAW_UNDERC; | |
7 | 2440 |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12136
diff
changeset
|
2441 /* Do we strikethrough the text? */ |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12136
diff
changeset
|
2442 if (hl_mask_todo & HL_STRIKETHROUGH) |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12136
diff
changeset
|
2443 draw_flags |= DRAW_STRIKE; |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12136
diff
changeset
|
2444 |
1199 | 2445 /* Do we draw transparently? */ |
7 | 2446 if (flags & GUI_MON_TRS_CURSOR) |
2447 draw_flags |= DRAW_TRANSP; | |
2448 | |
2449 /* | |
2450 * Draw the text. | |
2451 */ | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2452 #ifdef FEAT_GUI_GTK |
7 | 2453 /* The value returned is the length in display cells */ |
2454 len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags); | |
2455 #else | |
2456 # ifdef FEAT_MBYTE | |
2457 if (enc_utf8) | |
2458 { | |
2459 int start; /* index of bytes to be drawn */ | |
2460 int cells; /* cellwidth of bytes to be drawn */ | |
4352 | 2461 int thislen; /* length of bytes to be drawn */ |
7 | 2462 int cn; /* cellwidth of current char */ |
2463 int i; /* index of current char */ | |
2464 int c; /* current char value */ | |
2465 int cl; /* byte length of current char */ | |
2466 int comping; /* current char is composing */ | |
2467 int scol = col; /* screen column */ | |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2468 int curr_wide = FALSE; /* use 'guifontwide' */ |
4053 | 2469 int prev_wide = FALSE; |
2470 int wide_changed; | |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2471 # ifdef WIN3264 |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2472 int sep_comp = FALSE; /* Don't separate composing chars. */ |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2473 # else |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2474 int sep_comp = TRUE; /* Separate composing chars. */ |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2475 # endif |
7 | 2476 |
2477 /* Break the string at a composing character, it has to be drawn on | |
2478 * top of the previous character. */ | |
2479 start = 0; | |
2480 cells = 0; | |
2481 for (i = 0; i < len; i += cl) | |
2482 { | |
2483 c = utf_ptr2char(s + i); | |
2484 cn = utf_char2cells(c); | |
2485 comping = utf_iscomposing(c); | |
2486 if (!comping) /* count cells from non-composing chars */ | |
2487 cells += cn; | |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2488 if (!comping || sep_comp) |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2489 { |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2490 if (cn > 1 |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2491 # ifdef FEAT_XFONTSET |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2492 && fontset == NOFONTSET |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2493 # endif |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2494 && wide_font != NOFONT) |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2495 curr_wide = TRUE; |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2496 else |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2497 curr_wide = FALSE; |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2498 } |
474 | 2499 cl = utf_ptr2len(s + i); |
7 | 2500 if (cl == 0) /* hit end of string */ |
2501 len = i + cl; /* len must be wrong "cannot happen" */ | |
2502 | |
4053 | 2503 wide_changed = curr_wide != prev_wide; |
2504 | |
2505 /* Print the string so far if it's the last character or there is | |
7 | 2506 * a composing character. */ |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2507 if (i + cl >= len || (comping && sep_comp && i > start) |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2508 || wide_changed |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2509 # if defined(FEAT_GUI_X11) |
7 | 2510 || (cn > 1 |
2511 # ifdef FEAT_XFONTSET | |
2512 /* No fontset: At least draw char after wide char at | |
2513 * right position. */ | |
2514 && fontset == NOFONTSET | |
2515 # endif | |
2516 ) | |
2517 # endif | |
2518 ) | |
2519 { | |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2520 if ((comping && sep_comp) || wide_changed) |
7 | 2521 thislen = i - start; |
2522 else | |
2523 thislen = i - start + cl; | |
2524 if (thislen > 0) | |
2525 { | |
4053 | 2526 if (prev_wide) |
4950
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2527 gui_mch_set_font(wide_font); |
7 | 2528 gui_mch_draw_string(gui.row, scol, s + start, thislen, |
2529 draw_flags); | |
4053 | 2530 if (prev_wide) |
2531 gui_mch_set_font(font); | |
7 | 2532 start += thislen; |
2533 } | |
2534 scol += cells; | |
2535 cells = 0; | |
4053 | 2536 /* Adjust to not draw a character which width is changed |
2537 * against with last one. */ | |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2538 if (wide_changed && !(comping && sep_comp)) |
7 | 2539 { |
4053 | 2540 scol -= cn; |
2541 cl = 0; | |
7 | 2542 } |
2543 | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2237
diff
changeset
|
2544 # if defined(FEAT_GUI_X11) |
11 | 2545 /* No fontset: draw a space to fill the gap after a wide char |
2546 * */ | |
7 | 2547 if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0 |
2548 # ifdef FEAT_XFONTSET | |
2549 && fontset == NOFONTSET | |
2550 # endif | |
4053 | 2551 && !wide_changed) |
7 | 2552 gui_mch_draw_string(gui.row, scol - 1, (char_u *)" ", |
2553 1, draw_flags); | |
2554 # endif | |
2555 } | |
2556 /* Draw a composing char on top of the previous char. */ | |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2557 if (comping && sep_comp) |
7 | 2558 { |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12712
diff
changeset
|
2559 # if defined(__APPLE_CC__) && TARGET_API_MAC_CARBON |
536 | 2560 /* Carbon ATSUI autodraws composing char over previous char */ |
2561 gui_mch_draw_string(gui.row, scol, s + i, cl, | |
7 | 2562 draw_flags | DRAW_TRANSP); |
187 | 2563 # else |
536 | 2564 gui_mch_draw_string(gui.row, scol - cn, s + i, cl, |
187 | 2565 draw_flags | DRAW_TRANSP); |
2566 # endif | |
7 | 2567 start = i + cl; |
2568 } | |
4053 | 2569 prev_wide = curr_wide; |
7 | 2570 } |
2571 /* The stuff below assumes "len" is the length in screen columns. */ | |
2572 len = scol - col; | |
2573 } | |
2574 else | |
2575 # endif | |
2576 { | |
2577 gui_mch_draw_string(gui.row, col, s, len, draw_flags); | |
2578 # ifdef FEAT_MBYTE | |
2579 if (enc_dbcs == DBCS_JPNU) | |
2580 { | |
2581 /* Get the length in display cells, this can be different from the | |
2582 * number of bytes for "euc-jp". */ | |
2338
da6ec32d8d8f
Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2583 len = mb_string2cells(s, len); |
7 | 2584 } |
2585 # endif | |
2586 } | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2587 #endif /* !FEAT_GUI_GTK */ |
7 | 2588 |
2589 if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) | |
2590 gui.col = col + len; | |
2591 | |
2592 /* May need to invert it when it's part of the selection. */ | |
2593 if (flags & GUI_MON_NOCLEAR) | |
2594 clip_may_redraw_selection(gui.row, col, len); | |
2595 | |
2596 if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) | |
2597 { | |
2598 /* Invalidate the old physical cursor position if we wrote over it */ | |
2599 if (gui.cursor_row == gui.row | |
2600 && gui.cursor_col >= col | |
2601 && gui.cursor_col < col + len) | |
2602 gui.cursor_is_valid = FALSE; | |
2603 } | |
2604 | |
2605 #ifdef FEAT_SIGN_ICONS | |
2606 if (draw_sign) | |
2607 /* Draw the sign on top of the spaces. */ | |
2608 gui_mch_drawsign(gui.row, col, gui.highlight_mask); | |
2592 | 2609 # if defined(FEAT_NETBEANS_INTG) && (defined(FEAT_GUI_X11) \ |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2208
diff
changeset
|
2610 || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32)) |
7 | 2611 if (multi_sign) |
2612 netbeans_draw_multisign_indicator(gui.row); | |
2613 # endif | |
2614 #endif | |
2615 | |
2616 return OK; | |
2617 } | |
2618 | |
2619 /* | |
2620 * Un-draw the cursor. Actually this just redraws the character at the given | |
2621 * position. The character just before it too, for when it was in bold. | |
2622 */ | |
2623 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2624 gui_undraw_cursor(void) |
7 | 2625 { |
2626 if (gui.cursor_is_valid) | |
2627 { | |
2628 #ifdef FEAT_HANGULIN | |
2629 if (composing_hangul | |
2630 && gui.col == gui.cursor_col && gui.row == gui.cursor_row) | |
7208
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2631 { |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2632 char_u *comp_buf; |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2633 int comp_len; |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2634 |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2635 comp_buf = hangul_composing_buffer_get(&comp_len); |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2636 if (comp_buf) |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2637 { |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2638 (void)gui_outstr_nowrap(comp_buf, comp_len, |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2639 GUI_MON_IS_CURSOR | GUI_MON_NOCLEAR, |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2640 gui.norm_pixel, gui.back_pixel, 0); |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2641 vim_free(comp_buf); |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2642 } |
2c00f6b312bf
commit https://github.com/vim/vim/commit/72f4cc4a987d123c0ed909c85b9a05f65cef7202
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
2643 } |
7 | 2644 else |
2645 { | |
2646 #endif | |
2647 if (gui_redraw_block(gui.cursor_row, gui.cursor_col, | |
2648 gui.cursor_row, gui.cursor_col, GUI_MON_NOCLEAR) | |
2649 && gui.cursor_col > 0) | |
2650 (void)gui_redraw_block(gui.cursor_row, gui.cursor_col - 1, | |
2651 gui.cursor_row, gui.cursor_col - 1, GUI_MON_NOCLEAR); | |
2652 #ifdef FEAT_HANGULIN | |
2653 if (composing_hangul) | |
2654 (void)gui_redraw_block(gui.cursor_row, gui.cursor_col + 1, | |
2655 gui.cursor_row, gui.cursor_col + 1, GUI_MON_NOCLEAR); | |
2656 } | |
2657 #endif | |
2658 /* Cursor_is_valid is reset when the cursor is undrawn, also reset it | |
2659 * here in case it wasn't needed to undraw it. */ | |
2660 gui.cursor_is_valid = FALSE; | |
2661 } | |
2662 } | |
2663 | |
2664 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2665 gui_redraw( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2666 int x, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2667 int y, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2668 int w, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2669 int h) |
7 | 2670 { |
2671 int row1, col1, row2, col2; | |
2672 | |
2673 row1 = Y_2_ROW(y); | |
2674 col1 = X_2_COL(x); | |
2675 row2 = Y_2_ROW(y + h - 1); | |
2676 col2 = X_2_COL(x + w - 1); | |
2677 | |
2678 (void)gui_redraw_block(row1, col1, row2, col2, GUI_MON_NOCLEAR); | |
2679 | |
2680 /* | |
2681 * We may need to redraw the cursor, but don't take it upon us to change | |
2682 * its location after a scroll. | |
2683 * (maybe be more strict even and test col too?) | |
2684 * These things may be outside the update/clipping region and reality may | |
2685 * not reflect Vims internal ideas if these operations are clipped away. | |
2686 */ | |
2687 if (gui.row == gui.cursor_row) | |
2688 gui_update_cursor(TRUE, TRUE); | |
2689 } | |
2690 | |
2691 /* | |
2692 * Draw a rectangular block of characters, from row1 to row2 (inclusive) and | |
2693 * from col1 to col2 (inclusive). | |
2694 * Return TRUE when the character before the first drawn character has | |
2695 * different attributes (may have to be redrawn too). | |
2696 */ | |
2697 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2698 gui_redraw_block( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2699 int row1, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2700 int col1, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2701 int row2, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2702 int col2, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2703 int flags) /* flags for gui_outstr_nowrap() */ |
7 | 2704 { |
2705 int old_row, old_col; | |
2706 long_u old_hl_mask; | |
2707 int off; | |
203 | 2708 sattr_T first_attr; |
7 | 2709 int idx, len; |
2710 int back, nback; | |
2711 int retval = FALSE; | |
2712 #ifdef FEAT_MBYTE | |
2713 int orig_col1, orig_col2; | |
2714 #endif | |
2715 | |
2716 /* Don't try to update when ScreenLines is not valid */ | |
2717 if (!screen_cleared || ScreenLines == NULL) | |
2718 return retval; | |
2719 | |
2720 /* Don't try to draw outside the shell! */ | |
2721 /* Check everything, strange values may be caused by a big border width */ | |
2722 col1 = check_col(col1); | |
2723 col2 = check_col(col2); | |
2724 row1 = check_row(row1); | |
2725 row2 = check_row(row2); | |
2726 | |
2727 /* Remember where our cursor was */ | |
2728 old_row = gui.row; | |
2729 old_col = gui.col; | |
2730 old_hl_mask = gui.highlight_mask; | |
2731 #ifdef FEAT_MBYTE | |
2732 orig_col1 = col1; | |
2733 orig_col2 = col2; | |
2734 #endif | |
2735 | |
2736 for (gui.row = row1; gui.row <= row2; gui.row++) | |
2737 { | |
2738 #ifdef FEAT_MBYTE | |
2739 /* When only half of a double-wide character is in the block, include | |
2740 * the other half. */ | |
2741 col1 = orig_col1; | |
2742 col2 = orig_col2; | |
2743 off = LineOffset[gui.row]; | |
2744 if (enc_dbcs != 0) | |
2745 { | |
2746 if (col1 > 0) | |
2747 col1 -= dbcs_screen_head_off(ScreenLines + off, | |
2748 ScreenLines + off + col1); | |
2749 col2 += dbcs_screen_tail_off(ScreenLines + off, | |
2750 ScreenLines + off + col2); | |
2751 } | |
2752 else if (enc_utf8) | |
2753 { | |
2754 if (ScreenLines[off + col1] == 0) | |
2755 --col1; | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2756 # ifdef FEAT_GUI_GTK |
7 | 2757 if (col2 + 1 < Columns && ScreenLines[off + col2 + 1] == 0) |
2758 ++col2; | |
2759 # endif | |
2760 } | |
2761 #endif | |
2762 gui.col = col1; | |
2763 off = LineOffset[gui.row] + gui.col; | |
2764 len = col2 - col1 + 1; | |
2765 | |
2766 /* Find how many chars back this highlighting starts, or where a space | |
2767 * is. Needed for when the bold trick is used */ | |
2768 for (back = 0; back < col1; ++back) | |
2769 if (ScreenAttrs[off - 1 - back] != ScreenAttrs[off] | |
2770 || ScreenLines[off - 1 - back] == ' ') | |
2771 break; | |
2772 retval = (col1 > 0 && ScreenAttrs[off - 1] != 0 && back == 0 | |
2773 && ScreenLines[off - 1] != ' '); | |
2774 | |
2775 /* Break it up in strings of characters with the same attributes. */ | |
2776 /* Print UTF-8 characters individually. */ | |
2777 while (len > 0) | |
2778 { | |
2779 first_attr = ScreenAttrs[off]; | |
2780 gui.highlight_mask = first_attr; | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2781 #if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK) |
7 | 2782 if (enc_utf8 && ScreenLinesUC[off] != 0) |
2783 { | |
2784 /* output multi-byte character separately */ | |
2785 nback = gui_screenchar(off, flags, | |
2786 (guicolor_T)0, (guicolor_T)0, back); | |
2787 if (gui.col < Columns && ScreenLines[off + 1] == 0) | |
2788 idx = 2; | |
2789 else | |
2790 idx = 1; | |
2791 } | |
2792 else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) | |
2793 { | |
2794 /* output double-byte, single-width character separately */ | |
2795 nback = gui_screenchar(off, flags, | |
2796 (guicolor_T)0, (guicolor_T)0, back); | |
2797 idx = 1; | |
2798 } | |
2799 else | |
2800 #endif | |
2801 { | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2802 #ifdef FEAT_GUI_GTK |
7 | 2803 for (idx = 0; idx < len; ++idx) |
2804 { | |
2805 if (enc_utf8 && ScreenLines[off + idx] == 0) | |
2806 continue; /* skip second half of double-width char */ | |
2807 if (ScreenAttrs[off + idx] != first_attr) | |
2808 break; | |
2809 } | |
2810 /* gui_screenstr() takes care of multibyte chars */ | |
2811 nback = gui_screenstr(off, idx, flags, | |
2812 (guicolor_T)0, (guicolor_T)0, back); | |
2813 #else | |
2814 for (idx = 0; idx < len && ScreenAttrs[off + idx] == first_attr; | |
2815 idx++) | |
2816 { | |
2817 # ifdef FEAT_MBYTE | |
2818 /* Stop at a multi-byte Unicode character. */ | |
2819 if (enc_utf8 && ScreenLinesUC[off + idx] != 0) | |
2820 break; | |
2821 if (enc_dbcs == DBCS_JPNU) | |
2822 { | |
2823 /* Stop at a double-byte single-width char. */ | |
2824 if (ScreenLines[off + idx] == 0x8e) | |
2825 break; | |
474 | 2826 if (len > 1 && (*mb_ptr2len)(ScreenLines |
7 | 2827 + off + idx) == 2) |
2828 ++idx; /* skip second byte of double-byte char */ | |
2829 } | |
2830 # endif | |
2831 } | |
2832 nback = gui_outstr_nowrap(ScreenLines + off, idx, flags, | |
2833 (guicolor_T)0, (guicolor_T)0, back); | |
2834 #endif | |
2835 } | |
2836 if (nback == FAIL) | |
2837 { | |
2838 /* Must back up to start drawing where a bold or italic word | |
2839 * starts. */ | |
2840 off -= back; | |
2841 len += back; | |
2842 gui.col -= back; | |
2843 } | |
2844 else | |
2845 { | |
2846 off += idx; | |
2847 len -= idx; | |
2848 } | |
2849 back = 0; | |
2850 } | |
2851 } | |
2852 | |
2853 /* Put the cursor back where it was */ | |
2854 gui.row = old_row; | |
2855 gui.col = old_col; | |
835 | 2856 gui.highlight_mask = (int)old_hl_mask; |
7 | 2857 |
2858 return retval; | |
2859 } | |
2860 | |
2861 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2862 gui_delete_lines(int row, int count) |
7 | 2863 { |
2864 if (count <= 0) | |
2865 return; | |
2866 | |
2867 if (row + count > gui.scroll_region_bot) | |
2868 /* Scrolled out of region, just blank the lines out */ | |
2869 gui_clear_block(row, gui.scroll_region_left, | |
2870 gui.scroll_region_bot, gui.scroll_region_right); | |
2871 else | |
2872 { | |
2873 gui_mch_delete_lines(row, count); | |
2874 | |
2875 /* If the cursor was in the deleted lines it's now gone. If the | |
2876 * cursor was in the scrolled lines adjust its position. */ | |
2877 if (gui.cursor_row >= row | |
2878 && gui.cursor_col >= gui.scroll_region_left | |
2879 && gui.cursor_col <= gui.scroll_region_right) | |
2880 { | |
2881 if (gui.cursor_row < row + count) | |
2882 gui.cursor_is_valid = FALSE; | |
2883 else if (gui.cursor_row <= gui.scroll_region_bot) | |
2884 gui.cursor_row -= count; | |
2885 } | |
2886 } | |
2887 } | |
2888 | |
2889 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2890 gui_insert_lines(int row, int count) |
7 | 2891 { |
2892 if (count <= 0) | |
2893 return; | |
2894 | |
2895 if (row + count > gui.scroll_region_bot) | |
2896 /* Scrolled out of region, just blank the lines out */ | |
2897 gui_clear_block(row, gui.scroll_region_left, | |
2898 gui.scroll_region_bot, gui.scroll_region_right); | |
2899 else | |
2900 { | |
2901 gui_mch_insert_lines(row, count); | |
2902 | |
2903 if (gui.cursor_row >= gui.row | |
2904 && gui.cursor_col >= gui.scroll_region_left | |
2905 && gui.cursor_col <= gui.scroll_region_right) | |
2906 { | |
2907 if (gui.cursor_row <= gui.scroll_region_bot - count) | |
2908 gui.cursor_row += count; | |
2909 else if (gui.cursor_row <= gui.scroll_region_bot) | |
2910 gui.cursor_is_valid = FALSE; | |
2911 } | |
2912 } | |
2913 } | |
2914 | |
13080
eee366f56b1a
patch 8.0.1415: warning for unused function without timers feature
Christian Brabandt <cb@256bit.org>
parents:
13064
diff
changeset
|
2915 #ifdef FEAT_TIMERS |
11471
26525db57c4c
patch 8.0.0619: GUI gets stuck if timer uses feedkeys()
Christian Brabandt <cb@256bit.org>
parents:
11163
diff
changeset
|
2916 /* |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2917 * Passed to ui_wait_for_chars_or_timer(), ignoring extra arguments. |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2918 */ |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2919 static int |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2920 gui_wait_for_chars_3( |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2921 long wtime, |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2922 int *interrupted UNUSED, |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2923 int ignore_input UNUSED) |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2924 { |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2925 return gui_mch_wait_for_chars(wtime); |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2926 } |
13080
eee366f56b1a
patch 8.0.1415: warning for unused function without timers feature
Christian Brabandt <cb@256bit.org>
parents:
13064
diff
changeset
|
2927 #endif |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2928 |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2929 /* |
11471
26525db57c4c
patch 8.0.0619: GUI gets stuck if timer uses feedkeys()
Christian Brabandt <cb@256bit.org>
parents:
11163
diff
changeset
|
2930 * Returns OK if a character was found to be available within the given time, |
26525db57c4c
patch 8.0.0619: GUI gets stuck if timer uses feedkeys()
Christian Brabandt <cb@256bit.org>
parents:
11163
diff
changeset
|
2931 * or FAIL otherwise. |
26525db57c4c
patch 8.0.0619: GUI gets stuck if timer uses feedkeys()
Christian Brabandt <cb@256bit.org>
parents:
11163
diff
changeset
|
2932 */ |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2933 static int |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2934 gui_wait_for_chars_or_timer(long wtime) |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2935 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2936 #ifdef FEAT_TIMERS |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2937 return ui_wait_for_chars_or_timer(wtime, gui_wait_for_chars_3, NULL, 0); |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2938 #else |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2939 return gui_mch_wait_for_chars(wtime); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2940 #endif |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2941 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2942 |
7 | 2943 /* |
2944 * The main GUI input routine. Waits for a character from the keyboard. | |
2945 * wtime == -1 Wait forever. | |
2946 * wtime == 0 Don't wait. | |
2947 * wtime > 0 Wait wtime milliseconds for a character. | |
2948 * Returns OK if a character was found to be available within the given time, | |
2949 * or FAIL otherwise. | |
2950 */ | |
2951 int | |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2952 gui_wait_for_chars(long wtime, int tb_change_cnt) |
7 | 2953 { |
2954 int retval; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
2955 #if defined(ELAPSED_FUNC) |
13064
dc160dbdcfe2
patch 8.0.1407: GUI: CursorHold may trigger before 'updatetime'
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
2956 ELAPSED_TYPE start_tv; |
dc160dbdcfe2
patch 8.0.1407: GUI: CursorHold may trigger before 'updatetime'
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
2957 #endif |
7 | 2958 |
2208
495995b9ce7d
Fix: window title not updated after file dropped.
Bram Moolenaar <bram@vim.org>
parents:
2178
diff
changeset
|
2959 #ifdef FEAT_MENU |
7 | 2960 /* |
2961 * If we're going to wait a bit, update the menus and mouse shape for the | |
2962 * current State. | |
2963 */ | |
2964 if (wtime != 0) | |
2965 gui_update_menus(0); | |
2966 #endif | |
2967 | |
2968 gui_mch_update(); | |
2969 if (input_available()) /* Got char, return immediately */ | |
2970 return OK; | |
2971 if (wtime == 0) /* Don't wait for char */ | |
2972 return FAIL; | |
2973 | |
2974 /* Before waiting, flush any output to the screen. */ | |
2975 gui_mch_flush(); | |
2976 | |
2977 if (wtime > 0) | |
2978 { | |
2979 /* Blink when waiting for a character. Probably only does something | |
2980 * for showmatch() */ | |
2981 gui_mch_start_blink(); | |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2982 retval = gui_wait_for_chars_or_timer(wtime); |
13152
f4c3a7f410f4
patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
2983 gui_mch_stop_blink(TRUE); |
7 | 2984 return retval; |
2985 } | |
2986 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
2987 #if defined(ELAPSED_FUNC) |
13064
dc160dbdcfe2
patch 8.0.1407: GUI: CursorHold may trigger before 'updatetime'
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
2988 ELAPSED_INIT(start_tv); |
dc160dbdcfe2
patch 8.0.1407: GUI: CursorHold may trigger before 'updatetime'
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
2989 #endif |
dc160dbdcfe2
patch 8.0.1407: GUI: CursorHold may trigger before 'updatetime'
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
2990 |
7 | 2991 /* |
1199 | 2992 * While we are waiting indefinitely for a character, blink the cursor. |
7 | 2993 */ |
2994 gui_mch_start_blink(); | |
2995 | |
203 | 2996 retval = FAIL; |
2997 /* | |
2998 * We may want to trigger the CursorHold event. First wait for | |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2999 * 'updatetime' and if nothing is typed within that time, and feedkeys() |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3000 * wasn't used, put the K_CURSORHOLD key in the input buffer. |
203 | 3001 */ |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
3002 if (gui_wait_for_chars_or_timer(p_ut) == OK) |
203 | 3003 retval = OK; |
13064
dc160dbdcfe2
patch 8.0.1407: GUI: CursorHold may trigger before 'updatetime'
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
3004 else if (trigger_cursorhold() |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
3005 #ifdef ELAPSED_FUNC |
13064
dc160dbdcfe2
patch 8.0.1407: GUI: CursorHold may trigger before 'updatetime'
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
3006 && ELAPSED_FUNC(start_tv) >= p_ut |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
3007 #endif |
13064
dc160dbdcfe2
patch 8.0.1407: GUI: CursorHold may trigger before 'updatetime'
Christian Brabandt <cb@256bit.org>
parents:
13060
diff
changeset
|
3008 && typebuf.tb_change_cnt == tb_change_cnt) |
7 | 3009 { |
203 | 3010 char_u buf[3]; |
3011 | |
3012 /* Put K_CURSORHOLD in the input buffer. */ | |
3013 buf[0] = CSI; | |
3014 buf[1] = KS_EXTRA; | |
3015 buf[2] = (int)KE_CURSORHOLD; | |
3016 add_to_input_buf(buf, 3); | |
3017 | |
3018 retval = OK; | |
3019 } | |
3020 | |
11471
26525db57c4c
patch 8.0.0619: GUI gets stuck if timer uses feedkeys()
Christian Brabandt <cb@256bit.org>
parents:
11163
diff
changeset
|
3021 if (retval == FAIL && typebuf.tb_change_cnt == tb_change_cnt) |
203 | 3022 { |
3023 /* Blocking wait. */ | |
368 | 3024 before_blocking(); |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
3025 retval = gui_wait_for_chars_or_timer(-1L); |
7 | 3026 } |
3027 | |
13152
f4c3a7f410f4
patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents:
13150
diff
changeset
|
3028 gui_mch_stop_blink(TRUE); |
7 | 3029 return retval; |
3030 } | |
3031 | |
3032 /* | |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3033 * Equivalent of mch_inchar() for the GUI. |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3034 */ |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3035 int |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3036 gui_inchar( |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3037 char_u *buf, |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3038 int maxlen, |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3039 long wtime, /* milli seconds */ |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3040 int tb_change_cnt) |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3041 { |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3042 if (gui_wait_for_chars(wtime, tb_change_cnt) |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3043 && !typebuf_changed(tb_change_cnt)) |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3044 return read_from_input_buf(buf, (long)maxlen); |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3045 return 0; |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3046 } |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3047 |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3048 /* |
1137 | 3049 * Fill p[4] with mouse coordinates encoded for check_termcode(). |
7 | 3050 */ |
3051 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3052 fill_mouse_coord(char_u *p, int col, int row) |
7 | 3053 { |
3054 p[0] = (char_u)(col / 128 + ' ' + 1); | |
3055 p[1] = (char_u)(col % 128 + ' ' + 1); | |
3056 p[2] = (char_u)(row / 128 + ' ' + 1); | |
3057 p[3] = (char_u)(row % 128 + ' ' + 1); | |
3058 } | |
3059 | |
3060 /* | |
3061 * Generic mouse support function. Add a mouse event to the input buffer with | |
3062 * the given properties. | |
3063 * button --- may be any of MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT, | |
3064 * MOUSE_X1, MOUSE_X2 | |
3065 * MOUSE_DRAG, or MOUSE_RELEASE. | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3066 * MOUSE_4 and MOUSE_5 are used for vertical scroll wheel, |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3067 * MOUSE_6 and MOUSE_7 for horizontal scroll wheel. |
7 | 3068 * x, y --- Coordinates of mouse in pixels. |
3069 * repeated_click --- TRUE if this click comes only a short time after a | |
3070 * previous click. | |
3071 * modifiers --- Bit field which may be any of the following modifiers | |
3072 * or'ed together: MOUSE_SHIFT | MOUSE_CTRL | MOUSE_ALT. | |
3073 * This function will ignore drag events where the mouse has not moved to a new | |
3074 * character. | |
3075 */ | |
3076 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3077 gui_send_mouse_event( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3078 int button, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3079 int x, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3080 int y, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3081 int repeated_click, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3082 int_u modifiers) |
7 | 3083 { |
3084 static int prev_row = 0, prev_col = 0; | |
3085 static int prev_button = -1; | |
3086 static int num_clicks = 1; | |
3087 char_u string[10]; | |
3088 enum key_extra button_char; | |
3089 int row, col; | |
3090 #ifdef FEAT_CLIPBOARD | |
3091 int checkfor; | |
3092 int did_clip = FALSE; | |
3093 #endif | |
3094 | |
3095 /* | |
3096 * Scrolling may happen at any time, also while a selection is present. | |
3097 */ | |
3098 switch (button) | |
3099 { | |
3100 case MOUSE_X1: | |
3101 button_char = KE_X1MOUSE; | |
3102 goto button_set; | |
3103 case MOUSE_X2: | |
3104 button_char = KE_X2MOUSE; | |
3105 goto button_set; | |
3106 case MOUSE_4: | |
3107 button_char = KE_MOUSEDOWN; | |
3108 goto button_set; | |
3109 case MOUSE_5: | |
3110 button_char = KE_MOUSEUP; | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3111 goto button_set; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3112 case MOUSE_6: |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3113 button_char = KE_MOUSELEFT; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3114 goto button_set; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3115 case MOUSE_7: |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3116 button_char = KE_MOUSERIGHT; |
7 | 3117 button_set: |
3118 { | |
3119 /* Don't put events in the input queue now. */ | |
3120 if (hold_gui_events) | |
3121 return; | |
3122 | |
3123 string[3] = CSI; | |
3124 string[4] = KS_EXTRA; | |
3125 string[5] = (int)button_char; | |
3126 | |
3127 /* Pass the pointer coordinates of the scroll event so that we | |
3128 * know which window to scroll. */ | |
3129 row = gui_xy2colrow(x, y, &col); | |
3130 string[6] = (char_u)(col / 128 + ' ' + 1); | |
3131 string[7] = (char_u)(col % 128 + ' ' + 1); | |
3132 string[8] = (char_u)(row / 128 + ' ' + 1); | |
3133 string[9] = (char_u)(row % 128 + ' ' + 1); | |
3134 | |
3135 if (modifiers == 0) | |
3136 add_to_input_buf(string + 3, 7); | |
3137 else | |
3138 { | |
3139 string[0] = CSI; | |
3140 string[1] = KS_MODIFIER; | |
3141 string[2] = 0; | |
3142 if (modifiers & MOUSE_SHIFT) | |
3143 string[2] |= MOD_MASK_SHIFT; | |
3144 if (modifiers & MOUSE_CTRL) | |
3145 string[2] |= MOD_MASK_CTRL; | |
3146 if (modifiers & MOUSE_ALT) | |
3147 string[2] |= MOD_MASK_ALT; | |
3148 add_to_input_buf(string, 10); | |
3149 } | |
3150 return; | |
3151 } | |
3152 } | |
3153 | |
3154 #ifdef FEAT_CLIPBOARD | |
3155 /* If a clipboard selection is in progress, handle it */ | |
3156 if (clip_star.state == SELECT_IN_PROGRESS) | |
3157 { | |
3158 clip_process_selection(button, X_2_COL(x), Y_2_ROW(y), repeated_click); | |
3159 return; | |
3160 } | |
3161 | |
3162 /* Determine which mouse settings to look for based on the current mode */ | |
3163 switch (get_real_state()) | |
3164 { | |
3165 case NORMAL_BUSY: | |
3166 case OP_PENDING: | |
12822
0eb12ef4f8ba
patch 8.0.1288: GUI: cannot drag the statusline of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12802
diff
changeset
|
3167 # ifdef FEAT_TERMINAL |
0eb12ef4f8ba
patch 8.0.1288: GUI: cannot drag the statusline of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12802
diff
changeset
|
3168 case TERMINAL: |
0eb12ef4f8ba
patch 8.0.1288: GUI: cannot drag the statusline of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12802
diff
changeset
|
3169 # endif |
7 | 3170 case NORMAL: checkfor = MOUSE_NORMAL; break; |
3171 case VISUAL: checkfor = MOUSE_VISUAL; break; | |
788 | 3172 case SELECTMODE: checkfor = MOUSE_VISUAL; break; |
7 | 3173 case REPLACE: |
3174 case REPLACE+LANGMAP: | |
12822
0eb12ef4f8ba
patch 8.0.1288: GUI: cannot drag the statusline of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12802
diff
changeset
|
3175 # ifdef FEAT_VREPLACE |
7 | 3176 case VREPLACE: |
3177 case VREPLACE+LANGMAP: | |
12822
0eb12ef4f8ba
patch 8.0.1288: GUI: cannot drag the statusline of a terminal window
Christian Brabandt <cb@256bit.org>
parents:
12802
diff
changeset
|
3178 # endif |
7 | 3179 case INSERT: |
3180 case INSERT+LANGMAP: checkfor = MOUSE_INSERT; break; | |
3181 case ASKMORE: | |
3182 case HITRETURN: /* At the more- and hit-enter prompt pass the | |
3183 mouse event for a click on or below the | |
3184 message line. */ | |
3185 if (Y_2_ROW(y) >= msg_row) | |
3186 checkfor = MOUSE_NORMAL; | |
3187 else | |
3188 checkfor = MOUSE_RETURN; | |
3189 break; | |
3190 | |
3191 /* | |
3192 * On the command line, use the clipboard selection on all lines | |
3193 * but the command line. But not when pasting. | |
3194 */ | |
3195 case CMDLINE: | |
3196 case CMDLINE+LANGMAP: | |
3197 if (Y_2_ROW(y) < cmdline_row && button != MOUSE_MIDDLE) | |
3198 checkfor = MOUSE_NONE; | |
3199 else | |
3200 checkfor = MOUSE_COMMAND; | |
3201 break; | |
3202 | |
3203 default: | |
3204 checkfor = MOUSE_NONE; | |
3205 break; | |
3206 }; | |
3207 | |
3208 /* | |
3209 * Allow clipboard selection of text on the command line in "normal" | |
3210 * modes. Don't do this when dragging the status line, or extending a | |
3211 * Visual selection. | |
3212 */ | |
3213 if ((State == NORMAL || State == NORMAL_BUSY || (State & INSERT)) | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
3214 && Y_2_ROW(y) >= topframe->fr_height + firstwin->w_winrow |
7 | 3215 && button != MOUSE_DRAG |
3216 # ifdef FEAT_MOUSESHAPE | |
3217 && !drag_status_line | |
3218 && !drag_sep_line | |
3219 # endif | |
3220 ) | |
3221 checkfor = MOUSE_NONE; | |
3222 | |
3223 /* | |
3224 * Use modeless selection when holding CTRL and SHIFT pressed. | |
3225 */ | |
3226 if ((modifiers & MOUSE_CTRL) && (modifiers & MOUSE_SHIFT)) | |
3227 checkfor = MOUSE_NONEF; | |
3228 | |
3229 /* | |
3230 * In Ex mode, always use modeless selection. | |
3231 */ | |
3232 if (exmode_active) | |
3233 checkfor = MOUSE_NONE; | |
3234 | |
3235 /* | |
3236 * If the mouse settings say to not use the mouse, use the modeless | |
3237 * selection. But if Visual is active, assume that only the Visual area | |
3238 * will be selected. | |
3239 * Exception: On the command line, both the selection is used and a mouse | |
3240 * key is send. | |
3241 */ | |
3242 if (!mouse_has(checkfor) || checkfor == MOUSE_COMMAND) | |
3243 { | |
3244 /* Don't do modeless selection in Visual mode. */ | |
3245 if (checkfor != MOUSE_NONEF && VIsual_active && (State & NORMAL)) | |
3246 return; | |
3247 | |
3248 /* | |
3249 * When 'mousemodel' is "popup", shift-left is translated to right. | |
3250 * But not when also using Ctrl. | |
3251 */ | |
3252 if (mouse_model_popup() && button == MOUSE_LEFT | |
3253 && (modifiers & MOUSE_SHIFT) && !(modifiers & MOUSE_CTRL)) | |
3254 { | |
3255 button = MOUSE_RIGHT; | |
3256 modifiers &= ~ MOUSE_SHIFT; | |
3257 } | |
3258 | |
3259 /* If the selection is done, allow the right button to extend it. | |
3260 * If the selection is cleared, allow the right button to start it | |
3261 * from the cursor position. */ | |
3262 if (button == MOUSE_RIGHT) | |
3263 { | |
3264 if (clip_star.state == SELECT_CLEARED) | |
3265 { | |
3266 if (State & CMDLINE) | |
3267 { | |
3268 col = msg_col; | |
3269 row = msg_row; | |
3270 } | |
3271 else | |
3272 { | |
3273 col = curwin->w_wcol; | |
3274 row = curwin->w_wrow + W_WINROW(curwin); | |
3275 } | |
3276 clip_start_selection(col, row, FALSE); | |
3277 } | |
3278 clip_process_selection(button, X_2_COL(x), Y_2_ROW(y), | |
3279 repeated_click); | |
3280 did_clip = TRUE; | |
3281 } | |
3282 /* Allow the left button to start the selection */ | |
2823 | 3283 else if (button == MOUSE_LEFT) |
7 | 3284 { |
3285 clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click); | |
3286 did_clip = TRUE; | |
3287 } | |
3288 | |
3289 /* Always allow pasting */ | |
3290 if (button != MOUSE_MIDDLE) | |
3291 { | |
3292 if (!mouse_has(checkfor) || button == MOUSE_RELEASE) | |
3293 return; | |
3294 if (checkfor != MOUSE_COMMAND) | |
3295 button = MOUSE_LEFT; | |
3296 } | |
3297 repeated_click = FALSE; | |
3298 } | |
3299 | |
3300 if (clip_star.state != SELECT_CLEARED && !did_clip) | |
3674 | 3301 clip_clear_selection(&clip_star); |
7 | 3302 #endif |
3303 | |
3304 /* Don't put events in the input queue now. */ | |
3305 if (hold_gui_events) | |
3306 return; | |
3307 | |
3308 row = gui_xy2colrow(x, y, &col); | |
3309 | |
3310 /* | |
3311 * If we are dragging and the mouse hasn't moved far enough to be on a | |
3312 * different character, then don't send an event to vim. | |
3313 */ | |
3314 if (button == MOUSE_DRAG) | |
3315 { | |
3316 if (row == prev_row && col == prev_col) | |
3317 return; | |
3318 /* Dragging above the window, set "row" to -1 to cause a scroll. */ | |
3319 if (y < 0) | |
3320 row = -1; | |
3321 } | |
3322 | |
3323 /* | |
3324 * If topline has changed (window scrolled) since the last click, reset | |
3325 * repeated_click, because we don't want starting Visual mode when | |
3326 * clicking on a different character in the text. | |
3327 */ | |
3328 if (curwin->w_topline != gui_prev_topline | |
3329 #ifdef FEAT_DIFF | |
3330 || curwin->w_topfill != gui_prev_topfill | |
3331 #endif | |
3332 ) | |
3333 repeated_click = FALSE; | |
3334 | |
3335 string[0] = CSI; /* this sequence is recognized by check_termcode() */ | |
3336 string[1] = KS_MOUSE; | |
3337 string[2] = KE_FILLER; | |
3338 if (button != MOUSE_DRAG && button != MOUSE_RELEASE) | |
3339 { | |
3340 if (repeated_click) | |
3341 { | |
3342 /* | |
3343 * Handle multiple clicks. They only count if the mouse is still | |
3344 * pointing at the same character. | |
3345 */ | |
3346 if (button != prev_button || row != prev_row || col != prev_col) | |
3347 num_clicks = 1; | |
3348 else if (++num_clicks > 4) | |
3349 num_clicks = 1; | |
3350 } | |
3351 else | |
3352 num_clicks = 1; | |
3353 prev_button = button; | |
3354 gui_prev_topline = curwin->w_topline; | |
3355 #ifdef FEAT_DIFF | |
3356 gui_prev_topfill = curwin->w_topfill; | |
3357 #endif | |
3358 | |
3359 string[3] = (char_u)(button | 0x20); | |
3360 SET_NUM_MOUSE_CLICKS(string[3], num_clicks); | |
3361 } | |
3362 else | |
3363 string[3] = (char_u)button; | |
3364 | |
3365 string[3] |= modifiers; | |
3366 fill_mouse_coord(string + 4, col, row); | |
3367 add_to_input_buf(string, 8); | |
3368 | |
3369 if (row < 0) | |
3370 prev_row = 0; | |
3371 else | |
3372 prev_row = row; | |
3373 prev_col = col; | |
3374 | |
3375 /* | |
3376 * We need to make sure this is cleared since Athena doesn't tell us when | |
3377 * he is done dragging. Neither does GTK+ 2 -- at least for now. | |
3378 */ | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
3379 #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) |
7 | 3380 gui.dragged_sb = SBAR_NONE; |
3381 #endif | |
3382 } | |
3383 | |
3384 /* | |
3385 * Convert x and y coordinate to column and row in text window. | |
3386 * Corrects for multi-byte character. | |
3387 * returns column in "*colp" and row as return value; | |
3388 */ | |
3389 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3390 gui_xy2colrow(int x, int y, int *colp) |
7 | 3391 { |
3392 int col = check_col(X_2_COL(x)); | |
3393 int row = check_row(Y_2_ROW(y)); | |
3394 | |
3395 #ifdef FEAT_MBYTE | |
3396 *colp = mb_fix_col(col, row); | |
3397 #else | |
3398 *colp = col; | |
3399 #endif | |
3400 return row; | |
3401 } | |
3402 | |
3403 #if defined(FEAT_MENU) || defined(PROTO) | |
3404 /* | |
3405 * Callback function for when a menu entry has been selected. | |
3406 */ | |
3407 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3408 gui_menu_cb(vimmenu_T *menu) |
7 | 3409 { |
664 | 3410 char_u bytes[sizeof(long_u)]; |
7 | 3411 |
3412 /* Don't put events in the input queue now. */ | |
3413 if (hold_gui_events) | |
3414 return; | |
3415 | |
3416 bytes[0] = CSI; | |
3417 bytes[1] = KS_MENU; | |
3418 bytes[2] = KE_FILLER; | |
664 | 3419 add_to_input_buf(bytes, 3); |
3420 add_long_to_buf((long_u)menu, bytes); | |
3421 add_to_input_buf_csi(bytes, sizeof(long_u)); | |
7 | 3422 } |
3423 #endif | |
3424 | |
811 | 3425 static int prev_which_scrollbars[3]; |
669 | 3426 |
7 | 3427 /* |
3428 * Set which components are present. | |
685 | 3429 * If "oldval" is not NULL, "oldval" is the previous value, the new value is |
7 | 3430 * in p_go. |
3431 */ | |
3432 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3433 gui_init_which_components(char_u *oldval UNUSED) |
7 | 3434 { |
3435 #ifdef FEAT_MENU | |
3436 static int prev_menu_is_active = -1; | |
3437 #endif | |
3438 #ifdef FEAT_TOOLBAR | |
3439 static int prev_toolbar = -1; | |
3440 int using_toolbar = FALSE; | |
3441 #endif | |
685 | 3442 #ifdef FEAT_GUI_TABLINE |
3443 int using_tabline; | |
3444 #endif | |
7 | 3445 #ifdef FEAT_FOOTER |
3446 static int prev_footer = -1; | |
3447 int using_footer = FALSE; | |
3448 #endif | |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3449 #if defined(FEAT_MENU) |
7 | 3450 static int prev_tearoff = -1; |
3451 int using_tearoff = FALSE; | |
3452 #endif | |
3453 | |
3454 char_u *p; | |
3455 int i; | |
3456 #ifdef FEAT_MENU | |
3457 int grey_old, grey_new; | |
3458 char_u *temp; | |
3459 #endif | |
3460 win_T *wp; | |
3461 int need_set_size; | |
3462 int fix_size; | |
3463 | |
3464 #ifdef FEAT_MENU | |
3465 if (oldval != NULL && gui.in_use) | |
3466 { | |
3467 /* | |
3468 * Check if the menu's go from grey to non-grey or vise versa. | |
3469 */ | |
3470 grey_old = (vim_strchr(oldval, GO_GREY) != NULL); | |
3471 grey_new = (vim_strchr(p_go, GO_GREY) != NULL); | |
3472 if (grey_old != grey_new) | |
3473 { | |
3474 temp = p_go; | |
3475 p_go = oldval; | |
3476 gui_update_menus(MENU_ALL_MODES); | |
3477 p_go = temp; | |
3478 } | |
3479 } | |
3480 gui.menu_is_active = FALSE; | |
3481 #endif | |
3482 | |
3483 for (i = 0; i < 3; i++) | |
3484 gui.which_scrollbars[i] = FALSE; | |
3485 for (p = p_go; *p; p++) | |
3486 switch (*p) | |
3487 { | |
3488 case GO_LEFT: | |
3489 gui.which_scrollbars[SBAR_LEFT] = TRUE; | |
3490 break; | |
3491 case GO_RIGHT: | |
3492 gui.which_scrollbars[SBAR_RIGHT] = TRUE; | |
3493 break; | |
3494 case GO_VLEFT: | |
3495 if (win_hasvertsplit()) | |
3496 gui.which_scrollbars[SBAR_LEFT] = TRUE; | |
3497 break; | |
3498 case GO_VRIGHT: | |
3499 if (win_hasvertsplit()) | |
3500 gui.which_scrollbars[SBAR_RIGHT] = TRUE; | |
3501 break; | |
3502 case GO_BOT: | |
3503 gui.which_scrollbars[SBAR_BOTTOM] = TRUE; | |
3504 break; | |
3505 #ifdef FEAT_MENU | |
3506 case GO_MENUS: | |
3507 gui.menu_is_active = TRUE; | |
3508 break; | |
3509 #endif | |
3510 case GO_GREY: | |
3511 /* make menu's have grey items, ignored here */ | |
3512 break; | |
3513 #ifdef FEAT_TOOLBAR | |
3514 case GO_TOOLBAR: | |
3515 using_toolbar = TRUE; | |
3516 break; | |
3517 #endif | |
3518 #ifdef FEAT_FOOTER | |
3519 case GO_FOOTER: | |
3520 using_footer = TRUE; | |
3521 break; | |
3522 #endif | |
3523 case GO_TEAROFF: | |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3524 #if defined(FEAT_MENU) |
7 | 3525 using_tearoff = TRUE; |
3526 #endif | |
3527 break; | |
3528 default: | |
3529 /* Ignore options that are not supported */ | |
3530 break; | |
3531 } | |
685 | 3532 |
7 | 3533 if (gui.in_use) |
3534 { | |
811 | 3535 need_set_size = 0; |
7 | 3536 fix_size = FALSE; |
685 | 3537 |
3538 #ifdef FEAT_GUI_TABLINE | |
687 | 3539 /* Update the GUI tab line, it may appear or disappear. This may |
3540 * cause the non-GUI tab line to disappear or appear. */ | |
685 | 3541 using_tabline = gui_has_tabline(); |
706 | 3542 if (!gui_mch_showing_tabline() != !using_tabline) |
685 | 3543 { |
797 | 3544 /* We don't want a resize event change "Rows" here, save and |
3545 * restore it. Resizing is handled below. */ | |
3546 i = Rows; | |
685 | 3547 gui_update_tabline(); |
797 | 3548 Rows = i; |
1767 | 3549 need_set_size |= RESIZE_VERT; |
685 | 3550 if (using_tabline) |
3551 fix_size = TRUE; | |
3552 if (!gui_use_tabline()) | |
3553 redraw_tabline = TRUE; /* may draw non-GUI tab line */ | |
3554 } | |
3555 #endif | |
3556 | |
7 | 3557 for (i = 0; i < 3; i++) |
3558 { | |
811 | 3559 /* The scrollbar needs to be updated when it is shown/unshown and |
3560 * when switching tab pages. But the size only changes when it's | |
3561 * shown/unshown. Thus we need two places to remember whether a | |
3562 * scrollbar is there or not. */ | |
3563 if (gui.which_scrollbars[i] != prev_which_scrollbars[i] | |
3564 || gui.which_scrollbars[i] | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
3565 != curtab->tp_prev_which_scrollbars[i]) |
7 | 3566 { |
3567 if (i == SBAR_BOTTOM) | |
3568 gui_mch_enable_scrollbar(&gui.bottom_sbar, | |
3569 gui.which_scrollbars[i]); | |
3570 else | |
3571 { | |
3572 FOR_ALL_WINDOWS(wp) | |
3573 { | |
3574 gui_do_scrollbar(wp, i, gui.which_scrollbars[i]); | |
3575 } | |
3576 } | |
811 | 3577 if (gui.which_scrollbars[i] != prev_which_scrollbars[i]) |
3578 { | |
3579 if (i == SBAR_BOTTOM) | |
1767 | 3580 need_set_size |= RESIZE_VERT; |
811 | 3581 else |
1767 | 3582 need_set_size |= RESIZE_HOR; |
811 | 3583 if (gui.which_scrollbars[i]) |
3584 fix_size = TRUE; | |
3585 } | |
7 | 3586 } |
811 | 3587 curtab->tp_prev_which_scrollbars[i] = gui.which_scrollbars[i]; |
3588 prev_which_scrollbars[i] = gui.which_scrollbars[i]; | |
7 | 3589 } |
3590 | |
3591 #ifdef FEAT_MENU | |
3592 if (gui.menu_is_active != prev_menu_is_active) | |
3593 { | |
3594 /* We don't want a resize event change "Rows" here, save and | |
3595 * restore it. Resizing is handled below. */ | |
3596 i = Rows; | |
3597 gui_mch_enable_menu(gui.menu_is_active); | |
3598 Rows = i; | |
3599 prev_menu_is_active = gui.menu_is_active; | |
1767 | 3600 need_set_size |= RESIZE_VERT; |
7 | 3601 if (gui.menu_is_active) |
3602 fix_size = TRUE; | |
3603 } | |
3604 #endif | |
3605 | |
3606 #ifdef FEAT_TOOLBAR | |
3607 if (using_toolbar != prev_toolbar) | |
3608 { | |
3609 gui_mch_show_toolbar(using_toolbar); | |
3610 prev_toolbar = using_toolbar; | |
1767 | 3611 need_set_size |= RESIZE_VERT; |
7 | 3612 if (using_toolbar) |
3613 fix_size = TRUE; | |
3614 } | |
3615 #endif | |
3616 #ifdef FEAT_FOOTER | |
3617 if (using_footer != prev_footer) | |
3618 { | |
3619 gui_mch_enable_footer(using_footer); | |
3620 prev_footer = using_footer; | |
1767 | 3621 need_set_size |= RESIZE_VERT; |
7 | 3622 if (using_footer) |
3623 fix_size = TRUE; | |
3624 } | |
3625 #endif | |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3626 #if defined(FEAT_MENU) && !(defined(WIN3264) && !defined(FEAT_TEAROFF)) |
7 | 3627 if (using_tearoff != prev_tearoff) |
3628 { | |
3629 gui_mch_toggle_tearoffs(using_tearoff); | |
3630 prev_tearoff = using_tearoff; | |
3631 } | |
3632 #endif | |
1767 | 3633 if (need_set_size != 0) |
276 | 3634 { |
3635 #ifdef FEAT_GUI_GTK | |
1767 | 3636 long prev_Columns = Columns; |
3637 long prev_Rows = Rows; | |
276 | 3638 #endif |
7 | 3639 /* Adjust the size of the window to make the text area keep the |
3640 * same size and to avoid that part of our window is off-screen | |
3641 * and a scrollbar can't be used, for example. */ | |
811 | 3642 gui_set_shellsize(FALSE, fix_size, need_set_size); |
276 | 3643 |
3644 #ifdef FEAT_GUI_GTK | |
3645 /* GTK has the annoying habit of sending us resize events when | |
3646 * changing the window size ourselves. This mostly happens when | |
3647 * waiting for a character to arrive, quite unpredictably, and may | |
3648 * change Columns and Rows when we don't want it. Wait for a | |
3649 * character here to avoid this effect. | |
3650 * If you remove this, please test this command for resizing | |
292 | 3651 * effects (with optional left scrollbar): ":vsp|q|vsp|q|vsp|q". |
687 | 3652 * Don't do this while starting up though. |
1767 | 3653 * Don't change Rows when adding menu/toolbar/tabline. |
3654 * Don't change Columns when adding vertical toolbar. */ | |
3655 if (!gui.starting && need_set_size != (RESIZE_VERT | RESIZE_HOR)) | |
287 | 3656 (void)char_avail(); |
1767 | 3657 if ((need_set_size & RESIZE_VERT) == 0) |
3658 Rows = prev_Rows; | |
3659 if ((need_set_size & RESIZE_HOR) == 0) | |
3660 Columns = prev_Columns; | |
276 | 3661 #endif |
3662 } | |
687 | 3663 /* When the console tabline appears or disappears the window positions |
3664 * change. */ | |
3665 if (firstwin->w_winrow != tabline_height()) | |
3666 shell_new_rows(); /* recompute window positions and heights */ | |
7 | 3667 } |
3668 } | |
3669 | |
685 | 3670 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
3671 /* | |
3672 * Return TRUE if the GUI is taking care of the tabline. | |
3673 * It may still be hidden if 'showtabline' is zero. | |
3674 */ | |
3675 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3676 gui_use_tabline(void) |
685 | 3677 { |
3678 return gui.in_use && vim_strchr(p_go, GO_TABLINE) != NULL; | |
3679 } | |
3680 | |
3681 /* | |
3682 * Return TRUE if the GUI is showing the tabline. | |
3683 * This uses 'showtabline'. | |
3684 */ | |
3685 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3686 gui_has_tabline(void) |
685 | 3687 { |
3688 if (!gui_use_tabline() | |
3689 || p_stal == 0 | |
3690 || (p_stal == 1 && first_tabpage->tp_next == NULL)) | |
3691 return FALSE; | |
3692 return TRUE; | |
3693 } | |
3694 | |
3695 /* | |
3696 * Update the tabline. | |
3697 * This may display/undisplay the tabline and update the labels. | |
3698 */ | |
3699 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3700 gui_update_tabline(void) |
685 | 3701 { |
3702 int showit = gui_has_tabline(); | |
797 | 3703 int shown = gui_mch_showing_tabline(); |
685 | 3704 |
3705 if (!gui.starting && starting == 0) | |
3706 { | |
848 | 3707 /* Updating the tabline uses direct GUI commands, flush |
3708 * outstanding instructions first. (esp. clear screen) */ | |
3709 out_flush(); | |
3710 | |
797 | 3711 if (!showit != !shown) |
3712 gui_mch_show_tabline(showit); | |
685 | 3713 if (showit != 0) |
3714 gui_mch_update_tabline(); | |
797 | 3715 |
3716 /* When the tabs change from hidden to shown or from shown to | |
3717 * hidden the size of the text area should remain the same. */ | |
3718 if (!showit != !shown) | |
811 | 3719 gui_set_shellsize(FALSE, showit, RESIZE_VERT); |
685 | 3720 } |
3721 } | |
3722 | |
3723 /* | |
839 | 3724 * Get the label or tooltip for tab page "tp" into NameBuff[]. |
685 | 3725 */ |
3726 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3727 get_tabline_label( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3728 tabpage_T *tp, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3729 int tooltip) /* TRUE: get tooltip */ |
685 | 3730 { |
3731 int modified = FALSE; | |
3732 char_u buf[40]; | |
3733 int wincount; | |
3734 win_T *wp; | |
857 | 3735 char_u **opt; |
839 | 3736 |
3737 /* Use 'guitablabel' or 'guitabtooltip' if it's set. */ | |
857 | 3738 opt = (tooltip ? &p_gtt : &p_gtl); |
3739 if (**opt != NUL) | |
685 | 3740 { |
687 | 3741 int use_sandbox = FALSE; |
3742 int save_called_emsg = called_emsg; | |
3743 char_u res[MAXPATHL]; | |
706 | 3744 tabpage_T *save_curtab; |
839 | 3745 char_u *opt_name = (char_u *)(tooltip ? "guitabtooltip" |
3746 : "guitablabel"); | |
687 | 3747 |
3748 called_emsg = FALSE; | |
3749 | |
3750 printer_page_num = tabpage_index(tp); | |
3751 # ifdef FEAT_EVAL | |
3752 set_vim_var_nr(VV_LNUM, printer_page_num); | |
839 | 3753 use_sandbox = was_set_insecurely(opt_name, 0); |
687 | 3754 # endif |
706 | 3755 /* It's almost as going to the tabpage, but without autocommands. */ |
3756 curtab->tp_firstwin = firstwin; | |
3757 curtab->tp_lastwin = lastwin; | |
3758 curtab->tp_curwin = curwin; | |
3759 save_curtab = curtab; | |
3760 curtab = tp; | |
3761 topframe = curtab->tp_topframe; | |
3762 firstwin = curtab->tp_firstwin; | |
3763 lastwin = curtab->tp_lastwin; | |
3764 curwin = curtab->tp_curwin; | |
3765 curbuf = curwin->w_buffer; | |
3766 | |
687 | 3767 /* Can't use NameBuff directly, build_stl_str_hl() uses it. */ |
857 | 3768 build_stl_str_hl(curwin, res, MAXPATHL, *opt, use_sandbox, |
706 | 3769 0, (int)Columns, NULL, NULL); |
687 | 3770 STRCPY(NameBuff, res); |
3771 | |
706 | 3772 /* Back to the original curtab. */ |
3773 curtab = save_curtab; | |
3774 topframe = curtab->tp_topframe; | |
3775 firstwin = curtab->tp_firstwin; | |
3776 lastwin = curtab->tp_lastwin; | |
3777 curwin = curtab->tp_curwin; | |
3778 curbuf = curwin->w_buffer; | |
3779 | |
687 | 3780 if (called_emsg) |
839 | 3781 set_string_option_direct(opt_name, -1, |
694 | 3782 (char_u *)"", OPT_FREE, SID_ERROR); |
687 | 3783 called_emsg |= save_called_emsg; |
3784 } | |
857 | 3785 |
3786 /* If 'guitablabel'/'guitabtooltip' is not set or the result is empty then | |
3787 * use a default label. */ | |
3788 if (**opt == NUL || *NameBuff == NUL) | |
687 | 3789 { |
819 | 3790 /* Get the buffer name into NameBuff[] and shorten it. */ |
687 | 3791 get_trans_bufname(tp == curtab ? curbuf : tp->tp_curwin->w_buffer); |
839 | 3792 if (!tooltip) |
3793 shorten_dir(NameBuff); | |
687 | 3794 |
3795 wp = (tp == curtab) ? firstwin : tp->tp_firstwin; | |
3796 for (wincount = 0; wp != NULL; wp = wp->w_next, ++wincount) | |
3797 if (bufIsChanged(wp->w_buffer)) | |
3798 modified = TRUE; | |
3799 if (modified || wincount > 1) | |
3800 { | |
3801 if (wincount > 1) | |
3802 vim_snprintf((char *)buf, sizeof(buf), "%d", wincount); | |
3803 else | |
3804 buf[0] = NUL; | |
3805 if (modified) | |
3806 STRCAT(buf, "+"); | |
3807 STRCAT(buf, " "); | |
1620 | 3808 STRMOVE(NameBuff + STRLEN(buf), NameBuff); |
687 | 3809 mch_memmove(NameBuff, buf, STRLEN(buf)); |
3810 } | |
685 | 3811 } |
3812 } | |
3813 | |
691 | 3814 /* |
3815 * Send the event for clicking to select tab page "nr". | |
3816 * Returns TRUE if it was done, FALSE when skipped because we are already at | |
838 | 3817 * that tab page or the cmdline window is open. |
691 | 3818 */ |
3819 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3820 send_tabline_event(int nr) |
691 | 3821 { |
3822 char_u string[3]; | |
3823 | |
3824 if (nr == tabpage_index(curtab)) | |
3825 return FALSE; | |
844 | 3826 |
3827 /* Don't put events in the input queue now. */ | |
3828 if (hold_gui_events | |
838 | 3829 # ifdef FEAT_CMDWIN |
844 | 3830 || cmdwin_type != 0 |
3831 # endif | |
3832 ) | |
838 | 3833 { |
3834 /* Set it back to the current tab page. */ | |
3835 gui_mch_set_curtab(tabpage_index(curtab)); | |
3836 return FALSE; | |
3837 } | |
844 | 3838 |
691 | 3839 string[0] = CSI; |
3840 string[1] = KS_TABLINE; | |
3841 string[2] = KE_FILLER; | |
3842 add_to_input_buf(string, 3); | |
3843 string[0] = nr; | |
3844 add_to_input_buf_csi(string, 1); | |
3845 return TRUE; | |
3846 } | |
3847 | |
824 | 3848 /* |
3849 * Send a tabline menu event | |
3850 */ | |
3851 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3852 send_tabline_menu_event(int tabidx, int event) |
824 | 3853 { |
3854 char_u string[3]; | |
3855 | |
844 | 3856 /* Don't put events in the input queue now. */ |
3857 if (hold_gui_events) | |
3858 return; | |
3859 | |
824 | 3860 string[0] = CSI; |
3861 string[1] = KS_TABMENU; | |
3862 string[2] = KE_FILLER; | |
3863 add_to_input_buf(string, 3); | |
3864 string[0] = tabidx; | |
3865 string[1] = (char_u)(long)event; | |
3866 add_to_input_buf_csi(string, 2); | |
3867 } | |
3868 | |
685 | 3869 #endif |
7 | 3870 |
3871 /* | |
3872 * Scrollbar stuff: | |
3873 */ | |
3874 | |
669 | 3875 /* |
3876 * Remove all scrollbars. Used before switching to another tab page. | |
3877 */ | |
3878 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3879 gui_remove_scrollbars(void) |
669 | 3880 { |
3881 int i; | |
3882 win_T *wp; | |
3883 | |
3884 for (i = 0; i < 3; i++) | |
3885 { | |
3886 if (i == SBAR_BOTTOM) | |
3887 gui_mch_enable_scrollbar(&gui.bottom_sbar, FALSE); | |
3888 else | |
3889 { | |
3890 FOR_ALL_WINDOWS(wp) | |
3891 { | |
3892 gui_do_scrollbar(wp, i, FALSE); | |
3893 } | |
3894 } | |
788 | 3895 curtab->tp_prev_which_scrollbars[i] = -1; |
669 | 3896 } |
3897 } | |
3898 | |
7 | 3899 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3900 gui_create_scrollbar(scrollbar_T *sb, int type, win_T *wp) |
7 | 3901 { |
3902 static int sbar_ident = 0; | |
3903 | |
3904 sb->ident = sbar_ident++; /* No check for too big, but would it happen? */ | |
3905 sb->wp = wp; | |
3906 sb->type = type; | |
3907 sb->value = 0; | |
3908 #ifdef FEAT_GUI_ATHENA | |
3909 sb->pixval = 0; | |
3910 #endif | |
3911 sb->size = 1; | |
3912 sb->max = 1; | |
3913 sb->top = 0; | |
3914 sb->height = 0; | |
3915 sb->width = 0; | |
3916 sb->status_height = 0; | |
3917 gui_mch_create_scrollbar(sb, (wp == NULL) ? SBAR_HORIZ : SBAR_VERT); | |
3918 } | |
3919 | |
3920 /* | |
3921 * Find the scrollbar with the given index. | |
3922 */ | |
3923 scrollbar_T * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3924 gui_find_scrollbar(long ident) |
7 | 3925 { |
3926 win_T *wp; | |
3927 | |
3928 if (gui.bottom_sbar.ident == ident) | |
3929 return &gui.bottom_sbar; | |
3930 FOR_ALL_WINDOWS(wp) | |
3931 { | |
3932 if (wp->w_scrollbars[SBAR_LEFT].ident == ident) | |
3933 return &wp->w_scrollbars[SBAR_LEFT]; | |
3934 if (wp->w_scrollbars[SBAR_RIGHT].ident == ident) | |
3935 return &wp->w_scrollbars[SBAR_RIGHT]; | |
3936 } | |
3937 return NULL; | |
3938 } | |
3939 | |
3940 /* | |
3941 * For most systems: Put a code in the input buffer for a dragged scrollbar. | |
3942 * | |
3943 * For Win32, Macintosh and GTK+ 2: | |
3944 * Scrollbars seem to grab focus and vim doesn't read the input queue until | |
3945 * you stop dragging the scrollbar. We get here each time the scrollbar is | |
3946 * dragged another pixel, but as far as the rest of vim goes, it thinks | |
3947 * we're just hanging in the call to DispatchMessage() in | |
3948 * process_message(). The DispatchMessage() call that hangs was passed a | |
3949 * mouse button click event in the scrollbar window. -- webb. | |
3950 * | |
3951 * Solution: Do the scrolling right here. But only when allowed. | |
3952 * Ignore the scrollbars while executing an external command or when there | |
3953 * are still characters to be processed. | |
3954 */ | |
3955 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3956 gui_drag_scrollbar(scrollbar_T *sb, long value, int still_dragging) |
7 | 3957 { |
3958 win_T *wp; | |
3959 int sb_num; | |
3960 #ifdef USE_ON_FLY_SCROLL | |
3961 colnr_T old_leftcol = curwin->w_leftcol; | |
3962 linenr_T old_topline = curwin->w_topline; | |
3963 # ifdef FEAT_DIFF | |
3964 int old_topfill = curwin->w_topfill; | |
3965 # endif | |
3966 #else | |
664 | 3967 char_u bytes[sizeof(long_u)]; |
7 | 3968 int byte_count; |
3969 #endif | |
3970 | |
3971 if (sb == NULL) | |
3972 return; | |
3973 | |
3974 /* Don't put events in the input queue now. */ | |
3975 if (hold_gui_events) | |
3976 return; | |
3977 | |
3978 #ifdef FEAT_CMDWIN | |
3979 if (cmdwin_type != 0 && sb->wp != curwin) | |
3980 return; | |
3981 #endif | |
3982 | |
3983 if (still_dragging) | |
3984 { | |
3985 if (sb->wp == NULL) | |
3986 gui.dragged_sb = SBAR_BOTTOM; | |
3987 else if (sb == &sb->wp->w_scrollbars[SBAR_LEFT]) | |
3988 gui.dragged_sb = SBAR_LEFT; | |
3989 else | |
3990 gui.dragged_sb = SBAR_RIGHT; | |
3991 gui.dragged_wp = sb->wp; | |
3992 } | |
3993 else | |
3994 { | |
3995 gui.dragged_sb = SBAR_NONE; | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
3996 #ifdef FEAT_GUI_GTK |
7 | 3997 /* Keep the "dragged_wp" value until after the scrolling, for when the |
4352 | 3998 * mouse button is released. GTK2 doesn't send the button-up event. */ |
7 | 3999 gui.dragged_wp = NULL; |
4000 #endif | |
4001 } | |
4002 | |
4003 /* Vertical sbar info is kept in the first sbar (the left one) */ | |
4004 if (sb->wp != NULL) | |
4005 sb = &sb->wp->w_scrollbars[0]; | |
4006 | |
4007 /* | |
4008 * Check validity of value | |
4009 */ | |
4010 if (value < 0) | |
4011 value = 0; | |
4012 #ifdef SCROLL_PAST_END | |
4013 else if (value > sb->max) | |
4014 value = sb->max; | |
4015 #else | |
4016 if (value > sb->max - sb->size + 1) | |
4017 value = sb->max - sb->size + 1; | |
4018 #endif | |
4019 | |
4020 sb->value = value; | |
4021 | |
4022 #ifdef USE_ON_FLY_SCROLL | |
1476 | 4023 /* When not allowed to do the scrolling right now, return. |
4024 * This also checked input_available(), but that causes the first click in | |
4025 * a scrollbar to be ignored when Vim doesn't have focus. */ | |
4026 if (dont_scroll) | |
7 | 4027 return; |
4028 #endif | |
973 | 4029 #ifdef FEAT_INS_EXPAND |
4030 /* Disallow scrolling the current window when the completion popup menu is | |
4031 * visible. */ | |
4032 if ((sb->wp == NULL || sb->wp == curwin) && pum_visible()) | |
4033 return; | |
4034 #endif | |
7 | 4035 |
4036 #ifdef FEAT_RIGHTLEFT | |
4037 if (sb->wp == NULL && curwin->w_p_rl) | |
4038 { | |
4039 value = sb->max + 1 - sb->size - value; | |
4040 if (value < 0) | |
4041 value = 0; | |
4042 } | |
4043 #endif | |
4044 | |
4045 if (sb->wp != NULL) /* vertical scrollbar */ | |
4046 { | |
4047 sb_num = 0; | |
4048 for (wp = firstwin; wp != sb->wp && wp != NULL; wp = wp->w_next) | |
4049 sb_num++; | |
4050 if (wp == NULL) | |
4051 return; | |
4052 | |
4053 #ifdef USE_ON_FLY_SCROLL | |
4054 current_scrollbar = sb_num; | |
4055 scrollbar_value = value; | |
4056 if (State & NORMAL) | |
4057 { | |
4058 gui_do_scroll(); | |
4059 setcursor(); | |
4060 } | |
4061 else if (State & INSERT) | |
4062 { | |
4063 ins_scroll(); | |
4064 setcursor(); | |
4065 } | |
4066 else if (State & CMDLINE) | |
4067 { | |
4068 if (msg_scrolled == 0) | |
4069 { | |
4070 gui_do_scroll(); | |
4071 redrawcmdline(); | |
4072 } | |
4073 } | |
4074 # ifdef FEAT_FOLDING | |
4075 /* Value may have been changed for closed fold. */ | |
4076 sb->value = sb->wp->w_topline - 1; | |
4077 # endif | |
788 | 4078 |
4079 /* When dragging one scrollbar and there is another one at the other | |
4080 * side move the thumb of that one too. */ | |
4081 if (gui.which_scrollbars[SBAR_RIGHT] && gui.which_scrollbars[SBAR_LEFT]) | |
4082 gui_mch_set_scrollbar_thumb( | |
4083 &sb->wp->w_scrollbars[ | |
4084 sb == &sb->wp->w_scrollbars[SBAR_RIGHT] | |
4085 ? SBAR_LEFT : SBAR_RIGHT], | |
4086 sb->value, sb->size, sb->max); | |
4087 | |
7 | 4088 #else |
4089 bytes[0] = CSI; | |
4090 bytes[1] = KS_VER_SCROLLBAR; | |
4091 bytes[2] = KE_FILLER; | |
4092 bytes[3] = (char_u)sb_num; | |
4093 byte_count = 4; | |
4094 #endif | |
4095 } | |
4096 else | |
4097 { | |
4098 #ifdef USE_ON_FLY_SCROLL | |
4099 scrollbar_value = value; | |
4100 | |
4101 if (State & NORMAL) | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4102 gui_do_horiz_scroll(scrollbar_value, FALSE); |
7 | 4103 else if (State & INSERT) |
4104 ins_horscroll(); | |
4105 else if (State & CMDLINE) | |
4106 { | |
540 | 4107 if (msg_scrolled == 0) |
7 | 4108 { |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4109 gui_do_horiz_scroll(scrollbar_value, FALSE); |
7 | 4110 redrawcmdline(); |
4111 } | |
4112 } | |
4113 if (old_leftcol != curwin->w_leftcol) | |
4114 { | |
4115 updateWindow(curwin); /* update window, status and cmdline */ | |
4116 setcursor(); | |
4117 } | |
4118 #else | |
4119 bytes[0] = CSI; | |
4120 bytes[1] = KS_HOR_SCROLLBAR; | |
4121 bytes[2] = KE_FILLER; | |
4122 byte_count = 3; | |
4123 #endif | |
4124 } | |
4125 | |
4126 #ifdef USE_ON_FLY_SCROLL | |
4127 /* | |
4128 * synchronize other windows, as necessary according to 'scrollbind' | |
4129 */ | |
4130 if (curwin->w_p_scb | |
4131 && ((sb->wp == NULL && curwin->w_leftcol != old_leftcol) | |
4132 || (sb->wp == curwin && (curwin->w_topline != old_topline | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
4133 # ifdef FEAT_DIFF |
7 | 4134 || curwin->w_topfill != old_topfill |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
4135 # endif |
7 | 4136 )))) |
4137 { | |
4138 do_check_scrollbind(TRUE); | |
4139 /* need to update the window right here */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
4140 FOR_ALL_WINDOWS(wp) |
7 | 4141 if (wp->w_redr_type > 0) |
4142 updateWindow(wp); | |
4143 setcursor(); | |
4144 } | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
4145 out_flush_cursor(FALSE, TRUE); |
7 | 4146 #else |
664 | 4147 add_to_input_buf(bytes, byte_count); |
4148 add_long_to_buf((long_u)value, bytes); | |
4149 add_to_input_buf_csi(bytes, sizeof(long_u)); | |
7 | 4150 #endif |
4151 } | |
4152 | |
4153 /* | |
4154 * Scrollbar stuff: | |
4155 */ | |
4156 | |
1906 | 4157 /* |
4158 * Called when something in the window layout has changed. | |
4159 */ | |
4160 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4161 gui_may_update_scrollbars(void) |
1906 | 4162 { |
4163 if (gui.in_use && starting == 0) | |
4164 { | |
4165 out_flush(); | |
4166 gui_init_which_components(NULL); | |
4167 gui_update_scrollbars(TRUE); | |
4168 } | |
4169 need_mouse_correct = TRUE; | |
4170 } | |
4171 | |
7 | 4172 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4173 gui_update_scrollbars( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4174 int force) /* Force all scrollbars to get updated */ |
7 | 4175 { |
4176 win_T *wp; | |
4177 scrollbar_T *sb; | |
4178 long val, size, max; /* need 32 bits here */ | |
4179 int which_sb; | |
4180 int h, y; | |
4181 static win_T *prev_curwin = NULL; | |
4182 | |
4183 /* Update the horizontal scrollbar */ | |
4184 gui_update_horiz_scrollbar(force); | |
4185 | |
4186 #ifndef WIN3264 | |
4187 /* Return straight away if there is neither a left nor right scrollbar. | |
4188 * On MS-Windows this is required anyway for scrollwheel messages. */ | |
4189 if (!gui.which_scrollbars[SBAR_LEFT] && !gui.which_scrollbars[SBAR_RIGHT]) | |
4190 return; | |
4191 #endif | |
4192 | |
4193 /* | |
4194 * Don't want to update a scrollbar while we're dragging it. But if we | |
4195 * have both a left and right scrollbar, and we drag one of them, we still | |
4196 * need to update the other one. | |
4197 */ | |
674 | 4198 if (!force && (gui.dragged_sb == SBAR_LEFT || gui.dragged_sb == SBAR_RIGHT) |
4199 && gui.which_scrollbars[SBAR_LEFT] | |
4200 && gui.which_scrollbars[SBAR_RIGHT]) | |
7 | 4201 { |
4202 /* | |
4203 * If we have two scrollbars and one of them is being dragged, just | |
4204 * copy the scrollbar position from the dragged one to the other one. | |
4205 */ | |
4206 which_sb = SBAR_LEFT + SBAR_RIGHT - gui.dragged_sb; | |
4207 if (gui.dragged_wp != NULL) | |
4208 gui_mch_set_scrollbar_thumb( | |
4209 &gui.dragged_wp->w_scrollbars[which_sb], | |
4210 gui.dragged_wp->w_scrollbars[0].value, | |
4211 gui.dragged_wp->w_scrollbars[0].size, | |
4212 gui.dragged_wp->w_scrollbars[0].max); | |
4213 } | |
4214 | |
4215 /* avoid that moving components around generates events */ | |
4216 ++hold_gui_events; | |
4217 | |
9651
fe665dae7197
commit https://github.com/vim/vim/commit/45a249513f5ed2de0a6f6b5cb6e32015e35644be
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
4218 for (wp = firstwin; wp != NULL; wp = W_NEXT(wp)) |
7 | 4219 { |
4220 if (wp->w_buffer == NULL) /* just in case */ | |
4221 continue; | |
674 | 4222 /* Skip a scrollbar that is being dragged. */ |
4223 if (!force && (gui.dragged_sb == SBAR_LEFT | |
4224 || gui.dragged_sb == SBAR_RIGHT) | |
4225 && gui.dragged_wp == wp) | |
4226 continue; | |
4227 | |
7 | 4228 #ifdef SCROLL_PAST_END |
4229 max = wp->w_buffer->b_ml.ml_line_count - 1; | |
4230 #else | |
4231 max = wp->w_buffer->b_ml.ml_line_count + wp->w_height - 2; | |
4232 #endif | |
4233 if (max < 0) /* empty buffer */ | |
4234 max = 0; | |
4235 val = wp->w_topline - 1; | |
4236 size = wp->w_height; | |
4237 #ifdef SCROLL_PAST_END | |
4238 if (val > max) /* just in case */ | |
4239 val = max; | |
4240 #else | |
4241 if (size > max + 1) /* just in case */ | |
4242 size = max + 1; | |
4243 if (val > max - size + 1) | |
4244 val = max - size + 1; | |
4245 #endif | |
4246 if (val < 0) /* minimal value is 0 */ | |
4247 val = 0; | |
4248 | |
4249 /* | |
4250 * Scrollbar at index 0 (the left one) contains all the information. | |
4251 * It would be the same info for left and right so we just store it for | |
4252 * one of them. | |
4253 */ | |
4254 sb = &wp->w_scrollbars[0]; | |
4255 | |
4256 /* | |
4257 * Note: no check for valid w_botline. If it's not valid the | |
4258 * scrollbars will be updated later anyway. | |
4259 */ | |
4260 if (size < 1 || wp->w_botline - 2 > max) | |
4261 { | |
4262 /* | |
4263 * This can happen during changing files. Just don't update the | |
4264 * scrollbar for now. | |
4265 */ | |
4266 sb->height = 0; /* Force update next time */ | |
4267 if (gui.which_scrollbars[SBAR_LEFT]) | |
4268 gui_do_scrollbar(wp, SBAR_LEFT, FALSE); | |
4269 if (gui.which_scrollbars[SBAR_RIGHT]) | |
4270 gui_do_scrollbar(wp, SBAR_RIGHT, FALSE); | |
4271 continue; | |
4272 } | |
4273 if (force || sb->height != wp->w_height | |
4274 || sb->top != wp->w_winrow | |
4275 || sb->status_height != wp->w_status_height | |
4276 || sb->width != wp->w_width | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
4277 || prev_curwin != curwin) |
7 | 4278 { |
4279 /* Height, width or position of scrollbar has changed. For | |
4280 * vertical split: curwin changed. */ | |
4281 sb->height = wp->w_height; | |
4282 sb->top = wp->w_winrow; | |
4283 sb->status_height = wp->w_status_height; | |
4284 sb->width = wp->w_width; | |
4285 | |
4286 /* Calculate height and position in pixels */ | |
4287 h = (sb->height + sb->status_height) * gui.char_height; | |
4288 y = sb->top * gui.char_height + gui.border_offset; | |
4289 #if defined(FEAT_MENU) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) && !defined(FEAT_GUI_PHOTON) | |
4290 if (gui.menu_is_active) | |
4291 y += gui.menu_height; | |
4292 #endif | |
4293 | |
4294 #if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_ATHENA)) | |
4295 if (vim_strchr(p_go, GO_TOOLBAR) != NULL) | |
4296 # ifdef FEAT_GUI_ATHENA | |
4297 y += gui.toolbar_height; | |
4298 # else | |
4299 # ifdef FEAT_GUI_MSWIN | |
4300 y += TOOLBAR_BUTTON_HEIGHT + TOOLBAR_BORDER_HEIGHT; | |
4301 # endif | |
4302 # endif | |
4303 #endif | |
4304 | |
810 | 4305 #if defined(FEAT_GUI_TABLINE) && defined(FEAT_GUI_MSWIN) |
4306 if (gui_has_tabline()) | |
843 | 4307 y += gui.tabline_height; |
810 | 4308 #endif |
4309 | |
7 | 4310 if (wp->w_winrow == 0) |
4311 { | |
4312 /* Height of top scrollbar includes width of top border */ | |
4313 h += gui.border_offset; | |
4314 y -= gui.border_offset; | |
4315 } | |
4316 if (gui.which_scrollbars[SBAR_LEFT]) | |
4317 { | |
4318 gui_mch_set_scrollbar_pos(&wp->w_scrollbars[SBAR_LEFT], | |
4319 gui.left_sbar_x, y, | |
4320 gui.scrollbar_width, h); | |
4321 gui_do_scrollbar(wp, SBAR_LEFT, TRUE); | |
4322 } | |
4323 if (gui.which_scrollbars[SBAR_RIGHT]) | |
4324 { | |
4325 gui_mch_set_scrollbar_pos(&wp->w_scrollbars[SBAR_RIGHT], | |
4326 gui.right_sbar_x, y, | |
4327 gui.scrollbar_width, h); | |
4328 gui_do_scrollbar(wp, SBAR_RIGHT, TRUE); | |
4329 } | |
4330 } | |
4331 | |
4332 /* Reduce the number of calls to gui_mch_set_scrollbar_thumb() by | |
4333 * checking if the thumb moved at least a pixel. Only do this for | |
4334 * Athena, most other GUIs require the update anyway to make the | |
4335 * arrows work. */ | |
4336 #ifdef FEAT_GUI_ATHENA | |
4337 if (max == 0) | |
4338 y = 0; | |
4339 else | |
4340 y = (val * (sb->height + 2) * gui.char_height + max / 2) / max; | |
4341 if (force || sb->pixval != y || sb->size != size || sb->max != max) | |
4342 #else | |
4343 if (force || sb->value != val || sb->size != size || sb->max != max) | |
4344 #endif | |
4345 { | |
4346 /* Thumb of scrollbar has moved */ | |
4347 sb->value = val; | |
4348 #ifdef FEAT_GUI_ATHENA | |
4349 sb->pixval = y; | |
4350 #endif | |
4351 sb->size = size; | |
4352 sb->max = max; | |
674 | 4353 if (gui.which_scrollbars[SBAR_LEFT] |
4354 && (gui.dragged_sb != SBAR_LEFT || gui.dragged_wp != wp)) | |
7 | 4355 gui_mch_set_scrollbar_thumb(&wp->w_scrollbars[SBAR_LEFT], |
4356 val, size, max); | |
4357 if (gui.which_scrollbars[SBAR_RIGHT] | |
674 | 4358 && (gui.dragged_sb != SBAR_RIGHT || gui.dragged_wp != wp)) |
7 | 4359 gui_mch_set_scrollbar_thumb(&wp->w_scrollbars[SBAR_RIGHT], |
4360 val, size, max); | |
4361 } | |
4362 } | |
4363 prev_curwin = curwin; | |
4364 --hold_gui_events; | |
4365 } | |
4366 | |
4367 /* | |
4368 * Enable or disable a scrollbar. | |
4369 * Check for scrollbars for vertically split windows which are not enabled | |
4370 * sometimes. | |
4371 */ | |
4372 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4373 gui_do_scrollbar( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4374 win_T *wp, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4375 int which, /* SBAR_LEFT or SBAR_RIGHT */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4376 int enable) /* TRUE to enable scrollbar */ |
7 | 4377 { |
4378 int midcol = curwin->w_wincol + curwin->w_width / 2; | |
4379 int has_midcol = (wp->w_wincol <= midcol | |
4380 && wp->w_wincol + wp->w_width >= midcol); | |
4381 | |
4382 /* Only enable scrollbars that contain the middle column of the current | |
4383 * window. */ | |
4384 if (gui.which_scrollbars[SBAR_RIGHT] != gui.which_scrollbars[SBAR_LEFT]) | |
4385 { | |
4386 /* Scrollbars only on one side. Don't enable scrollbars that don't | |
4387 * contain the middle column of the current window. */ | |
4388 if (!has_midcol) | |
4389 enable = FALSE; | |
4390 } | |
4391 else | |
4392 { | |
4393 /* Scrollbars on both sides. Don't enable scrollbars that neither | |
4394 * contain the middle column of the current window nor are on the far | |
4395 * side. */ | |
4396 if (midcol > Columns / 2) | |
4397 { | |
4398 if (which == SBAR_LEFT ? wp->w_wincol != 0 : !has_midcol) | |
4399 enable = FALSE; | |
4400 } | |
4401 else | |
4402 { | |
4403 if (which == SBAR_RIGHT ? wp->w_wincol + wp->w_width != Columns | |
4404 : !has_midcol) | |
4405 enable = FALSE; | |
4406 } | |
4407 } | |
4408 gui_mch_enable_scrollbar(&wp->w_scrollbars[which], enable); | |
4409 } | |
4410 | |
4411 /* | |
4412 * Scroll a window according to the values set in the globals current_scrollbar | |
4413 * and scrollbar_value. Return TRUE if the cursor in the current window moved | |
4414 * or FALSE otherwise. | |
4415 */ | |
4416 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4417 gui_do_scroll(void) |
7 | 4418 { |
4419 win_T *wp, *save_wp; | |
4420 int i; | |
4421 long nlines; | |
4422 pos_T old_cursor; | |
4423 linenr_T old_topline; | |
4424 #ifdef FEAT_DIFF | |
4425 int old_topfill; | |
4426 #endif | |
4427 | |
4428 for (wp = firstwin, i = 0; i < current_scrollbar; wp = W_NEXT(wp), i++) | |
4429 if (wp == NULL) | |
4430 break; | |
4431 if (wp == NULL) | |
4432 /* Couldn't find window */ | |
4433 return FALSE; | |
4434 | |
4435 /* | |
4436 * Compute number of lines to scroll. If zero, nothing to do. | |
4437 */ | |
4438 nlines = (long)scrollbar_value + 1 - (long)wp->w_topline; | |
4439 if (nlines == 0) | |
4440 return FALSE; | |
4441 | |
4442 save_wp = curwin; | |
4443 old_topline = wp->w_topline; | |
4444 #ifdef FEAT_DIFF | |
4445 old_topfill = wp->w_topfill; | |
4446 #endif | |
4447 old_cursor = wp->w_cursor; | |
4448 curwin = wp; | |
4449 curbuf = wp->w_buffer; | |
4450 if (nlines < 0) | |
4451 scrolldown(-nlines, gui.dragged_wp == NULL); | |
4452 else | |
4453 scrollup(nlines, gui.dragged_wp == NULL); | |
4454 /* Reset dragged_wp after using it. "dragged_sb" will have been reset for | |
4455 * the mouse-up event already, but we still want it to behave like when | |
4456 * dragging. But not the next click in an arrow. */ | |
4457 if (gui.dragged_sb == SBAR_NONE) | |
4458 gui.dragged_wp = NULL; | |
4459 | |
4460 if (old_topline != wp->w_topline | |
4461 #ifdef FEAT_DIFF | |
4462 || old_topfill != wp->w_topfill | |
4463 #endif | |
4464 ) | |
4465 { | |
4466 if (p_so != 0) | |
4467 { | |
4468 cursor_correct(); /* fix window for 'so' */ | |
4469 update_topline(); /* avoid up/down jump */ | |
4470 } | |
4471 if (old_cursor.lnum != wp->w_cursor.lnum) | |
4472 coladvance(wp->w_curswant); | |
4473 wp->w_scbind_pos = wp->w_topline; | |
4474 } | |
4475 | |
519 | 4476 /* Make sure wp->w_leftcol and wp->w_skipcol are correct. */ |
4477 validate_cursor(); | |
4478 | |
7 | 4479 curwin = save_wp; |
4480 curbuf = save_wp->w_buffer; | |
4481 | |
4482 /* | |
4483 * Don't call updateWindow() when nothing has changed (it will overwrite | |
4484 * the status line!). | |
4485 */ | |
4486 if (old_topline != wp->w_topline | |
519 | 4487 || wp->w_redr_type != 0 |
7 | 4488 #ifdef FEAT_DIFF |
4489 || old_topfill != wp->w_topfill | |
4490 #endif | |
4491 ) | |
4492 { | |
1434 | 4493 int type = VALID; |
4494 | |
4495 #ifdef FEAT_INS_EXPAND | |
4496 if (pum_visible()) | |
4497 { | |
4498 type = NOT_VALID; | |
4499 wp->w_lines_valid = 0; | |
4500 } | |
4501 #endif | |
4502 /* Don't set must_redraw here, it may cause the popup menu to | |
4503 * disappear when losing focus after a scrollbar drag. */ | |
4504 if (wp->w_redr_type < type) | |
4505 wp->w_redr_type = type; | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
4506 mch_disable_flush(); |
7 | 4507 updateWindow(wp); /* update window, status line, and cmdline */ |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
4508 mch_enable_flush(); |
7 | 4509 } |
4510 | |
973 | 4511 #ifdef FEAT_INS_EXPAND |
4512 /* May need to redraw the popup menu. */ | |
4513 if (pum_visible()) | |
4514 pum_redraw(); | |
4515 #endif | |
4516 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10819
diff
changeset
|
4517 return (wp == curwin && !EQUAL_POS(curwin->w_cursor, old_cursor)); |
7 | 4518 } |
4519 | |
4520 | |
4521 /* | |
4522 * Horizontal scrollbar stuff: | |
4523 */ | |
4524 | |
4525 /* | |
4526 * Return length of line "lnum" for horizontal scrolling. | |
4527 */ | |
4528 static colnr_T | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4529 scroll_line_len(linenr_T lnum) |
7 | 4530 { |
4531 char_u *p; | |
4532 colnr_T col; | |
4533 int w; | |
4534 | |
4535 p = ml_get(lnum); | |
4536 col = 0; | |
4537 if (*p != NUL) | |
4538 for (;;) | |
4539 { | |
4540 w = chartabsize(p, col); | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
4541 MB_PTR_ADV(p); |
7 | 4542 if (*p == NUL) /* don't count the last character */ |
4543 break; | |
4544 col += w; | |
4545 } | |
4546 return col; | |
4547 } | |
4548 | |
4549 /* Remember which line is currently the longest, so that we don't have to | |
4550 * search for it when scrolling horizontally. */ | |
4551 static linenr_T longest_lnum = 0; | |
4552 | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4553 /* |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4554 * Find longest visible line number. If this is not possible (or not desired, |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4555 * by setting 'h' in "guioptions") then the current line number is returned. |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4556 */ |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4557 static linenr_T |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4558 gui_find_longest_lnum(void) |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4559 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4560 linenr_T ret = 0; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4561 |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4562 /* Calculate maximum for horizontal scrollbar. Check for reasonable |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4563 * line numbers, topline and botline can be invalid when displaying is |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4564 * postponed. */ |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4565 if (vim_strchr(p_go, GO_HORSCROLL) == NULL |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4566 && curwin->w_topline <= curwin->w_cursor.lnum |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4567 && curwin->w_botline > curwin->w_cursor.lnum |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4568 && curwin->w_botline <= curbuf->b_ml.ml_line_count + 1) |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4569 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4570 linenr_T lnum; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4571 colnr_T n; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4572 long max = 0; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4573 |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4574 /* Use maximum of all visible lines. Remember the lnum of the |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4575 * longest line, closest to the cursor line. Used when scrolling |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4576 * below. */ |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4577 for (lnum = curwin->w_topline; lnum < curwin->w_botline; ++lnum) |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4578 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4579 n = scroll_line_len(lnum); |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4580 if (n > (colnr_T)max) |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4581 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4582 max = n; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4583 ret = lnum; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4584 } |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4585 else if (n == (colnr_T)max |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4586 && abs((int)(lnum - curwin->w_cursor.lnum)) |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4587 < abs((int)(ret - curwin->w_cursor.lnum))) |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4588 ret = lnum; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4589 } |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4590 } |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4591 else |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4592 /* Use cursor line only. */ |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4593 ret = curwin->w_cursor.lnum; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4594 |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4595 return ret; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4596 } |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4597 |
7 | 4598 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4599 gui_update_horiz_scrollbar(int force) |
7 | 4600 { |
4601 long value, size, max; /* need 32 bit ints here */ | |
4602 | |
4603 if (!gui.which_scrollbars[SBAR_BOTTOM]) | |
4604 return; | |
4605 | |
4606 if (!force && gui.dragged_sb == SBAR_BOTTOM) | |
4607 return; | |
4608 | |
4609 if (!force && curwin->w_p_wrap && gui.prev_wrap) | |
4610 return; | |
4611 | |
4612 /* | |
4613 * It is possible for the cursor to be invalid if we're in the middle of | |
4614 * something (like changing files). If so, don't do anything for now. | |
4615 */ | |
4616 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
4617 { | |
4618 gui.bottom_sbar.value = -1; | |
4619 return; | |
4620 } | |
4621 | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4622 size = curwin->w_width; |
7 | 4623 if (curwin->w_p_wrap) |
4624 { | |
4625 value = 0; | |
4626 #ifdef SCROLL_PAST_END | |
4627 max = 0; | |
4628 #else | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4629 max = curwin->w_width - 1; |
7 | 4630 #endif |
4631 } | |
4632 else | |
4633 { | |
4634 value = curwin->w_leftcol; | |
4635 | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4636 longest_lnum = gui_find_longest_lnum(); |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4637 max = scroll_line_len(longest_lnum); |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4638 |
7 | 4639 #ifdef FEAT_VIRTUALEDIT |
4640 if (virtual_active()) | |
4641 { | |
4642 /* May move the cursor even further to the right. */ | |
4643 if (curwin->w_virtcol >= (colnr_T)max) | |
4644 max = curwin->w_virtcol; | |
4645 } | |
4646 #endif | |
4647 | |
4648 #ifndef SCROLL_PAST_END | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4649 max += curwin->w_width - 1; |
7 | 4650 #endif |
4651 /* The line number isn't scrolled, thus there is less space when | |
2178
c6f1aa1e9f32
Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents:
2065
diff
changeset
|
4652 * 'number' or 'relativenumber' is set (also for 'foldcolumn'). */ |
7 | 4653 size -= curwin_col_off(); |
4654 #ifndef SCROLL_PAST_END | |
4655 max -= curwin_col_off(); | |
4656 #endif | |
4657 } | |
4658 | |
4659 #ifndef SCROLL_PAST_END | |
4660 if (value > max - size + 1) | |
4661 value = max - size + 1; /* limit the value to allowable range */ | |
4662 #endif | |
4663 | |
4664 #ifdef FEAT_RIGHTLEFT | |
4665 if (curwin->w_p_rl) | |
4666 { | |
4667 value = max + 1 - size - value; | |
4668 if (value < 0) | |
4669 { | |
4670 size += value; | |
4671 value = 0; | |
4672 } | |
4673 } | |
4674 #endif | |
4675 if (!force && value == gui.bottom_sbar.value && size == gui.bottom_sbar.size | |
4676 && max == gui.bottom_sbar.max) | |
4677 return; | |
4678 | |
4679 gui.bottom_sbar.value = value; | |
4680 gui.bottom_sbar.size = size; | |
4681 gui.bottom_sbar.max = max; | |
4682 gui.prev_wrap = curwin->w_p_wrap; | |
4683 | |
4684 gui_mch_set_scrollbar_thumb(&gui.bottom_sbar, value, size, max); | |
4685 } | |
4686 | |
4687 /* | |
4688 * Do a horizontal scroll. Return TRUE if the cursor moved, FALSE otherwise. | |
4689 */ | |
4690 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4691 gui_do_horiz_scroll(long_u leftcol, int compute_longest_lnum) |
7 | 4692 { |
4693 /* no wrapping, no scrolling */ | |
4694 if (curwin->w_p_wrap) | |
4695 return FALSE; | |
4696 | |
2416
1a9c16dd76d4
Fix compiler warnings on 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents:
2409
diff
changeset
|
4697 if (curwin->w_leftcol == (colnr_T)leftcol) |
7 | 4698 return FALSE; |
4699 | |
2416
1a9c16dd76d4
Fix compiler warnings on 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents:
2409
diff
changeset
|
4700 curwin->w_leftcol = (colnr_T)leftcol; |
7 | 4701 |
4702 /* When the line of the cursor is too short, move the cursor to the | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4703 * longest visible line. */ |
7 | 4704 if (vim_strchr(p_go, GO_HORSCROLL) == NULL |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4705 && !virtual_active() |
2416
1a9c16dd76d4
Fix compiler warnings on 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents:
2409
diff
changeset
|
4706 && (colnr_T)leftcol > scroll_line_len(curwin->w_cursor.lnum)) |
7 | 4707 { |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4708 if (compute_longest_lnum) |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4709 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4710 curwin->w_cursor.lnum = gui_find_longest_lnum(); |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4711 curwin->w_cursor.col = 0; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4712 } |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4713 /* Do a sanity check on "longest_lnum", just in case. */ |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4714 else if (longest_lnum >= curwin->w_topline |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4715 && longest_lnum < curwin->w_botline) |
7 | 4716 { |
4717 curwin->w_cursor.lnum = longest_lnum; | |
4718 curwin->w_cursor.col = 0; | |
4719 } | |
4720 } | |
4721 | |
4722 return leftcol_changed(); | |
4723 } | |
4724 | |
4725 /* | |
4726 * Check that none of the colors are the same as the background color | |
4727 */ | |
4728 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4729 gui_check_colors(void) |
7 | 4730 { |
4731 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) | |
4732 { | |
4733 gui_set_bg_color((char_u *)"White"); | |
4734 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) | |
4735 gui_set_fg_color((char_u *)"Black"); | |
4736 } | |
4737 } | |
4738 | |
203 | 4739 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4740 gui_set_fg_color(char_u *name) |
7 | 4741 { |
4742 gui.norm_pixel = gui_get_color(name); | |
4743 hl_set_fg_color_name(vim_strsave(name)); | |
4744 } | |
4745 | |
203 | 4746 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4747 gui_set_bg_color(char_u *name) |
7 | 4748 { |
4749 gui.back_pixel = gui_get_color(name); | |
4750 hl_set_bg_color_name(vim_strsave(name)); | |
4751 } | |
4752 | |
4753 /* | |
4754 * Allocate a color by name. | |
4755 * Returns INVALCOLOR and gives an error message when failed. | |
4756 */ | |
4757 guicolor_T | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4758 gui_get_color(char_u *name) |
7 | 4759 { |
4760 guicolor_T t; | |
4761 | |
4762 if (*name == NUL) | |
4763 return INVALCOLOR; | |
4764 t = gui_mch_get_color(name); | |
11 | 4765 |
7 | 4766 if (t == INVALCOLOR |
574 | 4767 #if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) |
7 | 4768 && gui.in_use |
4769 #endif | |
4770 ) | |
4771 EMSG2(_("E254: Cannot allocate color %s"), name); | |
4772 return t; | |
4773 } | |
4774 | |
4775 /* | |
4776 * Return the grey value of a color (range 0-255). | |
4777 */ | |
4778 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4779 gui_get_lightness(guicolor_T pixel) |
7 | 4780 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9848
diff
changeset
|
4781 long_u rgb = (long_u)gui_mch_get_rgb(pixel); |
7 | 4782 |
835 | 4783 return (int)( (((rgb >> 16) & 0xff) * 299) |
856 | 4784 + (((rgb >> 8) & 0xff) * 587) |
4785 + ((rgb & 0xff) * 114)) / 1000; | |
7 | 4786 } |
4787 | |
4788 #if defined(FEAT_GUI_X11) || defined(PROTO) | |
4789 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4790 gui_new_scrollbar_colors(void) |
7 | 4791 { |
4792 win_T *wp; | |
4793 | |
4794 /* Nothing to do if GUI hasn't started yet. */ | |
4795 if (!gui.in_use) | |
4796 return; | |
4797 | |
4798 FOR_ALL_WINDOWS(wp) | |
4799 { | |
4800 gui_mch_set_scrollbar_colors(&(wp->w_scrollbars[SBAR_LEFT])); | |
4801 gui_mch_set_scrollbar_colors(&(wp->w_scrollbars[SBAR_RIGHT])); | |
4802 } | |
4803 gui_mch_set_scrollbar_colors(&gui.bottom_sbar); | |
4804 } | |
4805 #endif | |
4806 | |
4807 /* | |
4808 * Call this when focus has changed. | |
4809 */ | |
4810 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4811 gui_focus_change(int in_focus) |
7 | 4812 { |
4813 /* | |
4814 * Skip this code to avoid drawing the cursor when debugging and switching | |
4815 * between the debugger window and gvim. | |
4816 */ | |
4817 #if 1 | |
4818 gui.in_focus = in_focus; | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
4819 out_flush_cursor(TRUE, FALSE); |
7 | 4820 |
4821 # ifdef FEAT_XIM | |
4822 xim_set_focus(in_focus); | |
4823 # endif | |
4824 | |
1380 | 4825 /* Put events in the input queue only when allowed. |
4826 * ui_focus_change() isn't called directly, because it invokes | |
4827 * autocommands and that must not happen asynchronously. */ | |
4828 if (!hold_gui_events) | |
4829 { | |
4830 char_u bytes[3]; | |
4831 | |
4832 bytes[0] = CSI; | |
4833 bytes[1] = KS_EXTRA; | |
4834 bytes[2] = in_focus ? (int)KE_FOCUSGAINED : (int)KE_FOCUSLOST; | |
4835 add_to_input_buf(bytes, 3); | |
4836 } | |
7 | 4837 #endif |
4838 } | |
4839 | |
4840 /* | |
4841 * Called when the mouse moved (but not when dragging). | |
4842 */ | |
4843 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4844 gui_mouse_moved(int x, int y) |
7 | 4845 { |
4846 win_T *wp; | |
894 | 4847 char_u st[8]; |
7 | 4848 |
771 | 4849 /* Ignore this while still starting up. */ |
4850 if (!gui.in_use || gui.starting) | |
4851 return; | |
4852 | |
7 | 4853 #ifdef FEAT_MOUSESHAPE |
4854 /* Get window pointer, and update mouse shape as well. */ | |
4855 wp = xy2win(x, y); | |
4856 #endif | |
4857 | |
4858 /* Only handle this when 'mousefocus' set and ... */ | |
4859 if (p_mousef | |
4860 && !hold_gui_events /* not holding events */ | |
4861 && (State & (NORMAL|INSERT))/* Normal/Visual/Insert mode */ | |
4862 && State != HITRETURN /* but not hit-return prompt */ | |
4863 && msg_scrolled == 0 /* no scrolled message */ | |
4864 && !need_mouse_correct /* not moving the pointer */ | |
4865 && gui.in_focus) /* gvim in focus */ | |
4866 { | |
4867 /* Don't move the mouse when it's left or right of the Vim window */ | |
4868 if (x < 0 || x > Columns * gui.char_width) | |
4869 return; | |
4870 #ifndef FEAT_MOUSESHAPE | |
4871 wp = xy2win(x, y); | |
4872 #endif | |
4873 if (wp == curwin || wp == NULL) | |
4874 return; /* still in the same old window, or none at all */ | |
4875 | |
859 | 4876 /* Ignore position in the tab pages line. */ |
4877 if (Y_2_ROW(y) < tabline_height()) | |
4878 return; | |
4879 | |
7 | 4880 /* |
4881 * format a mouse click on status line input | |
4882 * ala gui_send_mouse_event(0, x, y, 0, 0); | |
261 | 4883 * Trick: Use a column number -1, so that get_pseudo_mouse_code() will |
4884 * generate a K_LEFTMOUSE_NM key code. | |
7 | 4885 */ |
4886 if (finish_op) | |
4887 { | |
4888 /* abort the current operator first */ | |
4889 st[0] = ESC; | |
4890 add_to_input_buf(st, 1); | |
4891 } | |
4892 st[0] = CSI; | |
4893 st[1] = KS_MOUSE; | |
4894 st[2] = KE_FILLER; | |
4895 st[3] = (char_u)MOUSE_LEFT; | |
4896 fill_mouse_coord(st + 4, | |
261 | 4897 wp->w_wincol == 0 ? -1 : wp->w_wincol + MOUSE_COLOFF, |
7 | 4898 wp->w_height + W_WINROW(wp)); |
4899 | |
4900 add_to_input_buf(st, 8); | |
4901 st[3] = (char_u)MOUSE_RELEASE; | |
4902 add_to_input_buf(st, 8); | |
4903 #ifdef FEAT_GUI_GTK | |
4904 /* Need to wake up the main loop */ | |
4905 if (gtk_main_level() > 0) | |
4906 gtk_main_quit(); | |
4907 #endif | |
4908 } | |
4909 } | |
4910 | |
4911 /* | |
4912 * Called when mouse should be moved to window with focus. | |
4913 */ | |
4914 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4915 gui_mouse_correct(void) |
7 | 4916 { |
4917 int x, y; | |
4918 win_T *wp = NULL; | |
4919 | |
4920 need_mouse_correct = FALSE; | |
87 | 4921 |
4922 if (!(gui.in_use && p_mousef)) | |
4923 return; | |
4924 | |
4925 gui_mch_getmouse(&x, &y); | |
4926 /* Don't move the mouse when it's left or right of the Vim window */ | |
4927 if (x < 0 || x > Columns * gui.char_width) | |
4928 return; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
4929 if (y >= 0 && Y_2_ROW(y) >= tabline_height()) |
87 | 4930 wp = xy2win(x, y); |
4931 if (wp != curwin && wp != NULL) /* If in other than current window */ | |
7 | 4932 { |
87 | 4933 validate_cline_row(); |
4934 gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3, | |
4935 (W_WINROW(curwin) + curwin->w_wrow) * gui.char_height | |
7 | 4936 + (gui.char_height) / 2); |
4937 } | |
4938 } | |
4939 | |
4940 /* | |
12136
60cf03e59402
patch 8.0.0948: crash if timer closes window while dragging status line
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
4941 * Find window where the mouse pointer "x" / "y" coordinate is in. |
7 | 4942 */ |
4943 static win_T * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4944 xy2win(int x UNUSED, int y UNUSED) |
7 | 4945 { |
4946 int row; | |
4947 int col; | |
4948 win_T *wp; | |
4949 | |
4950 row = Y_2_ROW(y); | |
4951 col = X_2_COL(x); | |
4952 if (row < 0 || col < 0) /* before first window */ | |
4953 return NULL; | |
4954 wp = mouse_find_win(&row, &col); | |
12136
60cf03e59402
patch 8.0.0948: crash if timer closes window while dragging status line
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
4955 if (wp == NULL) |
60cf03e59402
patch 8.0.0948: crash if timer closes window while dragging status line
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
4956 return NULL; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
4957 #ifdef FEAT_MOUSESHAPE |
7 | 4958 if (State == HITRETURN || State == ASKMORE) |
4959 { | |
4960 if (Y_2_ROW(y) >= msg_row) | |
4961 update_mouseshape(SHAPE_IDX_MOREL); | |
4962 else | |
4963 update_mouseshape(SHAPE_IDX_MORE); | |
4964 } | |
4965 else if (row > wp->w_height) /* below status line */ | |
4966 update_mouseshape(SHAPE_IDX_CLINE); | |
12529
158917d728b4
patch 8.0.1143: macros always expand to the same thing
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
4967 else if (!(State & CMDLINE) && wp->w_vsep_width > 0 && col == wp->w_width |
819 | 4968 && (row != wp->w_height || !stl_connected(wp)) && msg_scrolled == 0) |
7 | 4969 update_mouseshape(SHAPE_IDX_VSEP); |
12529
158917d728b4
patch 8.0.1143: macros always expand to the same thing
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
4970 else if (!(State & CMDLINE) && wp->w_status_height > 0 |
819 | 4971 && row == wp->w_height && msg_scrolled == 0) |
7 | 4972 update_mouseshape(SHAPE_IDX_STATUS); |
4973 else | |
4974 update_mouseshape(-2); | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
4975 #endif |
7 | 4976 return wp; |
4977 } | |
4978 | |
4979 /* | |
4980 * ":gui" and ":gvim": Change from the terminal version to the GUI version. | |
4981 * File names may be given to redefine the args list. | |
4982 */ | |
4983 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4984 ex_gui(exarg_T *eap) |
7 | 4985 { |
4986 char_u *arg = eap->arg; | |
4987 | |
4988 /* | |
4989 * Check for "-f" argument: foreground, don't fork. | |
4990 * Also don't fork when started with "gvim -f". | |
4991 * Do fork when using "gui -b". | |
4992 */ | |
4993 if (arg[0] == '-' | |
4994 && (arg[1] == 'f' || arg[1] == 'b') | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
4995 && (arg[2] == NUL || VIM_ISWHITE(arg[2]))) |
7 | 4996 { |
4997 gui.dofork = (arg[1] == 'b'); | |
4998 eap->arg = skipwhite(eap->arg + 2); | |
4999 } | |
5000 if (!gui.in_use) | |
5001 { | |
5002 /* Clear the command. Needed for when forking+exiting, to avoid part | |
5003 * of the argument ending up after the shell prompt. */ | |
5004 msg_clr_eos_force(); | |
5005 gui_start(); | |
8493
caed4b2d305f
commit https://github.com/vim/vim/commit/509ce2a558e7e0c03242e32e844255af52f1c821
Christian Brabandt <cb@256bit.org>
parents:
8140
diff
changeset
|
5006 #ifdef FEAT_JOB_CHANNEL |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7469
diff
changeset
|
5007 channel_gui_register_all(); |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2208
diff
changeset
|
5008 #endif |
7 | 5009 } |
5010 if (!ends_excmd(*eap->arg)) | |
5011 ex_next(eap); | |
5012 } | |
5013 | |
5014 #if ((defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) \ | |
574 | 5015 || defined(FEAT_GUI_PHOTON)) && defined(FEAT_TOOLBAR)) || defined(PROTO) |
7 | 5016 /* |
5017 * This is shared between Athena, Motif and GTK. | |
5018 */ | |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
5019 static void gfp_setname(char_u *fname, void *cookie); |
7 | 5020 |
5021 /* | |
5022 * Callback function for do_in_runtimepath(). | |
5023 */ | |
5024 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5025 gfp_setname(char_u *fname, void *cookie) |
7 | 5026 { |
236 | 5027 char_u *gfp_buffer = cookie; |
5028 | |
7 | 5029 if (STRLEN(fname) >= MAXPATHL) |
5030 *gfp_buffer = NUL; | |
5031 else | |
5032 STRCPY(gfp_buffer, fname); | |
5033 } | |
5034 | |
5035 /* | |
5036 * Find the path of bitmap "name" with extension "ext" in 'runtimepath'. | |
5037 * Return FAIL for failure and OK if buffer[MAXPATHL] contains the result. | |
5038 */ | |
5039 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5040 gui_find_bitmap(char_u *name, char_u *buffer, char *ext) |
7 | 5041 { |
5042 if (STRLEN(name) > MAXPATHL - 14) | |
5043 return FAIL; | |
273 | 5044 vim_snprintf((char *)buffer, MAXPATHL, "bitmaps/%s.%s", name, ext); |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8493
diff
changeset
|
5045 if (do_in_runtimepath(buffer, 0, gfp_setname, buffer) == FAIL |
236 | 5046 || *buffer == NUL) |
7 | 5047 return FAIL; |
5048 return OK; | |
5049 } | |
5050 | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
5051 # if !defined(FEAT_GUI_GTK) || defined(PROTO) |
7 | 5052 /* |
5053 * Given the name of the "icon=" argument, try finding the bitmap file for the | |
5054 * icon. If it is an absolute path name, use it as it is. Otherwise append | |
5055 * "ext" and search for it in 'runtimepath'. | |
5056 * The result is put in "buffer[MAXPATHL]". If something fails "buffer" | |
5057 * contains "name". | |
5058 */ | |
5059 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5060 gui_find_iconfile(char_u *name, char_u *buffer, char *ext) |
7 | 5061 { |
5062 char_u buf[MAXPATHL + 1]; | |
5063 | |
5064 expand_env(name, buffer, MAXPATHL); | |
5065 if (!mch_isFullName(buffer) && gui_find_bitmap(buffer, buf, ext) == OK) | |
5066 STRCPY(buffer, buf); | |
5067 } | |
5068 # endif | |
5069 #endif | |
5070 | |
574 | 5071 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(PROTO) |
7 | 5072 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5073 display_errors(void) |
7 | 5074 { |
5075 char_u *p; | |
5076 | |
5077 if (isatty(2)) | |
5078 fflush(stderr); | |
5079 else if (error_ga.ga_data != NULL) | |
5080 { | |
5081 /* avoid putting up a message box with blanks only */ | |
5082 for (p = (char_u *)error_ga.ga_data; *p != NUL; ++p) | |
5083 if (!isspace(*p)) | |
5084 { | |
5085 /* Truncate a very long message, it will go off-screen. */ | |
5086 if (STRLEN(p) > 2000) | |
5087 STRCPY(p + 2000 - 14, "...(truncated)"); | |
5088 (void)do_dialog(VIM_ERROR, (char_u *)_("Error"), | |
2684 | 5089 p, (char_u *)_("&Ok"), 1, NULL, FALSE); |
7 | 5090 break; |
5091 } | |
5092 ga_clear(&error_ga); | |
5093 } | |
5094 } | |
5095 #endif | |
5096 | |
5097 #if defined(NO_CONSOLE_INPUT) || defined(PROTO) | |
5098 /* | |
5099 * Return TRUE if still starting up and there is no place to enter text. | |
5100 * For GTK and X11 we check if stderr is not a tty, which means we were | |
5101 * (probably) started from the desktop. Also check stdin, "vim >& file" does | |
5102 * allow typing on stdin. | |
5103 */ | |
5104 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5105 no_console_input(void) |
7 | 5106 { |
5107 return ((!gui.in_use || gui.starting) | |
5108 # ifndef NO_CONSOLE | |
5109 && !isatty(0) && !isatty(2) | |
5110 # endif | |
5111 ); | |
5112 } | |
5113 #endif | |
5114 | |
28 | 5115 #if defined(FIND_REPLACE_DIALOG) || defined(FEAT_SUN_WORKSHOP) \ |
1002 | 5116 || defined(NEED_GUI_UPDATE_SCREEN) \ |
28 | 5117 || defined(PROTO) |
7 | 5118 /* |
5119 * Update the current window and the screen. | |
5120 */ | |
5121 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5122 gui_update_screen(void) |
7 | 5123 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5124 # ifdef FEAT_CONCEAL |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5125 linenr_T conceal_old_cursor_line = 0; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5126 linenr_T conceal_new_cursor_line = 0; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5127 int conceal_update_lines = FALSE; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5128 # endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5129 |
7 | 5130 update_topline(); |
5131 validate_cursor(); | |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5132 |
1584 | 5133 /* Trigger CursorMoved if the cursor moved. */ |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5134 if (!finish_op && (has_cursormoved() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5135 # ifdef FEAT_CONCEAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5136 || curwin->w_p_cole > 0 |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5137 # endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5138 ) && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) |
1584 | 5139 { |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5140 if (has_cursormoved()) |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5141 apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf); |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5142 # ifdef FEAT_CONCEAL |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5143 if (curwin->w_p_cole > 0) |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5144 { |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5145 conceal_old_cursor_line = last_cursormoved.lnum; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5146 conceal_new_cursor_line = curwin->w_cursor.lnum; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5147 conceal_update_lines = TRUE; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5148 } |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5149 # endif |
1584 | 5150 last_cursormoved = curwin->w_cursor; |
5151 } | |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5152 |
7 | 5153 update_screen(0); /* may need to update the screen */ |
5154 setcursor(); | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5155 # ifdef FEAT_CONCEAL |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5156 if (conceal_update_lines |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5157 && (conceal_old_cursor_line != conceal_new_cursor_line |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5158 || conceal_cursor_line(curwin) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5159 || need_cursor_line_redraw)) |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5160 { |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5161 if (conceal_old_cursor_line != conceal_new_cursor_line) |
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5162 update_single_line(curwin, conceal_old_cursor_line); |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5163 update_single_line(curwin, conceal_new_cursor_line); |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5164 curwin->w_valid &= ~VALID_CROW; |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5165 } |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5166 # endif |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
5167 out_flush_cursor(TRUE, FALSE); |
7 | 5168 } |
5169 #endif | |
5170 | |
28 | 5171 #if defined(FIND_REPLACE_DIALOG) || defined(PROTO) |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
5172 static void concat_esc(garray_T *gap, char_u *text, int what); |
7 | 5173 |
5174 /* | |
5175 * Get the text to use in a find/replace dialog. Uses the last search pattern | |
5176 * if the argument is empty. | |
5177 * Returns an allocated string. | |
5178 */ | |
5179 char_u * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5180 get_find_dialog_text( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5181 char_u *arg, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5182 int *wwordp, /* return: TRUE if \< \> found */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5183 int *mcasep) /* return: TRUE if \C found */ |
7 | 5184 { |
5185 char_u *text; | |
5186 | |
5187 if (*arg == NUL) | |
5188 text = last_search_pat(); | |
5189 else | |
5190 text = arg; | |
5191 if (text != NULL) | |
5192 { | |
5193 text = vim_strsave(text); | |
5194 if (text != NULL) | |
5195 { | |
835 | 5196 int len = (int)STRLEN(text); |
7 | 5197 int i; |
5198 | |
5199 /* Remove "\V" */ | |
5200 if (len >= 2 && STRNCMP(text, "\\V", 2) == 0) | |
5201 { | |
5202 mch_memmove(text, text + 2, (size_t)(len - 1)); | |
5203 len -= 2; | |
5204 } | |
5205 | |
5206 /* Recognize "\c" and "\C" and remove. */ | |
5207 if (len >= 2 && *text == '\\' && (text[1] == 'c' || text[1] == 'C')) | |
5208 { | |
5209 *mcasep = (text[1] == 'C'); | |
5210 mch_memmove(text, text + 2, (size_t)(len - 1)); | |
5211 len -= 2; | |
5212 } | |
5213 | |
5214 /* Recognize "\<text\>" and remove. */ | |
5215 if (len >= 4 | |
5216 && STRNCMP(text, "\\<", 2) == 0 | |
5217 && STRNCMP(text + len - 2, "\\>", 2) == 0) | |
5218 { | |
5219 *wwordp = TRUE; | |
5220 mch_memmove(text, text + 2, (size_t)(len - 4)); | |
5221 text[len - 4] = NUL; | |
5222 } | |
5223 | |
5224 /* Recognize "\/" or "\?" and remove. */ | |
5225 for (i = 0; i + 1 < len; ++i) | |
5226 if (text[i] == '\\' && (text[i + 1] == '/' | |
5227 || text[i + 1] == '?')) | |
5228 { | |
5229 mch_memmove(text + i, text + i + 1, (size_t)(len - i)); | |
5230 --len; | |
5231 } | |
5232 } | |
5233 } | |
5234 return text; | |
5235 } | |
5236 | |
5237 /* | |
5238 * Concatenate "text" to grow array "gap", escaping "what" with a backslash. | |
5239 */ | |
5240 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5241 concat_esc(garray_T *gap, char_u *text, int what) |
7 | 5242 { |
5243 while (*text != NUL) | |
5244 { | |
5245 #ifdef FEAT_MBYTE | |
474 | 5246 int l = (*mb_ptr2len)(text); |
819 | 5247 |
7 | 5248 if (l > 1) |
5249 { | |
5250 while (--l >= 0) | |
5251 ga_append(gap, *text++); | |
5252 continue; | |
5253 } | |
5254 #endif | |
5255 if (*text == what) | |
5256 ga_append(gap, '\\'); | |
5257 ga_append(gap, *text); | |
5258 ++text; | |
5259 } | |
5260 } | |
5261 | |
5262 /* | |
5263 * Handle the press of a button in the find-replace dialog. | |
5264 * Return TRUE when something was added to the input buffer. | |
5265 */ | |
5266 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5267 gui_do_findrepl( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5268 int flags, /* one of FRD_REPLACE, FRD_FINDNEXT, etc. */ |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5269 char_u *find_text, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5270 char_u *repl_text, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5271 int down) /* Search downwards. */ |
7 | 5272 { |
5273 garray_T ga; | |
5274 int i; | |
5275 int type = (flags & FRD_TYPE_MASK); | |
5276 char_u *p; | |
28 | 5277 regmatch_T regmatch; |
482 | 5278 int save_did_emsg = did_emsg; |
1943 | 5279 static int busy = FALSE; |
5280 | |
5281 /* When the screen is being updated we should not change buffers and | |
5282 * windows structures, it may cause freed memory to be used. Also don't | |
5283 * do this recursively (pressing "Find" quickly several times. */ | |
5284 if (updating_screen || busy) | |
5285 return FALSE; | |
5286 | |
5287 /* refuse replace when text cannot be changed */ | |
5288 if ((type == FRD_REPLACE || type == FRD_REPLACEALL) && text_locked()) | |
5289 return FALSE; | |
5290 | |
5291 busy = TRUE; | |
7 | 5292 |
5293 ga_init2(&ga, 1, 100); | |
28 | 5294 if (type == FRD_REPLACEALL) |
7 | 5295 ga_concat(&ga, (char_u *)"%s/"); |
5296 | |
5297 ga_concat(&ga, (char_u *)"\\V"); | |
5298 if (flags & FRD_MATCH_CASE) | |
5299 ga_concat(&ga, (char_u *)"\\C"); | |
5300 else | |
5301 ga_concat(&ga, (char_u *)"\\c"); | |
5302 if (flags & FRD_WHOLE_WORD) | |
5303 ga_concat(&ga, (char_u *)"\\<"); | |
5304 if (type == FRD_REPLACEALL || down) | |
5305 concat_esc(&ga, find_text, '/'); /* escape slashes */ | |
5306 else | |
5307 concat_esc(&ga, find_text, '?'); /* escape '?' */ | |
5308 if (flags & FRD_WHOLE_WORD) | |
5309 ga_concat(&ga, (char_u *)"\\>"); | |
5310 | |
5311 if (type == FRD_REPLACEALL) | |
5312 { | |
28 | 5313 ga_concat(&ga, (char_u *)"/"); |
694 | 5314 /* escape / and \ */ |
5315 p = vim_strsave_escaped(repl_text, (char_u *)"/\\"); | |
5316 if (p != NULL) | |
5317 ga_concat(&ga, p); | |
5318 vim_free(p); | |
28 | 5319 ga_concat(&ga, (char_u *)"/g"); |
5320 } | |
5321 ga_append(&ga, NUL); | |
5322 | |
5323 if (type == FRD_REPLACE) | |
5324 { | |
5325 /* Do the replacement when the text at the cursor matches. Thus no | |
5326 * replacement is done if the cursor was moved! */ | |
5327 regmatch.regprog = vim_regcomp(ga.ga_data, RE_MAGIC + RE_STRING); | |
5328 regmatch.rm_ic = 0; | |
5329 if (regmatch.regprog != NULL) | |
5330 { | |
5331 p = ml_get_cursor(); | |
5332 if (vim_regexec_nl(®match, p, (colnr_T)0) | |
5333 && regmatch.startp[0] == p) | |
5334 { | |
5335 /* Clear the command line to remove any old "No match" | |
5336 * error. */ | |
5337 msg_end_prompt(); | |
5338 | |
5339 if (u_save_cursor() == OK) | |
5340 { | |
5341 /* A button was pressed thus undo should be synced. */ | |
825 | 5342 u_sync(FALSE); |
28 | 5343 |
5344 del_bytes((long)(regmatch.endp[0] - regmatch.startp[0]), | |
609 | 5345 FALSE, FALSE); |
28 | 5346 ins_str(repl_text); |
5347 } | |
5348 } | |
5349 else | |
5350 MSG(_("No match at cursor, finding next")); | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5351 vim_regfree(regmatch.regprog); |
28 | 5352 } |
5353 } | |
5354 | |
5355 if (type == FRD_REPLACEALL) | |
5356 { | |
7 | 5357 /* A button was pressed, thus undo should be synced. */ |
825 | 5358 u_sync(FALSE); |
7 | 5359 do_cmdline_cmd(ga.ga_data); |
5360 } | |
5361 else | |
5362 { | |
9305
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5363 int searchflags = SEARCH_MSG + SEARCH_MARK; |
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5364 |
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5365 /* Search for the next match. |
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5366 * Don't skip text under cursor for single replace. */ |
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5367 if (type == FRD_REPLACE) |
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5368 searchflags += SEARCH_START; |
7 | 5369 i = msg_scroll; |
7009 | 5370 (void)do_search(NULL, down ? '/' : '?', ga.ga_data, 1L, |
11521
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11471
diff
changeset
|
5371 searchflags, NULL, NULL); |
7 | 5372 msg_scroll = i; /* don't let an error message set msg_scroll */ |
5373 } | |
5374 | |
482 | 5375 /* Don't want to pass did_emsg to other code, it may cause disabling |
5376 * syntax HL if we were busy redrawing. */ | |
5377 did_emsg = save_did_emsg; | |
5378 | |
7 | 5379 if (State & (NORMAL | INSERT)) |
5380 { | |
5381 gui_update_screen(); /* update the screen */ | |
5382 msg_didout = 0; /* overwrite any message */ | |
5383 need_wait_return = FALSE; /* don't wait for return */ | |
5384 } | |
5385 | |
5386 vim_free(ga.ga_data); | |
1943 | 5387 busy = FALSE; |
7 | 5388 return (ga.ga_len > 0); |
5389 } | |
5390 | |
5391 #endif | |
5392 | |
5393 #if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \ | |
5394 || defined(FEAT_GUI_MSWIN) \ | |
5395 || defined(FEAT_GUI_MAC) \ | |
5396 || defined(PROTO) | |
5397 | |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7770
diff
changeset
|
5398 static void gui_wingoto_xy(int x, int y); |
7 | 5399 |
5400 /* | |
5401 * Jump to the window at specified point (x, y). | |
5402 */ | |
5403 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5404 gui_wingoto_xy(int x, int y) |
7 | 5405 { |
5406 int row = Y_2_ROW(y); | |
5407 int col = X_2_COL(x); | |
5408 win_T *wp; | |
5409 | |
5410 if (row >= 0 && col >= 0) | |
5411 { | |
5412 wp = mouse_find_win(&row, &col); | |
5413 if (wp != NULL && wp != curwin) | |
5414 win_goto(wp); | |
5415 } | |
5416 } | |
5417 | |
5418 /* | |
5419 * Process file drop. Mouse cursor position, key modifiers, name of files | |
5420 * and count of files are given. Argument "fnames[count]" has full pathnames | |
5421 * of dropped files, they will be freed in this function, and caller can't use | |
5422 * fnames after call this function. | |
5423 */ | |
5424 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5425 gui_handle_drop( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5426 int x UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5427 int y UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5428 int_u modifiers, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5429 char_u **fnames, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5430 int count) |
7 | 5431 { |
5432 int i; | |
5433 char_u *p; | |
1668 | 5434 static int entered = FALSE; |
5435 | |
5436 /* | |
5437 * This function is called by event handlers. Just in case we get a | |
5438 * second event before the first one is handled, ignore the second one. | |
5439 * Not sure if this can ever happen, just in case. | |
5440 */ | |
5441 if (entered) | |
5442 return; | |
5443 entered = TRUE; | |
7 | 5444 |
5445 /* | |
5446 * When the cursor is at the command line, add the file names to the | |
5447 * command line, don't edit the files. | |
5448 */ | |
5449 if (State & CMDLINE) | |
5450 { | |
5451 shorten_filenames(fnames, count); | |
5452 for (i = 0; i < count; ++i) | |
5453 { | |
5454 if (fnames[i] != NULL) | |
5455 { | |
5456 if (i > 0) | |
5457 add_to_input_buf((char_u*)" ", 1); | |
5458 | |
5459 /* We don't know what command is used thus we can't be sure | |
5460 * about which characters need to be escaped. Only escape the | |
5461 * most common ones. */ | |
5462 # ifdef BACKSLASH_IN_FILENAME | |
5463 p = vim_strsave_escaped(fnames[i], (char_u *)" \t\"|"); | |
5464 # else | |
5465 p = vim_strsave_escaped(fnames[i], (char_u *)"\\ \t\"|"); | |
5466 # endif | |
5467 if (p != NULL) | |
1364 | 5468 add_to_input_buf_csi(p, (int)STRLEN(p)); |
7 | 5469 vim_free(p); |
5470 vim_free(fnames[i]); | |
5471 } | |
5472 } | |
5473 vim_free(fnames); | |
5474 } | |
5475 else | |
5476 { | |
5477 /* Go to the window under mouse cursor, then shorten given "fnames" by | |
5478 * current window, because a window can have local current dir. */ | |
5479 gui_wingoto_xy(x, y); | |
5480 shorten_filenames(fnames, count); | |
5481 | |
5482 /* If Shift held down, remember the first item. */ | |
5483 if ((modifiers & MOUSE_SHIFT) != 0) | |
5484 p = vim_strsave(fnames[0]); | |
5485 else | |
5486 p = NULL; | |
5487 | |
5488 /* Handle the drop, :edit or :split to get to the file. This also | |
5489 * frees fnames[]. Skip this if there is only one item it's a | |
5490 * directory and Shift is held down. */ | |
5491 if (count == 1 && (modifiers & MOUSE_SHIFT) != 0 | |
5492 && mch_isdir(fnames[0])) | |
5493 { | |
5494 vim_free(fnames[0]); | |
5495 vim_free(fnames); | |
5496 } | |
5497 else | |
5498 handle_drop(count, fnames, (modifiers & MOUSE_CTRL) != 0); | |
5499 | |
5500 /* If Shift held down, change to first file's directory. If the first | |
5501 * item is a directory, change to that directory (and let the explorer | |
5502 * plugin show the contents). */ | |
5503 if (p != NULL) | |
5504 { | |
5505 if (mch_isdir(p)) | |
5506 { | |
5507 if (mch_chdir((char *)p) == 0) | |
5508 shorten_fnames(TRUE); | |
5509 } | |
13176
bd1253c60938
patch 8.0.1462: missing yet another file in patch
Christian Brabandt <cb@256bit.org>
parents:
13152
diff
changeset
|
5510 else if (vim_chdirfile(p, "drop") == OK) |
7 | 5511 shorten_fnames(TRUE); |
5512 vim_free(p); | |
5513 } | |
5514 | |
5515 /* Update the screen display */ | |
5516 update_screen(NOT_VALID); | |
5517 # ifdef FEAT_MENU | |
5518 gui_update_menus(0); | |
5519 # endif | |
2208
495995b9ce7d
Fix: window title not updated after file dropped.
Bram Moolenaar <bram@vim.org>
parents:
2178
diff
changeset
|
5520 #ifdef FEAT_TITLE |
495995b9ce7d
Fix: window title not updated after file dropped.
Bram Moolenaar <bram@vim.org>
parents:
2178
diff
changeset
|
5521 maketitle(); |
495995b9ce7d
Fix: window title not updated after file dropped.
Bram Moolenaar <bram@vim.org>
parents:
2178
diff
changeset
|
5522 #endif |
7 | 5523 setcursor(); |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
5524 out_flush_cursor(FALSE, FALSE); |
7 | 5525 } |
1668 | 5526 |
5527 entered = FALSE; | |
7 | 5528 } |
5529 #endif |