4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Postponing keys in Netbeans interface does not work properly.
12 Solution: Store the key string instead of the number. Avoid an infinite
13 loop. (Mostly by Xavier de Gaye)
14 Files: src/netbeans.c, src/proto/netbeans.pro
17 *** ../vim-7.2.333/src/netbeans.c 2010-01-19 14:59:14.000000000 +0100
18 --- src/netbeans.c 2010-01-19 15:12:17.000000000 +0100
21 static pos_T *off2pos __ARGS((buf_T *, long));
22 static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp));
23 static long get_buf_size __ARGS((buf_T *));
24 ! static void netbeans_keystring __ARGS((int key, char *keystr));
25 static void special_keys __ARGS((char_u *args));
27 static void netbeans_connect __ARGS((void));
29 static pos_T *off2pos __ARGS((buf_T *, long));
30 static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp));
31 static long get_buf_size __ARGS((buf_T *));
32 ! static int netbeans_keystring __ARGS((char_u *keystr));
33 ! static void postpone_keycommand __ARGS((char_u *keystr));
34 static void special_keys __ARGS((char_u *args));
36 static void netbeans_connect __ARGS((void));
43 struct keyqueue *next;
44 struct keyqueue *prev;
51 struct keyqueue *next;
52 struct keyqueue *prev;
58 * Queue up key commands sent from netbeans.
61 ! postpone_keycommand(int key)
65 node = (keyQ_T *)alloc(sizeof(keyQ_T));
67 if (keyHead.next == NULL) /* initialize circular queue */
72 * Queue up key commands sent from netbeans.
73 + * We store the string, because it may depend on the global mod_mask and
74 + * :nbkey doesn't have a key number.
77 ! postpone_keycommand(char_u *keystr)
81 node = (keyQ_T *)alloc(sizeof(keyQ_T));
83 + return; /* out of memory, drop the key */
85 if (keyHead.next == NULL) /* initialize circular queue */
89 keyHead.prev->next = node;
97 keyHead.prev->next = node;
100 ! node->keystr = vim_strsave(keystr);
107 handle_key_queue(void)
109 ! while (keyHead.next && keyHead.next != &keyHead)
111 /* first, unlink the node */
112 keyQ_T *node = keyHead.next;
113 keyHead.next = node->next;
114 node->next->prev = node->prev;
116 ! /* now, send the keycommand */
117 ! netbeans_keycommand(node->key);
119 /* Finally, dispose of the node */
123 handle_key_queue(void)
125 ! int postponed = FALSE;
127 ! while (!postponed && keyHead.next && keyHead.next != &keyHead)
129 /* first, unlink the node */
130 keyQ_T *node = keyHead.next;
131 keyHead.next = node->next;
132 node->next->prev = node->prev;
134 ! /* Now, send the keycommand. This may cause it to be postponed again
135 ! * and change keyHead. */
136 ! if (node->keystr != NULL)
137 ! postponed = !netbeans_keystring(node->keystr);
138 ! vim_free(node->keystr);
140 /* Finally, dispose of the node */
147 ! nbdebug((" Buffer has no changes!\n"));
149 /* =====================================================================*/
155 ! nbdebug((" Buffer has no changes!\n"));
157 /* =====================================================================*/
164 ! netbeans_keystring(0, (char *)eap->arg);
172 ! (void)netbeans_keystring(eap->arg);
181 ! * Convert key to netbeans name.
184 netbeans_keyname(int key, char *buf)
189 ! * Convert key to netbeans name. This uses the global "mod_mask".
192 netbeans_keyname(int key, char *buf)
196 * Send a keypress event back to netbeans. This usually simulates some
197 * kind of function key press. This function operates on a key code.
200 netbeans_keycommand(int key)
204 netbeans_keyname(key, keyName);
205 ! netbeans_keystring(key, keyName);
210 * Send a keypress event back to netbeans. This usually simulates some
211 * kind of function key press. This function operates on a key string.
214 ! netbeans_keystring(int key, char *keyName)
216 char buf[2*MAXPATHL];
217 int bufno = nb_getbufno(curbuf);
220 * Send a keypress event back to netbeans. This usually simulates some
221 * kind of function key press. This function operates on a key code.
222 + * Return TRUE when the key was sent, FALSE when the command has been
226 netbeans_keycommand(int key)
230 netbeans_keyname(key, keyName);
231 ! return netbeans_keystring((char_u *)keyName);
236 * Send a keypress event back to netbeans. This usually simulates some
237 * kind of function key press. This function operates on a key string.
238 + * Return TRUE when the key was sent, FALSE when the command has been
242 ! netbeans_keystring(char_u *keyName)
244 char buf[2*MAXPATHL];
245 int bufno = nb_getbufno(curbuf);
265 q = curbuf->b_ffname == NULL ? (char_u *)""
266 : nb_quote(curbuf->b_ffname);
269 vim_snprintf(buf, sizeof(buf), "0:fileOpened=%d \"%s\" %s %s\n", 0,
271 "T", /* open in NetBeans */
273 q = curbuf->b_ffname == NULL ? (char_u *)""
274 : nb_quote(curbuf->b_ffname);
277 vim_snprintf(buf, sizeof(buf), "0:fileOpened=%d \"%s\" %s %s\n", 0,
279 "T", /* open in NetBeans */
282 nbdebug(("EVT: %s", buf));
283 nb_send(buf, "netbeans_keycommand");
286 ! postpone_keycommand(key);
290 /* sync the cursor position */
292 nbdebug(("EVT: %s", buf));
293 nb_send(buf, "netbeans_keycommand");
295 ! postpone_keycommand(keyName);
299 /* sync the cursor position */
303 off, (long)curwin->w_cursor.lnum, (long)curwin->w_cursor.col);
304 nbdebug(("EVT: %s", buf));
305 nb_send(buf, "netbeans_keycommand");
310 *** ../vim-7.2.333/src/proto/netbeans.pro 2009-01-06 16:13:42.000000000 +0100
311 --- src/proto/netbeans.pro 2010-01-19 13:31:01.000000000 +0100
314 void netbeans_removed __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, long len));
315 void netbeans_unmodified __ARGS((buf_T *bufp));
316 void netbeans_button_release __ARGS((int button));
317 ! void netbeans_keycommand __ARGS((int key));
318 void netbeans_save_buffer __ARGS((buf_T *bufp));
319 void netbeans_deleted_all_lines __ARGS((buf_T *bufp));
320 int netbeans_is_guarded __ARGS((linenr_T top, linenr_T bot));
322 void netbeans_removed __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, long len));
323 void netbeans_unmodified __ARGS((buf_T *bufp));
324 void netbeans_button_release __ARGS((int button));
325 ! int netbeans_keycommand __ARGS((int key));
326 void netbeans_save_buffer __ARGS((buf_T *bufp));
327 void netbeans_deleted_all_lines __ARGS((buf_T *bufp));
328 int netbeans_is_guarded __ARGS((linenr_T top, linenr_T bot));
329 *** ../vim-7.2.333/src/version.c 2010-01-19 14:59:14.000000000 +0100
330 --- src/version.c 2010-01-19 15:08:44.000000000 +0100
334 { /* Add new patch number below this line */
340 hundred-and-one symptoms of being an internet addict:
341 119. You are reading a book and look for the scroll bar to get to
344 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
345 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
346 \\\ download, build and distribute -- http://www.A-A-P.org ///
347 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///