annotate src/gui_beval.c @ 8579:556817999955 v7.4.1579

commit https://github.com/vim/vim/commit/a3dc5e92dcb79bdc4f0103e6eb91de4c7a6ee9a7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 15 23:19:14 2016 +0100 patch 7.4.1579 Problem: Missing changes in channel.c Solution: Include the changes.
author Christian Brabandt <cb@256bit.org>
date Tue, 15 Mar 2016 23:30:06 +0100
parents 3456e2ebebd4
children fc69eed19ba7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 #if defined(FEAT_BEVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
15 /*
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
16 * Common code, invoked when the mouse is resting for a moment.
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
17 */
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
18 void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
19 general_beval_cb(BalloonEval *beval, int state UNUSED)
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
20 {
2251
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 1887
diff changeset
21 #ifdef FEAT_EVAL
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
22 win_T *wp;
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
23 int col;
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 474
diff changeset
24 int use_sandbox;
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
25 linenr_T lnum;
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
26 char_u *text;
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
27 static char_u *result = NULL;
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
28 long winnr = 0;
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
29 char_u *bexpr;
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
30 buf_T *save_curbuf;
6297
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
31 size_t len;
2251
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 1887
diff changeset
32 # ifdef FEAT_WINDOWS
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
33 win_T *cw;
2251
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 1887
diff changeset
34 # endif
640
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 634
diff changeset
35 #endif
865
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
36 static int recursive = FALSE;
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
37
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
38 /* Don't do anything when 'ballooneval' is off, messages scrolled the
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
39 * windows up or we have no beval area. */
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
40 if (!p_beval || balloonEval == NULL || msg_scrolled > 0)
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
41 return;
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
42
865
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
43 /* Don't do this recursively. Happens when the expression evaluation
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
44 * takes a long time and invokes something that checks for CTRL-C typed. */
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
45 if (recursive)
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
46 return;
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
47 recursive = TRUE;
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
48
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
49 #ifdef FEAT_EVAL
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
50 if (get_beval_info(balloonEval, TRUE, &wp, &lnum, &text, &col) == OK)
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
51 {
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
52 bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
53 : wp->w_buffer->b_p_bexpr;
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
54 if (*bexpr != NUL)
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
55 {
640
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 634
diff changeset
56 # ifdef FEAT_WINDOWS
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
57 /* Convert window pointer to number. */
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
58 for (cw = firstwin; cw != wp; cw = cw->w_next)
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
59 ++winnr;
640
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 634
diff changeset
60 # endif
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
61
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
62 set_vim_var_nr(VV_BEVAL_BUFNR, (long)wp->w_buffer->b_fnum);
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
63 set_vim_var_nr(VV_BEVAL_WINNR, winnr);
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
64 set_vim_var_nr(VV_BEVAL_LNUM, (long)lnum);
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
65 set_vim_var_nr(VV_BEVAL_COL, (long)(col + 1));
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
66 set_vim_var_string(VV_BEVAL_TEXT, text, -1);
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
67 vim_free(text);
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 474
diff changeset
68
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
69 /*
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
70 * Temporarily change the curbuf, so that we can determine whether
1228
5eb1ac6f92ad updated for version 7.1b
vimboss
parents: 944
diff changeset
71 * the buffer-local balloonexpr option was set insecurely.
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
72 */
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
73 save_curbuf = curbuf;
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
74 curbuf = wp->w_buffer;
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
75 use_sandbox = was_set_insecurely((char_u *)"balloonexpr",
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
76 *curbuf->b_p_bexpr == NUL ? 0 : OPT_LOCAL);
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
77 curbuf = save_curbuf;
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
78 if (use_sandbox)
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
79 ++sandbox;
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
80 ++textlock;
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 474
diff changeset
81
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
82 vim_free(result);
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
83 result = eval_to_string(bexpr, NULL, TRUE);
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
84
6297
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
85 /* Remove one trailing newline, it is added when the result was a
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
86 * list and it's hardly every useful. If the user really wants a
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
87 * trailing newline he can add two and one remains. */
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
88 if (result != NULL)
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
89 {
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
90 len = STRLEN(result);
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
91 if (len > 0 && result[len - 1] == NL)
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
92 result[len - 1] = NUL;
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
93 }
488bb7c4ace0 updated for version 7.4.482
Bram Moolenaar <bram@vim.org>
parents: 6003
diff changeset
94
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
95 if (use_sandbox)
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
96 --sandbox;
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
97 --textlock;
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
98
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
99 set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
100 if (result != NULL && result[0] != NUL)
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
101 {
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
102 gui_mch_post_balloon(beval, result);
865
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
103 recursive = FALSE;
791
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
104 return;
98a88a884610 updated for version 7.0230
vimboss
parents: 714
diff changeset
105 }
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
106 }
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
107 }
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
108 #endif
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
109 #ifdef FEAT_NETBEANS_INTG
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
110 if (bevalServers & BEVAL_NETBEANS)
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
111 netbeans_beval_cb(beval, state);
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
112 #endif
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
113 #ifdef FEAT_SUN_WORKSHOP
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
114 if (bevalServers & BEVAL_WORKSHOP)
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
115 workshop_beval_cb(beval, state);
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
116 #endif
865
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
117
f41fa84cd738 updated for version 7.0g03
vimboss
parents: 791
diff changeset
118 recursive = FALSE;
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
119 }
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
120
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
121 /* on Win32 only get_beval_info() is required */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 #if !defined(FEAT_GUI_W32) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 #ifdef FEAT_GUI_GTK
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
125 # 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
126 # include <gdk/gdkkeysyms-compat.h>
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
127 # else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
128 # include <gdk/gdkkeysyms.h>
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
129 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 # include <gtk/gtk.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 # include <X11/keysym.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 # ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 # include <Xm/PushB.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 # include <Xm/Separator.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 # include <Xm/List.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 # include <Xm/Label.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 # include <Xm/AtomMgr.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 # include <Xm/Protocols.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 /* Assume Athena */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 # include <X11/Shell.h>
680
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
143 # ifdef FEAT_GUI_NEXTAW
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
144 # include <X11/neXtaw/Label.h>
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
145 # else
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
146 # include <X11/Xaw/Label.h>
5b101ff9d4c4 updated for version 7.0203
vimboss
parents: 667
diff changeset
147 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 #include "gui_beval.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 #ifndef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 extern Widget vimShell;
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 * Currently, we assume that there can be only one BalloonEval showing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 * on-screen at any given moment. This variable will hold the currently
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 * showing BalloonEval or NULL if none is showing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 static BalloonEval *current_beval = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 #ifdef FEAT_GUI_GTK
7801
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
165 static void addEventHandler(GtkWidget *, BalloonEval *);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
166 static void removeEventHandler(BalloonEval *);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
167 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
168 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
169 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
170 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
171 # 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
172 static gboolean timeout_cb(gpointer);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
173 # else
7801
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
174 static gint timeout_cb(gpointer);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
175 # endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
176 # 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
177 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
178 # else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
179 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
180 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 #else
7801
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
182 static void addEventHandler(Widget, BalloonEval *);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
183 static void removeEventHandler(BalloonEval *);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
184 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
185 static void pointerEvent(BalloonEval *, XEvent *);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
186 static void timerRoutine(XtPointer, XtIntervalId *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 #endif
7801
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
188 static void cancelBalloon(BalloonEval *);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
189 static void requestBalloon(BalloonEval *);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
190 static void drawBalloon(BalloonEval *);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
191 static void undrawBalloon(BalloonEval *beval);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 6297
diff changeset
192 static void createBalloonEvalWindow(BalloonEval *);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 * Create a balloon-evaluation area for a Widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 * 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
199 * message by calling this callback function.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 * 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
201 * used. It is not freed here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 * Returns a pointer to the resulting object (NULL when out of memory).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 BalloonEval *
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
205 gui_mch_create_beval_area(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
206 void *target,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
207 char_u *mesg,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
208 void (*mesgCB)(BalloonEval *, int),
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
209 void *clientData)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 #ifndef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 char *display_name; /* get from gui.dpy */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 int screen_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 BalloonEval *beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 if (mesg != NULL && mesgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 EMSG(_("E232: Cannot create BalloonEval with both message and callback"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 beval = (BalloonEval *)alloc(sizeof(BalloonEval));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 if (beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 #ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 beval->target = GTK_WIDGET(target);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 beval->balloonShell = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 beval->timerID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 beval->target = (Widget)target;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 beval->balloonShell = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 beval->timerID = (XtIntervalId)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 beval->appContext = XtWidgetToApplicationContext((Widget)target);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 beval->x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 beval->y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 beval->msg = mesg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 beval->msgCB = mesgCB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 beval->clientData = clientData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 * Set up event handler which will keep its eyes on the pointer,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 * and when the pointer rests in a certain spot for a given time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 * interval, show the beval.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 addEventHandler(beval->target, beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 createBalloonEvalWindow(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 #ifndef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 * Now create and save the screen width and height. Used in drawing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 display_name = DisplayString(gui.dpy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 p = strrchr(display_name, '.');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 screen_num = atoi(++p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 screen_num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 beval->screen_width = DisplayWidth(gui.dpy, screen_num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 beval->screen_height = DisplayHeight(gui.dpy, screen_num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 return beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 #if defined(FEAT_BEVAL_TIP) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 /*
1228
5eb1ac6f92ad updated for version 7.1b
vimboss
parents: 944
diff changeset
272 * Destroy a balloon-eval and free its associated memory.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
275 gui_mch_destroy_beval_area(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 removeEventHandler(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 /* Children will automatically be destroyed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 # ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 gtk_widget_destroy(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 XtDestroyWidget(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 vim_free(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
290 gui_mch_enable_beval_area(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 if (beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 addEventHandler(beval->target, beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
297 gui_mch_disable_beval_area(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 if (beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 removeEventHandler(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 #if defined(FEAT_BEVAL_TIP) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 * This function returns the BalloonEval * associated with the currently
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 * displayed tooltip. Returns NULL if there is no tooltip currently showing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 * Assumption: Only one tooltip can be shown at a time.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 BalloonEval *
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
311 gui_mch_currently_showing_beval(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 return current_beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 #endif /* !FEAT_GUI_W32 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
318 #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
319 || defined(FEAT_EVAL) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 * Get the text and position to be evaluated for "beval".
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
322 * If "getword" is true the returned text is not the whole line but the
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
323 * relevant word in allocated memory.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 * Returns OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 int
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
327 get_beval_info(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
328 BalloonEval *beval,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
329 int getword,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
330 win_T **winp,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
331 linenr_T *lnump,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
332 char_u **textp,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
333 int *colp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 int row, col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 char_u *lbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
340 *textp = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 row = Y_2_ROW(beval->y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 col = X_2_COL(beval->x);
640
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 634
diff changeset
343 #ifdef FEAT_WINDOWS
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 wp = mouse_find_win(&row, &col);
640
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 634
diff changeset
345 #else
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 634
diff changeset
346 wp = firstwin;
8a5a95f7ef2a updated for version 7.0185
vimboss
parents: 634
diff changeset
347 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 if (wp != NULL && row < wp->w_height && col < W_WIDTH(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 /* Found a window and the cursor is in the text. Now find the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 * number. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 if (!mouse_comp_pos(wp, &row, &col, &lnum))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 /* Not past end of the file. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 lbuf = ml_get_buf(wp->w_buffer, lnum, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 if (col <= win_linetabsize(wp, lbuf, (colnr_T)MAXCOL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 /* Not past end of line. */
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
359 if (getword)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 /* For Netbeans we get the relevant part of the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 * instead of the whole line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 pos_T *spos = NULL, *epos = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 if (VIsual_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 if (lt(VIsual, curwin->w_cursor))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 spos = &VIsual;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 epos = &curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 spos = &curwin->w_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 epos = &VIsual;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379
3877
cd6c420e31d6 updated for version 7.3.695
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
380 col = vcol2col(wp, lnum, col);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 if (VIsual_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 && wp->w_buffer == curwin->w_buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 && (lnum == spos->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 ? col >= (int)spos->col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 : lnum > spos->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 && (lnum == epos->lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 ? col <= (int)epos->col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 : lnum < epos->lnum))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 /* Visual mode and pointing to the line with the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 * Visual selection: return selected text, with a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 * maximum of one line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 if (spos->lnum != epos->lnum || spos->col == epos->col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 lbuf = ml_get_buf(curwin->w_buffer, VIsual.lnum, FALSE);
3877
cd6c420e31d6 updated for version 7.3.695
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
398 len = epos->col - spos->col;
cd6c420e31d6 updated for version 7.3.695
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
399 if (*p_sel != 'e')
cd6c420e31d6 updated for version 7.3.695
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
400 len += MB_PTR2LEN(lbuf + epos->col);
cd6c420e31d6 updated for version 7.3.695
Bram Moolenaar <bram@vim.org>
parents: 2275
diff changeset
401 lbuf = vim_strnsave(lbuf + spos->col, len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 lnum = spos->lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 col = spos->col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 /* Find the word under the cursor. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 ++emsg_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 len = find_ident_at_pos(wp, lnum, (colnr_T)col, &lbuf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 FIND_IDENT + FIND_STRING + FIND_EVAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 --emsg_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 if (len == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 lbuf = vim_strnsave(lbuf, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 }
192
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
417
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
418 *winp = wp;
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
419 *lnump = lnum;
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
420 *textp = lbuf;
2fcd444c4bd3 updated for version 7.0057
vimboss
parents: 137
diff changeset
421 *colp = col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 beval->ts = wp->w_buffer->b_p_ts;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 }
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 # if !defined(FEAT_GUI_W32) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 * Show a balloon with "mesg".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
437 gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 beval->msg = mesg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 if (mesg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 drawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 undrawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 # endif /* FEAT_GUI_W32 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 #endif /* FEAT_SUN_WORKSHOP || FEAT_NETBEANS_INTG || PROTO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 #if !defined(FEAT_GUI_W32) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 #if defined(FEAT_BEVAL_TIP) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 * Hide the given balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
454 gui_mch_unpost_balloon(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 undrawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 #ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 * We can unconditionally use ANSI-style prototypes here since
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 * GTK+ requires an ANSI C compiler anyway.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 addEventHandler(GtkWidget *target, BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 * Connect to the generic "event" signal instead of the individual
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 * signals for each event type, because the former is emitted earlier.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 * This allows us to catch events independently of the signal handlers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 * in gui_gtk_x11.c.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
474 # 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
475 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
476 G_CALLBACK(target_event_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
477 beval);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
478 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 /* Should use GTK_OBJECT() here, but that causes a lint warning... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 gtk_signal_connect((GtkObject*)(target), "event",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 GTK_SIGNAL_FUNC(target_event_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
483 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 * Nasty: Key press events go to the main window thus the drawing area
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 * will never see them. This means we have to connect to the main window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 * as well in order to catch those events.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 if (gtk_socket_id == 0 && gui.mainwin != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 && gtk_widget_is_ancestor(target, gui.mainwin))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
492 # 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
493 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
494 G_CALLBACK(mainwin_event_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
495 beval);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
496 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 gtk_signal_connect((GtkObject*)(gui.mainwin), "event",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 GTK_SIGNAL_FUNC(mainwin_event_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
500 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 removeEventHandler(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 {
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 7
diff changeset
507 /* 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
508 # 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
509 g_signal_handlers_disconnect_by_func(G_OBJECT(beval->target),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
510 G_CALLBACK(target_event_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
511 beval);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
512 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 gtk_signal_disconnect_by_func((GtkObject*)(beval->target),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 GTK_SIGNAL_FUNC(target_event_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
516 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 if (gtk_socket_id == 0 && gui.mainwin != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 && gtk_widget_is_ancestor(beval->target, gui.mainwin))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 {
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 7
diff changeset
521 /* 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
522 # 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
523 g_signal_handlers_disconnect_by_func(G_OBJECT(gui.mainwin),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
524 G_CALLBACK(mainwin_event_cb),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
525 beval);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
526 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 gtk_signal_disconnect_by_func((GtkObject*)(gui.mainwin),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 GTK_SIGNAL_FUNC(mainwin_event_cb),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
530 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 static gint
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 target_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 BalloonEval *beval = (BalloonEval *)data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 switch (event->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 case GDK_ENTER_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 pointer_event(beval, (int)event->crossing.x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 (int)event->crossing.y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 event->crossing.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 case GDK_MOTION_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 if (event->motion.is_hint)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 GdkModifierType state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 * GDK_POINTER_MOTION_HINT_MASK is set, thus we cannot obtain
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 * the coordinates from the GdkEventMotion struct directly.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
556 # 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
557 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
558 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
559 GdkDisplay * const dpy = gdk_window_get_display(win);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
560 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
561 GdkDevice * const dev = gdk_device_manager_get_client_pointer(mngr);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
562 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
563 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
564 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 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
566 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 pointer_event(beval, x, y, (unsigned int)state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 pointer_event(beval, (int)event->motion.x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 (int)event->motion.y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 event->motion.state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 case GDK_LEAVE_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 * Ignore LeaveNotify events that are not "normal".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 * Apparently we also get it when somebody else grabs focus.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 if (event->crossing.mode == GDK_CROSSING_NORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 case GDK_BUTTON_PRESS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 case GDK_SCROLL:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 case GDK_KEY_PRESS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 key_event(beval, event->key.keyval, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 case GDK_KEY_RELEASE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 key_event(beval, event->key.keyval, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 return FALSE; /* continue emission */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 static gint
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1844
diff changeset
602 mainwin_event_cb(GtkWidget *widget UNUSED, GdkEvent *event, gpointer data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 BalloonEval *beval = (BalloonEval *)data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 switch (event->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 case GDK_KEY_PRESS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 key_event(beval, event->key.keyval, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 case GDK_KEY_RELEASE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 key_event(beval, event->key.keyval, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 return FALSE; /* continue emission */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 pointer_event(BalloonEval *beval, int x, int y, unsigned state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 int distance;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 distance = ABS(x - beval->x) + ABS(y - beval->y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 if (distance > 4)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 * Moved out of the balloon location: cancel it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 * Remember button state
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 beval->state = state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 /* Mouse buttons are pressed - no balloon now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 if (!(state & ((int)GDK_BUTTON1_MASK | (int)GDK_BUTTON2_MASK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 | (int)GDK_BUTTON3_MASK)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 beval->x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 beval->y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 if (state & (int)GDK_MOD1_MASK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 * Alt is pressed -- enter super-evaluate-mode,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 * where there is no time delay
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 if (beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 beval->showState = ShS_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 (*beval->msgCB)(beval, state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
658 # 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
659 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
660 &timeout_cb, beval);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
661 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 beval->timerID = gtk_timeout_add((guint32)p_bdlay,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 &timeout_cb, beval);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
664 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 key_event(BalloonEval *beval, unsigned keyval, int is_keypress)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 switch (keyval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 case GDK_Shift_L:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 case GDK_Shift_R:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 (*beval->msgCB)(beval, (is_keypress)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 ? (int)GDK_SHIFT_MASK : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 case GDK_Control_L:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 case GDK_Control_R:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 (*beval->msgCB)(beval, (is_keypress)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 ? (int)GDK_CONTROL_MASK : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 default:
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 640
diff changeset
690 /* Don't do this for key release, we apparently get these with
9090f866cd57 updated for version 7.0197
vimboss
parents: 640
diff changeset
691 * focus changes in some GTK version. */
9090f866cd57 updated for version 7.0197
vimboss
parents: 640
diff changeset
692 if (is_keypress)
9090f866cd57 updated for version 7.0197
vimboss
parents: 640
diff changeset
693 cancelBalloon(beval);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
701 # 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
702 static gboolean
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
703 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 static gint
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
705 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 timeout_cb(gpointer data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 BalloonEval *beval = (BalloonEval *)data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 beval->timerID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 * If the timer event happens then the mouse has stopped long enough for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 * a request to be started. The request will only send to the debugger if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 * there the mouse is pointing at real data.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 requestBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 return FALSE; /* don't call me again */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
721 # 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
722 static gboolean
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
723 balloon_draw_event_cb(GtkWidget *widget,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
724 cairo_t *cr,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
725 gpointer data UNUSED)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
726 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
727 GtkStyleContext *context = NULL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
728 gint width = -1, height = -1;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
729
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
730 if (widget == NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
731 return TRUE;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
732
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
733 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
734 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
735 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
736
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
737 gtk_style_context_save(context);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
738
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
739 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
740 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
741
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
742 cairo_save(cr);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
743 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
744 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
745 cairo_restore(cr);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
746
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
747 gtk_style_context_restore(context);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
748
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
749 return FALSE;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
750 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
751 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 static gint
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1844
diff changeset
753 balloon_expose_event_cb(GtkWidget *widget,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1844
diff changeset
754 GdkEventExpose *event,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1844
diff changeset
755 gpointer data UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 gtk_paint_flat_box(widget->style, widget->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 GTK_STATE_NORMAL, GTK_SHADOW_OUT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 &event->area, widget, "tooltip",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 0, 0, -1, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 return FALSE; /* continue emission */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
764 # endif /* !GTK_CHECK_VERSION(3,0,0) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 #else /* !FEAT_GUI_GTK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
769 addEventHandler(Widget target, BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 XtAddEventHandler(target,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 PointerMotionMask | EnterWindowMask |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 LeaveWindowMask | ButtonPressMask | KeyPressMask |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 KeyReleaseMask,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 False,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 pointerEventEH, (XtPointer)beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
780 removeEventHandler(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 XtRemoveEventHandler(beval->target,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 PointerMotionMask | EnterWindowMask |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 LeaveWindowMask | ButtonPressMask | KeyPressMask |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 KeyReleaseMask,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 False,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 pointerEventEH, (XtPointer)beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 * The X event handler. All it does is call the real event handler.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
795 pointerEventEH(
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
796 Widget w UNUSED,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
797 XtPointer client_data,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
798 XEvent *event,
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
799 Boolean *unused UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 BalloonEval *beval = (BalloonEval *)client_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 pointerEvent(beval, event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 * The real event handler. Called by pointerEventEH() whenever an event we are
1228
5eb1ac6f92ad updated for version 7.1b
vimboss
parents: 944
diff changeset
808 * interested in occurs.
7
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 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
812 pointerEvent(BalloonEval *beval, XEvent *event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 {
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3877
diff changeset
814 Position distance; /* a measure of how much the pointer moved */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 Position delta; /* used to compute distance */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 switch (event->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 case EnterNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 case MotionNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 delta = event->xmotion.x - beval->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 if (delta < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 delta = -delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 distance = delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 delta = event->xmotion.y - beval->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 if (delta < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 delta = -delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 distance += delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 if (distance > 4)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 * Moved out of the balloon location: cancel it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 * Remember button state
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 beval->state = event->xmotion.state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 if (beval->state & (Button1Mask|Button2Mask|Button3Mask))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 /* Mouse buttons are pressed - no balloon now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 else if (beval->state & (Mod1Mask|Mod2Mask|Mod3Mask))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 * Alt is pressed -- enter super-evaluate-mode,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 * where there is no time delay
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 beval->x = event->xmotion.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 beval->y = event->xmotion.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 beval->x_root = event->xmotion.x_root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 beval->y_root = event->xmotion.y_root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 if (beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 beval->showState = ShS_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 (*beval->msgCB)(beval, beval->state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 beval->x = event->xmotion.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 beval->y = event->xmotion.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 beval->x_root = event->xmotion.x_root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 beval->y_root = event->xmotion.y_root;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 beval->timerID = XtAppAddTimeOut( beval->appContext,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 (long_u)p_bdlay, timerRoutine, beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 * Motif and Athena version: Keystrokes will be caught by the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 * "textArea" widget, and handled in gui_x11_key_hit_cb().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 case KeyPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 Modifiers modifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 KeySym keysym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 XtTranslateKeycode(gui.dpy,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 event->xkey.keycode, event->xkey.state,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 &modifier, &keysym);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 if (keysym == XK_Shift_L || keysym == XK_Shift_R)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 (*beval->msgCB)(beval, ShiftMask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 else if (keysym == XK_Control_L || keysym == XK_Control_R)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 (*beval->msgCB)(beval, ControlMask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 case KeyRelease:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 if (beval->showState == ShS_SHOWING && beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 Modifiers modifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 KeySym keysym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 XtTranslateKeycode(gui.dpy, event->xkey.keycode,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 event->xkey.state, &modifier, &keysym);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 (*beval->msgCB)(beval, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 else if ((keysym == XK_Control_L) || (keysym == XK_Control_R))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 beval->showState = ShS_UPDATE_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 (*beval->msgCB)(beval, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 case LeaveNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 /* Ignore LeaveNotify events that are not "normal".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 * Apparently we also get it when somebody else grabs focus.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 * Happens for me every two seconds (some clipboard tool?) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 if (event->xcrossing.mode == NotifyNormal)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 case ButtonPress:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 cancelBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
943 timerRoutine(XtPointer dx, XtIntervalId *id UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 BalloonEval *beval = (BalloonEval *)dx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 beval->timerID = (XtIntervalId)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 * If the timer event happens then the mouse has stopped long enough for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 * a request to be started. The request will only send to the debugger if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 * there the mouse is pointing at real data.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 requestBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 #endif /* !FEAT_GUI_GTK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
960 requestBalloon(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 if (beval->showState != ShS_PENDING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 /* Determine the beval to display */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 if (beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 beval->showState = ShS_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 (*beval->msgCB)(beval, beval->state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 else if (beval->msg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 drawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 #ifdef FEAT_GUI_GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 * Convert the string to UTF-8 if 'encoding' is not "utf-8".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 * Replace any non-printable characters and invalid bytes sequences with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 * "^X" or "<xx>" escapes, and apply SpecialKey highlighting to them.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 * TAB and NL are passed through unscathed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 */
2275
e4d849f4df03 Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
982 # define IS_NONPRINTABLE(c) (((c) < 0x20 && (c) != TAB && (c) != NL) \
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 || (c) == DEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 static void
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
985 set_printable_label_text(GtkLabel *label, char_u *text)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 char_u *convbuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 char_u *pdest;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 unsigned int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 int charlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 int uc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 PangoAttrList *attr_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 /* Convert to UTF-8 if it isn't already */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
999 convbuf = string_convert(&output_conv, text, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 if (convbuf != NULL)
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
1001 text = convbuf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 /* First let's see how much we need to allocate */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 len = 0;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
1006 for (p = text; *p != NUL; p += charlen)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 if ((*p & 0x80) == 0) /* be quick for ASCII */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 charlen = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 len += IS_NONPRINTABLE(*p) ? 2 : 1; /* nonprintable: ^X */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 {
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 192
diff changeset
1015 charlen = utf_ptr2len(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 uc = utf_ptr2char(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 if (charlen != utf_char2len(uc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 charlen = 1; /* reject overlong sequences */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 if (charlen == 1 || uc < 0xa0) /* illegal byte or */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 len += 4; /* control char: <xx> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 else if (!utf_printable(uc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 /* Note: we assume here that utf_printable() doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 * care about characters outside the BMP. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 len += 6; /* nonprintable: <xxxx> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 len += charlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 attr_list = pango_attr_list_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 buf = alloc(len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 /* Now go for the real work */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 attrentry_T *aep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 PangoAttribute *attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 guicolor_T pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 GdkColor color = { 0, 0, 0, 0 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 /* Look up the RGB values of the SpecialKey foreground color. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 aep = syn_gui_attr2entry(hl_attr(HLF_8));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 if (pixel != INVALCOLOR)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1047 # 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
1048 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1049 GdkVisual * const visual = gtk_widget_get_visual(gui.drawarea);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1050
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1051 if (visual == NULL)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1052 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1053 color.red = 0;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1054 color.green = 0;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1055 color.blue = 0;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1056 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1057 else
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1058 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1059 guint32 r_mask, g_mask, b_mask;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1060 gint r_shift, g_shift, b_shift;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1061
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1062 gdk_visual_get_red_pixel_details(visual, &r_mask, &r_shift,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1063 NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1064 gdk_visual_get_green_pixel_details(visual, &g_mask, &g_shift,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1065 NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1066 gdk_visual_get_blue_pixel_details(visual, &b_mask, &b_shift,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1067 NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1068
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1069 color.red = ((pixel & r_mask) >> r_shift) / 255.0 * 65535;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1070 color.green = ((pixel & g_mask) >> g_shift) / 255.0 * 65535;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1071 color.blue = ((pixel & b_mask) >> b_shift) / 255.0 * 65535;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1072 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1073 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1074 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 (unsigned long)pixel, &color);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1077 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 pdest = buf;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 865
diff changeset
1080 p = text;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 while (*p != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 /* Be quick for ASCII */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 if ((*p & 0x80) == 0 && !IS_NONPRINTABLE(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 *pdest++ = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 {
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 192
diff changeset
1090 charlen = utf_ptr2len(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 uc = utf_ptr2char(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 if (charlen != utf_char2len(uc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 charlen = 1; /* reject overlong sequences */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 if (charlen == 1 || uc < 0xa0 || !utf_printable(uc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 int outlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 /* Careful: we can't just use transchar_byte() here,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 * since 'encoding' is not necessarily set to "utf-8". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 if (*p & 0x80 && charlen == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 transchar_hex(pdest, *p); /* <xx> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 outlen = 4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 else if (uc >= 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 /* Note: we assume here that utf_printable() doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 * care about characters outside the BMP. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 transchar_hex(pdest, uc); /* <xx> or <xxxx> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 outlen = (uc < 0x100) ? 4 : 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 transchar_nonprint(pdest, *p); /* ^X */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 outlen = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 if (pixel != INVALCOLOR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 attr = pango_attr_foreground_new(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 color.red, color.green, color.blue);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 attr->start_index = pdest - buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 attr->end_index = pdest - buf + outlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 pango_attr_list_insert(attr_list, attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 pdest += outlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 p += charlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 *pdest++ = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 while (--charlen != 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 *pdest = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 vim_free(convbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 gtk_label_set_text(label, (const char *)buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 gtk_label_set_attributes(label, attr_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 pango_attr_list_unref(attr_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 }
2275
e4d849f4df03 Remove the old and not well supported GTK 1 code. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
1149 # undef IS_NONPRINTABLE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 * Draw a balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 drawBalloon(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 if (beval->msg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 GtkRequisition requisition;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 int screen_w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 int screen_h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 int x_offset = EVAL_OFFSET_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 int y_offset = EVAL_OFFSET_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 PangoLayout *layout;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 # ifdef HAVE_GTK_MULTIHEAD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 GdkScreen *screen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 screen = gtk_widget_get_screen(beval->target);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 screen_w = gdk_screen_get_width(screen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 screen_h = gdk_screen_get_height(screen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 screen_w = gdk_screen_width();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 screen_h = gdk_screen_height();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 # endif
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1178 # if !GTK_CHECK_VERSION(3,0,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 gtk_widget_ensure_style(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 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
1181 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 set_printable_label_text(GTK_LABEL(beval->balloonLabel), beval->msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 * Dirty trick: Enable wrapping mode on the label's layout behind its
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 * back. This way GtkLabel won't try to constrain the wrap width to a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 * builtin maximum value of about 65 Latin characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 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
1190 # ifdef PANGO_WRAP_WORD_CHAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 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
1192 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 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
1194 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 pango_layout_set_width(layout,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 /* try to come up with some reasonable width */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 screen_w / 2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 MAX(20, screen_w - 20)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 /* 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
1202 # 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
1203 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
1204 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 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
1206 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 /* 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
1209 # 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
1210 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
1211 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 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
1213 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 x += beval->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 y += beval->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 /* Get out of the way of the mouse pointer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 if (x + x_offset + requisition.width > screen_w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 y_offset += 15;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 if (y + y_offset + requisition.height > screen_h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 y_offset = -requisition.height - EVAL_OFFSET_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 /* Sanitize values */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 x = CLAMP(x + x_offset, 0, MAX(0, screen_w - requisition.width));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 y = CLAMP(y + y_offset, 0, MAX(0, screen_h - requisition.height));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 /* Show the balloon */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1228 # 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
1229 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
1230 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 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
1232 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 gtk_widget_show(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 beval->showState = ShS_SHOWING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 * Undraw a balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 undrawBalloon(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 if (beval->balloonShell != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 gtk_widget_hide(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 cancelBalloon(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 if (beval->showState == ShS_SHOWING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 || beval->showState == ShS_UPDATE_PENDING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 undrawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 if (beval->timerID != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1259 # 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
1260 g_source_remove(beval->timerID);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1261 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 gtk_timeout_remove(beval->timerID);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1263 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 beval->timerID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 createBalloonEvalWindow(BalloonEval *beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 beval->balloonShell = gtk_window_new(GTK_WINDOW_POPUP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 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
1275 # 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
1276 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
1277 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 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
1279 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 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
1281 # 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
1282 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
1283 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 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
1285 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1287 # 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
1288 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
1289 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
1290 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 gtk_signal_connect((GtkObject*)(beval->balloonShell), "expose_event",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 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
1293 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 beval->balloonLabel = gtk_label_new(NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 gtk_label_set_line_wrap(GTK_LABEL(beval->balloonLabel), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 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
1298 # 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
1299 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
1300 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
1301 # 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
1302 GValue align_val = G_VALUE_INIT;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1303 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
1304 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
1305 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
1306 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
1307 g_value_unset(&align_val);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 7821
diff changeset
1308 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 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
1310 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 gtk_widget_set_name(beval->balloonLabel, "vim-balloon-label");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 gtk_widget_show(beval->balloonLabel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 #else /* !FEAT_GUI_GTK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 * Draw a balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1323 drawBalloon(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 Dimension w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 Dimension h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 Position tx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 Position ty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 if (beval->msg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 /* Show the Balloon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 /* Calculate the label's width and height */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 XmString s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 /* For the callback function we parse NL characters to create a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 * multi-line label. This doesn't work for all languages, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 * XmStringCreateLocalized() doesn't do multi-line labels... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 if (beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 s = XmStringCreateLtoR((char *)beval->msg, XmFONTLIST_DEFAULT_TAG);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 s = XmStringCreateLocalized((char *)beval->msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 XmFontList fl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 fl = gui_motif_fontset2fontlist(&gui.tooltip_fontset);
6003
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1349 if (fl == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 {
6003
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1351 XmStringFree(s);
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1352 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 }
6003
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1354 XmStringExtent(fl, s, &w, &h);
8dcc6f142460 updated for version 7.4.342
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1355 XmFontListFree(fl);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 w += gui.border_offset << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 h += gui.border_offset << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 XmStringFree(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 #else /* Athena */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 /* Assume XtNinternational == True */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 XFontSet fset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 XFontSetExtents *ext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 XtVaGetValues(beval->balloonLabel, XtNfontSet, &fset, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 ext = XExtentsOfFontSet(fset);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 h = ext->max_ink_extent.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 w = XmbTextEscapement(fset,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 (char *)beval->msg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 (int)STRLEN(beval->msg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 w += gui.border_offset << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 h += gui.border_offset << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 /* Compute position of the balloon area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 tx = beval->x_root + EVAL_OFFSET_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 ty = beval->y_root + EVAL_OFFSET_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 if ((tx + w) > beval->screen_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 tx = beval->screen_width - w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 if ((ty + h) > beval->screen_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 ty = beval->screen_height - h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 XtVaSetValues(beval->balloonShell,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 XmNx, tx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 XmNy, ty,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 /* Athena */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 XtVaSetValues(beval->balloonShell,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 XtNx, tx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 XtNy, ty,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 #endif
1844
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1396 /* Set tooltip colors */
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1397 {
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1398 Arg args[2];
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1399
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1400 #ifdef FEAT_GUI_MOTIF
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1401 args[0].name = XmNbackground;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1402 args[0].value = gui.tooltip_bg_pixel;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1403 args[1].name = XmNforeground;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1404 args[1].value = gui.tooltip_fg_pixel;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1405 #else /* Athena */
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1406 args[0].name = XtNbackground;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1407 args[0].value = gui.tooltip_bg_pixel;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1408 args[1].name = XtNforeground;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1409 args[1].value = gui.tooltip_fg_pixel;
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1410 #endif
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1411 XtSetValues(beval->balloonLabel, &args[0], XtNumber(args));
819d952a0a5c updated for version 7.2-142
vimboss
parents: 1228
diff changeset
1412 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 XtPopup(beval->balloonShell, XtGrabNone);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 beval->showState = ShS_SHOWING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 current_beval = beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 * Undraw a balloon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1426 undrawBalloon(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 if (beval->balloonShell != (Widget)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 XtPopdown(beval->balloonShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 current_beval = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1436 cancelBalloon(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 if (beval->showState == ShS_SHOWING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 || beval->showState == ShS_UPDATE_PENDING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 undrawBalloon(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 if (beval->timerID != (XtIntervalId)NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 XtRemoveTimeOut(beval->timerID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 beval->timerID = (XtIntervalId)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 static void
7821
81794242a275 commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
1452 createBalloonEvalWindow(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 Arg args[12];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 XtSetArg(args[n], XmNallowShellResize, True); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 overrideShellWidgetClass, gui.dpy, args, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 /* Athena */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 XtSetArg(args[n], XtNallowShellResize, True); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 overrideShellWidgetClass, gui.dpy, args, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 #ifdef FEAT_GUI_MOTIF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 XmFontList fl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 fl = gui_motif_fontset2fontlist(&gui.tooltip_fontset);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 XtSetArg(args[n], XmNforeground, gui.tooltip_fg_pixel); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 XtSetArg(args[n], XmNbackground, gui.tooltip_bg_pixel); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 XtSetArg(args[n], XmNfontList, fl); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 beval->balloonLabel = XtCreateManagedWidget("balloonLabel",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 xmLabelWidgetClass, beval->balloonShell, args, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 #else /* FEAT_GUI_ATHENA */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 XtSetArg(args[n], XtNinternational, True); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 XtSetArg(args[n], XtNfontSet, gui.tooltip_fontset); n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 beval->balloonLabel = XtCreateManagedWidget("balloonLabel",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 labelWidgetClass, beval->balloonShell, args, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 #endif /* !FEAT_GUI_GTK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 #endif /* !FEAT_GUI_W32 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 #endif /* FEAT_BEVAL */