Mercurial > vim
annotate src/gui_beval.c @ 12996:973a0037f4c3 v8.0.1374
patch 8.0.1374: CTRL-A does not work with an empty line
commit https://github.com/vim/vim/commit/5fe6bdf858a7f2f288d599ffb5efb3c08449c817
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 5 17:22:12 2017 +0100
patch 8.0.1374: CTRL-A does not work with an empty line
Problem: CTRL-A does not work with an empty line. (Alex)
Solution: Decrement the end only once. (Hirohito Higashi, closes https://github.com/vim/vim/issues/2387)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 05 Dec 2017 17:30:05 +0100 |
parents | 1a450ce6980c |
children | 2ad722003b36 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9630
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * Visual Workshop integration by Gordon Prieur | |
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 | |
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
|
13 #if defined(FEAT_BEVAL_GUI) || defined(PROTO) |
192 | 14 |
15 /* on Win32 only get_beval_info() is required */ | |
7 | 16 #if !defined(FEAT_GUI_W32) || defined(PROTO) |
17 | |
18 #ifdef FEAT_GUI_GTK | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
19 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
20 # include <gdk/gdkkeysyms-compat.h> |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
21 # else |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
22 # include <gdk/gdkkeysyms.h> |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
23 # endif |
7 | 24 # include <gtk/gtk.h> |
25 #else | |
26 # include <X11/keysym.h> | |
27 # ifdef FEAT_GUI_MOTIF | |
28 # include <Xm/PushB.h> | |
29 # include <Xm/Separator.h> | |
30 # include <Xm/List.h> | |
31 # include <Xm/Label.h> | |
32 # include <Xm/AtomMgr.h> | |
33 # include <Xm/Protocols.h> | |
34 # else | |
35 /* Assume Athena */ | |
36 # include <X11/Shell.h> | |
680 | 37 # ifdef FEAT_GUI_NEXTAW |
38 # include <X11/neXtaw/Label.h> | |
39 # else | |
40 # include <X11/Xaw/Label.h> | |
41 # endif | |
7 | 42 # endif |
43 #endif | |
44 | |
45 #ifndef FEAT_GUI_GTK | |
46 extern Widget vimShell; | |
47 | |
48 /* | |
49 * Currently, we assume that there can be only one BalloonEval showing | |
50 * on-screen at any given moment. This variable will hold the currently | |
51 * showing BalloonEval or NULL if none is showing. | |
52 */ | |
53 static BalloonEval *current_beval = NULL; | |
54 #endif | |
55 | |
56 #ifdef FEAT_GUI_GTK | |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
57 static void addEventHandler(GtkWidget *, BalloonEval *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
58 static void removeEventHandler(BalloonEval *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
59 static gint target_event_cb(GtkWidget *, GdkEvent *, gpointer); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
60 static gint mainwin_event_cb(GtkWidget *, GdkEvent *, gpointer); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
61 static void pointer_event(BalloonEval *, int, int, unsigned); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
62 static void key_event(BalloonEval *, unsigned, int); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
63 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
64 static gboolean timeout_cb(gpointer); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
65 # else |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
66 static gint timeout_cb(gpointer); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
67 # endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
68 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
69 static gboolean balloon_draw_event_cb (GtkWidget *, cairo_t *, gpointer); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
70 # else |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
71 static gint balloon_expose_event_cb (GtkWidget *, GdkEventExpose *, gpointer); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
72 # endif |
7 | 73 #else |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
74 static void addEventHandler(Widget, BalloonEval *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
75 static void removeEventHandler(BalloonEval *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
76 static void pointerEventEH(Widget, XtPointer, XEvent *, Boolean *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
77 static void pointerEvent(BalloonEval *, XEvent *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
78 static void timerRoutine(XtPointer, XtIntervalId *); |
7 | 79 #endif |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
80 static void cancelBalloon(BalloonEval *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
81 static void requestBalloon(BalloonEval *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
82 static void drawBalloon(BalloonEval *); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
83 static void undrawBalloon(BalloonEval *beval); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
6297
diff
changeset
|
84 static void createBalloonEvalWindow(BalloonEval *); |
7 | 85 |
86 /* | |
87 * Create a balloon-evaluation area for a Widget. | |
88 * There can be either a "mesg" for a fixed string or "mesgCB" to generate a | |
89 * message by calling this callback function. | |
90 * When "mesg" is not NULL it must remain valid for as long as the balloon is | |
91 * used. It is not freed here. | |
92 * Returns a pointer to the resulting object (NULL when out of memory). | |
93 */ | |
94 BalloonEval * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
95 gui_mch_create_beval_area( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
96 void *target, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
97 char_u *mesg, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
98 void (*mesgCB)(BalloonEval *, int), |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
99 void *clientData) |
7 | 100 { |
101 #ifndef FEAT_GUI_GTK | |
102 char *display_name; /* get from gui.dpy */ | |
103 int screen_num; | |
104 char *p; | |
105 #endif | |
106 BalloonEval *beval; | |
107 | |
108 if (mesg != NULL && mesgCB != NULL) | |
109 { | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10176
diff
changeset
|
110 IEMSG(_("E232: Cannot create BalloonEval with both message and callback")); |
7 | 111 return NULL; |
112 } | |
113 | |
114 beval = (BalloonEval *)alloc(sizeof(BalloonEval)); | |
115 if (beval != NULL) | |
116 { | |
117 #ifdef FEAT_GUI_GTK | |
118 beval->target = GTK_WIDGET(target); | |
119 beval->balloonShell = NULL; | |
120 beval->timerID = 0; | |
121 #else | |
122 beval->target = (Widget)target; | |
123 beval->balloonShell = NULL; | |
124 beval->timerID = (XtIntervalId)NULL; | |
125 beval->appContext = XtWidgetToApplicationContext((Widget)target); | |
126 #endif | |
127 beval->showState = ShS_NEUTRAL; | |
128 beval->x = 0; | |
129 beval->y = 0; | |
130 beval->msg = mesg; | |
131 beval->msgCB = mesgCB; | |
132 beval->clientData = clientData; | |
133 | |
134 /* | |
135 * Set up event handler which will keep its eyes on the pointer, | |
136 * and when the pointer rests in a certain spot for a given time | |
137 * interval, show the beval. | |
138 */ | |
139 addEventHandler(beval->target, beval); | |
140 createBalloonEvalWindow(beval); | |
141 | |
142 #ifndef FEAT_GUI_GTK | |
143 /* | |
144 * Now create and save the screen width and height. Used in drawing. | |
145 */ | |
146 display_name = DisplayString(gui.dpy); | |
147 p = strrchr(display_name, '.'); | |
148 if (p != NULL) | |
149 screen_num = atoi(++p); | |
150 else | |
151 screen_num = 0; | |
152 beval->screen_width = DisplayWidth(gui.dpy, screen_num); | |
153 beval->screen_height = DisplayHeight(gui.dpy, screen_num); | |
154 #endif | |
155 } | |
156 | |
157 return beval; | |
158 } | |
159 | |
160 #if defined(FEAT_BEVAL_TIP) || defined(PROTO) | |
161 /* | |
1228 | 162 * Destroy a balloon-eval and free its associated memory. |
7 | 163 */ |
164 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
165 gui_mch_destroy_beval_area(BalloonEval *beval) |
7 | 166 { |
167 cancelBalloon(beval); | |
168 removeEventHandler(beval); | |
169 /* Children will automatically be destroyed */ | |
170 # ifdef FEAT_GUI_GTK | |
171 gtk_widget_destroy(beval->balloonShell); | |
172 # else | |
173 XtDestroyWidget(beval->balloonShell); | |
174 # endif | |
175 vim_free(beval); | |
176 } | |
177 #endif | |
178 | |
179 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
180 gui_mch_enable_beval_area(BalloonEval *beval) |
7 | 181 { |
182 if (beval != NULL) | |
183 addEventHandler(beval->target, beval); | |
184 } | |
185 | |
186 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
187 gui_mch_disable_beval_area(BalloonEval *beval) |
7 | 188 { |
189 if (beval != NULL) | |
190 removeEventHandler(beval); | |
191 } | |
192 | |
193 #if defined(FEAT_BEVAL_TIP) || defined(PROTO) | |
194 /* | |
195 * This function returns the BalloonEval * associated with the currently | |
196 * displayed tooltip. Returns NULL if there is no tooltip currently showing. | |
197 * | |
198 * Assumption: Only one tooltip can be shown at a time. | |
199 */ | |
200 BalloonEval * | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
201 gui_mch_currently_showing_beval(void) |
7 | 202 { |
203 return current_beval; | |
204 } | |
205 #endif | |
206 #endif /* !FEAT_GUI_W32 */ | |
207 | |
192 | 208 #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \ |
209 || defined(FEAT_EVAL) || defined(PROTO) | |
7 | 210 # if !defined(FEAT_GUI_W32) || defined(PROTO) |
211 | |
212 /* | |
213 * Show a balloon with "mesg". | |
214 */ | |
215 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
216 gui_mch_post_balloon(BalloonEval *beval, char_u *mesg) |
7 | 217 { |
218 beval->msg = mesg; | |
219 if (mesg != NULL) | |
220 drawBalloon(beval); | |
221 else | |
222 undrawBalloon(beval); | |
223 } | |
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
|
224 # endif /* !FEAT_GUI_W32 */ |
7 | 225 #endif /* FEAT_SUN_WORKSHOP || FEAT_NETBEANS_INTG || PROTO */ |
226 | |
227 #if !defined(FEAT_GUI_W32) || defined(PROTO) | |
228 #if defined(FEAT_BEVAL_TIP) || defined(PROTO) | |
229 /* | |
230 * Hide the given balloon. | |
231 */ | |
232 void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
233 gui_mch_unpost_balloon(BalloonEval *beval) |
7 | 234 { |
235 undrawBalloon(beval); | |
236 } | |
237 #endif | |
238 | |
239 #ifdef FEAT_GUI_GTK | |
240 static void | |
241 addEventHandler(GtkWidget *target, BalloonEval *beval) | |
242 { | |
243 /* | |
244 * Connect to the generic "event" signal instead of the individual | |
245 * signals for each event type, because the former is emitted earlier. | |
246 * This allows us to catch events independently of the signal handlers | |
247 * in gui_gtk_x11.c. | |
248 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
249 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
250 g_signal_connect(G_OBJECT(target), "event", |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
251 G_CALLBACK(target_event_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
252 beval); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
253 # else |
7 | 254 /* Should use GTK_OBJECT() here, but that causes a lint warning... */ |
255 gtk_signal_connect((GtkObject*)(target), "event", | |
256 GTK_SIGNAL_FUNC(target_event_cb), | |
257 beval); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
258 # endif |
7 | 259 /* |
260 * Nasty: Key press events go to the main window thus the drawing area | |
261 * will never see them. This means we have to connect to the main window | |
262 * as well in order to catch those events. | |
263 */ | |
264 if (gtk_socket_id == 0 && gui.mainwin != NULL | |
265 && gtk_widget_is_ancestor(target, gui.mainwin)) | |
266 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
267 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
268 g_signal_connect(G_OBJECT(gui.mainwin), "event", |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
269 G_CALLBACK(mainwin_event_cb), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
270 beval); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
271 # else |
7 | 272 gtk_signal_connect((GtkObject*)(gui.mainwin), "event", |
273 GTK_SIGNAL_FUNC(mainwin_event_cb), | |
274 beval); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
275 # endif |
7 | 276 } |
277 } | |
278 | |
279 static void | |
280 removeEventHandler(BalloonEval *beval) | |
281 { | |
137 | 282 /* LINTED: avoid warning: dubious operation on enum */ |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
283 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
284 g_signal_handlers_disconnect_by_func(G_OBJECT(beval->target), |
10176
51888fb2599f
commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
285 FUNC2GENERIC(target_event_cb), |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
286 beval); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
287 # else |
7 | 288 gtk_signal_disconnect_by_func((GtkObject*)(beval->target), |
289 GTK_SIGNAL_FUNC(target_event_cb), | |
290 beval); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
291 # endif |
7 | 292 |
293 if (gtk_socket_id == 0 && gui.mainwin != NULL | |
294 && gtk_widget_is_ancestor(beval->target, gui.mainwin)) | |
295 { | |
137 | 296 /* LINTED: avoid warning: dubious operation on enum */ |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
297 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
298 g_signal_handlers_disconnect_by_func(G_OBJECT(gui.mainwin), |
10176
51888fb2599f
commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
299 FUNC2GENERIC(mainwin_event_cb), |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
300 beval); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
301 # else |
7 | 302 gtk_signal_disconnect_by_func((GtkObject*)(gui.mainwin), |
303 GTK_SIGNAL_FUNC(mainwin_event_cb), | |
304 beval); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
305 # endif |
7 | 306 } |
307 } | |
308 | |
309 static gint | |
310 target_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data) | |
311 { | |
312 BalloonEval *beval = (BalloonEval *)data; | |
313 | |
314 switch (event->type) | |
315 { | |
316 case GDK_ENTER_NOTIFY: | |
317 pointer_event(beval, (int)event->crossing.x, | |
318 (int)event->crossing.y, | |
319 event->crossing.state); | |
320 break; | |
321 case GDK_MOTION_NOTIFY: | |
322 if (event->motion.is_hint) | |
323 { | |
324 int x; | |
325 int y; | |
326 GdkModifierType state; | |
327 /* | |
328 * GDK_POINTER_MOTION_HINT_MASK is set, thus we cannot obtain | |
329 * the coordinates from the GdkEventMotion struct directly. | |
330 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
331 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
332 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
333 GdkWindow * const win = gtk_widget_get_window(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
334 GdkDisplay * const dpy = gdk_window_get_display(win); |
8926
fc69eed19ba7
commit https://github.com/vim/vim/commit/30e12d259ee78272359f9da2655d0593a4f6a626
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
335 # if GTK_CHECK_VERSION(3,20,0) |
fc69eed19ba7
commit https://github.com/vim/vim/commit/30e12d259ee78272359f9da2655d0593a4f6a626
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
336 GdkSeat * const seat = gdk_display_get_default_seat(dpy); |
fc69eed19ba7
commit https://github.com/vim/vim/commit/30e12d259ee78272359f9da2655d0593a4f6a626
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
337 GdkDevice * const dev = gdk_seat_get_pointer(seat); |
fc69eed19ba7
commit https://github.com/vim/vim/commit/30e12d259ee78272359f9da2655d0593a4f6a626
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
338 # else |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
339 GdkDeviceManager * const mngr = gdk_display_get_device_manager(dpy); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
340 GdkDevice * const dev = gdk_device_manager_get_client_pointer(mngr); |
8926
fc69eed19ba7
commit https://github.com/vim/vim/commit/30e12d259ee78272359f9da2655d0593a4f6a626
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
341 # endif |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
342 gdk_window_get_device_position(win, dev , &x, &y, &state); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
343 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
344 # else |
7 | 345 gdk_window_get_pointer(widget->window, &x, &y, &state); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
346 # endif |
7 | 347 pointer_event(beval, x, y, (unsigned int)state); |
348 } | |
349 else | |
350 { | |
351 pointer_event(beval, (int)event->motion.x, | |
352 (int)event->motion.y, | |
353 event->motion.state); | |
354 } | |
355 break; | |
356 case GDK_LEAVE_NOTIFY: | |
357 /* | |
358 * Ignore LeaveNotify events that are not "normal". | |
359 * Apparently we also get it when somebody else grabs focus. | |
360 */ | |
361 if (event->crossing.mode == GDK_CROSSING_NORMAL) | |
362 cancelBalloon(beval); | |
363 break; | |
364 case GDK_BUTTON_PRESS: | |
365 case GDK_SCROLL: | |
366 cancelBalloon(beval); | |
367 break; | |
368 case GDK_KEY_PRESS: | |
369 key_event(beval, event->key.keyval, TRUE); | |
370 break; | |
371 case GDK_KEY_RELEASE: | |
372 key_event(beval, event->key.keyval, FALSE); | |
373 break; | |
374 default: | |
375 break; | |
376 } | |
377 | |
378 return FALSE; /* continue emission */ | |
379 } | |
380 | |
381 static gint | |
1884 | 382 mainwin_event_cb(GtkWidget *widget UNUSED, GdkEvent *event, gpointer data) |
7 | 383 { |
384 BalloonEval *beval = (BalloonEval *)data; | |
385 | |
386 switch (event->type) | |
387 { | |
388 case GDK_KEY_PRESS: | |
389 key_event(beval, event->key.keyval, TRUE); | |
390 break; | |
391 case GDK_KEY_RELEASE: | |
392 key_event(beval, event->key.keyval, FALSE); | |
393 break; | |
394 default: | |
395 break; | |
396 } | |
397 | |
398 return FALSE; /* continue emission */ | |
399 } | |
400 | |
401 static void | |
402 pointer_event(BalloonEval *beval, int x, int y, unsigned state) | |
403 { | |
404 int distance; | |
405 | |
406 distance = ABS(x - beval->x) + ABS(y - beval->y); | |
407 | |
408 if (distance > 4) | |
409 { | |
410 /* | |
411 * Moved out of the balloon location: cancel it. | |
412 * Remember button state | |
413 */ | |
414 beval->state = state; | |
415 cancelBalloon(beval); | |
416 | |
417 /* Mouse buttons are pressed - no balloon now */ | |
418 if (!(state & ((int)GDK_BUTTON1_MASK | (int)GDK_BUTTON2_MASK | |
419 | (int)GDK_BUTTON3_MASK))) | |
420 { | |
421 beval->x = x; | |
422 beval->y = y; | |
423 | |
424 if (state & (int)GDK_MOD1_MASK) | |
425 { | |
426 /* | |
427 * Alt is pressed -- enter super-evaluate-mode, | |
428 * where there is no time delay | |
429 */ | |
430 if (beval->msgCB != NULL) | |
431 { | |
432 beval->showState = ShS_PENDING; | |
433 (*beval->msgCB)(beval, state); | |
434 } | |
435 } | |
436 else | |
437 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
438 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
439 beval->timerID = g_timeout_add((guint)p_bdlay, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
440 &timeout_cb, beval); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
441 # else |
7 | 442 beval->timerID = gtk_timeout_add((guint32)p_bdlay, |
443 &timeout_cb, beval); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
444 # endif |
7 | 445 } |
446 } | |
447 } | |
448 } | |
449 | |
450 static void | |
451 key_event(BalloonEval *beval, unsigned keyval, int is_keypress) | |
452 { | |
453 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL) | |
454 { | |
455 switch (keyval) | |
456 { | |
457 case GDK_Shift_L: | |
458 case GDK_Shift_R: | |
459 beval->showState = ShS_UPDATE_PENDING; | |
460 (*beval->msgCB)(beval, (is_keypress) | |
461 ? (int)GDK_SHIFT_MASK : 0); | |
462 break; | |
463 case GDK_Control_L: | |
464 case GDK_Control_R: | |
465 beval->showState = ShS_UPDATE_PENDING; | |
466 (*beval->msgCB)(beval, (is_keypress) | |
467 ? (int)GDK_CONTROL_MASK : 0); | |
468 break; | |
469 default: | |
667 | 470 /* Don't do this for key release, we apparently get these with |
471 * focus changes in some GTK version. */ | |
472 if (is_keypress) | |
473 cancelBalloon(beval); | |
7 | 474 break; |
475 } | |
476 } | |
477 else | |
478 cancelBalloon(beval); | |
479 } | |
480 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
481 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
482 static gboolean |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
483 # else |
7 | 484 static gint |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
485 # endif |
7 | 486 timeout_cb(gpointer data) |
487 { | |
488 BalloonEval *beval = (BalloonEval *)data; | |
489 | |
490 beval->timerID = 0; | |
491 /* | |
492 * If the timer event happens then the mouse has stopped long enough for | |
493 * a request to be started. The request will only send to the debugger if | |
494 * there the mouse is pointing at real data. | |
495 */ | |
496 requestBalloon(beval); | |
497 | |
498 return FALSE; /* don't call me again */ | |
499 } | |
500 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
501 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
502 static gboolean |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
503 balloon_draw_event_cb(GtkWidget *widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
504 cairo_t *cr, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
505 gpointer data UNUSED) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
506 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
507 GtkStyleContext *context = NULL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
508 gint width = -1, height = -1; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
509 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
510 if (widget == NULL) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
511 return TRUE; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
512 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
513 context = gtk_widget_get_style_context(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
514 width = gtk_widget_get_allocated_width(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
515 height = gtk_widget_get_allocated_height(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
516 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
517 gtk_style_context_save(context); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
518 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
519 gtk_style_context_add_class(context, "tooltip"); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
520 gtk_style_context_set_state(context, GTK_STATE_FLAG_NORMAL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
521 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
522 cairo_save(cr); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
523 gtk_render_frame(context, cr, 0, 0, width, height); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
524 gtk_render_background(context, cr, 0, 0, width, height); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
525 cairo_restore(cr); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
526 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
527 gtk_style_context_restore(context); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
528 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
529 return FALSE; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
530 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
531 # else |
7 | 532 static gint |
1884 | 533 balloon_expose_event_cb(GtkWidget *widget, |
534 GdkEventExpose *event, | |
535 gpointer data UNUSED) | |
7 | 536 { |
537 gtk_paint_flat_box(widget->style, widget->window, | |
538 GTK_STATE_NORMAL, GTK_SHADOW_OUT, | |
539 &event->area, widget, "tooltip", | |
540 0, 0, -1, -1); | |
541 | |
542 return FALSE; /* continue emission */ | |
543 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
544 # endif /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 545 |
546 #else /* !FEAT_GUI_GTK */ | |
547 | |
548 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
549 addEventHandler(Widget target, BalloonEval *beval) |
7 | 550 { |
551 XtAddEventHandler(target, | |
552 PointerMotionMask | EnterWindowMask | | |
553 LeaveWindowMask | ButtonPressMask | KeyPressMask | | |
554 KeyReleaseMask, | |
555 False, | |
556 pointerEventEH, (XtPointer)beval); | |
557 } | |
558 | |
559 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
560 removeEventHandler(BalloonEval *beval) |
7 | 561 { |
562 XtRemoveEventHandler(beval->target, | |
563 PointerMotionMask | EnterWindowMask | | |
564 LeaveWindowMask | ButtonPressMask | KeyPressMask | | |
565 KeyReleaseMask, | |
566 False, | |
567 pointerEventEH, (XtPointer)beval); | |
568 } | |
569 | |
570 | |
571 /* | |
572 * The X event handler. All it does is call the real event handler. | |
573 */ | |
574 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
575 pointerEventEH( |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
576 Widget w UNUSED, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
577 XtPointer client_data, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
578 XEvent *event, |
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
579 Boolean *unused UNUSED) |
7 | 580 { |
581 BalloonEval *beval = (BalloonEval *)client_data; | |
582 pointerEvent(beval, event); | |
583 } | |
584 | |
585 | |
586 /* | |
587 * The real event handler. Called by pointerEventEH() whenever an event we are | |
1228 | 588 * interested in occurs. |
7 | 589 */ |
590 | |
591 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
592 pointerEvent(BalloonEval *beval, XEvent *event) |
7 | 593 { |
4352 | 594 Position distance; /* a measure of how much the pointer moved */ |
7 | 595 Position delta; /* used to compute distance */ |
596 | |
597 switch (event->type) | |
598 { | |
599 case EnterNotify: | |
600 case MotionNotify: | |
601 delta = event->xmotion.x - beval->x; | |
602 if (delta < 0) | |
603 delta = -delta; | |
604 distance = delta; | |
605 delta = event->xmotion.y - beval->y; | |
606 if (delta < 0) | |
607 delta = -delta; | |
608 distance += delta; | |
609 if (distance > 4) | |
610 { | |
611 /* | |
612 * Moved out of the balloon location: cancel it. | |
613 * Remember button state | |
614 */ | |
615 beval->state = event->xmotion.state; | |
616 if (beval->state & (Button1Mask|Button2Mask|Button3Mask)) | |
617 { | |
618 /* Mouse buttons are pressed - no balloon now */ | |
619 cancelBalloon(beval); | |
620 } | |
621 else if (beval->state & (Mod1Mask|Mod2Mask|Mod3Mask)) | |
622 { | |
623 /* | |
624 * Alt is pressed -- enter super-evaluate-mode, | |
625 * where there is no time delay | |
626 */ | |
627 beval->x = event->xmotion.x; | |
628 beval->y = event->xmotion.y; | |
629 beval->x_root = event->xmotion.x_root; | |
630 beval->y_root = event->xmotion.y_root; | |
631 cancelBalloon(beval); | |
632 if (beval->msgCB != NULL) | |
633 { | |
634 beval->showState = ShS_PENDING; | |
635 (*beval->msgCB)(beval, beval->state); | |
636 } | |
637 } | |
638 else | |
639 { | |
640 beval->x = event->xmotion.x; | |
641 beval->y = event->xmotion.y; | |
642 beval->x_root = event->xmotion.x_root; | |
643 beval->y_root = event->xmotion.y_root; | |
644 cancelBalloon(beval); | |
645 beval->timerID = XtAppAddTimeOut( beval->appContext, | |
646 (long_u)p_bdlay, timerRoutine, beval); | |
647 } | |
648 } | |
649 break; | |
650 | |
651 /* | |
652 * Motif and Athena version: Keystrokes will be caught by the | |
653 * "textArea" widget, and handled in gui_x11_key_hit_cb(). | |
654 */ | |
655 case KeyPress: | |
656 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL) | |
657 { | |
658 Modifiers modifier; | |
659 KeySym keysym; | |
660 | |
661 XtTranslateKeycode(gui.dpy, | |
662 event->xkey.keycode, event->xkey.state, | |
663 &modifier, &keysym); | |
664 if (keysym == XK_Shift_L || keysym == XK_Shift_R) | |
665 { | |
666 beval->showState = ShS_UPDATE_PENDING; | |
667 (*beval->msgCB)(beval, ShiftMask); | |
668 } | |
669 else if (keysym == XK_Control_L || keysym == XK_Control_R) | |
670 { | |
671 beval->showState = ShS_UPDATE_PENDING; | |
672 (*beval->msgCB)(beval, ControlMask); | |
673 } | |
674 else | |
675 cancelBalloon(beval); | |
676 } | |
677 else | |
678 cancelBalloon(beval); | |
679 break; | |
680 | |
681 case KeyRelease: | |
682 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL) | |
683 { | |
684 Modifiers modifier; | |
685 KeySym keysym; | |
686 | |
687 XtTranslateKeycode(gui.dpy, event->xkey.keycode, | |
688 event->xkey.state, &modifier, &keysym); | |
689 if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R)) { | |
690 beval->showState = ShS_UPDATE_PENDING; | |
691 (*beval->msgCB)(beval, 0); | |
692 } | |
693 else if ((keysym == XK_Control_L) || (keysym == XK_Control_R)) | |
694 { | |
695 beval->showState = ShS_UPDATE_PENDING; | |
696 (*beval->msgCB)(beval, 0); | |
697 } | |
698 else | |
699 cancelBalloon(beval); | |
700 } | |
701 else | |
702 cancelBalloon(beval); | |
703 break; | |
704 | |
705 case LeaveNotify: | |
706 /* Ignore LeaveNotify events that are not "normal". | |
707 * Apparently we also get it when somebody else grabs focus. | |
708 * Happens for me every two seconds (some clipboard tool?) */ | |
709 if (event->xcrossing.mode == NotifyNormal) | |
710 cancelBalloon(beval); | |
711 break; | |
712 | |
713 case ButtonPress: | |
714 cancelBalloon(beval); | |
715 break; | |
716 | |
717 default: | |
718 break; | |
719 } | |
720 } | |
721 | |
722 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
723 timerRoutine(XtPointer dx, XtIntervalId *id UNUSED) |
7 | 724 { |
725 BalloonEval *beval = (BalloonEval *)dx; | |
726 | |
727 beval->timerID = (XtIntervalId)NULL; | |
728 | |
729 /* | |
730 * If the timer event happens then the mouse has stopped long enough for | |
731 * a request to be started. The request will only send to the debugger if | |
732 * there the mouse is pointing at real data. | |
733 */ | |
734 requestBalloon(beval); | |
735 } | |
736 | |
737 #endif /* !FEAT_GUI_GTK */ | |
738 | |
739 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
740 requestBalloon(BalloonEval *beval) |
7 | 741 { |
742 if (beval->showState != ShS_PENDING) | |
743 { | |
744 /* Determine the beval to display */ | |
745 if (beval->msgCB != NULL) | |
746 { | |
747 beval->showState = ShS_PENDING; | |
748 (*beval->msgCB)(beval, beval->state); | |
749 } | |
750 else if (beval->msg != NULL) | |
751 drawBalloon(beval); | |
752 } | |
753 } | |
754 | |
755 #ifdef FEAT_GUI_GTK | |
756 /* | |
757 * Convert the string to UTF-8 if 'encoding' is not "utf-8". | |
758 * Replace any non-printable characters and invalid bytes sequences with | |
759 * "^X" or "<xx>" escapes, and apply SpecialKey highlighting to them. | |
760 * TAB and NL are passed through unscathed. | |
761 */ | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
762 # define IS_NONPRINTABLE(c) (((c) < 0x20 && (c) != TAB && (c) != NL) \ |
7 | 763 || (c) == DEL) |
764 static void | |
944 | 765 set_printable_label_text(GtkLabel *label, char_u *text) |
7 | 766 { |
767 char_u *convbuf = NULL; | |
768 char_u *buf; | |
769 char_u *p; | |
770 char_u *pdest; | |
771 unsigned int len; | |
772 int charlen; | |
773 int uc; | |
774 PangoAttrList *attr_list; | |
775 | |
776 /* Convert to UTF-8 if it isn't already */ | |
777 if (output_conv.vc_type != CONV_NONE) | |
778 { | |
944 | 779 convbuf = string_convert(&output_conv, text, NULL); |
7 | 780 if (convbuf != NULL) |
944 | 781 text = convbuf; |
7 | 782 } |
783 | |
784 /* First let's see how much we need to allocate */ | |
785 len = 0; | |
944 | 786 for (p = text; *p != NUL; p += charlen) |
7 | 787 { |
788 if ((*p & 0x80) == 0) /* be quick for ASCII */ | |
789 { | |
790 charlen = 1; | |
791 len += IS_NONPRINTABLE(*p) ? 2 : 1; /* nonprintable: ^X */ | |
792 } | |
793 else | |
794 { | |
474 | 795 charlen = utf_ptr2len(p); |
7 | 796 uc = utf_ptr2char(p); |
797 | |
798 if (charlen != utf_char2len(uc)) | |
799 charlen = 1; /* reject overlong sequences */ | |
800 | |
801 if (charlen == 1 || uc < 0xa0) /* illegal byte or */ | |
802 len += 4; /* control char: <xx> */ | |
803 else if (!utf_printable(uc)) | |
804 /* Note: we assume here that utf_printable() doesn't | |
805 * care about characters outside the BMP. */ | |
806 len += 6; /* nonprintable: <xxxx> */ | |
807 else | |
808 len += charlen; | |
809 } | |
810 } | |
811 | |
812 attr_list = pango_attr_list_new(); | |
813 buf = alloc(len + 1); | |
814 | |
815 /* Now go for the real work */ | |
816 if (buf != NULL) | |
817 { | |
818 attrentry_T *aep; | |
819 PangoAttribute *attr; | |
820 guicolor_T pixel; | |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
821 #if GTK_CHECK_VERSION(3,0,0) |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
822 GdkRGBA color = { 0.0, 0.0, 0.0, 1.0 }; |
9630
0c098fb3994c
commit https://github.com/vim/vim/commit/870b749ce1db1cec80f0f3766064a031688e6a46
Christian Brabandt <cb@256bit.org>
parents:
9624
diff
changeset
|
823 # if PANGO_VERSION_CHECK(1,38,0) |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
824 PangoAttribute *attr_alpha; |
9630
0c098fb3994c
commit https://github.com/vim/vim/commit/870b749ce1db1cec80f0f3766064a031688e6a46
Christian Brabandt <cb@256bit.org>
parents:
9624
diff
changeset
|
825 # endif |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
826 #else |
7 | 827 GdkColor color = { 0, 0, 0, 0 }; |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
828 #endif |
7 | 829 |
830 /* Look up the RGB values of the SpecialKey foreground color. */ | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
831 aep = syn_gui_attr2entry(HL_ATTR(HLF_8)); |
7 | 832 pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR; |
833 if (pixel != INVALCOLOR) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
834 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
835 { |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
836 color.red = ((pixel & 0xff0000) >> 16) / 255.0; |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
837 color.green = ((pixel & 0xff00) >> 8) / 255.0; |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
838 color.blue = (pixel & 0xff) / 255.0; |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
839 color.alpha = 1.0; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
840 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
841 # else |
7 | 842 gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea), |
843 (unsigned long)pixel, &color); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
844 # endif |
7 | 845 |
846 pdest = buf; | |
944 | 847 p = text; |
7 | 848 while (*p != NUL) |
849 { | |
850 /* Be quick for ASCII */ | |
851 if ((*p & 0x80) == 0 && !IS_NONPRINTABLE(*p)) | |
852 { | |
853 *pdest++ = *p++; | |
854 } | |
855 else | |
856 { | |
474 | 857 charlen = utf_ptr2len(p); |
7 | 858 uc = utf_ptr2char(p); |
859 | |
860 if (charlen != utf_char2len(uc)) | |
861 charlen = 1; /* reject overlong sequences */ | |
862 | |
863 if (charlen == 1 || uc < 0xa0 || !utf_printable(uc)) | |
864 { | |
865 int outlen; | |
866 | |
867 /* Careful: we can't just use transchar_byte() here, | |
868 * since 'encoding' is not necessarily set to "utf-8". */ | |
869 if (*p & 0x80 && charlen == 1) | |
870 { | |
871 transchar_hex(pdest, *p); /* <xx> */ | |
872 outlen = 4; | |
873 } | |
874 else if (uc >= 0x80) | |
875 { | |
876 /* Note: we assume here that utf_printable() doesn't | |
877 * care about characters outside the BMP. */ | |
878 transchar_hex(pdest, uc); /* <xx> or <xxxx> */ | |
879 outlen = (uc < 0x100) ? 4 : 6; | |
880 } | |
881 else | |
882 { | |
883 transchar_nonprint(pdest, *p); /* ^X */ | |
884 outlen = 2; | |
885 } | |
886 if (pixel != INVALCOLOR) | |
887 { | |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
888 #if GTK_CHECK_VERSION(3,0,0) |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
889 # define DOUBLE2UINT16(val) ((guint16)((val) * 65535 + 0.5)) |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
890 attr = pango_attr_foreground_new( |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
891 DOUBLE2UINT16(color.red), |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
892 DOUBLE2UINT16(color.green), |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
893 DOUBLE2UINT16(color.blue)); |
9630
0c098fb3994c
commit https://github.com/vim/vim/commit/870b749ce1db1cec80f0f3766064a031688e6a46
Christian Brabandt <cb@256bit.org>
parents:
9624
diff
changeset
|
894 # if PANGO_VERSION_CHECK(1,38,0) |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
895 attr_alpha = pango_attr_foreground_alpha_new( |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
896 DOUBLE2UINT16(color.alpha)); |
9630
0c098fb3994c
commit https://github.com/vim/vim/commit/870b749ce1db1cec80f0f3766064a031688e6a46
Christian Brabandt <cb@256bit.org>
parents:
9624
diff
changeset
|
897 # endif |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
898 # undef DOUBLE2UINT16 |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
899 #else |
7 | 900 attr = pango_attr_foreground_new( |
901 color.red, color.green, color.blue); | |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
902 #endif |
7 | 903 attr->start_index = pdest - buf; |
904 attr->end_index = pdest - buf + outlen; | |
905 pango_attr_list_insert(attr_list, attr); | |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
906 #if GTK_CHECK_VERSION(3,0,0) |
9630
0c098fb3994c
commit https://github.com/vim/vim/commit/870b749ce1db1cec80f0f3766064a031688e6a46
Christian Brabandt <cb@256bit.org>
parents:
9624
diff
changeset
|
907 # if PANGO_VERSION_CHECK(1,38,0) |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
908 attr_alpha->start_index = pdest - buf; |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
909 attr_alpha->end_index = pdest - buf + outlen; |
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
910 pango_attr_list_insert(attr_list, attr_alpha); |
9630
0c098fb3994c
commit https://github.com/vim/vim/commit/870b749ce1db1cec80f0f3766064a031688e6a46
Christian Brabandt <cb@256bit.org>
parents:
9624
diff
changeset
|
911 # endif |
9624
d63b85fe3dc7
commit https://github.com/vim/vim/commit/36edf0685c8b55ee3ce709058d83ada8027fec1e
Christian Brabandt <cb@256bit.org>
parents:
9217
diff
changeset
|
912 #endif |
7 | 913 } |
914 pdest += outlen; | |
915 p += charlen; | |
916 } | |
917 else | |
918 { | |
919 do | |
920 *pdest++ = *p++; | |
921 while (--charlen != 0); | |
922 } | |
923 } | |
924 } | |
925 *pdest = NUL; | |
926 } | |
927 | |
928 vim_free(convbuf); | |
929 | |
930 gtk_label_set_text(label, (const char *)buf); | |
931 vim_free(buf); | |
932 | |
933 gtk_label_set_attributes(label, attr_list); | |
934 pango_attr_list_unref(attr_list); | |
935 } | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
936 # undef IS_NONPRINTABLE |
7 | 937 |
938 /* | |
939 * Draw a balloon. | |
940 */ | |
941 static void | |
942 drawBalloon(BalloonEval *beval) | |
943 { | |
944 if (beval->msg != NULL) | |
945 { | |
946 GtkRequisition requisition; | |
947 int screen_w; | |
948 int screen_h; | |
949 int x; | |
950 int y; | |
951 int x_offset = EVAL_OFFSET_X; | |
952 int y_offset = EVAL_OFFSET_Y; | |
953 PangoLayout *layout; | |
10390
6c8a4d21b873
commit https://github.com/vim/vim/commit/a859f04b4db651860c07db3587f29906517c552b
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
954 |
12409
2c020bc30f62
patch 8.0.1084: GTK build has compiler warnings
Christian Brabandt <cb@256bit.org>
parents:
11474
diff
changeset
|
955 # if !GTK_CHECK_VERSION(3,22,2) |
7 | 956 GdkScreen *screen; |
957 | |
958 screen = gtk_widget_get_screen(beval->target); | |
959 gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen); | |
960 # endif | |
12409
2c020bc30f62
patch 8.0.1084: GTK build has compiler warnings
Christian Brabandt <cb@256bit.org>
parents:
11474
diff
changeset
|
961 gui_gtk_get_screen_size_of_win(beval->balloonShell, |
2c020bc30f62
patch 8.0.1084: GTK build has compiler warnings
Christian Brabandt <cb@256bit.org>
parents:
11474
diff
changeset
|
962 &screen_w, &screen_h); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
963 # if !GTK_CHECK_VERSION(3,0,0) |
7 | 964 gtk_widget_ensure_style(beval->balloonShell); |
965 gtk_widget_ensure_style(beval->balloonLabel); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
966 # endif |
7 | 967 |
968 set_printable_label_text(GTK_LABEL(beval->balloonLabel), beval->msg); | |
969 /* | |
970 * Dirty trick: Enable wrapping mode on the label's layout behind its | |
971 * back. This way GtkLabel won't try to constrain the wrap width to a | |
972 * builtin maximum value of about 65 Latin characters. | |
973 */ | |
974 layout = gtk_label_get_layout(GTK_LABEL(beval->balloonLabel)); | |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
975 # ifdef PANGO_WRAP_WORD_CHAR |
7 | 976 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
977 # else |
7 | 978 pango_layout_set_wrap(layout, PANGO_WRAP_WORD); |
2275
e4d849f4df03
Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents:
2251
diff
changeset
|
979 # endif |
7 | 980 pango_layout_set_width(layout, |
981 /* try to come up with some reasonable width */ | |
982 PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width, | |
983 screen_w / 2, | |
984 MAX(20, screen_w - 20))); | |
985 | |
986 /* Calculate the balloon's width and height. */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
987 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
988 gtk_widget_get_preferred_size(beval->balloonShell, &requisition, NULL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
989 # else |
7 | 990 gtk_widget_size_request(beval->balloonShell, &requisition); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
991 # endif |
7 | 992 |
993 /* Compute position of the balloon area */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
994 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
995 gdk_window_get_origin(gtk_widget_get_window(beval->target), &x, &y); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
996 # else |
7 | 997 gdk_window_get_origin(beval->target->window, &x, &y); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
998 # endif |
7 | 999 x += beval->x; |
1000 y += beval->y; | |
1001 | |
1002 /* Get out of the way of the mouse pointer */ | |
1003 if (x + x_offset + requisition.width > screen_w) | |
1004 y_offset += 15; | |
1005 if (y + y_offset + requisition.height > screen_h) | |
1006 y_offset = -requisition.height - EVAL_OFFSET_Y; | |
1007 | |
1008 /* Sanitize values */ | |
1009 x = CLAMP(x + x_offset, 0, MAX(0, screen_w - requisition.width)); | |
1010 y = CLAMP(y + y_offset, 0, MAX(0, screen_h - requisition.height)); | |
1011 | |
1012 /* Show the balloon */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1013 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1014 gtk_window_move(GTK_WINDOW(beval->balloonShell), x, y); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1015 # else |
7 | 1016 gtk_widget_set_uposition(beval->balloonShell, x, y); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1017 # endif |
7 | 1018 gtk_widget_show(beval->balloonShell); |
1019 | |
1020 beval->showState = ShS_SHOWING; | |
1021 } | |
1022 } | |
1023 | |
1024 /* | |
1025 * Undraw a balloon. | |
1026 */ | |
1027 static void | |
1028 undrawBalloon(BalloonEval *beval) | |
1029 { | |
1030 if (beval->balloonShell != NULL) | |
1031 gtk_widget_hide(beval->balloonShell); | |
1032 beval->showState = ShS_NEUTRAL; | |
1033 } | |
1034 | |
1035 static void | |
1036 cancelBalloon(BalloonEval *beval) | |
1037 { | |
1038 if (beval->showState == ShS_SHOWING | |
1039 || beval->showState == ShS_UPDATE_PENDING) | |
1040 undrawBalloon(beval); | |
1041 | |
1042 if (beval->timerID != 0) | |
1043 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1044 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1045 g_source_remove(beval->timerID); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1046 # else |
7 | 1047 gtk_timeout_remove(beval->timerID); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1048 # endif |
7 | 1049 beval->timerID = 0; |
1050 } | |
1051 beval->showState = ShS_NEUTRAL; | |
1052 } | |
1053 | |
1054 static void | |
1055 createBalloonEvalWindow(BalloonEval *beval) | |
1056 { | |
1057 beval->balloonShell = gtk_window_new(GTK_WINDOW_POPUP); | |
1058 | |
1059 gtk_widget_set_app_paintable(beval->balloonShell, TRUE); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1060 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1061 gtk_window_set_resizable(GTK_WINDOW(beval->balloonShell), FALSE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1062 # else |
7 | 1063 gtk_window_set_policy(GTK_WINDOW(beval->balloonShell), FALSE, FALSE, TRUE); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1064 # endif |
7 | 1065 gtk_widget_set_name(beval->balloonShell, "gtk-tooltips"); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1066 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1067 gtk_container_set_border_width(GTK_CONTAINER(beval->balloonShell), 4); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1068 # else |
7 | 1069 gtk_container_border_width(GTK_CONTAINER(beval->balloonShell), 4); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1070 # endif |
7 | 1071 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1072 # if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1073 g_signal_connect(G_OBJECT(beval->balloonShell), "draw", |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1074 G_CALLBACK(balloon_draw_event_cb), NULL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1075 # else |
7 | 1076 gtk_signal_connect((GtkObject*)(beval->balloonShell), "expose_event", |
1077 GTK_SIGNAL_FUNC(balloon_expose_event_cb), NULL); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1078 # endif |
7 | 1079 beval->balloonLabel = gtk_label_new(NULL); |
1080 | |
1081 gtk_label_set_line_wrap(GTK_LABEL(beval->balloonLabel), FALSE); | |
1082 gtk_label_set_justify(GTK_LABEL(beval->balloonLabel), GTK_JUSTIFY_LEFT); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1083 # if GTK_CHECK_VERSION(3,16,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1084 gtk_label_set_xalign(GTK_LABEL(beval->balloonLabel), 0.5); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1085 gtk_label_set_yalign(GTK_LABEL(beval->balloonLabel), 0.5); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1086 # elif GTK_CHECK_VERSION(3,14,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1087 GValue align_val = G_VALUE_INIT; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1088 g_value_init(&align_val, G_TYPE_FLOAT); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1089 g_value_set_float(&align_val, 0.5); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1090 g_object_set_property(G_OBJECT(beval->balloonLabel), "xalign", &align_val); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1091 g_object_set_property(G_OBJECT(beval->balloonLabel), "yalign", &align_val); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1092 g_value_unset(&align_val); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1093 # else |
7 | 1094 gtk_misc_set_alignment(GTK_MISC(beval->balloonLabel), 0.5f, 0.5f); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
7821
diff
changeset
|
1095 # endif |
7 | 1096 gtk_widget_set_name(beval->balloonLabel, "vim-balloon-label"); |
1097 gtk_widget_show(beval->balloonLabel); | |
1098 | |
1099 gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel); | |
1100 } | |
1101 | |
1102 #else /* !FEAT_GUI_GTK */ | |
1103 | |
1104 /* | |
1105 * Draw a balloon. | |
1106 */ | |
1107 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1108 drawBalloon(BalloonEval *beval) |
7 | 1109 { |
1110 Dimension w; | |
1111 Dimension h; | |
1112 Position tx; | |
1113 Position ty; | |
1114 | |
1115 if (beval->msg != NULL) | |
1116 { | |
1117 /* Show the Balloon */ | |
1118 | |
1119 /* Calculate the label's width and height */ | |
1120 #ifdef FEAT_GUI_MOTIF | |
1121 XmString s; | |
1122 | |
1123 /* For the callback function we parse NL characters to create a | |
1124 * multi-line label. This doesn't work for all languages, but | |
1125 * XmStringCreateLocalized() doesn't do multi-line labels... */ | |
1126 if (beval->msgCB != NULL) | |
1127 s = XmStringCreateLtoR((char *)beval->msg, XmFONTLIST_DEFAULT_TAG); | |
1128 else | |
1129 s = XmStringCreateLocalized((char *)beval->msg); | |
1130 { | |
1131 XmFontList fl; | |
1132 | |
1133 fl = gui_motif_fontset2fontlist(&gui.tooltip_fontset); | |
6003 | 1134 if (fl == NULL) |
7 | 1135 { |
6003 | 1136 XmStringFree(s); |
1137 return; | |
7 | 1138 } |
6003 | 1139 XmStringExtent(fl, s, &w, &h); |
1140 XmFontListFree(fl); | |
7 | 1141 } |
1142 w += gui.border_offset << 1; | |
1143 h += gui.border_offset << 1; | |
1144 XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL); | |
1145 XmStringFree(s); | |
1146 #else /* Athena */ | |
1147 /* Assume XtNinternational == True */ | |
1148 XFontSet fset; | |
1149 XFontSetExtents *ext; | |
1150 | |
1151 XtVaGetValues(beval->balloonLabel, XtNfontSet, &fset, NULL); | |
1152 ext = XExtentsOfFontSet(fset); | |
1153 h = ext->max_ink_extent.height; | |
1154 w = XmbTextEscapement(fset, | |
1155 (char *)beval->msg, | |
1156 (int)STRLEN(beval->msg)); | |
1157 w += gui.border_offset << 1; | |
1158 h += gui.border_offset << 1; | |
1159 XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL); | |
1160 #endif | |
1161 | |
1162 /* Compute position of the balloon area */ | |
1163 tx = beval->x_root + EVAL_OFFSET_X; | |
1164 ty = beval->y_root + EVAL_OFFSET_Y; | |
1165 if ((tx + w) > beval->screen_width) | |
1166 tx = beval->screen_width - w; | |
1167 if ((ty + h) > beval->screen_height) | |
1168 ty = beval->screen_height - h; | |
1169 #ifdef FEAT_GUI_MOTIF | |
1170 XtVaSetValues(beval->balloonShell, | |
1171 XmNx, tx, | |
1172 XmNy, ty, | |
1173 NULL); | |
1174 #else | |
1175 /* Athena */ | |
1176 XtVaSetValues(beval->balloonShell, | |
1177 XtNx, tx, | |
1178 XtNy, ty, | |
1179 NULL); | |
1180 #endif | |
1844 | 1181 /* Set tooltip colors */ |
1182 { | |
1183 Arg args[2]; | |
1184 | |
1185 #ifdef FEAT_GUI_MOTIF | |
1186 args[0].name = XmNbackground; | |
1187 args[0].value = gui.tooltip_bg_pixel; | |
1188 args[1].name = XmNforeground; | |
1189 args[1].value = gui.tooltip_fg_pixel; | |
1190 #else /* Athena */ | |
1191 args[0].name = XtNbackground; | |
1192 args[0].value = gui.tooltip_bg_pixel; | |
1193 args[1].name = XtNforeground; | |
1194 args[1].value = gui.tooltip_fg_pixel; | |
1195 #endif | |
1196 XtSetValues(beval->balloonLabel, &args[0], XtNumber(args)); | |
1197 } | |
7 | 1198 |
1199 XtPopup(beval->balloonShell, XtGrabNone); | |
1200 | |
1201 beval->showState = ShS_SHOWING; | |
1202 | |
1203 current_beval = beval; | |
1204 } | |
1205 } | |
1206 | |
1207 /* | |
1208 * Undraw a balloon. | |
1209 */ | |
1210 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1211 undrawBalloon(BalloonEval *beval) |
7 | 1212 { |
1213 if (beval->balloonShell != (Widget)0) | |
1214 XtPopdown(beval->balloonShell); | |
1215 beval->showState = ShS_NEUTRAL; | |
1216 | |
1217 current_beval = NULL; | |
1218 } | |
1219 | |
1220 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1221 cancelBalloon(BalloonEval *beval) |
7 | 1222 { |
1223 if (beval->showState == ShS_SHOWING | |
1224 || beval->showState == ShS_UPDATE_PENDING) | |
1225 undrawBalloon(beval); | |
1226 | |
1227 if (beval->timerID != (XtIntervalId)NULL) | |
1228 { | |
1229 XtRemoveTimeOut(beval->timerID); | |
1230 beval->timerID = (XtIntervalId)NULL; | |
1231 } | |
1232 beval->showState = ShS_NEUTRAL; | |
1233 } | |
1234 | |
1235 | |
1236 static void | |
7821
81794242a275
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1237 createBalloonEvalWindow(BalloonEval *beval) |
7 | 1238 { |
1239 Arg args[12]; | |
1240 int n; | |
1241 | |
1242 n = 0; | |
1243 #ifdef FEAT_GUI_MOTIF | |
1244 XtSetArg(args[n], XmNallowShellResize, True); n++; | |
1245 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", | |
1246 overrideShellWidgetClass, gui.dpy, args, n); | |
1247 #else | |
1248 /* Athena */ | |
1249 XtSetArg(args[n], XtNallowShellResize, True); n++; | |
1250 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", | |
1251 overrideShellWidgetClass, gui.dpy, args, n); | |
1252 #endif | |
1253 | |
1254 n = 0; | |
1255 #ifdef FEAT_GUI_MOTIF | |
1256 { | |
1257 XmFontList fl; | |
1258 | |
1259 fl = gui_motif_fontset2fontlist(&gui.tooltip_fontset); | |
1260 XtSetArg(args[n], XmNforeground, gui.tooltip_fg_pixel); n++; | |
1261 XtSetArg(args[n], XmNbackground, gui.tooltip_bg_pixel); n++; | |
1262 XtSetArg(args[n], XmNfontList, fl); n++; | |
1263 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; | |
1264 beval->balloonLabel = XtCreateManagedWidget("balloonLabel", | |
1265 xmLabelWidgetClass, beval->balloonShell, args, n); | |
1266 } | |
1267 #else /* FEAT_GUI_ATHENA */ | |
1268 XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++; | |
1269 XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++; | |
1270 XtSetArg(args[n], XtNinternational, True); n++; | |
1271 XtSetArg(args[n], XtNfontSet, gui.tooltip_fontset); n++; | |
1272 beval->balloonLabel = XtCreateManagedWidget("balloonLabel", | |
1273 labelWidgetClass, beval->balloonShell, args, n); | |
1274 #endif | |
1275 } | |
1276 | |
1277 #endif /* !FEAT_GUI_GTK */ | |
1278 #endif /* !FEAT_GUI_W32 */ | |
1279 | |
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
|
1280 #endif /* FEAT_BEVAL_GUI */ |