1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
To: vim-dev@vim.org
Subject: Patch 7.2.334
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.2.334
Problem: Postponing keys in Netbeans interface does not work properly.
Solution: Store the key string instead of the number. Avoid an infinite
loop. (Mostly by Xavier de Gaye)
Files: src/netbeans.c, src/proto/netbeans.pro
*** ../vim-7.2.333/src/netbeans.c 2010-01-19 14:59:14.000000000 +0100
--- src/netbeans.c 2010-01-19 15:12:17.000000000 +0100
***************
*** 70,76 ****
static pos_T *off2pos __ARGS((buf_T *, long));
static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp));
static long get_buf_size __ARGS((buf_T *));
! static void netbeans_keystring __ARGS((int key, char *keystr));
static void special_keys __ARGS((char_u *args));
static void netbeans_connect __ARGS((void));
--- 70,77 ----
static pos_T *off2pos __ARGS((buf_T *, long));
static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp));
static long get_buf_size __ARGS((buf_T *));
! static int netbeans_keystring __ARGS((char_u *keystr));
! static void postpone_keycommand __ARGS((char_u *keystr));
static void special_keys __ARGS((char_u *args));
static void netbeans_connect __ARGS((void));
***************
*** 502,508 ****
struct keyqueue
{
! int key;
struct keyqueue *next;
struct keyqueue *prev;
};
--- 503,509 ----
struct keyqueue
{
! char_u *keystr;
struct keyqueue *next;
struct keyqueue *prev;
};
***************
*** 514,526 ****
/*
* Queue up key commands sent from netbeans.
*/
static void
! postpone_keycommand(int key)
{
keyQ_T *node;
node = (keyQ_T *)alloc(sizeof(keyQ_T));
if (keyHead.next == NULL) /* initialize circular queue */
{
--- 515,531 ----
/*
* Queue up key commands sent from netbeans.
+ * We store the string, because it may depend on the global mod_mask and
+ * :nbkey doesn't have a key number.
*/
static void
! postpone_keycommand(char_u *keystr)
{
keyQ_T *node;
node = (keyQ_T *)alloc(sizeof(keyQ_T));
+ if (node == NULL)
+ return; /* out of memory, drop the key */
if (keyHead.next == NULL) /* initialize circular queue */
{
***************
*** 534,540 ****
keyHead.prev->next = node;
keyHead.prev = node;
! node->key = key;
}
/*
--- 539,545 ----
keyHead.prev->next = node;
keyHead.prev = node;
! node->keystr = vim_strsave(keystr);
}
/*
***************
*** 543,557 ****
static void
handle_key_queue(void)
{
! while (keyHead.next && keyHead.next != &keyHead)
{
/* first, unlink the node */
keyQ_T *node = keyHead.next;
keyHead.next = node->next;
node->next->prev = node->prev;
! /* now, send the keycommand */
! netbeans_keycommand(node->key);
/* Finally, dispose of the node */
vim_free(node);
--- 548,567 ----
static void
handle_key_queue(void)
{
! int postponed = FALSE;
!
! while (!postponed && keyHead.next && keyHead.next != &keyHead)
{
/* first, unlink the node */
keyQ_T *node = keyHead.next;
keyHead.next = node->next;
node->next->prev = node->prev;
! /* Now, send the keycommand. This may cause it to be postponed again
! * and change keyHead. */
! if (node->keystr != NULL)
! postponed = !netbeans_keystring(node->keystr);
! vim_free(node->keystr);
/* Finally, dispose of the node */
vim_free(node);
***************
*** 2495,2501 ****
}
else
{
! nbdebug((" Buffer has no changes!\n"));
}
/* =====================================================================*/
}
--- 2505,2511 ----
}
else
{
! nbdebug((" Buffer has no changes!\n"));
}
/* =====================================================================*/
}
***************
*** 2658,2664 ****
ex_nbkey(eap)
exarg_T *eap;
{
! netbeans_keystring(0, (char *)eap->arg);
}
--- 2668,2674 ----
ex_nbkey(eap)
exarg_T *eap;
{
! (void)netbeans_keystring(eap->arg);
}
***************
*** 2680,2686 ****
}
/*
! * Convert key to netbeans name.
*/
static void
netbeans_keyname(int key, char *buf)
--- 2690,2696 ----
}
/*
! * Convert key to netbeans name. This uses the global "mod_mask".
*/
static void
netbeans_keyname(int key, char *buf)
***************
*** 3127,3149 ****
/*
* Send a keypress event back to netbeans. This usually simulates some
* kind of function key press. This function operates on a key code.
*/
! void
netbeans_keycommand(int key)
{
char keyName[60];
netbeans_keyname(key, keyName);
! netbeans_keystring(key, keyName);
}
/*
* Send a keypress event back to netbeans. This usually simulates some
* kind of function key press. This function operates on a key string.
*/
! static void
! netbeans_keystring(int key, char *keyName)
{
char buf[2*MAXPATHL];
int bufno = nb_getbufno(curbuf);
--- 3137,3163 ----
/*
* Send a keypress event back to netbeans. This usually simulates some
* kind of function key press. This function operates on a key code.
+ * Return TRUE when the key was sent, FALSE when the command has been
+ * postponed.
*/
! int
netbeans_keycommand(int key)
{
char keyName[60];
netbeans_keyname(key, keyName);
! return netbeans_keystring((char_u *)keyName);
}
/*
* Send a keypress event back to netbeans. This usually simulates some
* kind of function key press. This function operates on a key string.
+ * Return TRUE when the key was sent, FALSE when the command has been
+ * postponed.
*/
! static int
! netbeans_keystring(char_u *keyName)
{
char buf[2*MAXPATHL];
int bufno = nb_getbufno(curbuf);
***************
*** 3151,3157 ****
char_u *q;
if (!haveConnection)
! return;
if (bufno == -1)
--- 3165,3171 ----
char_u *q;
if (!haveConnection)
! return TRUE;
if (bufno == -1)
***************
*** 3160,3166 ****
q = curbuf->b_ffname == NULL ? (char_u *)""
: nb_quote(curbuf->b_ffname);
if (q == NULL)
! return;
vim_snprintf(buf, sizeof(buf), "0:fileOpened=%d \"%s\" %s %s\n", 0,
q,
"T", /* open in NetBeans */
--- 3174,3180 ----
q = curbuf->b_ffname == NULL ? (char_u *)""
: nb_quote(curbuf->b_ffname);
if (q == NULL)
! return TRUE;
vim_snprintf(buf, sizeof(buf), "0:fileOpened=%d \"%s\" %s %s\n", 0,
q,
"T", /* open in NetBeans */
***************
*** 3170,3178 ****
nbdebug(("EVT: %s", buf));
nb_send(buf, "netbeans_keycommand");
! if (key > 0)
! postpone_keycommand(key);
! return;
}
/* sync the cursor position */
--- 3184,3191 ----
nbdebug(("EVT: %s", buf));
nb_send(buf, "netbeans_keycommand");
! postpone_keycommand(keyName);
! return FALSE;
}
/* sync the cursor position */
***************
*** 3198,3203 ****
--- 3211,3217 ----
off, (long)curwin->w_cursor.lnum, (long)curwin->w_cursor.col);
nbdebug(("EVT: %s", buf));
nb_send(buf, "netbeans_keycommand");
+ return TRUE;
}
*** ../vim-7.2.333/src/proto/netbeans.pro 2009-01-06 16:13:42.000000000 +0100
--- src/proto/netbeans.pro 2010-01-19 13:31:01.000000000 +0100
***************
*** 16,22 ****
void netbeans_removed __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, long len));
void netbeans_unmodified __ARGS((buf_T *bufp));
void netbeans_button_release __ARGS((int button));
! void netbeans_keycommand __ARGS((int key));
void netbeans_save_buffer __ARGS((buf_T *bufp));
void netbeans_deleted_all_lines __ARGS((buf_T *bufp));
int netbeans_is_guarded __ARGS((linenr_T top, linenr_T bot));
--- 16,22 ----
void netbeans_removed __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, long len));
void netbeans_unmodified __ARGS((buf_T *bufp));
void netbeans_button_release __ARGS((int button));
! int netbeans_keycommand __ARGS((int key));
void netbeans_save_buffer __ARGS((buf_T *bufp));
void netbeans_deleted_all_lines __ARGS((buf_T *bufp));
int netbeans_is_guarded __ARGS((linenr_T top, linenr_T bot));
*** ../vim-7.2.333/src/version.c 2010-01-19 14:59:14.000000000 +0100
--- src/version.c 2010-01-19 15:08:44.000000000 +0100
***************
*** 683,684 ****
--- 683,686 ----
{ /* Add new patch number below this line */
+ /**/
+ 334,
/**/
--
hundred-and-one symptoms of being an internet addict:
119. You are reading a book and look for the scroll bar to get to
the next page.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|