annotate src/gui_beval.c @ 10726:78927b31c73a v8.0.0253

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