annotate src/gui_beval.c @ 12716:351cf7c67bbe v8.0.1236

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