comparison src/netbeans.c @ 2210:8c6a66e2b3cc vim73

Add :nbstart and :nbclose.
author Bram Moolenaar <bram@vim.org>
date Sat, 22 May 2010 21:34:09 +0200
parents d0ddf7ba1630
children 0e0e99d1092e
comparison
equal deleted inserted replaced
2209:d0ddf7ba1630 2210:8c6a66e2b3cc
21 #endif 21 #endif
22 22
23 #include "vim.h" 23 #include "vim.h"
24 24
25 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO) 25 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
26
27 /* TODO: when should this not be defined? */
28 #define INET_SOCKETS
26 29
27 /* Note: when making changes here also adjust configure.in. */ 30 /* Note: when making changes here also adjust configure.in. */
28 #ifdef WIN32 31 #ifdef WIN32
29 # ifdef DEBUG 32 # ifdef DEBUG
30 # include <tchar.h> /* for _T definition for TRACEn macros */ 33 # include <tchar.h> /* for _T definition for TRACEn macros */
41 # define sock_write(sd, buf, len) send(sd, buf, len, 0) 44 # define sock_write(sd, buf, len) send(sd, buf, len, 0)
42 # define sock_read(sd, buf, len) recv(sd, buf, len, 0) 45 # define sock_read(sd, buf, len) recv(sd, buf, len, 0)
43 # define sock_close(sd) closesocket(sd) 46 # define sock_close(sd) closesocket(sd)
44 # define sleep(t) Sleep(t*1000) /* WinAPI Sleep() accepts milliseconds */ 47 # define sleep(t) Sleep(t*1000) /* WinAPI Sleep() accepts milliseconds */
45 #else 48 #else
46 # include <netdb.h> 49 # ifdef INET_SOCKETS
47 # include <netinet/in.h> 50 # include <netdb.h>
51 # include <netinet/in.h>
52 # else
53 # include <sys/un.h>
54 # endif
55
48 # include <sys/socket.h> 56 # include <sys/socket.h>
49 # ifdef HAVE_LIBGEN_H 57 # ifdef HAVE_LIBGEN_H
50 # include <libgen.h> 58 # include <libgen.h>
51 # endif 59 # endif
52 # define sock_errno errno 60 # define sock_errno errno
55 # define sock_close(sd) close(sd) 63 # define sock_close(sd) close(sd)
56 #endif 64 #endif
57 65
58 #include "version.h" 66 #include "version.h"
59 67
60 #define INET_SOCKETS
61
62 #define GUARDED 10000 /* typenr for "guarded" annotation */ 68 #define GUARDED 10000 /* typenr for "guarded" annotation */
63 #define GUARDEDOFFSET 1000000 /* base for "guarded" sign id's */ 69 #define GUARDEDOFFSET 1000000 /* base for "guarded" sign id's */
64 #define MAX_COLOR_LENGTH 32 /* max length of color name in defineAnnoType */ 70 #define MAX_COLOR_LENGTH 32 /* max length of color name in defineAnnoType */
65 71
66 /* The first implementation (working only with Netbeans) returned "1.1". The 72 /* The first implementation (working only with Netbeans) returned "1.1". The
73 static long get_buf_size __ARGS((buf_T *)); 79 static long get_buf_size __ARGS((buf_T *));
74 static int netbeans_keystring __ARGS((char_u *keystr)); 80 static int netbeans_keystring __ARGS((char_u *keystr));
75 static void postpone_keycommand __ARGS((char_u *keystr)); 81 static void postpone_keycommand __ARGS((char_u *keystr));
76 static void special_keys __ARGS((char_u *args)); 82 static void special_keys __ARGS((char_u *args));
77 83
78 static void netbeans_connect __ARGS((void)); 84 static int netbeans_connect __ARGS((char *, int));
79 static int getConnInfo __ARGS((char *file, char **host, char **port, char **password)); 85 static int getConnInfo __ARGS((char *file, char **host, char **port, char **password));
80 86
81 static void nb_init_graphics __ARGS((void)); 87 static void nb_init_graphics __ARGS((void));
82 static void coloncmd __ARGS((char *cmd, ...)); 88 static void coloncmd __ARGS((char *cmd, ...));
83 static void nb_set_curbuf __ARGS((buf_T *buf)); 89 static void nb_set_curbuf __ARGS((buf_T *buf));
88 static void messageFromNetbeans __ARGS((gpointer, gint, GdkInputCondition)); 94 static void messageFromNetbeans __ARGS((gpointer, gint, GdkInputCondition));
89 #endif 95 #endif
90 static void nb_parse_cmd __ARGS((char_u *)); 96 static void nb_parse_cmd __ARGS((char_u *));
91 static int nb_do_cmd __ARGS((int, char_u *, int, int, char_u *)); 97 static int nb_do_cmd __ARGS((int, char_u *, int, int, char_u *));
92 static void nb_send __ARGS((char *buf, char *fun)); 98 static void nb_send __ARGS((char *buf, char *fun));
99 static void nb_free __ARGS((void));
93 100
94 /* TRUE when netbeans is running with a GUI. */ 101 /* TRUE when netbeans is running with a GUI. */
95 #ifdef FEAT_GUI 102 #ifdef FEAT_GUI
96 # define NB_HAS_GUI (gui.in_use || gui.starting) 103 # define NB_HAS_GUI (gui.in_use || gui.starting)
97 #endif 104 #endif
100 typedef __int64 NBSOCK; 107 typedef __int64 NBSOCK;
101 #else 108 #else
102 typedef int NBSOCK; 109 typedef int NBSOCK;
103 #endif 110 #endif
104 111
105 static NBSOCK sd = -1; /* socket fd for Netbeans connection */ 112 static NBSOCK nbsock = -1; /* socket fd for Netbeans connection */
113 #define NETBEANS_OPEN (nbsock != -1)
114
106 #ifdef FEAT_GUI_MOTIF 115 #ifdef FEAT_GUI_MOTIF
107 static XtInputId inputHandler; /* Cookie for input */ 116 static XtInputId inputHandler = (XtInputId)NULL; /* Cookie for input */
108 #endif 117 #endif
109 #ifdef FEAT_GUI_GTK 118 #ifdef FEAT_GUI_GTK
110 static gint inputHandler; /* Cookie for input */ 119 static gint inputHandler = 0; /* Cookie for input */
111 #endif 120 #endif
112 #ifdef FEAT_GUI_W32 121 #ifdef FEAT_GUI_W32
113 static int inputHandler = -1; /* simply ret.value of WSAAsyncSelect() */ 122 static int inputHandler = -1; /* simply ret.value of WSAAsyncSelect() */
114 extern HWND s_hwnd; /* Gvim's Window handle */ 123 extern HWND s_hwnd; /* Gvim's Window handle */
115 #endif 124 #endif
116 static int r_cmdno; /* current command number for reply */ 125 static int r_cmdno; /* current command number for reply */
117 static int haveConnection = FALSE; /* socket is connected and
118 initialization is done */
119 static int dosetvisible = FALSE; 126 static int dosetvisible = FALSE;
120 127
121 /* 128 /*
122 * Include the debugging code if wanted. 129 * Include the debugging code if wanted.
123 */ 130 */
124 #ifdef NBDEBUG 131 #ifdef NBDEBUG
125 # include "nbdebug.c" 132 # include "nbdebug.c"
126 #endif 133 #endif
127 134
128 /* Connect back to Netbeans process */ 135 static int needupdate = 0;
136 static int inAtomic = 0;
137
129 static void 138 static void
130 netbeans_disconnect(void) 139 netbeans_close(void)
131 { 140 {
141 if (!NETBEANS_OPEN)
142 return;
143
144 netbeans_send_disconnect();
145
132 #ifdef FEAT_GUI_MOTIF 146 #ifdef FEAT_GUI_MOTIF
133 if (inputHandler != (XtInputId)NULL) 147 if (inputHandler != (XtInputId)NULL)
134 { 148 {
135 XtRemoveInput(inputHandler); 149 XtRemoveInput(inputHandler);
136 inputHandler = (XtInputId)NULL; 150 inputHandler = (XtInputId)NULL;
144 } 158 }
145 # else 159 # else
146 # ifdef FEAT_GUI_W32 160 # ifdef FEAT_GUI_W32
147 if (inputHandler == 0) 161 if (inputHandler == 0)
148 { 162 {
149 WSAAsyncSelect(sd, s_hwnd, 0, 0); 163 WSAAsyncSelect(nbsock, s_hwnd, 0, 0);
150 inputHandler = -1; 164 inputHandler = -1;
151 } 165 }
152 # endif 166 # endif
153 # endif 167 # endif
154 #endif 168 #endif
155 169
156 sd = -1;
157 haveConnection = FALSE;
158 #ifdef FEAT_BEVAL 170 #ifdef FEAT_BEVAL
159 bevalServers &= ~BEVAL_NETBEANS; 171 bevalServers &= ~BEVAL_NETBEANS;
172 #endif
173
174 sock_close(nbsock);
175 nbsock = -1;
176
177 needupdate = 0;
178 inAtomic = 0;
179 nb_free();
180
181 /* remove all signs and update the screen after gutter removal */
182 coloncmd(":sign unplace *");
183 changed_window_setting();
184 update_screen(CLEAR);
185 setcursor();
186 out_flush();
187 #ifdef FEAT_GUI
188 gui_update_cursor(TRUE, FALSE);
189 gui_mch_flush();
160 #endif 190 #endif
161 } 191 }
162 192
163 #define NB_DEF_HOST "localhost" 193 #define NB_DEF_HOST "localhost"
164 #define NB_DEF_ADDR "3219" 194 #define NB_DEF_ADDR "3219"
165 #define NB_DEF_PASS "changeme" 195 #define NB_DEF_PASS "changeme"
166 196
167 static void 197 static int
168 netbeans_connect(void) 198 netbeans_connect(char *params, int abort)
169 { 199 {
170 #ifdef INET_SOCKETS 200 #ifdef INET_SOCKETS
171 struct sockaddr_in server; 201 struct sockaddr_in server;
172 struct hostent * host; 202 struct hostent * host;
173 # ifdef FEAT_GUI_W32 203 # ifdef FEAT_GUI_W32
176 int port; 206 int port;
177 # endif 207 # endif
178 #else 208 #else
179 struct sockaddr_un server; 209 struct sockaddr_un server;
180 #endif 210 #endif
211 int sd;
181 char buf[32]; 212 char buf[32];
182 char *hostname = NULL; 213 char *hostname = NULL;
183 char *address = NULL; 214 char *address = NULL;
184 char *password = NULL; 215 char *password = NULL;
185 char *fname; 216 char *fname;
186 char *arg = NULL; 217 char *arg = NULL;
187 218
188 if (netbeansArg[3] == '=') 219 if (*params == '=')
189 { 220 {
190 /* "-nb=fname": Read info from specified file. */ 221 /* "=fname": Read info from specified file. */
191 if (getConnInfo(netbeansArg + 4, &hostname, &address, &password) 222 if (getConnInfo(params + 1, &hostname, &address, &password)
192 == FAIL) 223 == FAIL)
193 return; 224 return FAIL;
194 } 225 }
195 else 226 else
196 { 227 {
197 if (netbeansArg[3] == ':') 228 if (*params == ':')
198 /* "-nb:<host>:<addr>:<password>": get info from argument */ 229 /* ":<host>:<addr>:<password>": get info from argument */
199 arg = netbeansArg + 4; 230 arg = params + 1;
200 if (arg == NULL && (fname = getenv("__NETBEANS_CONINFO")) != NULL) 231 if (arg == NULL && (fname = getenv("__NETBEANS_CONINFO")) != NULL)
201 { 232 {
202 /* "-nb": get info from file specified in environment */ 233 /* "": get info from file specified in environment */
203 if (getConnInfo(fname, &hostname, &address, &password) == FAIL) 234 if (getConnInfo(fname, &hostname, &address, &password) == FAIL)
204 return; 235 return FAIL;
205 } 236 }
206 else 237 else
207 { 238 {
208 if (arg != NULL) 239 if (arg != NULL)
209 { 240 {
210 /* "-nb:<host>:<addr>:<password>": get info from argument */ 241 /* ":<host>:<addr>:<password>": get info from argument */
211 hostname = arg; 242 hostname = arg;
212 address = strchr(hostname, ':'); 243 address = strchr(hostname, ':');
213 if (address != NULL) 244 if (address != NULL)
214 { 245 {
215 *address++ = '\0'; 246 *address++ = '\0';
254 password = (char *)vim_strsave((char_u *)NB_DEF_PASS); 285 password = (char *)vim_strsave((char_u *)NB_DEF_PASS);
255 } 286 }
256 if (hostname == NULL || address == NULL || password == NULL) 287 if (hostname == NULL || address == NULL || password == NULL)
257 goto theend; /* out of memory */ 288 goto theend; /* out of memory */
258 289
290 #ifdef FEAT_GUI_W32
291 netbeans_init_winsock();
292 #endif
293
259 #ifdef INET_SOCKETS 294 #ifdef INET_SOCKETS
260 port = atoi(address); 295 port = atoi(address);
261 296
262 if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1) 297 if ((sd = (NBSOCK)socket(AF_INET, SOCK_STREAM, 0)) == (NBSOCK)-1)
263 { 298 {
279 sd = mch_open(hostname, O_RDONLY, 0); 314 sd = mch_open(hostname, O_RDONLY, 0);
280 goto theend; 315 goto theend;
281 } 316 }
282 nbdebug(("error in gethostbyname() in netbeans_connect()\n")); 317 nbdebug(("error in gethostbyname() in netbeans_connect()\n"));
283 PERROR("gethostbyname() in netbeans_connect()"); 318 PERROR("gethostbyname() in netbeans_connect()");
284 sd = -1;
285 goto theend; 319 goto theend;
286 } 320 }
287 memcpy((char *)&server.sin_addr, host->h_addr, host->h_length); 321 memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
288 #else 322 #else
289 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 323 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
325 while (retries-- 359 while (retries--
326 && ((sock_errno == ECONNREFUSED) || (sock_errno == EINTR))) 360 && ((sock_errno == ECONNREFUSED) || (sock_errno == EINTR)))
327 { 361 {
328 nbdebug(("retrying...\n")); 362 nbdebug(("retrying...\n"));
329 sleep(5); 363 sleep(5);
364 if (!abort)
365 {
366 ui_breakcheck();
367 if (got_int)
368 {
369 sock_errno = EINTR;
370 break;
371 }
372 }
330 if (connect(sd, (struct sockaddr *)&server, 373 if (connect(sd, (struct sockaddr *)&server,
331 sizeof(server)) == 0) 374 sizeof(server)) == 0)
332 { 375 {
333 success = TRUE; 376 success = TRUE;
334 break; 377 break;
337 if (!success) 380 if (!success)
338 { 381 {
339 /* Get here when the server can't be found. */ 382 /* Get here when the server can't be found. */
340 nbdebug(("Cannot connect to Netbeans #2\n")); 383 nbdebug(("Cannot connect to Netbeans #2\n"));
341 PERROR(_("Cannot connect to Netbeans #2")); 384 PERROR(_("Cannot connect to Netbeans #2"));
342 getout(1); 385 if (abort)
386 getout(1);
387 goto theend;
343 } 388 }
344 } 389 }
345 390
346 } 391 }
347 else 392 else
348 { 393 {
349 nbdebug(("Cannot connect to Netbeans\n")); 394 nbdebug(("Cannot connect to Netbeans\n"));
350 PERROR(_("Cannot connect to Netbeans")); 395 PERROR(_("Cannot connect to Netbeans"));
351 getout(1); 396 if (abort)
352 } 397 getout(1);
353 } 398 goto theend;
354 399 }
400 }
401
402 nbsock = sd;
355 vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password); 403 vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password);
356 nb_send(buf, "netbeans_connect"); 404 nb_send(buf, "netbeans_connect");
357 405
358 sprintf(buf, "0:version=0 \"%s\"\n", ExtEdProtocolVersion); 406 sprintf(buf, "0:version=0 \"%s\"\n", ExtEdProtocolVersion);
359 nb_send(buf, "externaleditor_version"); 407 nb_send(buf, "externaleditor_version");
360
361 /* nb_init_graphics(); delay until needed */
362
363 haveConnection = TRUE;
364 408
365 theend: 409 theend:
366 vim_free(hostname); 410 vim_free(hostname);
367 vim_free(address); 411 vim_free(address);
368 vim_free(password); 412 vim_free(password);
369 return; 413 return NETBEANS_OPEN ? OK : FAIL;
370 } 414 }
371 415
372 /* 416 /*
373 * Obtain the NetBeans hostname, port address and password from a file. 417 * Obtain the NetBeans hostname, port address and password from a file.
374 * Return the strings in allocated memory. 418 * Return the strings in allocated memory.
577 void 621 void
578 netbeans_parse_messages(void) 622 netbeans_parse_messages(void)
579 { 623 {
580 char_u *p; 624 char_u *p;
581 queue_T *node; 625 queue_T *node;
626
627 if (!NETBEANS_OPEN)
628 return;
582 629
583 while (head.next != NULL && head.next != &head) 630 while (head.next != NULL && head.next != &head)
584 { 631 {
585 node = head.next; 632 node = head.next;
586 633
681 # ifdef HAVE_POLL 728 # ifdef HAVE_POLL
682 struct pollfd fds; 729 struct pollfd fds;
683 # endif 730 # endif
684 #endif 731 #endif
685 732
686 if (sd < 0) 733 if (!NETBEANS_OPEN)
687 { 734 {
688 nbdebug(("messageFromNetbeans() called without a socket\n")); 735 nbdebug(("messageFromNetbeans() called without a socket\n"));
689 return; 736 return;
690 } 737 }
691 738
709 * MAXMSGSIZE long. */ 756 * MAXMSGSIZE long. */
710 for (;;) 757 for (;;)
711 { 758 {
712 #ifdef HAVE_SELECT 759 #ifdef HAVE_SELECT
713 FD_ZERO(&rfds); 760 FD_ZERO(&rfds);
714 FD_SET(sd, &rfds); 761 FD_SET(nbsock, &rfds);
715 tval.tv_sec = 0; 762 tval.tv_sec = 0;
716 tval.tv_usec = 0; 763 tval.tv_usec = 0;
717 if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0) 764 if (select(nbsock + 1, &rfds, NULL, NULL, &tval) <= 0)
718 break; 765 break;
719 #else 766 #else
720 # ifdef HAVE_POLL 767 # ifdef HAVE_POLL
721 fds.fd = sd; 768 fds.fd = nbsock;
722 fds.events = POLLIN; 769 fds.events = POLLIN;
723 if (poll(&fds, 1, 0) <= 0) 770 if (poll(&fds, 1, 0) <= 0)
724 break; 771 break;
725 # endif 772 # endif
726 #endif 773 #endif
727 len = sock_read(sd, buf, MAXMSGSIZE); 774 len = sock_read(nbsock, buf, MAXMSGSIZE);
728 if (len <= 0) 775 if (len <= 0)
729 break; /* error or nothing more to read */ 776 break; /* error or nothing more to read */
730 777
731 /* Store the read message in the queue. */ 778 /* Store the read message in the queue. */
732 save(buf, len); 779 save(buf, len);
736 } 783 }
737 784
738 if (readlen <= 0) 785 if (readlen <= 0)
739 { 786 {
740 /* read error or didn't read anything */ 787 /* read error or didn't read anything */
741 netbeans_disconnect(); 788 netbeans_close();
742 nbdebug(("messageFromNetbeans: Error in read() from socket\n")); 789 nbdebug(("messageFromNetbeans: Error in read() from socket\n"));
743 if (len < 0) 790 if (len < 0)
744 { 791 {
745 nbdebug(("read from Netbeans socket\n")); 792 nbdebug(("read from Netbeans socket\n"));
746 PERROR(_("read from Netbeans socket")); 793 PERROR(_("read from Netbeans socket"));
791 int isfunc = -1; 838 int isfunc = -1;
792 839
793 if (STRCMP(cmd, "DISCONNECT") == 0) 840 if (STRCMP(cmd, "DISCONNECT") == 0)
794 { 841 {
795 /* We assume the server knows that we can safely exit! */ 842 /* We assume the server knows that we can safely exit! */
796 if (sd >= 0)
797 sock_close(sd);
798 /* Disconnect before exiting, Motif hangs in a Select error 843 /* Disconnect before exiting, Motif hangs in a Select error
799 * message otherwise. */ 844 * message otherwise. */
800 netbeans_disconnect(); 845 netbeans_close();
801 getout(0); 846 getout(0);
802 /* NOTREACHED */ 847 /* NOTREACHED */
803 } 848 }
804 849
805 if (STRCMP(cmd, "DETACH") == 0) 850 if (STRCMP(cmd, "DETACH") == 0)
806 { 851 {
807 /* The IDE is breaking the connection. */ 852 /* The IDE is breaking the connection. */
808 if (sd >= 0) 853 netbeans_close();
809 sock_close(sd);
810 netbeans_disconnect();
811 return; 854 return;
812 } 855 }
813 856
814 bufno = strtol((char *)cmd, &verb, 10); 857 bufno = strtol((char *)cmd, &verb, 10);
815 858
876 short_u signmapused; 919 short_u signmapused;
877 }; 920 };
878 921
879 typedef struct nbbuf_struct nbbuf_T; 922 typedef struct nbbuf_struct nbbuf_T;
880 923
881 static nbbuf_T *buf_list = 0; 924 static nbbuf_T *buf_list = NULL;
882 static int buf_list_size = 0; /* size of buf_list */ 925 static int buf_list_size = 0; /* size of buf_list */
883 static int buf_list_used = 0; /* nr of entries in buf_list actually in use */ 926 static int buf_list_used = 0; /* nr of entries in buf_list actually in use */
884 927
885 static char **globalsignmap; 928 static char **globalsignmap = NULL;
886 static int globalsignmaplen; 929 static int globalsignmaplen = 0;
887 static int globalsignmapused; 930 static int globalsignmapused = 0;
888 931
889 static int mapsigntype __ARGS((nbbuf_T *, int localsigntype)); 932 static int mapsigntype __ARGS((nbbuf_T *, int localsigntype));
890 static void addsigntype __ARGS((nbbuf_T *, int localsigntype, char_u *typeName, 933 static void addsigntype __ARGS((nbbuf_T *, int localsigntype, char_u *typeName,
891 char_u *tooltip, char_u *glyphfile, 934 char_u *tooltip, char_u *glyphfile,
892 char_u *fg, char_u *bg)); 935 char_u *fg, char_u *bg));
894 static void print_save_msg __ARGS((nbbuf_T *buf, long nchars)); 937 static void print_save_msg __ARGS((nbbuf_T *buf, long nchars));
895 938
896 static int curPCtype = -1; 939 static int curPCtype = -1;
897 940
898 /* 941 /*
942 * Free netbeans resources.
943 */
944 static void
945 nb_free()
946 {
947 keyQ_T *key_node = keyHead.next;
948 queue_T *cmd_node = head.next;
949 nbbuf_T buf;
950 buf_T *bufp;
951 int i;
952
953 /* free the netbeans buffer list */
954 for (i = 0; i < buf_list_used; i++)
955 {
956 buf = buf_list[i];
957 vim_free(buf.displayname);
958 vim_free(buf.signmap);
959 if ((bufp=buf.bufp) != NULL)
960 {
961 buf.bufp->b_netbeans_file = FALSE;
962 buf.bufp->b_was_netbeans_file = FALSE;
963 }
964 }
965 vim_free(buf_list);
966 buf_list = NULL;
967 buf_list_size = 0;
968 buf_list_used = 0;
969
970 /* free the queued key commands */
971 while(key_node != NULL && key_node != &keyHead)
972 {
973 keyQ_T *next = key_node->next;
974 vim_free(key_node->keystr);
975 vim_free(key_node);
976 if (next == &keyHead)
977 {
978 keyHead.next = &keyHead;
979 keyHead.prev = &keyHead;
980 break;
981 }
982 key_node = next;
983 }
984
985 /* free the queued netbeans commands */
986 while(cmd_node != NULL && cmd_node != &head)
987 {
988 queue_T *next = cmd_node->next;
989 vim_free(cmd_node->buffer);
990 vim_free(cmd_node);
991 if (next == &head)
992 {
993 head.next = &head;
994 head.prev = &head;
995 break;
996 }
997 cmd_node = next;
998 }
999 }
1000
1001 /*
899 * Get the Netbeans buffer number for the specified buffer. 1002 * Get the Netbeans buffer number for the specified buffer.
900 */ 1003 */
901 static int 1004 static int
902 nb_getbufno(buf_T *bufp) 1005 nb_getbufno(buf_T *bufp)
903 { 1006 {
913 * Is this a NetBeans-owned buffer? 1016 * Is this a NetBeans-owned buffer?
914 */ 1017 */
915 int 1018 int
916 isNetbeansBuffer(buf_T *bufp) 1019 isNetbeansBuffer(buf_T *bufp)
917 { 1020 {
918 return usingNetbeans && bufp->b_netbeans_file; 1021 return NETBEANS_OPEN && bufp->b_netbeans_file;
919 } 1022 }
920 1023
921 /* 1024 /*
922 * NetBeans and Vim have different undo models. In Vim, the file isn't 1025 * NetBeans and Vim have different undo models. In Vim, the file isn't
923 * changed if changes are undone via the undo command. In NetBeans, once 1026 * changed if changes are undone via the undo command. In NetBeans, once
928 * unmodified but NetBeans thinks it IS modified. 1031 * unmodified but NetBeans thinks it IS modified.
929 */ 1032 */
930 int 1033 int
931 isNetbeansModified(buf_T *bufp) 1034 isNetbeansModified(buf_T *bufp)
932 { 1035 {
933 if (usingNetbeans && bufp->b_netbeans_file) 1036 if (isNetbeansBuffer(bufp))
934 { 1037 {
935 int bufno = nb_getbufno(bufp); 1038 int bufno = nb_getbufno(bufp);
936 1039
937 if (bufno > 0) 1040 if (bufno > 0)
938 return buf_list[bufno].modified; 1041 return buf_list[bufno].modified;
1008 netbeans_end(void) 1111 netbeans_end(void)
1009 { 1112 {
1010 int i; 1113 int i;
1011 static char buf[128]; 1114 static char buf[128];
1012 1115
1013 if (!haveConnection) 1116 if (!NETBEANS_OPEN)
1014 return; 1117 return;
1015 1118
1016 for (i = 0; i < buf_list_used; i++) 1119 for (i = 0; i < buf_list_used; i++)
1017 { 1120 {
1018 if (!buf_list[i].bufp) 1121 if (!buf_list[i].bufp)
1024 nbdebug(("EVT: %s", buf)); 1127 nbdebug(("EVT: %s", buf));
1025 nb_send(buf, "netbeans_end"); 1128 nb_send(buf, "netbeans_end");
1026 } 1129 }
1027 sprintf(buf, "%d:killed=%d\n", i, r_cmdno); 1130 sprintf(buf, "%d:killed=%d\n", i, r_cmdno);
1028 nbdebug(("EVT: %s", buf)); 1131 nbdebug(("EVT: %s", buf));
1029 /* nb_send(buf, "netbeans_end"); avoid "write failed" messages */ 1132 /* nb_send(buf, "netbeans_end"); avoid "write failed" messages */
1030 if (sd >= 0) 1133 ignored = sock_write(nbsock, buf, (int)STRLEN(buf));
1031 ignored = sock_write(sd, buf, (int)STRLEN(buf));
1032 } 1134 }
1033 } 1135 }
1034 1136
1035 /* 1137 /*
1036 * Send a message to netbeans. 1138 * Send a message to netbeans.
1040 { 1142 {
1041 /* Avoid giving pages full of error messages when the other side has 1143 /* Avoid giving pages full of error messages when the other side has
1042 * exited, only mention the first error until the connection works again. */ 1144 * exited, only mention the first error until the connection works again. */
1043 static int did_error = FALSE; 1145 static int did_error = FALSE;
1044 1146
1045 if (sd < 0) 1147 if (!NETBEANS_OPEN)
1046 { 1148 {
1047 if (!did_error) 1149 if (!did_error)
1048 { 1150 {
1049 nbdebug((" %s(): write while not connected\n", fun)); 1151 nbdebug((" %s(): write while not connected\n", fun));
1050 EMSG2("E630: %s(): write while not connected", fun); 1152 EMSG2("E630: %s(): write while not connected", fun);
1051 } 1153 }
1052 did_error = TRUE; 1154 did_error = TRUE;
1053 } 1155 }
1054 else if (sock_write(sd, buf, (int)STRLEN(buf)) != (int)STRLEN(buf)) 1156 else if (sock_write(nbsock, buf, (int)STRLEN(buf)) != (int)STRLEN(buf))
1055 { 1157 {
1056 if (!did_error) 1158 if (!did_error)
1057 { 1159 {
1058 nbdebug((" %s(): write failed\n", fun)); 1160 nbdebug((" %s(): write failed\n", fun));
1059 EMSG2("E631: %s(): write failed", fun); 1161 EMSG2("E631: %s(): write failed", fun);
1071 static void 1173 static void
1072 nb_reply_nil(int cmdno) 1174 nb_reply_nil(int cmdno)
1073 { 1175 {
1074 char reply[32]; 1176 char reply[32];
1075 1177
1076 if (!haveConnection)
1077 return;
1078
1079 nbdebug(("REP %d: <none>\n", cmdno)); 1178 nbdebug(("REP %d: <none>\n", cmdno));
1080 1179
1081 sprintf(reply, "%d\n", cmdno); 1180 sprintf(reply, "%d\n", cmdno);
1082 nb_send(reply, "nb_reply_nil"); 1181 nb_send(reply, "nb_reply_nil");
1083 } 1182 }
1089 */ 1188 */
1090 static void 1189 static void
1091 nb_reply_text(int cmdno, char_u *result) 1190 nb_reply_text(int cmdno, char_u *result)
1092 { 1191 {
1093 char_u *reply; 1192 char_u *reply;
1094
1095 if (!haveConnection)
1096 return;
1097 1193
1098 nbdebug(("REP %d: %s\n", cmdno, (char *)result)); 1194 nbdebug(("REP %d: %s\n", cmdno, (char *)result));
1099 1195
1100 reply = alloc((unsigned)STRLEN(result) + 32); 1196 reply = alloc((unsigned)STRLEN(result) + 32);
1101 sprintf((char *)reply, "%d %s\n", cmdno, (char *)result); 1197 sprintf((char *)reply, "%d %s\n", cmdno, (char *)result);
1110 */ 1206 */
1111 static void 1207 static void
1112 nb_reply_nr(int cmdno, long result) 1208 nb_reply_nr(int cmdno, long result)
1113 { 1209 {
1114 char reply[32]; 1210 char reply[32];
1115
1116 if (!haveConnection)
1117 return;
1118 1211
1119 nbdebug(("REP %d: %ld\n", cmdno, result)); 1212 nbdebug(("REP %d: %ld\n", cmdno, result));
1120 1213
1121 sprintf(reply, "%d %ld\n", cmdno, result); 1214 sprintf(reply, "%d %ld\n", cmdno, result);
1122 nb_send(reply, "nb_reply_nr"); 1215 nb_send(reply, "nb_reply_nr");
1270 } 1363 }
1271 } 1364 }
1272 1365
1273 #define SKIP_STOP 2 1366 #define SKIP_STOP 2
1274 #define streq(a,b) (strcmp(a,b) == 0) 1367 #define streq(a,b) (strcmp(a,b) == 0)
1275 static int needupdate = 0;
1276 static int inAtomic = 0;
1277 1368
1278 /* 1369 /*
1279 * Do the actual processing of a single netbeans command or function. 1370 * Do the actual processing of a single netbeans command or function.
1280 * The difference between a command and function is that a function 1371 * The difference between a command and function is that a function
1281 * gets a response (it's required) but a command does not. 1372 * gets a response (it's required) but a command does not.
2646 tok = strtok(NULL, " "); 2737 tok = strtok(NULL, " ");
2647 } 2738 }
2648 vim_free(save_str); 2739 vim_free(save_str);
2649 } 2740 }
2650 2741
2742 void
2743 ex_nbclose(eap)
2744 exarg_T *eap UNUSED;
2745 {
2746 netbeans_close();
2747 }
2651 2748
2652 void 2749 void
2653 ex_nbkey(eap) 2750 ex_nbkey(eap)
2654 exarg_T *eap; 2751 exarg_T *eap;
2655 { 2752 {
2656 (void)netbeans_keystring(eap->arg); 2753 (void)netbeans_keystring(eap->arg);
2657 } 2754 }
2658 2755
2756 void
2757 ex_nbstart(eap)
2758 exarg_T *eap;
2759 {
2760 netbeans_open((char *)eap->arg, FALSE);
2761 }
2659 2762
2660 /* 2763 /*
2661 * Initialize highlights and signs for use by netbeans (mostly obsolete) 2764 * Initialize highlights and signs for use by netbeans (mostly obsolete)
2662 */ 2765 */
2663 static void 2766 static void
2764 char buf[MAXPATHL * 2 + 25]; 2867 char buf[MAXPATHL * 2 + 25];
2765 char_u *p; 2868 char_u *p;
2766 2869
2767 /* Don't do anything when 'ballooneval' is off, messages scrolled the 2870 /* Don't do anything when 'ballooneval' is off, messages scrolled the
2768 * windows up or we have no connection. */ 2871 * windows up or we have no connection. */
2769 if (!p_beval || msg_scrolled > 0 || !haveConnection) 2872 if (!p_beval || msg_scrolled > 0 || !NETBEANS_OPEN)
2770 return; 2873 return;
2771 2874
2772 if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK) 2875 if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
2773 { 2876 {
2774 /* Send debugger request. Only when the text is of reasonable 2877 /* Send debugger request. Only when the text is of reasonable
2789 } 2892 }
2790 } 2893 }
2791 #endif 2894 #endif
2792 2895
2793 /* 2896 /*
2897 * Return TRUE when the netbeans connection is closed.
2898 */
2899 int
2900 netbeans_active(void)
2901 {
2902 return NETBEANS_OPEN;
2903 }
2904
2905 /*
2794 * Return netbeans file descriptor. 2906 * Return netbeans file descriptor.
2795 */ 2907 */
2796 int 2908 int
2797 netbeans_filedesc (void) 2909 netbeans_filedesc(void)
2798 { 2910 {
2799 return sd; 2911 return nbsock;
2800 } 2912 }
2801 2913
2802 #if defined(FEAT_GUI) || defined(PROTO) 2914 #if defined(FEAT_GUI) || defined(PROTO)
2803 /* 2915 /*
2804 * Register our file descriptor with the gui event handling system. 2916 * Register our file descriptor with the gui event handling system.
2805 */ 2917 */
2806 void 2918 void
2807 netbeans_gui_register(void) 2919 netbeans_gui_register(void)
2808 { 2920 {
2809 if (!NB_HAS_GUI) 2921 if (!NB_HAS_GUI || !NETBEANS_OPEN)
2810 return; 2922 return;
2811 2923
2812 if (sd > 0)
2813 {
2814 # ifdef FEAT_GUI_MOTIF 2924 # ifdef FEAT_GUI_MOTIF
2815 /* tell notifier we are interested in being called 2925 /* tell notifier we are interested in being called
2816 * when there is input on the editor connection socket 2926 * when there is input on the editor connection socket
2817 */ 2927 */
2818 if (inputHandler == (XtInputId)NULL) 2928 if (inputHandler == (XtInputId)NULL)
2819 inputHandler = XtAppAddInput((XtAppContext)app_context, sd, 2929 inputHandler = XtAppAddInput((XtAppContext)app_context, nbsock,
2820 (XtPointer)(XtInputReadMask + XtInputExceptMask), 2930 (XtPointer)(XtInputReadMask + XtInputExceptMask),
2821 messageFromNetbeans, NULL); 2931 messageFromNetbeans, NULL);
2822 # else 2932 # else
2823 # ifdef FEAT_GUI_GTK 2933 # ifdef FEAT_GUI_GTK
2824 /* 2934 /*
2825 * Tell gdk we are interested in being called when there 2935 * Tell gdk we are interested in being called when there
2826 * is input on the editor connection socket 2936 * is input on the editor connection socket
2827 */ 2937 */
2828 if (inputHandler == 0) 2938 if (inputHandler == 0)
2829 inputHandler = gdk_input_add((gint)sd, (GdkInputCondition) 2939 inputHandler = gdk_input_add((gint)nbsock, (GdkInputCondition)
2830 ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION), 2940 ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION),
2831 messageFromNetbeans, NULL); 2941 messageFromNetbeans, NULL);
2832 # else 2942 # else
2833 # ifdef FEAT_GUI_W32 2943 # ifdef FEAT_GUI_W32
2834 /* 2944 /*
2835 * Tell Windows we are interested in receiving message when there 2945 * Tell Windows we are interested in receiving message when there
2836 * is input on the editor connection socket 2946 * is input on the editor connection socket
2837 */ 2947 */
2838 if (inputHandler == -1) 2948 if (inputHandler == -1)
2839 inputHandler = WSAAsyncSelect(sd, s_hwnd, WM_NETBEANS, FD_READ); 2949 inputHandler = WSAAsyncSelect(nbsock, s_hwnd, WM_NETBEANS, FD_READ);
2840 # endif 2950 # endif
2841 # endif 2951 # endif
2842 # endif 2952 # endif
2843 }
2844 2953
2845 # ifdef FEAT_BEVAL 2954 # ifdef FEAT_BEVAL
2846 bevalServers |= BEVAL_NETBEANS; 2955 bevalServers |= BEVAL_NETBEANS;
2847 # endif 2956 # endif
2848 } 2957 }
2850 2959
2851 /* 2960 /*
2852 * Tell netbeans that the window was opened, ready for commands. 2961 * Tell netbeans that the window was opened, ready for commands.
2853 */ 2962 */
2854 void 2963 void
2855 netbeans_startup_done(void) 2964 netbeans_open(char *params, int abort)
2856 { 2965 {
2857 char *cmd = "0:startupDone=0\n"; 2966 char *cmd = "0:startupDone=0\n";
2858 2967
2859 if (!usingNetbeans) 2968 if (NETBEANS_OPEN)
2969 {
2970 EMSG(_("E511: netbeans already connected"));
2860 return; 2971 return;
2861 2972 }
2862 netbeans_connect(); 2973
2863 if (!haveConnection) 2974 if (netbeans_connect(params, abort) != OK)
2864 return; 2975 return;
2865 #ifdef FEAT_GUI 2976 #ifdef FEAT_GUI
2866 netbeans_gui_register(); 2977 netbeans_gui_register();
2867 #endif 2978 #endif
2868 2979
2869 nbdebug(("EVT: %s", cmd)); 2980 nbdebug(("EVT: %s", cmd));
2870 nb_send(cmd, "netbeans_startup_done"); 2981 nb_send(cmd, "netbeans_startup_done");
2982
2983 /* update the screen after having added the gutter */
2984 changed_window_setting();
2985 update_screen(CLEAR);
2986 setcursor();
2987 out_flush();
2988 #ifdef FEAT_GUI
2989 gui_update_cursor(TRUE, FALSE);
2990 gui_mch_flush();
2991 #endif
2871 } 2992 }
2872 2993
2873 /* 2994 /*
2874 * Tell netbeans that we're exiting. This should be called right 2995 * Tell netbeans that we're exiting. This should be called right
2875 * before calling exit. 2996 * before calling exit.
2877 void 2998 void
2878 netbeans_send_disconnect() 2999 netbeans_send_disconnect()
2879 { 3000 {
2880 char buf[128]; 3001 char buf[128];
2881 3002
2882 if (haveConnection) 3003 if (NETBEANS_OPEN)
2883 { 3004 {
2884 sprintf(buf, "0:disconnect=%d\n", r_cmdno); 3005 sprintf(buf, "0:disconnect=%d\n", r_cmdno);
2885 nbdebug(("EVT: %s", buf)); 3006 nbdebug(("EVT: %s", buf));
2886 nb_send(buf, "netbeans_disconnect"); 3007 nb_send(buf, "netbeans_disconnect");
2887 } 3008 }
2894 void 3015 void
2895 netbeans_frame_moved(int new_x, int new_y) 3016 netbeans_frame_moved(int new_x, int new_y)
2896 { 3017 {
2897 char buf[128]; 3018 char buf[128];
2898 3019
2899 if (!haveConnection) 3020 if (!NETBEANS_OPEN)
2900 return; 3021 return;
2901 3022
2902 sprintf(buf, "0:geometry=%d %d %d %d %d\n", 3023 sprintf(buf, "0:geometry=%d %d %d %d %d\n",
2903 r_cmdno, (int)Columns, (int)Rows, new_x, new_y); 3024 r_cmdno, (int)Columns, (int)Rows, new_x, new_y);
2904 /*nbdebug(("EVT: %s", buf)); happens too many times during a move */ 3025 /*nbdebug(("EVT: %s", buf)); happens too many times during a move */
2915 int bufno = nb_getbufno(bufp); 3036 int bufno = nb_getbufno(bufp);
2916 nbbuf_T *bp = nb_get_buf(bufno); 3037 nbbuf_T *bp = nb_get_buf(bufno);
2917 char buffer[2*MAXPATHL]; 3038 char buffer[2*MAXPATHL];
2918 char_u *q; 3039 char_u *q;
2919 3040
2920 if (!haveConnection || dosetvisible) 3041 if (!NETBEANS_OPEN || !bufp->b_netbeans_file || dosetvisible)
2921 return; 3042 return;
2922 3043
2923 q = nb_quote(bufp->b_ffname); 3044 q = nb_quote(bufp->b_ffname);
2924 if (q == NULL || bp == NULL) 3045 if (q == NULL || bp == NULL)
2925 return; 3046 return;
2947 char buffer[2*MAXPATHL]; 3068 char buffer[2*MAXPATHL];
2948 char_u *q; 3069 char_u *q;
2949 nbbuf_T *bp = nb_get_buf(nb_getbufno(bufp)); 3070 nbbuf_T *bp = nb_get_buf(nb_getbufno(bufp));
2950 int bnum; 3071 int bnum;
2951 3072
2952 if (!haveConnection) 3073 if (!NETBEANS_OPEN)
2953 return; 3074 return;
2954 3075
2955 q = nb_quote(bufp->b_ffname); 3076 q = nb_quote(bufp->b_ffname);
2956 if (q == NULL) 3077 if (q == NULL)
2957 return; 3078 return;
2983 { 3104 {
2984 int bufno = nb_getbufno(bufp); 3105 int bufno = nb_getbufno(bufp);
2985 nbbuf_T *nbbuf = nb_get_buf(bufno); 3106 nbbuf_T *nbbuf = nb_get_buf(bufno);
2986 char buffer[2*MAXPATHL]; 3107 char buffer[2*MAXPATHL];
2987 3108
2988 if (!haveConnection || bufno == -1) 3109 if (!NETBEANS_OPEN || bufno == -1)
2989 return; 3110 return;
2990 3111
2991 nbdebug(("netbeans_file_killed:\n")); 3112 nbdebug(("netbeans_file_killed:\n"));
2992 nbdebug((" Killing bufno: %d", bufno)); 3113 nbdebug((" Killing bufno: %d", bufno));
2993 3114
3010 nb_bufp2nbbuf_fire(buf_T *bufp, int *bufnop) 3131 nb_bufp2nbbuf_fire(buf_T *bufp, int *bufnop)
3011 { 3132 {
3012 int bufno; 3133 int bufno;
3013 nbbuf_T *nbbuf; 3134 nbbuf_T *nbbuf;
3014 3135
3015 if (!haveConnection || !netbeansFireChanges) 3136 if (!NETBEANS_OPEN || !netbeansFireChanges)
3016 return NULL; /* changes are not reported at all */ 3137 return NULL; /* changes are not reported at all */
3017 3138
3018 bufno = nb_getbufno(bufp); 3139 bufno = nb_getbufno(bufp);
3019 if (bufno <= 0) 3140 if (bufno <= 0)
3020 return NULL; /* file is not known to NetBeans */ 3141 return NULL; /* file is not known to NetBeans */
3044 pos_T pos; 3165 pos_T pos;
3045 long off; 3166 long off;
3046 char_u *p; 3167 char_u *p;
3047 char_u *newtxt; 3168 char_u *newtxt;
3048 3169
3170 if (!NETBEANS_OPEN)
3171 return;
3172
3049 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno); 3173 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
3050 if (nbbuf == NULL) 3174 if (nbbuf == NULL)
3051 return; 3175 return;
3052 3176
3053 /* Don't mark as modified for initial read */ 3177 /* Don't mark as modified for initial read */
3089 int bufno; 3213 int bufno;
3090 nbbuf_T *nbbuf; 3214 nbbuf_T *nbbuf;
3091 pos_T pos; 3215 pos_T pos;
3092 long off; 3216 long off;
3093 3217
3218 if (!NETBEANS_OPEN)
3219 return;
3220
3094 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno); 3221 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
3095 if (nbbuf == NULL) 3222 if (nbbuf == NULL)
3096 return; 3223 return;
3097 3224
3098 if (len < 0) 3225 if (len < 0)
3117 * Send netbeans an unmodified command. 3244 * Send netbeans an unmodified command.
3118 */ 3245 */
3119 void 3246 void
3120 netbeans_unmodified(buf_T *bufp UNUSED) 3247 netbeans_unmodified(buf_T *bufp UNUSED)
3121 { 3248 {
3249 if (!NETBEANS_OPEN)
3250 return;
3251
3122 #if 0 3252 #if 0
3123 char_u buf[128]; 3253 char_u buf[128];
3124 int bufno; 3254 int bufno;
3125 nbbuf_T *nbbuf; 3255 nbbuf_T *nbbuf;
3126 3256
3146 netbeans_button_release(int button) 3276 netbeans_button_release(int button)
3147 { 3277 {
3148 char buf[128]; 3278 char buf[128];
3149 int bufno; 3279 int bufno;
3150 3280
3281 if (!NETBEANS_OPEN)
3282 return;
3283
3151 bufno = nb_getbufno(curbuf); 3284 bufno = nb_getbufno(curbuf);
3152 3285
3153 if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf) 3286 if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf)
3154 { 3287 {
3155 int col = mouse_col - W_WINCOL(curwin) 3288 int col = mouse_col - W_WINCOL(curwin)
3197 char buf[2*MAXPATHL]; 3330 char buf[2*MAXPATHL];
3198 int bufno = nb_getbufno(curbuf); 3331 int bufno = nb_getbufno(curbuf);
3199 long off; 3332 long off;
3200 char_u *q; 3333 char_u *q;
3201 3334
3202 if (!haveConnection) 3335 if (!NETBEANS_OPEN)
3203 return TRUE; 3336 return TRUE;
3204
3205 3337
3206 if (bufno == -1) 3338 if (bufno == -1)
3207 { 3339 {
3208 nbdebug(("got keycommand for non-NetBeans buffer, opening...\n")); 3340 nbdebug(("got keycommand for non-NetBeans buffer, opening...\n"));
3209 q = curbuf->b_ffname == NULL ? (char_u *)"" 3341 q = curbuf->b_ffname == NULL ? (char_u *)""
3258 { 3390 {
3259 char_u buf[64]; 3391 char_u buf[64];
3260 int bufno; 3392 int bufno;
3261 nbbuf_T *nbbuf; 3393 nbbuf_T *nbbuf;
3262 3394
3395 if (!NETBEANS_OPEN)
3396 return;
3397
3263 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno); 3398 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
3264 if (nbbuf == NULL) 3399 if (nbbuf == NULL)
3265 return; 3400 return;
3266 3401
3267 nbbuf->modified = 0; 3402 nbbuf->modified = 0;
3280 { 3415 {
3281 char_u buf[64]; 3416 char_u buf[64];
3282 int bufno; 3417 int bufno;
3283 nbbuf_T *nbbuf; 3418 nbbuf_T *nbbuf;
3284 3419
3420 if (!NETBEANS_OPEN)
3421 return;
3422
3285 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno); 3423 nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
3286 if (nbbuf == NULL) 3424 if (nbbuf == NULL)
3287 return; 3425 return;
3288 3426
3289 /* Don't mark as modified for initial read */ 3427 /* Don't mark as modified for initial read */
3304 int 3442 int
3305 netbeans_is_guarded(linenr_T top, linenr_T bot) 3443 netbeans_is_guarded(linenr_T top, linenr_T bot)
3306 { 3444 {
3307 signlist_T *p; 3445 signlist_T *p;
3308 int lnum; 3446 int lnum;
3447
3448 if (!NETBEANS_OPEN)
3449 return FALSE;
3309 3450
3310 for (p = curbuf->b_signlist; p != NULL; p = p->next) 3451 for (p = curbuf->b_signlist; p != NULL; p = p->next)
3311 if (p->id >= GUARDEDOFFSET) 3452 if (p->id >= GUARDEDOFFSET)
3312 for (lnum = top + 1; lnum < bot; lnum++) 3453 for (lnum = top + 1; lnum < bot; lnum++)
3313 if (lnum == p->lnum) 3454 if (lnum == p->lnum)
3325 netbeans_draw_multisign_indicator(int row) 3466 netbeans_draw_multisign_indicator(int row)
3326 { 3467 {
3327 int i; 3468 int i;
3328 int y; 3469 int y;
3329 int x; 3470 int x;
3471
3472 if (!NETBEANS_OPEN)
3473 return;
3330 3474
3331 x = 0; 3475 x = 0;
3332 y = row * gui.char_height + 2; 3476 y = row * gui.char_height + 2;
3333 3477
3334 for (i = 0; i < gui.char_height - 3; i++) 3478 for (i = 0; i < gui.char_height - 3; i++)
3355 int i; 3499 int i;
3356 int y; 3500 int y;
3357 int x; 3501 int x;
3358 GdkDrawable *drawable = gui.drawarea->window; 3502 GdkDrawable *drawable = gui.drawarea->window;
3359 3503
3504 if (!NETBEANS_OPEN)
3505 return;
3506
3360 x = 0; 3507 x = 0;
3361 y = row * gui.char_height + 2; 3508 y = row * gui.char_height + 2;
3362 3509
3363 for (i = 0; i < gui.char_height - 3; i++) 3510 for (i = 0; i < gui.char_height - 3; i++)
3364 gdk_draw_point(drawable, gui.text_gc, x+2, y++); 3511 gdk_draw_point(drawable, gui.text_gc, x+2, y++);
3379 */ 3526 */
3380 void 3527 void
3381 netbeans_gutter_click(linenr_T lnum) 3528 netbeans_gutter_click(linenr_T lnum)
3382 { 3529 {
3383 signlist_T *p; 3530 signlist_T *p;
3531
3532 if (!NETBEANS_OPEN)
3533 return;
3384 3534
3385 for (p = curbuf->b_signlist; p != NULL; p = p->next) 3535 for (p = curbuf->b_signlist; p != NULL; p = p->next)
3386 { 3536 {
3387 if (p->lnum == lnum && p->next && p->next->lnum == lnum) 3537 if (p->lnum == lnum && p->next && p->next->lnum == lnum)
3388 { 3538 {