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