Mercurial > vim
comparison src/netbeans.c @ 2209:d0ddf7ba1630 vim73
Included the patch to support netbeans in a terminal.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 22 May 2010 18:28:27 +0200 |
parents | 014a996ac896 |
children | 8c6a66e2b3cc |
comparison
equal
deleted
inserted
replaced
2208:495995b9ce7d | 2209:d0ddf7ba1630 |
---|---|
59 | 59 |
60 #define INET_SOCKETS | 60 #define INET_SOCKETS |
61 | 61 |
62 #define GUARDED 10000 /* typenr for "guarded" annotation */ | 62 #define GUARDED 10000 /* typenr for "guarded" annotation */ |
63 #define GUARDEDOFFSET 1000000 /* base for "guarded" sign id's */ | 63 #define GUARDEDOFFSET 1000000 /* base for "guarded" sign id's */ |
64 #define MAX_COLOR_LENGTH 32 /* max length of color name in defineAnnoType */ | |
64 | 65 |
65 /* The first implementation (working only with Netbeans) returned "1.1". The | 66 /* The first implementation (working only with Netbeans) returned "1.1". The |
66 * protocol implemented here also supports A-A-P. */ | 67 * protocol implemented here also supports A-A-P. */ |
67 static char *ExtEdProtocolVersion = "2.4"; | 68 static char *ExtEdProtocolVersion = "2.5"; |
68 | 69 |
69 static long pos2off __ARGS((buf_T *, pos_T *)); | 70 static long pos2off __ARGS((buf_T *, pos_T *)); |
70 static pos_T *off2pos __ARGS((buf_T *, long)); | 71 static pos_T *off2pos __ARGS((buf_T *, long)); |
71 static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp)); | 72 static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp)); |
72 static long get_buf_size __ARGS((buf_T *)); | 73 static long get_buf_size __ARGS((buf_T *)); |
88 #endif | 89 #endif |
89 static void nb_parse_cmd __ARGS((char_u *)); | 90 static void nb_parse_cmd __ARGS((char_u *)); |
90 static int nb_do_cmd __ARGS((int, char_u *, int, int, char_u *)); | 91 static int nb_do_cmd __ARGS((int, char_u *, int, int, char_u *)); |
91 static void nb_send __ARGS((char *buf, char *fun)); | 92 static void nb_send __ARGS((char *buf, char *fun)); |
92 | 93 |
94 /* TRUE when netbeans is running with a GUI. */ | |
95 #ifdef FEAT_GUI | |
96 # define NB_HAS_GUI (gui.in_use || gui.starting) | |
97 #endif | |
98 | |
93 #ifdef WIN64 | 99 #ifdef WIN64 |
94 typedef __int64 NBSOCK; | 100 typedef __int64 NBSOCK; |
95 #else | 101 #else |
96 typedef int NBSOCK; | 102 typedef int NBSOCK; |
97 #endif | 103 #endif |
108 extern HWND s_hwnd; /* Gvim's Window handle */ | 114 extern HWND s_hwnd; /* Gvim's Window handle */ |
109 #endif | 115 #endif |
110 static int r_cmdno; /* current command number for reply */ | 116 static int r_cmdno; /* current command number for reply */ |
111 static int haveConnection = FALSE; /* socket is connected and | 117 static int haveConnection = FALSE; /* socket is connected and |
112 initialization is done */ | 118 initialization is done */ |
113 #ifdef FEAT_GUI_MOTIF | |
114 static void netbeans_Xt_connect __ARGS((void *context)); | |
115 #endif | |
116 #ifdef FEAT_GUI_GTK | |
117 static void netbeans_gtk_connect __ARGS((void)); | |
118 #endif | |
119 #ifdef FEAT_GUI_W32 | |
120 static void netbeans_w32_connect __ARGS((void)); | |
121 #endif | |
122 | |
123 static int dosetvisible = FALSE; | 119 static int dosetvisible = FALSE; |
124 | 120 |
125 /* | 121 /* |
126 * Include the debugging code if wanted. | 122 * Include the debugging code if wanted. |
127 */ | 123 */ |
128 #ifdef NBDEBUG | 124 #ifdef NBDEBUG |
129 # include "nbdebug.c" | 125 # include "nbdebug.c" |
130 #endif | 126 #endif |
131 | 127 |
132 /* Connect back to Netbeans process */ | 128 /* Connect back to Netbeans process */ |
133 #ifdef FEAT_GUI_MOTIF | |
134 static void | |
135 netbeans_Xt_connect(void *context) | |
136 { | |
137 netbeans_connect(); | |
138 if (sd > 0) | |
139 { | |
140 /* tell notifier we are interested in being called | |
141 * when there is input on the editor connection socket | |
142 */ | |
143 inputHandler = XtAppAddInput((XtAppContext)context, sd, | |
144 (XtPointer)(XtInputReadMask + XtInputExceptMask), | |
145 messageFromNetbeans, NULL); | |
146 } | |
147 } | |
148 | |
149 static void | 129 static void |
150 netbeans_disconnect(void) | 130 netbeans_disconnect(void) |
151 { | 131 { |
132 #ifdef FEAT_GUI_MOTIF | |
152 if (inputHandler != (XtInputId)NULL) | 133 if (inputHandler != (XtInputId)NULL) |
153 { | 134 { |
154 XtRemoveInput(inputHandler); | 135 XtRemoveInput(inputHandler); |
155 inputHandler = (XtInputId)NULL; | 136 inputHandler = (XtInputId)NULL; |
156 } | 137 } |
138 #else | |
139 # ifdef FEAT_GUI_GTK | |
140 if (inputHandler != 0) | |
141 { | |
142 gdk_input_remove(inputHandler); | |
143 inputHandler = 0; | |
144 } | |
145 # else | |
146 # ifdef FEAT_GUI_W32 | |
147 if (inputHandler == 0) | |
148 { | |
149 WSAAsyncSelect(sd, s_hwnd, 0, 0); | |
150 inputHandler = -1; | |
151 } | |
152 # endif | |
153 # endif | |
154 #endif | |
155 | |
157 sd = -1; | 156 sd = -1; |
158 haveConnection = FALSE; | 157 haveConnection = FALSE; |
159 # ifdef FEAT_BEVAL | 158 #ifdef FEAT_BEVAL |
160 bevalServers &= ~BEVAL_NETBEANS; | 159 bevalServers &= ~BEVAL_NETBEANS; |
161 # endif | 160 #endif |
162 } | 161 } |
163 #endif /* FEAT_MOTIF_GUI */ | |
164 | |
165 #ifdef FEAT_GUI_GTK | |
166 static void | |
167 netbeans_gtk_connect(void) | |
168 { | |
169 netbeans_connect(); | |
170 if (sd > 0) | |
171 { | |
172 /* | |
173 * Tell gdk we are interested in being called when there | |
174 * is input on the editor connection socket | |
175 */ | |
176 inputHandler = gdk_input_add((gint)sd, (GdkInputCondition) | |
177 ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION), | |
178 messageFromNetbeans, NULL); | |
179 } | |
180 } | |
181 | |
182 static void | |
183 netbeans_disconnect(void) | |
184 { | |
185 if (inputHandler != 0) | |
186 { | |
187 gdk_input_remove(inputHandler); | |
188 inputHandler = 0; | |
189 } | |
190 sd = -1; | |
191 haveConnection = FALSE; | |
192 # ifdef FEAT_BEVAL | |
193 bevalServers &= ~BEVAL_NETBEANS; | |
194 # endif | |
195 } | |
196 #endif /* FEAT_GUI_GTK */ | |
197 | |
198 #if defined(FEAT_GUI_W32) || defined(PROTO) | |
199 static void | |
200 netbeans_w32_connect(void) | |
201 { | |
202 netbeans_connect(); | |
203 if (sd > 0) | |
204 { | |
205 /* | |
206 * Tell Windows we are interested in receiving message when there | |
207 * is input on the editor connection socket | |
208 */ | |
209 inputHandler = WSAAsyncSelect(sd, s_hwnd, WM_NETBEANS, FD_READ); | |
210 } | |
211 } | |
212 | |
213 static void | |
214 netbeans_disconnect(void) | |
215 { | |
216 if (inputHandler == 0) | |
217 { | |
218 WSAAsyncSelect(sd, s_hwnd, 0, 0); | |
219 inputHandler = -1; | |
220 } | |
221 sd = -1; | |
222 haveConnection = FALSE; | |
223 # ifdef FEAT_BEVAL | |
224 bevalServers &= ~BEVAL_NETBEANS; | |
225 # endif | |
226 } | |
227 #endif /* FEAT_GUI_W32 */ | |
228 | 162 |
229 #define NB_DEF_HOST "localhost" | 163 #define NB_DEF_HOST "localhost" |
230 #define NB_DEF_ADDR "3219" | 164 #define NB_DEF_ADDR "3219" |
231 #define NB_DEF_PASS "changeme" | 165 #define NB_DEF_PASS "changeme" |
232 | 166 |
238 struct hostent * host; | 172 struct hostent * host; |
239 # ifdef FEAT_GUI_W32 | 173 # ifdef FEAT_GUI_W32 |
240 u_short port; | 174 u_short port; |
241 # else | 175 # else |
242 int port; | 176 int port; |
243 #endif | 177 # endif |
244 #else | 178 #else |
245 struct sockaddr_un server; | 179 struct sockaddr_un server; |
246 #endif | 180 #endif |
247 char buf[32]; | 181 char buf[32]; |
248 char *hostname = NULL; | 182 char *hostname = NULL; |
707 | 641 |
708 /* Buffer size for reading incoming messages. */ | 642 /* Buffer size for reading incoming messages. */ |
709 #define MAXMSGSIZE 4096 | 643 #define MAXMSGSIZE 4096 |
710 | 644 |
711 /* | 645 /* |
712 * Read and process a command from netbeans. | 646 * Read a command from netbeans. |
713 */ | 647 */ |
714 #if defined(FEAT_GUI_W32) || defined(PROTO) | 648 #ifdef FEAT_GUI_MOTIF |
715 /* Use this one when generating prototypes, the others are static. */ | |
716 void | |
717 messageFromNetbeansW32() | |
718 #else | |
719 # ifdef FEAT_GUI_MOTIF | |
720 static void | 649 static void |
721 messageFromNetbeans(XtPointer clientData UNUSED, | 650 messageFromNetbeans(XtPointer clientData UNUSED, |
722 int *unused1 UNUSED, | 651 int *unused1 UNUSED, |
723 XtInputId *unused2 UNUSED) | 652 XtInputId *unused2 UNUSED) |
724 # endif | 653 { |
725 # ifdef FEAT_GUI_GTK | 654 netbeans_read(); |
655 } | |
656 #endif | |
657 | |
658 #ifdef FEAT_GUI_GTK | |
726 static void | 659 static void |
727 messageFromNetbeans(gpointer clientData UNUSED, | 660 messageFromNetbeans(gpointer clientData UNUSED, |
728 gint unused1 UNUSED, | 661 gint unused1 UNUSED, |
729 GdkInputCondition unused2 UNUSED) | 662 GdkInputCondition unused2 UNUSED) |
730 # endif | 663 { |
731 #endif | 664 netbeans_read(); |
665 } | |
666 #endif | |
667 | |
668 void | |
669 netbeans_read() | |
732 { | 670 { |
733 static char_u *buf = NULL; | 671 static char_u *buf = NULL; |
734 int len = 0; | 672 int len = 0; |
735 int readlen = 0; | 673 int readlen = 0; |
736 #ifndef FEAT_GUI_GTK | 674 #if defined(NB_HAS_GUI) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_W32) |
737 static int level = 0; | 675 static int level = 0; |
738 #endif | 676 #endif |
739 #ifdef HAVE_SELECT | 677 #ifdef HAVE_SELECT |
740 struct timeval tval; | 678 struct timeval tval; |
741 fd_set rfds; | 679 fd_set rfds; |
749 { | 687 { |
750 nbdebug(("messageFromNetbeans() called without a socket\n")); | 688 nbdebug(("messageFromNetbeans() called without a socket\n")); |
751 return; | 689 return; |
752 } | 690 } |
753 | 691 |
754 #ifndef FEAT_GUI_GTK | 692 #if defined(NB_HAS_GUI) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_W32) |
755 ++level; /* recursion guard; this will be called from the X event loop */ | 693 /* recursion guard; this will be called from the X event loop at unknown |
694 * moments */ | |
695 if (NB_HAS_GUI) | |
696 ++level; | |
756 #endif | 697 #endif |
757 | 698 |
758 /* Allocate a buffer to read into. */ | 699 /* Allocate a buffer to read into. */ |
759 if (buf == NULL) | 700 if (buf == NULL) |
760 { | 701 { |
768 * MAXMSGSIZE long. */ | 709 * MAXMSGSIZE long. */ |
769 for (;;) | 710 for (;;) |
770 { | 711 { |
771 #ifdef HAVE_SELECT | 712 #ifdef HAVE_SELECT |
772 FD_ZERO(&rfds); | 713 FD_ZERO(&rfds); |
773 FD_SET(sd, &rfds); | 714 FD_SET(sd, &rfds); |
774 tval.tv_sec = 0; | 715 tval.tv_sec = 0; |
775 tval.tv_usec = 0; | 716 tval.tv_usec = 0; |
776 if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0) | 717 if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0) |
777 break; | 718 break; |
778 #else | 719 #else |
779 # ifdef HAVE_POLL | 720 # ifdef HAVE_POLL |
780 fds.fd = sd; | 721 fds.fd = sd; |
781 fds.events = POLLIN; | 722 fds.events = POLLIN; |
782 if (poll(&fds, 1, 0) <= 0) | 723 if (poll(&fds, 1, 0) <= 0) |
783 break; | 724 break; |
784 # endif | 725 # endif |
785 #endif | 726 #endif |
786 len = sock_read(sd, buf, MAXMSGSIZE); | 727 len = sock_read(sd, buf, MAXMSGSIZE); |
787 if (len <= 0) | 728 if (len <= 0) |
788 break; /* error or nothing more to read */ | 729 break; /* error or nothing more to read */ |
805 PERROR(_("read from Netbeans socket")); | 746 PERROR(_("read from Netbeans socket")); |
806 } | 747 } |
807 return; /* don't try to parse it */ | 748 return; /* don't try to parse it */ |
808 } | 749 } |
809 | 750 |
810 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) | 751 #if defined(NB_HAS_GUI) && !defined(FEAT_GUI_W32) |
811 /* Let the main loop handle messages. */ | 752 /* Let the main loop handle messages. */ |
753 if (NB_HAS_GUI) | |
754 { | |
812 # ifdef FEAT_GUI_GTK | 755 # ifdef FEAT_GUI_GTK |
813 if (gtk_main_level() > 0) | 756 if (gtk_main_level() > 0) |
814 gtk_main_quit(); | 757 gtk_main_quit(); |
758 # else | |
759 /* Parse the messages now, but avoid recursion. */ | |
760 if (level == 1) | |
761 netbeans_parse_messages(); | |
762 | |
763 --level; | |
815 # endif | 764 # endif |
816 #else | 765 } |
817 /* Parse the messages now, but avoid recursion. */ | |
818 if (level == 1) | |
819 netbeans_parse_messages(); | |
820 | |
821 --level; | |
822 #endif | 766 #endif |
823 } | 767 } |
824 | 768 |
825 /* | 769 /* |
826 * Handle one NUL terminated command. | 770 * Handle one NUL terminated command. |
943 static int globalsignmapused; | 887 static int globalsignmapused; |
944 | 888 |
945 static int mapsigntype __ARGS((nbbuf_T *, int localsigntype)); | 889 static int mapsigntype __ARGS((nbbuf_T *, int localsigntype)); |
946 static void addsigntype __ARGS((nbbuf_T *, int localsigntype, char_u *typeName, | 890 static void addsigntype __ARGS((nbbuf_T *, int localsigntype, char_u *typeName, |
947 char_u *tooltip, char_u *glyphfile, | 891 char_u *tooltip, char_u *glyphfile, |
948 int usefg, int fg, int usebg, int bg)); | 892 char_u *fg, char_u *bg)); |
949 static void print_read_msg __ARGS((nbbuf_T *buf)); | 893 static void print_read_msg __ARGS((nbbuf_T *buf)); |
950 static void print_save_msg __ARGS((nbbuf_T *buf, long nchars)); | 894 static void print_save_msg __ARGS((nbbuf_T *buf, long nchars)); |
951 | 895 |
952 static int curPCtype = -1; | 896 static int curPCtype = -1; |
953 | 897 |
1846 do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin); | 1790 do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin); |
1847 netbeansReadFile = 1; | 1791 netbeansReadFile = 1; |
1848 buf->bufp = curbuf; | 1792 buf->bufp = curbuf; |
1849 maketitle(); | 1793 maketitle(); |
1850 buf->insertDone = FALSE; | 1794 buf->insertDone = FALSE; |
1795 #if defined(FEAT_MENU) && defined(FEAT_GUI) | |
1851 gui_update_menus(0); | 1796 gui_update_menus(0); |
1797 #endif | |
1852 /* =====================================================================*/ | 1798 /* =====================================================================*/ |
1853 } | 1799 } |
1854 else if (streq((char *)cmd, "insertDone")) | 1800 else if (streq((char *)cmd, "insertDone")) |
1855 { | 1801 { |
1856 if (buf == NULL || buf->bufp == NULL) | 1802 if (buf == NULL || buf->bufp == NULL) |
2010 do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE, | 1956 do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE, |
2011 ECMD_HIDE + ECMD_OLDBUF, curwin); | 1957 ECMD_HIDE + ECMD_OLDBUF, curwin); |
2012 netbeansReadFile = 1; | 1958 netbeansReadFile = 1; |
2013 buf->bufp = curbuf; | 1959 buf->bufp = curbuf; |
2014 maketitle(); | 1960 maketitle(); |
1961 #if defined(FEAT_MENU) && defined(FEAT_GUI) | |
2015 gui_update_menus(0); | 1962 gui_update_menus(0); |
1963 #endif | |
2016 /* =====================================================================*/ | 1964 /* =====================================================================*/ |
2017 } | 1965 } |
2018 else if (streq((char *)cmd, "editFile")) | 1966 else if (streq((char *)cmd, "editFile")) |
2019 { | 1967 { |
2020 if (buf == NULL) | 1968 if (buf == NULL) |
2032 buf->initDone = TRUE; | 1980 buf->initDone = TRUE; |
2033 doupdate = 1; | 1981 doupdate = 1; |
2034 #if defined(FEAT_TITLE) | 1982 #if defined(FEAT_TITLE) |
2035 maketitle(); | 1983 maketitle(); |
2036 #endif | 1984 #endif |
1985 #if defined(FEAT_MENU) && defined(FEAT_GUI) | |
2037 gui_update_menus(0); | 1986 gui_update_menus(0); |
1987 #endif | |
2038 /* =====================================================================*/ | 1988 /* =====================================================================*/ |
2039 } | 1989 } |
2040 else if (streq((char *)cmd, "setVisible")) | 1990 else if (streq((char *)cmd, "setVisible")) |
2041 { | 1991 { |
2042 if (buf == NULL || buf->bufp == NULL) | 1992 if (buf == NULL || buf->bufp == NULL) |
2056 dosetvisible = TRUE; | 2006 dosetvisible = TRUE; |
2057 goto_buffer(&exarg, DOBUF_FIRST, FORWARD, buf->bufp->b_fnum); | 2007 goto_buffer(&exarg, DOBUF_FIRST, FORWARD, buf->bufp->b_fnum); |
2058 doupdate = 1; | 2008 doupdate = 1; |
2059 dosetvisible = FALSE; | 2009 dosetvisible = FALSE; |
2060 | 2010 |
2011 #ifdef FEAT_GUI | |
2061 /* Side effect!!!. */ | 2012 /* Side effect!!!. */ |
2062 if (!gui.starting) | 2013 if (!gui.starting) |
2063 gui_mch_set_foreground(); | 2014 gui_mch_set_foreground(); |
2015 #endif | |
2064 } | 2016 } |
2065 /* =====================================================================*/ | 2017 /* =====================================================================*/ |
2066 } | 2018 } |
2067 else if (streq((char *)cmd, "raise")) | 2019 else if (streq((char *)cmd, "raise")) |
2068 { | 2020 { |
2021 #ifdef FEAT_GUI | |
2069 /* Bring gvim to the foreground. */ | 2022 /* Bring gvim to the foreground. */ |
2070 if (!gui.starting) | 2023 if (!gui.starting) |
2071 gui_mch_set_foreground(); | 2024 gui_mch_set_foreground(); |
2025 #endif | |
2072 /* =====================================================================*/ | 2026 /* =====================================================================*/ |
2073 } | 2027 } |
2074 else if (streq((char *)cmd, "setModified")) | 2028 else if (streq((char *)cmd, "setModified")) |
2075 { | 2029 { |
2076 int prev_b_changed; | 2030 int prev_b_changed; |
2197 /* update_curbuf(NOT_VALID); */ | 2151 /* update_curbuf(NOT_VALID); */ |
2198 update_topline(); /* scroll to show the line */ | 2152 update_topline(); /* scroll to show the line */ |
2199 update_screen(VALID); | 2153 update_screen(VALID); |
2200 setcursor(); | 2154 setcursor(); |
2201 out_flush(); | 2155 out_flush(); |
2156 #ifdef FEAT_GUI | |
2202 gui_update_cursor(TRUE, FALSE); | 2157 gui_update_cursor(TRUE, FALSE); |
2203 gui_mch_flush(); | 2158 gui_mch_flush(); |
2159 #endif | |
2204 /* Quit a hit-return or more prompt. */ | 2160 /* Quit a hit-return or more prompt. */ |
2205 if (State == HITRETURN || State == ASKMORE) | 2161 if (State == HITRETURN || State == ASKMORE) |
2206 { | 2162 { |
2207 #ifdef FEAT_GUI_GTK | 2163 #ifdef FEAT_GUI_GTK |
2208 if (gtk_main_level() > 0) | 2164 if (gtk_main_level() > 0) |
2235 * happen when shutting down. */ | 2191 * happen when shutting down. */ |
2236 if (p_verbose > 0) | 2192 if (p_verbose > 0) |
2237 EMSG("E649: invalid buffer identifier in close"); | 2193 EMSG("E649: invalid buffer identifier in close"); |
2238 } | 2194 } |
2239 nbdebug((" CLOSE %d: %s\n", bufno, name)); | 2195 nbdebug((" CLOSE %d: %s\n", bufno, name)); |
2196 #ifdef FEAT_GUI | |
2240 need_mouse_correct = TRUE; | 2197 need_mouse_correct = TRUE; |
2198 #endif | |
2241 if (buf->bufp != NULL) | 2199 if (buf->bufp != NULL) |
2242 do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, | 2200 do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, |
2243 buf->bufp->b_fnum, TRUE); | 2201 buf->bufp->b_fnum, TRUE); |
2244 buf->bufp = NULL; | 2202 buf->bufp = NULL; |
2245 buf->initDone = FALSE; | 2203 buf->initDone = FALSE; |
2262 int typeNum; | 2220 int typeNum; |
2263 char_u *typeName; | 2221 char_u *typeName; |
2264 char_u *tooltip; | 2222 char_u *tooltip; |
2265 char_u *p; | 2223 char_u *p; |
2266 char_u *glyphFile; | 2224 char_u *glyphFile; |
2267 int use_fg = 0; | 2225 int parse_error = FALSE; |
2268 int use_bg = 0; | 2226 char_u *fg; |
2269 int fg = -1; | 2227 char_u *bg; |
2270 int bg = -1; | |
2271 | 2228 |
2272 if (buf == NULL) | 2229 if (buf == NULL) |
2273 { | 2230 { |
2274 nbdebug((" invalid buffer identifier in defineAnnoType\n")); | 2231 nbdebug((" invalid buffer identifier in defineAnnoType\n")); |
2275 EMSG("E650: invalid buffer identifier in defineAnnoType"); | 2232 EMSG("E650: invalid buffer identifier in defineAnnoType"); |
2288 p = (char_u *)nb_unquote(args, &args); | 2245 p = (char_u *)nb_unquote(args, &args); |
2289 glyphFile = vim_strsave_escaped(p, escape_chars); | 2246 glyphFile = vim_strsave_escaped(p, escape_chars); |
2290 vim_free(p); | 2247 vim_free(p); |
2291 | 2248 |
2292 args = skipwhite(args + 1); | 2249 args = skipwhite(args + 1); |
2293 if (STRNCMP(args, "none", 4) == 0) | 2250 p = skiptowhite(args); |
2294 args += 5; | 2251 if (*p != NUL) |
2295 else | 2252 { |
2296 { | 2253 *p = NUL; |
2297 use_fg = 1; | 2254 p = skipwhite(p + 1); |
2298 cp = (char *)args; | 2255 } |
2299 fg = strtol(cp, &cp, 10); | 2256 fg = vim_strsave(args); |
2300 args = (char_u *)cp; | 2257 bg = vim_strsave(p); |
2301 } | 2258 if (STRLEN(fg) > MAX_COLOR_LENGTH || STRLEN(bg) > MAX_COLOR_LENGTH) |
2302 if (STRNCMP(args, "none", 4) == 0) | 2259 { |
2303 args += 5; | 2260 EMSG("E532: highlighting color name too long in defineAnnoType"); |
2304 else | 2261 vim_free(typeName); |
2305 { | 2262 parse_error = TRUE; |
2306 use_bg = 1; | 2263 } |
2307 cp = (char *)args; | 2264 else if (typeName != NULL && tooltip != NULL && glyphFile != NULL) |
2308 bg = strtol(cp, &cp, 10); | 2265 addsigntype(buf, typeNum, typeName, tooltip, glyphFile, fg, bg); |
2309 args = (char_u *)cp; | |
2310 } | |
2311 if (typeName != NULL && tooltip != NULL && glyphFile != NULL) | |
2312 addsigntype(buf, typeNum, typeName, tooltip, glyphFile, | |
2313 use_fg, fg, use_bg, bg); | |
2314 else | 2266 else |
2315 vim_free(typeName); | 2267 vim_free(typeName); |
2316 | 2268 |
2317 /* don't free typeName; it's used directly in addsigntype() */ | 2269 /* don't free typeName; it's used directly in addsigntype() */ |
2270 vim_free(fg); | |
2271 vim_free(bg); | |
2318 vim_free(tooltip); | 2272 vim_free(tooltip); |
2319 vim_free(glyphFile); | 2273 vim_free(glyphFile); |
2274 if (parse_error) | |
2275 return FAIL; | |
2320 | 2276 |
2321 #endif | 2277 #endif |
2322 /* =====================================================================*/ | 2278 /* =====================================================================*/ |
2323 } | 2279 } |
2324 else if (streq((char *)cmd, "addAnno")) | 2280 else if (streq((char *)cmd, "addAnno")) |
2586 if (buf != NULL && buf->initDone && doupdate) | 2542 if (buf != NULL && buf->initDone && doupdate) |
2587 { | 2543 { |
2588 update_screen(NOT_VALID); | 2544 update_screen(NOT_VALID); |
2589 setcursor(); | 2545 setcursor(); |
2590 out_flush(); | 2546 out_flush(); |
2547 #ifdef FEAT_GUI | |
2591 gui_update_cursor(TRUE, FALSE); | 2548 gui_update_cursor(TRUE, FALSE); |
2592 gui_mch_flush(); | 2549 gui_mch_flush(); |
2550 #endif | |
2593 /* Quit a hit-return or more prompt. */ | 2551 /* Quit a hit-return or more prompt. */ |
2594 if (State == HITRETURN || State == ASKMORE) | 2552 if (State == HITRETURN || State == ASKMORE) |
2595 { | 2553 { |
2596 #ifdef FEAT_GUI_GTK | 2554 #ifdef FEAT_GUI_GTK |
2597 if (gtk_main_level() > 0) | 2555 if (gtk_main_level() > 0) |
2636 /* ALT_INPUT_LOCK_OFF; */ | 2594 /* ALT_INPUT_LOCK_OFF; */ |
2637 | 2595 |
2638 setcursor(); /* restore the cursor position */ | 2596 setcursor(); /* restore the cursor position */ |
2639 out_flush(); /* make sure output has been written */ | 2597 out_flush(); /* make sure output has been written */ |
2640 | 2598 |
2599 #ifdef FEAT_GUI | |
2641 gui_update_cursor(TRUE, FALSE); | 2600 gui_update_cursor(TRUE, FALSE); |
2642 gui_mch_flush(); | 2601 gui_mch_flush(); |
2602 #endif | |
2643 } | 2603 } |
2644 | 2604 |
2645 | 2605 |
2646 /* | 2606 /* |
2647 * Parse the specialKeys argument and issue the appropriate map commands. | 2607 * Parse the specialKeys argument and issue the appropriate map commands. |
2705 { | 2665 { |
2706 static int did_init = FALSE; | 2666 static int did_init = FALSE; |
2707 | 2667 |
2708 if (!did_init) | 2668 if (!did_init) |
2709 { | 2669 { |
2710 coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"); | 2670 coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black" |
2671 " ctermbg=LightCyan ctermfg=Black"); | |
2711 coloncmd(":sign define %d linehl=NBGuarded", GUARDED); | 2672 coloncmd(":sign define %d linehl=NBGuarded", GUARDED); |
2712 | 2673 |
2713 did_init = TRUE; | 2674 did_init = TRUE; |
2714 } | 2675 } |
2715 } | 2676 } |
2783 if (ctrl || shift || alt) | 2744 if (ctrl || shift || alt) |
2784 strcat(buf, "-"); | 2745 strcat(buf, "-"); |
2785 strcat(buf, name); | 2746 strcat(buf, name); |
2786 } | 2747 } |
2787 | 2748 |
2788 #ifdef FEAT_BEVAL | 2749 #if defined(FEAT_BEVAL) || defined(PROTO) |
2789 /* | 2750 /* |
2790 * Function to be called for balloon evaluation. Grabs the text under the | 2751 * Function to be called for balloon evaluation. Grabs the text under the |
2791 * cursor and sends it to the debugger for evaluation. The debugger should | 2752 * cursor and sends it to the debugger for evaluation. The debugger should |
2792 * respond with a showBalloon command when there is a useful result. | 2753 * respond with a showBalloon command when there is a useful result. |
2793 */ | 2754 */ |
2828 } | 2789 } |
2829 } | 2790 } |
2830 #endif | 2791 #endif |
2831 | 2792 |
2832 /* | 2793 /* |
2794 * Return netbeans file descriptor. | |
2795 */ | |
2796 int | |
2797 netbeans_filedesc (void) | |
2798 { | |
2799 return sd; | |
2800 } | |
2801 | |
2802 #if defined(FEAT_GUI) || defined(PROTO) | |
2803 /* | |
2804 * Register our file descriptor with the gui event handling system. | |
2805 */ | |
2806 void | |
2807 netbeans_gui_register(void) | |
2808 { | |
2809 if (!NB_HAS_GUI) | |
2810 return; | |
2811 | |
2812 if (sd > 0) | |
2813 { | |
2814 # ifdef FEAT_GUI_MOTIF | |
2815 /* tell notifier we are interested in being called | |
2816 * when there is input on the editor connection socket | |
2817 */ | |
2818 if (inputHandler == (XtInputId)NULL) | |
2819 inputHandler = XtAppAddInput((XtAppContext)app_context, sd, | |
2820 (XtPointer)(XtInputReadMask + XtInputExceptMask), | |
2821 messageFromNetbeans, NULL); | |
2822 # else | |
2823 # ifdef FEAT_GUI_GTK | |
2824 /* | |
2825 * Tell gdk we are interested in being called when there | |
2826 * is input on the editor connection socket | |
2827 */ | |
2828 if (inputHandler == 0) | |
2829 inputHandler = gdk_input_add((gint)sd, (GdkInputCondition) | |
2830 ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION), | |
2831 messageFromNetbeans, NULL); | |
2832 # else | |
2833 # ifdef FEAT_GUI_W32 | |
2834 /* | |
2835 * Tell Windows we are interested in receiving message when there | |
2836 * is input on the editor connection socket | |
2837 */ | |
2838 if (inputHandler == -1) | |
2839 inputHandler = WSAAsyncSelect(sd, s_hwnd, WM_NETBEANS, FD_READ); | |
2840 # endif | |
2841 # endif | |
2842 # endif | |
2843 } | |
2844 | |
2845 # ifdef FEAT_BEVAL | |
2846 bevalServers |= BEVAL_NETBEANS; | |
2847 # endif | |
2848 } | |
2849 #endif | |
2850 | |
2851 /* | |
2833 * Tell netbeans that the window was opened, ready for commands. | 2852 * Tell netbeans that the window was opened, ready for commands. |
2834 */ | 2853 */ |
2835 void | 2854 void |
2836 netbeans_startup_done(void) | 2855 netbeans_startup_done(void) |
2837 { | 2856 { |
2838 char *cmd = "0:startupDone=0\n"; | 2857 char *cmd = "0:startupDone=0\n"; |
2839 | 2858 |
2840 if (usingNetbeans) | 2859 if (!usingNetbeans) |
2841 #ifdef FEAT_GUI_MOTIF | 2860 return; |
2842 netbeans_Xt_connect(app_context); | 2861 |
2843 #else | 2862 netbeans_connect(); |
2844 # ifdef FEAT_GUI_GTK | |
2845 netbeans_gtk_connect(); | |
2846 # else | |
2847 # ifdef FEAT_GUI_W32 | |
2848 netbeans_w32_connect(); | |
2849 # endif | |
2850 # endif | |
2851 #endif | |
2852 | |
2853 if (!haveConnection) | 2863 if (!haveConnection) |
2854 return; | 2864 return; |
2855 | 2865 #ifdef FEAT_GUI |
2856 #ifdef FEAT_BEVAL | 2866 netbeans_gui_register(); |
2857 bevalServers |= BEVAL_NETBEANS; | |
2858 #endif | 2867 #endif |
2859 | 2868 |
2860 nbdebug(("EVT: %s", cmd)); | 2869 nbdebug(("EVT: %s", cmd)); |
2861 nb_send(cmd, "netbeans_startup_done"); | 2870 nb_send(cmd, "netbeans_startup_done"); |
2862 } | 2871 } |
3142 bufno = nb_getbufno(curbuf); | 3151 bufno = nb_getbufno(curbuf); |
3143 | 3152 |
3144 if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf) | 3153 if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf) |
3145 { | 3154 { |
3146 int col = mouse_col - W_WINCOL(curwin) | 3155 int col = mouse_col - W_WINCOL(curwin) |
3147 - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1); | 3156 - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1); |
3148 long off = pos2off(curbuf, &curwin->w_cursor); | 3157 long off = pos2off(curbuf, &curwin->w_cursor); |
3149 | 3158 |
3150 /* sync the cursor position */ | 3159 /* sync the cursor position */ |
3151 sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off); | 3160 sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off); |
3152 nbdebug(("EVT: %s", buf)); | 3161 nbdebug(("EVT: %s", buf)); |
3402 break; | 3411 break; |
3403 } | 3412 } |
3404 } | 3413 } |
3405 } | 3414 } |
3406 | 3415 |
3407 | |
3408 /* | 3416 /* |
3409 * Add a sign of the requested type at the requested location. | 3417 * Add a sign of the requested type at the requested location. |
3410 * | 3418 * |
3411 * Reverse engineering: | 3419 * Reverse engineering: |
3412 * Apparently an annotation is defined the first time it is used in a buffer. | 3420 * Apparently an annotation is defined the first time it is used in a buffer. |
3425 nbbuf_T *buf, | 3433 nbbuf_T *buf, |
3426 int typeNum, | 3434 int typeNum, |
3427 char_u *typeName, | 3435 char_u *typeName, |
3428 char_u *tooltip UNUSED, | 3436 char_u *tooltip UNUSED, |
3429 char_u *glyphFile, | 3437 char_u *glyphFile, |
3430 int use_fg, | 3438 char_u *fg, |
3431 int fg, | 3439 char_u *bg) |
3432 int use_bg, | 3440 { |
3433 int bg) | |
3434 { | |
3435 char fgbuf[32]; | |
3436 char bgbuf[32]; | |
3437 int i, j; | 3441 int i, j; |
3442 int use_fg = (*fg && STRCMP(fg, "none") != 0); | |
3443 int use_bg = (*bg && STRCMP(bg, "none") != 0); | |
3438 | 3444 |
3439 for (i = 0; i < globalsignmapused; i++) | 3445 for (i = 0; i < globalsignmapused; i++) |
3440 if (STRCMP(typeName, globalsignmap[i]) == 0) | 3446 if (STRCMP(typeName, globalsignmap[i]) == 0) |
3441 break; | 3447 break; |
3442 | 3448 |
3443 if (i == globalsignmapused) /* not found; add it to global map */ | 3449 if (i == globalsignmapused) /* not found; add it to global map */ |
3444 { | 3450 { |
3445 nbdebug(("DEFINEANNOTYPE(%d,%s,%s,%s,%d,%d)\n", | 3451 nbdebug(("DEFINEANNOTYPE(%d,%s,%s,%s,%s,%s)\n", |
3446 typeNum, typeName, tooltip, glyphFile, fg, bg)); | 3452 typeNum, typeName, tooltip, glyphFile, fg, bg)); |
3447 if (use_fg || use_bg) | 3453 if (use_fg || use_bg) |
3448 { | 3454 { |
3449 sprintf(fgbuf, "guifg=#%06x", fg & 0xFFFFFF); | 3455 char fgbuf[2 * (8 + MAX_COLOR_LENGTH) + 1]; |
3450 sprintf(bgbuf, "guibg=#%06x", bg & 0xFFFFFF); | 3456 char bgbuf[2 * (8 + MAX_COLOR_LENGTH) + 1]; |
3457 char *ptr; | |
3458 int value; | |
3459 | |
3460 value = strtol((char *)fg, &ptr, 10); | |
3461 if (ptr != (char *)fg) | |
3462 sprintf(fgbuf, "guifg=#%06x", value & 0xFFFFFF); | |
3463 else | |
3464 sprintf(fgbuf, "guifg=%s ctermfg=%s", fg, fg); | |
3465 | |
3466 value = strtol((char *)bg, &ptr, 10); | |
3467 if (ptr != (char *)bg) | |
3468 sprintf(bgbuf, "guibg=#%06x", value & 0xFFFFFF); | |
3469 else | |
3470 sprintf(bgbuf, "guibg=%s ctermbg=%s", bg, bg); | |
3451 | 3471 |
3452 coloncmd(":highlight NB_%s %s %s", typeName, (use_fg) ? fgbuf : "", | 3472 coloncmd(":highlight NB_%s %s %s", typeName, (use_fg) ? fgbuf : "", |
3453 (use_bg) ? bgbuf : ""); | 3473 (use_bg) ? bgbuf : ""); |
3454 if (*glyphFile == NUL) | 3474 if (*glyphFile == NUL) |
3455 /* no glyph, line highlighting only */ | 3475 /* no glyph, line highlighting only */ |
3672 STRCAT(IObuff, shortmess(SHM_RO) ? _("[RO]") : _("[readonly]")); | 3692 STRCAT(IObuff, shortmess(SHM_RO) ? _("[RO]") : _("[readonly]")); |
3673 c = TRUE; | 3693 c = TRUE; |
3674 } | 3694 } |
3675 if (!buf->bufp->b_start_eol) | 3695 if (!buf->bufp->b_start_eol) |
3676 { | 3696 { |
3677 STRCAT(IObuff, shortmess(SHM_LAST) ? _("[noeol]") : _("[Incomplete last line]")); | 3697 STRCAT(IObuff, shortmess(SHM_LAST) ? _("[noeol]") |
3698 : _("[Incomplete last line]")); | |
3678 c = TRUE; | 3699 c = TRUE; |
3679 } | 3700 } |
3680 msg_add_lines(c, (long)lnum, nchars); | 3701 msg_add_lines(c, (long)lnum, nchars); |
3681 | 3702 |
3682 /* Now display it */ | 3703 /* Now display it */ |
3687 msg_scrolled_ign = FALSE; | 3708 msg_scrolled_ign = FALSE; |
3688 } | 3709 } |
3689 | 3710 |
3690 | 3711 |
3691 /* | 3712 /* |
3692 * Print a message after NetBeans writes the file. This message should be identical | 3713 * Print a message after NetBeans writes the file. This message should be |
3693 * to the standard message a non-netbeans user would see when writing a file. | 3714 * identical to the standard message a non-netbeans user would see when |
3715 * writing a file. | |
3694 */ | 3716 */ |
3695 static void | 3717 static void |
3696 print_save_msg(buf, nchars) | 3718 print_save_msg(buf, nchars) |
3697 nbbuf_T *buf; | 3719 nbbuf_T *buf; |
3698 long nchars; | 3720 long nchars; |
3700 char_u c; | 3722 char_u c; |
3701 char_u *p; | 3723 char_u *p; |
3702 | 3724 |
3703 if (nchars >= 0) | 3725 if (nchars >= 0) |
3704 { | 3726 { |
3705 msg_add_fname(buf->bufp, buf->bufp->b_ffname); /* fname in IObuff with quotes */ | 3727 /* put fname in IObuff with quotes */ |
3728 msg_add_fname(buf->bufp, buf->bufp->b_ffname); | |
3706 c = FALSE; | 3729 c = FALSE; |
3707 | 3730 |
3708 msg_add_lines(c, buf->bufp->b_ml.ml_line_count, | 3731 msg_add_lines(c, buf->bufp->b_ml.ml_line_count, |
3709 (long)buf->bufp->b_orig_size); | 3732 (long)buf->bufp->b_orig_size); |
3710 | 3733 |