In case you do not want the NetBeans interface you can disable it by
uncommenting a line with "--disable-netbeans" in the Makefile.
-Currently, only GVim is supported in this integration as NetBeans does not
-have means to supply a terminal emulator for the Vim command. Furthermore,
-there is only GUI support for GTK, GNOME, and Motif.
+Currently the NetBeans interface is supported by Vim running in a terminal and
+by GVim when it is run with one of the following GUIs: GTK, GNOME, and Motif.
If Motif support is required the user must supply XPM libraries. See
|workshop-xpm| for details on obtaining the latest version of XPM.
which you cannot change. Also sets the current buffer, if
necessary.
+ *E532*
+The defineAnnoType highlighting color name is too long
+ The maximum length of the "fg" or "bg" color argument in the
+ defineAnnoType command is 32 characters.
+ New in version 2.5.
+
*E656*
Writes of unmodified buffers forbidden
Writes of unmodified buffers that were opened from the
confusion happening again, netbeans_saved() has been renamed to
netbeans_save_buffer().
-We are now at version 2.4. For the differences between 2.3 and 2.4 search for
-"2.4" below.
+We are now at version 2.5. For the differences between 2.4 and 2.5 search for
+"2.5" below.
The messages are currently sent over a socket. Since the messages are in
plain UTF-8 text this protocol could also be used with any other communication
number Argument with a decimal number.
-optnum Argument with either a decimal number or "none" (without the
- quotes).
+color Argument with either a decimal number, "none" (without the
+ quotes) or the name of a color (without the quotes) defined
+ both in the color list in|highlight-ctermfg| and in the color
+ list in|gui-colors|.
+ New in version 2.5.
offset A number argument that indicates a byte position in a buffer.
The first byte has offset zero. Line breaks are counted for
typeName string name that identifies this annotation
tooltip string not used
glyphFile string name of icon file
- fg optnum foreground color for line highlighting
- bg optnum background color for line highlighting
+ fg color foreground color for line highlighting
+ bg color background color for line highlighting
Vim will define a sign for the annotation.
+ When color is a number, this is the "#rrggbb" Red, Green and
+ Blue values of the color (see |gui-colors|) and the
+ highlighting is only defined for GVim.
+ When color is a name, this color is defined both for Vim
+ running in a color terminal and for GVim.
When both "fg" and "bg" are "none" no line highlighting is
used (new in version 2.1).
When "glyphFile" is empty, no text sign is used (new in
New in version 2.1.
raise Bring the editor to the foreground.
+ Only when Vim is run with a GUI.
New in version 2.1.
removeAnno serNum
Show a balloon (popup window) at the mouse pointer position,
containing "text", a string argument. The balloon should
disappear when the mouse is moved more than a few pixels.
+ Only when Vim is run with a GUI.
New in version 2.1.
specialKeys
Used when 'ballooneval' is set and the mouse pointer rests on
some text for a moment. "text" is a string, the text under
the mouse pointer.
+ Only when Vim is run with a GUI.
New in version 2.1.
buttonRelease button lnum col
NUL bytes are not possible. For editor -> IDE they will appear as NL
characters. For IDE -> editor they cannot be inserted.
+A NetBeans session may be initiated with Vim running in a terminal, and
+continued later in a GUI environment after running the |:gui|command. In this
+case, the highlighting defined for the NetBeans annotations may be cleared
+when the ":gui" command sources .gvimrc and this file loads a colorscheme
+that runs the command ":highlight clear".
+New in version 2.5.
+
==============================================================================
9. Debugging NetBeans protocol *netbeans-debugging*
#define GUARDED 10000 /* typenr for "guarded" annotation */
#define GUARDEDOFFSET 1000000 /* base for "guarded" sign id's */
+#define MAX_COLOR_LENGTH 32 /* max length of color name in defineAnnoType */
/* The first implementation (working only with Netbeans) returned "1.1". The
* protocol implemented here also supports A-A-P. */
-static char *ExtEdProtocolVersion = "2.4";
+static char *ExtEdProtocolVersion = "2.5";
static long pos2off __ARGS((buf_T *, pos_T *));
static pos_T *off2pos __ARGS((buf_T *, long));
static int nb_do_cmd __ARGS((int, char_u *, int, int, char_u *));
static void nb_send __ARGS((char *buf, char *fun));
+/* TRUE when netbeans is running with a GUI. */
+#ifdef FEAT_GUI
+# define NB_HAS_GUI (gui.in_use || gui.starting)
+#endif
+
#ifdef WIN64
typedef __int64 NBSOCK;
#else
static int r_cmdno; /* current command number for reply */
static int haveConnection = FALSE; /* socket is connected and
initialization is done */
-#ifdef FEAT_GUI_MOTIF
-static void netbeans_Xt_connect __ARGS((void *context));
-#endif
-#ifdef FEAT_GUI_GTK
-static void netbeans_gtk_connect __ARGS((void));
-#endif
-#ifdef FEAT_GUI_W32
-static void netbeans_w32_connect __ARGS((void));
-#endif
-
static int dosetvisible = FALSE;
/*
#endif
/* Connect back to Netbeans process */
-#ifdef FEAT_GUI_MOTIF
- static void
-netbeans_Xt_connect(void *context)
-{
- netbeans_connect();
- if (sd > 0)
- {
- /* tell notifier we are interested in being called
- * when there is input on the editor connection socket
- */
- inputHandler = XtAppAddInput((XtAppContext)context, sd,
- (XtPointer)(XtInputReadMask + XtInputExceptMask),
- messageFromNetbeans, NULL);
- }
-}
-
static void
netbeans_disconnect(void)
{
+#ifdef FEAT_GUI_MOTIF
if (inputHandler != (XtInputId)NULL)
{
XtRemoveInput(inputHandler);
inputHandler = (XtInputId)NULL;
}
- sd = -1;
- haveConnection = FALSE;
-# ifdef FEAT_BEVAL
- bevalServers &= ~BEVAL_NETBEANS;
-# endif
-}
-#endif /* FEAT_MOTIF_GUI */
-
-#ifdef FEAT_GUI_GTK
- static void
-netbeans_gtk_connect(void)
-{
- netbeans_connect();
- if (sd > 0)
- {
- /*
- * Tell gdk we are interested in being called when there
- * is input on the editor connection socket
- */
- inputHandler = gdk_input_add((gint)sd, (GdkInputCondition)
- ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION),
- messageFromNetbeans, NULL);
- }
-}
-
- static void
-netbeans_disconnect(void)
-{
+#else
+# ifdef FEAT_GUI_GTK
if (inputHandler != 0)
{
gdk_input_remove(inputHandler);
inputHandler = 0;
}
- sd = -1;
- haveConnection = FALSE;
-# ifdef FEAT_BEVAL
- bevalServers &= ~BEVAL_NETBEANS;
-# endif
-}
-#endif /* FEAT_GUI_GTK */
-
-#if defined(FEAT_GUI_W32) || defined(PROTO)
- static void
-netbeans_w32_connect(void)
-{
- netbeans_connect();
- if (sd > 0)
- {
- /*
- * Tell Windows we are interested in receiving message when there
- * is input on the editor connection socket
- */
- inputHandler = WSAAsyncSelect(sd, s_hwnd, WM_NETBEANS, FD_READ);
- }
-}
-
- static void
-netbeans_disconnect(void)
-{
+# else
+# ifdef FEAT_GUI_W32
if (inputHandler == 0)
{
WSAAsyncSelect(sd, s_hwnd, 0, 0);
inputHandler = -1;
}
+# endif
+# endif
+#endif
+
sd = -1;
haveConnection = FALSE;
-# ifdef FEAT_BEVAL
+#ifdef FEAT_BEVAL
bevalServers &= ~BEVAL_NETBEANS;
-# endif
+#endif
}
-#endif /* FEAT_GUI_W32 */
#define NB_DEF_HOST "localhost"
#define NB_DEF_ADDR "3219"
u_short port;
# else
int port;
-#endif
+# endif
#else
struct sockaddr_un server;
#endif
#define MAXMSGSIZE 4096
/*
- * Read and process a command from netbeans.
+ * Read a command from netbeans.
*/
-#if defined(FEAT_GUI_W32) || defined(PROTO)
-/* Use this one when generating prototypes, the others are static. */
- void
-messageFromNetbeansW32()
-#else
-# ifdef FEAT_GUI_MOTIF
+#ifdef FEAT_GUI_MOTIF
static void
messageFromNetbeans(XtPointer clientData UNUSED,
int *unused1 UNUSED,
XtInputId *unused2 UNUSED)
-# endif
-# ifdef FEAT_GUI_GTK
+{
+ netbeans_read();
+}
+#endif
+
+#ifdef FEAT_GUI_GTK
static void
messageFromNetbeans(gpointer clientData UNUSED,
gint unused1 UNUSED,
GdkInputCondition unused2 UNUSED)
-# endif
+{
+ netbeans_read();
+}
#endif
+
+ void
+netbeans_read()
{
static char_u *buf = NULL;
int len = 0;
int readlen = 0;
-#ifndef FEAT_GUI_GTK
+#if defined(NB_HAS_GUI) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_W32)
static int level = 0;
#endif
#ifdef HAVE_SELECT
return;
}
-#ifndef FEAT_GUI_GTK
- ++level; /* recursion guard; this will be called from the X event loop */
+#if defined(NB_HAS_GUI) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_W32)
+ /* recursion guard; this will be called from the X event loop at unknown
+ * moments */
+ if (NB_HAS_GUI)
+ ++level;
#endif
/* Allocate a buffer to read into. */
{
#ifdef HAVE_SELECT
FD_ZERO(&rfds);
- FD_SET(sd, &rfds);
- tval.tv_sec = 0;
- tval.tv_usec = 0;
- if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0)
- break;
+ FD_SET(sd, &rfds);
+ tval.tv_sec = 0;
+ tval.tv_usec = 0;
+ if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0)
+ break;
#else
# ifdef HAVE_POLL
fds.fd = sd;
fds.events = POLLIN;
- if (poll(&fds, 1, 0) <= 0)
- break;
+ if (poll(&fds, 1, 0) <= 0)
+ break;
# endif
#endif
len = sock_read(sd, buf, MAXMSGSIZE);
return; /* don't try to parse it */
}
-#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32)
+#if defined(NB_HAS_GUI) && !defined(FEAT_GUI_W32)
/* Let the main loop handle messages. */
+ if (NB_HAS_GUI)
+ {
# ifdef FEAT_GUI_GTK
- if (gtk_main_level() > 0)
- gtk_main_quit();
-# endif
-#else
- /* Parse the messages now, but avoid recursion. */
- if (level == 1)
- netbeans_parse_messages();
+ if (gtk_main_level() > 0)
+ gtk_main_quit();
+# else
+ /* Parse the messages now, but avoid recursion. */
+ if (level == 1)
+ netbeans_parse_messages();
- --level;
+ --level;
+# endif
+ }
#endif
}
static int mapsigntype __ARGS((nbbuf_T *, int localsigntype));
static void addsigntype __ARGS((nbbuf_T *, int localsigntype, char_u *typeName,
char_u *tooltip, char_u *glyphfile,
- int usefg, int fg, int usebg, int bg));
+ char_u *fg, char_u *bg));
static void print_read_msg __ARGS((nbbuf_T *buf));
static void print_save_msg __ARGS((nbbuf_T *buf, long nchars));
buf->bufp = curbuf;
maketitle();
buf->insertDone = FALSE;
+#if defined(FEAT_MENU) && defined(FEAT_GUI)
gui_update_menus(0);
+#endif
/* =====================================================================*/
}
else if (streq((char *)cmd, "insertDone"))
netbeansReadFile = 1;
buf->bufp = curbuf;
maketitle();
+#if defined(FEAT_MENU) && defined(FEAT_GUI)
gui_update_menus(0);
+#endif
/* =====================================================================*/
}
else if (streq((char *)cmd, "editFile"))
#if defined(FEAT_TITLE)
maketitle();
#endif
+#if defined(FEAT_MENU) && defined(FEAT_GUI)
gui_update_menus(0);
+#endif
/* =====================================================================*/
}
else if (streq((char *)cmd, "setVisible"))
doupdate = 1;
dosetvisible = FALSE;
+#ifdef FEAT_GUI
/* Side effect!!!. */
if (!gui.starting)
gui_mch_set_foreground();
+#endif
}
/* =====================================================================*/
}
else if (streq((char *)cmd, "raise"))
{
+#ifdef FEAT_GUI
/* Bring gvim to the foreground. */
if (!gui.starting)
gui_mch_set_foreground();
+#endif
/* =====================================================================*/
}
else if (streq((char *)cmd, "setModified"))
update_screen(VALID);
setcursor();
out_flush();
+#ifdef FEAT_GUI
gui_update_cursor(TRUE, FALSE);
gui_mch_flush();
+#endif
/* Quit a hit-return or more prompt. */
if (State == HITRETURN || State == ASKMORE)
{
EMSG("E649: invalid buffer identifier in close");
}
nbdebug((" CLOSE %d: %s\n", bufno, name));
+#ifdef FEAT_GUI
need_mouse_correct = TRUE;
+#endif
if (buf->bufp != NULL)
do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD,
buf->bufp->b_fnum, TRUE);
char_u *tooltip;
char_u *p;
char_u *glyphFile;
- int use_fg = 0;
- int use_bg = 0;
- int fg = -1;
- int bg = -1;
+ int parse_error = FALSE;
+ char_u *fg;
+ char_u *bg;
if (buf == NULL)
{
vim_free(p);
args = skipwhite(args + 1);
- if (STRNCMP(args, "none", 4) == 0)
- args += 5;
- else
+ p = skiptowhite(args);
+ if (*p != NUL)
{
- use_fg = 1;
- cp = (char *)args;
- fg = strtol(cp, &cp, 10);
- args = (char_u *)cp;
+ *p = NUL;
+ p = skipwhite(p + 1);
}
- if (STRNCMP(args, "none", 4) == 0)
- args += 5;
- else
+ fg = vim_strsave(args);
+ bg = vim_strsave(p);
+ if (STRLEN(fg) > MAX_COLOR_LENGTH || STRLEN(bg) > MAX_COLOR_LENGTH)
{
- use_bg = 1;
- cp = (char *)args;
- bg = strtol(cp, &cp, 10);
- args = (char_u *)cp;
+ EMSG("E532: highlighting color name too long in defineAnnoType");
+ vim_free(typeName);
+ parse_error = TRUE;
}
- if (typeName != NULL && tooltip != NULL && glyphFile != NULL)
- addsigntype(buf, typeNum, typeName, tooltip, glyphFile,
- use_fg, fg, use_bg, bg);
+ else if (typeName != NULL && tooltip != NULL && glyphFile != NULL)
+ addsigntype(buf, typeNum, typeName, tooltip, glyphFile, fg, bg);
else
vim_free(typeName);
/* don't free typeName; it's used directly in addsigntype() */
+ vim_free(fg);
+ vim_free(bg);
vim_free(tooltip);
vim_free(glyphFile);
+ if (parse_error)
+ return FAIL;
#endif
/* =====================================================================*/
update_screen(NOT_VALID);
setcursor();
out_flush();
+#ifdef FEAT_GUI
gui_update_cursor(TRUE, FALSE);
gui_mch_flush();
+#endif
/* Quit a hit-return or more prompt. */
if (State == HITRETURN || State == ASKMORE)
{
setcursor(); /* restore the cursor position */
out_flush(); /* make sure output has been written */
+#ifdef FEAT_GUI
gui_update_cursor(TRUE, FALSE);
gui_mch_flush();
+#endif
}
if (!did_init)
{
- coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black");
+ coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"
+ " ctermbg=LightCyan ctermfg=Black");
coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
did_init = TRUE;
strcat(buf, name);
}
-#ifdef FEAT_BEVAL
+#if defined(FEAT_BEVAL) || defined(PROTO)
/*
* Function to be called for balloon evaluation. Grabs the text under the
* cursor and sends it to the debugger for evaluation. The debugger should
#endif
/*
- * Tell netbeans that the window was opened, ready for commands.
+ * Return netbeans file descriptor.
+ */
+ int
+netbeans_filedesc (void)
+{
+ return sd;
+}
+
+#if defined(FEAT_GUI) || defined(PROTO)
+/*
+ * Register our file descriptor with the gui event handling system.
*/
void
-netbeans_startup_done(void)
+netbeans_gui_register(void)
{
- char *cmd = "0:startupDone=0\n";
+ if (!NB_HAS_GUI)
+ return;
- if (usingNetbeans)
-#ifdef FEAT_GUI_MOTIF
- netbeans_Xt_connect(app_context);
-#else
-# ifdef FEAT_GUI_GTK
- netbeans_gtk_connect();
+ if (sd > 0)
+ {
+# ifdef FEAT_GUI_MOTIF
+ /* tell notifier we are interested in being called
+ * when there is input on the editor connection socket
+ */
+ if (inputHandler == (XtInputId)NULL)
+ inputHandler = XtAppAddInput((XtAppContext)app_context, sd,
+ (XtPointer)(XtInputReadMask + XtInputExceptMask),
+ messageFromNetbeans, NULL);
# else
-# ifdef FEAT_GUI_W32
- netbeans_w32_connect();
+# ifdef FEAT_GUI_GTK
+ /*
+ * Tell gdk we are interested in being called when there
+ * is input on the editor connection socket
+ */
+ if (inputHandler == 0)
+ inputHandler = gdk_input_add((gint)sd, (GdkInputCondition)
+ ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION),
+ messageFromNetbeans, NULL);
+# else
+# ifdef FEAT_GUI_W32
+ /*
+ * Tell Windows we are interested in receiving message when there
+ * is input on the editor connection socket
+ */
+ if (inputHandler == -1)
+ inputHandler = WSAAsyncSelect(sd, s_hwnd, WM_NETBEANS, FD_READ);
+# endif
# endif
# endif
+ }
+
+# ifdef FEAT_BEVAL
+ bevalServers |= BEVAL_NETBEANS;
+# endif
+}
#endif
- if (!haveConnection)
+/*
+ * Tell netbeans that the window was opened, ready for commands.
+ */
+ void
+netbeans_startup_done(void)
+{
+ char *cmd = "0:startupDone=0\n";
+
+ if (!usingNetbeans)
return;
-#ifdef FEAT_BEVAL
- bevalServers |= BEVAL_NETBEANS;
+ netbeans_connect();
+ if (!haveConnection)
+ return;
+#ifdef FEAT_GUI
+ netbeans_gui_register();
#endif
nbdebug(("EVT: %s", cmd));
if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf)
{
int col = mouse_col - W_WINCOL(curwin)
- - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
+ - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
long off = pos2off(curbuf, &curwin->w_cursor);
/* sync the cursor position */
}
}
-
/*
* Add a sign of the requested type at the requested location.
*
char_u *typeName,
char_u *tooltip UNUSED,
char_u *glyphFile,
- int use_fg,
- int fg,
- int use_bg,
- int bg)
+ char_u *fg,
+ char_u *bg)
{
- char fgbuf[32];
- char bgbuf[32];
int i, j;
+ int use_fg = (*fg && STRCMP(fg, "none") != 0);
+ int use_bg = (*bg && STRCMP(bg, "none") != 0);
for (i = 0; i < globalsignmapused; i++)
if (STRCMP(typeName, globalsignmap[i]) == 0)
if (i == globalsignmapused) /* not found; add it to global map */
{
- nbdebug(("DEFINEANNOTYPE(%d,%s,%s,%s,%d,%d)\n",
+ nbdebug(("DEFINEANNOTYPE(%d,%s,%s,%s,%s,%s)\n",
typeNum, typeName, tooltip, glyphFile, fg, bg));
if (use_fg || use_bg)
{
- sprintf(fgbuf, "guifg=#%06x", fg & 0xFFFFFF);
- sprintf(bgbuf, "guibg=#%06x", bg & 0xFFFFFF);
+ char fgbuf[2 * (8 + MAX_COLOR_LENGTH) + 1];
+ char bgbuf[2 * (8 + MAX_COLOR_LENGTH) + 1];
+ char *ptr;
+ int value;
+
+ value = strtol((char *)fg, &ptr, 10);
+ if (ptr != (char *)fg)
+ sprintf(fgbuf, "guifg=#%06x", value & 0xFFFFFF);
+ else
+ sprintf(fgbuf, "guifg=%s ctermfg=%s", fg, fg);
+
+ value = strtol((char *)bg, &ptr, 10);
+ if (ptr != (char *)bg)
+ sprintf(bgbuf, "guibg=#%06x", value & 0xFFFFFF);
+ else
+ sprintf(bgbuf, "guibg=%s ctermbg=%s", bg, bg);
coloncmd(":highlight NB_%s %s %s", typeName, (use_fg) ? fgbuf : "",
(use_bg) ? bgbuf : "");
}
if (!buf->bufp->b_start_eol)
{
- STRCAT(IObuff, shortmess(SHM_LAST) ? _("[noeol]") : _("[Incomplete last line]"));
+ STRCAT(IObuff, shortmess(SHM_LAST) ? _("[noeol]")
+ : _("[Incomplete last line]"));
c = TRUE;
}
msg_add_lines(c, (long)lnum, nchars);
/*
- * Print a message after NetBeans writes the file. This message should be identical
- * to the standard message a non-netbeans user would see when writing a file.
+ * Print a message after NetBeans writes the file. This message should be
+ * identical to the standard message a non-netbeans user would see when
+ * writing a file.
*/
static void
print_save_msg(buf, nchars)
if (nchars >= 0)
{
- msg_add_fname(buf->bufp, buf->bufp->b_ffname); /* fname in IObuff with quotes */
+ /* put fname in IObuff with quotes */
+ msg_add_fname(buf->bufp, buf->bufp->b_ffname);
c = FALSE;
msg_add_lines(c, buf->bufp->b_ml.ml_line_count,