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