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