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