Mercurial > vim
annotate src/gui.c @ 27521:3ad379c0ab28 v8.2.4288
patch 8.2.4288: preprocessor indents are inconsistent
Commit: https://github.com/vim/vim/commit/6e1d31e9e3ca42cb883abca198f011dc6f4ceb14
Author: K.Takata <kentkt@csc.jp>
Date: Thu Feb 3 13:05:32 2022 +0000
patch 8.2.4288: preprocessor indents are inconsistent
Problem: Preprocessor indents are inconsistent.
Solution: Fix preprocessor indents. (Ken Takata, closes https://github.com/vim/vim/issues/9691)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 03 Feb 2022 14:15:03 +0100 |
parents | fb4c30606b4a |
children | d27a9eed9849 |
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 |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
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); |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
299 # endif |
3518 | 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; |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
351 # define READ_BUFFER_SIZE 10 |
3147 | 352 char buffer[READ_BUFFER_SIZE]; |
353 | |
354 bytes_read = read_eintr(fd, buffer, READ_BUFFER_SIZE - 1); | |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
355 # undef READ_BUFFER_SIZE |
3147 | 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 | |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
462 #ifdef FEAT_GUI_GTK |
25982
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 | |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
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 | |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
1456 #if defined(FEAT_GUI_TABLINE) && defined(FEAT_GUI_HAIKU) |
19526
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 { |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27404
diff
changeset
|
1838 OUT_STR("\033|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 } | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27404
diff
changeset
|
1965 else if (s[0] < 0x20 // Ctrl character |
7 | 1966 #ifdef FEAT_SIGN_ICONS |
1967 && s[0] != SIGN_BYTE | |
1968 # ifdef FEAT_NETBEANS_INTG | |
1969 && s[0] != MULTISIGN_BYTE | |
1970 # endif | |
1971 #endif | |
1972 ) | |
1973 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1974 if (s[0] == '\n') // NL |
7 | 1975 { |
1976 gui.col = 0; | |
1977 if (gui.row < gui.scroll_region_bot) | |
1978 gui.row++; | |
1979 else | |
1980 gui_delete_lines(gui.scroll_region_top, 1); | |
1981 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1982 else if (s[0] == '\r') // CR |
7 | 1983 { |
1984 gui.col = 0; | |
1985 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1986 else if (s[0] == '\b') // Backspace |
7 | 1987 { |
1988 if (gui.col) | |
1989 --gui.col; | |
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] == Ctrl_L) // cursor-right |
7 | 1992 { |
1993 ++gui.col; | |
1994 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1995 else if (s[0] == Ctrl_G) // Beep |
7 | 1996 { |
1997 gui_mch_beep(); | |
1998 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1999 // 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
|
2000 |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2001 --len; // Skip this char |
7 | 2002 ++s; |
2003 } | |
2004 else | |
2005 { | |
2006 p = s; | |
2007 while (len > 0 && ( | |
2008 *p >= 0x20 | |
2009 #ifdef FEAT_SIGN_ICONS | |
2010 || *p == SIGN_BYTE | |
2011 # ifdef FEAT_NETBEANS_INTG | |
2012 || *p == MULTISIGN_BYTE | |
2013 # endif | |
2014 #endif | |
2015 )) | |
2016 { | |
2017 len--; | |
2018 p++; | |
2019 } | |
2020 gui_outstr(s, (int)(p - s)); | |
2021 s = p; | |
2022 } | |
2023 } | |
2024 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2025 // 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
|
2026 // set). |
7 | 2027 if (force_cursor) |
2028 gui_update_cursor(TRUE, TRUE); | |
2029 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2030 // 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
|
2031 // Required for GTK, dragged_sb isn't reset. |
7 | 2032 if (old_curwin != curwin) |
2033 gui.dragged_sb = SBAR_NONE; | |
2034 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2035 // 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
|
2036 // to another window. |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2037 // 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
|
2038 // situations where it might change. |
7 | 2039 if (force_scrollbar || old_curwin != curwin) |
2040 gui_update_scrollbars(force_scrollbar); | |
2041 else | |
2042 gui_update_horiz_scrollbar(FALSE); | |
2043 old_curwin = curwin; | |
2044 | |
2045 /* | |
2046 * We need to make sure this is cleared since Athena doesn't tell us when | |
2047 * he is done dragging. Do the same for GTK. | |
2048 */ | |
574 | 2049 #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) |
7 | 2050 gui.dragged_sb = SBAR_NONE; |
2051 #endif | |
2052 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2053 gui_may_flush(); // In case vim decides to take a nap |
7 | 2054 } |
2055 | |
2056 /* | |
2057 * When ScreenLines[] is invalid, updating the cursor should not be done, it | |
2058 * produces wrong results. Call gui_dont_update_cursor() before that code and | |
2059 * gui_can_update_cursor() afterwards. | |
2060 */ | |
2061 void | |
9848
664276833670
commit https://github.com/vim/vim/commit/107abd2ca53c31fd3bb40d77ff296e98eaae2975
Christian Brabandt <cb@256bit.org>
parents:
9836
diff
changeset
|
2062 gui_dont_update_cursor(int undraw) |
7 | 2063 { |
2064 if (gui.in_use) | |
2065 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2066 // 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
|
2067 if (undraw) |
664276833670
commit https://github.com/vim/vim/commit/107abd2ca53c31fd3bb40d77ff296e98eaae2975
Christian Brabandt <cb@256bit.org>
parents:
9836
diff
changeset
|
2068 gui_undraw_cursor(); |
7 | 2069 can_update_cursor = FALSE; |
2070 } | |
2071 } | |
2072 | |
2073 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2074 gui_can_update_cursor(void) |
7 | 2075 { |
2076 can_update_cursor = TRUE; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2077 // 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
|
2078 // after scrolling. |
7 | 2079 } |
2080 | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2081 /* |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2082 * Disable issuing gui_mch_flush(). |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2083 */ |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2084 void |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2085 gui_disable_flush(void) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2086 { |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2087 ++disable_flush; |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2088 } |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2089 |
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 * Enable 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_enable_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 * 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
|
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_may_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 if (disable_flush == 0) |
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
2106 gui_mch_flush(); |
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 |
7 | 2109 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2110 gui_outstr(char_u *s, int len) |
7 | 2111 { |
2112 int this_len; | |
2113 int cells; | |
2114 | |
2115 if (len == 0) | |
2116 return; | |
2117 | |
2118 if (len < 0) | |
2119 len = (int)STRLEN(s); | |
2120 | |
2121 while (len > 0) | |
2122 { | |
2123 if (has_mbyte) | |
2124 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2125 // Find out how many chars fit in the current line. |
7 | 2126 cells = 0; |
2127 for (this_len = 0; this_len < len; ) | |
2128 { | |
2129 cells += (*mb_ptr2cells)(s + this_len); | |
2130 if (gui.col + cells > Columns) | |
2131 break; | |
474 | 2132 this_len += (*mb_ptr2len)(s + this_len); |
7 | 2133 } |
2134 if (this_len > len) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2135 this_len = len; // don't include following composing char |
7 | 2136 } |
2137 else | |
2138 if (gui.col + len > Columns) | |
2139 this_len = Columns - gui.col; | |
2140 else | |
2141 this_len = len; | |
2142 | |
2143 (void)gui_outstr_nowrap(s, this_len, | |
2144 0, (guicolor_T)0, (guicolor_T)0, 0); | |
2145 s += this_len; | |
2146 len -= this_len; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2147 // fill up for a double-width char that doesn't fit. |
7 | 2148 if (len > 0 && gui.col < Columns) |
2149 (void)gui_outstr_nowrap((char_u *)" ", 1, | |
2150 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
|
2151 // The cursor may wrap to the next line. |
7 | 2152 if (gui.col >= Columns) |
2153 { | |
2154 gui.col = 0; | |
2155 gui.row++; | |
2156 } | |
2157 } | |
2158 } | |
2159 | |
2160 /* | |
2161 * Output one character (may be one or two display cells). | |
2162 * Caller must check for valid "off". | |
2163 * Returns FAIL or OK, just like gui_outstr_nowrap(). | |
2164 */ | |
2165 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2166 gui_screenchar( |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2167 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
|
2168 int flags, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2169 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
|
2170 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
|
2171 int back) // backup this many chars when using bold trick |
7 | 2172 { |
2173 char_u buf[MB_MAXBYTES + 1]; | |
2174 | |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
2175 // Don't draw right half of a double-width UTF-8 char. "cannot happen" |
7 | 2176 if (enc_utf8 && ScreenLines[off] == 0) |
2177 return OK; | |
2178 | |
2179 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
|
2180 // Draw UTF-8 multi-byte character. |
7 | 2181 return gui_outstr_nowrap(buf, utfc_char2bytes(off, buf), |
2182 flags, fg, bg, back); | |
2183 | |
2184 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) | |
2185 { | |
2186 buf[0] = ScreenLines[off]; | |
2187 buf[1] = ScreenLines2[off]; | |
2188 return gui_outstr_nowrap(buf, 2, flags, fg, bg, back); | |
2189 } | |
2190 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2191 // Draw non-multi-byte character or DBCS character. |
7 | 2192 return gui_outstr_nowrap(ScreenLines + off, |
474 | 2193 enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1, |
7 | 2194 flags, fg, bg, back); |
2195 } | |
2196 | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2197 #ifdef FEAT_GUI_GTK |
7 | 2198 /* |
2199 * Output the string at the given screen position. This is used in place | |
2200 * of gui_screenchar() where possible because Pango needs as much context | |
2201 * as possible to work nicely. It's a lot faster as well. | |
2202 */ | |
2203 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2204 gui_screenstr( |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2205 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
|
2206 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
|
2207 int flags, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2208 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
|
2209 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
|
2210 int back) // backup this many chars when using bold trick |
7 | 2211 { |
2212 char_u *buf; | |
2213 int outlen = 0; | |
2214 int i; | |
2215 int retval; | |
2216 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2217 if (len <= 0) // "cannot happen"? |
7 | 2218 return OK; |
2219 | |
2220 if (enc_utf8) | |
2221 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
2222 buf = alloc(len * MB_MAXBYTES + 1); |
7 | 2223 if (buf == NULL) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2224 return OK; // not much we could do here... |
7 | 2225 |
2226 for (i = off; i < off + len; ++i) | |
2227 { | |
2228 if (ScreenLines[i] == 0) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2229 continue; // skip second half of double-width char |
7 | 2230 |
2231 if (ScreenLinesUC[i] == 0) | |
2232 buf[outlen++] = ScreenLines[i]; | |
2233 else | |
2234 outlen += utfc_char2bytes(i, buf + outlen); | |
2235 } | |
2236 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2237 buf[outlen] = NUL; // only to aid debugging |
7 | 2238 retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back); |
2239 vim_free(buf); | |
2240 | |
2241 return retval; | |
2242 } | |
2243 else if (enc_dbcs == DBCS_JPNU) | |
2244 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
2245 buf = alloc(len * 2 + 1); |
7 | 2246 if (buf == NULL) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2247 return OK; // not much we could do here... |
7 | 2248 |
2249 for (i = off; i < off + len; ++i) | |
2250 { | |
2251 buf[outlen++] = ScreenLines[i]; | |
2252 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2253 // handle double-byte single-width char |
7 | 2254 if (ScreenLines[i] == 0x8e) |
2255 buf[outlen++] = ScreenLines2[i]; | |
2256 else if (MB_BYTE2LEN(ScreenLines[i]) == 2) | |
2257 buf[outlen++] = ScreenLines[++i]; | |
2258 } | |
2259 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2260 buf[outlen] = NUL; // only to aid debugging |
7 | 2261 retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back); |
2262 vim_free(buf); | |
2263 | |
2264 return retval; | |
2265 } | |
2266 else | |
2267 { | |
2268 return gui_outstr_nowrap(&ScreenLines[off], len, | |
2269 flags, fg, bg, back); | |
2270 } | |
2271 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2272 #endif // FEAT_GUI_GTK |
7 | 2273 |
2274 /* | |
2275 * Output the given string at the current cursor position. If the string is | |
2276 * too long to fit on the line, then it is truncated. | |
2277 * "flags": | |
2278 * GUI_MON_IS_CURSOR should only be used when this function is being called to | |
2279 * actually draw (an inverted) cursor. | |
1199 | 2280 * GUI_MON_TRS_CURSOR is used to draw the cursor text with a transparent |
7 | 2281 * background. |
2282 * GUI_MON_NOCLEAR is used to avoid clearing the selection when drawing over | |
2283 * it. | |
2284 * Returns OK, unless "back" is non-zero and using the bold trick, then return | |
2285 * FAIL (the caller should start drawing "back" chars back). | |
2286 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17407
diff
changeset
|
2287 static int |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2288 gui_outstr_nowrap( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2289 char_u *s, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2290 int len, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2291 int flags, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2292 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
|
2293 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
|
2294 int back) // backup this many chars when using bold trick |
7 | 2295 { |
2296 long_u highlight_mask; | |
2297 long_u hl_mask_todo; | |
2298 guicolor_T fg_color; | |
2299 guicolor_T bg_color; | |
203 | 2300 guicolor_T sp_color; |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2301 #if !defined(FEAT_GUI_GTK) |
7 | 2302 GuiFont font = NOFONT; |
4950
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2303 GuiFont wide_font = NOFONT; |
7 | 2304 # ifdef FEAT_XFONTSET |
2305 GuiFontset fontset = NOFONTSET; | |
2306 # endif | |
2307 #endif | |
2308 attrentry_T *aep = NULL; | |
2309 int draw_flags; | |
2310 int col = gui.col; | |
2311 #ifdef FEAT_SIGN_ICONS | |
2312 int draw_sign = FALSE; | |
17407
df340014f9e4
patch 8.1.1702: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17342
diff
changeset
|
2313 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
|
2314 char_u extra[18]; |
7 | 2315 # ifdef FEAT_NETBEANS_INTG |
2316 int multi_sign = FALSE; | |
2317 # endif | |
2318 #endif | |
2319 | |
2320 if (len < 0) | |
2321 len = (int)STRLEN(s); | |
2322 if (len == 0) | |
2323 return OK; | |
2324 | |
2325 #ifdef FEAT_SIGN_ICONS | |
2326 if (*s == SIGN_BYTE | |
2327 # ifdef FEAT_NETBEANS_INTG | |
2328 || *s == MULTISIGN_BYTE | |
2329 # endif | |
17342
54fcde87a9eb
patch 8.1.1670: sign column not always properly aligned
Bram Moolenaar <Bram@vim.org>
parents:
17306
diff
changeset
|
2330 ) |
7 | 2331 { |
2332 # ifdef FEAT_NETBEANS_INTG | |
2333 if (*s == MULTISIGN_BYTE) | |
2334 multi_sign = TRUE; | |
2335 # endif | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2336 // 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
|
2337 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
|
2338 (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
|
2339 { |
3c0efdd95f8d
patch 8.1.1570: icon signs not displayed properly in the number column
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
2340 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
|
2341 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
|
2342 } |
3c0efdd95f8d
patch 8.1.1570: icon signs not displayed properly in the number column
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
2343 else |
3c0efdd95f8d
patch 8.1.1570: icon signs not displayed properly in the number column
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
2344 s = (char_u *)" "; |
7 | 2345 if (len == 1 && col > 0) |
2346 --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
|
2347 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
|
2348 if (len > 2) |
17342
54fcde87a9eb
patch 8.1.1670: sign column not always properly aligned
Bram Moolenaar <Bram@vim.org>
parents:
17306
diff
changeset
|
2349 // 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
|
2350 signcol = col + len - 3; |
54fcde87a9eb
patch 8.1.1670: sign column not always properly aligned
Bram Moolenaar <Bram@vim.org>
parents:
17306
diff
changeset
|
2351 else |
54fcde87a9eb
patch 8.1.1670: sign column not always properly aligned
Bram Moolenaar <Bram@vim.org>
parents:
17306
diff
changeset
|
2352 signcol = col; |
7 | 2353 draw_sign = TRUE; |
2354 highlight_mask = 0; | |
2355 } | |
2356 else | |
2357 #endif | |
2358 if (gui.highlight_mask > HL_ALL) | |
2359 { | |
2360 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
|
2361 if (aep == NULL) // highlighting not set |
7 | 2362 highlight_mask = 0; |
2363 else | |
2364 highlight_mask = aep->ae_attr; | |
2365 } | |
2366 else | |
2367 highlight_mask = gui.highlight_mask; | |
2368 hl_mask_todo = highlight_mask; | |
2369 | |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2370 #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
|
2371 // Set the font |
7 | 2372 if (aep != NULL && aep->ae_u.gui.font != NOFONT) |
2373 font = aep->ae_u.gui.font; | |
2374 # ifdef FEAT_XFONTSET | |
2375 else if (aep != NULL && aep->ae_u.gui.fontset != NOFONTSET) | |
2376 fontset = aep->ae_u.gui.fontset; | |
2377 # endif | |
2378 else | |
2379 { | |
2380 # ifdef FEAT_XFONTSET | |
2381 if (gui.fontset != NOFONTSET) | |
2382 fontset = gui.fontset; | |
2383 else | |
2384 # endif | |
2385 if (hl_mask_todo & (HL_BOLD | HL_STANDOUT)) | |
2386 { | |
2387 if ((hl_mask_todo & HL_ITALIC) && gui.boldital_font != NOFONT) | |
2388 { | |
2389 font = gui.boldital_font; | |
2390 hl_mask_todo &= ~(HL_BOLD | HL_STANDOUT | HL_ITALIC); | |
2391 } | |
2392 else if (gui.bold_font != NOFONT) | |
2393 { | |
2394 font = gui.bold_font; | |
2395 hl_mask_todo &= ~(HL_BOLD | HL_STANDOUT); | |
2396 } | |
2397 else | |
2398 font = gui.norm_font; | |
2399 } | |
2400 else if ((hl_mask_todo & HL_ITALIC) && gui.ital_font != NOFONT) | |
2401 { | |
2402 font = gui.ital_font; | |
2403 hl_mask_todo &= ~HL_ITALIC; | |
2404 } | |
2405 else | |
2406 font = gui.norm_font; | |
4950
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2407 |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2408 /* |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2409 * 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
|
2410 * 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
|
2411 * blocks. So we do it here. |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2412 */ |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2413 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
|
2414 wide_font = gui.wide_boldital_font; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2415 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
|
2416 wide_font = gui.wide_bold_font; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2417 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
|
2418 wide_font = gui.wide_ital_font; |
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2419 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
|
2420 wide_font = gui.wide_font; |
7 | 2421 } |
2422 # ifdef FEAT_XFONTSET | |
2423 if (fontset != NOFONTSET) | |
2424 gui_mch_set_fontset(fontset); | |
2425 else | |
2426 # endif | |
2427 gui_mch_set_font(font); | |
2428 #endif | |
2429 | |
2430 draw_flags = 0; | |
2431 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2432 // Set the color |
7 | 2433 bg_color = gui.back_pixel; |
2434 if ((flags & GUI_MON_IS_CURSOR) && gui.in_focus) | |
2435 { | |
2436 draw_flags |= DRAW_CURSOR; | |
2437 fg_color = fg; | |
2438 bg_color = bg; | |
203 | 2439 sp_color = fg; |
7 | 2440 } |
2441 else if (aep != NULL) | |
2442 { | |
2443 fg_color = aep->ae_u.gui.fg_color; | |
2444 if (fg_color == INVALCOLOR) | |
2445 fg_color = gui.norm_pixel; | |
2446 bg_color = aep->ae_u.gui.bg_color; | |
2447 if (bg_color == INVALCOLOR) | |
2448 bg_color = gui.back_pixel; | |
203 | 2449 sp_color = aep->ae_u.gui.sp_color; |
2450 if (sp_color == INVALCOLOR) | |
2451 sp_color = fg_color; | |
7 | 2452 } |
2453 else | |
203 | 2454 { |
7 | 2455 fg_color = gui.norm_pixel; |
203 | 2456 sp_color = fg_color; |
2457 } | |
7 | 2458 |
2459 if (highlight_mask & (HL_INVERSE | HL_STANDOUT)) | |
2460 { | |
2461 gui_mch_set_fg_color(bg_color); | |
2462 gui_mch_set_bg_color(fg_color); | |
2463 } | |
2464 else | |
2465 { | |
2466 gui_mch_set_fg_color(fg_color); | |
2467 gui_mch_set_bg_color(bg_color); | |
2468 } | |
203 | 2469 gui_mch_set_sp_color(sp_color); |
7 | 2470 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2471 // Clear the selection if we are about to write over it |
7 | 2472 if (!(flags & GUI_MON_NOCLEAR)) |
2473 clip_may_clear_selection(gui.row, gui.row); | |
2474 | |
2475 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2476 // If there's no bold font, then fake it |
7 | 2477 if (hl_mask_todo & (HL_BOLD | HL_STANDOUT)) |
2478 draw_flags |= DRAW_BOLD; | |
2479 | |
2480 /* | |
2481 * When drawing bold or italic characters the spill-over from the left | |
2482 * neighbor may be destroyed. Let the caller backup to start redrawing | |
2483 * just after a blank. | |
2484 */ | |
2485 if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC))) | |
2486 return FAIL; | |
2487 | |
2823 | 2488 #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
|
2489 // 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
|
2490 // For GTK2, we don't need a different font for italic style. |
7 | 2491 if (hl_mask_todo & HL_ITALIC) |
2492 draw_flags |= DRAW_ITALIC; | |
2493 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2494 // Do we underline the text? |
7 | 2495 if (hl_mask_todo & HL_UNDERLINE) |
2496 draw_flags |= DRAW_UNDERL; | |
12317
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12136
diff
changeset
|
2497 |
7 | 2498 #else |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2499 // Do we underline the text? |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
2500 if ((hl_mask_todo & HL_UNDERLINE) || (hl_mask_todo & HL_ITALIC)) |
7 | 2501 draw_flags |= DRAW_UNDERL; |
2502 #endif | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2503 // Do we undercurl the text? |
203 | 2504 if (hl_mask_todo & HL_UNDERCURL) |
2505 draw_flags |= DRAW_UNDERC; | |
7 | 2506 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2507 // 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
|
2508 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
|
2509 draw_flags |= DRAW_STRIKE; |
2a8890b80923
patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents:
12136
diff
changeset
|
2510 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2511 // Do we draw transparently? |
7 | 2512 if (flags & GUI_MON_TRS_CURSOR) |
2513 draw_flags |= DRAW_TRANSP; | |
2514 | |
2515 /* | |
2516 * Draw the text. | |
2517 */ | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2518 #ifdef FEAT_GUI_GTK |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2519 // The value returned is the length in display cells |
7 | 2520 len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags); |
2521 #else | |
2522 if (enc_utf8) | |
2523 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2524 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
|
2525 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
|
2526 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
|
2527 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
|
2528 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
|
2529 int c; // current char value |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2530 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
|
2531 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
|
2532 int scol = col; // screen column |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2533 int curr_wide = FALSE; // use 'guifontwide' |
4053 | 2534 int prev_wide = FALSE; |
2535 int wide_changed; | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2536 # ifdef MSWIN |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2537 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
|
2538 # else |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2539 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
|
2540 # endif |
7 | 2541 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2542 // 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
|
2543 // top of the previous character. |
7 | 2544 start = 0; |
2545 cells = 0; | |
2546 for (i = 0; i < len; i += cl) | |
2547 { | |
2548 c = utf_ptr2char(s + i); | |
2549 cn = utf_char2cells(c); | |
2550 comping = utf_iscomposing(c); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2551 if (!comping) // count cells from non-composing chars |
7 | 2552 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
|
2553 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
|
2554 { |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2555 if (cn > 1 |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2556 # 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
|
2557 && fontset == NOFONTSET |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2558 # endif |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2559 && 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
|
2560 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
|
2561 else |
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2562 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
|
2563 } |
474 | 2564 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
|
2565 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
|
2566 len = i + cl; // len must be wrong "cannot happen" |
7 | 2567 |
4053 | 2568 wide_changed = curr_wide != prev_wide; |
2569 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2570 // 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
|
2571 // 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
|
2572 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
|
2573 || wide_changed |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2574 # if defined(FEAT_GUI_X11) |
7 | 2575 || (cn > 1 |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2576 # ifdef FEAT_XFONTSET |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2577 // 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
|
2578 // right position. |
7 | 2579 && fontset == NOFONTSET |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2580 # endif |
7 | 2581 ) |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2582 # endif |
7 | 2583 ) |
2584 { | |
12712
25f7d8ee04c7
patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2585 if ((comping && sep_comp) || wide_changed) |
7 | 2586 thislen = i - start; |
2587 else | |
2588 thislen = i - start + cl; | |
2589 if (thislen > 0) | |
2590 { | |
4053 | 2591 if (prev_wide) |
4950
ba7db05e1482
updated for version 7.3.1220
Bram Moolenaar <bram@vim.org>
parents:
4863
diff
changeset
|
2592 gui_mch_set_font(wide_font); |
7 | 2593 gui_mch_draw_string(gui.row, scol, s + start, thislen, |
2594 draw_flags); | |
4053 | 2595 if (prev_wide) |
2596 gui_mch_set_font(font); | |
7 | 2597 start += thislen; |
2598 } | |
2599 scol += cells; | |
2600 cells = 0; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2601 // 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
|
2602 // 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
|
2603 if (wide_changed && !(comping && sep_comp)) |
7 | 2604 { |
4053 | 2605 scol -= cn; |
2606 cl = 0; | |
7 | 2607 } |
2608 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2609 # 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
|
2610 // 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
|
2611 // |
7 | 2612 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
|
2613 # ifdef FEAT_XFONTSET |
7 | 2614 && fontset == NOFONTSET |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2615 # endif |
4053 | 2616 && !wide_changed) |
7 | 2617 gui_mch_draw_string(gui.row, scol - 1, (char_u *)" ", |
2618 1, draw_flags); | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2619 # endif |
7 | 2620 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2621 // 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
|
2622 if (comping && sep_comp) |
7 | 2623 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2624 # 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
|
2625 // Carbon ATSUI autodraws composing char over previous char |
536 | 2626 gui_mch_draw_string(gui.row, scol, s + i, cl, |
7 | 2627 draw_flags | DRAW_TRANSP); |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2628 # else |
536 | 2629 gui_mch_draw_string(gui.row, scol - cn, s + i, cl, |
187 | 2630 draw_flags | DRAW_TRANSP); |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2631 # endif |
7 | 2632 start = i + cl; |
2633 } | |
4053 | 2634 prev_wide = curr_wide; |
7 | 2635 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2636 // The stuff below assumes "len" is the length in screen columns. |
7 | 2637 len = scol - col; |
2638 } | |
2639 else | |
2640 { | |
2641 gui_mch_draw_string(gui.row, col, s, len, draw_flags); | |
2642 if (enc_dbcs == DBCS_JPNU) | |
2643 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2644 // 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
|
2645 // number of bytes for "euc-jp". |
2338
da6ec32d8d8f
Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2646 len = mb_string2cells(s, len); |
7 | 2647 } |
2648 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2649 #endif // !FEAT_GUI_GTK |
7 | 2650 |
2651 if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) | |
2652 gui.col = col + len; | |
2653 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2654 // May need to invert it when it's part of the selection. |
7 | 2655 if (flags & GUI_MON_NOCLEAR) |
2656 clip_may_redraw_selection(gui.row, col, len); | |
2657 | |
2658 if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) | |
2659 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2660 // Invalidate the old physical cursor position if we wrote over it |
7 | 2661 if (gui.cursor_row == gui.row |
2662 && gui.cursor_col >= col | |
2663 && gui.cursor_col < col + len) | |
2664 gui.cursor_is_valid = FALSE; | |
2665 } | |
2666 | |
2667 #ifdef FEAT_SIGN_ICONS | |
2668 if (draw_sign) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2669 // 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
|
2670 gui_mch_drawsign(gui.row, signcol, gui.highlight_mask); |
2592 | 2671 # 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
|
2672 || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)) |
7 | 2673 if (multi_sign) |
2674 netbeans_draw_multisign_indicator(gui.row); | |
2675 # endif | |
2676 #endif | |
2677 | |
2678 return OK; | |
2679 } | |
2680 | |
2681 /* | |
26232
393ee487cf82
patch 8.2.3647: GTK: when using ligatures the cursor is drawn wrong
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2682 * 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
|
2683 * position, plus some more characters when needed. |
7 | 2684 */ |
2685 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2686 gui_undraw_cursor(void) |
7 | 2687 { |
2688 if (gui.cursor_is_valid) | |
2689 { | |
26232
393ee487cf82
patch 8.2.3647: GTK: when using ligatures the cursor is drawn wrong
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2690 // 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
|
2691 // 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
|
2692 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
|
2693 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
|
2694 |
393ee487cf82
patch 8.2.3647: GTK: when using ligatures the cursor is drawn wrong
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2695 #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
|
2696 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
|
2697 #endif |
393ee487cf82
patch 8.2.3647: GTK: when using ligatures the cursor is drawn wrong
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
2698 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
|
2699 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
|
2700 |
18671
df141c730008
patch 8.1.2327: cannot build with Hangul input
Bram Moolenaar <Bram@vim.org>
parents:
18642
diff
changeset
|
2701 // 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
|
2702 // here in case it wasn't needed to undraw it. |
7 | 2703 gui.cursor_is_valid = FALSE; |
2704 } | |
2705 } | |
2706 | |
2707 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2708 gui_redraw( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2709 int x, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2710 int y, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2711 int w, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2712 int h) |
7 | 2713 { |
2714 int row1, col1, row2, col2; | |
2715 | |
2716 row1 = Y_2_ROW(y); | |
2717 col1 = X_2_COL(x); | |
2718 row2 = Y_2_ROW(y + h - 1); | |
2719 col2 = X_2_COL(x + w - 1); | |
2720 | |
19824
09a621bdb0bc
patch 8.2.0468: GUI: pixel dust with some fonts and characters
Bram Moolenaar <Bram@vim.org>
parents:
19760
diff
changeset
|
2721 gui_redraw_block(row1, col1, row2, col2, GUI_MON_NOCLEAR); |
7 | 2722 |
2723 /* | |
2724 * We may need to redraw the cursor, but don't take it upon us to change | |
2725 * its location after a scroll. | |
2726 * (maybe be more strict even and test col too?) | |
2727 * These things may be outside the update/clipping region and reality may | |
2728 * not reflect Vims internal ideas if these operations are clipped away. | |
2729 */ | |
2730 if (gui.row == gui.cursor_row) | |
2731 gui_update_cursor(TRUE, TRUE); | |
2732 } | |
2733 | |
2734 /* | |
2735 * Draw a rectangular block of characters, from row1 to row2 (inclusive) and | |
2736 * from col1 to col2 (inclusive). | |
2737 */ | |
19824
09a621bdb0bc
patch 8.2.0468: GUI: pixel dust with some fonts and characters
Bram Moolenaar <Bram@vim.org>
parents:
19760
diff
changeset
|
2738 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2739 gui_redraw_block( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2740 int row1, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2741 int col1, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2742 int row2, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2743 int col2, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2744 int flags) // flags for gui_outstr_nowrap() |
7 | 2745 { |
2746 int old_row, old_col; | |
2747 long_u old_hl_mask; | |
2748 int off; | |
203 | 2749 sattr_T first_attr; |
7 | 2750 int idx, len; |
2751 int back, nback; | |
2752 int orig_col1, orig_col2; | |
2753 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2754 // Don't try to update when ScreenLines is not valid |
7 | 2755 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
|
2756 return; |
7 | 2757 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2758 // 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
|
2759 // Check everything, strange values may be caused by a big border width |
7 | 2760 col1 = check_col(col1); |
2761 col2 = check_col(col2); | |
2762 row1 = check_row(row1); | |
2763 row2 = check_row(row2); | |
2764 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2765 // Remember where our cursor was |
7 | 2766 old_row = gui.row; |
2767 old_col = gui.col; | |
2768 old_hl_mask = gui.highlight_mask; | |
2769 orig_col1 = col1; | |
2770 orig_col2 = col2; | |
2771 | |
2772 for (gui.row = row1; gui.row <= row2; gui.row++) | |
2773 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2774 // 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
|
2775 // the other half. |
7 | 2776 col1 = orig_col1; |
2777 col2 = orig_col2; | |
2778 off = LineOffset[gui.row]; | |
2779 if (enc_dbcs != 0) | |
2780 { | |
2781 if (col1 > 0) | |
2782 col1 -= dbcs_screen_head_off(ScreenLines + off, | |
2783 ScreenLines + off + col1); | |
2784 col2 += dbcs_screen_tail_off(ScreenLines + off, | |
2785 ScreenLines + off + col2); | |
2786 } | |
2787 else if (enc_utf8) | |
2788 { | |
15113
ae25a1172514
patch 8.1.0567: error for NUL byte in ScreenLines goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
15109
diff
changeset
|
2789 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
|
2790 { |
ae25a1172514
patch 8.1.0567: error for NUL byte in ScreenLines goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
15109
diff
changeset
|
2791 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
|
2792 --col1; |
ae25a1172514
patch 8.1.0567: error for NUL byte in ScreenLines goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
15109
diff
changeset
|
2793 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
|
2794 { |
15113
ae25a1172514
patch 8.1.0567: error for NUL byte in ScreenLines goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
15109
diff
changeset
|
2795 // 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
|
2796 // 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
|
2797 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
|
2798 "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
|
2799 (long)gui.row); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
2800 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
|
2801 } |
15113
ae25a1172514
patch 8.1.0567: error for NUL byte in ScreenLines goes unnoticed
Bram Moolenaar <Bram@vim.org>
parents:
15109
diff
changeset
|
2802 } |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2803 #ifdef FEAT_GUI_GTK |
7 | 2804 if (col2 + 1 < Columns && ScreenLines[off + col2 + 1] == 0) |
2805 ++col2; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2806 #endif |
7 | 2807 } |
2808 gui.col = col1; | |
2809 off = LineOffset[gui.row] + gui.col; | |
2810 len = col2 - col1 + 1; | |
2811 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2812 // 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
|
2813 // is. Needed for when the bold trick is used |
7 | 2814 for (back = 0; back < col1; ++back) |
2815 if (ScreenAttrs[off - 1 - back] != ScreenAttrs[off] | |
2816 || ScreenLines[off - 1 - back] == ' ') | |
2817 break; | |
2818 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2819 // 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
|
2820 // Print UTF-8 characters individually. |
7 | 2821 while (len > 0) |
2822 { | |
2823 first_attr = ScreenAttrs[off]; | |
2824 gui.highlight_mask = first_attr; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2825 #if !defined(FEAT_GUI_GTK) |
7 | 2826 if (enc_utf8 && ScreenLinesUC[off] != 0) |
2827 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2828 // output multi-byte character separately |
7 | 2829 nback = gui_screenchar(off, flags, |
2830 (guicolor_T)0, (guicolor_T)0, back); | |
2831 if (gui.col < Columns && ScreenLines[off + 1] == 0) | |
2832 idx = 2; | |
2833 else | |
2834 idx = 1; | |
2835 } | |
2836 else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) | |
2837 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2838 // output double-byte, single-width character separately |
7 | 2839 nback = gui_screenchar(off, flags, |
2840 (guicolor_T)0, (guicolor_T)0, back); | |
2841 idx = 1; | |
2842 } | |
2843 else | |
2844 #endif | |
2845 { | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
2846 #ifdef FEAT_GUI_GTK |
7 | 2847 for (idx = 0; idx < len; ++idx) |
2848 { | |
2849 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
|
2850 continue; // skip second half of double-width char |
7 | 2851 if (ScreenAttrs[off + idx] != first_attr) |
2852 break; | |
2853 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2854 // gui_screenstr() takes care of multibyte chars |
7 | 2855 nback = gui_screenstr(off, idx, flags, |
2856 (guicolor_T)0, (guicolor_T)0, back); | |
2857 #else | |
2858 for (idx = 0; idx < len && ScreenAttrs[off + idx] == first_attr; | |
2859 idx++) | |
2860 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2861 // Stop at a multi-byte Unicode character. |
7 | 2862 if (enc_utf8 && ScreenLinesUC[off + idx] != 0) |
2863 break; | |
2864 if (enc_dbcs == DBCS_JPNU) | |
2865 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2866 // Stop at a double-byte single-width char. |
7 | 2867 if (ScreenLines[off + idx] == 0x8e) |
2868 break; | |
474 | 2869 if (len > 1 && (*mb_ptr2len)(ScreenLines |
7 | 2870 + off + idx) == 2) |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2871 ++idx; // skip second byte of double-byte char |
7 | 2872 } |
2873 } | |
2874 nback = gui_outstr_nowrap(ScreenLines + off, idx, flags, | |
2875 (guicolor_T)0, (guicolor_T)0, back); | |
2876 #endif | |
2877 } | |
2878 if (nback == FAIL) | |
2879 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2880 // 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
|
2881 // starts. |
7 | 2882 off -= back; |
2883 len += back; | |
2884 gui.col -= back; | |
2885 } | |
2886 else | |
2887 { | |
2888 off += idx; | |
2889 len -= idx; | |
2890 } | |
2891 back = 0; | |
2892 } | |
2893 } | |
2894 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2895 // Put the cursor back where it was |
7 | 2896 gui.row = old_row; |
2897 gui.col = old_col; | |
835 | 2898 gui.highlight_mask = (int)old_hl_mask; |
7 | 2899 } |
2900 | |
2901 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2902 gui_delete_lines(int row, int count) |
7 | 2903 { |
2904 if (count <= 0) | |
2905 return; | |
2906 | |
2907 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
|
2908 // Scrolled out of region, just blank the lines out |
7 | 2909 gui_clear_block(row, gui.scroll_region_left, |
2910 gui.scroll_region_bot, gui.scroll_region_right); | |
2911 else | |
2912 { | |
2913 gui_mch_delete_lines(row, count); | |
2914 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2915 // 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
|
2916 // cursor was in the scrolled lines adjust its position. |
7 | 2917 if (gui.cursor_row >= row |
2918 && gui.cursor_col >= gui.scroll_region_left | |
2919 && gui.cursor_col <= gui.scroll_region_right) | |
2920 { | |
2921 if (gui.cursor_row < row + count) | |
2922 gui.cursor_is_valid = FALSE; | |
2923 else if (gui.cursor_row <= gui.scroll_region_bot) | |
2924 gui.cursor_row -= count; | |
2925 } | |
2926 } | |
2927 } | |
2928 | |
2929 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2930 gui_insert_lines(int row, int count) |
7 | 2931 { |
2932 if (count <= 0) | |
2933 return; | |
2934 | |
2935 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
|
2936 // Scrolled out of region, just blank the lines out |
7 | 2937 gui_clear_block(row, gui.scroll_region_left, |
2938 gui.scroll_region_bot, gui.scroll_region_right); | |
2939 else | |
2940 { | |
2941 gui_mch_insert_lines(row, count); | |
2942 | |
2943 if (gui.cursor_row >= gui.row | |
2944 && gui.cursor_col >= gui.scroll_region_left | |
2945 && gui.cursor_col <= gui.scroll_region_right) | |
2946 { | |
2947 if (gui.cursor_row <= gui.scroll_region_bot - count) | |
2948 gui.cursor_row += count; | |
2949 else if (gui.cursor_row <= gui.scroll_region_bot) | |
2950 gui.cursor_is_valid = FALSE; | |
2951 } | |
2952 } | |
2953 } | |
2954 | |
13080
eee366f56b1a
patch 8.0.1415: warning for unused function without timers feature
Christian Brabandt <cb@256bit.org>
parents:
13064
diff
changeset
|
2955 #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
|
2956 /* |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2957 * 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
|
2958 */ |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2959 static int |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2960 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
|
2961 long wtime, |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2962 int *interrupted UNUSED, |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2963 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
|
2964 { |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2965 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
|
2966 } |
13080
eee366f56b1a
patch 8.0.1415: warning for unused function without timers feature
Christian Brabandt <cb@256bit.org>
parents:
13064
diff
changeset
|
2967 #endif |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2968 |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
2969 /* |
11471
26525db57c4c
patch 8.0.0619: GUI gets stuck if timer uses feedkeys()
Christian Brabandt <cb@256bit.org>
parents:
11163
diff
changeset
|
2970 * 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
|
2971 * or FAIL otherwise. |
26525db57c4c
patch 8.0.0619: GUI gets stuck if timer uses feedkeys()
Christian Brabandt <cb@256bit.org>
parents:
11163
diff
changeset
|
2972 */ |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2973 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
|
2974 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
|
2975 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
|
2976 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
|
2977 int ignore_input UNUSED) |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2978 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2979 #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
|
2980 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
|
2981 interrupted, ignore_input); |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2982 #else |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2983 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
|
2984 #endif |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2985 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
2986 |
7 | 2987 /* |
2988 * 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
|
2989 * "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
|
2990 * "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
|
2991 * "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
|
2992 * |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
2993 * 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
|
2994 * "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
|
2995 * 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
|
2996 */ |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
2997 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
|
2998 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
|
2999 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
|
3000 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
|
3001 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
|
3002 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
|
3003 { |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3004 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
|
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 #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
|
3007 // 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
|
3008 // 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
|
3009 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
|
3010 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
|
3011 #endif |
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 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
|
3014 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
|
3015 { |
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 (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
|
3017 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
|
3018 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
|
3019 } |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3020 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
|
3021 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
|
3022 |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3023 // 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
|
3024 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
|
3025 |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3026 // 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
|
3027 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
|
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 // 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
|
3030 // 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
|
3031 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
|
3032 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
|
3033 |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3034 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
|
3035 |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3036 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
|
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 |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3039 /* |
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3040 * 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
|
3041 * Also deals with timers. |
7 | 3042 * wtime == -1 Wait forever. |
3043 * wtime == 0 Don't wait. | |
3044 * wtime > 0 Wait wtime milliseconds for a character. | |
3045 * Returns OK if a character was found to be available within the given time, | |
3046 * or FAIL otherwise. | |
3047 */ | |
3048 int | |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3049 gui_wait_for_chars(long wtime, int tb_change_cnt) |
7 | 3050 { |
15653
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3051 return gui_wait_for_chars_buf(NULL, 0, wtime, tb_change_cnt); |
7 | 3052 } |
3053 | |
3054 /* | |
13060
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3055 * 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
|
3056 */ |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3057 int |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3058 gui_inchar( |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3059 char_u *buf, |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3060 int maxlen, |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
3061 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
|
3062 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
|
3063 { |
15653
59a1ff689b4d
patch 8.1.0834: GUI may wait too long before dealing with messages
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
3064 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
|
3065 } |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3066 |
1bdc12630fc0
patch 8.0.1405: duplicated code for getting a typed character
Christian Brabandt <cb@256bit.org>
parents:
13052
diff
changeset
|
3067 /* |
1137 | 3068 * Fill p[4] with mouse coordinates encoded for check_termcode(). |
7 | 3069 */ |
3070 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3071 fill_mouse_coord(char_u *p, int col, int row) |
7 | 3072 { |
3073 p[0] = (char_u)(col / 128 + ' ' + 1); | |
3074 p[1] = (char_u)(col % 128 + ' ' + 1); | |
3075 p[2] = (char_u)(row / 128 + ' ' + 1); | |
3076 p[3] = (char_u)(row % 128 + ' ' + 1); | |
3077 } | |
3078 | |
3079 /* | |
3080 * Generic mouse support function. Add a mouse event to the input buffer with | |
3081 * the given properties. | |
3082 * button --- may be any of MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT, | |
3083 * MOUSE_X1, MOUSE_X2 | |
3084 * MOUSE_DRAG, or MOUSE_RELEASE. | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3085 * 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
|
3086 * MOUSE_6 and MOUSE_7 for horizontal scroll wheel. |
7 | 3087 * x, y --- Coordinates of mouse in pixels. |
3088 * repeated_click --- TRUE if this click comes only a short time after a | |
3089 * previous click. | |
3090 * modifiers --- Bit field which may be any of the following modifiers | |
3091 * or'ed together: MOUSE_SHIFT | MOUSE_CTRL | MOUSE_ALT. | |
3092 * This function will ignore drag events where the mouse has not moved to a new | |
3093 * character. | |
3094 */ | |
3095 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3096 gui_send_mouse_event( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3097 int button, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3098 int x, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3099 int y, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3100 int repeated_click, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3101 int_u modifiers) |
7 | 3102 { |
3103 static int prev_row = 0, prev_col = 0; | |
3104 static int prev_button = -1; | |
3105 static int num_clicks = 1; | |
3106 char_u string[10]; | |
3107 enum key_extra button_char; | |
3108 int row, col; | |
3109 #ifdef FEAT_CLIPBOARD | |
3110 int checkfor; | |
3111 int did_clip = FALSE; | |
3112 #endif | |
3113 | |
3114 /* | |
3115 * Scrolling may happen at any time, also while a selection is present. | |
3116 */ | |
3117 switch (button) | |
3118 { | |
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
|
3119 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
|
3120 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
|
3121 goto button_set; |
7 | 3122 case MOUSE_X1: |
3123 button_char = KE_X1MOUSE; | |
3124 goto button_set; | |
3125 case MOUSE_X2: | |
3126 button_char = KE_X2MOUSE; | |
3127 goto button_set; | |
3128 case MOUSE_4: | |
3129 button_char = KE_MOUSEDOWN; | |
3130 goto button_set; | |
3131 case MOUSE_5: | |
3132 button_char = KE_MOUSEUP; | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3133 goto button_set; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3134 case MOUSE_6: |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3135 button_char = KE_MOUSELEFT; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3136 goto button_set; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3137 case MOUSE_7: |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
3138 button_char = KE_MOUSERIGHT; |
7 | 3139 button_set: |
3140 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3141 // Don't put events in the input queue now. |
7 | 3142 if (hold_gui_events) |
3143 return; | |
3144 | |
3145 string[3] = CSI; | |
3146 string[4] = KS_EXTRA; | |
3147 string[5] = (int)button_char; | |
3148 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3149 // 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
|
3150 // know which window to scroll. |
7 | 3151 row = gui_xy2colrow(x, y, &col); |
3152 string[6] = (char_u)(col / 128 + ' ' + 1); | |
3153 string[7] = (char_u)(col % 128 + ' ' + 1); | |
3154 string[8] = (char_u)(row / 128 + ' ' + 1); | |
3155 string[9] = (char_u)(row % 128 + ' ' + 1); | |
3156 | |
3157 if (modifiers == 0) | |
3158 add_to_input_buf(string + 3, 7); | |
3159 else | |
3160 { | |
3161 string[0] = CSI; | |
3162 string[1] = KS_MODIFIER; | |
3163 string[2] = 0; | |
3164 if (modifiers & MOUSE_SHIFT) | |
3165 string[2] |= MOD_MASK_SHIFT; | |
3166 if (modifiers & MOUSE_CTRL) | |
3167 string[2] |= MOD_MASK_CTRL; | |
3168 if (modifiers & MOUSE_ALT) | |
3169 string[2] |= MOD_MASK_ALT; | |
3170 add_to_input_buf(string, 10); | |
3171 } | |
3172 return; | |
3173 } | |
3174 } | |
3175 | |
3176 #ifdef FEAT_CLIPBOARD | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3177 // If a clipboard selection is in progress, handle it |
7 | 3178 if (clip_star.state == SELECT_IN_PROGRESS) |
3179 { | |
3180 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
|
3181 |
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
|
3182 // 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
|
3183 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
|
3184 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
|
3185 return; |
7 | 3186 } |
3187 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3188 // Determine which mouse settings to look for based on the current mode |
7 | 3189 switch (get_real_state()) |
3190 { | |
3191 case NORMAL_BUSY: | |
3192 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
|
3193 # 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
|
3194 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
|
3195 # endif |
7 | 3196 case NORMAL: checkfor = MOUSE_NORMAL; break; |
3197 case VISUAL: checkfor = MOUSE_VISUAL; break; | |
788 | 3198 case SELECTMODE: checkfor = MOUSE_VISUAL; break; |
7 | 3199 case REPLACE: |
3200 case REPLACE+LANGMAP: | |
3201 case VREPLACE: | |
3202 case VREPLACE+LANGMAP: | |
3203 case INSERT: | |
3204 case INSERT+LANGMAP: checkfor = MOUSE_INSERT; break; | |
3205 case ASKMORE: | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3206 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
|
3207 // 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
|
3208 // message line. |
7 | 3209 if (Y_2_ROW(y) >= msg_row) |
3210 checkfor = MOUSE_NORMAL; | |
3211 else | |
3212 checkfor = MOUSE_RETURN; | |
3213 break; | |
3214 | |
3215 /* | |
3216 * On the command line, use the clipboard selection on all lines | |
3217 * but the command line. But not when pasting. | |
3218 */ | |
3219 case CMDLINE: | |
3220 case CMDLINE+LANGMAP: | |
3221 if (Y_2_ROW(y) < cmdline_row && button != MOUSE_MIDDLE) | |
3222 checkfor = MOUSE_NONE; | |
3223 else | |
3224 checkfor = MOUSE_COMMAND; | |
3225 break; | |
3226 | |
3227 default: | |
3228 checkfor = MOUSE_NONE; | |
3229 break; | |
3230 }; | |
3231 | |
3232 /* | |
3233 * Allow clipboard selection of text on the command line in "normal" | |
3234 * modes. Don't do this when dragging the status line, or extending a | |
3235 * Visual selection. | |
3236 */ | |
3237 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
|
3238 && Y_2_ROW(y) >= topframe->fr_height + firstwin->w_winrow |
7 | 3239 && button != MOUSE_DRAG |
3240 # ifdef FEAT_MOUSESHAPE | |
3241 && !drag_status_line | |
3242 && !drag_sep_line | |
3243 # endif | |
3244 ) | |
3245 checkfor = MOUSE_NONE; | |
3246 | |
3247 /* | |
3248 * Use modeless selection when holding CTRL and SHIFT pressed. | |
3249 */ | |
3250 if ((modifiers & MOUSE_CTRL) && (modifiers & MOUSE_SHIFT)) | |
3251 checkfor = MOUSE_NONEF; | |
3252 | |
3253 /* | |
3254 * In Ex mode, always use modeless selection. | |
3255 */ | |
3256 if (exmode_active) | |
3257 checkfor = MOUSE_NONE; | |
3258 | |
3259 /* | |
3260 * If the mouse settings say to not use the mouse, use the modeless | |
3261 * selection. But if Visual is active, assume that only the Visual area | |
3262 * will be selected. | |
3263 * 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
|
3264 * key is sent. |
7 | 3265 */ |
3266 if (!mouse_has(checkfor) || checkfor == MOUSE_COMMAND) | |
3267 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3268 // Don't do modeless selection in Visual mode. |
7 | 3269 if (checkfor != MOUSE_NONEF && VIsual_active && (State & NORMAL)) |
3270 return; | |
3271 | |
3272 /* | |
3273 * When 'mousemodel' is "popup", shift-left is translated to right. | |
3274 * But not when also using Ctrl. | |
3275 */ | |
3276 if (mouse_model_popup() && button == MOUSE_LEFT | |
3277 && (modifiers & MOUSE_SHIFT) && !(modifiers & MOUSE_CTRL)) | |
3278 { | |
3279 button = MOUSE_RIGHT; | |
3280 modifiers &= ~ MOUSE_SHIFT; | |
3281 } | |
3282 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3283 // 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
|
3284 // 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
|
3285 // from the cursor position. |
7 | 3286 if (button == MOUSE_RIGHT) |
3287 { | |
3288 if (clip_star.state == SELECT_CLEARED) | |
3289 { | |
3290 if (State & CMDLINE) | |
3291 { | |
3292 col = msg_col; | |
3293 row = msg_row; | |
3294 } | |
3295 else | |
3296 { | |
3297 col = curwin->w_wcol; | |
3298 row = curwin->w_wrow + W_WINROW(curwin); | |
3299 } | |
3300 clip_start_selection(col, row, FALSE); | |
3301 } | |
3302 clip_process_selection(button, X_2_COL(x), Y_2_ROW(y), | |
3303 repeated_click); | |
3304 did_clip = TRUE; | |
3305 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3306 // Allow the left button to start the selection |
2823 | 3307 else if (button == MOUSE_LEFT) |
7 | 3308 { |
3309 clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click); | |
3310 did_clip = TRUE; | |
3311 } | |
3312 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3313 // Always allow pasting |
7 | 3314 if (button != MOUSE_MIDDLE) |
3315 { | |
3316 if (!mouse_has(checkfor) || button == MOUSE_RELEASE) | |
3317 return; | |
3318 if (checkfor != MOUSE_COMMAND) | |
3319 button = MOUSE_LEFT; | |
3320 } | |
3321 repeated_click = FALSE; | |
3322 } | |
3323 | |
3324 if (clip_star.state != SELECT_CLEARED && !did_clip) | |
3674 | 3325 clip_clear_selection(&clip_star); |
7 | 3326 #endif |
3327 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3328 // Don't put events in the input queue now. |
7 | 3329 if (hold_gui_events) |
3330 return; | |
3331 | |
3332 row = gui_xy2colrow(x, y, &col); | |
3333 | |
3334 /* | |
3335 * If we are dragging and the mouse hasn't moved far enough to be on a | |
3336 * different character, then don't send an event to vim. | |
3337 */ | |
3338 if (button == MOUSE_DRAG) | |
3339 { | |
3340 if (row == prev_row && col == prev_col) | |
3341 return; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3342 // Dragging above the window, set "row" to -1 to cause a scroll. |
7 | 3343 if (y < 0) |
3344 row = -1; | |
3345 } | |
3346 | |
3347 /* | |
3348 * If topline has changed (window scrolled) since the last click, reset | |
3349 * repeated_click, because we don't want starting Visual mode when | |
3350 * clicking on a different character in the text. | |
3351 */ | |
3352 if (curwin->w_topline != gui_prev_topline | |
3353 #ifdef FEAT_DIFF | |
3354 || curwin->w_topfill != gui_prev_topfill | |
3355 #endif | |
3356 ) | |
3357 repeated_click = FALSE; | |
3358 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3359 string[0] = CSI; // this sequence is recognized by check_termcode() |
7 | 3360 string[1] = KS_MOUSE; |
3361 string[2] = KE_FILLER; | |
3362 if (button != MOUSE_DRAG && button != MOUSE_RELEASE) | |
3363 { | |
3364 if (repeated_click) | |
3365 { | |
3366 /* | |
3367 * Handle multiple clicks. They only count if the mouse is still | |
3368 * pointing at the same character. | |
3369 */ | |
3370 if (button != prev_button || row != prev_row || col != prev_col) | |
3371 num_clicks = 1; | |
3372 else if (++num_clicks > 4) | |
3373 num_clicks = 1; | |
3374 } | |
3375 else | |
3376 num_clicks = 1; | |
3377 prev_button = button; | |
3378 gui_prev_topline = curwin->w_topline; | |
3379 #ifdef FEAT_DIFF | |
3380 gui_prev_topfill = curwin->w_topfill; | |
3381 #endif | |
3382 | |
3383 string[3] = (char_u)(button | 0x20); | |
3384 SET_NUM_MOUSE_CLICKS(string[3], num_clicks); | |
3385 } | |
3386 else | |
3387 string[3] = (char_u)button; | |
3388 | |
3389 string[3] |= modifiers; | |
3390 fill_mouse_coord(string + 4, col, row); | |
3391 add_to_input_buf(string, 8); | |
3392 | |
3393 if (row < 0) | |
3394 prev_row = 0; | |
3395 else | |
3396 prev_row = row; | |
3397 prev_col = col; | |
3398 | |
3399 /* | |
3400 * We need to make sure this is cleared since Athena doesn't tell us when | |
3401 * he is done dragging. Neither does GTK+ 2 -- at least for now. | |
3402 */ | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
3403 #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) |
7 | 3404 gui.dragged_sb = SBAR_NONE; |
3405 #endif | |
3406 } | |
3407 | |
3408 /* | |
3409 * Convert x and y coordinate to column and row in text window. | |
3410 * Corrects for multi-byte character. | |
3411 * returns column in "*colp" and row as return value; | |
3412 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17407
diff
changeset
|
3413 static int |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3414 gui_xy2colrow(int x, int y, int *colp) |
7 | 3415 { |
3416 int col = check_col(X_2_COL(x)); | |
3417 int row = check_row(Y_2_ROW(y)); | |
3418 | |
3419 *colp = mb_fix_col(col, row); | |
3420 return row; | |
3421 } | |
3422 | |
3423 #if defined(FEAT_MENU) || defined(PROTO) | |
3424 /* | |
3425 * Callback function for when a menu entry has been selected. | |
3426 */ | |
3427 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3428 gui_menu_cb(vimmenu_T *menu) |
7 | 3429 { |
664 | 3430 char_u bytes[sizeof(long_u)]; |
7 | 3431 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3432 // Don't put events in the input queue now. |
7 | 3433 if (hold_gui_events) |
3434 return; | |
3435 | |
3436 bytes[0] = CSI; | |
3437 bytes[1] = KS_MENU; | |
3438 bytes[2] = KE_FILLER; | |
664 | 3439 add_to_input_buf(bytes, 3); |
3440 add_long_to_buf((long_u)menu, bytes); | |
3441 add_to_input_buf_csi(bytes, sizeof(long_u)); | |
7 | 3442 } |
3443 #endif | |
3444 | |
811 | 3445 static int prev_which_scrollbars[3]; |
669 | 3446 |
7 | 3447 /* |
3448 * Set which components are present. | |
685 | 3449 * If "oldval" is not NULL, "oldval" is the previous value, the new value is |
7 | 3450 * in p_go. |
3451 */ | |
3452 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3453 gui_init_which_components(char_u *oldval UNUSED) |
7 | 3454 { |
18078
5ae41d0ea397
patch 8.1.2034: dark them of GTK 3 not supported
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3455 #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
|
3456 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
|
3457 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
|
3458 #endif |
7 | 3459 #ifdef FEAT_MENU |
3460 static int prev_menu_is_active = -1; | |
3461 #endif | |
3462 #ifdef FEAT_TOOLBAR | |
3463 static int prev_toolbar = -1; | |
3464 int using_toolbar = FALSE; | |
3465 #endif | |
685 | 3466 #ifdef FEAT_GUI_TABLINE |
3467 int using_tabline; | |
3468 #endif | |
7 | 3469 #ifdef FEAT_FOOTER |
3470 static int prev_footer = -1; | |
3471 int using_footer = FALSE; | |
3472 #endif | |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3473 #if defined(FEAT_MENU) |
7 | 3474 static int prev_tearoff = -1; |
3475 int using_tearoff = FALSE; | |
3476 #endif | |
3477 | |
3478 char_u *p; | |
3479 int i; | |
3480 #ifdef FEAT_MENU | |
3481 int grey_old, grey_new; | |
3482 char_u *temp; | |
3483 #endif | |
3484 win_T *wp; | |
3485 int need_set_size; | |
3486 int fix_size; | |
3487 | |
3488 #ifdef FEAT_MENU | |
3489 if (oldval != NULL && gui.in_use) | |
3490 { | |
3491 /* | |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
3492 * Check if the menus go from grey to non-grey or vice versa. |
7 | 3493 */ |
3494 grey_old = (vim_strchr(oldval, GO_GREY) != NULL); | |
3495 grey_new = (vim_strchr(p_go, GO_GREY) != NULL); | |
3496 if (grey_old != grey_new) | |
3497 { | |
3498 temp = p_go; | |
3499 p_go = oldval; | |
3500 gui_update_menus(MENU_ALL_MODES); | |
3501 p_go = temp; | |
3502 } | |
3503 } | |
3504 gui.menu_is_active = FALSE; | |
3505 #endif | |
3506 | |
3507 for (i = 0; i < 3; i++) | |
3508 gui.which_scrollbars[i] = FALSE; | |
3509 for (p = p_go; *p; p++) | |
3510 switch (*p) | |
3511 { | |
3512 case GO_LEFT: | |
3513 gui.which_scrollbars[SBAR_LEFT] = TRUE; | |
3514 break; | |
3515 case GO_RIGHT: | |
3516 gui.which_scrollbars[SBAR_RIGHT] = TRUE; | |
3517 break; | |
3518 case GO_VLEFT: | |
3519 if (win_hasvertsplit()) | |
3520 gui.which_scrollbars[SBAR_LEFT] = TRUE; | |
3521 break; | |
3522 case GO_VRIGHT: | |
3523 if (win_hasvertsplit()) | |
3524 gui.which_scrollbars[SBAR_RIGHT] = TRUE; | |
3525 break; | |
3526 case GO_BOT: | |
3527 gui.which_scrollbars[SBAR_BOTTOM] = TRUE; | |
3528 break; | |
18078
5ae41d0ea397
patch 8.1.2034: dark them of GTK 3 not supported
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3529 #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
|
3530 case GO_DARKTHEME: |
5ae41d0ea397
patch 8.1.2034: dark them of GTK 3 not supported
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3531 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
|
3532 break; |
5ae41d0ea397
patch 8.1.2034: dark them of GTK 3 not supported
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3533 #endif |
7 | 3534 #ifdef FEAT_MENU |
3535 case GO_MENUS: | |
3536 gui.menu_is_active = TRUE; | |
3537 break; | |
3538 #endif | |
3539 case GO_GREY: | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3540 // make menu's have grey items, ignored here |
7 | 3541 break; |
3542 #ifdef FEAT_TOOLBAR | |
3543 case GO_TOOLBAR: | |
3544 using_toolbar = TRUE; | |
3545 break; | |
3546 #endif | |
3547 #ifdef FEAT_FOOTER | |
3548 case GO_FOOTER: | |
3549 using_footer = TRUE; | |
3550 break; | |
3551 #endif | |
3552 case GO_TEAROFF: | |
8140
563c923b1584
commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
3553 #if defined(FEAT_MENU) |
7 | 3554 using_tearoff = TRUE; |
3555 #endif | |
3556 break; | |
3557 default: | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3558 // Ignore options that are not supported |
7 | 3559 break; |
3560 } | |
685 | 3561 |
7 | 3562 if (gui.in_use) |
3563 { | |
811 | 3564 need_set_size = 0; |
7 | 3565 fix_size = FALSE; |
685 | 3566 |
18078
5ae41d0ea397
patch 8.1.2034: dark them of GTK 3 not supported
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3567 #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
|
3568 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
|
3569 { |
5ae41d0ea397
patch 8.1.2034: dark them of GTK 3 not supported
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3570 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
|
3571 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
|
3572 } |
5ae41d0ea397
patch 8.1.2034: dark them of GTK 3 not supported
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3573 #endif |
5ae41d0ea397
patch 8.1.2034: dark them of GTK 3 not supported
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
3574 |
685 | 3575 #ifdef FEAT_GUI_TABLINE |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3576 // 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
|
3577 // cause the non-GUI tab line to disappear or appear. |
685 | 3578 using_tabline = gui_has_tabline(); |
706 | 3579 if (!gui_mch_showing_tabline() != !using_tabline) |
685 | 3580 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3581 // 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
|
3582 // restore it. Resizing is handled below. |
797 | 3583 i = Rows; |
685 | 3584 gui_update_tabline(); |
797 | 3585 Rows = i; |
1767 | 3586 need_set_size |= RESIZE_VERT; |
685 | 3587 if (using_tabline) |
3588 fix_size = TRUE; | |
3589 if (!gui_use_tabline()) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3590 redraw_tabline = TRUE; // may draw non-GUI tab line |
685 | 3591 } |
3592 #endif | |
3593 | |
7 | 3594 for (i = 0; i < 3; i++) |
3595 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3596 // 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
|
3597 // 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
|
3598 // 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
|
3599 // scrollbar is there or not. |
811 | 3600 if (gui.which_scrollbars[i] != prev_which_scrollbars[i] |
3601 || 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
|
3602 != curtab->tp_prev_which_scrollbars[i]) |
7 | 3603 { |
3604 if (i == SBAR_BOTTOM) | |
3605 gui_mch_enable_scrollbar(&gui.bottom_sbar, | |
3606 gui.which_scrollbars[i]); | |
3607 else | |
3608 { | |
3609 FOR_ALL_WINDOWS(wp) | |
3610 gui_do_scrollbar(wp, i, gui.which_scrollbars[i]); | |
3611 } | |
811 | 3612 if (gui.which_scrollbars[i] != prev_which_scrollbars[i]) |
3613 { | |
3614 if (i == SBAR_BOTTOM) | |
1767 | 3615 need_set_size |= RESIZE_VERT; |
811 | 3616 else |
1767 | 3617 need_set_size |= RESIZE_HOR; |
811 | 3618 if (gui.which_scrollbars[i]) |
3619 fix_size = TRUE; | |
3620 } | |
7 | 3621 } |
811 | 3622 curtab->tp_prev_which_scrollbars[i] = gui.which_scrollbars[i]; |
3623 prev_which_scrollbars[i] = gui.which_scrollbars[i]; | |
7 | 3624 } |
3625 | |
3626 #ifdef FEAT_MENU | |
3627 if (gui.menu_is_active != prev_menu_is_active) | |
3628 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3629 // 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
|
3630 // restore it. Resizing is handled below. |
7 | 3631 i = Rows; |
3632 gui_mch_enable_menu(gui.menu_is_active); | |
3633 Rows = i; | |
3634 prev_menu_is_active = gui.menu_is_active; | |
1767 | 3635 need_set_size |= RESIZE_VERT; |
7 | 3636 if (gui.menu_is_active) |
3637 fix_size = TRUE; | |
3638 } | |
3639 #endif | |
3640 | |
3641 #ifdef FEAT_TOOLBAR | |
3642 if (using_toolbar != prev_toolbar) | |
3643 { | |
3644 gui_mch_show_toolbar(using_toolbar); | |
3645 prev_toolbar = using_toolbar; | |
1767 | 3646 need_set_size |= RESIZE_VERT; |
7 | 3647 if (using_toolbar) |
3648 fix_size = TRUE; | |
3649 } | |
3650 #endif | |
3651 #ifdef FEAT_FOOTER | |
3652 if (using_footer != prev_footer) | |
3653 { | |
3654 gui_mch_enable_footer(using_footer); | |
3655 prev_footer = using_footer; | |
1767 | 3656 need_set_size |= RESIZE_VERT; |
7 | 3657 if (using_footer) |
3658 fix_size = TRUE; | |
3659 } | |
3660 #endif | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
3661 #if defined(FEAT_MENU) && !(defined(MSWIN) && !defined(FEAT_TEAROFF)) |
7 | 3662 if (using_tearoff != prev_tearoff) |
3663 { | |
3664 gui_mch_toggle_tearoffs(using_tearoff); | |
3665 prev_tearoff = using_tearoff; | |
3666 } | |
3667 #endif | |
1767 | 3668 if (need_set_size != 0) |
276 | 3669 { |
3670 #ifdef FEAT_GUI_GTK | |
1767 | 3671 long prev_Columns = Columns; |
3672 long prev_Rows = Rows; | |
276 | 3673 #endif |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3674 // 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
|
3675 // 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
|
3676 // and a scrollbar can't be used, for example. |
811 | 3677 gui_set_shellsize(FALSE, fix_size, need_set_size); |
276 | 3678 |
3679 #ifdef FEAT_GUI_GTK | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3680 // 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
|
3681 // 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
|
3682 // 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
|
3683 // 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
|
3684 // 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
|
3685 // 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
|
3686 // 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
|
3687 // 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
|
3688 // 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
|
3689 // Don't change Columns when adding vertical toolbar. |
1767 | 3690 if (!gui.starting && need_set_size != (RESIZE_VERT | RESIZE_HOR)) |
287 | 3691 (void)char_avail(); |
1767 | 3692 if ((need_set_size & RESIZE_VERT) == 0) |
3693 Rows = prev_Rows; | |
3694 if ((need_set_size & RESIZE_HOR) == 0) | |
3695 Columns = prev_Columns; | |
276 | 3696 #endif |
3697 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3698 // 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
|
3699 // change. |
687 | 3700 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
|
3701 shell_new_rows(); // recompute window positions and heights |
7 | 3702 } |
3703 } | |
3704 | |
685 | 3705 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) |
3706 /* | |
3707 * Return TRUE if the GUI is taking care of the tabline. | |
3708 * It may still be hidden if 'showtabline' is zero. | |
3709 */ | |
3710 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3711 gui_use_tabline(void) |
685 | 3712 { |
3713 return gui.in_use && vim_strchr(p_go, GO_TABLINE) != NULL; | |
3714 } | |
3715 | |
3716 /* | |
3717 * Return TRUE if the GUI is showing the tabline. | |
3718 * This uses 'showtabline'. | |
3719 */ | |
3720 static int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3721 gui_has_tabline(void) |
685 | 3722 { |
3723 if (!gui_use_tabline() | |
3724 || p_stal == 0 | |
3725 || (p_stal == 1 && first_tabpage->tp_next == NULL)) | |
3726 return FALSE; | |
3727 return TRUE; | |
3728 } | |
3729 | |
3730 /* | |
3731 * Update the tabline. | |
3732 * This may display/undisplay the tabline and update the labels. | |
3733 */ | |
3734 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3735 gui_update_tabline(void) |
685 | 3736 { |
3737 int showit = gui_has_tabline(); | |
797 | 3738 int shown = gui_mch_showing_tabline(); |
685 | 3739 |
3740 if (!gui.starting && starting == 0) | |
3741 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3742 // 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
|
3743 // outstanding instructions first. (esp. clear screen) |
848 | 3744 out_flush(); |
3745 | |
797 | 3746 if (!showit != !shown) |
3747 gui_mch_show_tabline(showit); | |
685 | 3748 if (showit != 0) |
3749 gui_mch_update_tabline(); | |
797 | 3750 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3751 // 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
|
3752 // hidden the size of the text area should remain the same. |
797 | 3753 if (!showit != !shown) |
811 | 3754 gui_set_shellsize(FALSE, showit, RESIZE_VERT); |
685 | 3755 } |
3756 } | |
3757 | |
3758 /* | |
839 | 3759 * Get the label or tooltip for tab page "tp" into NameBuff[]. |
685 | 3760 */ |
3761 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3762 get_tabline_label( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3763 tabpage_T *tp, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3764 int tooltip) // TRUE: get tooltip |
685 | 3765 { |
3766 int modified = FALSE; | |
3767 char_u buf[40]; | |
3768 int wincount; | |
3769 win_T *wp; | |
857 | 3770 char_u **opt; |
839 | 3771 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3772 // Use 'guitablabel' or 'guitabtooltip' if it's set. |
857 | 3773 opt = (tooltip ? &p_gtt : &p_gtl); |
3774 if (**opt != NUL) | |
685 | 3775 { |
687 | 3776 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
|
3777 int called_emsg_before = called_emsg; |
687 | 3778 char_u res[MAXPATHL]; |
706 | 3779 tabpage_T *save_curtab; |
839 | 3780 char_u *opt_name = (char_u *)(tooltip ? "guitabtooltip" |
3781 : "guitablabel"); | |
687 | 3782 |
3783 printer_page_num = tabpage_index(tp); | |
3784 # ifdef FEAT_EVAL | |
3785 set_vim_var_nr(VV_LNUM, printer_page_num); | |
839 | 3786 use_sandbox = was_set_insecurely(opt_name, 0); |
687 | 3787 # endif |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3788 // It's almost as going to the tabpage, but without autocommands. |
706 | 3789 curtab->tp_firstwin = firstwin; |
3790 curtab->tp_lastwin = lastwin; | |
3791 curtab->tp_curwin = curwin; | |
3792 save_curtab = curtab; | |
3793 curtab = tp; | |
3794 topframe = curtab->tp_topframe; | |
3795 firstwin = curtab->tp_firstwin; | |
3796 lastwin = curtab->tp_lastwin; | |
3797 curwin = curtab->tp_curwin; | |
3798 curbuf = curwin->w_buffer; | |
3799 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3800 // Can't use NameBuff directly, build_stl_str_hl() uses it. |
857 | 3801 build_stl_str_hl(curwin, res, MAXPATHL, *opt, use_sandbox, |
706 | 3802 0, (int)Columns, NULL, NULL); |
687 | 3803 STRCPY(NameBuff, res); |
3804 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3805 // Back to the original curtab. |
706 | 3806 curtab = save_curtab; |
3807 topframe = curtab->tp_topframe; | |
3808 firstwin = curtab->tp_firstwin; | |
3809 lastwin = curtab->tp_lastwin; | |
3810 curwin = curtab->tp_curwin; | |
3811 curbuf = curwin->w_buffer; | |
3812 | |
18949
5c405689da3e
patch 8.2.0035: saving and restoring called_emsg is clumsy
Bram Moolenaar <Bram@vim.org>
parents:
18922
diff
changeset
|
3813 if (called_emsg > called_emsg_before) |
839 | 3814 set_string_option_direct(opt_name, -1, |
694 | 3815 (char_u *)"", OPT_FREE, SID_ERROR); |
687 | 3816 } |
857 | 3817 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3818 // 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
|
3819 // use a default label. |
857 | 3820 if (**opt == NUL || *NameBuff == NUL) |
687 | 3821 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3822 // Get the buffer name into NameBuff[] and shorten it. |
687 | 3823 get_trans_bufname(tp == curtab ? curbuf : tp->tp_curwin->w_buffer); |
839 | 3824 if (!tooltip) |
3825 shorten_dir(NameBuff); | |
687 | 3826 |
3827 wp = (tp == curtab) ? firstwin : tp->tp_firstwin; | |
3828 for (wincount = 0; wp != NULL; wp = wp->w_next, ++wincount) | |
3829 if (bufIsChanged(wp->w_buffer)) | |
3830 modified = TRUE; | |
3831 if (modified || wincount > 1) | |
3832 { | |
3833 if (wincount > 1) | |
3834 vim_snprintf((char *)buf, sizeof(buf), "%d", wincount); | |
3835 else | |
3836 buf[0] = NUL; | |
3837 if (modified) | |
3838 STRCAT(buf, "+"); | |
3839 STRCAT(buf, " "); | |
1620 | 3840 STRMOVE(NameBuff + STRLEN(buf), NameBuff); |
687 | 3841 mch_memmove(NameBuff, buf, STRLEN(buf)); |
3842 } | |
685 | 3843 } |
3844 } | |
3845 | |
691 | 3846 /* |
3847 * Send the event for clicking to select tab page "nr". | |
3848 * Returns TRUE if it was done, FALSE when skipped because we are already at | |
838 | 3849 * that tab page or the cmdline window is open. |
691 | 3850 */ |
3851 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3852 send_tabline_event(int nr) |
691 | 3853 { |
3854 char_u string[3]; | |
3855 | |
3856 if (nr == tabpage_index(curtab)) | |
3857 return FALSE; | |
844 | 3858 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3859 // Don't put events in the input queue now. |
844 | 3860 if (hold_gui_events |
838 | 3861 # ifdef FEAT_CMDWIN |
844 | 3862 || cmdwin_type != 0 |
3863 # endif | |
3864 ) | |
838 | 3865 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3866 // Set it back to the current tab page. |
838 | 3867 gui_mch_set_curtab(tabpage_index(curtab)); |
3868 return FALSE; | |
3869 } | |
844 | 3870 |
691 | 3871 string[0] = CSI; |
3872 string[1] = KS_TABLINE; | |
3873 string[2] = KE_FILLER; | |
3874 add_to_input_buf(string, 3); | |
3875 string[0] = nr; | |
3876 add_to_input_buf_csi(string, 1); | |
3877 return TRUE; | |
3878 } | |
3879 | |
824 | 3880 /* |
3881 * Send a tabline menu event | |
3882 */ | |
3883 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3884 send_tabline_menu_event(int tabidx, int event) |
824 | 3885 { |
3886 char_u string[3]; | |
3887 | |
15134
f2972ff144ab
patch 8.1.0577: tabpage right-click menu never shows "Close tab"
Bram Moolenaar <Bram@vim.org>
parents:
15115
diff
changeset
|
3888 // Don't put events in the input queue now. |
844 | 3889 if (hold_gui_events) |
3890 return; | |
3891 | |
15134
f2972ff144ab
patch 8.1.0577: tabpage right-click menu never shows "Close tab"
Bram Moolenaar <Bram@vim.org>
parents:
15115
diff
changeset
|
3892 // 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
|
3893 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
|
3894 return; |
f2972ff144ab
patch 8.1.0577: tabpage right-click menu never shows "Close tab"
Bram Moolenaar <Bram@vim.org>
parents:
15115
diff
changeset
|
3895 |
824 | 3896 string[0] = CSI; |
3897 string[1] = KS_TABMENU; | |
3898 string[2] = KE_FILLER; | |
3899 add_to_input_buf(string, 3); | |
3900 string[0] = tabidx; | |
3901 string[1] = (char_u)(long)event; | |
3902 add_to_input_buf_csi(string, 2); | |
3903 } | |
3904 | |
685 | 3905 #endif |
7 | 3906 |
3907 /* | |
3908 * Scrollbar stuff: | |
3909 */ | |
3910 | |
669 | 3911 /* |
3912 * Remove all scrollbars. Used before switching to another tab page. | |
3913 */ | |
3914 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3915 gui_remove_scrollbars(void) |
669 | 3916 { |
3917 int i; | |
3918 win_T *wp; | |
3919 | |
3920 for (i = 0; i < 3; i++) | |
3921 { | |
3922 if (i == SBAR_BOTTOM) | |
3923 gui_mch_enable_scrollbar(&gui.bottom_sbar, FALSE); | |
3924 else | |
3925 { | |
3926 FOR_ALL_WINDOWS(wp) | |
3927 gui_do_scrollbar(wp, i, FALSE); | |
3928 } | |
788 | 3929 curtab->tp_prev_which_scrollbars[i] = -1; |
669 | 3930 } |
3931 } | |
3932 | |
7 | 3933 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3934 gui_create_scrollbar(scrollbar_T *sb, int type, win_T *wp) |
7 | 3935 { |
3936 static int sbar_ident = 0; | |
3937 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3938 sb->ident = sbar_ident++; // No check for too big, but would it happen? |
7 | 3939 sb->wp = wp; |
3940 sb->type = type; | |
3941 sb->value = 0; | |
3942 #ifdef FEAT_GUI_ATHENA | |
3943 sb->pixval = 0; | |
3944 #endif | |
3945 sb->size = 1; | |
3946 sb->max = 1; | |
3947 sb->top = 0; | |
3948 sb->height = 0; | |
3949 sb->width = 0; | |
3950 sb->status_height = 0; | |
3951 gui_mch_create_scrollbar(sb, (wp == NULL) ? SBAR_HORIZ : SBAR_VERT); | |
3952 } | |
3953 | |
3954 /* | |
3955 * Find the scrollbar with the given index. | |
3956 */ | |
3957 scrollbar_T * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3958 gui_find_scrollbar(long ident) |
7 | 3959 { |
3960 win_T *wp; | |
3961 | |
3962 if (gui.bottom_sbar.ident == ident) | |
3963 return &gui.bottom_sbar; | |
3964 FOR_ALL_WINDOWS(wp) | |
3965 { | |
3966 if (wp->w_scrollbars[SBAR_LEFT].ident == ident) | |
3967 return &wp->w_scrollbars[SBAR_LEFT]; | |
3968 if (wp->w_scrollbars[SBAR_RIGHT].ident == ident) | |
3969 return &wp->w_scrollbars[SBAR_RIGHT]; | |
3970 } | |
3971 return NULL; | |
3972 } | |
3973 | |
3974 /* | |
3975 * For most systems: Put a code in the input buffer for a dragged scrollbar. | |
3976 * | |
3977 * For Win32, Macintosh and GTK+ 2: | |
3978 * Scrollbars seem to grab focus and vim doesn't read the input queue until | |
3979 * you stop dragging the scrollbar. We get here each time the scrollbar is | |
3980 * dragged another pixel, but as far as the rest of vim goes, it thinks | |
3981 * we're just hanging in the call to DispatchMessage() in | |
3982 * process_message(). The DispatchMessage() call that hangs was passed a | |
3983 * mouse button click event in the scrollbar window. -- webb. | |
3984 * | |
3985 * Solution: Do the scrolling right here. But only when allowed. | |
3986 * Ignore the scrollbars while executing an external command or when there | |
3987 * are still characters to be processed. | |
3988 */ | |
3989 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
3990 gui_drag_scrollbar(scrollbar_T *sb, long value, int still_dragging) |
7 | 3991 { |
3992 win_T *wp; | |
3993 int sb_num; | |
3994 #ifdef USE_ON_FLY_SCROLL | |
3995 colnr_T old_leftcol = curwin->w_leftcol; | |
3996 linenr_T old_topline = curwin->w_topline; | |
3997 # ifdef FEAT_DIFF | |
3998 int old_topfill = curwin->w_topfill; | |
3999 # endif | |
4000 #else | |
664 | 4001 char_u bytes[sizeof(long_u)]; |
7 | 4002 int byte_count; |
4003 #endif | |
4004 | |
4005 if (sb == NULL) | |
4006 return; | |
4007 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4008 // Don't put events in the input queue now. |
7 | 4009 if (hold_gui_events) |
4010 return; | |
4011 | |
4012 #ifdef FEAT_CMDWIN | |
4013 if (cmdwin_type != 0 && sb->wp != curwin) | |
4014 return; | |
4015 #endif | |
4016 | |
4017 if (still_dragging) | |
4018 { | |
4019 if (sb->wp == NULL) | |
4020 gui.dragged_sb = SBAR_BOTTOM; | |
4021 else if (sb == &sb->wp->w_scrollbars[SBAR_LEFT]) | |
4022 gui.dragged_sb = SBAR_LEFT; | |
4023 else | |
4024 gui.dragged_sb = SBAR_RIGHT; | |
4025 gui.dragged_wp = sb->wp; | |
4026 } | |
4027 else | |
4028 { | |
4029 gui.dragged_sb = SBAR_NONE; | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
4030 #ifdef FEAT_GUI_GTK |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4031 // 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
|
4032 // mouse button is released. GTK2 doesn't send the button-up event. |
7 | 4033 gui.dragged_wp = NULL; |
4034 #endif | |
4035 } | |
4036 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4037 // Vertical sbar info is kept in the first sbar (the left one) |
7 | 4038 if (sb->wp != NULL) |
4039 sb = &sb->wp->w_scrollbars[0]; | |
4040 | |
4041 /* | |
4042 * Check validity of value | |
4043 */ | |
4044 if (value < 0) | |
4045 value = 0; | |
4046 #ifdef SCROLL_PAST_END | |
4047 else if (value > sb->max) | |
4048 value = sb->max; | |
4049 #else | |
4050 if (value > sb->max - sb->size + 1) | |
4051 value = sb->max - sb->size + 1; | |
4052 #endif | |
4053 | |
4054 sb->value = value; | |
4055 | |
4056 #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
|
4057 // 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
|
4058 // 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
|
4059 // a scrollbar to be ignored when Vim doesn't have focus. |
1476 | 4060 if (dont_scroll) |
7 | 4061 return; |
4062 #endif | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4063 // 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
|
4064 // visible. |
973 | 4065 if ((sb->wp == NULL || sb->wp == curwin) && pum_visible()) |
4066 return; | |
7 | 4067 |
4068 #ifdef FEAT_RIGHTLEFT | |
4069 if (sb->wp == NULL && curwin->w_p_rl) | |
4070 { | |
4071 value = sb->max + 1 - sb->size - value; | |
4072 if (value < 0) | |
4073 value = 0; | |
4074 } | |
4075 #endif | |
4076 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4077 if (sb->wp != NULL) // vertical scrollbar |
7 | 4078 { |
4079 sb_num = 0; | |
4080 for (wp = firstwin; wp != sb->wp && wp != NULL; wp = wp->w_next) | |
4081 sb_num++; | |
4082 if (wp == NULL) | |
4083 return; | |
4084 | |
4085 #ifdef USE_ON_FLY_SCROLL | |
4086 current_scrollbar = sb_num; | |
4087 scrollbar_value = value; | |
4088 if (State & NORMAL) | |
4089 { | |
4090 gui_do_scroll(); | |
4091 setcursor(); | |
4092 } | |
4093 else if (State & INSERT) | |
4094 { | |
4095 ins_scroll(); | |
4096 setcursor(); | |
4097 } | |
4098 else if (State & CMDLINE) | |
4099 { | |
4100 if (msg_scrolled == 0) | |
4101 { | |
4102 gui_do_scroll(); | |
4103 redrawcmdline(); | |
4104 } | |
4105 } | |
4106 # ifdef FEAT_FOLDING | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4107 // Value may have been changed for closed fold. |
7 | 4108 sb->value = sb->wp->w_topline - 1; |
4109 # endif | |
788 | 4110 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4111 // 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
|
4112 // side move the thumb of that one too. |
788 | 4113 if (gui.which_scrollbars[SBAR_RIGHT] && gui.which_scrollbars[SBAR_LEFT]) |
4114 gui_mch_set_scrollbar_thumb( | |
4115 &sb->wp->w_scrollbars[ | |
4116 sb == &sb->wp->w_scrollbars[SBAR_RIGHT] | |
4117 ? SBAR_LEFT : SBAR_RIGHT], | |
4118 sb->value, sb->size, sb->max); | |
4119 | |
7 | 4120 #else |
4121 bytes[0] = CSI; | |
4122 bytes[1] = KS_VER_SCROLLBAR; | |
4123 bytes[2] = KE_FILLER; | |
4124 bytes[3] = (char_u)sb_num; | |
4125 byte_count = 4; | |
4126 #endif | |
4127 } | |
4128 else | |
4129 { | |
4130 #ifdef USE_ON_FLY_SCROLL | |
4131 scrollbar_value = value; | |
4132 | |
4133 if (State & NORMAL) | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4134 gui_do_horiz_scroll(scrollbar_value, FALSE); |
7 | 4135 else if (State & INSERT) |
4136 ins_horscroll(); | |
4137 else if (State & CMDLINE) | |
4138 { | |
540 | 4139 if (msg_scrolled == 0) |
7 | 4140 { |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4141 gui_do_horiz_scroll(scrollbar_value, FALSE); |
7 | 4142 redrawcmdline(); |
4143 } | |
4144 } | |
4145 if (old_leftcol != curwin->w_leftcol) | |
4146 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4147 updateWindow(curwin); // update window, status and cmdline |
7 | 4148 setcursor(); |
4149 } | |
4150 #else | |
4151 bytes[0] = CSI; | |
4152 bytes[1] = KS_HOR_SCROLLBAR; | |
4153 bytes[2] = KE_FILLER; | |
4154 byte_count = 3; | |
4155 #endif | |
4156 } | |
4157 | |
4158 #ifdef USE_ON_FLY_SCROLL | |
4159 /* | |
4160 * synchronize other windows, as necessary according to 'scrollbind' | |
4161 */ | |
4162 if (curwin->w_p_scb | |
4163 && ((sb->wp == NULL && curwin->w_leftcol != old_leftcol) | |
4164 || (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
|
4165 # ifdef FEAT_DIFF |
7 | 4166 || curwin->w_topfill != old_topfill |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
4167 # endif |
7 | 4168 )))) |
4169 { | |
4170 do_check_scrollbind(TRUE); | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4171 // 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
|
4172 FOR_ALL_WINDOWS(wp) |
7 | 4173 if (wp->w_redr_type > 0) |
4174 updateWindow(wp); | |
4175 setcursor(); | |
4176 } | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
4177 out_flush_cursor(FALSE, TRUE); |
7 | 4178 #else |
664 | 4179 add_to_input_buf(bytes, byte_count); |
4180 add_long_to_buf((long_u)value, bytes); | |
4181 add_to_input_buf_csi(bytes, sizeof(long_u)); | |
7 | 4182 #endif |
4183 } | |
4184 | |
4185 /* | |
4186 * Scrollbar stuff: | |
4187 */ | |
4188 | |
1906 | 4189 /* |
4190 * Called when something in the window layout has changed. | |
4191 */ | |
4192 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4193 gui_may_update_scrollbars(void) |
1906 | 4194 { |
4195 if (gui.in_use && starting == 0) | |
4196 { | |
4197 out_flush(); | |
4198 gui_init_which_components(NULL); | |
4199 gui_update_scrollbars(TRUE); | |
4200 } | |
4201 need_mouse_correct = TRUE; | |
4202 } | |
4203 | |
7 | 4204 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4205 gui_update_scrollbars( |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4206 int force) // Force all scrollbars to get updated |
7 | 4207 { |
4208 win_T *wp; | |
4209 scrollbar_T *sb; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4210 long val, size, max; // need 32 bits here |
7 | 4211 int which_sb; |
4212 int h, y; | |
4213 static win_T *prev_curwin = NULL; | |
4214 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4215 // Update the horizontal scrollbar |
7 | 4216 gui_update_horiz_scrollbar(force); |
4217 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
4218 #ifndef MSWIN |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4219 // 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
|
4220 // On MS-Windows this is required anyway for scrollwheel messages. |
7 | 4221 if (!gui.which_scrollbars[SBAR_LEFT] && !gui.which_scrollbars[SBAR_RIGHT]) |
4222 return; | |
4223 #endif | |
4224 | |
4225 /* | |
4226 * Don't want to update a scrollbar while we're dragging it. But if we | |
4227 * have both a left and right scrollbar, and we drag one of them, we still | |
4228 * need to update the other one. | |
4229 */ | |
674 | 4230 if (!force && (gui.dragged_sb == SBAR_LEFT || gui.dragged_sb == SBAR_RIGHT) |
4231 && gui.which_scrollbars[SBAR_LEFT] | |
4232 && gui.which_scrollbars[SBAR_RIGHT]) | |
7 | 4233 { |
4234 /* | |
4235 * If we have two scrollbars and one of them is being dragged, just | |
4236 * copy the scrollbar position from the dragged one to the other one. | |
4237 */ | |
4238 which_sb = SBAR_LEFT + SBAR_RIGHT - gui.dragged_sb; | |
4239 if (gui.dragged_wp != NULL) | |
4240 gui_mch_set_scrollbar_thumb( | |
4241 &gui.dragged_wp->w_scrollbars[which_sb], | |
4242 gui.dragged_wp->w_scrollbars[0].value, | |
4243 gui.dragged_wp->w_scrollbars[0].size, | |
4244 gui.dragged_wp->w_scrollbars[0].max); | |
4245 } | |
4246 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4247 // avoid that moving components around generates events |
7 | 4248 ++hold_gui_events; |
4249 | |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19824
diff
changeset
|
4250 FOR_ALL_WINDOWS(wp) |
7 | 4251 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4252 if (wp->w_buffer == NULL) // just in case |
7 | 4253 continue; |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4254 // Skip a scrollbar that is being dragged. |
674 | 4255 if (!force && (gui.dragged_sb == SBAR_LEFT |
4256 || gui.dragged_sb == SBAR_RIGHT) | |
4257 && gui.dragged_wp == wp) | |
4258 continue; | |
4259 | |
7 | 4260 #ifdef SCROLL_PAST_END |
4261 max = wp->w_buffer->b_ml.ml_line_count - 1; | |
4262 #else | |
4263 max = wp->w_buffer->b_ml.ml_line_count + wp->w_height - 2; | |
4264 #endif | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4265 if (max < 0) // empty buffer |
7 | 4266 max = 0; |
4267 val = wp->w_topline - 1; | |
4268 size = wp->w_height; | |
4269 #ifdef SCROLL_PAST_END | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4270 if (val > max) // just in case |
7 | 4271 val = max; |
4272 #else | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4273 if (size > max + 1) // just in case |
7 | 4274 size = max + 1; |
4275 if (val > max - size + 1) | |
4276 val = max - size + 1; | |
4277 #endif | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4278 if (val < 0) // minimal value is 0 |
7 | 4279 val = 0; |
4280 | |
4281 /* | |
4282 * Scrollbar at index 0 (the left one) contains all the information. | |
4283 * It would be the same info for left and right so we just store it for | |
4284 * one of them. | |
4285 */ | |
4286 sb = &wp->w_scrollbars[0]; | |
4287 | |
4288 /* | |
4289 * Note: no check for valid w_botline. If it's not valid the | |
4290 * scrollbars will be updated later anyway. | |
4291 */ | |
4292 if (size < 1 || wp->w_botline - 2 > max) | |
4293 { | |
4294 /* | |
4295 * This can happen during changing files. Just don't update the | |
4296 * scrollbar for now. | |
4297 */ | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4298 sb->height = 0; // Force update next time |
7 | 4299 if (gui.which_scrollbars[SBAR_LEFT]) |
4300 gui_do_scrollbar(wp, SBAR_LEFT, FALSE); | |
4301 if (gui.which_scrollbars[SBAR_RIGHT]) | |
4302 gui_do_scrollbar(wp, SBAR_RIGHT, FALSE); | |
4303 continue; | |
4304 } | |
4305 if (force || sb->height != wp->w_height | |
4306 || sb->top != wp->w_winrow | |
4307 || sb->status_height != wp->w_status_height | |
4308 || 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
|
4309 || prev_curwin != curwin) |
7 | 4310 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4311 // 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
|
4312 // vertical split: curwin changed. |
7 | 4313 sb->height = wp->w_height; |
4314 sb->top = wp->w_winrow; | |
4315 sb->status_height = wp->w_status_height; | |
4316 sb->width = wp->w_width; | |
4317 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4318 // Calculate height and position in pixels |
7 | 4319 h = (sb->height + sb->status_height) * gui.char_height; |
4320 y = sb->top * gui.char_height + gui.border_offset; | |
4321 #if defined(FEAT_MENU) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) && !defined(FEAT_GUI_PHOTON) | |
4322 if (gui.menu_is_active) | |
4323 y += gui.menu_height; | |
4324 #endif | |
4325 | |
19526
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
4326 #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
|
4327 || defined(FEAT_GUI_HAIKU)) |
7 | 4328 if (vim_strchr(p_go, GO_TOOLBAR) != NULL) |
4329 y += gui.toolbar_height; | |
4330 #endif | |
4331 | |
19526
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
4332 #if defined(FEAT_GUI_TABLINE) && defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU) |
810 | 4333 if (gui_has_tabline()) |
843 | 4334 y += gui.tabline_height; |
810 | 4335 #endif |
4336 | |
7 | 4337 if (wp->w_winrow == 0) |
4338 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4339 // Height of top scrollbar includes width of top border |
7 | 4340 h += gui.border_offset; |
4341 y -= gui.border_offset; | |
4342 } | |
4343 if (gui.which_scrollbars[SBAR_LEFT]) | |
4344 { | |
4345 gui_mch_set_scrollbar_pos(&wp->w_scrollbars[SBAR_LEFT], | |
4346 gui.left_sbar_x, y, | |
4347 gui.scrollbar_width, h); | |
4348 gui_do_scrollbar(wp, SBAR_LEFT, TRUE); | |
4349 } | |
4350 if (gui.which_scrollbars[SBAR_RIGHT]) | |
4351 { | |
4352 gui_mch_set_scrollbar_pos(&wp->w_scrollbars[SBAR_RIGHT], | |
4353 gui.right_sbar_x, y, | |
4354 gui.scrollbar_width, h); | |
4355 gui_do_scrollbar(wp, SBAR_RIGHT, TRUE); | |
4356 } | |
4357 } | |
4358 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4359 // 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
|
4360 // 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
|
4361 // 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
|
4362 // arrows work. |
7 | 4363 #ifdef FEAT_GUI_ATHENA |
4364 if (max == 0) | |
4365 y = 0; | |
4366 else | |
4367 y = (val * (sb->height + 2) * gui.char_height + max / 2) / max; | |
4368 if (force || sb->pixval != y || sb->size != size || sb->max != max) | |
4369 #else | |
4370 if (force || sb->value != val || sb->size != size || sb->max != max) | |
4371 #endif | |
4372 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4373 // Thumb of scrollbar has moved |
7 | 4374 sb->value = val; |
4375 #ifdef FEAT_GUI_ATHENA | |
4376 sb->pixval = y; | |
4377 #endif | |
4378 sb->size = size; | |
4379 sb->max = max; | |
674 | 4380 if (gui.which_scrollbars[SBAR_LEFT] |
4381 && (gui.dragged_sb != SBAR_LEFT || gui.dragged_wp != wp)) | |
7 | 4382 gui_mch_set_scrollbar_thumb(&wp->w_scrollbars[SBAR_LEFT], |
4383 val, size, max); | |
4384 if (gui.which_scrollbars[SBAR_RIGHT] | |
674 | 4385 && (gui.dragged_sb != SBAR_RIGHT || gui.dragged_wp != wp)) |
7 | 4386 gui_mch_set_scrollbar_thumb(&wp->w_scrollbars[SBAR_RIGHT], |
4387 val, size, max); | |
4388 } | |
4389 } | |
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
|
4390 |
39f841f187d5
patch 8.2.3688: the window title is not updated when dragging the scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
26234
diff
changeset
|
4391 // 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
|
4392 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
|
4393 |
7 | 4394 prev_curwin = curwin; |
4395 --hold_gui_events; | |
4396 } | |
4397 | |
4398 /* | |
4399 * Enable or disable a scrollbar. | |
4400 * Check for scrollbars for vertically split windows which are not enabled | |
4401 * sometimes. | |
4402 */ | |
4403 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4404 gui_do_scrollbar( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4405 win_T *wp, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4406 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
|
4407 int enable) // TRUE to enable scrollbar |
7 | 4408 { |
4409 int midcol = curwin->w_wincol + curwin->w_width / 2; | |
4410 int has_midcol = (wp->w_wincol <= midcol | |
4411 && wp->w_wincol + wp->w_width >= midcol); | |
4412 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4413 // 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
|
4414 // window. |
7 | 4415 if (gui.which_scrollbars[SBAR_RIGHT] != gui.which_scrollbars[SBAR_LEFT]) |
4416 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4417 // 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
|
4418 // contain the middle column of the current window. |
7 | 4419 if (!has_midcol) |
4420 enable = FALSE; | |
4421 } | |
4422 else | |
4423 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4424 // 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
|
4425 // 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
|
4426 // side. |
7 | 4427 if (midcol > Columns / 2) |
4428 { | |
4429 if (which == SBAR_LEFT ? wp->w_wincol != 0 : !has_midcol) | |
4430 enable = FALSE; | |
4431 } | |
4432 else | |
4433 { | |
4434 if (which == SBAR_RIGHT ? wp->w_wincol + wp->w_width != Columns | |
4435 : !has_midcol) | |
4436 enable = FALSE; | |
4437 } | |
4438 } | |
4439 gui_mch_enable_scrollbar(&wp->w_scrollbars[which], enable); | |
4440 } | |
4441 | |
4442 /* | |
4443 * Scroll a window according to the values set in the globals current_scrollbar | |
4444 * and scrollbar_value. Return TRUE if the cursor in the current window moved | |
4445 * or FALSE otherwise. | |
4446 */ | |
4447 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4448 gui_do_scroll(void) |
7 | 4449 { |
4450 win_T *wp, *save_wp; | |
4451 int i; | |
4452 long nlines; | |
4453 pos_T old_cursor; | |
4454 linenr_T old_topline; | |
4455 #ifdef FEAT_DIFF | |
4456 int old_topfill; | |
4457 #endif | |
4458 | |
4459 for (wp = firstwin, i = 0; i < current_scrollbar; wp = W_NEXT(wp), i++) | |
4460 if (wp == NULL) | |
4461 break; | |
4462 if (wp == NULL) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4463 // Couldn't find window |
7 | 4464 return FALSE; |
4465 | |
4466 /* | |
4467 * Compute number of lines to scroll. If zero, nothing to do. | |
4468 */ | |
4469 nlines = (long)scrollbar_value + 1 - (long)wp->w_topline; | |
4470 if (nlines == 0) | |
4471 return FALSE; | |
4472 | |
4473 save_wp = curwin; | |
4474 old_topline = wp->w_topline; | |
4475 #ifdef FEAT_DIFF | |
4476 old_topfill = wp->w_topfill; | |
4477 #endif | |
4478 old_cursor = wp->w_cursor; | |
4479 curwin = wp; | |
4480 curbuf = wp->w_buffer; | |
4481 if (nlines < 0) | |
4482 scrolldown(-nlines, gui.dragged_wp == NULL); | |
4483 else | |
4484 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
|
4485 // 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
|
4486 // 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
|
4487 // dragging. But not the next click in an arrow. |
7 | 4488 if (gui.dragged_sb == SBAR_NONE) |
4489 gui.dragged_wp = NULL; | |
4490 | |
4491 if (old_topline != wp->w_topline | |
4492 #ifdef FEAT_DIFF | |
4493 || old_topfill != wp->w_topfill | |
4494 #endif | |
4495 ) | |
4496 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15653
diff
changeset
|
4497 if (get_scrolloff_value() != 0) |
7 | 4498 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4499 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
|
4500 update_topline(); // avoid up/down jump |
7 | 4501 } |
4502 if (old_cursor.lnum != wp->w_cursor.lnum) | |
4503 coladvance(wp->w_curswant); | |
4504 wp->w_scbind_pos = wp->w_topline; | |
4505 } | |
4506 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4507 // Make sure wp->w_leftcol and wp->w_skipcol are correct. |
519 | 4508 validate_cursor(); |
4509 | |
7 | 4510 curwin = save_wp; |
4511 curbuf = save_wp->w_buffer; | |
4512 | |
4513 /* | |
4514 * Don't call updateWindow() when nothing has changed (it will overwrite | |
4515 * the status line!). | |
4516 */ | |
4517 if (old_topline != wp->w_topline | |
519 | 4518 || wp->w_redr_type != 0 |
7 | 4519 #ifdef FEAT_DIFF |
4520 || old_topfill != wp->w_topfill | |
4521 #endif | |
4522 ) | |
4523 { | |
1434 | 4524 int type = VALID; |
4525 | |
4526 if (pum_visible()) | |
4527 { | |
4528 type = NOT_VALID; | |
4529 wp->w_lines_valid = 0; | |
4530 } | |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
4531 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4532 // 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
|
4533 // disappear when losing focus after a scrollbar drag. |
1434 | 4534 if (wp->w_redr_type < type) |
4535 wp->w_redr_type = type; | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
4536 mch_disable_flush(); |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4537 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
|
4538 mch_enable_flush(); |
7 | 4539 } |
4540 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4541 // May need to redraw the popup menu. |
973 | 4542 if (pum_visible()) |
4543 pum_redraw(); | |
4544 | |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10819
diff
changeset
|
4545 return (wp == curwin && !EQUAL_POS(curwin->w_cursor, old_cursor)); |
7 | 4546 } |
4547 | |
4548 | |
4549 /* | |
4550 * Horizontal scrollbar stuff: | |
4551 */ | |
4552 | |
4553 /* | |
4554 * Return length of line "lnum" for horizontal scrolling. | |
4555 */ | |
4556 static colnr_T | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4557 scroll_line_len(linenr_T lnum) |
7 | 4558 { |
4559 char_u *p; | |
4560 colnr_T col; | |
4561 int w; | |
4562 | |
4563 p = ml_get(lnum); | |
4564 col = 0; | |
4565 if (*p != NUL) | |
4566 for (;;) | |
4567 { | |
4568 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
|
4569 MB_PTR_ADV(p); |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4570 if (*p == NUL) // don't count the last character |
7 | 4571 break; |
4572 col += w; | |
4573 } | |
4574 return col; | |
4575 } | |
4576 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4577 // 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
|
4578 // search for it when scrolling horizontally. |
7 | 4579 static linenr_T longest_lnum = 0; |
4580 | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4581 /* |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4582 * 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
|
4583 * 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
|
4584 */ |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4585 static linenr_T |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4586 gui_find_longest_lnum(void) |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4587 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4588 linenr_T ret = 0; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4589 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4590 // 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
|
4591 // 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
|
4592 // postponed. |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4593 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
|
4594 && 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
|
4595 && 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
|
4596 && 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
|
4597 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4598 linenr_T lnum; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4599 colnr_T n; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4600 long max = 0; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4601 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4602 // 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
|
4603 // 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
|
4604 // below. |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4605 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
|
4606 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4607 n = scroll_line_len(lnum); |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4608 if (n > (colnr_T)max) |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4609 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4610 max = n; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4611 ret = lnum; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4612 } |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4613 else if (n == (colnr_T)max |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4614 && 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
|
4615 < 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
|
4616 ret = lnum; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4617 } |
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 else |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4620 // Use cursor line only. |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4621 ret = curwin->w_cursor.lnum; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4622 |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4623 return ret; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4624 } |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4625 |
7 | 4626 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4627 gui_update_horiz_scrollbar(int force) |
7 | 4628 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4629 long value, size, max; // need 32 bit ints here |
7 | 4630 |
4631 if (!gui.which_scrollbars[SBAR_BOTTOM]) | |
4632 return; | |
4633 | |
4634 if (!force && gui.dragged_sb == SBAR_BOTTOM) | |
4635 return; | |
4636 | |
4637 if (!force && curwin->w_p_wrap && gui.prev_wrap) | |
4638 return; | |
4639 | |
4640 /* | |
4641 * It is possible for the cursor to be invalid if we're in the middle of | |
4642 * something (like changing files). If so, don't do anything for now. | |
4643 */ | |
4644 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
4645 { | |
4646 gui.bottom_sbar.value = -1; | |
4647 return; | |
4648 } | |
4649 | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4650 size = curwin->w_width; |
7 | 4651 if (curwin->w_p_wrap) |
4652 { | |
4653 value = 0; | |
4654 #ifdef SCROLL_PAST_END | |
4655 max = 0; | |
4656 #else | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4657 max = curwin->w_width - 1; |
7 | 4658 #endif |
4659 } | |
4660 else | |
4661 { | |
4662 value = curwin->w_leftcol; | |
4663 | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4664 longest_lnum = gui_find_longest_lnum(); |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4665 max = scroll_line_len(longest_lnum); |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4666 |
7 | 4667 if (virtual_active()) |
4668 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4669 // May move the cursor even further to the right. |
7 | 4670 if (curwin->w_virtcol >= (colnr_T)max) |
4671 max = curwin->w_virtcol; | |
4672 } | |
4673 | |
4674 #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
|
4675 max += curwin->w_width - 1; |
7 | 4676 #endif |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4677 // 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
|
4678 // 'number' or 'relativenumber' is set (also for 'foldcolumn'). |
7 | 4679 size -= curwin_col_off(); |
4680 #ifndef SCROLL_PAST_END | |
4681 max -= curwin_col_off(); | |
4682 #endif | |
4683 } | |
4684 | |
4685 #ifndef SCROLL_PAST_END | |
4686 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
|
4687 value = max - size + 1; // limit the value to allowable range |
7 | 4688 #endif |
4689 | |
4690 #ifdef FEAT_RIGHTLEFT | |
4691 if (curwin->w_p_rl) | |
4692 { | |
4693 value = max + 1 - size - value; | |
4694 if (value < 0) | |
4695 { | |
4696 size += value; | |
4697 value = 0; | |
4698 } | |
4699 } | |
4700 #endif | |
4701 if (!force && value == gui.bottom_sbar.value && size == gui.bottom_sbar.size | |
4702 && max == gui.bottom_sbar.max) | |
4703 return; | |
4704 | |
4705 gui.bottom_sbar.value = value; | |
4706 gui.bottom_sbar.size = size; | |
4707 gui.bottom_sbar.max = max; | |
4708 gui.prev_wrap = curwin->w_p_wrap; | |
4709 | |
4710 gui_mch_set_scrollbar_thumb(&gui.bottom_sbar, value, size, max); | |
4711 } | |
4712 | |
4713 /* | |
4714 * Do a horizontal scroll. Return TRUE if the cursor moved, FALSE otherwise. | |
4715 */ | |
4716 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4717 gui_do_horiz_scroll(long_u leftcol, int compute_longest_lnum) |
7 | 4718 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4719 // no wrapping, no scrolling |
7 | 4720 if (curwin->w_p_wrap) |
4721 return FALSE; | |
4722 | |
2416
1a9c16dd76d4
Fix compiler warnings on 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents:
2409
diff
changeset
|
4723 if (curwin->w_leftcol == (colnr_T)leftcol) |
7 | 4724 return FALSE; |
4725 | |
2416
1a9c16dd76d4
Fix compiler warnings on 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents:
2409
diff
changeset
|
4726 curwin->w_leftcol = (colnr_T)leftcol; |
7 | 4727 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4728 // 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
|
4729 // longest visible line. |
7 | 4730 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
|
4731 && !virtual_active() |
2416
1a9c16dd76d4
Fix compiler warnings on 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents:
2409
diff
changeset
|
4732 && (colnr_T)leftcol > scroll_line_len(curwin->w_cursor.lnum)) |
7 | 4733 { |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4734 if (compute_longest_lnum) |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4735 { |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4736 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
|
4737 curwin->w_cursor.col = 0; |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2378
diff
changeset
|
4738 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4739 // 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
|
4740 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
|
4741 && longest_lnum < curwin->w_botline) |
7 | 4742 { |
4743 curwin->w_cursor.lnum = longest_lnum; | |
4744 curwin->w_cursor.col = 0; | |
4745 } | |
4746 } | |
4747 | |
4748 return leftcol_changed(); | |
4749 } | |
4750 | |
4751 /* | |
4752 * Check that none of the colors are the same as the background color | |
4753 */ | |
4754 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4755 gui_check_colors(void) |
7 | 4756 { |
4757 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) | |
4758 { | |
4759 gui_set_bg_color((char_u *)"White"); | |
4760 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) | |
4761 gui_set_fg_color((char_u *)"Black"); | |
4762 } | |
4763 } | |
4764 | |
203 | 4765 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4766 gui_set_fg_color(char_u *name) |
7 | 4767 { |
4768 gui.norm_pixel = gui_get_color(name); | |
4769 hl_set_fg_color_name(vim_strsave(name)); | |
4770 } | |
4771 | |
203 | 4772 static void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4773 gui_set_bg_color(char_u *name) |
7 | 4774 { |
4775 gui.back_pixel = gui_get_color(name); | |
4776 hl_set_bg_color_name(vim_strsave(name)); | |
4777 } | |
4778 | |
4779 /* | |
4780 * Allocate a color by name. | |
4781 * Returns INVALCOLOR and gives an error message when failed. | |
4782 */ | |
4783 guicolor_T | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4784 gui_get_color(char_u *name) |
7 | 4785 { |
4786 guicolor_T t; | |
4787 | |
4788 if (*name == NUL) | |
4789 return INVALCOLOR; | |
4790 t = gui_mch_get_color(name); | |
11 | 4791 |
7 | 4792 if (t == INVALCOLOR |
574 | 4793 #if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) |
7 | 4794 && gui.in_use |
4795 #endif | |
4796 ) | |
26057
92c424550367
patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents:
25982
diff
changeset
|
4797 semsg(_(e_cannot_allocate_color_str), name); |
7 | 4798 return t; |
4799 } | |
4800 | |
4801 /* | |
4802 * Return the grey value of a color (range 0-255). | |
4803 */ | |
4804 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4805 gui_get_lightness(guicolor_T pixel) |
7 | 4806 { |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9848
diff
changeset
|
4807 long_u rgb = (long_u)gui_mch_get_rgb(pixel); |
7 | 4808 |
835 | 4809 return (int)( (((rgb >> 16) & 0xff) * 299) |
856 | 4810 + (((rgb >> 8) & 0xff) * 587) |
4811 + ((rgb & 0xff) * 114)) / 1000; | |
7 | 4812 } |
4813 | |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4814 char_u * |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4815 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
|
4816 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4817 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
|
4818 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
|
4819 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
|
4820 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4821 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4822 /* |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4823 * 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
|
4824 */ |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4825 void |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4826 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
|
4827 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4828 // 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
|
4829 // 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
|
4830 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
|
4831 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4832 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
|
4833 highlight_changed(); |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4834 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4835 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18671
diff
changeset
|
4836 |
7 | 4837 #if defined(FEAT_GUI_X11) || defined(PROTO) |
4838 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4839 gui_new_scrollbar_colors(void) |
7 | 4840 { |
4841 win_T *wp; | |
4842 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4843 // Nothing to do if GUI hasn't started yet. |
7 | 4844 if (!gui.in_use) |
4845 return; | |
4846 | |
4847 FOR_ALL_WINDOWS(wp) | |
4848 { | |
4849 gui_mch_set_scrollbar_colors(&(wp->w_scrollbars[SBAR_LEFT])); | |
4850 gui_mch_set_scrollbar_colors(&(wp->w_scrollbars[SBAR_RIGHT])); | |
4851 } | |
4852 gui_mch_set_scrollbar_colors(&gui.bottom_sbar); | |
4853 } | |
4854 #endif | |
4855 | |
4856 /* | |
4857 * Call this when focus has changed. | |
4858 */ | |
4859 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
4860 gui_focus_change(int in_focus) |
7 | 4861 { |
4862 /* | |
4863 * Skip this code to avoid drawing the cursor when debugging and switching | |
4864 * between the debugger window and gvim. | |
4865 */ | |
4866 #if 1 | |
4867 gui.in_focus = in_focus; | |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
4868 out_flush_cursor(TRUE, FALSE); |
7 | 4869 |
4870 # ifdef FEAT_XIM | |
4871 xim_set_focus(in_focus); | |
4872 # endif | |
4873 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4874 // 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
|
4875 // 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
|
4876 // autocommands and that must not happen asynchronously. |
1380 | 4877 if (!hold_gui_events) |
4878 { | |
4879 char_u bytes[3]; | |
4880 | |
4881 bytes[0] = CSI; | |
4882 bytes[1] = KS_EXTRA; | |
4883 bytes[2] = in_focus ? (int)KE_FOCUSGAINED : (int)KE_FOCUSLOST; | |
4884 add_to_input_buf(bytes, 3); | |
4885 } | |
7 | 4886 #endif |
4887 } | |
4888 | |
4889 /* | |
17306
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4890 * 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
|
4891 * Also updates the mouse pointer shape. |
7 | 4892 */ |
17306
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4893 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
|
4894 gui_mouse_focus(int x, int y) |
7 | 4895 { |
4896 win_T *wp; | |
894 | 4897 char_u st[8]; |
7 | 4898 |
4899 #ifdef FEAT_MOUSESHAPE | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4900 // 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
|
4901 wp = xy2win(x, y, IGNORE_POPUP); |
7 | 4902 #endif |
4903 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4904 // Only handle this when 'mousefocus' set and ... |
7 | 4905 if (p_mousef |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4906 && !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
|
4907 && (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
|
4908 && 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
|
4909 && 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
|
4910 && !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
|
4911 && gui.in_focus) // gvim in focus |
7 | 4912 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4913 // Don't move the mouse when it's left or right of the Vim window |
7 | 4914 if (x < 0 || x > Columns * gui.char_width) |
4915 return; | |
4916 #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
|
4917 wp = xy2win(x, y, IGNORE_POPUP); |
7 | 4918 #endif |
4919 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
|
4920 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
|
4921 |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4922 // Ignore position in the tab pages line. |
859 | 4923 if (Y_2_ROW(y) < tabline_height()) |
4924 return; | |
4925 | |
7 | 4926 /* |
4927 * format a mouse click on status line input | |
4928 * ala gui_send_mouse_event(0, x, y, 0, 0); | |
261 | 4929 * Trick: Use a column number -1, so that get_pseudo_mouse_code() will |
4930 * generate a K_LEFTMOUSE_NM key code. | |
7 | 4931 */ |
4932 if (finish_op) | |
4933 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4934 // abort the current operator first |
7 | 4935 st[0] = ESC; |
4936 add_to_input_buf(st, 1); | |
4937 } | |
4938 st[0] = CSI; | |
4939 st[1] = KS_MOUSE; | |
4940 st[2] = KE_FILLER; | |
4941 st[3] = (char_u)MOUSE_LEFT; | |
4942 fill_mouse_coord(st + 4, | |
261 | 4943 wp->w_wincol == 0 ? -1 : wp->w_wincol + MOUSE_COLOFF, |
7 | 4944 wp->w_height + W_WINROW(wp)); |
4945 | |
4946 add_to_input_buf(st, 8); | |
4947 st[3] = (char_u)MOUSE_RELEASE; | |
4948 add_to_input_buf(st, 8); | |
4949 #ifdef FEAT_GUI_GTK | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4950 // Need to wake up the main loop |
7 | 4951 if (gtk_main_level() > 0) |
4952 gtk_main_quit(); | |
4953 #endif | |
4954 } | |
4955 } | |
4956 | |
4957 /* | |
17306
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4958 * 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
|
4959 */ |
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4960 void |
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4961 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
|
4962 { |
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4963 // 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
|
4964 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
|
4965 return; |
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4966 |
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4967 // 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
|
4968 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
|
4969 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
4970 #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
|
4971 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
|
4972 // 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
|
4973 // 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
|
4974 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
|
4975 #endif |
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4976 } |
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4977 |
16d5e91c5e5b
patch 8.1.1652: GUI: popup window doesn't close on mouse movement
Bram Moolenaar <Bram@vim.org>
parents:
17288
diff
changeset
|
4978 /* |
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
|
4979 * 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
|
4980 * 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
|
4981 */ |
6067fbb46625
patch 8.1.2254: MS-Windows: mouse scroll wheel doesn't work in popup
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
4982 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
|
4983 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
|
4984 { |
6067fbb46625
patch 8.1.2254: MS-Windows: mouse scroll wheel doesn't work in popup
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
4985 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
|
4986 |
6067fbb46625
patch 8.1.2254: MS-Windows: mouse scroll wheel doesn't work in popup
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
4987 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
|
4988 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
|
4989 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
|
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 // 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
|
4992 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
|
4993 && 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
|
4994 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
|
4995 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
|
4996 } |
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 |
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 /* |
7 | 4999 * Called when mouse should be moved to window with focus. |
5000 */ | |
5001 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5002 gui_mouse_correct(void) |
7 | 5003 { |
5004 win_T *wp = NULL; | |
5005 | |
5006 need_mouse_correct = FALSE; | |
87 | 5007 |
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
|
5008 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
|
5009 if (wp != curwin && wp != NULL) // If in other than current window |
7 | 5010 { |
87 | 5011 validate_cline_row(); |
5012 gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3, | |
5013 (W_WINROW(curwin) + curwin->w_wrow) * gui.char_height | |
7 | 5014 + (gui.char_height) / 2); |
5015 } | |
5016 } | |
5017 | |
5018 /* | |
12136
60cf03e59402
patch 8.0.0948: crash if timer closes window while dragging status line
Christian Brabandt <cb@256bit.org>
parents:
12082
diff
changeset
|
5019 * 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
|
5020 * As a side effect update the shape of the mouse pointer. |
7 | 5021 */ |
5022 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
|
5023 xy2win(int x, int y, mouse_find_T popup) |
7 | 5024 { |
5025 int row; | |
5026 int col; | |
5027 win_T *wp; | |
5028 | |
5029 row = Y_2_ROW(y); | |
5030 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
|
5031 if (row < 0 || col < 0) // before first window |
7 | 5032 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
|
5033 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
|
5034 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
|
5035 return NULL; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
5036 #ifdef FEAT_MOUSESHAPE |
7 | 5037 if (State == HITRETURN || State == ASKMORE) |
5038 { | |
5039 if (Y_2_ROW(y) >= msg_row) | |
5040 update_mouseshape(SHAPE_IDX_MOREL); | |
5041 else | |
5042 update_mouseshape(SHAPE_IDX_MORE); | |
5043 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5044 else if (row > wp->w_height) // below status line |
7 | 5045 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
|
5046 else if (!(State & CMDLINE) && wp->w_vsep_width > 0 && col == wp->w_width |
819 | 5047 && (row != wp->w_height || !stl_connected(wp)) && msg_scrolled == 0) |
7 | 5048 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
|
5049 else if (!(State & CMDLINE) && wp->w_status_height > 0 |
819 | 5050 && row == wp->w_height && msg_scrolled == 0) |
7 | 5051 update_mouseshape(SHAPE_IDX_STATUS); |
5052 else | |
5053 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
|
5054 #endif |
7 | 5055 return wp; |
5056 } | |
5057 | |
5058 /* | |
5059 * ":gui" and ":gvim": Change from the terminal version to the GUI version. | |
5060 * File names may be given to redefine the args list. | |
5061 */ | |
5062 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5063 ex_gui(exarg_T *eap) |
7 | 5064 { |
5065 char_u *arg = eap->arg; | |
5066 | |
5067 /* | |
5068 * Check for "-f" argument: foreground, don't fork. | |
5069 * Also don't fork when started with "gvim -f". | |
5070 * Do fork when using "gui -b". | |
5071 */ | |
5072 if (arg[0] == '-' | |
5073 && (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
|
5074 && (arg[2] == NUL || VIM_ISWHITE(arg[2]))) |
7 | 5075 { |
5076 gui.dofork = (arg[1] == 'b'); | |
5077 eap->arg = skipwhite(eap->arg + 2); | |
5078 } | |
5079 if (!gui.in_use) | |
5080 { | |
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
|
5081 #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
|
5082 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
|
5083 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25006
diff
changeset
|
5084 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
|
5085 return; |
7abe2444d1e1
patch 8.2.0055: cannot use ":gui" in vimrc with VIMDLL enabled
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
5086 } |
7abe2444d1e1
patch 8.2.0055: cannot use ":gui" in vimrc with VIMDLL enabled
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
5087 #endif |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5088 // 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
|
5089 // of the argument ending up after the shell prompt. |
7 | 5090 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
|
5091 #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
|
5092 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
|
5093 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
|
5094 else |
18989
7abe2444d1e1
patch 8.2.0055: cannot use ":gui" in vimrc with VIMDLL enabled
Bram Moolenaar <Bram@vim.org>
parents:
18949
diff
changeset
|
5095 #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
|
5096 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
|
5097 #ifdef FEAT_JOB_CHANNEL |
7770
42c1a4e63d12
commit https://github.com/vim/vim/commit/d04a020a8a8d7a438b091d49218c438880beb50c
Christian Brabandt <cb@256bit.org>
parents:
7469
diff
changeset
|
5098 channel_gui_register_all(); |
2209
d0ddf7ba1630
Included the patch to support netbeans in a terminal.
Bram Moolenaar <bram@vim.org>
parents:
2208
diff
changeset
|
5099 #endif |
7 | 5100 } |
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)) |
7 | 5102 ex_next(eap); |
5103 } | |
5104 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
5105 #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
|
5106 || 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
|
5107 || 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
|
5108 && defined(FEAT_TOOLBAR)) || defined(PROTO) |
7 | 5109 /* |
19526
22f0dda71638
patch 8.2.0320: no Haiku support
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
5110 * This is shared between Athena, Haiku, Motif, and GTK. |
7 | 5111 */ |
5112 | |
5113 /* | |
5114 * Callback function for do_in_runtimepath(). | |
5115 */ | |
5116 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5117 gfp_setname(char_u *fname, void *cookie) |
7 | 5118 { |
236 | 5119 char_u *gfp_buffer = cookie; |
5120 | |
7 | 5121 if (STRLEN(fname) >= MAXPATHL) |
5122 *gfp_buffer = NUL; | |
5123 else | |
5124 STRCPY(gfp_buffer, fname); | |
5125 } | |
5126 | |
5127 /* | |
5128 * Find the path of bitmap "name" with extension "ext" in 'runtimepath'. | |
5129 * Return FAIL for failure and OK if buffer[MAXPATHL] contains the result. | |
5130 */ | |
5131 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5132 gui_find_bitmap(char_u *name, char_u *buffer, char *ext) |
7 | 5133 { |
5134 if (STRLEN(name) > MAXPATHL - 14) | |
5135 return FAIL; | |
273 | 5136 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
|
5137 if (do_in_runtimepath(buffer, 0, gfp_setname, buffer) == FAIL |
236 | 5138 || *buffer == NUL) |
7 | 5139 return FAIL; |
5140 return OK; | |
5141 } | |
5142 | |
2277
f42e0b5ff9e9
Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
Bram Moolenaar <bram@vim.org>
parents:
2275
diff
changeset
|
5143 # if !defined(FEAT_GUI_GTK) || defined(PROTO) |
7 | 5144 /* |
5145 * Given the name of the "icon=" argument, try finding the bitmap file for the | |
5146 * icon. If it is an absolute path name, use it as it is. Otherwise append | |
5147 * "ext" and search for it in 'runtimepath'. | |
5148 * The result is put in "buffer[MAXPATHL]". If something fails "buffer" | |
5149 * contains "name". | |
5150 */ | |
5151 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5152 gui_find_iconfile(char_u *name, char_u *buffer, char *ext) |
7 | 5153 { |
5154 char_u buf[MAXPATHL + 1]; | |
5155 | |
5156 expand_env(name, buffer, MAXPATHL); | |
5157 if (!mch_isFullName(buffer) && gui_find_bitmap(buffer, buf, ext) == OK) | |
5158 STRCPY(buffer, buf); | |
5159 } | |
5160 # endif | |
5161 #endif | |
5162 | |
20231
993d820196b9
patch 8.2.0671: Haiku: compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
5163 #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
|
5164 || defined(PROTO) |
7 | 5165 void |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5166 display_errors(void) |
7 | 5167 { |
5168 char_u *p; | |
5169 | |
5170 if (isatty(2)) | |
5171 fflush(stderr); | |
5172 else if (error_ga.ga_data != NULL) | |
5173 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5174 // avoid putting up a message box with blanks only |
7 | 5175 for (p = (char_u *)error_ga.ga_data; *p != NUL; ++p) |
5176 if (!isspace(*p)) | |
5177 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5178 // Truncate a very long message, it will go off-screen. |
7 | 5179 if (STRLEN(p) > 2000) |
5180 STRCPY(p + 2000 - 14, "...(truncated)"); | |
5181 (void)do_dialog(VIM_ERROR, (char_u *)_("Error"), | |
2684 | 5182 p, (char_u *)_("&Ok"), 1, NULL, FALSE); |
7 | 5183 break; |
5184 } | |
5185 ga_clear(&error_ga); | |
5186 } | |
5187 } | |
5188 #endif | |
5189 | |
5190 #if defined(NO_CONSOLE_INPUT) || defined(PROTO) | |
5191 /* | |
5192 * Return TRUE if still starting up and there is no place to enter text. | |
5193 * For GTK and X11 we check if stderr is not a tty, which means we were | |
5194 * (probably) started from the desktop. Also check stdin, "vim >& file" does | |
5195 * allow typing on stdin. | |
5196 */ | |
5197 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5198 no_console_input(void) |
7 | 5199 { |
5200 return ((!gui.in_use || gui.starting) | |
5201 # ifndef NO_CONSOLE | |
5202 && !isatty(0) && !isatty(2) | |
5203 # endif | |
5204 ); | |
5205 } | |
5206 #endif | |
5207 | |
15510
41fbbcea0f1b
patch 8.1.0763: nobody is using the Sun Workshop support
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
5208 #if defined(FIND_REPLACE_DIALOG) \ |
1002 | 5209 || defined(NEED_GUI_UPDATE_SCREEN) \ |
28 | 5210 || defined(PROTO) |
7 | 5211 /* |
5212 * Update the current window and the screen. | |
5213 */ | |
5214 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5215 gui_update_screen(void) |
7 | 5216 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5217 # 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
|
5218 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
|
5219 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
|
5220 int conceal_update_lines = FALSE; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5221 # endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5222 |
7 | 5223 update_topline(); |
5224 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
|
5225 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5226 // Trigger CursorMoved if the cursor moved. |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5227 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
|
5228 # 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
|
5229 || popup_visible |
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5230 # endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5231 # ifdef FEAT_CONCEAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5232 || 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
|
5233 # endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5234 ) && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) |
1584 | 5235 { |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5236 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
|
5237 apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf); |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
5238 # 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
|
5239 if (popup_visible) |
9138e2c60bf1
patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
5240 popup_check_cursor_pos(); |
27521
3ad379c0ab28
patch 8.2.4288: preprocessor indents are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27490
diff
changeset
|
5241 # endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5242 # 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
|
5243 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
|
5244 { |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5245 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
|
5246 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
|
5247 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
|
5248 } |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5249 # endif |
1584 | 5250 last_cursormoved = curwin->w_cursor; |
5251 } | |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5252 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13194
diff
changeset
|
5253 # 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
|
5254 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
|
5255 && (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
|
5256 || 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
|
5257 || 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
|
5258 { |
2378
85b7dc8da5eb
Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents:
2348
diff
changeset
|
5259 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
|
5260 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
|
5261 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
|
5262 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
|
5263 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
|
5264 } |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2277
diff
changeset
|
5265 # endif |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5266 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
|
5267 setcursor(); |
13150
808625d4b71b
patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents:
13080
diff
changeset
|
5268 out_flush_cursor(TRUE, FALSE); |
7 | 5269 } |
5270 #endif | |
5271 | |
28 | 5272 #if defined(FIND_REPLACE_DIALOG) || defined(PROTO) |
7 | 5273 /* |
5274 * Get the text to use in a find/replace dialog. Uses the last search pattern | |
5275 * if the argument is empty. | |
5276 * Returns an allocated string. | |
5277 */ | |
5278 char_u * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5279 get_find_dialog_text( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5280 char_u *arg, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5281 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
|
5282 int *mcasep) // return: TRUE if \C found |
7 | 5283 { |
5284 char_u *text; | |
5285 | |
5286 if (*arg == NUL) | |
5287 text = last_search_pat(); | |
5288 else | |
5289 text = arg; | |
5290 if (text != NULL) | |
5291 { | |
5292 text = vim_strsave(text); | |
5293 if (text != NULL) | |
5294 { | |
835 | 5295 int len = (int)STRLEN(text); |
7 | 5296 int i; |
5297 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5298 // Remove "\V" |
7 | 5299 if (len >= 2 && STRNCMP(text, "\\V", 2) == 0) |
5300 { | |
5301 mch_memmove(text, text + 2, (size_t)(len - 1)); | |
5302 len -= 2; | |
5303 } | |
5304 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5305 // Recognize "\c" and "\C" and remove. |
7 | 5306 if (len >= 2 && *text == '\\' && (text[1] == 'c' || text[1] == 'C')) |
5307 { | |
5308 *mcasep = (text[1] == 'C'); | |
5309 mch_memmove(text, text + 2, (size_t)(len - 1)); | |
5310 len -= 2; | |
5311 } | |
5312 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5313 // Recognize "\<text\>" and remove. |
7 | 5314 if (len >= 4 |
5315 && STRNCMP(text, "\\<", 2) == 0 | |
5316 && STRNCMP(text + len - 2, "\\>", 2) == 0) | |
5317 { | |
5318 *wwordp = TRUE; | |
5319 mch_memmove(text, text + 2, (size_t)(len - 4)); | |
5320 text[len - 4] = NUL; | |
5321 } | |
5322 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5323 // Recognize "\/" or "\?" and remove. |
7 | 5324 for (i = 0; i + 1 < len; ++i) |
5325 if (text[i] == '\\' && (text[i + 1] == '/' | |
5326 || text[i + 1] == '?')) | |
5327 { | |
5328 mch_memmove(text + i, text + i + 1, (size_t)(len - i)); | |
5329 --len; | |
5330 } | |
5331 } | |
5332 } | |
5333 return text; | |
5334 } | |
5335 | |
5336 /* | |
5337 * Handle the press of a button in the find-replace dialog. | |
5338 * Return TRUE when something was added to the input buffer. | |
5339 */ | |
5340 int | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5341 gui_do_findrepl( |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5342 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
|
5343 char_u *find_text, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5344 char_u *repl_text, |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5345 int down) // Search downwards. |
7 | 5346 { |
5347 garray_T ga; | |
5348 int i; | |
5349 int type = (flags & FRD_TYPE_MASK); | |
5350 char_u *p; | |
28 | 5351 regmatch_T regmatch; |
482 | 5352 int save_did_emsg = did_emsg; |
1943 | 5353 static int busy = FALSE; |
5354 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5355 // 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
|
5356 // 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
|
5357 // do this recursively (pressing "Find" quickly several times). |
1943 | 5358 if (updating_screen || busy) |
5359 return FALSE; | |
5360 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5361 // refuse replace when text cannot be changed |
1943 | 5362 if ((type == FRD_REPLACE || type == FRD_REPLACEALL) && text_locked()) |
5363 return FALSE; | |
5364 | |
5365 busy = TRUE; | |
7 | 5366 |
5367 ga_init2(&ga, 1, 100); | |
28 | 5368 if (type == FRD_REPLACEALL) |
7 | 5369 ga_concat(&ga, (char_u *)"%s/"); |
5370 | |
5371 ga_concat(&ga, (char_u *)"\\V"); | |
5372 if (flags & FRD_MATCH_CASE) | |
5373 ga_concat(&ga, (char_u *)"\\C"); | |
5374 else | |
5375 ga_concat(&ga, (char_u *)"\\c"); | |
5376 if (flags & FRD_WHOLE_WORD) | |
5377 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
|
5378 // 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
|
5379 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
|
5380 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
|
5381 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
|
5382 vim_free(p); |
7 | 5383 if (flags & FRD_WHOLE_WORD) |
5384 ga_concat(&ga, (char_u *)"\\>"); | |
5385 | |
5386 if (type == FRD_REPLACEALL) | |
5387 { | |
28 | 5388 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
|
5389 // escape slash and backslash |
694 | 5390 p = vim_strsave_escaped(repl_text, (char_u *)"/\\"); |
5391 if (p != NULL) | |
5392 ga_concat(&ga, p); | |
5393 vim_free(p); | |
28 | 5394 ga_concat(&ga, (char_u *)"/g"); |
5395 } | |
5396 ga_append(&ga, NUL); | |
5397 | |
5398 if (type == FRD_REPLACE) | |
5399 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5400 // 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
|
5401 // replacement is done if the cursor was moved! |
28 | 5402 regmatch.regprog = vim_regcomp(ga.ga_data, RE_MAGIC + RE_STRING); |
5403 regmatch.rm_ic = 0; | |
5404 if (regmatch.regprog != NULL) | |
5405 { | |
5406 p = ml_get_cursor(); | |
5407 if (vim_regexec_nl(®match, p, (colnr_T)0) | |
5408 && regmatch.startp[0] == p) | |
5409 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5410 // 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
|
5411 // error. |
28 | 5412 msg_end_prompt(); |
5413 | |
5414 if (u_save_cursor() == OK) | |
5415 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5416 // A button was pressed thus undo should be synced. |
825 | 5417 u_sync(FALSE); |
28 | 5418 |
5419 del_bytes((long)(regmatch.endp[0] - regmatch.startp[0]), | |
609 | 5420 FALSE, FALSE); |
28 | 5421 ins_str(repl_text); |
5422 } | |
5423 } | |
5424 else | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15525
diff
changeset
|
5425 msg(_("No match at cursor, finding next")); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
5426 vim_regfree(regmatch.regprog); |
28 | 5427 } |
5428 } | |
5429 | |
5430 if (type == FRD_REPLACEALL) | |
5431 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5432 // A button was pressed, thus undo should be synced. |
825 | 5433 u_sync(FALSE); |
7 | 5434 do_cmdline_cmd(ga.ga_data); |
5435 } | |
5436 else | |
5437 { | |
9305
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5438 int searchflags = SEARCH_MSG + SEARCH_MARK; |
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5439 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5440 // Search for the next match. |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5441 // 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
|
5442 if (type == FRD_REPLACE) |
4981cd0802c7
commit https://github.com/vim/vim/commit/bee666f239eada035d288b77269aebc42f644ea6
Christian Brabandt <cb@256bit.org>
parents:
8947
diff
changeset
|
5443 searchflags += SEARCH_START; |
7 | 5444 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
|
5445 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
|
5446 { |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
5447 (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
|
5448 } |
ec54a202ad0c
patch 8.0.1834: GUI: find/replace dialog does not handle some chars
Christian Brabandt <cb@256bit.org>
parents:
13847
diff
changeset
|
5449 else |
ec54a202ad0c
patch 8.0.1834: GUI: find/replace dialog does not handle some chars
Christian Brabandt <cb@256bit.org>
parents:
13847
diff
changeset
|
5450 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5451 // 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
|
5452 // 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
|
5453 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
|
5454 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
|
5455 (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
|
5456 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
|
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 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5459 msg_scroll = i; // don't let an error message set msg_scroll |
7 | 5460 } |
5461 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5462 // 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
|
5463 // syntax HL if we were busy redrawing. |
482 | 5464 did_emsg = save_did_emsg; |
5465 | |
7 | 5466 if (State & (NORMAL | INSERT)) |
5467 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5468 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
|
5469 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
|
5470 need_wait_return = FALSE; // don't wait for return |
7 | 5471 } |
5472 | |
5473 vim_free(ga.ga_data); | |
1943 | 5474 busy = FALSE; |
7 | 5475 return (ga.ga_len > 0); |
5476 } | |
5477 | |
5478 #endif | |
5479 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5480 #if defined(HAVE_DROP_FILE) || defined(PROTO) |
7 | 5481 /* |
5482 * Jump to the window at specified point (x, y). | |
5483 */ | |
5484 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5485 gui_wingoto_xy(int x, int y) |
7 | 5486 { |
5487 int row = Y_2_ROW(y); | |
5488 int col = X_2_COL(x); | |
5489 win_T *wp; | |
5490 | |
5491 if (row >= 0 && col >= 0) | |
5492 { | |
17041
5ed4965ebc7b
patch 8.1.1520: popup windows are ignored when dealing with mouse position
Bram Moolenaar <Bram@vim.org>
parents:
16904
diff
changeset
|
5493 wp = mouse_find_win(&row, &col, FAIL_POPUP); |
7 | 5494 if (wp != NULL && wp != curwin) |
5495 win_goto(wp); | |
5496 } | |
5497 } | |
5498 | |
5499 /* | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5500 * 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
|
5501 * 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
|
5502 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5503 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5504 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
|
5505 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5506 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
|
5507 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
|
5508 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5509 // 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
|
5510 // 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
|
5511 // 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
|
5512 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
|
5513 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5514 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
|
5515 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5516 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
|
5517 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
|
5518 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5519 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
|
5520 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
|
5521 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
|
5522 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
|
5523 { |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5524 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
|
5525 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
|
5526 } |
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 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5529 // 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
|
5530 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
|
5531 # 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
|
5532 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
|
5533 # endif |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5534 maketitle(); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5535 setcursor(); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5536 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
|
5537 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5538 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5539 /* |
7 | 5540 * Process file drop. Mouse cursor position, key modifiers, name of files |
5541 * and count of files are given. Argument "fnames[count]" has full pathnames | |
5542 * of dropped files, they will be freed in this function, and caller can't use | |
5543 * fnames after call this function. | |
5544 */ | |
5545 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5546 gui_handle_drop( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5547 int x UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5548 int y UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5549 int_u modifiers, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5550 char_u **fnames, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
5551 int count) |
7 | 5552 { |
5553 int i; | |
5554 char_u *p; | |
1668 | 5555 static int entered = FALSE; |
5556 | |
5557 /* | |
5558 * This function is called by event handlers. Just in case we get a | |
5559 * second event before the first one is handled, ignore the second one. | |
5560 * Not sure if this can ever happen, just in case. | |
5561 */ | |
5562 if (entered) | |
5563 return; | |
5564 entered = TRUE; | |
7 | 5565 |
5566 /* | |
5567 * When the cursor is at the command line, add the file names to the | |
5568 * command line, don't edit the files. | |
5569 */ | |
5570 if (State & CMDLINE) | |
5571 { | |
5572 shorten_filenames(fnames, count); | |
5573 for (i = 0; i < count; ++i) | |
5574 { | |
5575 if (fnames[i] != NULL) | |
5576 { | |
5577 if (i > 0) | |
5578 add_to_input_buf((char_u*)" ", 1); | |
5579 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5580 // 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
|
5581 // 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
|
5582 // most common ones. |
7 | 5583 # ifdef BACKSLASH_IN_FILENAME |
5584 p = vim_strsave_escaped(fnames[i], (char_u *)" \t\"|"); | |
5585 # else | |
5586 p = vim_strsave_escaped(fnames[i], (char_u *)"\\ \t\"|"); | |
5587 # endif | |
5588 if (p != NULL) | |
1364 | 5589 add_to_input_buf_csi(p, (int)STRLEN(p)); |
7 | 5590 vim_free(p); |
5591 vim_free(fnames[i]); | |
5592 } | |
5593 } | |
5594 vim_free(fnames); | |
5595 } | |
5596 else | |
5597 { | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5598 // 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
|
5599 // current window, because a window can have local current dir. |
7 | 5600 gui_wingoto_xy(x, y); |
5601 shorten_filenames(fnames, count); | |
5602 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5603 // If Shift held down, remember the first item. |
7 | 5604 if ((modifiers & MOUSE_SHIFT) != 0) |
5605 p = vim_strsave(fnames[0]); | |
5606 else | |
5607 p = NULL; | |
5608 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5609 // 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
|
5610 // 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
|
5611 // directory and Shift is held down. |
7 | 5612 if (count == 1 && (modifiers & MOUSE_SHIFT) != 0 |
5613 && mch_isdir(fnames[0])) | |
5614 { | |
5615 vim_free(fnames[0]); | |
5616 vim_free(fnames); | |
25006
496221916885
patch 8.2.3040: GUI: dropping files not tested
Bram Moolenaar <Bram@vim.org>
parents:
24850
diff
changeset
|
5617 vim_free(p); |
7 | 5618 } |
5619 else | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14424
diff
changeset
|
5620 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
|
5621 drop_callback, (void *)p); |
7 | 5622 } |
1668 | 5623 |
5624 entered = FALSE; | |
7 | 5625 } |
5626 #endif | |
21570
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5627 |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5628 /* |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5629 * 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
|
5630 * applied yet. |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5631 * 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
|
5632 */ |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5633 int |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5634 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
|
5635 { |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5636 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
|
5637 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
|
5638 |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5639 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
|
5640 #ifdef UNIX |
e9954158a9cf
patch 8.2.1336: build failure on non-Unix systems
Bram Moolenaar <Bram@vim.org>
parents:
21570
diff
changeset
|
5641 || (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
|
5642 #endif |
e9954158a9cf
patch 8.2.1336: build failure on non-Unix systems
Bram Moolenaar <Bram@vim.org>
parents:
21570
diff
changeset
|
5643 ) |
21570
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 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
|
5646 return c; |
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 return NUL; |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5649 } |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
5650 |