2004-06-13 20:20:40 +00:00
|
|
|
/* vi:set ts=8 sts=4 sw=4:
|
|
|
|
*
|
|
|
|
* VIM - Vi IMproved by Bram Moolenaar
|
|
|
|
* Netbeans integration by David Weatherford
|
|
|
|
* Adopted for Win32 by Sergey Khorev
|
|
|
|
*
|
|
|
|
* Do ":help uganda" in Vim to read copying and usage conditions.
|
|
|
|
* Do ":help credits" in Vim to see a list of people who contributed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implements client side of org.netbeans.modules.emacs editor
|
|
|
|
* integration protocol. Be careful! The protocol uses offsets
|
|
|
|
* which are *between* characters, whereas vim uses line number
|
|
|
|
* and column number which are *on* characters.
|
|
|
|
* See ":help netbeans-protocol" for explanation.
|
2011-10-20 21:58:34 +02:00
|
|
|
*
|
|
|
|
* The Netbeans messages are received and queued in the gui event loop, or in
|
|
|
|
* the select loop when Vim runs in a terminal. These messages are processed
|
|
|
|
* by netbeans_parse_messages() which is invoked in the idle loop when Vim is
|
|
|
|
* waiting for user input. The function netbeans_parse_messages() is also
|
|
|
|
* called from the ":sleep" command, to allow the execution of test cases that
|
|
|
|
* may not invoke the idle loop.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "vim.h"
|
|
|
|
|
|
|
|
#if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
|
|
|
|
|
2016-01-26 23:30:18 +01:00
|
|
|
#ifndef WIN32
|
2016-01-24 22:17:03 +01:00
|
|
|
# include <netdb.h>
|
2004-06-13 20:20:40 +00:00
|
|
|
# ifdef HAVE_LIBGEN_H
|
|
|
|
# include <libgen.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "version.h"
|
|
|
|
|
|
|
|
#define GUARDED 10000 /* typenr for "guarded" annotation */
|
|
|
|
#define GUARDEDOFFSET 1000000 /* base for "guarded" sign id's */
|
2010-05-22 18:28:27 +02:00
|
|
|
#define MAX_COLOR_LENGTH 32 /* max length of color name in defineAnnoType */
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* The first implementation (working only with Netbeans) returned "1.1". The
|
|
|
|
* protocol implemented here also supports A-A-P. */
|
2010-05-22 18:28:27 +02:00
|
|
|
static char *ExtEdProtocolVersion = "2.5";
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2016-01-29 22:36:45 +01:00
|
|
|
static long pos2off(buf_T *, pos_T *);
|
|
|
|
static pos_T *off2pos(buf_T *, long);
|
|
|
|
static pos_T *get_off_or_lnum(buf_T *buf, char_u **argp);
|
|
|
|
static long get_buf_size(buf_T *);
|
|
|
|
static int netbeans_keystring(char_u *keystr);
|
|
|
|
static void postpone_keycommand(char_u *keystr);
|
|
|
|
static void special_keys(char_u *args);
|
|
|
|
|
|
|
|
static int netbeans_connect(char *, int);
|
|
|
|
static int getConnInfo(char *file, char **host, char **port, char **password);
|
|
|
|
|
|
|
|
static void nb_init_graphics(void);
|
|
|
|
static void coloncmd(char *cmd, ...);
|
|
|
|
static void nb_set_curbuf(buf_T *buf);
|
|
|
|
static void nb_parse_cmd(char_u *);
|
|
|
|
static int nb_do_cmd(int, char_u *, int, int, char_u *);
|
|
|
|
static void nb_send(char *buf, char *fun);
|
|
|
|
static void nb_free(void);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2016-02-13 23:23:53 +01:00
|
|
|
#define NETBEANS_OPEN (channel_can_write_to(nb_channel))
|
|
|
|
static channel_T *nb_channel = NULL;
|
2010-05-22 21:34:09 +02:00
|
|
|
|
2006-08-29 15:30:07 +00:00
|
|
|
static int r_cmdno; /* current command number for reply */
|
2004-10-24 19:18:58 +00:00
|
|
|
static int dosetvisible = FALSE;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Include the debugging code if wanted.
|
|
|
|
*/
|
|
|
|
#ifdef NBDEBUG
|
|
|
|
# include "nbdebug.c"
|
|
|
|
#endif
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
static int needupdate = 0;
|
|
|
|
static int inAtomic = 0;
|
|
|
|
|
2010-11-16 15:49:02 +01:00
|
|
|
/*
|
2016-01-26 23:30:18 +01:00
|
|
|
* Callback invoked when the channel is closed.
|
2010-11-16 15:49:02 +01:00
|
|
|
*/
|
2004-06-13 20:20:40 +00:00
|
|
|
static void
|
2016-01-26 23:30:18 +01:00
|
|
|
nb_channel_closed(void)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2016-02-13 23:23:53 +01:00
|
|
|
nb_channel = NULL;
|
2010-11-16 15:49:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close the connection and cleanup.
|
2016-01-26 23:30:18 +01:00
|
|
|
* May be called when the socket was closed earlier.
|
2010-11-16 15:49:02 +01:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
netbeans_close(void)
|
|
|
|
{
|
|
|
|
if (NETBEANS_OPEN)
|
|
|
|
{
|
|
|
|
netbeans_send_disconnect();
|
2016-02-13 23:23:53 +01:00
|
|
|
if (nb_channel != NULL)
|
2016-02-27 14:44:26 +01:00
|
|
|
{
|
2016-01-26 23:30:18 +01:00
|
|
|
/* Close the socket and remove the input handlers. */
|
2016-02-24 20:43:06 +01:00
|
|
|
channel_close(nb_channel, TRUE);
|
2016-02-27 14:44:26 +01:00
|
|
|
channel_clear(nb_channel);
|
|
|
|
}
|
2016-02-13 23:23:53 +01:00
|
|
|
nb_channel = NULL;
|
2010-11-16 15:49:02 +01:00
|
|
|
}
|
|
|
|
|
2010-05-22 18:28:27 +02:00
|
|
|
#ifdef FEAT_BEVAL
|
2005-03-07 22:56:57 +00:00
|
|
|
bevalServers &= ~BEVAL_NETBEANS;
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2010-05-22 21:34:09 +02:00
|
|
|
|
|
|
|
needupdate = 0;
|
|
|
|
inAtomic = 0;
|
|
|
|
nb_free();
|
|
|
|
|
|
|
|
/* remove all signs and update the screen after gutter removal */
|
|
|
|
coloncmd(":sign unplace *");
|
|
|
|
changed_window_setting();
|
|
|
|
update_screen(CLEAR);
|
|
|
|
setcursor();
|
2011-04-01 15:33:59 +02:00
|
|
|
cursor_on();
|
2010-05-22 21:34:09 +02:00
|
|
|
out_flush();
|
|
|
|
#ifdef FEAT_GUI
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
{
|
|
|
|
gui_update_cursor(TRUE, FALSE);
|
|
|
|
gui_mch_flush();
|
|
|
|
}
|
2010-05-22 21:34:09 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define NB_DEF_HOST "localhost"
|
|
|
|
#define NB_DEF_ADDR "3219"
|
|
|
|
#define NB_DEF_PASS "changeme"
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
static int
|
2010-06-22 06:28:58 +02:00
|
|
|
netbeans_connect(char *params, int doabort)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2016-01-26 23:30:18 +01:00
|
|
|
int port;
|
2004-06-13 20:20:40 +00:00
|
|
|
char buf[32];
|
|
|
|
char *hostname = NULL;
|
|
|
|
char *address = NULL;
|
|
|
|
char *password = NULL;
|
|
|
|
char *fname;
|
|
|
|
char *arg = NULL;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (*params == '=')
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2010-05-22 21:34:09 +02:00
|
|
|
/* "=fname": Read info from specified file. */
|
2016-01-24 20:36:41 +01:00
|
|
|
if (getConnInfo(params + 1, &hostname, &address, &password) == FAIL)
|
2010-05-22 21:34:09 +02:00
|
|
|
return FAIL;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-22 21:34:09 +02:00
|
|
|
if (*params == ':')
|
|
|
|
/* ":<host>:<addr>:<password>": get info from argument */
|
|
|
|
arg = params + 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
if (arg == NULL && (fname = getenv("__NETBEANS_CONINFO")) != NULL)
|
|
|
|
{
|
2010-05-22 21:34:09 +02:00
|
|
|
/* "": get info from file specified in environment */
|
2004-06-13 20:20:40 +00:00
|
|
|
if (getConnInfo(fname, &hostname, &address, &password) == FAIL)
|
2010-05-22 21:34:09 +02:00
|
|
|
return FAIL;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (arg != NULL)
|
|
|
|
{
|
2010-05-22 21:34:09 +02:00
|
|
|
/* ":<host>:<addr>:<password>": get info from argument */
|
2004-06-13 20:20:40 +00:00
|
|
|
hostname = arg;
|
|
|
|
address = strchr(hostname, ':');
|
|
|
|
if (address != NULL)
|
|
|
|
{
|
|
|
|
*address++ = '\0';
|
|
|
|
password = strchr(address, ':');
|
|
|
|
if (password != NULL)
|
|
|
|
*password++ = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the missing values from the environment. */
|
|
|
|
if (hostname == NULL || *hostname == '\0')
|
|
|
|
hostname = getenv("__NETBEANS_HOST");
|
|
|
|
if (address == NULL)
|
|
|
|
address = getenv("__NETBEANS_SOCKET");
|
|
|
|
if (password == NULL)
|
|
|
|
password = getenv("__NETBEANS_VIM_PASSWORD");
|
|
|
|
|
|
|
|
/* Move values to allocated memory. */
|
|
|
|
if (hostname != NULL)
|
|
|
|
hostname = (char *)vim_strsave((char_u *)hostname);
|
|
|
|
if (address != NULL)
|
|
|
|
address = (char *)vim_strsave((char_u *)address);
|
|
|
|
if (password != NULL)
|
|
|
|
password = (char *)vim_strsave((char_u *)password);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use the default when a value is missing. */
|
|
|
|
if (hostname == NULL || *hostname == '\0')
|
|
|
|
{
|
|
|
|
vim_free(hostname);
|
|
|
|
hostname = (char *)vim_strsave((char_u *)NB_DEF_HOST);
|
|
|
|
}
|
|
|
|
if (address == NULL || *address == '\0')
|
|
|
|
{
|
|
|
|
vim_free(address);
|
|
|
|
address = (char *)vim_strsave((char_u *)NB_DEF_ADDR);
|
|
|
|
}
|
|
|
|
if (password == NULL || *password == '\0')
|
|
|
|
{
|
|
|
|
vim_free(password);
|
|
|
|
password = (char *)vim_strsave((char_u *)NB_DEF_PASS);
|
|
|
|
}
|
2016-01-26 23:30:18 +01:00
|
|
|
if (hostname != NULL && address != NULL && password != NULL)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2016-01-26 23:30:18 +01:00
|
|
|
port = atoi(address);
|
2016-02-18 22:23:34 +01:00
|
|
|
nb_channel = channel_open(hostname, port, 3000, nb_channel_closed);
|
2016-02-13 23:23:53 +01:00
|
|
|
if (nb_channel != NULL)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2016-01-26 23:30:18 +01:00
|
|
|
/* success */
|
|
|
|
# ifdef FEAT_BEVAL
|
|
|
|
bevalServers |= BEVAL_NETBEANS;
|
|
|
|
# endif
|
2010-05-23 12:06:58 +02:00
|
|
|
|
2016-01-26 23:30:18 +01:00
|
|
|
/* success, login */
|
|
|
|
vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password);
|
|
|
|
nb_send(buf, "netbeans_connect");
|
|
|
|
|
|
|
|
sprintf(buf, "0:version=0 \"%s\"\n", ExtEdProtocolVersion);
|
|
|
|
nb_send(buf, "externaleditor_version");
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-13 23:23:53 +01:00
|
|
|
if (nb_channel == NULL && doabort)
|
2016-01-26 23:30:18 +01:00
|
|
|
getout(1);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
vim_free(hostname);
|
|
|
|
vim_free(address);
|
|
|
|
vim_free(password);
|
2010-05-22 21:34:09 +02:00
|
|
|
return NETBEANS_OPEN ? OK : FAIL;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Obtain the NetBeans hostname, port address and password from a file.
|
|
|
|
* Return the strings in allocated memory.
|
|
|
|
* Return FAIL if the file could not be read, OK otherwise (no matter what it
|
|
|
|
* contains).
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
getConnInfo(char *file, char **host, char **port, char **auth)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
char_u buf[BUFSIZ];
|
|
|
|
char_u *lp;
|
2012-01-10 22:31:31 +01:00
|
|
|
char_u *nlp;
|
2004-06-13 20:20:40 +00:00
|
|
|
#ifdef UNIX
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For Unix only accept the file when it's not accessible by others.
|
|
|
|
* The open will then fail if we don't own the file.
|
|
|
|
*/
|
|
|
|
if (mch_stat(file, &st) == 0 && (st.st_mode & 0077) != 0)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug(("Wrong access mode for NetBeans connection info file: \"%s\"\n",
|
|
|
|
file));
|
2004-06-13 20:20:40 +00:00
|
|
|
EMSG2(_("E668: Wrong access mode for NetBeans connection info file: \"%s\""),
|
|
|
|
file);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fp = mch_fopen(file, "r");
|
|
|
|
if (fp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug(("Cannot open NetBeans connection info file\n"));
|
2004-06-13 20:20:40 +00:00
|
|
|
PERROR("E660: Cannot open NetBeans connection info file");
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the file. There should be one of each parameter */
|
|
|
|
while ((lp = (char_u *)fgets((char *)buf, BUFSIZ, fp)) != NULL)
|
|
|
|
{
|
2012-01-10 22:31:31 +01:00
|
|
|
if ((nlp = vim_strchr(lp, '\n')) != NULL)
|
|
|
|
*nlp = 0; /* strip off the trailing newline */
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if (STRNCMP(lp, "host=", 5) == 0)
|
|
|
|
{
|
|
|
|
vim_free(*host);
|
|
|
|
*host = (char *)vim_strsave(&buf[5]);
|
|
|
|
}
|
|
|
|
else if (STRNCMP(lp, "port=", 5) == 0)
|
|
|
|
{
|
|
|
|
vim_free(*port);
|
|
|
|
*port = (char *)vim_strsave(&buf[5]);
|
|
|
|
}
|
|
|
|
else if (STRNCMP(lp, "auth=", 5) == 0)
|
|
|
|
{
|
|
|
|
vim_free(*auth);
|
|
|
|
*auth = (char *)vim_strsave(&buf[5]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct keyqueue
|
|
|
|
{
|
2010-01-19 15:13:14 +01:00
|
|
|
char_u *keystr;
|
2004-06-13 20:20:40 +00:00
|
|
|
struct keyqueue *next;
|
|
|
|
struct keyqueue *prev;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct keyqueue keyQ_T;
|
|
|
|
|
|
|
|
static keyQ_T keyHead; /* dummy node, header for circular queue */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue up key commands sent from netbeans.
|
2010-01-19 15:13:14 +01:00
|
|
|
* We store the string, because it may depend on the global mod_mask and
|
|
|
|
* :nbkey doesn't have a key number.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
static void
|
2010-01-19 15:13:14 +01:00
|
|
|
postpone_keycommand(char_u *keystr)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
keyQ_T *node;
|
|
|
|
|
|
|
|
node = (keyQ_T *)alloc(sizeof(keyQ_T));
|
2010-01-19 15:13:14 +01:00
|
|
|
if (node == NULL)
|
|
|
|
return; /* out of memory, drop the key */
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if (keyHead.next == NULL) /* initialize circular queue */
|
|
|
|
{
|
|
|
|
keyHead.next = &keyHead;
|
|
|
|
keyHead.prev = &keyHead;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* insert node at tail of queue */
|
|
|
|
node->next = &keyHead;
|
|
|
|
node->prev = keyHead.prev;
|
|
|
|
keyHead.prev->next = node;
|
|
|
|
keyHead.prev = node;
|
|
|
|
|
2010-01-19 15:13:14 +01:00
|
|
|
node->keystr = vim_strsave(keystr);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle any queued-up NetBeans keycommands to be send.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
handle_key_queue(void)
|
|
|
|
{
|
2010-01-19 15:13:14 +01:00
|
|
|
int postponed = FALSE;
|
|
|
|
|
|
|
|
while (!postponed && keyHead.next && keyHead.next != &keyHead)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
/* first, unlink the node */
|
|
|
|
keyQ_T *node = keyHead.next;
|
|
|
|
keyHead.next = node->next;
|
|
|
|
node->next->prev = node->prev;
|
|
|
|
|
2010-01-19 15:13:14 +01:00
|
|
|
/* Now, send the keycommand. This may cause it to be postponed again
|
|
|
|
* and change keyHead. */
|
|
|
|
if (node->keystr != NULL)
|
|
|
|
postponed = !netbeans_keystring(node->keystr);
|
|
|
|
vim_free(node->keystr);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* Finally, dispose of the node */
|
|
|
|
vim_free(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* While there's still a command in the work queue, parse and execute it.
|
|
|
|
*/
|
2008-06-24 20:19:36 +00:00
|
|
|
void
|
|
|
|
netbeans_parse_messages(void)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2016-01-26 23:30:18 +01:00
|
|
|
char_u *buffer;
|
2004-06-13 20:20:40 +00:00
|
|
|
char_u *p;
|
2010-12-02 17:09:54 +01:00
|
|
|
int own_node;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2016-02-13 23:23:53 +01:00
|
|
|
while (nb_channel != NULL)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2016-02-20 18:18:59 +01:00
|
|
|
buffer = channel_peek(nb_channel, PART_SOCK);
|
2016-01-26 23:30:18 +01:00
|
|
|
if (buffer == NULL)
|
|
|
|
break; /* nothing to read */
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* Locate the first line in the first buffer. */
|
2016-01-26 23:30:18 +01:00
|
|
|
p = vim_strchr(buffer, '\n');
|
2004-06-13 20:20:40 +00:00
|
|
|
if (p == NULL)
|
|
|
|
{
|
|
|
|
/* Command isn't complete. If there is no following buffer,
|
|
|
|
* return (wait for more). If there is another buffer following,
|
|
|
|
* prepend the text to that buffer and delete this one. */
|
2016-06-04 17:17:11 +02:00
|
|
|
if (channel_collapse(nb_channel, PART_SOCK, TRUE) == FAIL)
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* There is a complete command at the start of the buffer.
|
|
|
|
* Terminate it with a NUL. When no more text is following unlink
|
|
|
|
* the buffer. Do this before executing, because new buffers can
|
|
|
|
* be added while busy handling the command. */
|
|
|
|
*p++ = NUL;
|
|
|
|
if (*p == NUL)
|
|
|
|
{
|
2010-12-02 17:09:54 +01:00
|
|
|
own_node = TRUE;
|
2016-02-20 18:18:59 +01:00
|
|
|
channel_get(nb_channel, PART_SOCK);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
2010-12-02 17:09:54 +01:00
|
|
|
else
|
|
|
|
own_node = FALSE;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* now, parse and execute the commands */
|
2016-01-26 23:30:18 +01:00
|
|
|
nb_parse_cmd(buffer);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2010-12-02 17:09:54 +01:00
|
|
|
if (own_node)
|
2016-01-26 23:30:18 +01:00
|
|
|
/* buffer finished, dispose of it */
|
|
|
|
vim_free(buffer);
|
|
|
|
else
|
|
|
|
/* more follows, move it to the start */
|
|
|
|
STRMOVE(buffer, p);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle one NUL terminated command.
|
|
|
|
*
|
|
|
|
* format of a command from netbeans:
|
|
|
|
*
|
|
|
|
* 6:setTitle!84 "a.c"
|
|
|
|
*
|
|
|
|
* bufno
|
|
|
|
* colon
|
|
|
|
* cmd
|
|
|
|
* !
|
|
|
|
* cmdno
|
|
|
|
* args
|
|
|
|
*
|
|
|
|
* for function calls, the ! is replaced by a /
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nb_parse_cmd(char_u *cmd)
|
|
|
|
{
|
2004-10-11 10:00:50 +00:00
|
|
|
char *verb;
|
|
|
|
char *q;
|
2004-06-13 20:20:40 +00:00
|
|
|
int bufno;
|
|
|
|
int isfunc = -1;
|
|
|
|
|
|
|
|
if (STRCMP(cmd, "DISCONNECT") == 0)
|
|
|
|
{
|
|
|
|
/* We assume the server knows that we can safely exit! */
|
|
|
|
/* Disconnect before exiting, Motif hangs in a Select error
|
|
|
|
* message otherwise. */
|
2010-05-22 21:34:09 +02:00
|
|
|
netbeans_close();
|
2004-06-13 20:20:40 +00:00
|
|
|
getout(0);
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
2016-02-22 23:13:33 +01:00
|
|
|
if (STRCMP(cmd, "DETACH") == 0)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2016-01-26 23:30:18 +01:00
|
|
|
buf_T *buf;
|
|
|
|
|
|
|
|
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
|
|
|
buf->b_has_sign_column = FALSE;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
/* The IDE is breaking the connection. */
|
2010-05-22 21:34:09 +02:00
|
|
|
netbeans_close();
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-10-11 10:00:50 +00:00
|
|
|
bufno = strtol((char *)cmd, &verb, 10);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if (*verb != ':')
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" missing colon: %s\n", cmd));
|
2004-06-13 20:20:40 +00:00
|
|
|
EMSG2("E627: missing colon: %s", cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++verb; /* skip colon */
|
|
|
|
|
|
|
|
for (q = verb; *q; q++)
|
|
|
|
{
|
|
|
|
if (*q == '!')
|
|
|
|
{
|
|
|
|
*q++ = NUL;
|
|
|
|
isfunc = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (*q == '/')
|
|
|
|
{
|
|
|
|
*q++ = NUL;
|
|
|
|
isfunc = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isfunc < 0)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" missing ! or / in: %s\n", cmd));
|
2004-06-13 20:20:40 +00:00
|
|
|
EMSG2("E628: missing ! or / in: %s", cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-08-29 15:30:07 +00:00
|
|
|
r_cmdno = strtol(q, &q, 10);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2004-10-11 10:00:50 +00:00
|
|
|
q = (char *)skipwhite((char_u *)q);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2006-08-29 15:30:07 +00:00
|
|
|
if (nb_do_cmd(bufno, (char_u *)verb, isfunc, r_cmdno, (char_u *)q) == FAIL)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2004-10-24 19:18:58 +00:00
|
|
|
#ifdef NBDEBUG
|
|
|
|
/*
|
2010-01-19 14:59:56 +01:00
|
|
|
* This happens because the ExtEd can send a command or 2 after
|
2004-10-24 19:18:58 +00:00
|
|
|
* doing a stopDocumentListen command. It doesn't harm anything
|
|
|
|
* so I'm disabling it except for debugging.
|
|
|
|
*/
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("nb_parse_cmd: Command error for \"%s\"\n", cmd));
|
|
|
|
EMSG("E629: bad return from nb_do_cmd");
|
2004-10-24 19:18:58 +00:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct nbbuf_struct
|
|
|
|
{
|
|
|
|
buf_T *bufp;
|
|
|
|
unsigned int fireChanges:1;
|
|
|
|
unsigned int initDone:1;
|
2004-10-24 19:18:58 +00:00
|
|
|
unsigned int insertDone:1;
|
2004-06-13 20:20:40 +00:00
|
|
|
unsigned int modified:1;
|
2004-10-24 19:18:58 +00:00
|
|
|
int nbbuf_number;
|
2004-06-13 20:20:40 +00:00
|
|
|
char *displayname;
|
|
|
|
int *signmap;
|
|
|
|
short_u signmaplen;
|
|
|
|
short_u signmapused;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct nbbuf_struct nbbuf_T;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
static nbbuf_T *buf_list = NULL;
|
2005-06-21 22:37:39 +00:00
|
|
|
static int buf_list_size = 0; /* size of buf_list */
|
|
|
|
static int buf_list_used = 0; /* nr of entries in buf_list actually in use */
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
static char **globalsignmap = NULL;
|
|
|
|
static int globalsignmaplen = 0;
|
|
|
|
static int globalsignmapused = 0;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2016-01-29 22:36:45 +01:00
|
|
|
static int mapsigntype(nbbuf_T *, int localsigntype);
|
|
|
|
static void addsigntype(nbbuf_T *, int localsigntype, char_u *typeName,
|
2004-06-13 20:20:40 +00:00
|
|
|
char_u *tooltip, char_u *glyphfile,
|
2016-01-29 22:36:45 +01:00
|
|
|
char_u *fg, char_u *bg);
|
|
|
|
static void print_read_msg(nbbuf_T *buf);
|
|
|
|
static void print_save_msg(nbbuf_T *buf, off_t nchars);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
static int curPCtype = -1;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
/*
|
|
|
|
* Free netbeans resources.
|
|
|
|
*/
|
|
|
|
static void
|
2016-01-30 19:39:49 +01:00
|
|
|
nb_free(void)
|
2010-05-22 21:34:09 +02:00
|
|
|
{
|
|
|
|
keyQ_T *key_node = keyHead.next;
|
|
|
|
nbbuf_T buf;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* free the netbeans buffer list */
|
|
|
|
for (i = 0; i < buf_list_used; i++)
|
|
|
|
{
|
|
|
|
buf = buf_list[i];
|
|
|
|
vim_free(buf.displayname);
|
|
|
|
vim_free(buf.signmap);
|
2010-12-08 13:11:21 +01:00
|
|
|
if (buf.bufp != NULL)
|
2010-05-22 21:34:09 +02:00
|
|
|
{
|
|
|
|
buf.bufp->b_netbeans_file = FALSE;
|
|
|
|
buf.bufp->b_was_netbeans_file = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vim_free(buf_list);
|
|
|
|
buf_list = NULL;
|
|
|
|
buf_list_size = 0;
|
|
|
|
buf_list_used = 0;
|
|
|
|
|
|
|
|
/* free the queued key commands */
|
2012-11-20 17:19:01 +01:00
|
|
|
while (key_node != NULL && key_node != &keyHead)
|
2010-05-22 21:34:09 +02:00
|
|
|
{
|
|
|
|
keyQ_T *next = key_node->next;
|
|
|
|
vim_free(key_node->keystr);
|
|
|
|
vim_free(key_node);
|
|
|
|
if (next == &keyHead)
|
|
|
|
{
|
|
|
|
keyHead.next = &keyHead;
|
|
|
|
keyHead.prev = &keyHead;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
key_node = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the queued netbeans commands */
|
2016-02-13 23:23:53 +01:00
|
|
|
if (nb_channel != NULL)
|
|
|
|
channel_clear(nb_channel);
|
2010-05-22 21:34:09 +02:00
|
|
|
}
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Get the Netbeans buffer number for the specified buffer.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
nb_getbufno(buf_T *bufp)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < buf_list_used; i++)
|
|
|
|
if (buf_list[i].bufp == bufp)
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this a NetBeans-owned buffer?
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
isNetbeansBuffer(buf_T *bufp)
|
|
|
|
{
|
2010-05-22 21:34:09 +02:00
|
|
|
return NETBEANS_OPEN && bufp->b_netbeans_file;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NetBeans and Vim have different undo models. In Vim, the file isn't
|
|
|
|
* changed if changes are undone via the undo command. In NetBeans, once
|
|
|
|
* a change has been made the file is marked as modified until saved. It
|
|
|
|
* doesn't matter if the change was undone.
|
|
|
|
*
|
|
|
|
* So this function is for the corner case where Vim thinks a buffer is
|
|
|
|
* unmodified but NetBeans thinks it IS modified.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
isNetbeansModified(buf_T *bufp)
|
|
|
|
{
|
2010-05-22 21:34:09 +02:00
|
|
|
if (isNetbeansBuffer(bufp))
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
|
|
|
int bufno = nb_getbufno(bufp);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
if (bufno > 0)
|
|
|
|
return buf_list[bufno].modified;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Given a Netbeans buffer number, return the netbeans buffer.
|
|
|
|
* Returns NULL for 0 or a negative number. A 0 bufno means a
|
|
|
|
* non-buffer related command has been sent.
|
|
|
|
*/
|
|
|
|
static nbbuf_T *
|
|
|
|
nb_get_buf(int bufno)
|
|
|
|
{
|
|
|
|
/* find or create a buffer with the given number */
|
|
|
|
int incr;
|
|
|
|
|
|
|
|
if (bufno <= 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!buf_list)
|
|
|
|
{
|
|
|
|
/* initialize */
|
|
|
|
buf_list = (nbbuf_T *)alloc_clear(100 * sizeof(nbbuf_T));
|
|
|
|
buf_list_size = 100;
|
|
|
|
}
|
|
|
|
if (bufno >= buf_list_used) /* new */
|
|
|
|
{
|
|
|
|
if (bufno >= buf_list_size) /* grow list */
|
|
|
|
{
|
2015-02-10 18:34:01 +01:00
|
|
|
nbbuf_T *t_buf_list = buf_list;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
incr = bufno - buf_list_size + 90;
|
|
|
|
buf_list_size += incr;
|
|
|
|
buf_list = (nbbuf_T *)vim_realloc(
|
|
|
|
buf_list, buf_list_size * sizeof(nbbuf_T));
|
2015-02-10 18:34:01 +01:00
|
|
|
if (buf_list == NULL)
|
|
|
|
{
|
|
|
|
vim_free(t_buf_list);
|
|
|
|
buf_list_size = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-05-24 11:59:29 +02:00
|
|
|
vim_memset(buf_list + buf_list_size - incr, 0,
|
|
|
|
incr * sizeof(nbbuf_T));
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (buf_list_used <= bufno)
|
|
|
|
{
|
|
|
|
/* Default is to fire text changes. */
|
|
|
|
buf_list[buf_list_used].fireChanges = 1;
|
|
|
|
++buf_list_used;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf_list + bufno;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the number of buffers that are modified.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
count_changed_buffers(void)
|
|
|
|
{
|
|
|
|
buf_T *bufp;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for (bufp = firstbuf; bufp != NULL; bufp = bufp->b_next)
|
|
|
|
if (bufp->b_changed)
|
|
|
|
++n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* End the netbeans session.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_end(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
static char buf[128];
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < buf_list_used; i++)
|
|
|
|
{
|
|
|
|
if (!buf_list[i].bufp)
|
|
|
|
continue;
|
|
|
|
if (netbeansForcedQuit)
|
|
|
|
{
|
|
|
|
/* mark as unmodified so NetBeans won't put up dialog on "killed" */
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf(buf, "%d:unmodified=%d\n", i, r_cmdno);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_end");
|
|
|
|
}
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf(buf, "%d:killed=%d\n", i, r_cmdno);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
2010-05-22 21:34:09 +02:00
|
|
|
/* nb_send(buf, "netbeans_end"); avoid "write failed" messages */
|
2016-01-26 23:30:18 +01:00
|
|
|
nb_send(buf, NULL);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a message to netbeans.
|
2016-01-26 23:30:18 +01:00
|
|
|
* When "fun" is NULL no error is given.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nb_send(char *buf, char *fun)
|
|
|
|
{
|
2016-02-13 23:23:53 +01:00
|
|
|
if (nb_channel != NULL)
|
2016-02-20 18:18:59 +01:00
|
|
|
channel_send(nb_channel, PART_SOCK, (char_u *)buf, fun);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some input received from netbeans requires a response. This function
|
|
|
|
* handles a response with no information (except the command number).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nb_reply_nil(int cmdno)
|
|
|
|
{
|
|
|
|
char reply[32];
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
nbdebug(("REP %d: <none>\n", cmdno));
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2010-11-16 15:49:02 +01:00
|
|
|
/* Avoid printing an annoying error message. */
|
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
sprintf(reply, "%d\n", cmdno);
|
2004-06-13 20:20:40 +00:00
|
|
|
nb_send(reply, "nb_reply_nil");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a response with text.
|
|
|
|
* "result" must have been quoted already (using nb_quote()).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nb_reply_text(int cmdno, char_u *result)
|
|
|
|
{
|
|
|
|
char_u *reply;
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
nbdebug(("REP %d: %s\n", cmdno, (char *)result));
|
|
|
|
|
2006-04-17 22:14:47 +00:00
|
|
|
reply = alloc((unsigned)STRLEN(result) + 32);
|
2004-06-13 20:20:40 +00:00
|
|
|
sprintf((char *)reply, "%d %s\n", cmdno, (char *)result);
|
|
|
|
nb_send((char *)reply, "nb_reply_text");
|
|
|
|
|
|
|
|
vim_free(reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a response with a number result code.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nb_reply_nr(int cmdno, long result)
|
|
|
|
{
|
|
|
|
char reply[32];
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
nbdebug(("REP %d: %ld\n", cmdno, result));
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
sprintf(reply, "%d %ld\n", cmdno, result);
|
2004-06-13 20:20:40 +00:00
|
|
|
nb_send(reply, "nb_reply_nr");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Encode newline, ret, backslash, double quote for transmission to NetBeans.
|
|
|
|
*/
|
|
|
|
static char_u *
|
|
|
|
nb_quote(char_u *txt)
|
|
|
|
{
|
2006-04-17 22:14:47 +00:00
|
|
|
char_u *buf = alloc((unsigned)(2 * STRLEN(txt) + 1));
|
2004-06-13 20:20:40 +00:00
|
|
|
char_u *p = txt;
|
|
|
|
char_u *q = buf;
|
|
|
|
|
|
|
|
if (buf == NULL)
|
|
|
|
return NULL;
|
|
|
|
for (; *p; p++)
|
|
|
|
{
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '\"':
|
|
|
|
case '\\':
|
|
|
|
*q++ = '\\'; *q++ = *p; break;
|
|
|
|
/* case '\t': */
|
|
|
|
/* *q++ = '\\'; *q++ = 't'; break; */
|
|
|
|
case '\n':
|
|
|
|
*q++ = '\\'; *q++ = 'n'; break;
|
|
|
|
case '\r':
|
|
|
|
*q++ = '\\'; *q++ = 'r'; break;
|
|
|
|
default:
|
|
|
|
*q++ = *p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-01-19 14:59:56 +01:00
|
|
|
*q = '\0';
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove top level double quotes; convert backslashed chars.
|
|
|
|
* Returns an allocated string (NULL for failure).
|
|
|
|
* If "endp" is not NULL it is set to the character after the terminating
|
|
|
|
* quote.
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
nb_unquote(char_u *p, char_u **endp)
|
|
|
|
{
|
|
|
|
char *result = 0;
|
|
|
|
char *q;
|
|
|
|
int done = 0;
|
|
|
|
|
|
|
|
/* result is never longer than input */
|
2006-04-17 22:14:47 +00:00
|
|
|
result = (char *)alloc_clear((unsigned)STRLEN(p) + 1);
|
2004-06-13 20:20:40 +00:00
|
|
|
if (result == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (*p++ != '"')
|
|
|
|
{
|
|
|
|
nbdebug(("nb_unquote called with string that doesn't start with a quote!: %s\n",
|
|
|
|
p));
|
|
|
|
result[0] = NUL;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (q = result; !done && *p != NUL;)
|
|
|
|
{
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '"':
|
|
|
|
/*
|
|
|
|
* Unbackslashed dquote marks the end, if first char was dquote.
|
|
|
|
*/
|
|
|
|
done = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '\\':
|
|
|
|
++p;
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '\\': *q++ = '\\'; break;
|
|
|
|
case 'n': *q++ = '\n'; break;
|
|
|
|
case 't': *q++ = '\t'; break;
|
|
|
|
case 'r': *q++ = '\r'; break;
|
|
|
|
case '"': *q++ = '"'; break;
|
|
|
|
case NUL: --p; break;
|
|
|
|
/* default: skip over illegal chars */
|
|
|
|
}
|
|
|
|
++p;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
*q++ = *p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (endp != NULL)
|
|
|
|
*endp = p;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-01-05 17:07:13 +00:00
|
|
|
/*
|
|
|
|
* Remove from "first" byte to "last" byte (inclusive), at line "lnum" of the
|
|
|
|
* current buffer. Remove to end of line when "last" is MAXCOL.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nb_partialremove(linenr_T lnum, colnr_T first, colnr_T last)
|
|
|
|
{
|
|
|
|
char_u *oldtext, *newtext;
|
|
|
|
int oldlen;
|
|
|
|
int lastbyte = last;
|
|
|
|
|
|
|
|
oldtext = ml_get(lnum);
|
2008-03-16 15:04:34 +00:00
|
|
|
oldlen = (int)STRLEN(oldtext);
|
2008-01-18 10:40:55 +00:00
|
|
|
if (first >= (colnr_T)oldlen || oldlen == 0) /* just in case */
|
2008-01-05 17:07:13 +00:00
|
|
|
return;
|
|
|
|
if (lastbyte >= oldlen)
|
|
|
|
lastbyte = oldlen - 1;
|
|
|
|
newtext = alloc(oldlen - (int)(lastbyte - first));
|
|
|
|
if (newtext != NULL)
|
|
|
|
{
|
|
|
|
mch_memmove(newtext, oldtext, first);
|
2008-06-24 20:19:36 +00:00
|
|
|
STRMOVE(newtext + first, oldtext + lastbyte + 1);
|
2008-01-05 17:07:13 +00:00
|
|
|
nbdebug((" NEW LINE %d: %s\n", lnum, newtext));
|
|
|
|
ml_replace(lnum, newtext, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Replace the "first" line with the concatenation of the "first" and
|
|
|
|
* the "other" line. The "other" line is not removed.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nb_joinlines(linenr_T first, linenr_T other)
|
|
|
|
{
|
|
|
|
int len_first, len_other;
|
|
|
|
char_u *p;
|
|
|
|
|
2008-03-16 15:04:34 +00:00
|
|
|
len_first = (int)STRLEN(ml_get(first));
|
|
|
|
len_other = (int)STRLEN(ml_get(other));
|
2008-01-05 17:07:13 +00:00
|
|
|
p = alloc((unsigned)(len_first + len_other + 1));
|
|
|
|
if (p != NULL)
|
|
|
|
{
|
|
|
|
mch_memmove(p, ml_get(first), len_first);
|
|
|
|
mch_memmove(p + len_first, ml_get(other), len_other + 1);
|
|
|
|
ml_replace(first, p, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
#define SKIP_STOP 2
|
|
|
|
#define streq(a,b) (strcmp(a,b) == 0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do the actual processing of a single netbeans command or function.
|
2007-05-10 16:41:10 +00:00
|
|
|
* The difference between a command and function is that a function
|
|
|
|
* gets a response (it's required) but a command does not.
|
2004-06-13 20:20:40 +00:00
|
|
|
* For arguments see comment for nb_parse_cmd().
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
nb_do_cmd(
|
|
|
|
int bufno,
|
|
|
|
char_u *cmd,
|
|
|
|
int func,
|
|
|
|
int cmdno,
|
|
|
|
char_u *args) /* points to space before arguments or NUL */
|
|
|
|
{
|
2012-01-10 22:26:17 +01:00
|
|
|
int do_update = 0;
|
2004-06-13 20:20:40 +00:00
|
|
|
long off = 0;
|
|
|
|
nbbuf_T *buf = nb_get_buf(bufno);
|
|
|
|
static int skip = 0;
|
|
|
|
int retval = OK;
|
2004-10-11 10:00:50 +00:00
|
|
|
char *cp; /* for when a char pointer is needed */
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
nbdebug(("%s %d: (%d) %s %s\n", (func) ? "FUN" : "CMD", cmdno, bufno, cmd,
|
|
|
|
STRCMP(cmd, "insert") == 0 ? "<text>" : (char *)args));
|
|
|
|
|
|
|
|
if (func)
|
|
|
|
{
|
|
|
|
/* =====================================================================*/
|
|
|
|
if (streq((char *)cmd, "getModified"))
|
|
|
|
{
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
/* Return the number of buffers that are modified. */
|
|
|
|
nb_reply_nr(cmdno, (long)count_changed_buffers());
|
|
|
|
else
|
|
|
|
/* Return whether the buffer is modified. */
|
|
|
|
nb_reply_nr(cmdno, (long)(buf->bufp->b_changed
|
|
|
|
|| isNetbeansModified(buf->bufp)));
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "saveAndExit"))
|
|
|
|
{
|
|
|
|
/* Note: this will exit Vim if successful. */
|
|
|
|
coloncmd(":confirm qall");
|
|
|
|
|
|
|
|
/* We didn't exit: return the number of changed buffers. */
|
|
|
|
nb_reply_nr(cmdno, (long)count_changed_buffers());
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "getCursor"))
|
|
|
|
{
|
|
|
|
char_u text[200];
|
|
|
|
|
|
|
|
/* Note: nb_getbufno() may return -1. This indicates the IDE
|
|
|
|
* didn't assign a number to the current buffer in response to a
|
|
|
|
* fileOpened event. */
|
|
|
|
sprintf((char *)text, "%d %ld %d %ld",
|
|
|
|
nb_getbufno(curbuf),
|
|
|
|
(long)curwin->w_cursor.lnum,
|
|
|
|
(int)curwin->w_cursor.col,
|
|
|
|
pos2off(curbuf, &curwin->w_cursor));
|
|
|
|
nb_reply_text(cmdno, text);
|
2006-11-14 17:29:46 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "getAnno"))
|
|
|
|
{
|
|
|
|
long linenum = 0;
|
|
|
|
#ifdef FEAT_SIGNS
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" Invalid buffer identifier in getAnno\n"));
|
|
|
|
EMSG("E652: Invalid buffer identifier in getAnno");
|
2006-11-14 17:29:46 +00:00
|
|
|
retval = FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int serNum;
|
|
|
|
|
|
|
|
cp = (char *)args;
|
|
|
|
serNum = strtol(cp, &cp, 10);
|
|
|
|
/* If the sign isn't found linenum will be zero. */
|
|
|
|
linenum = (long)buf_findsign(buf->bufp, serNum);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
nb_reply_nr(cmdno, linenum);
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "getLength"))
|
|
|
|
{
|
|
|
|
long len = 0;
|
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in getLength\n"));
|
|
|
|
EMSG("E632: invalid buffer identifier in getLength");
|
2004-06-13 20:20:40 +00:00
|
|
|
retval = FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len = get_buf_size(buf->bufp);
|
|
|
|
}
|
|
|
|
nb_reply_nr(cmdno, len);
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "getText"))
|
|
|
|
{
|
|
|
|
long len;
|
|
|
|
linenr_T nlines;
|
|
|
|
char_u *text = NULL;
|
|
|
|
linenr_T lno = 1;
|
|
|
|
char_u *p;
|
|
|
|
char_u *line;
|
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in getText\n"));
|
|
|
|
EMSG("E633: invalid buffer identifier in getText");
|
2004-06-13 20:20:40 +00:00
|
|
|
retval = FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len = get_buf_size(buf->bufp);
|
|
|
|
nlines = buf->bufp->b_ml.ml_line_count;
|
|
|
|
text = alloc((unsigned)((len > 0)
|
|
|
|
? ((len + nlines) * 2) : 4));
|
|
|
|
if (text == NULL)
|
|
|
|
{
|
|
|
|
nbdebug((" nb_do_cmd: getText has null text field\n"));
|
|
|
|
retval = FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p = text;
|
|
|
|
*p++ = '\"';
|
|
|
|
for (; lno <= nlines ; lno++)
|
|
|
|
{
|
|
|
|
line = nb_quote(ml_get_buf(buf->bufp, lno, FALSE));
|
|
|
|
if (line != NULL)
|
|
|
|
{
|
|
|
|
STRCPY(p, line);
|
|
|
|
p += STRLEN(line);
|
|
|
|
*p++ = '\\';
|
|
|
|
*p++ = 'n';
|
2004-10-24 19:18:58 +00:00
|
|
|
vim_free(line);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*p++ = '\"';
|
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (text == NULL)
|
|
|
|
nb_reply_text(cmdno, (char_u *)"");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nb_reply_text(cmdno, text);
|
|
|
|
vim_free(text);
|
|
|
|
}
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "remove"))
|
|
|
|
{
|
|
|
|
long count;
|
|
|
|
pos_T first, last;
|
|
|
|
pos_T *pos;
|
2008-01-05 17:07:13 +00:00
|
|
|
pos_T *next;
|
|
|
|
linenr_T del_from_lnum, del_to_lnum; /* lines to be deleted as a whole */
|
2004-06-13 20:20:40 +00:00
|
|
|
int oldFire = netbeansFireChanges;
|
|
|
|
int oldSuppress = netbeansSuppressNoLines;
|
|
|
|
int wasChanged;
|
|
|
|
|
|
|
|
if (skip >= SKIP_STOP)
|
|
|
|
{
|
|
|
|
nbdebug((" Skipping %s command\n", (char *) cmd));
|
|
|
|
nb_reply_nil(cmdno);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in remove\n"));
|
|
|
|
EMSG("E634: invalid buffer identifier in remove");
|
2004-06-13 20:20:40 +00:00
|
|
|
retval = FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
netbeansFireChanges = FALSE;
|
|
|
|
netbeansSuppressNoLines = TRUE;
|
|
|
|
|
2006-02-08 09:20:24 +00:00
|
|
|
nb_set_curbuf(buf->bufp);
|
2004-06-13 20:20:40 +00:00
|
|
|
wasChanged = buf->bufp->b_changed;
|
2004-10-11 10:00:50 +00:00
|
|
|
cp = (char *)args;
|
|
|
|
off = strtol(cp, &cp, 10);
|
|
|
|
count = strtol(cp, &cp, 10);
|
|
|
|
args = (char_u *)cp;
|
2004-06-13 20:20:40 +00:00
|
|
|
/* delete "count" chars, starting at "off" */
|
|
|
|
pos = off2pos(buf->bufp, off);
|
|
|
|
if (!pos)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" !bad position\n"));
|
2004-06-13 20:20:40 +00:00
|
|
|
nb_reply_text(cmdno, (char_u *)"!bad position");
|
|
|
|
netbeansFireChanges = oldFire;
|
|
|
|
netbeansSuppressNoLines = oldSuppress;
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
first = *pos;
|
2009-09-11 12:19:51 +00:00
|
|
|
nbdebug((" FIRST POS: line %d, col %d\n",
|
|
|
|
first.lnum, first.col));
|
2004-06-13 20:20:40 +00:00
|
|
|
pos = off2pos(buf->bufp, off+count-1);
|
|
|
|
if (!pos)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" !bad count\n"));
|
2004-06-13 20:20:40 +00:00
|
|
|
nb_reply_text(cmdno, (char_u *)"!bad count");
|
|
|
|
netbeansFireChanges = oldFire;
|
|
|
|
netbeansSuppressNoLines = oldSuppress;
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
last = *pos;
|
2009-09-11 12:19:51 +00:00
|
|
|
nbdebug((" LAST POS: line %d, col %d\n",
|
|
|
|
last.lnum, last.col));
|
2008-01-05 17:07:13 +00:00
|
|
|
del_from_lnum = first.lnum;
|
|
|
|
del_to_lnum = last.lnum;
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2008-01-05 17:07:13 +00:00
|
|
|
/* Get the position of the first byte after the deleted
|
|
|
|
* section. "next" is NULL when deleting to the end of the
|
|
|
|
* file. */
|
|
|
|
next = off2pos(buf->bufp, off + count);
|
|
|
|
|
|
|
|
/* Remove part of the first line. */
|
2009-09-11 12:19:51 +00:00
|
|
|
if (first.col != 0
|
|
|
|
|| (next != NULL && first.lnum == next->lnum))
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2008-01-05 17:07:13 +00:00
|
|
|
if (first.lnum != last.lnum
|
|
|
|
|| (next != NULL && first.lnum != next->lnum))
|
|
|
|
{
|
|
|
|
/* remove to the end of the first line */
|
|
|
|
nb_partialremove(first.lnum, first.col,
|
|
|
|
(colnr_T)MAXCOL);
|
|
|
|
if (first.lnum == last.lnum)
|
|
|
|
{
|
|
|
|
/* Partial line to remove includes the end of
|
|
|
|
* line. Join the line with the next one, have
|
|
|
|
* the next line deleted below. */
|
|
|
|
nb_joinlines(first.lnum, next->lnum);
|
|
|
|
del_to_lnum = next->lnum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* remove within one line */
|
|
|
|
nb_partialremove(first.lnum, first.col, last.col);
|
|
|
|
}
|
|
|
|
++del_from_lnum; /* don't delete the first line */
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
2008-01-05 17:07:13 +00:00
|
|
|
/* Remove part of the last line. */
|
|
|
|
if (first.lnum != last.lnum && next != NULL
|
|
|
|
&& next->col != 0 && last.lnum == next->lnum)
|
|
|
|
{
|
|
|
|
nb_partialremove(last.lnum, 0, last.col);
|
|
|
|
if (del_from_lnum > first.lnum)
|
|
|
|
{
|
|
|
|
/* Join end of last line to start of first line; last
|
|
|
|
* line is deleted below. */
|
|
|
|
nb_joinlines(first.lnum, last.lnum);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* First line is deleted as a whole, keep the last
|
|
|
|
* line. */
|
|
|
|
--del_to_lnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First is partial line; last line to remove includes
|
|
|
|
* the end of line; join first line to line following last
|
|
|
|
* line; line following last line is deleted below. */
|
|
|
|
if (first.lnum != last.lnum && del_from_lnum > first.lnum
|
|
|
|
&& next != NULL && last.lnum != next->lnum)
|
|
|
|
{
|
|
|
|
nb_joinlines(first.lnum, next->lnum);
|
|
|
|
del_to_lnum = next->lnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete whole lines if there are any. */
|
|
|
|
if (del_to_lnum >= del_from_lnum)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* delete signs from the lines being deleted */
|
2008-01-05 17:07:13 +00:00
|
|
|
for (i = del_from_lnum; i <= del_to_lnum; i++)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
int id = buf_findsign_id(buf->bufp, (linenr_T)i);
|
|
|
|
if (id > 0)
|
|
|
|
{
|
2009-09-11 12:19:51 +00:00
|
|
|
nbdebug((" Deleting sign %d on line %d\n",
|
|
|
|
id, i));
|
2004-06-13 20:20:40 +00:00
|
|
|
buf_delsign(buf->bufp, id);
|
|
|
|
}
|
|
|
|
else
|
2009-05-17 14:24:23 +00:00
|
|
|
{
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug((" No sign on line %d\n", i));
|
2009-05-17 14:24:23 +00:00
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
2009-09-11 12:19:51 +00:00
|
|
|
nbdebug((" Deleting lines %d through %d\n",
|
|
|
|
del_from_lnum, del_to_lnum));
|
2008-01-05 17:07:13 +00:00
|
|
|
curwin->w_cursor.lnum = del_from_lnum;
|
|
|
|
curwin->w_cursor.col = 0;
|
|
|
|
del_lines(del_to_lnum - del_from_lnum + 1, FALSE);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
2008-01-05 17:07:13 +00:00
|
|
|
|
|
|
|
/* Leave cursor at first deleted byte. */
|
|
|
|
curwin->w_cursor = first;
|
|
|
|
check_cursor_lnum();
|
2004-06-13 20:20:40 +00:00
|
|
|
buf->bufp->b_changed = wasChanged; /* logically unchanged */
|
|
|
|
netbeansFireChanges = oldFire;
|
|
|
|
netbeansSuppressNoLines = oldSuppress;
|
|
|
|
|
|
|
|
u_blockfree(buf->bufp);
|
|
|
|
u_clearall(buf->bufp);
|
|
|
|
}
|
|
|
|
nb_reply_nil(cmdno);
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "insert"))
|
|
|
|
{
|
|
|
|
char_u *to_free;
|
|
|
|
|
|
|
|
if (skip >= SKIP_STOP)
|
|
|
|
{
|
|
|
|
nbdebug((" Skipping %s command\n", (char *) cmd));
|
|
|
|
nb_reply_nil(cmdno);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get offset */
|
2004-10-11 10:00:50 +00:00
|
|
|
cp = (char *)args;
|
|
|
|
off = strtol(cp, &cp, 10);
|
|
|
|
args = (char_u *)cp;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* get text to be inserted */
|
|
|
|
args = skipwhite(args);
|
|
|
|
args = to_free = (char_u *)nb_unquote(args, NULL);
|
2004-10-24 19:18:58 +00:00
|
|
|
/*
|
|
|
|
nbdebug((" CHUNK[%d]: %d bytes at offset %d\n",
|
|
|
|
buf->bufp->b_ml.ml_line_count, STRLEN(args), off));
|
|
|
|
*/
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in insert\n"));
|
|
|
|
EMSG("E635: invalid buffer identifier in insert");
|
2004-06-13 20:20:40 +00:00
|
|
|
retval = FAIL;
|
|
|
|
}
|
|
|
|
else if (args != NULL)
|
|
|
|
{
|
2006-03-09 22:27:48 +00:00
|
|
|
int ff_detected = EOL_UNKNOWN;
|
|
|
|
int buf_was_empty = (buf->bufp->b_ml.ml_flags & ML_EMPTY);
|
|
|
|
size_t len = 0;
|
|
|
|
int added = 0;
|
|
|
|
int oldFire = netbeansFireChanges;
|
|
|
|
int old_b_changed;
|
2012-01-10 22:31:31 +01:00
|
|
|
char_u *nlp;
|
2006-03-09 22:27:48 +00:00
|
|
|
linenr_T lnum;
|
|
|
|
linenr_T lnum_start;
|
|
|
|
pos_T *pos;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
netbeansFireChanges = 0;
|
|
|
|
|
2006-03-09 22:27:48 +00:00
|
|
|
/* Jump to the buffer where we insert. After this "curbuf"
|
|
|
|
* can be used. */
|
2006-02-08 09:20:24 +00:00
|
|
|
nb_set_curbuf(buf->bufp);
|
2006-03-08 21:32:40 +00:00
|
|
|
old_b_changed = curbuf->b_changed;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2006-03-09 22:27:48 +00:00
|
|
|
/* Convert the specified character offset into a lnum/col
|
|
|
|
* position. */
|
2006-03-08 21:32:40 +00:00
|
|
|
pos = off2pos(curbuf, off);
|
|
|
|
if (pos != NULL)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2006-03-09 22:27:48 +00:00
|
|
|
if (pos->lnum <= 0)
|
|
|
|
lnum_start = 1;
|
|
|
|
else
|
|
|
|
lnum_start = pos->lnum;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-09 22:27:48 +00:00
|
|
|
/* If the given position is not found, assume we want
|
2004-06-13 20:20:40 +00:00
|
|
|
* the end of the file. See setLocAndSize HACK. */
|
2006-03-09 22:27:48 +00:00
|
|
|
if (buf_was_empty)
|
|
|
|
lnum_start = 1; /* above empty line */
|
|
|
|
else
|
|
|
|
lnum_start = curbuf->b_ml.ml_line_count + 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
|
2006-03-09 22:27:48 +00:00
|
|
|
/* "lnum" is the line where we insert: either append to it or
|
|
|
|
* insert a new line above it. */
|
|
|
|
lnum = lnum_start;
|
2004-10-24 19:18:58 +00:00
|
|
|
|
2006-03-09 22:27:48 +00:00
|
|
|
/* Loop over the "\n" separated lines of the argument. */
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2006-03-09 22:27:48 +00:00
|
|
|
while (*args != NUL)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2012-01-10 22:31:31 +01:00
|
|
|
nlp = vim_strchr(args, '\n');
|
|
|
|
if (nlp == NULL)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2006-03-09 22:27:48 +00:00
|
|
|
/* Incomplete line, probably truncated. Next "insert"
|
|
|
|
* command should append to this one. */
|
|
|
|
len = STRLEN(args);
|
2004-10-24 19:18:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-10 22:31:31 +01:00
|
|
|
len = nlp - args;
|
2006-03-09 22:27:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to detect EOL style, because the commands
|
|
|
|
* use a character offset.
|
|
|
|
*/
|
2012-01-10 22:31:31 +01:00
|
|
|
if (nlp > args && nlp[-1] == '\r')
|
2006-03-09 22:27:48 +00:00
|
|
|
{
|
|
|
|
ff_detected = EOL_DOS;
|
|
|
|
--len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ff_detected = EOL_UNIX;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
2006-03-09 22:27:48 +00:00
|
|
|
args[len] = NUL;
|
2004-10-24 19:18:58 +00:00
|
|
|
|
2006-03-09 22:27:48 +00:00
|
|
|
if (lnum == lnum_start
|
|
|
|
&& ((pos != NULL && pos->col > 0)
|
|
|
|
|| (lnum == 1 && buf_was_empty)))
|
|
|
|
{
|
|
|
|
char_u *oldline = ml_get(lnum);
|
|
|
|
char_u *newline;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2012-04-20 19:47:05 +02:00
|
|
|
/* Insert halfway a line. */
|
2012-01-10 22:31:31 +01:00
|
|
|
newline = alloc_check(
|
|
|
|
(unsigned)(STRLEN(oldline) + len + 1));
|
2006-03-09 22:27:48 +00:00
|
|
|
if (newline != NULL)
|
|
|
|
{
|
2012-04-20 19:47:05 +02:00
|
|
|
mch_memmove(newline, oldline, (size_t)pos->col);
|
|
|
|
newline[pos->col] = NUL;
|
2006-03-09 22:27:48 +00:00
|
|
|
STRCAT(newline, args);
|
2012-04-20 19:47:05 +02:00
|
|
|
STRCAT(newline, oldline + pos->col);
|
2006-03-09 22:27:48 +00:00
|
|
|
ml_replace(lnum, newline, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Append a new line. Not that we always do this,
|
|
|
|
* also when the text doesn't end in a "\n". */
|
2012-01-10 22:31:31 +01:00
|
|
|
ml_append((linenr_T)(lnum - 1), args,
|
|
|
|
(colnr_T)(len + 1), FALSE);
|
2006-03-09 22:27:48 +00:00
|
|
|
++added;
|
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
|
2012-01-10 22:31:31 +01:00
|
|
|
if (nlp == NULL)
|
2006-03-09 22:27:48 +00:00
|
|
|
break;
|
|
|
|
++lnum;
|
2012-01-10 22:31:31 +01:00
|
|
|
args = nlp + 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
2006-03-09 22:27:48 +00:00
|
|
|
/* Adjust the marks below the inserted lines. */
|
|
|
|
appended_lines_mark(lnum_start - 1, (long)added);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2006-03-09 22:27:48 +00:00
|
|
|
/*
|
|
|
|
* When starting with an empty buffer set the fileformat.
|
|
|
|
* This is just guessing...
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
if (buf_was_empty)
|
|
|
|
{
|
|
|
|
if (ff_detected == EOL_UNKNOWN)
|
2016-02-23 14:53:34 +01:00
|
|
|
#if defined(MSWIN)
|
2004-06-13 20:20:40 +00:00
|
|
|
ff_detected = EOL_DOS;
|
2006-03-09 22:27:48 +00:00
|
|
|
#else
|
|
|
|
ff_detected = EOL_UNIX;
|
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
set_fileformat(ff_detected, OPT_LOCAL);
|
2006-03-08 21:32:40 +00:00
|
|
|
curbuf->b_start_ffc = *curbuf->b_p_ff;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX - GRP - Is the next line right? If I've inserted
|
|
|
|
* text the buffer has been updated but not written. Will
|
|
|
|
* netbeans guarantee to write it? Even if I do a :q! ?
|
|
|
|
*/
|
2006-03-08 21:32:40 +00:00
|
|
|
curbuf->b_changed = old_b_changed; /* logically unchanged */
|
2004-06-13 20:20:40 +00:00
|
|
|
netbeansFireChanges = oldFire;
|
|
|
|
|
2006-03-09 22:27:48 +00:00
|
|
|
/* Undo info is invalid now... */
|
2006-03-08 21:32:40 +00:00
|
|
|
u_blockfree(curbuf);
|
|
|
|
u_clearall(curbuf);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
vim_free(to_free);
|
|
|
|
nb_reply_nil(cmdno); /* or !error */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nbdebug(("UNIMPLEMENTED FUNCTION: %s\n", cmd));
|
|
|
|
nb_reply_nil(cmdno);
|
|
|
|
retval = FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Not a function; no reply required. */
|
|
|
|
{
|
|
|
|
/* =====================================================================*/
|
|
|
|
if (streq((char *)cmd, "create"))
|
|
|
|
{
|
|
|
|
/* Create a buffer without a name. */
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in create\n"));
|
|
|
|
EMSG("E636: invalid buffer identifier in create");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
vim_free(buf->displayname);
|
|
|
|
buf->displayname = NULL;
|
|
|
|
|
|
|
|
netbeansReadFile = 0; /* don't try to open disk file */
|
2008-11-15 13:12:07 +00:00
|
|
|
do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin);
|
2004-06-13 20:20:40 +00:00
|
|
|
netbeansReadFile = 1;
|
|
|
|
buf->bufp = curbuf;
|
|
|
|
maketitle();
|
2004-10-24 19:18:58 +00:00
|
|
|
buf->insertDone = FALSE;
|
2010-05-22 18:28:27 +02:00
|
|
|
#if defined(FEAT_MENU) && defined(FEAT_GUI)
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
gui_update_menus(0);
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-10-24 19:18:58 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "insertDone"))
|
|
|
|
{
|
2006-04-22 22:33:57 +00:00
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in insertDone\n"));
|
2006-04-22 22:33:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf->bufp->b_start_eol = *args == 'T';
|
|
|
|
buf->insertDone = TRUE;
|
|
|
|
args += 2;
|
|
|
|
buf->bufp->b_p_ro = *args == 'T';
|
|
|
|
print_read_msg(buf);
|
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "saveDone"))
|
|
|
|
{
|
2006-04-22 22:33:57 +00:00
|
|
|
long savedChars = atol((char *)args);
|
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in saveDone\n"));
|
2006-04-22 22:33:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
print_save_msg(buf, savedChars);
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "startDocumentListen"))
|
|
|
|
{
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in startDocumentListen\n"));
|
|
|
|
EMSG("E637: invalid buffer identifier in startDocumentListen");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
buf->fireChanges = 1;
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "stopDocumentListen"))
|
|
|
|
{
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in stopDocumentListen\n"));
|
|
|
|
EMSG("E638: invalid buffer identifier in stopDocumentListen");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
buf->fireChanges = 0;
|
2005-02-02 22:55:47 +00:00
|
|
|
if (buf->bufp != NULL && buf->bufp->b_was_netbeans_file)
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
2005-02-02 22:55:47 +00:00
|
|
|
if (!buf->bufp->b_netbeans_file)
|
2008-06-24 20:19:36 +00:00
|
|
|
{
|
|
|
|
nbdebug(("E658: NetBeans connection lost for buffer %ld\n", buf->bufp->b_fnum));
|
2004-10-24 19:18:58 +00:00
|
|
|
EMSGN(_("E658: NetBeans connection lost for buffer %ld"),
|
2004-06-13 20:20:40 +00:00
|
|
|
buf->bufp->b_fnum);
|
2008-06-24 20:19:36 +00:00
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
else
|
|
|
|
{
|
2005-02-02 22:55:47 +00:00
|
|
|
/* NetBeans uses stopDocumentListen when it stops editing
|
|
|
|
* a file. It then expects the buffer in Vim to
|
|
|
|
* disappear. */
|
|
|
|
do_bufdel(DOBUF_DEL, (char_u *)"", 1,
|
|
|
|
buf->bufp->b_fnum, buf->bufp->b_fnum, TRUE);
|
2004-10-24 19:18:58 +00:00
|
|
|
vim_memset(buf, 0, sizeof(nbbuf_T));
|
|
|
|
}
|
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setTitle"))
|
|
|
|
{
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in setTitle\n"));
|
|
|
|
EMSG("E639: invalid buffer identifier in setTitle");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
vim_free(buf->displayname);
|
|
|
|
buf->displayname = nb_unquote(args, NULL);
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "initDone"))
|
|
|
|
{
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in initDone\n"));
|
|
|
|
EMSG("E640: invalid buffer identifier in initDone");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-10-24 19:18:58 +00:00
|
|
|
buf->initDone = TRUE;
|
2006-02-08 09:20:24 +00:00
|
|
|
nb_set_curbuf(buf->bufp);
|
2004-06-13 20:20:40 +00:00
|
|
|
#if defined(FEAT_AUTOCMD)
|
|
|
|
apply_autocmds(EVENT_BUFREADPOST, 0, 0, FALSE, buf->bufp);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* handle any postponed key commands */
|
|
|
|
handle_key_queue();
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setBufferNumber")
|
|
|
|
|| streq((char *)cmd, "putBufferNumber"))
|
|
|
|
{
|
2004-10-24 19:18:58 +00:00
|
|
|
char_u *path;
|
2004-06-13 20:20:40 +00:00
|
|
|
buf_T *bufp;
|
|
|
|
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in setBufferNumber\n"));
|
|
|
|
EMSG("E641: invalid buffer identifier in setBufferNumber");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
path = (char_u *)nb_unquote(args, NULL);
|
|
|
|
if (path == NULL)
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
2004-10-24 19:18:58 +00:00
|
|
|
bufp = buflist_findname(path);
|
|
|
|
vim_free(path);
|
2004-06-13 20:20:40 +00:00
|
|
|
if (bufp == NULL)
|
|
|
|
{
|
2009-02-21 21:14:00 +00:00
|
|
|
nbdebug((" File %s not found in setBufferNumber\n", args));
|
2004-06-13 20:20:40 +00:00
|
|
|
EMSG2("E642: File %s not found in setBufferNumber", args);
|
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
buf->bufp = bufp;
|
2004-10-24 19:18:58 +00:00
|
|
|
buf->nbbuf_number = bufp->b_fnum;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* "setBufferNumber" has the side effect of jumping to the buffer
|
|
|
|
* (don't know why!). Don't do that for "putBufferNumber". */
|
|
|
|
if (*cmd != 'p')
|
|
|
|
coloncmd(":buffer %d", bufp->b_fnum);
|
|
|
|
else
|
|
|
|
{
|
2004-10-24 19:18:58 +00:00
|
|
|
buf->initDone = TRUE;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* handle any postponed key commands */
|
|
|
|
handle_key_queue();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setFullName"))
|
|
|
|
{
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in setFullName\n"));
|
|
|
|
EMSG("E643: invalid buffer identifier in setFullName");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
vim_free(buf->displayname);
|
|
|
|
buf->displayname = nb_unquote(args, NULL);
|
|
|
|
|
|
|
|
netbeansReadFile = 0; /* don't try to open disk file */
|
|
|
|
do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE,
|
2008-11-15 13:12:07 +00:00
|
|
|
ECMD_HIDE + ECMD_OLDBUF, curwin);
|
2004-06-13 20:20:40 +00:00
|
|
|
netbeansReadFile = 1;
|
|
|
|
buf->bufp = curbuf;
|
|
|
|
maketitle();
|
2010-05-22 18:28:27 +02:00
|
|
|
#if defined(FEAT_MENU) && defined(FEAT_GUI)
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
gui_update_menus(0);
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "editFile"))
|
|
|
|
{
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in editFile\n"));
|
|
|
|
EMSG("E644: invalid buffer identifier in editFile");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
/* Edit a file: like create + setFullName + read the file. */
|
|
|
|
vim_free(buf->displayname);
|
|
|
|
buf->displayname = nb_unquote(args, NULL);
|
|
|
|
do_ecmd(0, (char_u *)buf->displayname, NULL, NULL, ECMD_ONE,
|
2008-11-15 13:12:07 +00:00
|
|
|
ECMD_HIDE + ECMD_OLDBUF, curwin);
|
2004-06-13 20:20:40 +00:00
|
|
|
buf->bufp = curbuf;
|
2004-10-24 19:18:58 +00:00
|
|
|
buf->initDone = TRUE;
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
#if defined(FEAT_TITLE)
|
|
|
|
maketitle();
|
|
|
|
#endif
|
2010-05-22 18:28:27 +02:00
|
|
|
#if defined(FEAT_MENU) && defined(FEAT_GUI)
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
gui_update_menus(0);
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setVisible"))
|
|
|
|
{
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in setVisible\n"));
|
|
|
|
/* This message was commented out, probably because it can
|
|
|
|
* happen when shutting down. */
|
|
|
|
if (p_verbose > 0)
|
|
|
|
EMSG("E645: invalid buffer identifier in setVisible");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
if (streq((char *)args, "T") && buf->bufp != curbuf)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
exarg_T exarg;
|
|
|
|
exarg.cmd = (char_u *)"goto";
|
|
|
|
exarg.forceit = FALSE;
|
2004-10-24 19:18:58 +00:00
|
|
|
dosetvisible = TRUE;
|
2004-06-13 20:20:40 +00:00
|
|
|
goto_buffer(&exarg, DOBUF_FIRST, FORWARD, buf->bufp->b_fnum);
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-10-24 19:18:58 +00:00
|
|
|
dosetvisible = FALSE;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2010-05-22 18:28:27 +02:00
|
|
|
#ifdef FEAT_GUI
|
2004-06-13 20:20:40 +00:00
|
|
|
/* Side effect!!!. */
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
2004-06-13 20:20:40 +00:00
|
|
|
gui_mch_set_foreground();
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "raise"))
|
|
|
|
{
|
2010-05-22 18:28:27 +02:00
|
|
|
#ifdef FEAT_GUI
|
2004-06-13 20:20:40 +00:00
|
|
|
/* Bring gvim to the foreground. */
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
2004-06-13 20:20:40 +00:00
|
|
|
gui_mch_set_foreground();
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setModified"))
|
|
|
|
{
|
2008-06-09 13:10:45 +00:00
|
|
|
int prev_b_changed;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in setModified\n"));
|
|
|
|
/* This message was commented out, probably because it can
|
|
|
|
* happen when shutting down. */
|
|
|
|
if (p_verbose > 0)
|
|
|
|
EMSG("E646: invalid buffer identifier in setModified");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
2008-06-09 13:10:45 +00:00
|
|
|
prev_b_changed = buf->bufp->b_changed;
|
2004-06-13 20:20:40 +00:00
|
|
|
if (streq((char *)args, "T"))
|
2008-06-09 13:10:45 +00:00
|
|
|
buf->bufp->b_changed = TRUE;
|
2004-06-13 20:20:40 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
/* Assume NetBeans stored the file. Reset the timestamp to
|
|
|
|
* avoid "file changed" warnings. */
|
|
|
|
if (buf->bufp->b_ffname != NULL
|
|
|
|
&& mch_stat((char *)buf->bufp->b_ffname, &st) >= 0)
|
|
|
|
buf_store_time(buf->bufp, &st, buf->bufp->b_ffname);
|
2008-06-09 13:10:45 +00:00
|
|
|
buf->bufp->b_changed = FALSE;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
buf->modified = buf->bufp->b_changed;
|
2008-06-09 13:10:45 +00:00
|
|
|
if (prev_b_changed != buf->bufp->b_changed)
|
|
|
|
{
|
|
|
|
#ifdef FEAT_WINDOWS
|
|
|
|
check_status(buf->bufp);
|
|
|
|
redraw_tabline = TRUE;
|
|
|
|
#endif
|
|
|
|
#ifdef FEAT_TITLE
|
|
|
|
maketitle();
|
|
|
|
#endif
|
|
|
|
update_screen(0);
|
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setModtime"))
|
|
|
|
{
|
2006-04-22 22:33:57 +00:00
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in setModtime\n"));
|
2006-04-22 22:33:57 +00:00
|
|
|
else
|
|
|
|
buf->bufp->b_mtime = atoi((char *)args);
|
2004-10-24 19:18:58 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setReadOnly"))
|
|
|
|
{
|
2006-04-22 22:33:57 +00:00
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in setReadOnly\n"));
|
2006-04-22 22:33:57 +00:00
|
|
|
else if (streq((char *)args, "T"))
|
2004-10-24 19:18:58 +00:00
|
|
|
buf->bufp->b_p_ro = TRUE;
|
|
|
|
else
|
|
|
|
buf->bufp->b_p_ro = FALSE;
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setMark"))
|
|
|
|
{
|
|
|
|
/* not yet */
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "showBalloon"))
|
|
|
|
{
|
|
|
|
#if defined(FEAT_BEVAL)
|
|
|
|
static char *text = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the Balloon Expression Evaluation area.
|
|
|
|
* Ignore 'ballooneval' here.
|
|
|
|
* The text pointer must remain valid for a while.
|
|
|
|
*/
|
|
|
|
if (balloonEval != NULL)
|
|
|
|
{
|
|
|
|
vim_free(text);
|
|
|
|
text = nb_unquote(args, NULL);
|
|
|
|
if (text != NULL)
|
|
|
|
gui_mch_post_balloon(balloonEval, (char_u *)text);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setDot"))
|
|
|
|
{
|
|
|
|
pos_T *pos;
|
|
|
|
#ifdef NBDEBUG
|
|
|
|
char_u *s;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in setDot\n"));
|
|
|
|
EMSG("E647: invalid buffer identifier in setDot");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
2006-02-08 09:20:24 +00:00
|
|
|
nb_set_curbuf(buf->bufp);
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
/* Don't want Visual mode now. */
|
|
|
|
if (VIsual_active)
|
|
|
|
end_visual_mode();
|
|
|
|
#ifdef NBDEBUG
|
|
|
|
s = args;
|
|
|
|
#endif
|
|
|
|
pos = get_off_or_lnum(buf->bufp, &args);
|
|
|
|
if (pos)
|
|
|
|
{
|
|
|
|
curwin->w_cursor = *pos;
|
|
|
|
check_cursor();
|
|
|
|
#ifdef FEAT_FOLDING
|
|
|
|
foldOpenCursor();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
2009-05-17 14:24:23 +00:00
|
|
|
{
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug((" BAD POSITION in setDot: %s\n", s));
|
2009-05-17 14:24:23 +00:00
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* gui_update_cursor(TRUE, FALSE); */
|
|
|
|
/* update_curbuf(NOT_VALID); */
|
|
|
|
update_topline(); /* scroll to show the line */
|
|
|
|
update_screen(VALID);
|
|
|
|
setcursor();
|
2011-04-01 15:33:59 +02:00
|
|
|
cursor_on();
|
2004-06-13 20:20:40 +00:00
|
|
|
out_flush();
|
2010-05-22 18:28:27 +02:00
|
|
|
#ifdef FEAT_GUI
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
{
|
|
|
|
gui_update_cursor(TRUE, FALSE);
|
|
|
|
gui_mch_flush();
|
|
|
|
}
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
/* Quit a hit-return or more prompt. */
|
|
|
|
if (State == HITRETURN || State == ASKMORE)
|
|
|
|
{
|
|
|
|
#ifdef FEAT_GUI_GTK
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use && gtk_main_level() > 0)
|
2004-06-13 20:20:40 +00:00
|
|
|
gtk_main_quit();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "close"))
|
|
|
|
{
|
|
|
|
#ifdef NBDEBUG
|
|
|
|
char *name = "<NONE>";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in close\n"));
|
|
|
|
EMSG("E648: invalid buffer identifier in close");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NBDEBUG
|
|
|
|
if (buf->displayname != NULL)
|
|
|
|
name = buf->displayname;
|
|
|
|
#endif
|
2008-06-24 20:19:36 +00:00
|
|
|
if (buf->bufp == NULL)
|
|
|
|
{
|
|
|
|
nbdebug((" invalid buffer identifier in close\n"));
|
|
|
|
/* This message was commented out, probably because it can
|
|
|
|
* happen when shutting down. */
|
|
|
|
if (p_verbose > 0)
|
|
|
|
EMSG("E649: invalid buffer identifier in close");
|
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug((" CLOSE %d: %s\n", bufno, name));
|
2010-05-22 18:28:27 +02:00
|
|
|
#ifdef FEAT_GUI
|
2004-06-13 20:20:40 +00:00
|
|
|
need_mouse_correct = TRUE;
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
if (buf->bufp != NULL)
|
|
|
|
do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD,
|
|
|
|
buf->bufp->b_fnum, TRUE);
|
2006-08-08 19:34:19 +00:00
|
|
|
buf->bufp = NULL;
|
|
|
|
buf->initDone = FALSE;
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setStyle")) /* obsolete... */
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" setStyle is obsolete!\n"));
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "setExitDelay"))
|
|
|
|
{
|
2004-10-24 19:18:58 +00:00
|
|
|
/* Only used in version 2.1. */
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "defineAnnoType"))
|
|
|
|
{
|
|
|
|
#ifdef FEAT_SIGNS
|
|
|
|
int typeNum;
|
|
|
|
char_u *typeName;
|
|
|
|
char_u *tooltip;
|
|
|
|
char_u *p;
|
|
|
|
char_u *glyphFile;
|
2010-05-22 18:28:27 +02:00
|
|
|
int parse_error = FALSE;
|
|
|
|
char_u *fg;
|
|
|
|
char_u *bg;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if (buf == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in defineAnnoType\n"));
|
|
|
|
EMSG("E650: invalid buffer identifier in defineAnnoType");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
2004-10-11 10:00:50 +00:00
|
|
|
cp = (char *)args;
|
|
|
|
typeNum = strtol(cp, &cp, 10);
|
|
|
|
args = (char_u *)cp;
|
2004-06-13 20:20:40 +00:00
|
|
|
args = skipwhite(args);
|
|
|
|
typeName = (char_u *)nb_unquote(args, &args);
|
|
|
|
args = skipwhite(args + 1);
|
|
|
|
tooltip = (char_u *)nb_unquote(args, &args);
|
|
|
|
args = skipwhite(args + 1);
|
|
|
|
|
|
|
|
p = (char_u *)nb_unquote(args, &args);
|
|
|
|
glyphFile = vim_strsave_escaped(p, escape_chars);
|
|
|
|
vim_free(p);
|
|
|
|
|
|
|
|
args = skipwhite(args + 1);
|
2010-05-22 18:28:27 +02:00
|
|
|
p = skiptowhite(args);
|
|
|
|
if (*p != NUL)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2010-05-22 18:28:27 +02:00
|
|
|
*p = NUL;
|
|
|
|
p = skipwhite(p + 1);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
2010-05-22 18:28:27 +02:00
|
|
|
fg = vim_strsave(args);
|
|
|
|
bg = vim_strsave(p);
|
|
|
|
if (STRLEN(fg) > MAX_COLOR_LENGTH || STRLEN(bg) > MAX_COLOR_LENGTH)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2010-05-22 18:28:27 +02:00
|
|
|
EMSG("E532: highlighting color name too long in defineAnnoType");
|
|
|
|
vim_free(typeName);
|
|
|
|
parse_error = TRUE;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
2010-05-22 18:28:27 +02:00
|
|
|
else if (typeName != NULL && tooltip != NULL && glyphFile != NULL)
|
|
|
|
addsigntype(buf, typeNum, typeName, tooltip, glyphFile, fg, bg);
|
2004-06-13 20:20:40 +00:00
|
|
|
else
|
|
|
|
vim_free(typeName);
|
|
|
|
|
|
|
|
/* don't free typeName; it's used directly in addsigntype() */
|
2010-05-22 18:28:27 +02:00
|
|
|
vim_free(fg);
|
|
|
|
vim_free(bg);
|
2004-06-13 20:20:40 +00:00
|
|
|
vim_free(tooltip);
|
|
|
|
vim_free(glyphFile);
|
2010-05-22 18:28:27 +02:00
|
|
|
if (parse_error)
|
|
|
|
return FAIL;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "addAnno"))
|
|
|
|
{
|
|
|
|
#ifdef FEAT_SIGNS
|
|
|
|
int serNum;
|
|
|
|
int localTypeNum;
|
|
|
|
int typeNum;
|
|
|
|
pos_T *pos;
|
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in addAnno\n"));
|
|
|
|
EMSG("E651: invalid buffer identifier in addAnno");
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2004-10-11 10:00:50 +00:00
|
|
|
cp = (char *)args;
|
|
|
|
serNum = strtol(cp, &cp, 10);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
/* Get the typenr specific for this buffer and convert it to
|
|
|
|
* the global typenumber, as used for the sign name. */
|
2004-10-11 10:00:50 +00:00
|
|
|
localTypeNum = strtol(cp, &cp, 10);
|
|
|
|
args = (char_u *)cp;
|
2004-06-13 20:20:40 +00:00
|
|
|
typeNum = mapsigntype(buf, localTypeNum);
|
|
|
|
|
|
|
|
pos = get_off_or_lnum(buf->bufp, &args);
|
|
|
|
|
2004-10-11 10:00:50 +00:00
|
|
|
cp = (char *)args;
|
2008-11-28 20:29:07 +00:00
|
|
|
ignored = (int)strtol(cp, &cp, 10);
|
2004-10-11 10:00:50 +00:00
|
|
|
args = (char_u *)cp;
|
2004-06-13 20:20:40 +00:00
|
|
|
# ifdef NBDEBUG
|
2008-11-28 20:29:07 +00:00
|
|
|
if (ignored != -1)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" partial line annotation -- Not Yet Implemented!\n"));
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
if (serNum >= GUARDEDOFFSET)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" too many annotations! ignoring...\n"));
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
if (pos)
|
|
|
|
{
|
2009-02-21 21:14:00 +00:00
|
|
|
coloncmd(":sign place %d line=%ld name=%d buffer=%d",
|
2004-06-13 20:20:40 +00:00
|
|
|
serNum, pos->lnum, typeNum, buf->bufp->b_fnum);
|
|
|
|
if (typeNum == curPCtype)
|
|
|
|
coloncmd(":sign jump %d buffer=%d", serNum,
|
|
|
|
buf->bufp->b_fnum);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "removeAnno"))
|
|
|
|
{
|
|
|
|
#ifdef FEAT_SIGNS
|
|
|
|
int serNum;
|
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in removeAnno\n"));
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-10-11 10:00:50 +00:00
|
|
|
cp = (char *)args;
|
|
|
|
serNum = strtol(cp, &cp, 10);
|
|
|
|
args = (char_u *)cp;
|
2004-06-13 20:20:40 +00:00
|
|
|
coloncmd(":sign unplace %d buffer=%d",
|
|
|
|
serNum, buf->bufp->b_fnum);
|
|
|
|
redraw_buf_later(buf->bufp, NOT_VALID);
|
|
|
|
#endif
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "moveAnnoToFront"))
|
|
|
|
{
|
|
|
|
#ifdef FEAT_SIGNS
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" moveAnnoToFront: Not Yet Implemented!\n"));
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "guard") || streq((char *)cmd, "unguard"))
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
pos_T first;
|
|
|
|
pos_T last;
|
|
|
|
pos_T *pos;
|
|
|
|
int un = (cmd[0] == 'u');
|
|
|
|
static int guardId = GUARDEDOFFSET;
|
|
|
|
|
|
|
|
if (skip >= SKIP_STOP)
|
|
|
|
{
|
|
|
|
nbdebug((" Skipping %s command\n", (char *) cmd));
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nb_init_graphics();
|
|
|
|
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in %s command\n", cmd));
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
2006-02-08 09:20:24 +00:00
|
|
|
nb_set_curbuf(buf->bufp);
|
2004-10-11 10:00:50 +00:00
|
|
|
cp = (char *)args;
|
|
|
|
off = strtol(cp, &cp, 10);
|
|
|
|
len = strtol(cp, NULL, 10);
|
|
|
|
args = (char_u *)cp;
|
2004-06-13 20:20:40 +00:00
|
|
|
pos = off2pos(buf->bufp, off);
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
if (!pos)
|
|
|
|
nbdebug((" no such start pos in %s, %ld\n", cmd, off));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
first = *pos;
|
|
|
|
pos = off2pos(buf->bufp, off + len - 1);
|
2004-10-24 19:18:58 +00:00
|
|
|
if (pos != NULL && pos->col == 0)
|
|
|
|
{
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* In Java Swing the offset is a position between 2
|
|
|
|
* characters. If col == 0 then we really want the
|
|
|
|
* previous line as the end.
|
|
|
|
*/
|
|
|
|
pos = off2pos(buf->bufp, off + len - 2);
|
|
|
|
}
|
|
|
|
if (!pos)
|
|
|
|
nbdebug((" no such end pos in %s, %ld\n",
|
|
|
|
cmd, off + len - 1));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
long lnum;
|
|
|
|
last = *pos;
|
|
|
|
/* set highlight for region */
|
|
|
|
nbdebug((" %sGUARD %ld,%d to %ld,%d\n", (un) ? "UN" : "",
|
|
|
|
first.lnum, first.col,
|
|
|
|
last.lnum, last.col));
|
|
|
|
#ifdef FEAT_SIGNS
|
|
|
|
for (lnum = first.lnum; lnum <= last.lnum; lnum++)
|
|
|
|
{
|
|
|
|
if (un)
|
|
|
|
{
|
|
|
|
/* never used */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (buf_findsigntype_id(buf->bufp, lnum,
|
|
|
|
GUARDED) == 0)
|
|
|
|
{
|
|
|
|
coloncmd(
|
2009-02-21 21:14:00 +00:00
|
|
|
":sign place %d line=%ld name=%d buffer=%d",
|
2004-06-13 20:20:40 +00:00
|
|
|
guardId++, lnum, GUARDED,
|
|
|
|
buf->bufp->b_fnum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
redraw_buf_later(buf->bufp, NOT_VALID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "startAtomic"))
|
|
|
|
{
|
|
|
|
inAtomic = 1;
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "endAtomic"))
|
|
|
|
{
|
|
|
|
inAtomic = 0;
|
|
|
|
if (needupdate)
|
|
|
|
{
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
needupdate = 0;
|
|
|
|
}
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "save"))
|
|
|
|
{
|
2004-10-24 19:18:58 +00:00
|
|
|
/*
|
|
|
|
* NOTE - This command is obsolete wrt NetBeans. Its left in
|
|
|
|
* only for historical reasons.
|
|
|
|
*/
|
2004-06-13 20:20:40 +00:00
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in %s command\n", cmd));
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the following is taken from ex_cmds.c (do_wqall function) */
|
|
|
|
if (bufIsChanged(buf->bufp))
|
|
|
|
{
|
|
|
|
/* Only write if the buffer can be written. */
|
|
|
|
if (p_write
|
|
|
|
&& !buf->bufp->b_p_ro
|
|
|
|
&& buf->bufp->b_ffname != NULL
|
|
|
|
#ifdef FEAT_QUICKFIX
|
|
|
|
&& !bt_dontwrite(buf->bufp)
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
{
|
|
|
|
buf_write_all(buf->bufp, FALSE);
|
|
|
|
#ifdef FEAT_AUTOCMD
|
|
|
|
/* an autocommand may have deleted the buffer */
|
|
|
|
if (!buf_valid(buf->bufp))
|
|
|
|
buf->bufp = NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2008-06-24 20:19:36 +00:00
|
|
|
else
|
|
|
|
{
|
2010-01-19 15:13:14 +01:00
|
|
|
nbdebug((" Buffer has no changes!\n"));
|
2008-06-24 20:19:36 +00:00
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "netbeansBuffer"))
|
|
|
|
{
|
|
|
|
if (buf == NULL || buf->bufp == NULL)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug((" invalid buffer identifier in %s command\n", cmd));
|
2004-06-13 20:20:40 +00:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
if (*args == 'T')
|
|
|
|
{
|
|
|
|
buf->bufp->b_netbeans_file = TRUE;
|
|
|
|
buf->bufp->b_was_netbeans_file = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
buf->bufp->b_netbeans_file = FALSE;
|
2004-10-24 19:18:58 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "specialKeys"))
|
|
|
|
{
|
|
|
|
special_keys(args);
|
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "actionMenuItem"))
|
|
|
|
{
|
|
|
|
/* not used yet */
|
2004-06-13 20:20:40 +00:00
|
|
|
/* =====================================================================*/
|
|
|
|
}
|
|
|
|
else if (streq((char *)cmd, "version"))
|
|
|
|
{
|
2004-10-24 19:18:58 +00:00
|
|
|
/* not used yet */
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
2008-06-24 20:19:36 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
nbdebug(("Unrecognised command: %s\n", cmd));
|
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Unrecognized command is ignored.
|
|
|
|
*/
|
|
|
|
}
|
2012-01-10 22:26:17 +01:00
|
|
|
if (inAtomic && do_update)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
needupdate = 1;
|
2012-01-10 22:26:17 +01:00
|
|
|
do_update = 0;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
/*
|
|
|
|
* Is this needed? I moved the netbeans_Xt_connect() later during startup
|
|
|
|
* and it may no longer be necessary. If its not needed then needupdate
|
2012-01-10 22:26:17 +01:00
|
|
|
* and do_update can also be removed.
|
2004-10-24 19:18:58 +00:00
|
|
|
*/
|
2012-01-10 22:26:17 +01:00
|
|
|
if (buf != NULL && buf->initDone && do_update)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
update_screen(NOT_VALID);
|
|
|
|
setcursor();
|
2011-04-01 15:33:59 +02:00
|
|
|
cursor_on();
|
2004-06-13 20:20:40 +00:00
|
|
|
out_flush();
|
2010-05-22 18:28:27 +02:00
|
|
|
#ifdef FEAT_GUI
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
{
|
|
|
|
gui_update_cursor(TRUE, FALSE);
|
|
|
|
gui_mch_flush();
|
|
|
|
}
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
/* Quit a hit-return or more prompt. */
|
|
|
|
if (State == HITRETURN || State == ASKMORE)
|
|
|
|
{
|
|
|
|
#ifdef FEAT_GUI_GTK
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use && gtk_main_level() > 0)
|
2004-06-13 20:20:40 +00:00
|
|
|
gtk_main_quit();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-08 09:20:24 +00:00
|
|
|
/*
|
|
|
|
* If "buf" is not the current buffer try changing to a window that edits this
|
|
|
|
* buffer. If there is no such window then close the current buffer and set
|
|
|
|
* the current buffer as "buf".
|
|
|
|
*/
|
|
|
|
static void
|
2008-01-05 17:07:13 +00:00
|
|
|
nb_set_curbuf(buf_T *buf)
|
2006-02-08 09:20:24 +00:00
|
|
|
{
|
2015-03-14 15:35:52 +01:00
|
|
|
if (curbuf != buf) {
|
|
|
|
if (buf_jump_open_win(buf) != NULL)
|
|
|
|
return;
|
|
|
|
# ifdef FEAT_WINDOWS
|
|
|
|
if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL)
|
|
|
|
return;
|
|
|
|
# endif
|
2006-02-08 09:20:24 +00:00
|
|
|
set_curbuf(buf, DOBUF_GOTO);
|
2015-03-14 15:35:52 +01:00
|
|
|
}
|
2006-02-08 09:20:24 +00:00
|
|
|
}
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Process a vim colon command.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
coloncmd(char *cmd, ...)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, cmd);
|
2009-06-24 14:50:12 +00:00
|
|
|
vim_vsnprintf(buf, sizeof(buf), cmd, ap, NULL);
|
2004-06-13 20:20:40 +00:00
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
nbdebug((" COLONCMD %s\n", buf));
|
|
|
|
|
|
|
|
/* ALT_INPUT_LOCK_ON; */
|
|
|
|
do_cmdline((char_u *)buf, NULL, NULL, DOCMD_NOWAIT | DOCMD_KEYTYPED);
|
|
|
|
/* ALT_INPUT_LOCK_OFF; */
|
|
|
|
|
|
|
|
setcursor(); /* restore the cursor position */
|
|
|
|
out_flush(); /* make sure output has been written */
|
|
|
|
|
2010-05-22 18:28:27 +02:00
|
|
|
#ifdef FEAT_GUI
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
{
|
|
|
|
gui_update_cursor(TRUE, FALSE);
|
|
|
|
gui_mch_flush();
|
|
|
|
}
|
2010-05-22 18:28:27 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
/*
|
|
|
|
* Parse the specialKeys argument and issue the appropriate map commands.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
special_keys(char_u *args)
|
|
|
|
{
|
|
|
|
char *save_str = nb_unquote(args, NULL);
|
|
|
|
char *tok = strtok(save_str, " ");
|
|
|
|
char *sep;
|
|
|
|
char keybuf[64];
|
|
|
|
char cmdbuf[256];
|
|
|
|
|
|
|
|
while (tok != NULL)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if ((sep = strchr(tok, '-')) != NULL)
|
|
|
|
{
|
2004-12-09 21:34:53 +00:00
|
|
|
*sep = NUL;
|
2004-10-24 19:18:58 +00:00
|
|
|
while (*tok)
|
|
|
|
{
|
|
|
|
switch (*tok)
|
|
|
|
{
|
|
|
|
case 'A':
|
|
|
|
case 'M':
|
|
|
|
case 'C':
|
|
|
|
case 'S':
|
|
|
|
keybuf[i++] = *tok;
|
|
|
|
keybuf[i++] = '-';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tok++;
|
|
|
|
}
|
|
|
|
tok++;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(&keybuf[i], tok);
|
2005-05-19 20:53:52 +00:00
|
|
|
vim_snprintf(cmdbuf, sizeof(cmdbuf),
|
|
|
|
"<silent><%s> :nbkey %s<CR>", keybuf, keybuf);
|
2004-10-24 19:18:58 +00:00
|
|
|
do_map(0, (char_u *)cmdbuf, NORMAL, FALSE);
|
|
|
|
tok = strtok(NULL, " ");
|
|
|
|
}
|
|
|
|
vim_free(save_str);
|
|
|
|
}
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
void
|
2016-01-30 19:39:49 +01:00
|
|
|
ex_nbclose(exarg_T *eap UNUSED)
|
2010-05-22 21:34:09 +02:00
|
|
|
{
|
|
|
|
netbeans_close();
|
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
|
|
|
|
void
|
2016-01-30 19:39:49 +01:00
|
|
|
ex_nbkey(exarg_T *eap)
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
2010-01-19 15:13:14 +01:00
|
|
|
(void)netbeans_keystring(eap->arg);
|
2004-10-24 19:18:58 +00:00
|
|
|
}
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
void
|
2016-01-30 19:39:49 +01:00
|
|
|
ex_nbstart(
|
|
|
|
exarg_T *eap)
|
2010-05-22 21:34:09 +02:00
|
|
|
{
|
2010-09-30 21:03:26 +02:00
|
|
|
#ifdef FEAT_GUI
|
|
|
|
# if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \
|
2010-11-16 15:49:02 +01:00
|
|
|
&& !defined(FEAT_GUI_W32)
|
2010-09-30 21:03:26 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
{
|
2010-11-16 15:49:02 +01:00
|
|
|
EMSG(_("E838: netbeans is not supported with this GUI"));
|
|
|
|
return;
|
2010-09-30 21:03:26 +02:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
#endif
|
2010-05-22 21:34:09 +02:00
|
|
|
netbeans_open((char *)eap->arg, FALSE);
|
|
|
|
}
|
2004-10-24 19:18:58 +00:00
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Initialize highlights and signs for use by netbeans (mostly obsolete)
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nb_init_graphics(void)
|
|
|
|
{
|
|
|
|
static int did_init = FALSE;
|
|
|
|
|
|
|
|
if (!did_init)
|
|
|
|
{
|
2010-05-22 18:28:27 +02:00
|
|
|
coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black"
|
|
|
|
" ctermbg=LightCyan ctermfg=Black");
|
2004-06-13 20:20:40 +00:00
|
|
|
coloncmd(":sign define %d linehl=NBGuarded", GUARDED);
|
|
|
|
|
|
|
|
did_init = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-01-19 15:13:14 +01:00
|
|
|
* Convert key to netbeans name. This uses the global "mod_mask".
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
netbeans_keyname(int key, char *buf)
|
|
|
|
{
|
|
|
|
char *name = 0;
|
|
|
|
char namebuf[2];
|
|
|
|
int ctrl = 0;
|
|
|
|
int shift = 0;
|
|
|
|
int alt = 0;
|
|
|
|
|
|
|
|
if (mod_mask & MOD_MASK_CTRL)
|
|
|
|
ctrl = 1;
|
|
|
|
if (mod_mask & MOD_MASK_SHIFT)
|
|
|
|
shift = 1;
|
|
|
|
if (mod_mask & MOD_MASK_ALT)
|
|
|
|
alt = 1;
|
|
|
|
|
|
|
|
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case K_F1: name = "F1"; break;
|
|
|
|
case K_S_F1: name = "F1"; shift = 1; break;
|
|
|
|
case K_F2: name = "F2"; break;
|
|
|
|
case K_S_F2: name = "F2"; shift = 1; break;
|
|
|
|
case K_F3: name = "F3"; break;
|
|
|
|
case K_S_F3: name = "F3"; shift = 1; break;
|
|
|
|
case K_F4: name = "F4"; break;
|
|
|
|
case K_S_F4: name = "F4"; shift = 1; break;
|
|
|
|
case K_F5: name = "F5"; break;
|
|
|
|
case K_S_F5: name = "F5"; shift = 1; break;
|
|
|
|
case K_F6: name = "F6"; break;
|
|
|
|
case K_S_F6: name = "F6"; shift = 1; break;
|
|
|
|
case K_F7: name = "F7"; break;
|
|
|
|
case K_S_F7: name = "F7"; shift = 1; break;
|
|
|
|
case K_F8: name = "F8"; break;
|
|
|
|
case K_S_F8: name = "F8"; shift = 1; break;
|
|
|
|
case K_F9: name = "F9"; break;
|
|
|
|
case K_S_F9: name = "F9"; shift = 1; break;
|
|
|
|
case K_F10: name = "F10"; break;
|
|
|
|
case K_S_F10: name = "F10"; shift = 1; break;
|
|
|
|
case K_F11: name = "F11"; break;
|
|
|
|
case K_S_F11: name = "F11"; shift = 1; break;
|
|
|
|
case K_F12: name = "F12"; break;
|
|
|
|
case K_S_F12: name = "F12"; shift = 1; break;
|
|
|
|
default:
|
|
|
|
if (key >= ' ' && key <= '~')
|
|
|
|
{
|
|
|
|
/* Allow ASCII characters. */
|
|
|
|
name = namebuf;
|
|
|
|
namebuf[0] = key;
|
|
|
|
namebuf[1] = NUL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
name = "X";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf[0] = '\0';
|
|
|
|
if (ctrl)
|
|
|
|
strcat(buf, "C");
|
|
|
|
if (shift)
|
|
|
|
strcat(buf, "S");
|
|
|
|
if (alt)
|
|
|
|
strcat(buf, "M"); /* META */
|
|
|
|
if (ctrl || shift || alt)
|
|
|
|
strcat(buf, "-");
|
|
|
|
strcat(buf, name);
|
|
|
|
}
|
|
|
|
|
2010-05-22 18:28:27 +02:00
|
|
|
#if defined(FEAT_BEVAL) || defined(PROTO)
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Function to be called for balloon evaluation. Grabs the text under the
|
|
|
|
* cursor and sends it to the debugger for evaluation. The debugger should
|
|
|
|
* respond with a showBalloon command when there is a useful result.
|
|
|
|
*/
|
2005-03-07 22:56:57 +00:00
|
|
|
void
|
2004-06-13 20:20:40 +00:00
|
|
|
netbeans_beval_cb(
|
|
|
|
BalloonEval *beval,
|
2009-05-17 14:24:23 +00:00
|
|
|
int state UNUSED)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2005-03-07 22:56:57 +00:00
|
|
|
win_T *wp;
|
2004-06-13 20:20:40 +00:00
|
|
|
char_u *text;
|
2005-03-07 22:56:57 +00:00
|
|
|
linenr_T lnum;
|
2004-06-13 20:20:40 +00:00
|
|
|
int col;
|
2011-04-11 21:35:11 +02:00
|
|
|
char *buf;
|
2004-06-13 20:20:40 +00:00
|
|
|
char_u *p;
|
|
|
|
|
|
|
|
/* Don't do anything when 'ballooneval' is off, messages scrolled the
|
|
|
|
* windows up or we have no connection. */
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!p_beval || msg_scrolled > 0 || !NETBEANS_OPEN)
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
|
|
|
|
2005-03-07 22:56:57 +00:00
|
|
|
if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
/* Send debugger request. Only when the text is of reasonable
|
|
|
|
* length. */
|
|
|
|
if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL)
|
|
|
|
{
|
2011-04-11 21:35:11 +02:00
|
|
|
buf = (char *)alloc(MAXPATHL * 2 + 25);
|
|
|
|
if (buf != NULL)
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
2011-04-11 21:35:11 +02:00
|
|
|
p = nb_quote(text);
|
|
|
|
if (p != NULL)
|
|
|
|
{
|
|
|
|
vim_snprintf(buf, MAXPATHL * 2 + 25,
|
|
|
|
"0:balloonText=%d \"%s\"\n", r_cmdno, p);
|
|
|
|
vim_free(p);
|
|
|
|
}
|
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_beval_cb");
|
|
|
|
vim_free(buf);
|
2004-10-24 19:18:58 +00:00
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
vim_free(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
/*
|
2016-01-24 20:36:41 +01:00
|
|
|
* Return TRUE when the netbeans connection is active.
|
2010-05-22 21:34:09 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
netbeans_active(void)
|
|
|
|
{
|
|
|
|
return NETBEANS_OPEN;
|
|
|
|
}
|
|
|
|
|
2010-05-22 18:28:27 +02:00
|
|
|
/*
|
|
|
|
* Tell netbeans that the window was opened, ready for commands.
|
|
|
|
*/
|
|
|
|
void
|
2010-06-22 06:28:58 +02:00
|
|
|
netbeans_open(char *params, int doabort)
|
2010-05-22 18:28:27 +02:00
|
|
|
{
|
|
|
|
char *cmd = "0:startupDone=0\n";
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (NETBEANS_OPEN)
|
|
|
|
{
|
|
|
|
EMSG(_("E511: netbeans already connected"));
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
2010-05-22 21:34:09 +02:00
|
|
|
}
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2010-06-22 06:28:58 +02:00
|
|
|
if (netbeans_connect(params, doabort) != OK)
|
2010-05-22 18:28:27 +02:00
|
|
|
return;
|
2005-03-07 22:56:57 +00:00
|
|
|
|
|
|
|
nbdebug(("EVT: %s", cmd));
|
|
|
|
nb_send(cmd, "netbeans_startup_done");
|
2010-05-22 21:34:09 +02:00
|
|
|
|
|
|
|
/* update the screen after having added the gutter */
|
|
|
|
changed_window_setting();
|
|
|
|
update_screen(CLEAR);
|
|
|
|
setcursor();
|
2011-04-01 15:33:59 +02:00
|
|
|
cursor_on();
|
2010-05-22 21:34:09 +02:00
|
|
|
out_flush();
|
|
|
|
#ifdef FEAT_GUI
|
2010-08-09 22:49:00 +02:00
|
|
|
if (gui.in_use)
|
|
|
|
{
|
|
|
|
gui_update_cursor(TRUE, FALSE);
|
|
|
|
gui_mch_flush();
|
|
|
|
}
|
2010-05-22 21:34:09 +02:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
/*
|
|
|
|
* Tell netbeans that we're exiting. This should be called right
|
|
|
|
* before calling exit.
|
|
|
|
*/
|
|
|
|
void
|
2016-01-30 19:39:49 +01:00
|
|
|
netbeans_send_disconnect(void)
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (NETBEANS_OPEN)
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf(buf, "0:disconnect=%d\n", r_cmdno);
|
2004-10-24 19:18:58 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_disconnect");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-30 18:07:05 +02:00
|
|
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
|
|
|
int
|
|
|
|
set_ref_in_nb_channel(int copyID)
|
|
|
|
{
|
|
|
|
int abort = FALSE;
|
|
|
|
typval_T tv;
|
|
|
|
|
|
|
|
if (nb_channel != NULL)
|
|
|
|
{
|
|
|
|
tv.v_type = VAR_CHANNEL;
|
|
|
|
tv.vval.v_channel = nb_channel;
|
|
|
|
abort = set_ref_in_item(&tv, copyID, NULL, NULL);
|
|
|
|
}
|
|
|
|
return abort;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-09-29 17:27:01 +02:00
|
|
|
#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_W32) || defined(PROTO)
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Tell netbeans that the window was moved or resized.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_frame_moved(int new_x, int new_y)
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
sprintf(buf, "0:geometry=%d %d %d %d %d\n",
|
2006-08-29 15:30:07 +00:00
|
|
|
r_cmdno, (int)Columns, (int)Rows, new_x, new_y);
|
2004-10-24 19:18:58 +00:00
|
|
|
/*nbdebug(("EVT: %s", buf)); happens too many times during a move */
|
2004-06-13 20:20:40 +00:00
|
|
|
nb_send(buf, "netbeans_frame_moved");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
/*
|
|
|
|
* Tell netbeans the user opened or activated a file.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_file_activated(buf_T *bufp)
|
|
|
|
{
|
|
|
|
int bufno = nb_getbufno(bufp);
|
|
|
|
nbbuf_T *bp = nb_get_buf(bufno);
|
|
|
|
char buffer[2*MAXPATHL];
|
|
|
|
char_u *q;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN || !bufp->b_netbeans_file || dosetvisible)
|
2004-10-24 19:18:58 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
q = nb_quote(bufp->b_ffname);
|
2006-04-22 22:33:57 +00:00
|
|
|
if (q == NULL || bp == NULL)
|
2004-10-24 19:18:58 +00:00
|
|
|
return;
|
|
|
|
|
2005-05-19 20:53:52 +00:00
|
|
|
vim_snprintf(buffer, sizeof(buffer), "%d:fileOpened=%d \"%s\" %s %s\n",
|
2004-10-24 19:18:58 +00:00
|
|
|
bufno,
|
|
|
|
bufno,
|
|
|
|
(char *)q,
|
|
|
|
"T", /* open in NetBeans */
|
|
|
|
"F"); /* modified */
|
|
|
|
|
|
|
|
vim_free(q);
|
|
|
|
nbdebug(("EVT: %s", buffer));
|
|
|
|
|
|
|
|
nb_send(buffer, "netbeans_file_opened");
|
|
|
|
}
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Tell netbeans the user opened a file.
|
|
|
|
*/
|
|
|
|
void
|
2004-10-24 19:18:58 +00:00
|
|
|
netbeans_file_opened(buf_T *bufp)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2004-10-24 19:18:58 +00:00
|
|
|
int bufno = nb_getbufno(bufp);
|
2004-06-13 20:20:40 +00:00
|
|
|
char buffer[2*MAXPATHL];
|
|
|
|
char_u *q;
|
2004-10-24 19:18:58 +00:00
|
|
|
nbbuf_T *bp = nb_get_buf(nb_getbufno(bufp));
|
|
|
|
int bnum;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
q = nb_quote(bufp->b_ffname);
|
2004-06-13 20:20:40 +00:00
|
|
|
if (q == NULL)
|
|
|
|
return;
|
2004-10-24 19:18:58 +00:00
|
|
|
if (bp != NULL)
|
|
|
|
bnum = bufno;
|
|
|
|
else
|
|
|
|
bnum = 0;
|
|
|
|
|
2005-05-19 20:53:52 +00:00
|
|
|
vim_snprintf(buffer, sizeof(buffer), "%d:fileOpened=%d \"%s\" %s %s\n",
|
2004-10-24 19:18:58 +00:00
|
|
|
bnum,
|
2004-06-13 20:20:40 +00:00
|
|
|
0,
|
|
|
|
(char *)q,
|
|
|
|
"T", /* open in NetBeans */
|
|
|
|
"F"); /* modified */
|
|
|
|
|
|
|
|
vim_free(q);
|
|
|
|
nbdebug(("EVT: %s", buffer));
|
|
|
|
|
|
|
|
nb_send(buffer, "netbeans_file_opened");
|
2004-10-24 19:18:58 +00:00
|
|
|
if (p_acd && vim_chdirfile(bufp->b_ffname) == OK)
|
2004-06-13 20:20:40 +00:00
|
|
|
shorten_fnames(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-01-06 15:14:30 +00:00
|
|
|
* Tell netbeans that a file was deleted or wiped out.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
void
|
2009-01-06 15:14:30 +00:00
|
|
|
netbeans_file_killed(buf_T *bufp)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
int bufno = nb_getbufno(bufp);
|
|
|
|
nbbuf_T *nbbuf = nb_get_buf(bufno);
|
|
|
|
char buffer[2*MAXPATHL];
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN || bufno == -1)
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
|
|
|
|
2009-01-06 15:14:30 +00:00
|
|
|
nbdebug(("netbeans_file_killed:\n"));
|
|
|
|
nbdebug((" Killing bufno: %d", bufno));
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf(buffer, "%d:killed=%d\n", bufno, r_cmdno);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
nbdebug(("EVT: %s", buffer));
|
|
|
|
|
2009-01-06 15:14:30 +00:00
|
|
|
nb_send(buffer, "netbeans_file_killed");
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if (nbbuf != NULL)
|
|
|
|
nbbuf->bufp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a pointer to the Netbeans buffer for Vim buffer "bufp".
|
|
|
|
* Return NULL if there is no such buffer or changes are not to be reported.
|
|
|
|
* Otherwise store the buffer number in "*bufnop".
|
|
|
|
*/
|
|
|
|
static nbbuf_T *
|
|
|
|
nb_bufp2nbbuf_fire(buf_T *bufp, int *bufnop)
|
|
|
|
{
|
|
|
|
int bufno;
|
|
|
|
nbbuf_T *nbbuf;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN || !netbeansFireChanges)
|
2004-06-13 20:20:40 +00:00
|
|
|
return NULL; /* changes are not reported at all */
|
|
|
|
|
|
|
|
bufno = nb_getbufno(bufp);
|
|
|
|
if (bufno <= 0)
|
|
|
|
return NULL; /* file is not known to NetBeans */
|
|
|
|
|
|
|
|
nbbuf = nb_get_buf(bufno);
|
|
|
|
if (nbbuf != NULL && !nbbuf->fireChanges)
|
|
|
|
return NULL; /* changes in this buffer are not reported */
|
|
|
|
|
|
|
|
*bufnop = bufno;
|
|
|
|
return nbbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell netbeans the user inserted some text.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_inserted(
|
|
|
|
buf_T *bufp,
|
|
|
|
linenr_T linenr,
|
|
|
|
colnr_T col,
|
|
|
|
char_u *txt,
|
|
|
|
int newlen)
|
|
|
|
{
|
|
|
|
char_u *buf;
|
|
|
|
int bufno;
|
|
|
|
nbbuf_T *nbbuf;
|
|
|
|
pos_T pos;
|
|
|
|
long off;
|
|
|
|
char_u *p;
|
|
|
|
char_u *newtxt;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
|
|
if (nbbuf == NULL)
|
|
|
|
return;
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
/* Don't mark as modified for initial read */
|
|
|
|
if (nbbuf->insertDone)
|
|
|
|
nbbuf->modified = 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
pos.lnum = linenr;
|
|
|
|
pos.col = col;
|
|
|
|
off = pos2off(bufp, &pos);
|
|
|
|
|
|
|
|
/* send the "insert" EVT */
|
|
|
|
newtxt = alloc(newlen + 1);
|
2005-07-18 21:40:44 +00:00
|
|
|
vim_strncpy(newtxt, txt, newlen);
|
2004-06-13 20:20:40 +00:00
|
|
|
p = nb_quote(newtxt);
|
|
|
|
if (p != NULL)
|
|
|
|
{
|
2004-10-24 19:18:58 +00:00
|
|
|
buf = alloc(128 + 2*newlen);
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf((char *)buf, "%d:insert=%d %ld \"%s\"\n",
|
|
|
|
bufno, r_cmdno, off, p);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send((char *)buf, "netbeans_inserted");
|
2004-10-24 19:18:58 +00:00
|
|
|
vim_free(p);
|
|
|
|
vim_free(buf);
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
vim_free(newtxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell netbeans some bytes have been removed.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_removed(
|
|
|
|
buf_T *bufp,
|
|
|
|
linenr_T linenr,
|
|
|
|
colnr_T col,
|
|
|
|
long len)
|
|
|
|
{
|
|
|
|
char_u buf[128];
|
|
|
|
int bufno;
|
|
|
|
nbbuf_T *nbbuf;
|
|
|
|
pos_T pos;
|
|
|
|
long off;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
|
|
if (nbbuf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (len < 0)
|
|
|
|
{
|
2008-06-24 20:19:36 +00:00
|
|
|
nbdebug(("Negative len %ld in netbeans_removed()!\n", len));
|
2004-06-13 20:20:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nbbuf->modified = 1;
|
|
|
|
|
|
|
|
pos.lnum = linenr;
|
|
|
|
pos.col = col;
|
|
|
|
|
|
|
|
off = pos2off(bufp, &pos);
|
|
|
|
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf((char *)buf, "%d:remove=%d %ld %ld\n", bufno, r_cmdno, off, len);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send((char *)buf, "netbeans_removed");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-01-19 14:59:56 +01:00
|
|
|
* Send netbeans an unmodified command.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
void
|
2009-05-17 14:24:23 +00:00
|
|
|
netbeans_unmodified(buf_T *bufp UNUSED)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
2010-08-08 16:38:42 +02:00
|
|
|
/* This is a no-op, because NetBeans considers a buffer modified
|
2004-06-13 20:20:40 +00:00
|
|
|
* even when all changes have been undone. */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a button release event back to netbeans. Its up to netbeans
|
|
|
|
* to decide what to do (if anything) with this event.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_button_release(int button)
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
int bufno;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
bufno = nb_getbufno(curbuf);
|
|
|
|
|
|
|
|
if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf)
|
|
|
|
{
|
2010-05-16 15:46:46 +02:00
|
|
|
int col = mouse_col - W_WINCOL(curwin)
|
2010-05-22 18:28:27 +02:00
|
|
|
- ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1);
|
2004-06-13 20:20:40 +00:00
|
|
|
long off = pos2off(curbuf, &curwin->w_cursor);
|
|
|
|
|
|
|
|
/* sync the cursor position */
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_button_release[newDotAndMark]");
|
|
|
|
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno,
|
2004-06-13 20:20:40 +00:00
|
|
|
button, (long)curwin->w_cursor.lnum, col);
|
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_button_release");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2007-05-10 16:41:10 +00:00
|
|
|
* Send a keypress event back to netbeans. This usually simulates some
|
2004-10-24 19:18:58 +00:00
|
|
|
* kind of function key press. This function operates on a key code.
|
2010-01-19 15:13:14 +01:00
|
|
|
* Return TRUE when the key was sent, FALSE when the command has been
|
|
|
|
* postponed.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
2010-01-19 15:13:14 +01:00
|
|
|
int
|
2004-06-13 20:20:40 +00:00
|
|
|
netbeans_keycommand(int key)
|
|
|
|
{
|
|
|
|
char keyName[60];
|
2004-10-24 19:18:58 +00:00
|
|
|
|
|
|
|
netbeans_keyname(key, keyName);
|
2010-01-19 15:13:14 +01:00
|
|
|
return netbeans_keystring((char_u *)keyName);
|
2004-10-24 19:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2007-05-10 16:41:10 +00:00
|
|
|
* Send a keypress event back to netbeans. This usually simulates some
|
2004-10-24 19:18:58 +00:00
|
|
|
* kind of function key press. This function operates on a key string.
|
2010-01-19 15:13:14 +01:00
|
|
|
* Return TRUE when the key was sent, FALSE when the command has been
|
|
|
|
* postponed.
|
2004-10-24 19:18:58 +00:00
|
|
|
*/
|
2010-01-19 15:13:14 +01:00
|
|
|
static int
|
|
|
|
netbeans_keystring(char_u *keyName)
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
|
|
|
char buf[2*MAXPATHL];
|
|
|
|
int bufno = nb_getbufno(curbuf);
|
2004-06-13 20:20:40 +00:00
|
|
|
long off;
|
|
|
|
char_u *q;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
2010-01-19 15:13:14 +01:00
|
|
|
return TRUE;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if (bufno == -1)
|
|
|
|
{
|
|
|
|
nbdebug(("got keycommand for non-NetBeans buffer, opening...\n"));
|
|
|
|
q = curbuf->b_ffname == NULL ? (char_u *)""
|
|
|
|
: nb_quote(curbuf->b_ffname);
|
|
|
|
if (q == NULL)
|
2010-01-19 15:13:14 +01:00
|
|
|
return TRUE;
|
2005-05-19 20:53:52 +00:00
|
|
|
vim_snprintf(buf, sizeof(buf), "0:fileOpened=%d \"%s\" %s %s\n", 0,
|
2004-06-13 20:20:40 +00:00
|
|
|
q,
|
|
|
|
"T", /* open in NetBeans */
|
|
|
|
"F"); /* modified */
|
|
|
|
if (curbuf->b_ffname != NULL)
|
|
|
|
vim_free(q);
|
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_keycommand");
|
|
|
|
|
2010-01-19 15:13:14 +01:00
|
|
|
postpone_keycommand(keyName);
|
|
|
|
return FALSE;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sync the cursor position */
|
|
|
|
off = pos2off(curbuf, &curwin->w_cursor);
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_keycommand");
|
|
|
|
|
|
|
|
/* To work on Win32 you must apply patch to ExtEditor module
|
|
|
|
* from ExtEdCaret.java.diff - make EVT_newDotAndMark handler
|
|
|
|
* more synchronous
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* now send keyCommand event */
|
2005-05-19 20:53:52 +00:00
|
|
|
vim_snprintf(buf, sizeof(buf), "%d:keyCommand=%d \"%s\"\n",
|
2006-08-29 15:30:07 +00:00
|
|
|
bufno, r_cmdno, keyName);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_keycommand");
|
|
|
|
|
|
|
|
/* New: do both at once and include the lnum/col. */
|
2005-05-19 20:53:52 +00:00
|
|
|
vim_snprintf(buf, sizeof(buf), "%d:keyAtPos=%d \"%s\" %ld %ld/%ld\n",
|
2006-08-29 15:30:07 +00:00
|
|
|
bufno, r_cmdno, keyName,
|
2004-06-13 20:20:40 +00:00
|
|
|
off, (long)curwin->w_cursor.lnum, (long)curwin->w_cursor.col);
|
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send(buf, "netbeans_keycommand");
|
2010-01-19 15:13:14 +01:00
|
|
|
return TRUE;
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a save event to netbeans.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_save_buffer(buf_T *bufp)
|
|
|
|
{
|
|
|
|
char_u buf[64];
|
|
|
|
int bufno;
|
|
|
|
nbbuf_T *nbbuf;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
|
|
if (nbbuf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nbbuf->modified = 0;
|
|
|
|
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf((char *)buf, "%d:save=%d\n", bufno, r_cmdno);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT: %s", buf));
|
|
|
|
nb_send((char *)buf, "netbeans_save_buffer");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send remove command to netbeans (this command has been turned off).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_deleted_all_lines(buf_T *bufp)
|
|
|
|
{
|
|
|
|
char_u buf[64];
|
|
|
|
int bufno;
|
|
|
|
nbbuf_T *nbbuf;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
|
|
|
|
if (nbbuf == NULL)
|
|
|
|
return;
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
/* Don't mark as modified for initial read */
|
|
|
|
if (nbbuf->insertDone)
|
|
|
|
nbbuf->modified = 1;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2006-08-29 15:30:07 +00:00
|
|
|
sprintf((char *)buf, "%d:remove=%d 0 -1\n", bufno, r_cmdno);
|
2004-06-13 20:20:40 +00:00
|
|
|
nbdebug(("EVT(suppressed): %s", buf));
|
|
|
|
/* nb_send(buf, "netbeans_deleted_all_lines"); */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if the lines are guarded. The top and bot parameters are from
|
|
|
|
* u_savecommon(), these are the line above the change and the line below the
|
|
|
|
* change.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
netbeans_is_guarded(linenr_T top, linenr_T bot)
|
|
|
|
{
|
|
|
|
signlist_T *p;
|
|
|
|
int lnum;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return FALSE;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
for (p = curbuf->b_signlist; p != NULL; p = p->next)
|
|
|
|
if (p->id >= GUARDEDOFFSET)
|
|
|
|
for (lnum = top + 1; lnum < bot; lnum++)
|
|
|
|
if (lnum == p->lnum)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-09-29 17:27:01 +02:00
|
|
|
#if defined(FEAT_GUI_X11) || defined(PROTO)
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* We have multiple signs to draw at the same location. Draw the
|
|
|
|
* multi-sign indicator instead. This is the Motif version.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_draw_multisign_indicator(int row)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int x;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
x = 0;
|
|
|
|
y = row * gui.char_height + 2;
|
|
|
|
|
|
|
|
for (i = 0; i < gui.char_height - 3; i++)
|
|
|
|
XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+2, y++);
|
|
|
|
|
|
|
|
XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+0, y);
|
|
|
|
XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+2, y);
|
|
|
|
XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+4, y++);
|
|
|
|
XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+1, y);
|
|
|
|
XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+2, y);
|
|
|
|
XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+3, y++);
|
|
|
|
XDrawPoint(gui.dpy, gui.wid, gui.text_gc, x+2, y);
|
|
|
|
}
|
2010-09-29 17:27:01 +02:00
|
|
|
#endif /* FEAT_GUI_X11 */
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2010-06-26 06:24:45 +02:00
|
|
|
#if defined(FEAT_GUI_GTK) && !defined(PROTO)
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* We have multiple signs to draw at the same location. Draw the
|
|
|
|
* multi-sign indicator instead. This is the GTK/Gnome version.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_draw_multisign_indicator(int row)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int x;
|
2016-02-23 17:14:37 +01:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
cairo_t *cr = NULL;
|
|
|
|
#else
|
2004-06-13 20:20:40 +00:00
|
|
|
GdkDrawable *drawable = gui.drawarea->window;
|
2016-02-23 17:14:37 +01:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2016-02-23 17:14:37 +01:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
cr = cairo_create(gui.surface);
|
|
|
|
{
|
|
|
|
GdkVisual *visual = NULL;
|
|
|
|
guint32 r_mask, g_mask, b_mask;
|
|
|
|
gint r_shift, g_shift, b_shift;
|
|
|
|
|
|
|
|
visual = gdk_window_get_visual(gtk_widget_get_window(gui.drawarea));
|
|
|
|
if (visual != NULL)
|
|
|
|
{
|
|
|
|
gdk_visual_get_red_pixel_details(visual, &r_mask, &r_shift, NULL);
|
|
|
|
gdk_visual_get_green_pixel_details(visual, &g_mask, &g_shift, NULL);
|
|
|
|
gdk_visual_get_blue_pixel_details(visual, &b_mask, &b_shift, NULL);
|
|
|
|
|
|
|
|
cairo_set_source_rgb(cr,
|
|
|
|
((gui.fgcolor->red & r_mask) >> r_shift) / 255.0,
|
|
|
|
((gui.fgcolor->green & g_mask) >> g_shift) / 255.0,
|
|
|
|
((gui.fgcolor->blue & b_mask) >> b_shift) / 255.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
x = 0;
|
|
|
|
y = row * gui.char_height + 2;
|
|
|
|
|
|
|
|
for (i = 0; i < gui.char_height - 3; i++)
|
2016-02-23 17:14:37 +01:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
cairo_rectangle(cr, x+2, y++, 1, 1);
|
|
|
|
#else
|
2004-06-13 20:20:40 +00:00
|
|
|
gdk_draw_point(drawable, gui.text_gc, x+2, y++);
|
2016-02-23 17:14:37 +01:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2016-02-23 17:14:37 +01:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
cairo_rectangle(cr, x+0, y, 1, 1);
|
|
|
|
cairo_rectangle(cr, x+2, y, 1, 1);
|
|
|
|
cairo_rectangle(cr, x+4, y++, 1, 1);
|
|
|
|
cairo_rectangle(cr, x+1, y, 1, 1);
|
|
|
|
cairo_rectangle(cr, x+2, y, 1, 1);
|
|
|
|
cairo_rectangle(cr, x+3, y++, 1, 1);
|
|
|
|
cairo_rectangle(cr, x+2, y, 1, 1);
|
|
|
|
#else
|
2004-06-13 20:20:40 +00:00
|
|
|
gdk_draw_point(drawable, gui.text_gc, x+0, y);
|
|
|
|
gdk_draw_point(drawable, gui.text_gc, x+2, y);
|
|
|
|
gdk_draw_point(drawable, gui.text_gc, x+4, y++);
|
|
|
|
gdk_draw_point(drawable, gui.text_gc, x+1, y);
|
|
|
|
gdk_draw_point(drawable, gui.text_gc, x+2, y);
|
|
|
|
gdk_draw_point(drawable, gui.text_gc, x+3, y++);
|
|
|
|
gdk_draw_point(drawable, gui.text_gc, x+2, y);
|
2016-02-23 17:14:37 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
cairo_destroy(cr);
|
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
#endif /* FEAT_GUI_GTK */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the mouse is clicked in the gutter of a line with multiple
|
|
|
|
* annotations, cycle through the set of signs.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
netbeans_gutter_click(linenr_T lnum)
|
|
|
|
{
|
|
|
|
signlist_T *p;
|
|
|
|
|
2010-05-22 21:34:09 +02:00
|
|
|
if (!NETBEANS_OPEN)
|
|
|
|
return;
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
for (p = curbuf->b_signlist; p != NULL; p = p->next)
|
|
|
|
{
|
|
|
|
if (p->lnum == lnum && p->next && p->next->lnum == lnum)
|
|
|
|
{
|
|
|
|
signlist_T *tail;
|
|
|
|
|
|
|
|
/* remove "p" from list, reinsert it at the tail of the sublist */
|
|
|
|
if (p->prev)
|
|
|
|
p->prev->next = p->next;
|
|
|
|
else
|
|
|
|
curbuf->b_signlist = p->next;
|
|
|
|
p->next->prev = p->prev;
|
|
|
|
/* now find end of sublist and insert p */
|
|
|
|
for (tail = p->next;
|
|
|
|
tail->next && tail->next->lnum == lnum
|
|
|
|
&& tail->next->id < GUARDEDOFFSET;
|
|
|
|
tail = tail->next)
|
|
|
|
;
|
|
|
|
/* tail now points to last entry with same lnum (except
|
|
|
|
* that "guarded" annotations are always last) */
|
|
|
|
p->next = tail->next;
|
|
|
|
if (tail->next)
|
|
|
|
tail->next->prev = p;
|
|
|
|
p->prev = tail;
|
|
|
|
tail->next = p;
|
|
|
|
update_debug_sign(curbuf, lnum);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-01-19 14:59:56 +01:00
|
|
|
* Add a sign of the requested type at the requested location.
|
2004-06-13 20:20:40 +00:00
|
|
|
*
|
|
|
|
* Reverse engineering:
|
|
|
|
* Apparently an annotation is defined the first time it is used in a buffer.
|
|
|
|
* When the same annotation is used in two buffers, the second time we do not
|
|
|
|
* need to define a new sign name but reuse the existing one. But since the
|
|
|
|
* ID number used in the second buffer starts counting at one again, a mapping
|
|
|
|
* is made from the ID specifically for the buffer to the global sign name
|
|
|
|
* (which is a number).
|
|
|
|
*
|
|
|
|
* globalsignmap[] stores the signs that have been defined globally.
|
|
|
|
* buf->signmapused[] maps buffer-local annotation IDs to an index in
|
|
|
|
* globalsignmap[].
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
addsigntype(
|
|
|
|
nbbuf_T *buf,
|
|
|
|
int typeNum,
|
|
|
|
char_u *typeName,
|
2009-05-17 14:24:23 +00:00
|
|
|
char_u *tooltip UNUSED,
|
2004-06-13 20:20:40 +00:00
|
|
|
char_u *glyphFile,
|
2010-05-22 18:28:27 +02:00
|
|
|
char_u *fg,
|
|
|
|
char_u *bg)
|
2004-06-13 20:20:40 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
2010-05-22 18:28:27 +02:00
|
|
|
int use_fg = (*fg && STRCMP(fg, "none") != 0);
|
|
|
|
int use_bg = (*bg && STRCMP(bg, "none") != 0);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
for (i = 0; i < globalsignmapused; i++)
|
|
|
|
if (STRCMP(typeName, globalsignmap[i]) == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == globalsignmapused) /* not found; add it to global map */
|
|
|
|
{
|
2010-05-22 18:28:27 +02:00
|
|
|
nbdebug(("DEFINEANNOTYPE(%d,%s,%s,%s,%s,%s)\n",
|
2004-06-13 20:20:40 +00:00
|
|
|
typeNum, typeName, tooltip, glyphFile, fg, bg));
|
|
|
|
if (use_fg || use_bg)
|
|
|
|
{
|
2010-05-22 18:28:27 +02:00
|
|
|
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);
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
coloncmd(":highlight NB_%s %s %s", typeName, (use_fg) ? fgbuf : "",
|
|
|
|
(use_bg) ? bgbuf : "");
|
|
|
|
if (*glyphFile == NUL)
|
|
|
|
/* no glyph, line highlighting only */
|
|
|
|
coloncmd(":sign define %d linehl=NB_%s", i + 1, typeName);
|
|
|
|
else if (vim_strsize(glyphFile) <= 2)
|
|
|
|
/* one- or two-character glyph name, use as text glyph with
|
|
|
|
* texthl */
|
|
|
|
coloncmd(":sign define %d text=%s texthl=NB_%s", i + 1,
|
|
|
|
glyphFile, typeName);
|
|
|
|
else
|
|
|
|
/* glyph, line highlighting */
|
|
|
|
coloncmd(":sign define %d icon=%s linehl=NB_%s", i + 1,
|
|
|
|
glyphFile, typeName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* glyph, no line highlighting */
|
|
|
|
coloncmd(":sign define %d icon=%s", i + 1, glyphFile);
|
|
|
|
|
|
|
|
if (STRCMP(typeName,"CurrentPC") == 0)
|
|
|
|
curPCtype = typeNum;
|
|
|
|
|
|
|
|
if (globalsignmapused == globalsignmaplen)
|
|
|
|
{
|
|
|
|
if (globalsignmaplen == 0) /* first allocation */
|
|
|
|
{
|
|
|
|
globalsignmaplen = 20;
|
|
|
|
globalsignmap = (char **)alloc_clear(globalsignmaplen*sizeof(char *));
|
|
|
|
}
|
|
|
|
else /* grow it */
|
|
|
|
{
|
|
|
|
int incr;
|
|
|
|
int oldlen = globalsignmaplen;
|
2015-02-10 18:34:01 +01:00
|
|
|
char **t_globalsignmap = globalsignmap;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
globalsignmaplen *= 2;
|
|
|
|
incr = globalsignmaplen - oldlen;
|
|
|
|
globalsignmap = (char **)vim_realloc(globalsignmap,
|
|
|
|
globalsignmaplen * sizeof(char *));
|
2015-02-10 18:34:01 +01:00
|
|
|
if (globalsignmap == NULL)
|
|
|
|
{
|
|
|
|
vim_free(t_globalsignmap);
|
|
|
|
globalsignmaplen = 0;
|
|
|
|
return;
|
|
|
|
}
|
2010-05-24 11:59:29 +02:00
|
|
|
vim_memset(globalsignmap + oldlen, 0, incr * sizeof(char *));
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
globalsignmap[i] = (char *)typeName;
|
|
|
|
globalsignmapused = i + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check local map; should *not* be found! */
|
|
|
|
for (j = 0; j < buf->signmapused; j++)
|
|
|
|
if (buf->signmap[j] == i + 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* add to local map */
|
|
|
|
if (buf->signmapused == buf->signmaplen)
|
|
|
|
{
|
|
|
|
if (buf->signmaplen == 0) /* first allocation */
|
|
|
|
{
|
|
|
|
buf->signmaplen = 5;
|
2010-07-31 16:44:19 +02:00
|
|
|
buf->signmap = (int *)alloc_clear(buf->signmaplen * sizeof(int));
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
else /* grow it */
|
|
|
|
{
|
|
|
|
int incr;
|
|
|
|
int oldlen = buf->signmaplen;
|
2015-02-10 18:34:01 +01:00
|
|
|
int *t_signmap = buf->signmap;
|
2010-07-31 16:44:19 +02:00
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
buf->signmaplen *= 2;
|
|
|
|
incr = buf->signmaplen - oldlen;
|
|
|
|
buf->signmap = (int *)vim_realloc(buf->signmap,
|
2010-07-31 16:44:19 +02:00
|
|
|
buf->signmaplen * sizeof(int));
|
2015-02-10 18:34:01 +01:00
|
|
|
if (buf->signmap == NULL)
|
|
|
|
{
|
|
|
|
vim_free(t_signmap);
|
|
|
|
buf->signmaplen = 0;
|
|
|
|
return;
|
|
|
|
}
|
2010-07-31 16:44:19 +02:00
|
|
|
vim_memset(buf->signmap + oldlen, 0, incr * sizeof(int));
|
2004-06-13 20:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buf->signmap[buf->signmapused++] = i + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if we have the requested sign type in the buffer.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mapsigntype(nbbuf_T *buf, int localsigntype)
|
|
|
|
{
|
|
|
|
if (--localsigntype >= 0 && localsigntype < buf->signmapused)
|
|
|
|
return buf->signmap[localsigntype];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute length of buffer, don't print anything.
|
|
|
|
*/
|
|
|
|
static long
|
|
|
|
get_buf_size(buf_T *bufp)
|
|
|
|
{
|
|
|
|
linenr_T lnum;
|
|
|
|
long char_count = 0;
|
|
|
|
int eol_size;
|
|
|
|
long last_check = 100000L;
|
|
|
|
|
|
|
|
if (bufp->b_ml.ml_flags & ML_EMPTY)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (get_fileformat(bufp) == EOL_DOS)
|
|
|
|
eol_size = 2;
|
|
|
|
else
|
|
|
|
eol_size = 1;
|
|
|
|
for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
|
|
|
|
{
|
2009-09-11 12:19:51 +00:00
|
|
|
char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
|
|
|
|
+ eol_size;
|
2004-06-13 20:20:40 +00:00
|
|
|
/* Check for a CTRL-C every 100000 characters */
|
|
|
|
if (char_count > last_check)
|
|
|
|
{
|
|
|
|
ui_breakcheck();
|
|
|
|
if (got_int)
|
|
|
|
return char_count;
|
|
|
|
last_check = char_count + 100000L;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Correction for when last line doesn't have an EOL. */
|
2015-07-17 14:18:08 +02:00
|
|
|
if (!bufp->b_p_eol && (bufp->b_p_bin || !bufp->b_p_fixeol))
|
2004-06-13 20:20:40 +00:00
|
|
|
char_count -= eol_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
return char_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert character offset to lnum,col
|
|
|
|
*/
|
|
|
|
static pos_T *
|
|
|
|
off2pos(buf_T *buf, long offset)
|
|
|
|
{
|
|
|
|
linenr_T lnum;
|
|
|
|
static pos_T pos;
|
|
|
|
|
|
|
|
pos.lnum = 0;
|
|
|
|
pos.col = 0;
|
|
|
|
#ifdef FEAT_VIRTUALEDIT
|
|
|
|
pos.coladd = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!(buf->b_ml.ml_flags & ML_EMPTY))
|
|
|
|
{
|
|
|
|
if ((lnum = ml_find_line_or_offset(buf, (linenr_T)0, &offset)) < 0)
|
|
|
|
return NULL;
|
|
|
|
pos.lnum = lnum;
|
|
|
|
pos.col = offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert an argument in the form "1234" to an offset and compute the
|
|
|
|
* lnum/col from it. Convert an argument in the form "123/12" directly to a
|
|
|
|
* lnum/col.
|
|
|
|
* "argp" is advanced to after the argument.
|
|
|
|
* Return a pointer to the position, NULL if something is wrong.
|
|
|
|
*/
|
|
|
|
static pos_T *
|
|
|
|
get_off_or_lnum(buf_T *buf, char_u **argp)
|
|
|
|
{
|
|
|
|
static pos_T mypos;
|
|
|
|
long off;
|
|
|
|
|
|
|
|
off = strtol((char *)*argp, (char **)argp, 10);
|
|
|
|
if (**argp == '/')
|
|
|
|
{
|
|
|
|
mypos.lnum = (linenr_T)off;
|
|
|
|
++*argp;
|
|
|
|
mypos.col = strtol((char *)*argp, (char **)argp, 10);
|
|
|
|
#ifdef FEAT_VIRTUALEDIT
|
|
|
|
mypos.coladd = 0;
|
|
|
|
#endif
|
|
|
|
return &mypos;
|
|
|
|
}
|
|
|
|
return off2pos(buf, off);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-02-14 22:29:30 +00:00
|
|
|
* Convert (lnum,col) to byte offset in the file.
|
2004-06-13 20:20:40 +00:00
|
|
|
*/
|
|
|
|
static long
|
|
|
|
pos2off(buf_T *buf, pos_T *pos)
|
|
|
|
{
|
|
|
|
long offset = 0;
|
|
|
|
|
|
|
|
if (!(buf->b_ml.ml_flags & ML_EMPTY))
|
|
|
|
{
|
|
|
|
if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0)
|
|
|
|
return 0;
|
|
|
|
offset += pos->col;
|
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-24 19:18:58 +00:00
|
|
|
/*
|
|
|
|
* This message is printed after NetBeans opens a new file. Its
|
|
|
|
* similar to the message readfile() uses, but since NetBeans
|
|
|
|
* doesn't normally call readfile, we do our own.
|
|
|
|
*/
|
|
|
|
static void
|
2016-01-30 19:39:49 +01:00
|
|
|
print_read_msg(nbbuf_T *buf)
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
|
|
|
int lnum = buf->bufp->b_ml.ml_line_count;
|
2010-05-31 21:59:46 +02:00
|
|
|
off_t nchars = buf->bufp->b_orig_size;
|
2004-10-24 19:18:58 +00:00
|
|
|
char_u c;
|
|
|
|
|
|
|
|
msg_add_fname(buf->bufp, buf->bufp->b_ffname);
|
|
|
|
c = FALSE;
|
|
|
|
|
|
|
|
if (buf->bufp->b_p_ro)
|
|
|
|
{
|
|
|
|
STRCAT(IObuff, shortmess(SHM_RO) ? _("[RO]") : _("[readonly]"));
|
|
|
|
c = TRUE;
|
|
|
|
}
|
|
|
|
if (!buf->bufp->b_start_eol)
|
|
|
|
{
|
2010-05-22 18:28:27 +02:00
|
|
|
STRCAT(IObuff, shortmess(SHM_LAST) ? _("[noeol]")
|
|
|
|
: _("[Incomplete last line]"));
|
2004-10-24 19:18:58 +00:00
|
|
|
c = TRUE;
|
|
|
|
}
|
|
|
|
msg_add_lines(c, (long)lnum, nchars);
|
|
|
|
|
|
|
|
/* Now display it */
|
|
|
|
vim_free(keep_msg);
|
|
|
|
keep_msg = NULL;
|
|
|
|
msg_scrolled_ign = TRUE;
|
|
|
|
msg_trunc_attr(IObuff, FALSE, 0);
|
|
|
|
msg_scrolled_ign = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-05-22 18:28:27 +02:00
|
|
|
* 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.
|
2004-10-24 19:18:58 +00:00
|
|
|
*/
|
|
|
|
static void
|
2016-01-30 19:39:49 +01:00
|
|
|
print_save_msg(nbbuf_T *buf, off_t nchars)
|
2004-10-24 19:18:58 +00:00
|
|
|
{
|
|
|
|
char_u c;
|
|
|
|
char_u *p;
|
|
|
|
|
|
|
|
if (nchars >= 0)
|
|
|
|
{
|
2010-05-22 18:28:27 +02:00
|
|
|
/* put fname in IObuff with quotes */
|
|
|
|
msg_add_fname(buf->bufp, buf->bufp->b_ffname);
|
2004-10-24 19:18:58 +00:00
|
|
|
c = FALSE;
|
|
|
|
|
|
|
|
msg_add_lines(c, buf->bufp->b_ml.ml_line_count,
|
2010-05-31 21:59:46 +02:00
|
|
|
buf->bufp->b_orig_size);
|
2004-10-24 19:18:58 +00:00
|
|
|
|
|
|
|
vim_free(keep_msg);
|
|
|
|
keep_msg = NULL;
|
|
|
|
msg_scrolled_ign = TRUE;
|
|
|
|
p = msg_trunc_attr(IObuff, FALSE, 0);
|
|
|
|
if ((msg_scrolled && !need_wait_return) || !buf->initDone)
|
|
|
|
{
|
|
|
|
/* Need to repeat the message after redrawing when:
|
|
|
|
* - When reading from stdin (the screen will be cleared next).
|
|
|
|
* - When restart_edit is set (otherwise there will be a delay
|
|
|
|
* before redrawing).
|
|
|
|
* - When the screen was scrolled but there is no wait-return
|
|
|
|
* prompt. */
|
2006-02-21 22:02:53 +00:00
|
|
|
set_keep_msg(p, 0);
|
2004-10-24 19:18:58 +00:00
|
|
|
}
|
|
|
|
msg_scrolled_ign = FALSE;
|
|
|
|
/* add_to_input_buf((char_u *)"\f", 1); */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-04-11 16:56:35 +02:00
|
|
|
char_u msgbuf[IOSIZE];
|
|
|
|
|
|
|
|
vim_snprintf((char *)msgbuf, IOSIZE,
|
|
|
|
_("E505: %s is read-only (add ! to override)"), IObuff);
|
|
|
|
nbdebug((" %s\n", msgbuf));
|
|
|
|
emsg(msgbuf);
|
2004-10-24 19:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif /* defined(FEAT_NETBEANS_INTG) */
|