7
|
1 /* vi:set ts=8 sts=4 sw=4:
|
|
2 *
|
|
3 * VIM - Vi IMproved by Bram Moolenaar
|
|
4 * Netbeans integration by David Weatherford
|
|
5 * Adopted for Win32 by Sergey Khorev
|
|
6 *
|
|
7 * Do ":help uganda" in Vim to read copying and usage conditions.
|
|
8 * Do ":help credits" in Vim to see a list of people who contributed.
|
|
9 */
|
|
10
|
|
11 /*
|
|
12 * Implements client side of org.netbeans.modules.emacs editor
|
|
13 * integration protocol. Be careful! The protocol uses offsets
|
|
14 * which are *between* characters, whereas vim uses line number
|
|
15 * and column number which are *on* characters.
|
|
16 * See ":help netbeans-protocol" for explanation.
|
|
17 */
|
|
18
|
|
19 #include "vim.h"
|
|
20
|
|
21 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
|
|
22
|
|
23 /* Note: when making changes here also adjust configure.in. */
|
|
24 # include <fcntl.h>
|
|
25 #ifdef WIN32
|
|
26 # ifdef DEBUG
|
|
27 # include <tchar.h> /* for _T definition for TRACEn macros */
|
|
28 # endif
|
714
|
29 # include "vimio.h"
|
7
|
30 /* WinSock API is separated from C API, thus we can't use read(), write(),
|
|
31 * errno... */
|
|
32 # define sock_errno WSAGetLastError()
|
|
33 # define ECONNREFUSED WSAECONNREFUSED
|
|
34 # ifdef EINTR
|
|
35 # undef EINTR
|
|
36 # endif
|
|
37 # define EINTR WSAEINTR
|
|
38 # define sock_write(sd, buf, len) send(sd, buf, len, 0)
|
|
39 # define sock_read(sd, buf, len) recv(sd, buf, len, 0)
|
|
40 # define sock_close(sd) closesocket(sd)
|
|
41 # define sleep(t) Sleep(t*1000) /* WinAPI Sleep() accepts milliseconds */
|
|
42 #else
|
|
43 # include <netdb.h>
|
|
44 # include <netinet/in.h>
|
|
45 # include <sys/socket.h>
|
|
46 # ifdef HAVE_LIBGEN_H
|
|
47 # include <libgen.h>
|
|
48 # endif
|
|
49 # define sock_errno errno
|
|
50 # define sock_write(sd, buf, len) write(sd, buf, len)
|
|
51 # define sock_read(sd, buf, len) read(sd, buf, len)
|
|
52 # define sock_close(sd) close(sd)
|
|
53 #endif
|
|
54
|
|
55 #include "version.h"
|
|
56
|
|
57 #define INET_SOCKETS
|
|
58
|
|
59 #define GUARDED 10000 /* typenr for "guarded" annotation */
|
|
60 #define GUARDEDOFFSET 1000000 /* base for "guarded" sign id's */
|
|
61
|
|
62 /* The first implementation (working only with Netbeans) returned "1.1". The
|
|
63 * protocol implemented here also supports A-A-P. */
|
1037
|
64 static char *ExtEdProtocolVersion = "2.4";
|
7
|
65
|
|
66 static long pos2off __ARGS((buf_T *, pos_T *));
|
|
67 static pos_T *off2pos __ARGS((buf_T *, long));
|
|
68 static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp));
|
|
69 static long get_buf_size __ARGS((buf_T *));
|
33
|
70 static void netbeans_keystring __ARGS((int key, char *keystr));
|
|
71 static void special_keys __ARGS((char_u *args));
|
7
|
72
|
|
73 static void netbeans_connect __ARGS((void));
|
|
74 static int getConnInfo __ARGS((char *file, char **host, char **port, char **password));
|
|
75
|
|
76 static void nb_init_graphics __ARGS((void));
|
|
77 static void coloncmd __ARGS((char *cmd, ...));
|
659
|
78 static void nb_set_curbuf __ARGS((buf_T *buf));
|
7
|
79 #ifdef FEAT_GUI_MOTIF
|
|
80 static void messageFromNetbeans __ARGS((XtPointer, int *, XtInputId *));
|
|
81 #endif
|
|
82 #ifdef FEAT_GUI_GTK
|
|
83 static void messageFromNetbeans __ARGS((gpointer, gint, GdkInputCondition));
|
|
84 #endif
|
|
85 static void nb_parse_cmd __ARGS((char_u *));
|
|
86 static int nb_do_cmd __ARGS((int, char_u *, int, int, char_u *));
|
|
87 static void nb_send __ARGS((char *buf, char *fun));
|
|
88
|
835
|
89 #ifdef WIN64
|
|
90 typedef __int64 NBSOCK;
|
|
91 #else
|
|
92 typedef int NBSOCK;
|
|
93 #endif
|
|
94
|
|
95 static NBSOCK sd = -1; /* socket fd for Netbeans connection */
|
7
|
96 #ifdef FEAT_GUI_MOTIF
|
|
97 static XtInputId inputHandler; /* Cookie for input */
|
|
98 #endif
|
|
99 #ifdef FEAT_GUI_GTK
|
|
100 static gint inputHandler; /* Cookie for input */
|
|
101 #endif
|
|
102 #ifdef FEAT_GUI_W32
|
|
103 static int inputHandler = -1; /* simply ret.value of WSAAsyncSelect() */
|
|
104 extern HWND s_hwnd; /* Gvim's Window handle */
|
|
105 #endif
|
944
|
106 static int r_cmdno; /* current command number for reply */
|
7
|
107 static int haveConnection = FALSE; /* socket is connected and
|
|
108 initialization is done */
|
33
|
109 #ifdef FEAT_GUI_MOTIF
|
|
110 static void netbeans_Xt_connect __ARGS((void *context));
|
167
|
111 #endif
|
|
112 #ifdef FEAT_GUI_GTK
|
33
|
113 static void netbeans_gtk_connect __ARGS((void));
|
167
|
114 #endif
|
|
115 #ifdef FEAT_GUI_W32
|
33
|
116 static void netbeans_w32_connect __ARGS((void));
|
|
117 #endif
|
|
118
|
|
119 static int dosetvisible = FALSE;
|
|
120
|
7
|
121 /*
|
|
122 * Include the debugging code if wanted.
|
|
123 */
|
|
124 #ifdef NBDEBUG
|
|
125 # include "nbdebug.c"
|
|
126 #endif
|
|
127
|
|
128 /* Connect back to Netbeans process */
|
33
|
129 #ifdef FEAT_GUI_MOTIF
|
|
130 static void
|
7
|
131 netbeans_Xt_connect(void *context)
|
|
132 {
|
|
133 netbeans_connect();
|
|
134 if (sd > 0)
|
|
135 {
|
|
136 /* tell notifier we are interested in being called
|
|
137 * when there is input on the editor connection socket
|
|
138 */
|
|
139 inputHandler = XtAppAddInput((XtAppContext)context, sd,
|
|
140 (XtPointer)(XtInputReadMask + XtInputExceptMask),
|
|
141 messageFromNetbeans, NULL);
|
|
142 }
|
|
143 }
|
|
144
|
|
145 static void
|
|
146 netbeans_disconnect(void)
|
|
147 {
|
|
148 if (inputHandler != (XtInputId)NULL)
|
|
149 {
|
|
150 XtRemoveInput(inputHandler);
|
|
151 inputHandler = (XtInputId)NULL;
|
|
152 }
|
|
153 sd = -1;
|
|
154 haveConnection = FALSE;
|
183
|
155 # ifdef FEAT_BEVAL
|
|
156 bevalServers &= ~BEVAL_NETBEANS;
|
|
157 # endif
|
7
|
158 }
|
|
159 #endif /* FEAT_MOTIF_GUI */
|
|
160
|
33
|
161 #ifdef FEAT_GUI_GTK
|
|
162 static void
|
7
|
163 netbeans_gtk_connect(void)
|
|
164 {
|
|
165 netbeans_connect();
|
|
166 if (sd > 0)
|
|
167 {
|
|
168 /*
|
|
169 * Tell gdk we are interested in being called when there
|
|
170 * is input on the editor connection socket
|
|
171 */
|
836
|
172 inputHandler = gdk_input_add((gint)sd, (GdkInputCondition)
|
7
|
173 ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION),
|
|
174 messageFromNetbeans, NULL);
|
|
175 }
|
|
176 }
|
|
177
|
|
178 static void
|
|
179 netbeans_disconnect(void)
|
|
180 {
|
|
181 if (inputHandler != 0)
|
|
182 {
|
|
183 gdk_input_remove(inputHandler);
|
|
184 inputHandler = 0;
|
|
185 }
|
|
186 sd = -1;
|
|
187 haveConnection = FALSE;
|
183
|
188 # ifdef FEAT_BEVAL
|
|
189 bevalServers &= ~BEVAL_NETBEANS;
|
|
190 # endif
|
7
|
191 }
|
|
192 #endif /* FEAT_GUI_GTK */
|
|
193
|
143
|
194 #if defined(FEAT_GUI_W32) || defined(PROTO)
|
344
|
195 static void
|
7
|
196 netbeans_w32_connect(void)
|
|
197 {
|
|
198 netbeans_connect();
|
|
199 if (sd > 0)
|
|
200 {
|
|
201 /*
|
|
202 * Tell Windows we are interested in receiving message when there
|
|
203 * is input on the editor connection socket
|
|
204 */
|
|
205 inputHandler = WSAAsyncSelect(sd, s_hwnd, WM_NETBEANS, FD_READ);
|
|
206 }
|
|
207 }
|
|
208
|
|
209 static void
|
|
210 netbeans_disconnect(void)
|
|
211 {
|
|
212 if (inputHandler == 0)
|
|
213 {
|
|
214 WSAAsyncSelect(sd, s_hwnd, 0, 0);
|
|
215 inputHandler = -1;
|
|
216 }
|
|
217 sd = -1;
|
|
218 haveConnection = FALSE;
|
183
|
219 # ifdef FEAT_BEVAL
|
|
220 bevalServers &= ~BEVAL_NETBEANS;
|
|
221 # endif
|
7
|
222 }
|
|
223 #endif /* FEAT_GUI_W32 */
|
|
224
|
|
225 #define NB_DEF_HOST "localhost"
|
|
226 #define NB_DEF_ADDR "3219"
|
|
227 #define NB_DEF_PASS "changeme"
|
|
228
|
|
229 static void
|
|
230 netbeans_connect(void)
|
|
231 {
|
|
232 #ifdef INET_SOCKETS
|
|
233 struct sockaddr_in server;
|
|
234 struct hostent * host;
|
|
235 # ifdef FEAT_GUI_W32
|
|
236 u_short port;
|
|
237 # else
|
|
238 int port;
|
|
239 #endif
|
|
240 #else
|
|
241 struct sockaddr_un server;
|
|
242 #endif
|
|
243 char buf[32];
|
|
244 char *hostname = NULL;
|
|
245 char *address = NULL;
|
|
246 char *password = NULL;
|
|
247 char *fname;
|
|
248 char *arg = NULL;
|
|
249
|
|
250 if (netbeansArg[3] == '=')
|
|
251 {
|
|
252 /* "-nb=fname": Read info from specified file. */
|
|
253 if (getConnInfo(netbeansArg + 4, &hostname, &address, &password)
|
|
254 == FAIL)
|
|
255 return;
|
|
256 }
|
|
257 else
|
|
258 {
|
|
259 if (netbeansArg[3] == ':')
|
|
260 /* "-nb:<host>:<addr>:<password>": get info from argument */
|
|
261 arg = netbeansArg + 4;
|
|
262 if (arg == NULL && (fname = getenv("__NETBEANS_CONINFO")) != NULL)
|
|
263 {
|
|
264 /* "-nb": get info from file specified in environment */
|
|
265 if (getConnInfo(fname, &hostname, &address, &password) == FAIL)
|
|
266 return;
|
|
267 }
|
|
268 else
|
|
269 {
|
|
270 if (arg != NULL)
|
|
271 {
|
|
272 /* "-nb:<host>:<addr>:<password>": get info from argument */
|
|
273 hostname = arg;
|
|
274 address = strchr(hostname, ':');
|
|
275 if (address != NULL)
|
|
276 {
|
|
277 *address++ = '\0';
|
|
278 password = strchr(address, ':');
|
|
279 if (password != NULL)
|
|
280 *password++ = '\0';
|
|
281 }
|
|
282 }
|
|
283
|
|
284 /* Get the missing values from the environment. */
|
|
285 if (hostname == NULL || *hostname == '\0')
|
|
286 hostname = getenv("__NETBEANS_HOST");
|
|
287 if (address == NULL)
|
|
288 address = getenv("__NETBEANS_SOCKET");
|
|
289 if (password == NULL)
|
|
290 password = getenv("__NETBEANS_VIM_PASSWORD");
|
|
291
|
|
292 /* Move values to allocated memory. */
|
|
293 if (hostname != NULL)
|
|
294 hostname = (char *)vim_strsave((char_u *)hostname);
|
|
295 if (address != NULL)
|
|
296 address = (char *)vim_strsave((char_u *)address);
|
|
297 if (password != NULL)
|
|
298 password = (char *)vim_strsave((char_u *)password);
|
|
299 }
|
|
300 }
|
|
301
|
|
302 /* Use the default when a value is missing. */
|
|
303 if (hostname == NULL || *hostname == '\0')
|
|
304 {
|
|
305 vim_free(hostname);
|
|
306 hostname = (char *)vim_strsave((char_u *)NB_DEF_HOST);
|
|
307 }
|
|
308 if (address == NULL || *address == '\0')
|
|
309 {
|
|
310 vim_free(address);
|
|
311 address = (char *)vim_strsave((char_u *)NB_DEF_ADDR);
|
|
312 }
|
|
313 if (password == NULL || *password == '\0')
|
|
314 {
|
|
315 vim_free(password);
|
|
316 password = (char *)vim_strsave((char_u *)NB_DEF_PASS);
|
|
317 }
|
|
318 if (hostname == NULL || address == NULL || password == NULL)
|
|
319 goto theend; /* out of memory */
|
|
320
|
|
321 #ifdef INET_SOCKETS
|
|
322 port = atoi(address);
|
|
323
|
835
|
324 if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
|
7
|
325 {
|
|
326 PERROR("socket() in netbeans_connect()");
|
|
327 goto theend;
|
|
328 }
|
|
329
|
|
330 /* Get the server internet address and put into addr structure */
|
|
331 /* fill in the socket address structure and connect to server */
|
|
332 memset((char *)&server, '\0', sizeof(server));
|
|
333 server.sin_family = AF_INET;
|
|
334 server.sin_port = htons(port);
|
|
335 if ((host = gethostbyname(hostname)) == NULL)
|
|
336 {
|
|
337 if (mch_access(hostname, R_OK) >= 0)
|
|
338 {
|
|
339 /* DEBUG: input file */
|
|
340 sd = mch_open(hostname, O_RDONLY, 0);
|
|
341 goto theend;
|
|
342 }
|
|
343 PERROR("gethostbyname() in netbeans_connect()");
|
|
344 sd = -1;
|
|
345 goto theend;
|
|
346 }
|
|
347 memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
|
|
348 #else
|
|
349 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
|
350 {
|
|
351 PERROR("socket()");
|
|
352 goto theend;
|
|
353 }
|
|
354
|
|
355 server.sun_family = AF_UNIX;
|
|
356 strcpy(server.sun_path, address);
|
|
357 #endif
|
|
358 /* Connect to server */
|
|
359 if (connect(sd, (struct sockaddr *)&server, sizeof(server)))
|
|
360 {
|
|
361 nbdebug(("netbeans_connect: Connect failed with errno %d\n", sock_errno));
|
|
362 if (sock_errno == ECONNREFUSED)
|
|
363 {
|
|
364 sock_close(sd);
|
|
365 #ifdef INET_SOCKETS
|
835
|
366 if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
|
7
|
367 {
|
|
368 PERROR("socket()#2 in netbeans_connect()");
|
|
369 goto theend;
|
|
370 }
|
|
371 #else
|
|
372 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
|
373 {
|
|
374 PERROR("socket()#2 in netbeans_connect()");
|
|
375 goto theend;
|
|
376 }
|
|
377 #endif
|
|
378 if (connect(sd, (struct sockaddr *)&server, sizeof(server)))
|
|
379 {
|
|
380 int retries = 36;
|
|
381 int success = FALSE;
|
|
382 while (retries--
|
|
383 && ((sock_errno == ECONNREFUSED) || (sock_errno == EINTR)))
|
|
384 {
|
|
385 nbdebug(("retrying...\n"));
|
|
386 sleep(5);
|
|
387 if (connect(sd, (struct sockaddr *)&server,
|
|
388 sizeof(server)) == 0)
|
|
389 {
|
|
390 success = TRUE;
|
|
391 break;
|
|
392 }
|
|
393 }
|
|
394 if (!success)
|
|
395 {
|
|
396 /* Get here when the server can't be found. */
|
|
397 PERROR(_("Cannot connect to Netbeans #2"));
|
|
398 getout(1);
|
|
399 }
|
|
400 }
|
|
401
|
|
402 }
|
|
403 else
|
|
404 {
|
|
405 PERROR(_("Cannot connect to Netbeans"));
|
|
406 getout(1);
|
|
407 }
|
|
408 }
|
|
409
|
272
|
410 vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password);
|
7
|
411 nb_send(buf, "netbeans_connect");
|
|
412
|
|
413 sprintf(buf, "0:version=0 \"%s\"\n", ExtEdProtocolVersion);
|
|
414 nb_send(buf, "externaleditor_version");
|
|
415
|
|
416 /* nb_init_graphics(); delay until needed */
|
|
417
|
|
418 haveConnection = TRUE;
|
|
419
|
|
420 theend:
|
|
421 vim_free(hostname);
|
|
422 vim_free(address);
|
|
423 vim_free(password);
|
|
424 return;
|
|
425 }
|
|
426
|
|
427 /*
|
|
428 * Obtain the NetBeans hostname, port address and password from a file.
|
|
429 * Return the strings in allocated memory.
|
|
430 * Return FAIL if the file could not be read, OK otherwise (no matter what it
|
|
431 * contains).
|
|
432 */
|
|
433 static int
|
|
434 getConnInfo(char *file, char **host, char **port, char **auth)
|
|
435 {
|
|
436 FILE *fp;
|
|
437 char_u buf[BUFSIZ];
|
|
438 char_u *lp;
|
|
439 char_u *nl;
|
|
440 #ifdef UNIX
|
|
441 struct stat st;
|
|
442
|
|
443 /*
|
|
444 * For Unix only accept the file when it's not accessible by others.
|
|
445 * The open will then fail if we don't own the file.
|
|
446 */
|
|
447 if (mch_stat(file, &st) == 0 && (st.st_mode & 0077) != 0)
|
|
448 {
|
|
449 EMSG2(_("E668: Wrong access mode for NetBeans connection info file: \"%s\""),
|
|
450 file);
|
|
451 return FAIL;
|
|
452 }
|
|
453 #endif
|
|
454
|
|
455 fp = mch_fopen(file, "r");
|
|
456 if (fp == NULL)
|
|
457 {
|
|
458 PERROR("E660: Cannot open NetBeans connection info file");
|
|
459 return FAIL;
|
|
460 }
|
|
461
|
|
462 /* Read the file. There should be one of each parameter */
|
|
463 while ((lp = (char_u *)fgets((char *)buf, BUFSIZ, fp)) != NULL)
|
|
464 {
|
|
465 if ((nl = vim_strchr(lp, '\n')) != NULL)
|
|
466 *nl = 0; /* strip off the trailing newline */
|
|
467
|
|
468 if (STRNCMP(lp, "host=", 5) == 0)
|
|
469 {
|
|
470 vim_free(*host);
|
|
471 *host = (char *)vim_strsave(&buf[5]);
|
|
472 }
|
|
473 else if (STRNCMP(lp, "port=", 5) == 0)
|
|
474 {
|
|
475 vim_free(*port);
|
|
476 *port = (char *)vim_strsave(&buf[5]);
|
|
477 }
|
|
478 else if (STRNCMP(lp, "auth=", 5) == 0)
|
|
479 {
|
|
480 vim_free(*auth);
|
|
481 *auth = (char *)vim_strsave(&buf[5]);
|
|
482 }
|
|
483 }
|
|
484 fclose(fp);
|
|
485
|
|
486 return OK;
|
|
487 }
|
|
488
|
|
489
|
|
490 struct keyqueue
|
|
491 {
|
|
492 int key;
|
|
493 struct keyqueue *next;
|
|
494 struct keyqueue *prev;
|
|
495 };
|
|
496
|
|
497 typedef struct keyqueue keyQ_T;
|
|
498
|
|
499 static keyQ_T keyHead; /* dummy node, header for circular queue */
|
|
500
|
|
501
|
|
502 /*
|
|
503 * Queue up key commands sent from netbeans.
|
|
504 */
|
|
505 static void
|
|
506 postpone_keycommand(int key)
|
|
507 {
|
|
508 keyQ_T *node;
|
|
509
|
|
510 node = (keyQ_T *)alloc(sizeof(keyQ_T));
|
|
511
|
|
512 if (keyHead.next == NULL) /* initialize circular queue */
|
|
513 {
|
|
514 keyHead.next = &keyHead;
|
|
515 keyHead.prev = &keyHead;
|
|
516 }
|
|
517
|
|
518 /* insert node at tail of queue */
|
|
519 node->next = &keyHead;
|
|
520 node->prev = keyHead.prev;
|
|
521 keyHead.prev->next = node;
|
|
522 keyHead.prev = node;
|
|
523
|
|
524 node->key = key;
|
|
525 }
|
|
526
|
|
527 /*
|
|
528 * Handle any queued-up NetBeans keycommands to be send.
|
|
529 */
|
|
530 static void
|
|
531 handle_key_queue(void)
|
|
532 {
|
|
533 while (keyHead.next && keyHead.next != &keyHead)
|
|
534 {
|
|
535 /* first, unlink the node */
|
|
536 keyQ_T *node = keyHead.next;
|
|
537 keyHead.next = node->next;
|
|
538 node->next->prev = node->prev;
|
|
539
|
|
540 /* now, send the keycommand */
|
|
541 netbeans_keycommand(node->key);
|
|
542
|
|
543 /* Finally, dispose of the node */
|
|
544 vim_free(node);
|
|
545 }
|
|
546 }
|
|
547
|
|
548
|
|
549 struct cmdqueue
|
|
550 {
|
|
551 char_u *buffer;
|
|
552 struct cmdqueue *next;
|
|
553 struct cmdqueue *prev;
|
|
554 };
|
|
555
|
|
556 typedef struct cmdqueue queue_T;
|
|
557
|
|
558 static queue_T head; /* dummy node, header for circular queue */
|
|
559
|
|
560
|
|
561 /*
|
|
562 * Put the buffer on the work queue; possibly save it to a file as well.
|
|
563 */
|
|
564 static void
|
|
565 save(char_u *buf, int len)
|
|
566 {
|
|
567 queue_T *node;
|
|
568
|
|
569 node = (queue_T *)alloc(sizeof(queue_T));
|
|
570 if (node == NULL)
|
|
571 return; /* out of memory */
|
|
572 node->buffer = alloc(len + 1);
|
|
573 if (node->buffer == NULL)
|
|
574 {
|
|
575 vim_free(node);
|
|
576 return; /* out of memory */
|
|
577 }
|
|
578 mch_memmove(node->buffer, buf, (size_t)len);
|
|
579 node->buffer[len] = NUL;
|
|
580
|
|
581 if (head.next == NULL) /* initialize circular queue */
|
|
582 {
|
|
583 head.next = &head;
|
|
584 head.prev = &head;
|
|
585 }
|
|
586
|
|
587 /* insert node at tail of queue */
|
|
588 node->next = &head;
|
|
589 node->prev = head.prev;
|
|
590 head.prev->next = node;
|
|
591 head.prev = node;
|
|
592
|
|
593 #ifdef NBDEBUG
|
|
594 {
|
|
595 static int outfd = -2;
|
|
596
|
|
597 /* possibly write buffer out to a file */
|
|
598 if (outfd == -3)
|
|
599 return;
|
|
600
|
|
601 if (outfd == -2)
|
|
602 {
|
|
603 char *file = getenv("__NETBEANS_SAVE");
|
|
604 if (file == NULL)
|
|
605 outfd = -3;
|
|
606 else
|
|
607 outfd = mch_open(file, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
|
608 }
|
|
609
|
|
610 if (outfd >= 0)
|
|
611 write(outfd, buf, len);
|
|
612 }
|
|
613 #endif
|
|
614 }
|
|
615
|
|
616
|
|
617 /*
|
|
618 * While there's still a command in the work queue, parse and execute it.
|
|
619 */
|
|
620 static void
|
|
621 nb_parse_messages(void)
|
|
622 {
|
|
623 char_u *p;
|
|
624 queue_T *node;
|
|
625
|
|
626 while (head.next != &head)
|
|
627 {
|
|
628 node = head.next;
|
|
629
|
|
630 /* Locate the first line in the first buffer. */
|
|
631 p = vim_strchr(node->buffer, '\n');
|
|
632 if (p == NULL)
|
|
633 {
|
|
634 /* Command isn't complete. If there is no following buffer,
|
|
635 * return (wait for more). If there is another buffer following,
|
|
636 * prepend the text to that buffer and delete this one. */
|
|
637 if (node->next == &head)
|
|
638 return;
|
835
|
639 p = alloc((unsigned)(STRLEN(node->buffer) + STRLEN(node->next->buffer) + 1));
|
7
|
640 if (p == NULL)
|
|
641 return; /* out of memory */
|
|
642 STRCPY(p, node->buffer);
|
|
643 STRCAT(p, node->next->buffer);
|
|
644 vim_free(node->next->buffer);
|
|
645 node->next->buffer = p;
|
|
646
|
|
647 /* dispose of the node and buffer */
|
|
648 head.next = node->next;
|
|
649 node->next->prev = node->prev;
|
|
650 vim_free(node->buffer);
|
|
651 vim_free(node);
|
|
652 }
|
|
653 else
|
|
654 {
|
|
655 /* There is a complete command at the start of the buffer.
|
|
656 * Terminate it with a NUL. When no more text is following unlink
|
|
657 * the buffer. Do this before executing, because new buffers can
|
|
658 * be added while busy handling the command. */
|
|
659 *p++ = NUL;
|
|
660 if (*p == NUL)
|
|
661 {
|
|
662 head.next = node->next;
|
|
663 node->next->prev = node->prev;
|
|
664 }
|
|
665
|
|
666 /* now, parse and execute the commands */
|
|
667 nb_parse_cmd(node->buffer);
|
|
668
|
|
669 if (*p == NUL)
|
|
670 {
|
|
671 /* buffer finished, dispose of the node and buffer */
|
|
672 vim_free(node->buffer);
|
|
673 vim_free(node);
|
|
674 }
|
|
675 else
|
|
676 {
|
|
677 /* more follows, move to the start */
|
|
678 mch_memmove(node->buffer, p, STRLEN(p) + 1);
|
|
679 }
|
|
680 }
|
|
681 }
|
|
682 }
|
|
683
|
|
684 /* Buffer size for reading incoming messages. */
|
|
685 #define MAXMSGSIZE 4096
|
|
686
|
|
687 /*
|
|
688 * Read and process a command from netbeans.
|
|
689 */
|
|
690 /*ARGSUSED*/
|
|
691 #if defined(FEAT_GUI_W32) || defined(PROTO)
|
|
692 /* Use this one when generating prototypes, the others are static. */
|
|
693 void
|
|
694 messageFromNetbeansW32()
|
|
695 #else
|
|
696 # ifdef FEAT_GUI_MOTIF
|
|
697 static void
|
|
698 messageFromNetbeans(XtPointer clientData, int *unused1, XtInputId *unused2)
|
|
699 # endif
|
|
700 # ifdef FEAT_GUI_GTK
|
|
701 static void
|
|
702 messageFromNetbeans(gpointer clientData, gint unused1,
|
|
703 GdkInputCondition unused2)
|
|
704 # endif
|
|
705 #endif
|
|
706 {
|
|
707 static char_u *buf = NULL;
|
|
708 int len;
|
|
709 int readlen = 0;
|
|
710 static int level = 0;
|
|
711
|
|
712 if (sd < 0)
|
|
713 {
|
|
714 nbdebug(("messageFromNetbeans() called without a socket\n"));
|
|
715 return;
|
|
716 }
|
|
717
|
|
718 ++level; /* recursion guard; this will be called from the X event loop */
|
|
719
|
|
720 /* Allocate a buffer to read into. */
|
|
721 if (buf == NULL)
|
|
722 {
|
|
723 buf = alloc(MAXMSGSIZE);
|
|
724 if (buf == NULL)
|
|
725 return; /* out of memory! */
|
|
726 }
|
|
727
|
|
728 /* Keep on reading for as long as there is something to read. */
|
|
729 for (;;)
|
|
730 {
|
|
731 len = sock_read(sd, buf, MAXMSGSIZE);
|
|
732 if (len <= 0)
|
|
733 break; /* error or nothing more to read */
|
|
734
|
|
735 /* Store the read message in the queue. */
|
|
736 save(buf, len);
|
|
737 readlen += len;
|
|
738 if (len < MAXMSGSIZE)
|
|
739 break; /* did read everything that's available */
|
|
740 }
|
|
741
|
|
742 if (readlen <= 0)
|
|
743 {
|
|
744 /* read error or didn't read anything */
|
|
745 netbeans_disconnect();
|
|
746 nbdebug(("messageFromNetbeans: Error in read() from socket\n"));
|
|
747 if (len < 0)
|
|
748 PERROR(_("read from Netbeans socket"));
|
344
|
749 return; /* don't try to parse it */
|
7
|
750 }
|
|
751
|
|
752 /* Parse the messages, but avoid recursion. */
|
|
753 if (level == 1)
|
|
754 nb_parse_messages();
|
|
755
|
|
756 --level;
|
|
757 }
|
|
758
|
|
759 /*
|
|
760 * Handle one NUL terminated command.
|
|
761 *
|
|
762 * format of a command from netbeans:
|
|
763 *
|
|
764 * 6:setTitle!84 "a.c"
|
|
765 *
|
|
766 * bufno
|
|
767 * colon
|
|
768 * cmd
|
|
769 * !
|
|
770 * cmdno
|
|
771 * args
|
|
772 *
|
|
773 * for function calls, the ! is replaced by a /
|
|
774 */
|
|
775 static void
|
|
776 nb_parse_cmd(char_u *cmd)
|
|
777 {
|
27
|
778 char *verb;
|
|
779 char *q;
|
7
|
780 int bufno;
|
|
781 int isfunc = -1;
|
|
782
|
|
783 if (STRCMP(cmd, "DISCONNECT") == 0)
|
|
784 {
|
|
785 /* We assume the server knows that we can safely exit! */
|
|
786 if (sd >= 0)
|
|
787 sock_close(sd);
|
|
788 /* Disconnect before exiting, Motif hangs in a Select error
|
|
789 * message otherwise. */
|
|
790 netbeans_disconnect();
|
|
791 getout(0);
|
|
792 /* NOTREACHED */
|
|
793 }
|
|
794
|
|
795 if (STRCMP(cmd, "DETACH") == 0)
|
|
796 {
|
|
797 /* The IDE is breaking the connection. */
|
|
798 if (sd >= 0)
|
|
799 sock_close(sd);
|
|
800 netbeans_disconnect();
|
|
801 return;
|
|
802 }
|
|
803
|
27
|
804 bufno = strtol((char *)cmd, &verb, 10);
|
7
|
805
|
|
806 if (*verb != ':')
|
|
807 {
|
|
808 EMSG2("E627: missing colon: %s", cmd);
|
|
809 return;
|
|
810 }
|
|
811 ++verb; /* skip colon */
|
|
812
|
|
813 for (q = verb; *q; q++)
|
|
814 {
|
|
815 if (*q == '!')
|
|
816 {
|
|
817 *q++ = NUL;
|
|
818 isfunc = 0;
|
|
819 break;
|
|
820 }
|
|
821 else if (*q == '/')
|
|
822 {
|
|
823 *q++ = NUL;
|
|
824 isfunc = 1;
|
|
825 break;
|
|
826 }
|
|
827 }
|
|
828
|
|
829 if (isfunc < 0)
|
|
830 {
|
|
831 EMSG2("E628: missing ! or / in: %s", cmd);
|
|
832 return;
|
|
833 }
|
|
834
|
944
|
835 r_cmdno = strtol(q, &q, 10);
|
27
|
836
|
|
837 q = (char *)skipwhite((char_u *)q);
|
|
838
|
944
|
839 if (nb_do_cmd(bufno, (char_u *)verb, isfunc, r_cmdno, (char_u *)q) == FAIL)
|
7
|
840 {
|
33
|
841 #ifdef NBDEBUG
|
|
842 /*
|
|
843 * This happens because the ExtEd can send a cammand or 2 after
|
|
844 * doing a stopDocumentListen command. It doesn't harm anything
|
|
845 * so I'm disabling it except for debugging.
|
|
846 */
|
7
|
847 nbdebug(("nb_parse_cmd: Command error for \"%s\"\n", cmd));
|
|
848 EMSG("E629: bad return from nb_do_cmd");
|
33
|
849 #endif
|
7
|
850 }
|
|
851 }
|
|
852
|
|
853 struct nbbuf_struct
|
|
854 {
|
|
855 buf_T *bufp;
|
|
856 unsigned int fireChanges:1;
|
|
857 unsigned int initDone:1;
|
33
|
858 unsigned int insertDone:1;
|
7
|
859 unsigned int modified:1;
|
33
|
860 int nbbuf_number;
|
7
|
861 char *displayname;
|
|
862 int *signmap;
|
|
863 short_u signmaplen;
|
|
864 short_u signmapused;
|
|
865 };
|
|
866
|
|
867 typedef struct nbbuf_struct nbbuf_T;
|
|
868
|
|
869 static nbbuf_T *buf_list = 0;
|
344
|
870 static int buf_list_size = 0; /* size of buf_list */
|
|
871 static int buf_list_used = 0; /* nr of entries in buf_list actually in use */
|
7
|
872
|
|
873 static char **globalsignmap;
|
|
874 static int globalsignmaplen;
|
|
875 static int globalsignmapused;
|
|
876
|
|
877 static int mapsigntype __ARGS((nbbuf_T *, int localsigntype));
|
|
878 static void addsigntype __ARGS((nbbuf_T *, int localsigntype, char_u *typeName,
|
|
879 char_u *tooltip, char_u *glyphfile,
|
|
880 int usefg, int fg, int usebg, int bg));
|
33
|
881 static void print_read_msg __ARGS((nbbuf_T *buf));
|
|
882 static void print_save_msg __ARGS((nbbuf_T *buf, long nchars));
|
7
|
883
|
|
884 static int curPCtype = -1;
|
|
885
|
|
886 /*
|
|
887 * Get the Netbeans buffer number for the specified buffer.
|
|
888 */
|
|
889 static int
|
|
890 nb_getbufno(buf_T *bufp)
|
|
891 {
|
|
892 int i;
|
|
893
|
|
894 for (i = 0; i < buf_list_used; i++)
|
|
895 if (buf_list[i].bufp == bufp)
|
|
896 return i;
|
|
897 return -1;
|
|
898 }
|
|
899
|
|
900 /*
|
|
901 * Is this a NetBeans-owned buffer?
|
|
902 */
|
|
903 int
|
|
904 isNetbeansBuffer(buf_T *bufp)
|
|
905 {
|
33
|
906 return usingNetbeans && bufp->b_netbeans_file;
|
7
|
907 }
|
|
908
|
|
909 /*
|
|
910 * NetBeans and Vim have different undo models. In Vim, the file isn't
|
|
911 * changed if changes are undone via the undo command. In NetBeans, once
|
|
912 * a change has been made the file is marked as modified until saved. It
|
|
913 * doesn't matter if the change was undone.
|
|
914 *
|
|
915 * So this function is for the corner case where Vim thinks a buffer is
|
|
916 * unmodified but NetBeans thinks it IS modified.
|
|
917 */
|
|
918 int
|
|
919 isNetbeansModified(buf_T *bufp)
|
|
920 {
|
33
|
921 if (usingNetbeans && bufp->b_netbeans_file)
|
|
922 {
|
|
923 int bufno = nb_getbufno(bufp);
|
|
924
|
|
925 if (bufno > 0)
|
|
926 return buf_list[bufno].modified;
|
|
927 else
|
|
928 return FALSE;
|
|
929 }
|
7
|
930 else
|
|
931 return FALSE;
|
|
932 }
|
|
933
|
|
934 /*
|
|
935 * Given a Netbeans buffer number, return the netbeans buffer.
|
|
936 * Returns NULL for 0 or a negative number. A 0 bufno means a
|
|
937 * non-buffer related command has been sent.
|
|
938 */
|
|
939 static nbbuf_T *
|
|
940 nb_get_buf(int bufno)
|
|
941 {
|
|
942 /* find or create a buffer with the given number */
|
|
943 int incr;
|
|
944
|
|
945 if (bufno <= 0)
|
|
946 return NULL;
|
|
947
|
|
948 if (!buf_list)
|
|
949 {
|
|
950 /* initialize */
|
|
951 buf_list = (nbbuf_T *)alloc_clear(100 * sizeof(nbbuf_T));
|
|
952 buf_list_size = 100;
|
|
953 }
|
|
954 if (bufno >= buf_list_used) /* new */
|
|
955 {
|
|
956 if (bufno >= buf_list_size) /* grow list */
|
|
957 {
|
|
958 incr = bufno - buf_list_size + 90;
|
|
959 buf_list_size += incr;
|
|
960 buf_list = (nbbuf_T *)vim_realloc(
|
|
961 buf_list, buf_list_size * sizeof(nbbuf_T));
|
|
962 memset(buf_list + buf_list_size - incr, 0, incr * sizeof(nbbuf_T));
|
|
963 }
|
|
964
|
|
965 while (buf_list_used <= bufno)
|
|
966 {
|
|
967 /* Default is to fire text changes. */
|
|
968 buf_list[buf_list_used].fireChanges = 1;
|
|
969 ++buf_list_used;
|
|
970 }
|
|
971 }
|
|
972
|
|
973 return buf_list + bufno;
|
|
974 }
|
|
975
|
|
976 /*
|
|
977 * Return the number of buffers that are modified.
|
|
978 */
|
|
979 static int
|
|
980 count_changed_buffers(void)
|
|
981 {
|
|
982 buf_T *bufp;
|
|
983 int n;
|
|
984
|
|
985 n = 0;
|
|
986 for (bufp = firstbuf; bufp != NULL; bufp = bufp->b_next)
|
|
987 if (bufp->b_changed)
|
|
988 ++n;
|
|
989 return n;
|
|
990 }
|
|
991
|
|
992 /*
|
|
993 * End the netbeans session.
|
|
994 */
|
|
995 void
|
|
996 netbeans_end(void)
|
|
997 {
|
|
998 int i;
|
|
999 static char buf[128];
|
|
1000
|
|
1001 if (!haveConnection)
|
|
1002 return;
|
|
1003
|
|
1004 for (i = 0; i < buf_list_used; i++)
|
|
1005 {
|
|
1006 if (!buf_list[i].bufp)
|
|
1007 continue;
|
|
1008 if (netbeansForcedQuit)
|
|
1009 {
|
|
1010 /* mark as unmodified so NetBeans won't put up dialog on "killed" */
|
944
|
1011 sprintf(buf, "%d:unmodified=%d\n", i, r_cmdno);
|
7
|
1012 nbdebug(("EVT: %s", buf));
|
|
1013 nb_send(buf, "netbeans_end");
|
|
1014 }
|
944
|
1015 sprintf(buf, "%d:killed=%d\n", i, r_cmdno);
|
7
|
1016 nbdebug(("EVT: %s", buf));
|
|
1017 /* nb_send(buf, "netbeans_end"); avoid "write failed" messages */
|
|
1018 if (sd >= 0)
|
835
|
1019 sock_write(sd, buf, (int)STRLEN(buf)); /* ignore errors */
|
7
|
1020 }
|
|
1021 }
|
|
1022
|
|
1023 /*
|
|
1024 * Send a message to netbeans.
|
|
1025 */
|
|
1026 static void
|
|
1027 nb_send(char *buf, char *fun)
|
|
1028 {
|
|
1029 /* Avoid giving pages full of error messages when the other side has
|
|
1030 * exited, only mention the first error until the connection works again. */
|
|
1031 static int did_error = FALSE;
|
|
1032
|
|
1033 if (sd < 0)
|
|
1034 {
|
|
1035 if (!did_error)
|
|
1036 EMSG2("E630: %s(): write while not connected", fun);
|
|
1037 did_error = TRUE;
|
|
1038 }
|
835
|
1039 else if (sock_write(sd, buf, (int)STRLEN(buf)) != (int)STRLEN(buf))
|
7
|
1040 {
|
|
1041 if (!did_error)
|
|
1042 EMSG2("E631: %s(): write failed", fun);
|
|
1043 did_error = TRUE;
|
|
1044 }
|
|
1045 else
|
|
1046 did_error = FALSE;
|
|
1047 }
|
|
1048
|
|
1049 /*
|
|
1050 * Some input received from netbeans requires a response. This function
|
|
1051 * handles a response with no information (except the command number).
|
|
1052 */
|
|
1053 static void
|
|
1054 nb_reply_nil(int cmdno)
|
|
1055 {
|
|
1056 char reply[32];
|
|
1057
|
|
1058 if (!haveConnection)
|
|
1059 return;
|
|
1060
|
33
|
1061 nbdebug(("REP %d: <none>\n", cmdno));
|
|
1062
|
7
|
1063 sprintf(reply, "%d\n", cmdno);
|
|
1064 nb_send(reply, "nb_reply_nil");
|
|
1065 }
|
|
1066
|
|
1067
|
|
1068 /*
|
|
1069 * Send a response with text.
|
|
1070 * "result" must have been quoted already (using nb_quote()).
|
|
1071 */
|
|
1072 static void
|
|
1073 nb_reply_text(int cmdno, char_u *result)
|
|
1074 {
|
|
1075 char_u *reply;
|
|
1076
|
|
1077 if (!haveConnection)
|
|
1078 return;
|
|
1079
|
33
|
1080 nbdebug(("REP %d: %s\n", cmdno, (char *)result));
|
|
1081
|
835
|
1082 reply = alloc((unsigned)STRLEN(result) + 32);
|
7
|
1083 sprintf((char *)reply, "%d %s\n", cmdno, (char *)result);
|
|
1084 nb_send((char *)reply, "nb_reply_text");
|
|
1085
|
|
1086 vim_free(reply);
|
|
1087 }
|
|
1088
|
|
1089
|
|
1090 /*
|
|
1091 * Send a response with a number result code.
|
|
1092 */
|
|
1093 static void
|
|
1094 nb_reply_nr(int cmdno, long result)
|
|
1095 {
|
|
1096 char reply[32];
|
|
1097
|
|
1098 if (!haveConnection)
|
|
1099 return;
|
|
1100
|
33
|
1101 nbdebug(("REP %d: %ld\n", cmdno, result));
|
|
1102
|
7
|
1103 sprintf(reply, "%d %ld\n", cmdno, result);
|
|
1104 nb_send(reply, "nb_reply_nr");
|
|
1105 }
|
|
1106
|
|
1107
|
|
1108 /*
|
|
1109 * Encode newline, ret, backslash, double quote for transmission to NetBeans.
|
|
1110 */
|
|
1111 static char_u *
|
|
1112 nb_quote(char_u *txt)
|
|
1113 {
|
835
|
1114 char_u *buf = alloc((unsigned)(2 * STRLEN(txt) + 1));
|
7
|
1115 char_u *p = txt;
|
|
1116 char_u *q = buf;
|
|
1117
|
|
1118 if (buf == NULL)
|
|
1119 return NULL;
|
|
1120 for (; *p; p++)
|
|
1121 {
|
|
1122 switch (*p)
|
|
1123 {
|
|
1124 case '\"':
|
|
1125 case '\\':
|
|
1126 *q++ = '\\'; *q++ = *p; break;
|
|
1127 /* case '\t': */
|
|
1128 /* *q++ = '\\'; *q++ = 't'; break; */
|
|
1129 case '\n':
|
|
1130 *q++ = '\\'; *q++ = 'n'; break;
|
|
1131 case '\r':
|
|
1132 *q++ = '\\'; *q++ = 'r'; break;
|
|
1133 default:
|
|
1134 *q++ = *p;
|
|
1135 break;
|
|
1136 }
|
|
1137 }
|
|
1138 *q++ = '\0';
|
|
1139
|
|
1140 return buf;
|
|
1141 }
|
|
1142
|
|
1143
|
|
1144 /*
|
|
1145 * Remove top level double quotes; convert backslashed chars.
|
|
1146 * Returns an allocated string (NULL for failure).
|
|
1147 * If "endp" is not NULL it is set to the character after the terminating
|
|
1148 * quote.
|
|
1149 */
|
|
1150 static char *
|
|
1151 nb_unquote(char_u *p, char_u **endp)
|
|
1152 {
|
|
1153 char *result = 0;
|
|
1154 char *q;
|
|
1155 int done = 0;
|
|
1156
|
|
1157 /* result is never longer than input */
|
835
|
1158 result = (char *)alloc_clear((unsigned)STRLEN(p) + 1);
|
7
|
1159 if (result == NULL)
|
|
1160 return NULL;
|
|
1161
|
|
1162 if (*p++ != '"')
|
|
1163 {
|
|
1164 nbdebug(("nb_unquote called with string that doesn't start with a quote!: %s\n",
|
|
1165 p));
|
|
1166 result[0] = NUL;
|
|
1167 return result;
|
|
1168 }
|
|
1169
|
|
1170 for (q = result; !done && *p != NUL;)
|
|
1171 {
|
|
1172 switch (*p)
|
|
1173 {
|
|
1174 case '"':
|
|
1175 /*
|
|
1176 * Unbackslashed dquote marks the end, if first char was dquote.
|
|
1177 */
|
|
1178 done = 1;
|
|
1179 break;
|
|
1180
|
|
1181 case '\\':
|
|
1182 ++p;
|
|
1183 switch (*p)
|
|
1184 {
|
|
1185 case '\\': *q++ = '\\'; break;
|
|
1186 case 'n': *q++ = '\n'; break;
|
|
1187 case 't': *q++ = '\t'; break;
|
|
1188 case 'r': *q++ = '\r'; break;
|
|
1189 case '"': *q++ = '"'; break;
|
|
1190 case NUL: --p; break;
|
|
1191 /* default: skip over illegal chars */
|
|
1192 }
|
|
1193 ++p;
|
|
1194 break;
|
|
1195
|
|
1196 default:
|
|
1197 *q++ = *p++;
|
|
1198 }
|
|
1199 }
|
|
1200
|
|
1201 if (endp != NULL)
|
|
1202 *endp = p;
|
|
1203
|
|
1204 return result;
|
|
1205 }
|
|
1206
|
|
1207 #define SKIP_STOP 2
|
|
1208 #define streq(a,b) (strcmp(a,b) == 0)
|
|
1209 static int needupdate = 0;
|
|
1210 static int inAtomic = 0;
|
|
1211
|
|
1212 /*
|
|
1213 * Do the actual processing of a single netbeans command or function.
|
|
1214 * The differance between a command and function is that a function
|
|
1215 * gets a response (its required) but a command does not.
|
|
1216 * For arguments see comment for nb_parse_cmd().
|
|
1217 */
|
|
1218 static int
|
|
1219 nb_do_cmd(
|
|
1220 int bufno,
|
|
1221 char_u *cmd,
|
|
1222 int func,
|
|
1223 int cmdno,
|
|
1224 char_u *args) /* points to space before arguments or NUL */
|
|
1225 {
|
|
1226 int doupdate = 0;
|
|
1227 long off = 0;
|
|
1228 nbbuf_T *buf = nb_get_buf(bufno);
|
|
1229 static int skip = 0;
|
|
1230 int retval = OK;
|
27
|
1231 char *cp; /* for when a char pointer is needed */
|
7
|
1232
|
|
1233 nbdebug(("%s %d: (%d) %s %s\n", (func) ? "FUN" : "CMD", cmdno, bufno, cmd,
|
|
1234 STRCMP(cmd, "insert") == 0 ? "<text>" : (char *)args));
|
|
1235
|
|
1236 if (func)
|
|
1237 {
|
|
1238 /* =====================================================================*/
|
|
1239 if (streq((char *)cmd, "getModified"))
|
|
1240 {
|
|
1241 if (buf == NULL || buf->bufp == NULL)
|
|
1242 /* Return the number of buffers that are modified. */
|
|
1243 nb_reply_nr(cmdno, (long)count_changed_buffers());
|
|
1244 else
|
|
1245 /* Return whether the buffer is modified. */
|
|
1246 nb_reply_nr(cmdno, (long)(buf->bufp->b_changed
|
|
1247 || isNetbeansModified(buf->bufp)));
|
|
1248 /* =====================================================================*/
|
|
1249 }
|
|
1250 else if (streq((char *)cmd, "saveAndExit"))
|
|
1251 {
|
|
1252 /* Note: this will exit Vim if successful. */
|
|
1253 coloncmd(":confirm qall");
|
|
1254
|
|
1255 /* We didn't exit: return the number of changed buffers. */
|
|
1256 nb_reply_nr(cmdno, (long)count_changed_buffers());
|
|
1257 /* =====================================================================*/
|
|
1258 }
|
|
1259 else if (streq((char *)cmd, "getCursor"))
|
|
1260 {
|
|
1261 char_u text[200];
|
|
1262
|
|
1263 /* Note: nb_getbufno() may return -1. This indicates the IDE
|
|
1264 * didn't assign a number to the current buffer in response to a
|
|
1265 * fileOpened event. */
|
|
1266 sprintf((char *)text, "%d %ld %d %ld",
|
|
1267 nb_getbufno(curbuf),
|
|
1268 (long)curwin->w_cursor.lnum,
|
|
1269 (int)curwin->w_cursor.col,
|
|
1270 pos2off(curbuf, &curwin->w_cursor));
|
|
1271 nb_reply_text(cmdno, text);
|
|
1272 /* =====================================================================*/
|
|
1273 }
|
1037
|
1274 else if (streq((char *)cmd, "getAnno"))
|
|
1275 {
|
|
1276 long linenum = 0;
|
|
1277 #ifdef FEAT_SIGNS
|
|
1278 if (buf == NULL || buf->bufp == NULL)
|
|
1279 {
|
|
1280 nbdebug((" null bufp in getAnno"));
|
|
1281 EMSG("E652: null bufp in getAnno");
|
|
1282 retval = FAIL;
|
|
1283 }
|
|
1284 else
|
|
1285 {
|
|
1286 int serNum;
|
|
1287
|
|
1288 cp = (char *)args;
|
|
1289 serNum = strtol(cp, &cp, 10);
|
|
1290 /* If the sign isn't found linenum will be zero. */
|
|
1291 linenum = (long)buf_findsign(buf->bufp, serNum);
|
|
1292 }
|
|
1293 #endif
|
|
1294 nb_reply_nr(cmdno, linenum);
|
|
1295 /* =====================================================================*/
|
|
1296 }
|
7
|
1297 else if (streq((char *)cmd, "getLength"))
|
|
1298 {
|
|
1299 long len = 0;
|
|
1300
|
|
1301 if (buf == NULL || buf->bufp == NULL)
|
|
1302 {
|
|
1303 nbdebug((" null bufp in getLength"));
|
|
1304 EMSG("E632: null bufp in getLength");
|
|
1305 retval = FAIL;
|
|
1306 }
|
|
1307 else
|
|
1308 {
|
|
1309 len = get_buf_size(buf->bufp);
|
|
1310 }
|
|
1311 nb_reply_nr(cmdno, len);
|
|
1312 /* =====================================================================*/
|
|
1313 }
|
|
1314 else if (streq((char *)cmd, "getText"))
|
|
1315 {
|
|
1316 long len;
|
|
1317 linenr_T nlines;
|
|
1318 char_u *text = NULL;
|
|
1319 linenr_T lno = 1;
|
|
1320 char_u *p;
|
|
1321 char_u *line;
|
|
1322
|
|
1323 if (buf == NULL || buf->bufp == NULL)
|
|
1324 {
|
|
1325 nbdebug((" null bufp in getText"));
|
|
1326 EMSG("E633: null bufp in getText");
|
|
1327 retval = FAIL;
|
|
1328 }
|
|
1329 else
|
|
1330 {
|
|
1331 len = get_buf_size(buf->bufp);
|
|
1332 nlines = buf->bufp->b_ml.ml_line_count;
|
|
1333 text = alloc((unsigned)((len > 0)
|
|
1334 ? ((len + nlines) * 2) : 4));
|
|
1335 if (text == NULL)
|
|
1336 {
|
|
1337 nbdebug((" nb_do_cmd: getText has null text field\n"));
|
|
1338 retval = FAIL;
|
|
1339 }
|
|
1340 else
|
|
1341 {
|
|
1342 p = text;
|
|
1343 *p++ = '\"';
|
|
1344 for (; lno <= nlines ; lno++)
|
|
1345 {
|
|
1346 line = nb_quote(ml_get_buf(buf->bufp, lno, FALSE));
|
|
1347 if (line != NULL)
|
|
1348 {
|
|
1349 STRCPY(p, line);
|
|
1350 p += STRLEN(line);
|
|
1351 *p++ = '\\';
|
|
1352 *p++ = 'n';
|
33
|
1353 vim_free(line);
|
7
|
1354 }
|
|
1355 }
|
|
1356 *p++ = '\"';
|
|
1357 *p = '\0';
|
|
1358 }
|
|
1359 }
|
|
1360 if (text == NULL)
|
|
1361 nb_reply_text(cmdno, (char_u *)"");
|
|
1362 else
|
|
1363 {
|
|
1364 nb_reply_text(cmdno, text);
|
|
1365 vim_free(text);
|
|
1366 }
|
|
1367 /* =====================================================================*/
|
|
1368 }
|
|
1369 else if (streq((char *)cmd, "remove"))
|
|
1370 {
|
|
1371 long count;
|
|
1372 pos_T first, last;
|
|
1373 pos_T *pos;
|
|
1374 int oldFire = netbeansFireChanges;
|
|
1375 int oldSuppress = netbeansSuppressNoLines;
|
|
1376 int wasChanged;
|
|
1377
|
|
1378 if (skip >= SKIP_STOP)
|
|
1379 {
|
|
1380 nbdebug((" Skipping %s command\n", (char *) cmd));
|
|
1381 nb_reply_nil(cmdno);
|
|
1382 return OK;
|
|
1383 }
|
|
1384
|
|
1385 if (buf == NULL || buf->bufp == NULL)
|
|
1386 {
|
|
1387 nbdebug((" null bufp in remove"));
|
|
1388 EMSG("E634: null bufp in remove");
|
|
1389 retval = FAIL;
|
|
1390 }
|
|
1391 else
|
|
1392 {
|
|
1393 netbeansFireChanges = FALSE;
|
|
1394 netbeansSuppressNoLines = TRUE;
|
|
1395
|
659
|
1396 nb_set_curbuf(buf->bufp);
|
7
|
1397 wasChanged = buf->bufp->b_changed;
|
27
|
1398 cp = (char *)args;
|
|
1399 off = strtol(cp, &cp, 10);
|
|
1400 count = strtol(cp, &cp, 10);
|
|
1401 args = (char_u *)cp;
|
7
|
1402 /* delete "count" chars, starting at "off" */
|
|
1403 pos = off2pos(buf->bufp, off);
|
|
1404 if (!pos)
|
|
1405 {
|
|
1406 nb_reply_text(cmdno, (char_u *)"!bad position");
|
|
1407 netbeansFireChanges = oldFire;
|
|
1408 netbeansSuppressNoLines = oldSuppress;
|
|
1409 return FAIL;
|
|
1410 }
|
|
1411 first = *pos;
|
|
1412 nbdebug((" FIRST POS: line %d, col %d\n", first.lnum, first.col));
|
|
1413 pos = off2pos(buf->bufp, off+count-1);
|
|
1414 if (!pos)
|
|
1415 {
|
|
1416 nb_reply_text(cmdno, (char_u *)"!bad count");
|
|
1417 netbeansFireChanges = oldFire;
|
|
1418 netbeansSuppressNoLines = oldSuppress;
|
|
1419 return FAIL;
|
|
1420 }
|
|
1421 last = *pos;
|
|
1422 nbdebug((" LAST POS: line %d, col %d\n", last.lnum, last.col));
|
|
1423 curwin->w_cursor = first;
|
|
1424 doupdate = 1;
|
|
1425
|
|
1426 /* keep part of first line */
|
|
1427 if (first.lnum == last.lnum && first.col != last.col)
|
|
1428 {
|
|
1429 /* deletion is within one line */
|
|
1430 char_u *p = ml_get(first.lnum);
|
|
1431 mch_memmove(p + first.col, p + last.col + 1, STRLEN(p + last.col) + 1);
|
|
1432 nbdebug((" NEW LINE %d: %s\n", first.lnum, p));
|
|
1433 ml_replace(first.lnum, p, TRUE);
|
|
1434 }
|
|
1435
|
|
1436 if (first.lnum < last.lnum)
|
|
1437 {
|
|
1438 int i;
|
|
1439
|
|
1440 /* delete signs from the lines being deleted */
|
|
1441 for (i = first.lnum; i <= last.lnum; i++)
|
|
1442 {
|
|
1443 int id = buf_findsign_id(buf->bufp, (linenr_T)i);
|
|
1444 if (id > 0)
|
|
1445 {
|
|
1446 nbdebug((" Deleting sign %d on line %d\n", id, i));
|
|
1447 buf_delsign(buf->bufp, id);
|
|
1448 }
|
|
1449 else
|
|
1450 nbdebug((" No sign on line %d\n", i));
|
|
1451 }
|
|
1452
|
|
1453 /* delete whole lines */
|
|
1454 nbdebug((" Deleting lines %d through %d\n", first.lnum, last.lnum));
|
|
1455 del_lines(last.lnum - first.lnum + 1, FALSE);
|
|
1456 }
|
|
1457 buf->bufp->b_changed = wasChanged; /* logically unchanged */
|
|
1458 netbeansFireChanges = oldFire;
|
|
1459 netbeansSuppressNoLines = oldSuppress;
|
|
1460
|
|
1461 u_blockfree(buf->bufp);
|
|
1462 u_clearall(buf->bufp);
|
|
1463 }
|
|
1464 nb_reply_nil(cmdno);
|
|
1465 /* =====================================================================*/
|
|
1466 }
|
|
1467 else if (streq((char *)cmd, "insert"))
|
|
1468 {
|
|
1469 char_u *to_free;
|
|
1470
|
|
1471 if (skip >= SKIP_STOP)
|
|
1472 {
|
|
1473 nbdebug((" Skipping %s command\n", (char *) cmd));
|
|
1474 nb_reply_nil(cmdno);
|
|
1475 return OK;
|
|
1476 }
|
|
1477
|
|
1478 /* get offset */
|
27
|
1479 cp = (char *)args;
|
|
1480 off = strtol(cp, &cp, 10);
|
|
1481 args = (char_u *)cp;
|
7
|
1482
|
|
1483 /* get text to be inserted */
|
|
1484 args = skipwhite(args);
|
|
1485 args = to_free = (char_u *)nb_unquote(args, NULL);
|
33
|
1486 /*
|
|
1487 nbdebug((" CHUNK[%d]: %d bytes at offset %d\n",
|
|
1488 buf->bufp->b_ml.ml_line_count, STRLEN(args), off));
|
|
1489 */
|
7
|
1490
|
|
1491 if (buf == NULL || buf->bufp == NULL)
|
|
1492 {
|
|
1493 nbdebug((" null bufp in insert"));
|
|
1494 EMSG("E635: null bufp in insert");
|
|
1495 retval = FAIL;
|
|
1496 }
|
|
1497 else if (args != NULL)
|
|
1498 {
|
718
|
1499 int ff_detected = EOL_UNKNOWN;
|
|
1500 int buf_was_empty = (buf->bufp->b_ml.ml_flags & ML_EMPTY);
|
|
1501 size_t len = 0;
|
|
1502 int added = 0;
|
|
1503 int oldFire = netbeansFireChanges;
|
|
1504 int old_b_changed;
|
|
1505 char_u *nl;
|
|
1506 linenr_T lnum;
|
|
1507 linenr_T lnum_start;
|
|
1508 pos_T *pos;
|
|
1509
|
7
|
1510 netbeansFireChanges = 0;
|
718
|
1511
|
|
1512 /* Jump to the buffer where we insert. After this "curbuf"
|
|
1513 * can be used. */
|
659
|
1514 nb_set_curbuf(buf->bufp);
|
717
|
1515 old_b_changed = curbuf->b_changed;
|
|
1516
|
718
|
1517 /* Convert the specified character offset into a lnum/col
|
|
1518 * position. */
|
717
|
1519 pos = off2pos(curbuf, off);
|
|
1520 if (pos != NULL)
|
7
|
1521 {
|
718
|
1522 if (pos->lnum <= 0)
|
|
1523 lnum_start = 1;
|
|
1524 else
|
|
1525 lnum_start = pos->lnum;
|
7
|
1526 }
|
|
1527 else
|
|
1528 {
|
718
|
1529 /* If the given position is not found, assume we want
|
7
|
1530 * the end of the file. See setLocAndSize HACK. */
|
718
|
1531 if (buf_was_empty)
|
|
1532 lnum_start = 1; /* above empty line */
|
|
1533 else
|
|
1534 lnum_start = curbuf->b_ml.ml_line_count + 1;
|
7
|
1535 }
|
718
|
1536
|
|
1537 /* "lnum" is the line where we insert: either append to it or
|
|
1538 * insert a new line above it. */
|
|
1539 lnum = lnum_start;
|
|
1540
|
|
1541 /* Loop over the "\n" separated lines of the argument. */
|
|
1542 doupdate = 1;
|
|
1543 while (*args != NUL)
|
33
|
1544 {
|
718
|
1545 nl = vim_strchr(args, '\n');
|
|
1546 if (nl == NULL)
|
7
|
1547 {
|
718
|
1548 /* Incomplete line, probably truncated. Next "insert"
|
|
1549 * command should append to this one. */
|
|
1550 len = STRLEN(args);
|
7
|
1551 }
|
33
|
1552 else
|
|
1553 {
|
718
|
1554 len = nl - args;
|
|
1555
|
|
1556 /*
|
|
1557 * We need to detect EOL style, because the commands
|
|
1558 * use a character offset.
|
|
1559 */
|
|
1560 if (nl > args && nl[-1] == '\r')
|
|
1561 {
|
|
1562 ff_detected = EOL_DOS;
|
|
1563 --len;
|
|
1564 }
|
|
1565 else
|
|
1566 ff_detected = EOL_UNIX;
|
33
|
1567 }
|
718
|
1568 args[len] = NUL;
|
|
1569
|
|
1570 if (lnum == lnum_start
|
|
1571 && ((pos != NULL && pos->col > 0)
|
|
1572 || (lnum == 1 && buf_was_empty)))
|
|
1573 {
|
|
1574 char_u *oldline = ml_get(lnum);
|
|
1575 char_u *newline;
|
|
1576
|
|
1577 /* Insert halfway a line. For simplicity we assume we
|
|
1578 * need to append to the line. */
|
835
|
1579 newline = alloc_check((unsigned)(STRLEN(oldline) + len + 1));
|
718
|
1580 if (newline != NULL)
|
|
1581 {
|
|
1582 STRCPY(newline, oldline);
|
|
1583 STRCAT(newline, args);
|
|
1584 ml_replace(lnum, newline, FALSE);
|
|
1585 }
|
|
1586 }
|
|
1587 else
|
|
1588 {
|
|
1589 /* Append a new line. Not that we always do this,
|
|
1590 * also when the text doesn't end in a "\n". */
|
835
|
1591 ml_append((linenr_T)(lnum - 1), args, (colnr_T)(len + 1), FALSE);
|
718
|
1592 ++added;
|
|
1593 }
|
|
1594
|
|
1595 if (nl == NULL)
|
|
1596 break;
|
|
1597 ++lnum;
|
|
1598 args = nl + 1;
|
33
|
1599 }
|
|
1600
|
718
|
1601 /* Adjust the marks below the inserted lines. */
|
|
1602 appended_lines_mark(lnum_start - 1, (long)added);
|
|
1603
|
|
1604 /*
|
|
1605 * When starting with an empty buffer set the fileformat.
|
|
1606 * This is just guessing...
|
7
|
1607 */
|
|
1608 if (buf_was_empty)
|
|
1609 {
|
|
1610 if (ff_detected == EOL_UNKNOWN)
|
718
|
1611 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
|
7
|
1612 ff_detected = EOL_DOS;
|
718
|
1613 #else
|
|
1614 ff_detected = EOL_UNIX;
|
|
1615 #endif
|
7
|
1616 set_fileformat(ff_detected, OPT_LOCAL);
|
717
|
1617 curbuf->b_start_ffc = *curbuf->b_p_ff;
|
7
|
1618 }
|
|
1619
|
|
1620 /*
|
|
1621 * XXX - GRP - Is the next line right? If I've inserted
|
|
1622 * text the buffer has been updated but not written. Will
|
|
1623 * netbeans guarantee to write it? Even if I do a :q! ?
|
|
1624 */
|
717
|
1625 curbuf->b_changed = old_b_changed; /* logically unchanged */
|
7
|
1626 netbeansFireChanges = oldFire;
|
|
1627
|
718
|
1628 /* Undo info is invalid now... */
|
717
|
1629 u_blockfree(curbuf);
|
|
1630 u_clearall(curbuf);
|
7
|
1631 }
|
|
1632 vim_free(to_free);
|
|
1633 nb_reply_nil(cmdno); /* or !error */
|
|
1634 }
|
|
1635 else
|
|
1636 {
|
|
1637 nbdebug(("UNIMPLEMENTED FUNCTION: %s\n", cmd));
|
|
1638 nb_reply_nil(cmdno);
|
|
1639 retval = FAIL;
|
|
1640 }
|
|
1641 }
|
|
1642 else /* Not a function; no reply required. */
|
|
1643 {
|
|
1644 /* =====================================================================*/
|
|
1645 if (streq((char *)cmd, "create"))
|
|
1646 {
|
|
1647 /* Create a buffer without a name. */
|
|
1648 if (buf == NULL)
|
|
1649 {
|
|
1650 EMSG("E636: null buf in create");
|
|
1651 return FAIL;
|
|
1652 }
|
|
1653 vim_free(buf->displayname);
|
|
1654 buf->displayname = NULL;
|
|
1655
|
|
1656 netbeansReadFile = 0; /* don't try to open disk file */
|
|
1657 do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF);
|
|
1658 netbeansReadFile = 1;
|
|
1659 buf->bufp = curbuf;
|
|
1660 maketitle();
|
33
|
1661 buf->insertDone = FALSE;
|
7
|
1662 gui_update_menus(0);
|
|
1663 /* =====================================================================*/
|
|
1664 }
|
33
|
1665 else if (streq((char *)cmd, "insertDone"))
|
|
1666 {
|
840
|
1667 if (buf == NULL || buf->bufp == NULL)
|
|
1668 {
|
|
1669 nbdebug((" null bufp in insertDone"));
|
|
1670 }
|
|
1671 else
|
|
1672 {
|
|
1673 buf->bufp->b_start_eol = *args == 'T';
|
|
1674 buf->insertDone = TRUE;
|
|
1675 args += 2;
|
|
1676 buf->bufp->b_p_ro = *args == 'T';
|
|
1677 print_read_msg(buf);
|
|
1678 }
|
33
|
1679 /* =====================================================================*/
|
|
1680 }
|
|
1681 else if (streq((char *)cmd, "saveDone"))
|
|
1682 {
|
840
|
1683 long savedChars = atol((char *)args);
|
|
1684
|
|
1685 if (buf == NULL || buf->bufp == NULL)
|
|
1686 {
|
|
1687 nbdebug((" null bufp in saveDone"));
|
|
1688 }
|
|
1689 else
|
|
1690 print_save_msg(buf, savedChars);
|
33
|
1691 /* =====================================================================*/
|
|
1692 }
|
7
|
1693 else if (streq((char *)cmd, "startDocumentListen"))
|
|
1694 {
|
|
1695 if (buf == NULL)
|
|
1696 {
|
|
1697 EMSG("E637: null buf in startDocumentListen");
|
|
1698 return FAIL;
|
|
1699 }
|
|
1700 buf->fireChanges = 1;
|
|
1701 /* =====================================================================*/
|
|
1702 }
|
|
1703 else if (streq((char *)cmd, "stopDocumentListen"))
|
|
1704 {
|
|
1705 if (buf == NULL)
|
|
1706 {
|
|
1707 EMSG("E638: null buf in stopDocumentListen");
|
|
1708 return FAIL;
|
|
1709 }
|
|
1710 buf->fireChanges = 0;
|
152
|
1711 if (buf->bufp != NULL && buf->bufp->b_was_netbeans_file)
|
33
|
1712 {
|
152
|
1713 if (!buf->bufp->b_netbeans_file)
|
33
|
1714 EMSGN(_("E658: NetBeans connection lost for buffer %ld"),
|
7
|
1715 buf->bufp->b_fnum);
|
33
|
1716 else
|
|
1717 {
|
152
|
1718 /* NetBeans uses stopDocumentListen when it stops editing
|
|
1719 * a file. It then expects the buffer in Vim to
|
|
1720 * disappear. */
|
|
1721 do_bufdel(DOBUF_DEL, (char_u *)"", 1,
|
|
1722 buf->bufp->b_fnum, buf->bufp->b_fnum, TRUE);
|
33
|
1723 vim_memset(buf, 0, sizeof(nbbuf_T));
|
|
1724 }
|
|
1725 }
|
7
|
1726 /* =====================================================================*/
|
|
1727 }
|
|
1728 else if (streq((char *)cmd, "setTitle"))
|
|
1729 {
|
|
1730 if (buf == NULL)
|
|
1731 {
|
|
1732 EMSG("E639: null buf in setTitle");
|
|
1733 return FAIL;
|
|
1734 }
|
|
1735 vim_free(buf->displayname);
|
|
1736 buf->displayname = nb_unquote(args, NULL);
|
|
1737 /* =====================================================================*/
|
|
1738 }
|
|
1739 else if (streq((char *)cmd, "initDone"))
|
|
1740 {
|
|
1741 if (buf == NULL || buf->bufp == NULL)
|
|
1742 {
|
|
1743 EMSG("E640: null buf in initDone");
|
|
1744 return FAIL;
|
|
1745 }
|
|
1746 doupdate = 1;
|
33
|
1747 buf->initDone = TRUE;
|
659
|
1748 nb_set_curbuf(buf->bufp);
|
7
|
1749 #if defined(FEAT_AUTOCMD)
|
|
1750 apply_autocmds(EVENT_BUFREADPOST, 0, 0, FALSE, buf->bufp);
|
|
1751 #endif
|
|
1752
|
|
1753 /* handle any postponed key commands */
|
|
1754 handle_key_queue();
|
|
1755 /* =====================================================================*/
|
|
1756 }
|
|
1757 else if (streq((char *)cmd, "setBufferNumber")
|
|
1758 || streq((char *)cmd, "putBufferNumber"))
|
|
1759 {
|
33
|
1760 char_u *path;
|
7
|
1761 buf_T *bufp;
|
|
1762
|
|
1763 if (buf == NULL)
|
|
1764 {
|
|
1765 EMSG("E641: null buf in setBufferNumber");
|
|
1766 return FAIL;
|
|
1767 }
|
33
|
1768 path = (char_u *)nb_unquote(args, NULL);
|
|
1769 if (path == NULL)
|
7
|
1770 return FAIL;
|
33
|
1771 bufp = buflist_findname(path);
|
|
1772 vim_free(path);
|
7
|
1773 if (bufp == NULL)
|
|
1774 {
|
|
1775 EMSG2("E642: File %s not found in setBufferNumber", args);
|
|
1776 return FAIL;
|
|
1777 }
|
|
1778 buf->bufp = bufp;
|
33
|
1779 buf->nbbuf_number = bufp->b_fnum;
|
7
|
1780
|
|
1781 /* "setBufferNumber" has the side effect of jumping to the buffer
|
|
1782 * (don't know why!). Don't do that for "putBufferNumber". */
|
|
1783 if (*cmd != 'p')
|
|
1784 coloncmd(":buffer %d", bufp->b_fnum);
|
|
1785 else
|
|
1786 {
|
33
|
1787 buf->initDone = TRUE;
|
7
|
1788
|
|
1789 /* handle any postponed key commands */
|
|
1790 handle_key_queue();
|
|
1791 }
|
|
1792
|
|
1793 #if 0 /* never used */
|
|
1794 buf->internalname = (char *)alloc_clear(8);
|
|
1795 sprintf(buf->internalname, "<%d>", bufno);
|
|
1796 buf->netbeansOwns = 0;
|
|
1797 #endif
|
|
1798 /* =====================================================================*/
|
|
1799 }
|
|
1800 else if (streq((char *)cmd, "setFullName"))
|
|
1801 {
|
|
1802 if (buf == NULL)
|
|
1803 {
|
|
1804 EMSG("E643: null buf in setFullName");
|
|
1805 return FAIL;
|
|
1806 }
|
|
1807 vim_free(buf->displayname);
|
|
1808 buf->displayname = nb_unquote(args, NULL);
|
|
1809
|
|
1810 netbeansReadFile = 0; /* don't try to open disk file */
|
|
1811 do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE,
|
|
1812 ECMD_HIDE + ECMD_OLDBUF);
|
|
1813 netbeansReadFile = 1;
|
|
1814 buf->bufp = curbuf;
|
|
1815 maketitle();
|
|
1816 gui_update_menus(0);
|
|
1817 /* =====================================================================*/
|
|
1818 }
|
|
1819 else if (streq((char *)cmd, "editFile"))
|
|
1820 {
|
|
1821 if (buf == NULL)
|
|
1822 {
|
|
1823 EMSG("E644: null buf in editFile");
|
|
1824 return FAIL;
|
|
1825 }
|
|
1826 /* Edit a file: like create + setFullName + read the file. */
|
|
1827 vim_free(buf->displayname);
|
|
1828 buf->displayname = nb_unquote(args, NULL);
|
|
1829 do_ecmd(0, (char_u *)buf->displayname, NULL, NULL, ECMD_ONE,
|
|
1830 ECMD_HIDE + ECMD_OLDBUF);
|
|
1831 buf->bufp = curbuf;
|
33
|
1832 buf->initDone = TRUE;
|
7
|
1833 doupdate = 1;
|
|
1834 #if defined(FEAT_TITLE)
|
|
1835 maketitle();
|
|
1836 #endif
|
|
1837 gui_update_menus(0);
|
|
1838 /* =====================================================================*/
|
|
1839 }
|
|
1840 else if (streq((char *)cmd, "setVisible"))
|
|
1841 {
|
|
1842 if (buf == NULL || buf->bufp == NULL)
|
|
1843 {
|
|
1844 /* EMSG("E645: null bufp in setVisible"); */
|
|
1845 return FAIL;
|
|
1846 }
|
33
|
1847 if (streq((char *)args, "T") && buf->bufp != curbuf)
|
7
|
1848 {
|
|
1849 exarg_T exarg;
|
|
1850 exarg.cmd = (char_u *)"goto";
|
|
1851 exarg.forceit = FALSE;
|
33
|
1852 dosetvisible = TRUE;
|
7
|
1853 goto_buffer(&exarg, DOBUF_FIRST, FORWARD, buf->bufp->b_fnum);
|
|
1854 doupdate = 1;
|
33
|
1855 dosetvisible = FALSE;
|
7
|
1856
|
|
1857 /* Side effect!!!. */
|
|
1858 if (!gui.starting)
|
|
1859 gui_mch_set_foreground();
|
|
1860 }
|
|
1861 /* =====================================================================*/
|
|
1862 }
|
|
1863 else if (streq((char *)cmd, "raise"))
|
|
1864 {
|
|
1865 /* Bring gvim to the foreground. */
|
|
1866 if (!gui.starting)
|
|
1867 gui_mch_set_foreground();
|
|
1868 /* =====================================================================*/
|
|
1869 }
|
|
1870 else if (streq((char *)cmd, "setModified"))
|
|
1871 {
|
|
1872 if (buf == NULL || buf->bufp == NULL)
|
|
1873 {
|
|
1874 /* EMSG("E646: null bufp in setModified"); */
|
|
1875 return FAIL;
|
|
1876 }
|
|
1877 if (streq((char *)args, "T"))
|
|
1878 buf->bufp->b_changed = 1;
|
|
1879 else
|
|
1880 {
|
|
1881 struct stat st;
|
|
1882
|
|
1883 /* Assume NetBeans stored the file. Reset the timestamp to
|
|
1884 * avoid "file changed" warnings. */
|
|
1885 if (buf->bufp->b_ffname != NULL
|
|
1886 && mch_stat((char *)buf->bufp->b_ffname, &st) >= 0)
|
|
1887 buf_store_time(buf->bufp, &st, buf->bufp->b_ffname);
|
|
1888 buf->bufp->b_changed = 0;
|
|
1889 }
|
|
1890 buf->modified = buf->bufp->b_changed;
|
|
1891 /* =====================================================================*/
|
|
1892 }
|
33
|
1893 else if (streq((char *)cmd, "setModtime"))
|
|
1894 {
|
840
|
1895 if (buf == NULL || buf->bufp == NULL)
|
|
1896 nbdebug((" null bufp in setModtime"));
|
|
1897 else
|
|
1898 buf->bufp->b_mtime = atoi((char *)args);
|
33
|
1899 /* =====================================================================*/
|
|
1900 }
|
|
1901 else if (streq((char *)cmd, "setReadOnly"))
|
|
1902 {
|
840
|
1903 if (buf == NULL || buf->bufp == NULL)
|
|
1904 nbdebug((" null bufp in setReadOnly"));
|
|
1905 else if (streq((char *)args, "T"))
|
33
|
1906 buf->bufp->b_p_ro = TRUE;
|
|
1907 else
|
|
1908 buf->bufp->b_p_ro = FALSE;
|
|
1909 /* =====================================================================*/
|
|
1910 }
|
7
|
1911 else if (streq((char *)cmd, "setMark"))
|
|
1912 {
|
|
1913 /* not yet */
|
|
1914 /* =====================================================================*/
|
|
1915 }
|
|
1916 else if (streq((char *)cmd, "showBalloon"))
|
|
1917 {
|
|
1918 #if defined(FEAT_BEVAL)
|
|
1919 static char *text = NULL;
|
|
1920
|
|
1921 /*
|
|
1922 * Set up the Balloon Expression Evaluation area.
|
|
1923 * Ignore 'ballooneval' here.
|
|
1924 * The text pointer must remain valid for a while.
|
|
1925 */
|
|
1926 if (balloonEval != NULL)
|
|
1927 {
|
|
1928 vim_free(text);
|
|
1929 text = nb_unquote(args, NULL);
|
|
1930 if (text != NULL)
|
|
1931 gui_mch_post_balloon(balloonEval, (char_u *)text);
|
|
1932 }
|
|
1933 #endif
|
|
1934 /* =====================================================================*/
|
|
1935 }
|
|
1936 else if (streq((char *)cmd, "setDot"))
|
|
1937 {
|
|
1938 pos_T *pos;
|
|
1939 #ifdef NBDEBUG
|
|
1940 char_u *s;
|
|
1941 #endif
|
|
1942
|
|
1943 if (buf == NULL || buf->bufp == NULL)
|
|
1944 {
|
|
1945 EMSG("E647: null bufp in setDot");
|
|
1946 return FAIL;
|
|
1947 }
|
|
1948
|
659
|
1949 nb_set_curbuf(buf->bufp);
|
|
1950
|
7
|
1951 #ifdef FEAT_VISUAL
|
|
1952 /* Don't want Visual mode now. */
|
|
1953 if (VIsual_active)
|
|
1954 end_visual_mode();
|
|
1955 #endif
|
|
1956 #ifdef NBDEBUG
|
|
1957 s = args;
|
|
1958 #endif
|
|
1959 pos = get_off_or_lnum(buf->bufp, &args);
|
|
1960 if (pos)
|
|
1961 {
|
|
1962 curwin->w_cursor = *pos;
|
|
1963 check_cursor();
|
|
1964 #ifdef FEAT_FOLDING
|
|
1965 foldOpenCursor();
|
|
1966 #endif
|
|
1967 }
|
|
1968 else
|
|
1969 nbdebug((" BAD POSITION in setDot: %s\n", s));
|
|
1970
|
|
1971 /* gui_update_cursor(TRUE, FALSE); */
|
|
1972 /* update_curbuf(NOT_VALID); */
|
|
1973 update_topline(); /* scroll to show the line */
|
|
1974 update_screen(VALID);
|
|
1975 setcursor();
|
|
1976 out_flush();
|
|
1977 gui_update_cursor(TRUE, FALSE);
|
|
1978 gui_mch_flush();
|
|
1979 /* Quit a hit-return or more prompt. */
|
|
1980 if (State == HITRETURN || State == ASKMORE)
|
|
1981 {
|
|
1982 #ifdef FEAT_GUI_GTK
|
|
1983 if (gtk_main_level() > 0)
|
|
1984 gtk_main_quit();
|
|
1985 #endif
|
|
1986 }
|
|
1987 /* =====================================================================*/
|
|
1988 }
|
|
1989 else if (streq((char *)cmd, "close"))
|
|
1990 {
|
|
1991 #ifdef NBDEBUG
|
|
1992 char *name = "<NONE>";
|
|
1993 #endif
|
|
1994
|
|
1995 if (buf == NULL)
|
|
1996 {
|
|
1997 EMSG("E648: null buf in close");
|
|
1998 return FAIL;
|
|
1999 }
|
|
2000
|
|
2001 #ifdef NBDEBUG
|
|
2002 if (buf->displayname != NULL)
|
|
2003 name = buf->displayname;
|
|
2004 #endif
|
|
2005 /* if (buf->bufp == NULL) */
|
|
2006 /* EMSG("E649: null bufp in close"); */
|
|
2007 nbdebug((" CLOSE %d: %s\n", bufno, name));
|
|
2008 need_mouse_correct = TRUE;
|
|
2009 if (buf->bufp != NULL)
|
|
2010 do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD,
|
|
2011 buf->bufp->b_fnum, TRUE);
|
924
|
2012 buf->bufp = NULL;
|
|
2013 buf->initDone = FALSE;
|
7
|
2014 doupdate = 1;
|
|
2015 /* =====================================================================*/
|
|
2016 }
|
|
2017 else if (streq((char *)cmd, "setStyle")) /* obsolete... */
|
|
2018 {
|
|
2019 nbdebug((" setStyle is obsolete!"));
|
|
2020 /* =====================================================================*/
|
|
2021 }
|
|
2022 else if (streq((char *)cmd, "setExitDelay"))
|
|
2023 {
|
33
|
2024 /* Only used in version 2.1. */
|
7
|
2025 /* =====================================================================*/
|
|
2026 }
|
|
2027 else if (streq((char *)cmd, "defineAnnoType"))
|
|
2028 {
|
|
2029 #ifdef FEAT_SIGNS
|
|
2030 int typeNum;
|
|
2031 char_u *typeName;
|
|
2032 char_u *tooltip;
|
|
2033 char_u *p;
|
|
2034 char_u *glyphFile;
|
|
2035 int use_fg = 0;
|
|
2036 int use_bg = 0;
|
|
2037 int fg = -1;
|
|
2038 int bg = -1;
|
|
2039
|
|
2040 if (buf == NULL)
|
|
2041 {
|
|
2042 EMSG("E650: null buf in defineAnnoType");
|
|
2043 return FAIL;
|
|
2044 }
|
|
2045
|
27
|
2046 cp = (char *)args;
|
|
2047 typeNum = strtol(cp, &cp, 10);
|
|
2048 args = (char_u *)cp;
|
7
|
2049 args = skipwhite(args);
|
|
2050 typeName = (char_u *)nb_unquote(args, &args);
|
|
2051 args = skipwhite(args + 1);
|
|
2052 tooltip = (char_u *)nb_unquote(args, &args);
|
|
2053 args = skipwhite(args + 1);
|
|
2054
|
|
2055 p = (char_u *)nb_unquote(args, &args);
|
|
2056 glyphFile = vim_strsave_escaped(p, escape_chars);
|
|
2057 vim_free(p);
|
|
2058
|
|
2059 args = skipwhite(args + 1);
|
|
2060 if (STRNCMP(args, "none", 4) == 0)
|
|
2061 args += 5;
|
|
2062 else
|
|
2063 {
|
|
2064 use_fg = 1;
|
27
|
2065 cp = (char *)args;
|
|
2066 fg = strtol(cp, &cp, 10);
|
|
2067 args = (char_u *)cp;
|
7
|
2068 }
|
|
2069 if (STRNCMP(args, "none", 4) == 0)
|
|
2070 args += 5;
|
|
2071 else
|
|
2072 {
|
|
2073 use_bg = 1;
|
27
|
2074 cp = (char *)args;
|
|
2075 bg = strtol(cp, &cp, 10);
|
|
2076 args = (char_u *)cp;
|
7
|
2077 }
|
|
2078 if (typeName != NULL && tooltip != NULL && glyphFile != NULL)
|
|
2079 addsigntype(buf, typeNum, typeName, tooltip, glyphFile,
|
|
2080 use_fg, fg, use_bg, bg);
|
|
2081 else
|
|
2082 vim_free(typeName);
|
|
2083
|
|
2084 /* don't free typeName; it's used directly in addsigntype() */
|
|
2085 vim_free(tooltip);
|
|
2086 vim_free(glyphFile);
|
|
2087
|
|
2088 #endif
|
|
2089 /* =====================================================================*/
|
|
2090 }
|
|
2091 else if (streq((char *)cmd, "addAnno"))
|
|
2092 {
|
|
2093 #ifdef FEAT_SIGNS
|
|
2094 int serNum;
|
|
2095 int localTypeNum;
|
|
2096 int typeNum;
|
|
2097 # ifdef NBDEBUG
|
|
2098 int len;
|
|
2099 # endif
|
|
2100 pos_T *pos;
|
|
2101
|
|
2102 if (buf == NULL || buf->bufp == NULL)
|
|
2103 {
|
|
2104 EMSG("E651: null bufp in addAnno");
|
|
2105 return FAIL;
|
|
2106 }
|
|
2107
|
|
2108 doupdate = 1;
|
|
2109
|
27
|
2110 cp = (char *)args;
|
|
2111 serNum = strtol(cp, &cp, 10);
|
7
|
2112
|
|
2113 /* Get the typenr specific for this buffer and convert it to
|
|
2114 * the global typenumber, as used for the sign name. */
|
27
|
2115 localTypeNum = strtol(cp, &cp, 10);
|
|
2116 args = (char_u *)cp;
|
7
|
2117 typeNum = mapsigntype(buf, localTypeNum);
|
|
2118
|
|
2119 pos = get_off_or_lnum(buf->bufp, &args);
|
|
2120
|
27
|
2121 cp = (char *)args;
|
7
|
2122 # ifdef NBDEBUG
|
|
2123 len =
|
|
2124 # endif
|
27
|
2125 strtol(cp, &cp, 10);
|
|
2126 args = (char_u *)cp;
|
7
|
2127 # ifdef NBDEBUG
|
|
2128 if (len != -1)
|
|
2129 {
|
|
2130 nbdebug((" partial line annotation -- Not Yet Implemented!"));
|
|
2131 }
|
|
2132 # endif
|
|
2133 if (serNum >= GUARDEDOFFSET)
|
|
2134 {
|
|
2135 nbdebug((" too many annotations! ignoring..."));
|
|
2136 return FAIL;
|
|
2137 }
|
|
2138 if (pos)
|
|
2139 {
|
|
2140 coloncmd(":sign place %d line=%d name=%d buffer=%d",
|
|
2141 serNum, pos->lnum, typeNum, buf->bufp->b_fnum);
|
|
2142 if (typeNum == curPCtype)
|
|
2143 coloncmd(":sign jump %d buffer=%d", serNum,
|
|
2144 buf->bufp->b_fnum);
|
|
2145 }
|
|
2146 /* XXX only redraw what changed. */
|
|
2147 redraw_later(CLEAR);
|
|
2148 #endif
|
|
2149 /* =====================================================================*/
|
|
2150 }
|
|
2151 else if (streq((char *)cmd, "removeAnno"))
|
|
2152 {
|
|
2153 #ifdef FEAT_SIGNS
|
|
2154 int serNum;
|
|
2155
|
|
2156 if (buf == NULL || buf->bufp == NULL)
|
|
2157 {
|
|
2158 nbdebug((" null bufp in removeAnno"));
|
|
2159 return FAIL;
|
|
2160 }
|
|
2161 doupdate = 1;
|
27
|
2162 cp = (char *)args;
|
|
2163 serNum = strtol(cp, &cp, 10);
|
|
2164 args = (char_u *)cp;
|
7
|
2165 coloncmd(":sign unplace %d buffer=%d",
|
|
2166 serNum, buf->bufp->b_fnum);
|
|
2167 redraw_buf_later(buf->bufp, NOT_VALID);
|
|
2168 #endif
|
|
2169 /* =====================================================================*/
|
|
2170 }
|
|
2171 else if (streq((char *)cmd, "moveAnnoToFront"))
|
|
2172 {
|
|
2173 #ifdef FEAT_SIGNS
|
|
2174 nbdebug((" moveAnnoToFront: Not Yet Implemented!"));
|
|
2175 #endif
|
|
2176 /* =====================================================================*/
|
|
2177 }
|
|
2178 else if (streq((char *)cmd, "guard") || streq((char *)cmd, "unguard"))
|
|
2179 {
|
|
2180 int len;
|
|
2181 pos_T first;
|
|
2182 pos_T last;
|
|
2183 pos_T *pos;
|
|
2184 int un = (cmd[0] == 'u');
|
|
2185 static int guardId = GUARDEDOFFSET;
|
|
2186
|
|
2187 if (skip >= SKIP_STOP)
|
|
2188 {
|
|
2189 nbdebug((" Skipping %s command\n", (char *) cmd));
|
|
2190 return OK;
|
|
2191 }
|
|
2192
|
|
2193 nb_init_graphics();
|
|
2194
|
|
2195 if (buf == NULL || buf->bufp == NULL)
|
|
2196 {
|
|
2197 nbdebug((" null bufp in %s command", cmd));
|
|
2198 return FAIL;
|
|
2199 }
|
659
|
2200 nb_set_curbuf(buf->bufp);
|
27
|
2201 cp = (char *)args;
|
|
2202 off = strtol(cp, &cp, 10);
|
|
2203 len = strtol(cp, NULL, 10);
|
|
2204 args = (char_u *)cp;
|
7
|
2205 pos = off2pos(buf->bufp, off);
|
|
2206 doupdate = 1;
|
|
2207 if (!pos)
|
|
2208 nbdebug((" no such start pos in %s, %ld\n", cmd, off));
|
|
2209 else
|
|
2210 {
|
|
2211 first = *pos;
|
|
2212 pos = off2pos(buf->bufp, off + len - 1);
|
33
|
2213 if (pos != NULL && pos->col == 0)
|
|
2214 {
|
7
|
2215 /*
|
|
2216 * In Java Swing the offset is a position between 2
|
|
2217 * characters. If col == 0 then we really want the
|
|
2218 * previous line as the end.
|
|
2219 */
|
|
2220 pos = off2pos(buf->bufp, off + len - 2);
|
|
2221 }
|
|
2222 if (!pos)
|
|
2223 nbdebug((" no such end pos in %s, %ld\n",
|
|
2224 cmd, off + len - 1));
|
|
2225 else
|
|
2226 {
|
|
2227 long lnum;
|
|
2228 last = *pos;
|
|
2229 /* set highlight for region */
|
|
2230 nbdebug((" %sGUARD %ld,%d to %ld,%d\n", (un) ? "UN" : "",
|
|
2231 first.lnum, first.col,
|
|
2232 last.lnum, last.col));
|
|
2233 #ifdef FEAT_SIGNS
|
|
2234 for (lnum = first.lnum; lnum <= last.lnum; lnum++)
|
|
2235 {
|
|
2236 if (un)
|
|
2237 {
|
|
2238 /* never used */
|
|
2239 }
|
|
2240 else
|
|
2241 {
|
|
2242 if (buf_findsigntype_id(buf->bufp, lnum,
|
|
2243 GUARDED) == 0)
|
|
2244 {
|
|
2245 coloncmd(
|
|
2246 ":sign place %d line=%d name=%d buffer=%d",
|
|
2247 guardId++, lnum, GUARDED,
|
|
2248 buf->bufp->b_fnum);
|
|
2249 }
|
|
2250 }
|
|
2251 }
|
|
2252 #endif
|
|
2253 redraw_buf_later(buf->bufp, NOT_VALID);
|
|
2254 }
|
|
2255 }
|
|
2256 /* =====================================================================*/
|
|
2257 }
|
|
2258 else if (streq((char *)cmd, "startAtomic"))
|
|
2259 {
|
|
2260 inAtomic = 1;
|
|
2261 /* =====================================================================*/
|
|
2262 }
|
|
2263 else if (streq((char *)cmd, "endAtomic"))
|
|
2264 {
|
|
2265 inAtomic = 0;
|
|
2266 if (needupdate)
|
|
2267 {
|
|
2268 doupdate = 1;
|
|
2269 needupdate = 0;
|
|
2270 }
|
|
2271 /* =====================================================================*/
|
|
2272 }
|
|
2273 else if (streq((char *)cmd, "save"))
|
|
2274 {
|
33
|
2275 /*
|
|
2276 * NOTE - This command is obsolete wrt NetBeans. Its left in
|
|
2277 * only for historical reasons.
|
|
2278 */
|
7
|
2279 if (buf == NULL || buf->bufp == NULL)
|
|
2280 {
|
|
2281 nbdebug((" null bufp in %s command", cmd));
|
|
2282 return FAIL;
|
|
2283 }
|
|
2284
|
|
2285 /* the following is taken from ex_cmds.c (do_wqall function) */
|
|
2286 if (bufIsChanged(buf->bufp))
|
|
2287 {
|
|
2288 /* Only write if the buffer can be written. */
|
|
2289 if (p_write
|
|
2290 && !buf->bufp->b_p_ro
|
|
2291 && buf->bufp->b_ffname != NULL
|
|
2292 #ifdef FEAT_QUICKFIX
|
|
2293 && !bt_dontwrite(buf->bufp)
|
|
2294 #endif
|
|
2295 )
|
|
2296 {
|
|
2297 buf_write_all(buf->bufp, FALSE);
|
|
2298 #ifdef FEAT_AUTOCMD
|
|
2299 /* an autocommand may have deleted the buffer */
|
|
2300 if (!buf_valid(buf->bufp))
|
|
2301 buf->bufp = NULL;
|
|
2302 #endif
|
|
2303 }
|
|
2304 }
|
|
2305 /* =====================================================================*/
|
|
2306 }
|
|
2307 else if (streq((char *)cmd, "netbeansBuffer"))
|
|
2308 {
|
|
2309 if (buf == NULL || buf->bufp == NULL)
|
|
2310 {
|
|
2311 nbdebug((" null bufp in %s command", cmd));
|
|
2312 return FAIL;
|
|
2313 }
|
|
2314 if (*args == 'T')
|
|
2315 {
|
|
2316 buf->bufp->b_netbeans_file = TRUE;
|
|
2317 buf->bufp->b_was_netbeans_file = TRUE;
|
|
2318 }
|
|
2319 else
|
|
2320 buf->bufp->b_netbeans_file = FALSE;
|
|
2321 /* =====================================================================*/
|
|
2322 }
|
33
|
2323 else if (streq((char *)cmd, "specialKeys"))
|
|
2324 {
|
|
2325 special_keys(args);
|
|
2326 /* =====================================================================*/
|
|
2327 }
|
|
2328 else if (streq((char *)cmd, "actionMenuItem"))
|
|
2329 {
|
|
2330 /* not used yet */
|
|
2331 /* =====================================================================*/
|
|
2332 }
|
7
|
2333 else if (streq((char *)cmd, "version"))
|
|
2334 {
|
33
|
2335 /* not used yet */
|
7
|
2336 }
|
|
2337 /*
|
|
2338 * Unrecognized command is ignored.
|
|
2339 */
|
|
2340 }
|
|
2341 if (inAtomic && doupdate)
|
|
2342 {
|
|
2343 needupdate = 1;
|
|
2344 doupdate = 0;
|
|
2345 }
|
|
2346
|
33
|
2347 /*
|
|
2348 * Is this needed? I moved the netbeans_Xt_connect() later during startup
|
|
2349 * and it may no longer be necessary. If its not needed then needupdate
|
|
2350 * and doupdate can also be removed.
|
|
2351 */
|
7
|
2352 if (buf != NULL && buf->initDone && doupdate)
|
|
2353 {
|
|
2354 update_screen(NOT_VALID);
|
|
2355 setcursor();
|
|
2356 out_flush();
|
|
2357 gui_update_cursor(TRUE, FALSE);
|
|
2358 gui_mch_flush();
|
|
2359 /* Quit a hit-return or more prompt. */
|
|
2360 if (State == HITRETURN || State == ASKMORE)
|
|
2361 {
|
|
2362 #ifdef FEAT_GUI_GTK
|
|
2363 if (gtk_main_level() > 0)
|
|
2364 gtk_main_quit();
|
|
2365 #endif
|
|
2366 }
|
|
2367 }
|
|
2368
|
|
2369 return retval;
|
|
2370 }
|
|
2371
|
|
2372
|
|
2373 /*
|
659
|
2374 * If "buf" is not the current buffer try changing to a window that edits this
|
|
2375 * buffer. If there is no such window then close the current buffer and set
|
|
2376 * the current buffer as "buf".
|
|
2377 */
|
|
2378 static void
|
|
2379 nb_set_curbuf(buf)
|
|
2380 buf_T *buf;
|
|
2381 {
|
|
2382 if (curbuf != buf && buf_jump_open_win(buf) == NULL)
|
|
2383 set_curbuf(buf, DOBUF_GOTO);
|
|
2384 }
|
|
2385
|
|
2386 /*
|
7
|
2387 * Process a vim colon command.
|
|
2388 */
|
|
2389 static void
|
|
2390 coloncmd(char *cmd, ...)
|
|
2391 {
|
|
2392 char buf[1024];
|
|
2393 va_list ap;
|
|
2394
|
|
2395 va_start(ap, cmd);
|
|
2396 vsprintf(buf, cmd, ap);
|
|
2397 va_end(ap);
|
|
2398
|
|
2399 nbdebug((" COLONCMD %s\n", buf));
|
|
2400
|
|
2401 /* ALT_INPUT_LOCK_ON; */
|
|
2402 do_cmdline((char_u *)buf, NULL, NULL, DOCMD_NOWAIT | DOCMD_KEYTYPED);
|
|
2403 /* ALT_INPUT_LOCK_OFF; */
|
|
2404
|
|
2405 setcursor(); /* restore the cursor position */
|
|
2406 out_flush(); /* make sure output has been written */
|
|
2407
|
|
2408 gui_update_cursor(TRUE, FALSE);
|
|
2409 gui_mch_flush();
|
|
2410 }
|
|
2411
|
|
2412
|
|
2413 /*
|
33
|
2414 * Parse the specialKeys argument and issue the appropriate map commands.
|
|
2415 */
|
|
2416 static void
|
|
2417 special_keys(char_u *args)
|
|
2418 {
|
|
2419 char *save_str = nb_unquote(args, NULL);
|
|
2420 char *tok = strtok(save_str, " ");
|
|
2421 char *sep;
|
|
2422 char keybuf[64];
|
|
2423 char cmdbuf[256];
|
|
2424
|
|
2425 while (tok != NULL)
|
|
2426 {
|
|
2427 int i = 0;
|
|
2428
|
|
2429 if ((sep = strchr(tok, '-')) != NULL)
|
|
2430 {
|
36
|
2431 *sep = NUL;
|
33
|
2432 while (*tok)
|
|
2433 {
|
|
2434 switch (*tok)
|
|
2435 {
|
|
2436 case 'A':
|
|
2437 case 'M':
|
|
2438 case 'C':
|
|
2439 case 'S':
|
|
2440 keybuf[i++] = *tok;
|
|
2441 keybuf[i++] = '-';
|
|
2442 break;
|
|
2443 }
|
|
2444 tok++;
|
|
2445 }
|
|
2446 tok++;
|
|
2447 }
|
|
2448
|
|
2449 strcpy(&keybuf[i], tok);
|
272
|
2450 vim_snprintf(cmdbuf, sizeof(cmdbuf),
|
|
2451 "<silent><%s> :nbkey %s<CR>", keybuf, keybuf);
|
33
|
2452 do_map(0, (char_u *)cmdbuf, NORMAL, FALSE);
|
|
2453 tok = strtok(NULL, " ");
|
|
2454 }
|
|
2455 vim_free(save_str);
|
|
2456 }
|
|
2457
|
|
2458
|
|
2459 void
|
|
2460 ex_nbkey(eap)
|
|
2461 exarg_T *eap;
|
|
2462 {
|
|
2463 netbeans_keystring(0, (char *)eap->arg);
|
|
2464 }
|
|
2465
|
|
2466
|
|
2467 /*
|
7
|
2468 * Initialize highlights and signs for use by netbeans (mostly obsolete)
|
|
2469 */
|
|
2470 static void
|
|
2471 nb_init_graphics(void)
|
|
2472 {
|
|
2473 static int did_init = FALSE;
|
|
2474
|
|
2475 if (!did_init)
|
|
2476 {
|
|
2477 coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black");
|
|
2478 coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
|
|
2479
|
|
2480 did_init = TRUE;
|
|
2481 }
|
|
2482 }
|
|
2483
|
|
2484 /*
|
|
2485 * Convert key to netbeans name.
|
|
2486 */
|
|
2487 static void
|
|
2488 netbeans_keyname(int key, char *buf)
|
|
2489 {
|
|
2490 char *name = 0;
|
|
2491 char namebuf[2];
|
|
2492 int ctrl = 0;
|
|
2493 int shift = 0;
|
|
2494 int alt = 0;
|
|
2495
|
|
2496 if (mod_mask & MOD_MASK_CTRL)
|
|
2497 ctrl = 1;
|
|
2498 if (mod_mask & MOD_MASK_SHIFT)
|
|
2499 shift = 1;
|
|
2500 if (mod_mask & MOD_MASK_ALT)
|
|
2501 alt = 1;
|
|
2502
|
|
2503
|
|
2504 switch (key)
|
|
2505 {
|
|
2506 case K_F1: name = "F1"; break;
|
|
2507 case K_S_F1: name = "F1"; shift = 1; break;
|
|
2508 case K_F2: name = "F2"; break;
|
|
2509 case K_S_F2: name = "F2"; shift = 1; break;
|
|
2510 case K_F3: name = "F3"; break;
|
|
2511 case K_S_F3: name = "F3"; shift = 1; break;
|
|
2512 case K_F4: name = "F4"; break;
|
|
2513 case K_S_F4: name = "F4"; shift = 1; break;
|
|
2514 case K_F5: name = "F5"; break;
|
|
2515 case K_S_F5: name = "F5"; shift = 1; break;
|
|
2516 case K_F6: name = "F6"; break;
|
|
2517 case K_S_F6: name = "F6"; shift = 1; break;
|
|
2518 case K_F7: name = "F7"; break;
|
|
2519 case K_S_F7: name = "F7"; shift = 1; break;
|
|
2520 case K_F8: name = "F8"; break;
|
|
2521 case K_S_F8: name = "F8"; shift = 1; break;
|
|
2522 case K_F9: name = "F9"; break;
|
|
2523 case K_S_F9: name = "F9"; shift = 1; break;
|
|
2524 case K_F10: name = "F10"; break;
|
|
2525 case K_S_F10: name = "F10"; shift = 1; break;
|
|
2526 case K_F11: name = "F11"; break;
|
|
2527 case K_S_F11: name = "F11"; shift = 1; break;
|
|
2528 case K_F12: name = "F12"; break;
|
|
2529 case K_S_F12: name = "F12"; shift = 1; break;
|
|
2530 default:
|
|
2531 if (key >= ' ' && key <= '~')
|
|
2532 {
|
|
2533 /* Allow ASCII characters. */
|
|
2534 name = namebuf;
|
|
2535 namebuf[0] = key;
|
|
2536 namebuf[1] = NUL;
|
|
2537 }
|
|
2538 else
|
|
2539 name = "X";
|
|
2540 break;
|
|
2541 }
|
|
2542
|
|
2543 buf[0] = '\0';
|
|
2544 if (ctrl)
|
|
2545 strcat(buf, "C");
|
|
2546 if (shift)
|
|
2547 strcat(buf, "S");
|
|
2548 if (alt)
|
|
2549 strcat(buf, "M"); /* META */
|
|
2550 if (ctrl || shift || alt)
|
|
2551 strcat(buf, "-");
|
|
2552 strcat(buf, name);
|
|
2553 }
|
|
2554
|
|
2555 #ifdef FEAT_BEVAL
|
|
2556 /*
|
|
2557 * Function to be called for balloon evaluation. Grabs the text under the
|
|
2558 * cursor and sends it to the debugger for evaluation. The debugger should
|
|
2559 * respond with a showBalloon command when there is a useful result.
|
|
2560 */
|
|
2561 /*ARGSUSED*/
|
183
|
2562 void
|
7
|
2563 netbeans_beval_cb(
|
|
2564 BalloonEval *beval,
|
|
2565 int state)
|
|
2566 {
|
183
|
2567 win_T *wp;
|
7
|
2568 char_u *text;
|
183
|
2569 linenr_T lnum;
|
7
|
2570 int col;
|
|
2571 char buf[MAXPATHL * 2 + 25];
|
|
2572 char_u *p;
|
|
2573
|
|
2574 /* Don't do anything when 'ballooneval' is off, messages scrolled the
|
|
2575 * windows up or we have no connection. */
|
|
2576 if (!p_beval || msg_scrolled > 0 || !haveConnection)
|
|
2577 return;
|
|
2578
|
183
|
2579 if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
|
7
|
2580 {
|
|
2581 /* Send debugger request. Only when the text is of reasonable
|
|
2582 * length. */
|
|
2583 if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL)
|
|
2584 {
|
|
2585 p = nb_quote(text);
|
|
2586 if (p != NULL)
|
33
|
2587 {
|
272
|
2588 vim_snprintf(buf, sizeof(buf),
|
944
|
2589 "0:balloonText=%d \"%s\"\n", r_cmdno, p);
|
33
|
2590 vim_free(p);
|
|
2591 }
|
7
|
2592 nbdebug(("EVT: %s", buf));
|
|
2593 nb_send(buf, "netbeans_beval_cb");
|
|
2594 }
|
|
2595 vim_free(text);
|
|
2596 }
|
|
2597 }
|
|
2598 #endif
|
|
2599
|
|
2600 /*
|
|
2601 * Tell netbeans that the window was opened, ready for commands.
|
|
2602 */
|
|
2603 void
|
|
2604 netbeans_startup_done(void)
|
|
2605 {
|
|
2606 char *cmd = "0:startupDone=0\n";
|
|
2607
|
33
|
2608 if (usingNetbeans)
|
|
2609 #ifdef FEAT_GUI_MOTIF
|
|
2610 netbeans_Xt_connect(app_context);
|
|
2611 #else
|
|
2612 # ifdef FEAT_GUI_GTK
|
|
2613 netbeans_gtk_connect();
|
167
|
2614 # else
|
|
2615 # ifdef FEAT_GUI_W32
|
|
2616 netbeans_w32_connect();
|
|
2617 # endif
|
33
|
2618 # endif
|
|
2619 #endif
|
|
2620
|
7
|
2621 if (!haveConnection)
|
|
2622 return;
|
|
2623
|
183
|
2624 #ifdef FEAT_BEVAL
|
|
2625 bevalServers |= BEVAL_NETBEANS;
|
|
2626 #endif
|
|
2627
|
7
|
2628 nbdebug(("EVT: %s", cmd));
|
|
2629 nb_send(cmd, "netbeans_startup_done");
|
|
2630 }
|
|
2631
|
33
|
2632 /*
|
|
2633 * Tell netbeans that we're exiting. This should be called right
|
|
2634 * before calling exit.
|
|
2635 */
|
|
2636 void
|
|
2637 netbeans_send_disconnect()
|
|
2638 {
|
|
2639 char buf[128];
|
|
2640
|
|
2641 if (haveConnection)
|
|
2642 {
|
944
|
2643 sprintf(buf, "0:disconnect=%d\n", r_cmdno);
|
33
|
2644 nbdebug(("EVT: %s", buf));
|
|
2645 nb_send(buf, "netbeans_disconnect");
|
|
2646 }
|
|
2647 }
|
|
2648
|
7
|
2649 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_W32) || defined(PROTO)
|
|
2650 /*
|
|
2651 * Tell netbeans that the window was moved or resized.
|
|
2652 */
|
|
2653 void
|
|
2654 netbeans_frame_moved(int new_x, int new_y)
|
|
2655 {
|
|
2656 char buf[128];
|
|
2657
|
|
2658 if (!haveConnection)
|
|
2659 return;
|
|
2660
|
|
2661 sprintf(buf, "0:geometry=%d %d %d %d %d\n",
|
944
|
2662 r_cmdno, (int)Columns, (int)Rows, new_x, new_y);
|
33
|
2663 /*nbdebug(("EVT: %s", buf)); happens too many times during a move */
|
7
|
2664 nb_send(buf, "netbeans_frame_moved");
|
|
2665 }
|
|
2666 #endif
|
|
2667
|
|
2668 /*
|
33
|
2669 * Tell netbeans the user opened or activated a file.
|
|
2670 */
|
|
2671 void
|
|
2672 netbeans_file_activated(buf_T *bufp)
|
|
2673 {
|
|
2674 int bufno = nb_getbufno(bufp);
|
|
2675 nbbuf_T *bp = nb_get_buf(bufno);
|
|
2676 char buffer[2*MAXPATHL];
|
|
2677 char_u *q;
|
|
2678
|
|
2679 if (!haveConnection || dosetvisible)
|
|
2680 return;
|
|
2681
|
|
2682 q = nb_quote(bufp->b_ffname);
|
840
|
2683 if (q == NULL || bp == NULL)
|
33
|
2684 return;
|
|
2685
|
272
|
2686 vim_snprintf(buffer, sizeof(buffer), "%d:fileOpened=%d \"%s\" %s %s\n",
|
33
|
2687 bufno,
|
|
2688 bufno,
|
|
2689 (char *)q,
|
|
2690 "T", /* open in NetBeans */
|
|
2691 "F"); /* modified */
|
|
2692
|
|
2693 vim_free(q);
|
|
2694 nbdebug(("EVT: %s", buffer));
|
|
2695
|
|
2696 nb_send(buffer, "netbeans_file_opened");
|
|
2697 }
|
|
2698
|
|
2699 /*
|
7
|
2700 * Tell netbeans the user opened a file.
|
|
2701 */
|
|
2702 void
|
33
|
2703 netbeans_file_opened(buf_T *bufp)
|
7
|
2704 {
|
33
|
2705 int bufno = nb_getbufno(bufp);
|
7
|
2706 char buffer[2*MAXPATHL];
|
|
2707 char_u *q;
|
33
|
2708 nbbuf_T *bp = nb_get_buf(nb_getbufno(bufp));
|
|
2709 int bnum;
|
7
|
2710
|
|
2711 if (!haveConnection)
|
|
2712 return;
|
|
2713
|
33
|
2714 q = nb_quote(bufp->b_ffname);
|
7
|
2715 if (q == NULL)
|
|
2716 return;
|
33
|
2717 if (bp != NULL)
|
|
2718 bnum = bufno;
|
|
2719 else
|
|
2720 bnum = 0;
|
|
2721
|
272
|
2722 vim_snprintf(buffer, sizeof(buffer), "%d:fileOpened=%d \"%s\" %s %s\n",
|
33
|
2723 bnum,
|
7
|
2724 0,
|
|
2725 (char *)q,
|
|
2726 "T", /* open in NetBeans */
|
|
2727 "F"); /* modified */
|
|
2728
|
|
2729 vim_free(q);
|
|
2730 nbdebug(("EVT: %s", buffer));
|
|
2731
|
|
2732 nb_send(buffer, "netbeans_file_opened");
|
33
|
2733 if (p_acd && vim_chdirfile(bufp->b_ffname) == OK)
|
7
|
2734 shorten_fnames(TRUE);
|
|
2735 }
|
|
2736
|
|
2737 /*
|
|
2738 * Tell netbeans a file was closed.
|
|
2739 */
|
|
2740 void
|
|
2741 netbeans_file_closed(buf_T *bufp)
|
|
2742 {
|
|
2743 int bufno = nb_getbufno(bufp);
|
|
2744 nbbuf_T *nbbuf = nb_get_buf(bufno);
|
|
2745 char buffer[2*MAXPATHL];
|
|
2746
|
|
2747 if (!haveConnection || bufno < 0)
|
|
2748 return;
|
|
2749
|
|
2750 if (!netbeansCloseFile)
|
|
2751 {
|
33
|
2752 nbdebug(("Ignoring file_closed for %s. File was closed from IDE\n",
|
|
2753 bufp->b_ffname));
|
7
|
2754 return;
|
|
2755 }
|
|
2756
|
33
|
2757 nbdebug(("netbeans_file_closed:\n"));
|
|
2758 nbdebug((" Closing bufno: %d", bufno));
|
|
2759 if (curbuf != NULL && curbuf != bufp)
|
|
2760 {
|
|
2761 nbdebug((" Curbuf bufno: %d\n", nb_getbufno(curbuf)));
|
|
2762 }
|
|
2763 else if (curbuf == bufp)
|
|
2764 {
|
|
2765 nbdebug((" curbuf == bufp\n"));
|
|
2766 }
|
7
|
2767
|
|
2768 if (bufno <= 0)
|
|
2769 return;
|
|
2770
|
944
|
2771 sprintf(buffer, "%d:killed=%d\n", bufno, r_cmdno);
|
7
|
2772
|
|
2773 nbdebug(("EVT: %s", buffer));
|
|
2774
|
|
2775 nb_send(buffer, "netbeans_file_closed");
|
|
2776
|
|
2777 if (nbbuf != NULL)
|
|
2778 nbbuf->bufp = NULL;
|
|
2779 }
|
|
2780
|
|
2781 /*
|
|
2782 * Get a pointer to the Netbeans buffer for Vim buffer "bufp".
|
|
2783 * Return NULL if there is no such buffer or changes are not to be reported.
|
|
2784 * Otherwise store the buffer number in "*bufnop".
|
|
2785 */
|
|
2786 static nbbuf_T *
|
|
2787 nb_bufp2nbbuf_fire(buf_T *bufp, int *bufnop)
|
|
2788 {
|
|
2789 int bufno;
|
|
2790 nbbuf_T *nbbuf;
|
|
2791
|
|
2792 if (!haveConnection || !netbeansFireChanges)
|
|
2793 return NULL; /* changes are not reported at all */
|
|
2794
|
|
2795 bufno = nb_getbufno(bufp);
|
|
2796 if (bufno <= 0)
|
|
2797 return NULL; /* file is not known to NetBeans */
|
|
2798
|
|
2799 nbbuf = nb_get_buf(bufno);
|
|
2800 if (nbbuf != NULL && !nbbuf->fireChanges)
|
|
2801 return NULL; /* changes in this buffer are not reported */
|
|
2802
|
|
2803 *bufnop = bufno;
|
|
2804 return nbbuf;
|
|
2805 }
|
|
2806
|
|
2807 /*
|
|
2808 * Tell netbeans the user inserted some text.
|
|
2809 */
|
|
2810 void
|
|
2811 netbeans_inserted(
|
|
2812 buf_T *bufp,
|
|
2813 linenr_T linenr,
|
|
2814 colnr_T col,
|
|
2815 char_u *txt,
|
|
2816 int newlen)
|
|
2817 {
|
|
2818 char_u *buf;
|
|
2819 int bufno;
|
|
2820 nbbuf_T *nbbuf;
|
|
2821 pos_T pos;
|
|
2822 long off;
|
|
2823 char_u *p;
|
|
2824 char_u *newtxt;
|
|
2825
|
|
2826 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
2827 if (nbbuf == NULL)
|
|
2828 return;
|
|
2829
|
33
|
2830 /* Don't mark as modified for initial read */
|
|
2831 if (nbbuf->insertDone)
|
|
2832 nbbuf->modified = 1;
|
7
|
2833
|
|
2834 pos.lnum = linenr;
|
|
2835 pos.col = col;
|
|
2836 off = pos2off(bufp, &pos);
|
|
2837
|
|
2838 /* send the "insert" EVT */
|
|
2839 newtxt = alloc(newlen + 1);
|
416
|
2840 vim_strncpy(newtxt, txt, newlen);
|
7
|
2841 p = nb_quote(newtxt);
|
|
2842 if (p != NULL)
|
|
2843 {
|
33
|
2844 buf = alloc(128 + 2*newlen);
|
944
|
2845 sprintf((char *)buf, "%d:insert=%d %ld \"%s\"\n",
|
|
2846 bufno, r_cmdno, off, p);
|
7
|
2847 nbdebug(("EVT: %s", buf));
|
|
2848 nb_send((char *)buf, "netbeans_inserted");
|
33
|
2849 vim_free(p);
|
|
2850 vim_free(buf);
|
7
|
2851 }
|
|
2852 vim_free(newtxt);
|
|
2853 }
|
|
2854
|
|
2855 /*
|
|
2856 * Tell netbeans some bytes have been removed.
|
|
2857 */
|
|
2858 void
|
|
2859 netbeans_removed(
|
|
2860 buf_T *bufp,
|
|
2861 linenr_T linenr,
|
|
2862 colnr_T col,
|
|
2863 long len)
|
|
2864 {
|
|
2865 char_u buf[128];
|
|
2866 int bufno;
|
|
2867 nbbuf_T *nbbuf;
|
|
2868 pos_T pos;
|
|
2869 long off;
|
|
2870
|
|
2871 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
2872 if (nbbuf == NULL)
|
|
2873 return;
|
|
2874
|
|
2875 if (len < 0)
|
|
2876 {
|
|
2877 nbdebug(("Negative len %ld in netbeans_removed()!", len));
|
|
2878 return;
|
|
2879 }
|
|
2880
|
|
2881 nbbuf->modified = 1;
|
|
2882
|
|
2883 pos.lnum = linenr;
|
|
2884 pos.col = col;
|
|
2885
|
|
2886 off = pos2off(bufp, &pos);
|
|
2887
|
944
|
2888 sprintf((char *)buf, "%d:remove=%d %ld %ld\n", bufno, r_cmdno, off, len);
|
7
|
2889 nbdebug(("EVT: %s", buf));
|
|
2890 nb_send((char *)buf, "netbeans_removed");
|
|
2891 }
|
|
2892
|
|
2893 /*
|
|
2894 * Send netbeans an unmodufied command.
|
|
2895 */
|
|
2896 /*ARGSUSED*/
|
|
2897 void
|
|
2898 netbeans_unmodified(buf_T *bufp)
|
|
2899 {
|
|
2900 #if 0
|
|
2901 char_u buf[128];
|
|
2902 int bufno;
|
|
2903 nbbuf_T *nbbuf;
|
|
2904
|
|
2905 /* This has been disabled, because NetBeans considers a buffer modified
|
|
2906 * even when all changes have been undone. */
|
|
2907 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
2908 if (nbbuf == NULL)
|
|
2909 return;
|
|
2910
|
|
2911 nbbuf->modified = 0;
|
|
2912
|
944
|
2913 sprintf((char *)buf, "%d:unmodified=%d\n", bufno, r_cmdno);
|
7
|
2914 nbdebug(("EVT: %s", buf));
|
|
2915 nb_send((char *)buf, "netbeans_unmodified");
|
|
2916 #endif
|
|
2917 }
|
|
2918
|
|
2919 /*
|
|
2920 * Send a button release event back to netbeans. Its up to netbeans
|
|
2921 * to decide what to do (if anything) with this event.
|
|
2922 */
|
|
2923 void
|
|
2924 netbeans_button_release(int button)
|
|
2925 {
|
|
2926 char buf[128];
|
|
2927 int bufno;
|
|
2928
|
|
2929 bufno = nb_getbufno(curbuf);
|
|
2930
|
|
2931 if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf)
|
|
2932 {
|
118
|
2933 int col = mouse_col - W_WINCOL(curwin) - (curwin->w_p_nu ? 9 : 1);
|
7
|
2934 long off = pos2off(curbuf, &curwin->w_cursor);
|
|
2935
|
|
2936 /* sync the cursor position */
|
944
|
2937 sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
|
7
|
2938 nbdebug(("EVT: %s", buf));
|
|
2939 nb_send(buf, "netbeans_button_release[newDotAndMark]");
|
|
2940
|
944
|
2941 sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno,
|
7
|
2942 button, (long)curwin->w_cursor.lnum, col);
|
|
2943 nbdebug(("EVT: %s", buf));
|
|
2944 nb_send(buf, "netbeans_button_release");
|
|
2945 }
|
|
2946 }
|
|
2947
|
|
2948
|
|
2949 /*
|
|
2950 * Send a keypress event back to netbeans. This usualy simulates some
|
33
|
2951 * kind of function key press. This function operates on a key code.
|
7
|
2952 */
|
|
2953 void
|
|
2954 netbeans_keycommand(int key)
|
|
2955 {
|
33
|
2956 char keyName[60];
|
|
2957
|
|
2958 netbeans_keyname(key, keyName);
|
|
2959 netbeans_keystring(key, keyName);
|
|
2960 }
|
|
2961
|
|
2962
|
|
2963 /*
|
|
2964 * Send a keypress event back to netbeans. This usualy simulates some
|
|
2965 * kind of function key press. This function operates on a key string.
|
|
2966 */
|
|
2967 static void
|
|
2968 netbeans_keystring(int key, char *keyName)
|
|
2969 {
|
7
|
2970 char buf[2*MAXPATHL];
|
33
|
2971 int bufno = nb_getbufno(curbuf);
|
7
|
2972 long off;
|
|
2973 char_u *q;
|
|
2974
|
|
2975 if (!haveConnection)
|
|
2976 return;
|
|
2977
|
|
2978
|
|
2979 if (bufno == -1)
|
|
2980 {
|
|
2981 nbdebug(("got keycommand for non-NetBeans buffer, opening...\n"));
|
|
2982 q = curbuf->b_ffname == NULL ? (char_u *)""
|
|
2983 : nb_quote(curbuf->b_ffname);
|
|
2984 if (q == NULL)
|
|
2985 return;
|
272
|
2986 vim_snprintf(buf, sizeof(buf), "0:fileOpened=%d \"%s\" %s %s\n", 0,
|
7
|
2987 q,
|
|
2988 "T", /* open in NetBeans */
|
|
2989 "F"); /* modified */
|
|
2990 if (curbuf->b_ffname != NULL)
|
|
2991 vim_free(q);
|
|
2992 nbdebug(("EVT: %s", buf));
|
|
2993 nb_send(buf, "netbeans_keycommand");
|
|
2994
|
143
|
2995 if (key > 0)
|
|
2996 postpone_keycommand(key);
|
7
|
2997 return;
|
|
2998 }
|
|
2999
|
|
3000 /* sync the cursor position */
|
|
3001 off = pos2off(curbuf, &curwin->w_cursor);
|
944
|
3002 sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
|
7
|
3003 nbdebug(("EVT: %s", buf));
|
|
3004 nb_send(buf, "netbeans_keycommand");
|
|
3005
|
|
3006 /* To work on Win32 you must apply patch to ExtEditor module
|
|
3007 * from ExtEdCaret.java.diff - make EVT_newDotAndMark handler
|
|
3008 * more synchronous
|
|
3009 */
|
|
3010
|
|
3011 /* now send keyCommand event */
|
272
|
3012 vim_snprintf(buf, sizeof(buf), "%d:keyCommand=%d \"%s\"\n",
|
944
|
3013 bufno, r_cmdno, keyName);
|
7
|
3014 nbdebug(("EVT: %s", buf));
|
|
3015 nb_send(buf, "netbeans_keycommand");
|
|
3016
|
|
3017 /* New: do both at once and include the lnum/col. */
|
272
|
3018 vim_snprintf(buf, sizeof(buf), "%d:keyAtPos=%d \"%s\" %ld %ld/%ld\n",
|
944
|
3019 bufno, r_cmdno, keyName,
|
7
|
3020 off, (long)curwin->w_cursor.lnum, (long)curwin->w_cursor.col);
|
|
3021 nbdebug(("EVT: %s", buf));
|
|
3022 nb_send(buf, "netbeans_keycommand");
|
|
3023 }
|
|
3024
|
|
3025
|
|
3026 /*
|
|
3027 * Send a save event to netbeans.
|
|
3028 */
|
|
3029 void
|
|
3030 netbeans_save_buffer(buf_T *bufp)
|
|
3031 {
|
|
3032 char_u buf[64];
|
|
3033 int bufno;
|
|
3034 nbbuf_T *nbbuf;
|
|
3035
|
|
3036 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
3037 if (nbbuf == NULL)
|
|
3038 return;
|
|
3039
|
|
3040 nbbuf->modified = 0;
|
|
3041
|
944
|
3042 sprintf((char *)buf, "%d:save=%d\n", bufno, r_cmdno);
|
7
|
3043 nbdebug(("EVT: %s", buf));
|
|
3044 nb_send((char *)buf, "netbeans_save_buffer");
|
|
3045 }
|
|
3046
|
|
3047
|
|
3048 /*
|
|
3049 * Send remove command to netbeans (this command has been turned off).
|
|
3050 */
|
|
3051 void
|
|
3052 netbeans_deleted_all_lines(buf_T *bufp)
|
|
3053 {
|
|
3054 char_u buf[64];
|
|
3055 int bufno;
|
|
3056 nbbuf_T *nbbuf;
|
|
3057
|
|
3058 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
3059 if (nbbuf == NULL)
|
|
3060 return;
|
|
3061
|
33
|
3062 /* Don't mark as modified for initial read */
|
|
3063 if (nbbuf->insertDone)
|
|
3064 nbbuf->modified = 1;
|
7
|
3065
|
944
|
3066 sprintf((char *)buf, "%d:remove=%d 0 -1\n", bufno, r_cmdno);
|
7
|
3067 nbdebug(("EVT(suppressed): %s", buf));
|
|
3068 /* nb_send(buf, "netbeans_deleted_all_lines"); */
|
|
3069 }
|
|
3070
|
|
3071
|
|
3072 /*
|
|
3073 * See if the lines are guarded. The top and bot parameters are from
|
|
3074 * u_savecommon(), these are the line above the change and the line below the
|
|
3075 * change.
|
|
3076 */
|
|
3077 int
|
|
3078 netbeans_is_guarded(linenr_T top, linenr_T bot)
|
|
3079 {
|
|
3080 signlist_T *p;
|
|
3081 int lnum;
|
|
3082
|
|
3083 for (p = curbuf->b_signlist; p != NULL; p = p->next)
|
|
3084 if (p->id >= GUARDEDOFFSET)
|
|
3085 for (lnum = top + 1; lnum < bot; lnum++)
|
|
3086 if (lnum == p->lnum)
|
|
3087 return TRUE;
|
|
3088
|
|
3089 return FALSE;
|
|
3090 }
|
|
3091
|
|
3092 #if defined(FEAT_GUI_MOTIF) || defined(PROTO)
|
|
3093 /*
|
|
3094 * We have multiple signs to draw at the same location. Draw the
|
|
3095 * multi-sign indicator instead. This is the Motif version.
|
|
3096 */
|
|
3097 void
|
|
3098 netbeans_draw_multisign_indicator(int row)
|
|
3099 {
|
|
3100 int i;
|
|
3101 int y;
|
|
3102 int x;
|
|
3103
|
|
3104 x = 0;
|
|
3105 y = row * gui.char_height + 2;
|
|
3106
|
|
3107 for (i = 0; i < gui.char_height - 3; i++)
|
|
3108 XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+2, y++);
|
|
3109
|
|
3110 XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+0, y);
|
|
3111 XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+2, y);
|
|
3112 XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+4, y++);
|
|
3113 XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+1, y);
|
|
3114 XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+2, y);
|
|
3115 XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+3, y++);
|
|
3116 XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+2, y);
|
|
3117 }
|
|
3118 #endif /* FEAT_GUI_MOTIF */
|
|
3119
|
|
3120 #ifdef FEAT_GUI_GTK
|
|
3121 /*
|
|
3122 * We have multiple signs to draw at the same location. Draw the
|
|
3123 * multi-sign indicator instead. This is the GTK/Gnome version.
|
|
3124 */
|
|
3125 void
|
|
3126 netbeans_draw_multisign_indicator(int row)
|
|
3127 {
|
|
3128 int i;
|
|
3129 int y;
|
|
3130 int x;
|
|
3131 GdkDrawable *drawable = gui.drawarea->window;
|
|
3132
|
|
3133 x = 0;
|
|
3134 y = row * gui.char_height + 2;
|
|
3135
|
|
3136 for (i = 0; i < gui.char_height - 3; i++)
|
|
3137 gdk_draw_point(drawable, gui.text_gc, x+2, y++);
|
|
3138
|
|
3139 gdk_draw_point(drawable, gui.text_gc, x+0, y);
|
|
3140 gdk_draw_point(drawable, gui.text_gc, x+2, y);
|
|
3141 gdk_draw_point(drawable, gui.text_gc, x+4, y++);
|
|
3142 gdk_draw_point(drawable, gui.text_gc, x+1, y);
|
|
3143 gdk_draw_point(drawable, gui.text_gc, x+2, y);
|
|
3144 gdk_draw_point(drawable, gui.text_gc, x+3, y++);
|
|
3145 gdk_draw_point(drawable, gui.text_gc, x+2, y);
|
|
3146 }
|
|
3147 #endif /* FEAT_GUI_GTK */
|
|
3148
|
|
3149 /*
|
|
3150 * If the mouse is clicked in the gutter of a line with multiple
|
|
3151 * annotations, cycle through the set of signs.
|
|
3152 */
|
|
3153 void
|
|
3154 netbeans_gutter_click(linenr_T lnum)
|
|
3155 {
|
|
3156 signlist_T *p;
|
|
3157
|
|
3158 for (p = curbuf->b_signlist; p != NULL; p = p->next)
|
|
3159 {
|
|
3160 if (p->lnum == lnum && p->next && p->next->lnum == lnum)
|
|
3161 {
|
|
3162 signlist_T *tail;
|
|
3163
|
|
3164 /* remove "p" from list, reinsert it at the tail of the sublist */
|
|
3165 if (p->prev)
|
|
3166 p->prev->next = p->next;
|
|
3167 else
|
|
3168 curbuf->b_signlist = p->next;
|
|
3169 p->next->prev = p->prev;
|
|
3170 /* now find end of sublist and insert p */
|
|
3171 for (tail = p->next;
|
|
3172 tail->next && tail->next->lnum == lnum
|
|
3173 && tail->next->id < GUARDEDOFFSET;
|
|
3174 tail = tail->next)
|
|
3175 ;
|
|
3176 /* tail now points to last entry with same lnum (except
|
|
3177 * that "guarded" annotations are always last) */
|
|
3178 p->next = tail->next;
|
|
3179 if (tail->next)
|
|
3180 tail->next->prev = p;
|
|
3181 p->prev = tail;
|
|
3182 tail->next = p;
|
|
3183 update_debug_sign(curbuf, lnum);
|
|
3184 break;
|
|
3185 }
|
|
3186 }
|
|
3187 }
|
|
3188
|
|
3189
|
|
3190 /*
|
|
3191 * Add a sign of the reqested type at the requested location.
|
|
3192 *
|
|
3193 * Reverse engineering:
|
|
3194 * Apparently an annotation is defined the first time it is used in a buffer.
|
|
3195 * When the same annotation is used in two buffers, the second time we do not
|
|
3196 * need to define a new sign name but reuse the existing one. But since the
|
|
3197 * ID number used in the second buffer starts counting at one again, a mapping
|
|
3198 * is made from the ID specifically for the buffer to the global sign name
|
|
3199 * (which is a number).
|
|
3200 *
|
|
3201 * globalsignmap[] stores the signs that have been defined globally.
|
|
3202 * buf->signmapused[] maps buffer-local annotation IDs to an index in
|
|
3203 * globalsignmap[].
|
|
3204 */
|
|
3205 /*ARGSUSED*/
|
|
3206 static void
|
|
3207 addsigntype(
|
|
3208 nbbuf_T *buf,
|
|
3209 int typeNum,
|
|
3210 char_u *typeName,
|
|
3211 char_u *tooltip,
|
|
3212 char_u *glyphFile,
|
|
3213 int use_fg,
|
|
3214 int fg,
|
|
3215 int use_bg,
|
|
3216 int bg)
|
|
3217 {
|
|
3218 char fgbuf[32];
|
|
3219 char bgbuf[32];
|
|
3220 int i, j;
|
|
3221
|
|
3222 for (i = 0; i < globalsignmapused; i++)
|
|
3223 if (STRCMP(typeName, globalsignmap[i]) == 0)
|
|
3224 break;
|
|
3225
|
|
3226 if (i == globalsignmapused) /* not found; add it to global map */
|
|
3227 {
|
|
3228 nbdebug(("DEFINEANNOTYPE(%d,%s,%s,%s,%d,%d)\n",
|
|
3229 typeNum, typeName, tooltip, glyphFile, fg, bg));
|
|
3230 if (use_fg || use_bg)
|
|
3231 {
|
|
3232 sprintf(fgbuf, "guifg=#%06x", fg & 0xFFFFFF);
|
|
3233 sprintf(bgbuf, "guibg=#%06x", bg & 0xFFFFFF);
|
|
3234
|
|
3235 coloncmd(":highlight NB_%s %s %s", typeName, (use_fg) ? fgbuf : "",
|
|
3236 (use_bg) ? bgbuf : "");
|
|
3237 if (*glyphFile == NUL)
|
|
3238 /* no glyph, line highlighting only */
|
|
3239 coloncmd(":sign define %d linehl=NB_%s", i + 1, typeName);
|
|
3240 else if (vim_strsize(glyphFile) <= 2)
|
|
3241 /* one- or two-character glyph name, use as text glyph with
|
|
3242 * texthl */
|
|
3243 coloncmd(":sign define %d text=%s texthl=NB_%s", i + 1,
|
|
3244 glyphFile, typeName);
|
|
3245 else
|
|
3246 /* glyph, line highlighting */
|
|
3247 coloncmd(":sign define %d icon=%s linehl=NB_%s", i + 1,
|
|
3248 glyphFile, typeName);
|
|
3249 }
|
|
3250 else
|
|
3251 /* glyph, no line highlighting */
|
|
3252 coloncmd(":sign define %d icon=%s", i + 1, glyphFile);
|
|
3253
|
|
3254 if (STRCMP(typeName,"CurrentPC") == 0)
|
|
3255 curPCtype = typeNum;
|
|
3256
|
|
3257 if (globalsignmapused == globalsignmaplen)
|
|
3258 {
|
|
3259 if (globalsignmaplen == 0) /* first allocation */
|
|
3260 {
|
|
3261 globalsignmaplen = 20;
|
|
3262 globalsignmap = (char **)alloc_clear(globalsignmaplen*sizeof(char *));
|
|
3263 }
|
|
3264 else /* grow it */
|
|
3265 {
|
|
3266 int incr;
|
|
3267 int oldlen = globalsignmaplen;
|
|
3268
|
|
3269 globalsignmaplen *= 2;
|
|
3270 incr = globalsignmaplen - oldlen;
|
|
3271 globalsignmap = (char **)vim_realloc(globalsignmap,
|
|
3272 globalsignmaplen * sizeof(char *));
|
|
3273 memset(globalsignmap + oldlen, 0, incr * sizeof(char *));
|
|
3274 }
|
|
3275 }
|
|
3276
|
|
3277 globalsignmap[i] = (char *)typeName;
|
|
3278 globalsignmapused = i + 1;
|
|
3279 }
|
|
3280
|
|
3281 /* check local map; should *not* be found! */
|
|
3282 for (j = 0; j < buf->signmapused; j++)
|
|
3283 if (buf->signmap[j] == i + 1)
|
|
3284 return;
|
|
3285
|
|
3286 /* add to local map */
|
|
3287 if (buf->signmapused == buf->signmaplen)
|
|
3288 {
|
|
3289 if (buf->signmaplen == 0) /* first allocation */
|
|
3290 {
|
|
3291 buf->signmaplen = 5;
|
|
3292 buf->signmap = (int *)alloc_clear(buf->signmaplen * sizeof(int *));
|
|
3293 }
|
|
3294 else /* grow it */
|
|
3295 {
|
|
3296 int incr;
|
|
3297 int oldlen = buf->signmaplen;
|
|
3298 buf->signmaplen *= 2;
|
|
3299 incr = buf->signmaplen - oldlen;
|
|
3300 buf->signmap = (int *)vim_realloc(buf->signmap,
|
|
3301 buf->signmaplen*sizeof(int *));
|
|
3302 memset(buf->signmap + oldlen, 0, incr * sizeof(int *));
|
|
3303 }
|
|
3304 }
|
|
3305
|
|
3306 buf->signmap[buf->signmapused++] = i + 1;
|
|
3307
|
|
3308 }
|
|
3309
|
|
3310
|
|
3311 /*
|
|
3312 * See if we have the requested sign type in the buffer.
|
|
3313 */
|
|
3314 static int
|
|
3315 mapsigntype(nbbuf_T *buf, int localsigntype)
|
|
3316 {
|
|
3317 if (--localsigntype >= 0 && localsigntype < buf->signmapused)
|
|
3318 return buf->signmap[localsigntype];
|
|
3319
|
|
3320 return 0;
|
|
3321 }
|
|
3322
|
|
3323
|
|
3324 /*
|
|
3325 * Compute length of buffer, don't print anything.
|
|
3326 */
|
|
3327 static long
|
|
3328 get_buf_size(buf_T *bufp)
|
|
3329 {
|
|
3330 linenr_T lnum;
|
|
3331 long char_count = 0;
|
|
3332 int eol_size;
|
|
3333 long last_check = 100000L;
|
|
3334
|
|
3335 if (bufp->b_ml.ml_flags & ML_EMPTY)
|
|
3336 return 0;
|
|
3337 else
|
|
3338 {
|
|
3339 if (get_fileformat(bufp) == EOL_DOS)
|
|
3340 eol_size = 2;
|
|
3341 else
|
|
3342 eol_size = 1;
|
|
3343 for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
|
|
3344 {
|
835
|
3345 char_count += (long)STRLEN(ml_get(lnum)) + eol_size;
|
7
|
3346 /* Check for a CTRL-C every 100000 characters */
|
|
3347 if (char_count > last_check)
|
|
3348 {
|
|
3349 ui_breakcheck();
|
|
3350 if (got_int)
|
|
3351 return char_count;
|
|
3352 last_check = char_count + 100000L;
|
|
3353 }
|
|
3354 }
|
|
3355 /* Correction for when last line doesn't have an EOL. */
|
|
3356 if (!bufp->b_p_eol && bufp->b_p_bin)
|
|
3357 char_count -= eol_size;
|
|
3358 }
|
|
3359
|
|
3360 return char_count;
|
|
3361 }
|
|
3362
|
|
3363 /*
|
|
3364 * Convert character offset to lnum,col
|
|
3365 */
|
|
3366 static pos_T *
|
|
3367 off2pos(buf_T *buf, long offset)
|
|
3368 {
|
|
3369 linenr_T lnum;
|
|
3370 static pos_T pos;
|
|
3371
|
|
3372 pos.lnum = 0;
|
|
3373 pos.col = 0;
|
|
3374 #ifdef FEAT_VIRTUALEDIT
|
|
3375 pos.coladd = 0;
|
|
3376 #endif
|
|
3377
|
|
3378 if (!(buf->b_ml.ml_flags & ML_EMPTY))
|
|
3379 {
|
|
3380 if ((lnum = ml_find_line_or_offset(buf, (linenr_T)0, &offset)) < 0)
|
|
3381 return NULL;
|
|
3382 pos.lnum = lnum;
|
|
3383 pos.col = offset;
|
|
3384 }
|
|
3385
|
|
3386 return &pos;
|
|
3387 }
|
|
3388
|
|
3389 /*
|
|
3390 * Convert an argument in the form "1234" to an offset and compute the
|
|
3391 * lnum/col from it. Convert an argument in the form "123/12" directly to a
|
|
3392 * lnum/col.
|
|
3393 * "argp" is advanced to after the argument.
|
|
3394 * Return a pointer to the position, NULL if something is wrong.
|
|
3395 */
|
|
3396 static pos_T *
|
|
3397 get_off_or_lnum(buf_T *buf, char_u **argp)
|
|
3398 {
|
|
3399 static pos_T mypos;
|
|
3400 long off;
|
|
3401
|
|
3402 off = strtol((char *)*argp, (char **)argp, 10);
|
|
3403 if (**argp == '/')
|
|
3404 {
|
|
3405 mypos.lnum = (linenr_T)off;
|
|
3406 ++*argp;
|
|
3407 mypos.col = strtol((char *)*argp, (char **)argp, 10);
|
|
3408 #ifdef FEAT_VIRTUALEDIT
|
|
3409 mypos.coladd = 0;
|
|
3410 #endif
|
|
3411 return &mypos;
|
|
3412 }
|
|
3413 return off2pos(buf, off);
|
|
3414 }
|
|
3415
|
|
3416
|
|
3417 /*
|
667
|
3418 * Convert (lnum,col) to byte offset in the file.
|
7
|
3419 */
|
|
3420 static long
|
|
3421 pos2off(buf_T *buf, pos_T *pos)
|
|
3422 {
|
|
3423 long offset = 0;
|
|
3424
|
|
3425 if (!(buf->b_ml.ml_flags & ML_EMPTY))
|
|
3426 {
|
|
3427 if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0)
|
|
3428 return 0;
|
|
3429 offset += pos->col;
|
|
3430 }
|
|
3431
|
|
3432 return offset;
|
|
3433 }
|
|
3434
|
|
3435
|
33
|
3436 /*
|
|
3437 * This message is printed after NetBeans opens a new file. Its
|
|
3438 * similar to the message readfile() uses, but since NetBeans
|
|
3439 * doesn't normally call readfile, we do our own.
|
|
3440 */
|
|
3441 static void
|
|
3442 print_read_msg(buf)
|
|
3443 nbbuf_T *buf;
|
|
3444 {
|
|
3445 int lnum = buf->bufp->b_ml.ml_line_count;
|
835
|
3446 long nchars = (long)buf->bufp->b_orig_size;
|
33
|
3447 char_u c;
|
|
3448
|
|
3449 msg_add_fname(buf->bufp, buf->bufp->b_ffname);
|
|
3450 c = FALSE;
|
|
3451
|
|
3452 if (buf->bufp->b_p_ro)
|
|
3453 {
|
|
3454 STRCAT(IObuff, shortmess(SHM_RO) ? _("[RO]") : _("[readonly]"));
|
|
3455 c = TRUE;
|
|
3456 }
|
|
3457 if (!buf->bufp->b_start_eol)
|
|
3458 {
|
|
3459 STRCAT(IObuff, shortmess(SHM_LAST) ? _("[noeol]") : _("[Incomplete last line]"));
|
|
3460 c = TRUE;
|
|
3461 }
|
|
3462 msg_add_lines(c, (long)lnum, nchars);
|
|
3463
|
|
3464 /* Now display it */
|
|
3465 vim_free(keep_msg);
|
|
3466 keep_msg = NULL;
|
|
3467 msg_scrolled_ign = TRUE;
|
|
3468 msg_trunc_attr(IObuff, FALSE, 0);
|
|
3469 msg_scrolled_ign = FALSE;
|
|
3470 }
|
|
3471
|
|
3472
|
|
3473 /*
|
|
3474 * Print a message after NetBeans writes the file. This message should be identical
|
|
3475 * to the standard message a non-netbeans user would see when writing a file.
|
|
3476 */
|
|
3477 static void
|
|
3478 print_save_msg(buf, nchars)
|
|
3479 nbbuf_T *buf;
|
|
3480 long nchars;
|
|
3481 {
|
|
3482 char_u c;
|
|
3483 char_u *p;
|
|
3484
|
|
3485 if (nchars >= 0)
|
|
3486 {
|
|
3487 msg_add_fname(buf->bufp, buf->bufp->b_ffname); /* fname in IObuff with quotes */
|
|
3488 c = FALSE;
|
|
3489
|
|
3490 msg_add_lines(c, buf->bufp->b_ml.ml_line_count,
|
|
3491 (long)buf->bufp->b_orig_size);
|
|
3492
|
|
3493 vim_free(keep_msg);
|
|
3494 keep_msg = NULL;
|
|
3495 msg_scrolled_ign = TRUE;
|
|
3496 p = msg_trunc_attr(IObuff, FALSE, 0);
|
|
3497 if ((msg_scrolled && !need_wait_return) || !buf->initDone)
|
|
3498 {
|
|
3499 /* Need to repeat the message after redrawing when:
|
|
3500 * - When reading from stdin (the screen will be cleared next).
|
|
3501 * - When restart_edit is set (otherwise there will be a delay
|
|
3502 * before redrawing).
|
|
3503 * - When the screen was scrolled but there is no wait-return
|
|
3504 * prompt. */
|
678
|
3505 set_keep_msg(p, 0);
|
33
|
3506 }
|
|
3507 msg_scrolled_ign = FALSE;
|
|
3508 /* add_to_input_buf((char_u *)"\f", 1); */
|
|
3509 }
|
|
3510 else
|
|
3511 {
|
|
3512 char_u ebuf[BUFSIZ];
|
|
3513
|
|
3514 STRCPY(ebuf, (char_u *)_("E505: "));
|
|
3515 STRCAT(ebuf, IObuff);
|
|
3516 STRCAT(ebuf, (char_u *)_("is read-only (add ! to override)"));
|
|
3517 STRCPY(IObuff, ebuf);
|
|
3518 emsg(IObuff);
|
|
3519 }
|
|
3520 }
|
|
3521
|
7
|
3522 #endif /* defined(FEAT_NETBEANS_INTG) */
|