annotate src/gui_beval.c @ 7772:0677c5b880d1 v7.4.1183

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