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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * Visual Workshop integration by Gordon Prieur
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
14
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
15 /* on Win32 only get_beval_info() is required */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #if !defined(FEAT_GUI_W32) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 # include <gtk/gtk.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 # include <X11/keysym.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 # ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 # include <Xm/PushB.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 # include <Xm/Separator.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 # include <Xm/List.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 # include <Xm/Label.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # include <Xm/AtomMgr.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 # include <Xm/Protocols.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 /* Assume Athena */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 # include <X11/Shell.h>
680
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
37 # ifdef FEAT_GUI_NEXTAW
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
38 # include <X11/neXtaw/Label.h>
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
39 # else
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
40 # include <X11/Xaw/Label.h>
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
41 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 #ifndef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 extern Widget vimShell;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 * Currently, we assume that there can be only one BalloonEval showing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 * on-screen at any given moment. This variable will hold the currently
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 * showing BalloonEval or NULL if none is showing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 static BalloonEval *current_beval = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 * Create a balloon-evaluation area for a Widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 * There can be either a "mesg" for a fixed string or "mesgCB" to generate a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 * message by calling this callback function.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 * When "mesg" is not NULL it must remain valid for as long as the balloon is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 * used. It is not freed here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 * Returns a pointer to the resulting object (NULL when out of memory).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 #ifndef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 char *display_name; /* get from gui.dpy */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 int screen_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 BalloonEval *beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 if (mesg != NULL && mesgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 beval = (BalloonEval *)alloc(sizeof(BalloonEval));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 if (beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 #ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 beval->target = GTK_WIDGET(target);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 beval->balloonShell = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 beval->timerID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 beval->target = (Widget)target;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 beval->balloonShell = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 beval->timerID = (XtIntervalId)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 beval->appContext = XtWidgetToApplicationContext((Widget)target);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 beval->x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 beval->y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 beval->msg = mesg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 beval->msgCB = mesgCB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 beval->clientData = clientData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 * Set up event handler which will keep its eyes on the pointer,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 * and when the pointer rests in a certain spot for a given time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 * interval, show the beval.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 addEventHandler(beval->target, beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 createBalloonEvalWindow(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 #ifndef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 * Now create and save the screen width and height. Used in drawing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 display_name = DisplayString(gui.dpy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 p = strrchr(display_name, '.');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 screen_num = atoi(++p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 screen_num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 beval->screen_width = DisplayWidth(gui.dpy, screen_num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 beval->screen_height = DisplayHeight(gui.dpy, screen_num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 return beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 #if defined(FEAT_BEVAL_TIP) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 /*
1228
5eb1ac6f92ad updated for version 7.1b
vimboss
parents: 944
diff changeset
162 * Destroy a balloon-eval and free its associated memory.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 removeEventHandler(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 /* Children will automatically be destroyed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 # ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 gtk_widget_destroy(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 XtDestroyWidget(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 vim_free(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 if (beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 addEventHandler(beval->target, beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 if (beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 removeEventHandler(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 #if defined(FEAT_BEVAL_TIP) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 * This function returns the BalloonEval * associated with the currently
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 * displayed tooltip. Returns NULL if there is no tooltip currently showing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 * Assumption: Only one tooltip can be shown at a time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 return current_beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 #endif /* !FEAT_GUI_W32 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
208 #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
209 || defined(FEAT_EVAL) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 # if !defined(FEAT_GUI_W32) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 * Show a balloon with "mesg".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 beval->msg = mesg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 if (mesg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 drawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 undrawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 #endif /* FEAT_SUN_WORKSHOP || FEAT_NETBEANS_INTG || PROTO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 #if !defined(FEAT_GUI_W32) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 #if defined(FEAT_BEVAL_TIP) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 * Hide the given balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 undrawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 #ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 addEventHandler(GtkWidget *target, BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 * Connect to the generic "event" signal instead of the individual
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 * signals for each event type, because the former is emitted earlier.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 * This allows us to catch events independently of the signal handlers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 * in gui_gtk_x11.c.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 /* Should use GTK_OBJECT() here, but that causes a lint warning... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 gtk_signal_connect((GtkObject*)(target), "event",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 GTK_SIGNAL_FUNC(target_event_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
258 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 * Nasty: Key press events go to the main window thus the drawing area
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 * will never see them. This means we have to connect to the main window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 * as well in order to catch those events.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 if (gtk_socket_id == 0 && gui.mainwin != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 && gtk_widget_is_ancestor(target, gui.mainwin))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 gtk_signal_connect((GtkObject*)(gui.mainwin), "event",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 GTK_SIGNAL_FUNC(mainwin_event_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
275 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 removeEventHandler(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 {
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 7
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 gtk_signal_disconnect_by_func((GtkObject*)(beval->target),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 GTK_SIGNAL_FUNC(target_event_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
291 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 if (gtk_socket_id == 0 && gui.mainwin != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 && gtk_widget_is_ancestor(beval->target, gui.mainwin))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 {
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 7
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 gtk_signal_disconnect_by_func((GtkObject*)(gui.mainwin),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 GTK_SIGNAL_FUNC(mainwin_event_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
305 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 static gint
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 target_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 BalloonEval *beval = (BalloonEval *)data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 switch (event->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 case GDK_ENTER_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 pointer_event(beval, (int)event->crossing.x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 (int)event->crossing.y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 event->crossing.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 case GDK_MOTION_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 if (event->motion.is_hint)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 GdkModifierType state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 * GDK_POINTER_MOTION_HINT_MASK is set, thus we cannot obtain
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 * the coordinates from the GdkEventMotion struct directly.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 pointer_event(beval, x, y, (unsigned int)state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 pointer_event(beval, (int)event->motion.x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 (int)event->motion.y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 event->motion.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 case GDK_LEAVE_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 * Ignore LeaveNotify events that are not "normal".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 * Apparently we also get it when somebody else grabs focus.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 if (event->crossing.mode == GDK_CROSSING_NORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 case GDK_BUTTON_PRESS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 case GDK_SCROLL:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 case GDK_KEY_PRESS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 key_event(beval, event->key.keyval, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 case GDK_KEY_RELEASE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 key_event(beval, event->key.keyval, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 return FALSE; /* continue emission */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 static gint
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1844
diff changeset
382 mainwin_event_cb(GtkWidget *widget UNUSED, GdkEvent *event, gpointer data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 BalloonEval *beval = (BalloonEval *)data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 switch (event->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 case GDK_KEY_PRESS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 key_event(beval, event->key.keyval, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 case GDK_KEY_RELEASE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 key_event(beval, event->key.keyval, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 return FALSE; /* continue emission */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 pointer_event(BalloonEval *beval, int x, int y, unsigned state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 int distance;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 distance = ABS(x - beval->x) + ABS(y - beval->y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 if (distance > 4)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 * Moved out of the balloon location: cancel it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 * Remember button state
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 beval->state = state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 /* Mouse buttons are pressed - no balloon now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 if (!(state & ((int)GDK_BUTTON1_MASK | (int)GDK_BUTTON2_MASK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 | (int)GDK_BUTTON3_MASK)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 beval->x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 beval->y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 if (state & (int)GDK_MOD1_MASK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 * Alt is pressed -- enter super-evaluate-mode,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 * where there is no time delay
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 if (beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 beval->showState = ShS_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 (*beval->msgCB)(beval, state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 beval->timerID = gtk_timeout_add((guint32)p_bdlay,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 key_event(BalloonEval *beval, unsigned keyval, int is_keypress)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 switch (keyval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 case GDK_Shift_L:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 case GDK_Shift_R:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 (*beval->msgCB)(beval, (is_keypress)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 ? (int)GDK_SHIFT_MASK : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 case GDK_Control_L:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 case GDK_Control_R:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 (*beval->msgCB)(beval, (is_keypress)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 ? (int)GDK_CONTROL_MASK : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 default:
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 640
diff changeset
470 /* Don't do this for key release, we apparently get these with
9090f866cd57 updated for version 7.0197
vimboss
parents: 640
diff changeset
471 * focus changes in some GTK version. */
9090f866cd57 updated for version 7.0197
vimboss
parents: 640
diff changeset
472 if (is_keypress)
9090f866cd57 updated for version 7.0197
vimboss
parents: 640
diff changeset
473 cancelBalloon(beval);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 timeout_cb(gpointer data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 BalloonEval *beval = (BalloonEval *)data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 beval->timerID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 * If the timer event happens then the mouse has stopped long enough for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 * a request to be started. The request will only send to the debugger if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 * there the mouse is pointing at real data.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 requestBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 return FALSE; /* don't call me again */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 static gint
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1844
diff changeset
533 balloon_expose_event_cb(GtkWidget *widget,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1844
diff changeset
534 GdkEventExpose *event,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1844
diff changeset
535 gpointer data UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 gtk_paint_flat_box(widget->style, widget->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 GTK_STATE_NORMAL, GTK_SHADOW_OUT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 &event->area, widget, "tooltip",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 0, 0, -1, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 return FALSE; /* continue emission */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 #else /* !FEAT_GUI_GTK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 XtAddEventHandler(target,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 PointerMotionMask | EnterWindowMask |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 LeaveWindowMask | ButtonPressMask | KeyPressMask |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 KeyReleaseMask,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 False,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 pointerEventEH, (XtPointer)beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 XtRemoveEventHandler(beval->target,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 PointerMotionMask | EnterWindowMask |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 LeaveWindowMask | ButtonPressMask | KeyPressMask |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 KeyReleaseMask,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 False,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 pointerEventEH, (XtPointer)beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 * The X event handler. All it does is call the real event handler.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 BalloonEval *beval = (BalloonEval *)client_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 pointerEvent(beval, event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 * The real event handler. Called by pointerEventEH() whenever an event we are
1228
5eb1ac6f92ad updated for version 7.1b
vimboss
parents: 944
diff changeset
588 * interested in occurs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 {
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3877
diff changeset
594 Position distance; /* a measure of how much the pointer moved */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 Position delta; /* used to compute distance */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 switch (event->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 case EnterNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 case MotionNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 delta = event->xmotion.x - beval->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 if (delta < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 delta = -delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 distance = delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 delta = event->xmotion.y - beval->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 if (delta < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 delta = -delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 distance += delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 if (distance > 4)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 * Moved out of the balloon location: cancel it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 * Remember button state
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 beval->state = event->xmotion.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 if (beval->state & (Button1Mask|Button2Mask|Button3Mask))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 /* Mouse buttons are pressed - no balloon now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 else if (beval->state & (Mod1Mask|Mod2Mask|Mod3Mask))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 * Alt is pressed -- enter super-evaluate-mode,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 * where there is no time delay
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 beval->x = event->xmotion.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 beval->y = event->xmotion.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 beval->x_root = event->xmotion.x_root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 beval->y_root = event->xmotion.y_root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 if (beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 beval->showState = ShS_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 (*beval->msgCB)(beval, beval->state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 beval->x = event->xmotion.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 beval->y = event->xmotion.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 beval->x_root = event->xmotion.x_root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 beval->y_root = event->xmotion.y_root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 beval->timerID = XtAppAddTimeOut( beval->appContext,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 (long_u)p_bdlay, timerRoutine, beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 * Motif and Athena version: Keystrokes will be caught by the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 * "textArea" widget, and handled in gui_x11_key_hit_cb().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 case KeyPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 Modifiers modifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 KeySym keysym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 XtTranslateKeycode(gui.dpy,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 event->xkey.keycode, event->xkey.state,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 &modifier, &keysym);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 if (keysym == XK_Shift_L || keysym == XK_Shift_R)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 (*beval->msgCB)(beval, ShiftMask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 else if (keysym == XK_Control_L || keysym == XK_Control_R)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 (*beval->msgCB)(beval, ControlMask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 case KeyRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 Modifiers modifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 KeySym keysym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 XtTranslateKeycode(gui.dpy, event->xkey.keycode,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 event->xkey.state, &modifier, &keysym);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 (*beval->msgCB)(beval, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 else if ((keysym == XK_Control_L) || (keysym == XK_Control_R))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 (*beval->msgCB)(beval, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 case LeaveNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 /* Ignore LeaveNotify events that are not "normal".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 * Apparently we also get it when somebody else grabs focus.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 * Happens for me every two seconds (some clipboard tool?) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 if (event->xcrossing.mode == NotifyNormal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 case ButtonPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 BalloonEval *beval = (BalloonEval *)dx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 beval->timerID = (XtIntervalId)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 * If the timer event happens then the mouse has stopped long enough for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 * a request to be started. The request will only send to the debugger if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 * there the mouse is pointing at real data.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 requestBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 #endif /* !FEAT_GUI_GTK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 if (beval->showState != ShS_PENDING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 /* Determine the beval to display */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 if (beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 beval->showState = ShS_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 (*beval->msgCB)(beval, beval->state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 else if (beval->msg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 drawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 #ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 * Convert the string to UTF-8 if 'encoding' is not "utf-8".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 * Replace any non-printable characters and invalid bytes sequences with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 * "^X" or "<xx>" escapes, and apply SpecialKey highlighting to them.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 * TAB and NL are passed through unscathed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 || (c) == DEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 static void
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
765 set_printable_label_text(GtkLabel *label, char_u *text)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 char_u *convbuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 char_u *pdest;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 unsigned int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 int charlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 int uc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 PangoAttrList *attr_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 /* Convert to UTF-8 if it isn't already */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
779 convbuf = string_convert(&output_conv, text, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 if (convbuf != NULL)
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
781 text = convbuf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 /* First let's see how much we need to allocate */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 len = 0;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
786 for (p = text; *p != NUL; p += charlen)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 if ((*p & 0x80) == 0) /* be quick for ASCII */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 charlen = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 len += IS_NONPRINTABLE(*p) ? 2 : 1; /* nonprintable: ^X */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 {
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 192
diff changeset
795 charlen = utf_ptr2len(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 uc = utf_ptr2char(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 if (charlen != utf_char2len(uc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 charlen = 1; /* reject overlong sequences */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 if (charlen == 1 || uc < 0xa0) /* illegal byte or */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 len += 4; /* control char: <xx> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 else if (!utf_printable(uc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 /* Note: we assume here that utf_printable() doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 * care about characters outside the BMP. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 len += 6; /* nonprintable: <xxxx> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 len += charlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 attr_list = pango_attr_list_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 buf = alloc(len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 /* Now go for the real work */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 attrentry_T *aep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 PangoAttribute *attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 pdest = buf;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
847 p = text;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 while (*p != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 /* Be quick for ASCII */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 if ((*p & 0x80) == 0 && !IS_NONPRINTABLE(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 *pdest++ = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 {
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 192
diff changeset
857 charlen = utf_ptr2len(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 uc = utf_ptr2char(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 if (charlen != utf_char2len(uc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 charlen = 1; /* reject overlong sequences */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 if (charlen == 1 || uc < 0xa0 || !utf_printable(uc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 int outlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 /* Careful: we can't just use transchar_byte() here,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 * since 'encoding' is not necessarily set to "utf-8". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 if (*p & 0x80 && charlen == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 transchar_hex(pdest, *p); /* <xx> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 outlen = 4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 else if (uc >= 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 /* Note: we assume here that utf_printable() doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 * care about characters outside the BMP. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 transchar_hex(pdest, uc); /* <xx> or <xxxx> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 outlen = (uc < 0x100) ? 4 : 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 transchar_nonprint(pdest, *p); /* ^X */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 outlen = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 if (pixel != INVALCOLOR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 attr = pango_attr_foreground_new(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 attr->start_index = pdest - buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 attr->end_index = pdest - buf + outlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 pdest += outlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 p += charlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 *pdest++ = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 while (--charlen != 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 *pdest = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 vim_free(convbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 gtk_label_set_text(label, (const char *)buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 gtk_label_set_attributes(label, attr_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 pango_attr_list_unref(attr_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 * Draw a balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 drawBalloon(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 if (beval->msg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 GtkRequisition requisition;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 int screen_w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 int screen_h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 int x_offset = EVAL_OFFSET_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 int y_offset = EVAL_OFFSET_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 GdkScreen *screen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 screen = gtk_widget_get_screen(beval->target);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 gtk_widget_ensure_style(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 set_printable_label_text(GTK_LABEL(beval->balloonLabel), beval->msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 * Dirty trick: Enable wrapping mode on the label's layout behind its
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 * back. This way GtkLabel won't try to constrain the wrap width to a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 * builtin maximum value of about 65 Latin characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 pango_layout_set_width(layout,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 /* try to come up with some reasonable width */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 screen_w / 2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 MAX(20, screen_w - 20)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 x += beval->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 y += beval->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 /* Get out of the way of the mouse pointer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 if (x + x_offset + requisition.width > screen_w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 y_offset += 15;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 if (y + y_offset + requisition.height > screen_h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 y_offset = -requisition.height - EVAL_OFFSET_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 /* Sanitize values */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 x = CLAMP(x + x_offset, 0, MAX(0, screen_w - requisition.width));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 y = CLAMP(y + y_offset, 0, MAX(0, screen_h - requisition.height));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 gtk_widget_show(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 beval->showState = ShS_SHOWING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 * Undraw a balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 undrawBalloon(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 if (beval->balloonShell != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 gtk_widget_hide(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 cancelBalloon(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 if (beval->showState == ShS_SHOWING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 || beval->showState == ShS_UPDATE_PENDING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 undrawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 if (beval->timerID != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 beval->timerID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 createBalloonEvalWindow(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 beval->balloonShell = gtk_window_new(GTK_WINDOW_POPUP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 gtk_signal_connect((GtkObject*)(beval->balloonShell), "expose_event",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 beval->balloonLabel = gtk_label_new(NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 gtk_label_set_line_wrap(GTK_LABEL(beval->balloonLabel), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 gtk_widget_set_name(beval->balloonLabel, "vim-balloon-label");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 gtk_widget_show(beval->balloonLabel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 #else /* !FEAT_GUI_GTK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 * Draw a balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 Dimension w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 Dimension h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 Position tx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 Position ty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 if (beval->msg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 /* Show the Balloon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 /* Calculate the label's width and height */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 XmString s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 /* For the callback function we parse NL characters to create a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 * multi-line label. This doesn't work for all languages, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 * XmStringCreateLocalized() doesn't do multi-line labels... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 if (beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 s = XmStringCreateLtoR((char *)beval->msg, XmFONTLIST_DEFAULT_TAG);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 s = XmStringCreateLocalized((char *)beval->msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 XmFontList fl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 fl = gui_motif_fontset2fontlist(&gui.tooltip_fontset);
6003
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1134 if (fl == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 {
6003
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1136 XmStringFree(s);
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1137 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 }
6003
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1139 XmStringExtent(fl, s, &w, &h);
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1140 XmFontListFree(fl);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 w += gui.border_offset << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 h += gui.border_offset << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 XmStringFree(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 #else /* Athena */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 /* Assume XtNinternational == True */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 XFontSet fset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 XFontSetExtents *ext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 XtVaGetValues(beval->balloonLabel, XtNfontSet, &fset, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 ext = XExtentsOfFontSet(fset);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 h = ext->max_ink_extent.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 w = XmbTextEscapement(fset,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 (char *)beval->msg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 (int)STRLEN(beval->msg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 w += gui.border_offset << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 h += gui.border_offset << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 /* Compute position of the balloon area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 tx = beval->x_root + EVAL_OFFSET_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 ty = beval->y_root + EVAL_OFFSET_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 if ((tx + w) > beval->screen_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 tx = beval->screen_width - w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 if ((ty + h) > beval->screen_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 ty = beval->screen_height - h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 XtVaSetValues(beval->balloonShell,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 XmNx, tx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 XmNy, ty,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 /* Athena */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 XtVaSetValues(beval->balloonShell,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 XtNx, tx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 XtNy, ty,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 #endif
1844
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1181 /* Set tooltip colors */
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1182 {
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1183 Arg args[2];
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1184
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1185 #ifdef FEAT_GUI_MOTIF
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1186 args[0].name = XmNbackground;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1187 args[0].value = gui.tooltip_bg_pixel;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1188 args[1].name = XmNforeground;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1189 args[1].value = gui.tooltip_fg_pixel;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1190 #else /* Athena */
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1191 args[0].name = XtNbackground;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1192 args[0].value = gui.tooltip_bg_pixel;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1193 args[1].name = XtNforeground;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1194 args[1].value = gui.tooltip_fg_pixel;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1195 #endif
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1196 XtSetValues(beval->balloonLabel, &args[0], XtNumber(args));
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1197 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 XtPopup(beval->balloonShell, XtGrabNone);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 beval->showState = ShS_SHOWING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 current_beval = beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 * Undraw a balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 if (beval->balloonShell != (Widget)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 XtPopdown(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 current_beval = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 if (beval->showState == ShS_SHOWING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 || beval->showState == ShS_UPDATE_PENDING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 undrawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 if (beval->timerID != (XtIntervalId)NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 XtRemoveTimeOut(beval->timerID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 beval->timerID = (XtIntervalId)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 Arg args[12];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 XtSetArg(args[n], XmNallowShellResize, True); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 overrideShellWidgetClass, gui.dpy, args, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 /* Athena */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 XtSetArg(args[n], XtNallowShellResize, True); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 overrideShellWidgetClass, gui.dpy, args, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 XmFontList fl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 fl = gui_motif_fontset2fontlist(&gui.tooltip_fontset);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 XtSetArg(args[n], XmNforeground, gui.tooltip_fg_pixel); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 XtSetArg(args[n], XmNbackground, gui.tooltip_bg_pixel); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 XtSetArg(args[n], XmNfontList, fl); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 beval->balloonLabel = XtCreateManagedWidget("balloonLabel",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 xmLabelWidgetClass, beval->balloonShell, args, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 #else /* FEAT_GUI_ATHENA */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 XtSetArg(args[n], XtNinternational, True); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 XtSetArg(args[n], XtNfontSet, gui.tooltip_fontset); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 beval->balloonLabel = XtCreateManagedWidget("balloonLabel",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 labelWidgetClass, beval->balloonShell, args, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 #endif /* !FEAT_GUI_GTK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 #endif /* !FEAT_GUI_W32 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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 */