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