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