void *
lalloc_id(size_t size, int message, alloc_id_T id UNUSED)
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (alloc_fail_id == id && alloc_does_fail(size))
return NULL;
-#endif
+# endif
return (lalloc(size, message));
}
#endif
return OK;
}
-# if defined(FEAT_SYN_HL)
+#if defined(FEAT_SYN_HL)
/*
* Add "what" to 'eventignore' to skip loading syntax highlighting for every
vim_free(old_ei);
}
}
-# endif // FEAT_SYN_HL
+#endif // FEAT_SYN_HL
/*
* do_autocmd() -- implements the :autocmd command. Can be used in the
&& bufref_valid(&aco->new_curbuf)
&& aco->new_curbuf.br_buf->b_ml.ml_mfp != NULL)
{
-# if defined(FEAT_SYN_HL) || defined(FEAT_SPELL)
+#if defined(FEAT_SYN_HL) || defined(FEAT_SPELL)
if (curwin->w_s == &curbuf->b_s)
curwin->w_s = &aco->new_curbuf.br_buf->b_s;
-# endif
+#endif
--curbuf->b_nwindows;
curbuf = aco->new_curbuf.br_buf;
curwin->w_buffer = curbuf;
return retval;
}
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
static char_u *old_termresponse = NULL;
static char_u *old_termu7resp = NULL;
static char_u *old_termblinkresp = NULL;
static char_u *old_termrbgresp = NULL;
static char_u *old_termrfgresp = NULL;
static char_u *old_termstyleresp = NULL;
-# endif
+#endif
/*
* Block triggering autocommands until unblock_autocmd() is called.
void
block_autocmds(void)
{
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
// Remember the value of v:termresponse.
if (autocmd_blocked == 0)
{
old_termrfgresp = get_vim_var_str(VV_TERMRFGRESP);
old_termstyleresp = get_vim_var_str(VV_TERMSTYLERESP);
}
-# endif
+#endif
++autocmd_blocked;
}
{
--autocmd_blocked;
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
// When v:termresponse, etc, were set while autocommands were blocked,
// trigger the autocommands now. Esp. useful when executing a shell
// command during startup (vimdiff).
apply_autocmds(EVENT_TERMRESPONSEALL, (char_u *)"cursorshape", NULL, FALSE, curbuf);
}
}
-# endif
+#endif
}
int
can_use_beval(void)
{
return (0
-#ifdef FEAT_BEVAL_GUI
+# ifdef FEAT_BEVAL_GUI
|| (gui.in_use && p_beval)
-#endif
-#ifdef FEAT_BEVAL_TERM
+# endif
+# ifdef FEAT_BEVAL_TERM
|| (
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
!gui.in_use &&
-# endif
+# endif
p_bevalterm)
-#endif
+# endif
) && msg_scrolled == 0;
}
void
general_beval_cb(BalloonEval *beval, int state UNUSED)
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
win_T *wp;
int col;
linenr_T lnum;
char_u *text;
char_u *bexpr;
-#endif
+# endif
static int recursive = FALSE;
// Don't do anything when 'ballooneval' is off, messages scrolled the
return;
recursive = TRUE;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
{
bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr
return;
}
}
-#endif
-#ifdef FEAT_NETBEANS_INTG
+# endif
+# ifdef FEAT_NETBEANS_INTG
if (bevalServers & BEVAL_NETBEANS)
netbeans_beval_cb(beval, state);
-#endif
+# endif
recursive = FALSE;
}
mch_settitle(lasttitle, lasticon);
}
-# if defined(EXITFREE)
+#if defined(EXITFREE)
void
free_titles(void)
{
vim_free(lasttitle);
vim_free(lasticon);
}
-# endif
+#endif
#if defined(FEAT_STL_OPT) || defined(FEAT_GUI_TABLINE)
char_u *p;
char_u *s;
int byteval;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
int use_sandbox;
int save_VIsual_active;
-#endif
+# endif
int empty_line;
long l;
long n;
int itemcnt;
int curitem;
int groupdepth;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
int evaldepth;
-#endif
+# endif
int minwid;
int maxwid;
int zeropad;
char_u base;
char_u opt;
-#define TMPLEN 70
+# define TMPLEN 70
char_u buf_tmp[TMPLEN];
char_u *usefmt = fmt;
stl_hlrec_T *sp;
stl_separator_locations = ALLOC_MULT(int, stl_items_len);
}
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// if "fmt" was set insecurely it needs to be evaluated in the sandbox
use_sandbox = was_set_insecurely(wp, opt_name, opt_scope);
do_unlet((char_u *)"g:statusline_winid", TRUE);
}
-#endif
+# endif
if (fillchar == 0)
fillchar = ' ';
byteval = (*mb_ptr2char)(p + wp->w_cursor.col);
groupdepth = 0;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
evaldepth = 0;
-#endif
+# endif
p = out;
curitem = 0;
prevchar_isflag = TRUE;
curitem++;
continue;
}
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// Denotes end of expanded %{} block
if (*s == '}' && evaldepth > 0)
{
evaldepth--;
continue;
}
-#endif
+# endif
if (vim_strchr(STL_ALL, *s) == NULL)
{
if (*s == NUL) // can happen with "%0"
case STL_VIM_EXPR: // '{'
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
char_u *block_start = s - 1;
-#endif
+# endif
int reevaluate = (*s == '%');
char_u *t;
buf_T *save_curbuf;
else
*p = NUL;
p = t;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
vim_snprintf((char *)buf_tmp, sizeof(buf_tmp),
"%d", curbuf->b_fnum);
set_internal_string_var((char_u *)"g:actual_curbuf", buf_tmp);
continue;
}
}
-#endif
+# endif
break;
}
case STL_LINE:
str = buf_tmp;
break;
case STL_PAGENUM:
-#if defined(FEAT_PRINTER) || defined(FEAT_GUI_TABLINE)
+# if defined(FEAT_PRINTER) || defined(FEAT_GUI_TABLINE)
num = printer_page_num;
-#else
+# else
num = 0;
-#endif
+# endif
break;
case STL_BUFNO:
base = 'X';
// FALLTHROUGH
case STL_OFFSET:
-#ifdef FEAT_BYTEOFF
+# ifdef FEAT_BYTEOFF
l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL);
num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0
? 0L : l + 1 + ((State & MODE_INSERT) == 0 && empty_line
? 0 : (int)wp->w_cursor.col);
-#endif
+# endif
break;
case STL_BYTEVAL_X:
}
break;
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
case STL_PREVIEWFLAG:
case STL_PREVIEWFLAG_ALT:
itemisflag = TRUE;
? _(msg_loclist)
: _(msg_qflist));
break;
-#endif
+# endif
case STL_MODIFIED:
case STL_MODIFIED_ALT:
outputlen = (size_t)(p - out);
itemcnt = curitem;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (usefmt != fmt)
vim_free(usefmt);
-#endif
+# endif
width = vim_strsize(out);
if (maxwidth > 0 && width > maxwidth)
if (converted && wb_flags == 0
#ifdef USE_ICONV
&& write_info.bw_iconv_fd == (iconv_t)-1
-# endif
-# ifdef FEAT_EVAL
+#endif
+#ifdef FEAT_EVAL
&& wfname == fname
-# endif
+#endif
)
{
if (!forceit)
&& *buf->b_p_key != NUL && !filtering
&& *ptr == NUL)
write_info.bw_finish = TRUE;
- #endif
+#endif
if (buf_write_bytes(&write_info) == FAIL)
{
end = 0; // write error: break loop
&& (write_info.bw_flags & FIO_ENCRYPTED)
&& *buf->b_p_key != NUL && !filtering)
write_info.bw_finish = TRUE;
- #endif
+#endif
if (buf_write_bytes(&write_info) == FAIL)
end = 0; // write error
nchars += len;
// Probably need to set the security context.
if (!backup_copy)
{
-#if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
+# if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
mch_copy_sec(backup, wfname);
-#endif
-#ifdef FEAT_XATTR
+# endif
+# ifdef FEAT_XATTR
mch_copy_xattr(backup, wfname);
-#endif
+# endif
}
#endif
sai->sin_port = htons(port);
# ifdef HAVE_INET_NTOP
src = &sai->sin_addr;
-#endif
+# endif
}
# ifdef HAVE_INET_NTOP
if (src != NULL)
{
ch_close_part(channel, PART_IN);
channel->CH_IN_FD = in;
-# if defined(UNIX)
+#if defined(UNIX)
// Do not end the job when all output channels are closed, wait until
// the job ended.
if (mch_isatty(in))
channel->ch_to_be_closed |= (1U << PART_IN);
-# endif
+#endif
}
if (out != INVALID_FD)
{
-# if defined(FEAT_GUI)
+#if defined(FEAT_GUI)
channel_gui_unregister_one(channel, PART_OUT);
-# endif
+#endif
ch_close_part(channel, PART_OUT);
channel->CH_OUT_FD = out;
channel->ch_to_be_closed |= (1U << PART_OUT);
-# if defined(FEAT_GUI)
+#if defined(FEAT_GUI)
channel_gui_register_one(channel, PART_OUT);
-# endif
+#endif
}
if (err != INVALID_FD)
{
-# if defined(FEAT_GUI)
+#if defined(FEAT_GUI)
channel_gui_unregister_one(channel, PART_ERR);
-# endif
+#endif
ch_close_part(channel, PART_ERR);
channel->CH_ERR_FD = err;
channel->ch_to_be_closed |= (1U << PART_ERR);
-# if defined(FEAT_GUI)
+#if defined(FEAT_GUI)
channel_gui_register_one(channel, PART_ERR);
-# endif
+#endif
}
}
if (timeout > 0)
ch_log(channel, "Waiting for up to %d msec", timeout);
-# ifdef MSWIN
+#ifdef MSWIN
if (fd != channel->CH_SOCK_FD)
{
DWORD nread;
}
#endif
-# if defined(FEAT_GUI)
+#if defined(FEAT_GUI)
/*
* Return TRUE when there is any channel with a keep_open flag.
*/
return TRUE;
return FALSE;
}
-# endif
+#endif
/*
* Set "channel"/"part" to non-blocking.
# endif
# ifdef FEAT_PROP_POPUP
&& !cts->cts_has_prop_with_text
-#endif
+# endif
)
{
#endif
if (*s == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1))
{
-# ifdef FEAT_VARTABS
+#ifdef FEAT_VARTABS
return tabstop_padding(col, wp->w_buffer->b_p_ts,
wp->w_buffer->b_p_vts_array);
-# else
+#else
n = wp->w_buffer->b_p_ts;
return (int)(n - (col % n));
-# endif
+#endif
}
n = ptr2cells(s);
// Add one cell for a double-width character in the last column of the
#if defined(FEAT_CLIENTSERVER)
-#ifdef FEAT_SOCKETSERVER
-# include <sys/socket.h>
-# include "sys/un.h"
-#endif
+# ifdef FEAT_SOCKETSERVER
+# include <sys/socket.h>
+# include "sys/un.h"
+# endif
static void cmdsrv_main(int *argc, char **argv, char_u *serverName_arg, char_u **serverStr);
static char_u *serverMakeName(char_u *arg, char *cmd);
funccal_entry_T funccal_entry;
int did_save_funccal = FALSE;
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
ch_log(NULL, "eval_client_expr_to_string(\"%s\")", expr);
-#endif
+# endif
// Evaluate the expression at the toplevel, don't use variables local to
// the calling function. Except when in debug mode.
serverInitMessaging();
# endif
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
// If servername is specified and we are using sockets, always init the
// sockt server. We may need to receive replies back to us. If --serverlist
// is passed, the socket server will be uninitialized before listing
TIME_MSG("initialize socket server");
made_name = TRUE;
}
-#endif
+# endif
/*
* When a command server argument was found, execute it. This may
# endif
vim_free(parmp->servername);
}
-#ifdef FEAT_X11
+# ifdef FEAT_X11
else
serverDelayedStartName = parmp->servername;
-#endif
+# endif
# endif
/*
int newArgC = 1,
Argc = *argc;
int argtype;
-#define ARGTYPE_OTHER 0
-#define ARGTYPE_EDIT 1
-#define ARGTYPE_EDIT_WAIT 2
-#define ARGTYPE_SEND 3
+# define ARGTYPE_OTHER 0
+# define ARGTYPE_EDIT 1
+# define ARGTYPE_EDIT_WAIT 2
+# define ARGTYPE_SEND 3
int silent = FALSE;
int tabs = FALSE;
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
char_u *receiver;
-#endif
+# endif
# ifdef MSWIN
HWND srv;
# elif defined(FEAT_X11)
Argc = i;
}
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
ret = socket_server_send(
sname, *serverStr, NULL, &receiver,
0, -1, silent);
-#endif
-#ifdef FEAT_X11
+# endif
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11)
{
if (xterm_dpy == NULL)
ret = serverSendToVim(xterm_dpy, sname, *serverStr,
NULL, &srv, 0, 0, 0, silent);
}
-#endif
-#ifdef MSWIN
+# endif
+# ifdef MSWIN
// Win32 always works?
ret = serverSendToVim(sname, *serverStr, NULL, &srv, 0, 0, silent);
# endif
if (clientserver_method == CLIENTSERVER_METHOD_X11
&& serverReadReply(xterm_dpy, srv, &p, TRUE, -1) < 0)
break;
-# endif
+# endif
if (p == NULL)
break;
# endif
if (didone)
{
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
socket_server_uninit();
-#endif
+# endif
display_errors(); // display any collected messages
exit(exiterr); // Mission accomplished - get out
}
return NULL;
}
cdp = vim_strsave_escaped_ext(cwd,
-#ifdef BACKSLASH_IN_FILENAME
+# ifdef BACKSLASH_IN_FILENAME
(char_u *)"", // rem_backslash() will tell what chars to escape
-#else
+# else
PATH_ESC_CHARS,
-#endif
+# endif
'\\', TRUE);
vim_free(cwd);
if (cdp == NULL)
// do it again in the Vim server. On MS-Windows only escape
// non-wildcard characters.
p = vim_strsave_escaped((char_u *)filev[i],
-#ifdef UNIX
+# ifdef UNIX
PATH_ESC_CHARS
-#else
+# else
(char_u *)" \t%#"
-#endif
+# endif
);
if (p == NULL)
{
// endif
// endif
ga_concat(&ga, (char_u *)":if !exists('+acd')||!&acd|if haslocaldir()|");
-#ifdef MSWIN
+# ifdef MSWIN
// in case :set shellslash is set, need to normalize the directory separators
// '/' is not valid in a filename so replacing '/' by '\\' should be safe
ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd()->tr('/','\\') ==# '");
-#else
+# else
ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd() ==# '");
-#endif
+# endif
ga_concat(&ga, cdp);
ga_concat(&ga, (char_u *)"'|cd -|endif|endif<CR>");
vim_free(cdp);
if (arg != NULL && *arg != NUL)
{
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
// If we are using a socket server, we want to preserve the original
// name if it is a path, else uppercase it if its just a generic name.
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
}
else
p = vim_strsave_up(arg);
-#else
+# else
p = vim_strsave_up(arg);
-#endif
+# endif
}
else
{
# ifdef MSWIN
HWND w;
# else
-#ifdef FEAT_X11
+# ifdef FEAT_X11
Window w;
-#endif
-#ifdef FEAT_SOCKETSERVER
+# endif
+# ifdef FEAT_SOCKETSERVER
char_u *client = NULL;
-#endif
+# endif
# endif
if (check_restricted() || check_secure())
# ifdef MSWIN
if (serverSendToVim(server_name, keys, &r, &w, expr, timeout, TRUE) < 0)
# else
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
if (socket_server_send(server_name, keys, &r, &client, expr,
timeout * 1000, TRUE) < 0)
goto fail;
-#endif
-#ifdef FEAT_X11
+# endif
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11)
if (serverSendToVim(X_DISPLAY, server_name, keys, &r, &w, expr, timeout,
0, TRUE) < 0)
goto fail;
-#endif
+# endif
# endif
-#if !defined(MSWIN)
+# if !defined(MSWIN)
if (FALSE)
{
fail:
-#else
+# else
{
-#endif
+# endif
if (r != NULL)
{
emsg((char *)r); // sending worked but evaluation failed
vim_free(r);
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
vim_free(client);
-#endif
+# endif
}
else
semsg(_(e_unable_to_send_to_str), server_name);
if (argvars[2].v_type != VAR_UNKNOWN)
{
dictitem_T v;
-#if defined(FEAT_SOCKETSERVER)
+# if defined(FEAT_SOCKETSERVER)
struct sockaddr_un addr;
char_u str[sizeof(addr.sun_path)];
-#else
+# else
char_u str[30];
-#endif
+# endif
char_u *idvar;
idvar = tv_get_string_chk(&argvars[2]);
if (idvar != NULL && *idvar != NUL)
{
str[0] = NUL;
-#ifdef MSWIN
+# ifdef MSWIN
sprintf((char *)str, PRINTF_HEX_LONG_U, (long_u)w);
-#else
-#ifdef FEAT_X11
+# else
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11)
sprintf((char *)str, PRINTF_HEX_LONG_U, (long_u)w);
-#endif
-#ifdef FEAT_SOCKETSERVER
+# endif
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
vim_snprintf((char *)str, sizeof(addr.sun_path),
"%s", client);
-#endif
-#endif
+# endif
+# endif
v.di_tv.v_type = VAR_STRING;
v.di_tv.vval.v_string = vim_strsave(str);
set_var(idvar, &v.di_tv, FALSE);
vim_free(v.di_tv.vval.v_string);
}
}
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
vim_free(client);
-#endif
+# endif
}
#endif
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_string_arg(argvars, 1) == FAIL
return;
remote_common(argvars, rettv, TRUE);
-#endif
+# endif
}
/*
void
f_remote_foreground(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return;
-# ifdef MSWIN
+# ifdef MSWIN
// On Win32 it's done in this application.
{
char_u *server_name = tv_get_string_chk(&argvars[0]);
if (server_name != NULL)
serverForeground(server_name);
}
-# else
+# else
// Send a foreground() expression to the server.
argvars[1].v_type = VAR_STRING;
argvars[1].vval.v_string = vim_strsave((char_u *)"foreground()");
rettv->vval.v_string = NULL;
remote_common(argvars, rettv, TRUE);
vim_free(argvars[1].vval.v_string);
+# endif
# endif
-#endif
}
void
f_remote_peek(typval_T *argvars UNUSED, typval_T *rettv)
{
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
dictitem_T v;
char_u *s = NULL;
-# ifdef MSWIN
+# ifdef MSWIN
long_u n = 0;
-# endif
+# endif
char_u *serverid;
rettv->vval.v_number = -1;
serverid = tv_get_string_chk(&argvars[0]);
if (serverid == NULL)
return; // type error; errmsg already given
-# ifdef MSWIN
+# ifdef MSWIN
sscanf((const char *)serverid, SCANF_HEX_LONG_U, &n);
if (n == 0)
rettv->vval.v_number = -1;
s = serverGetReply((HWND)n, FALSE, FALSE, FALSE, 0);
rettv->vval.v_number = (s != NULL);
}
-# else
-# ifdef FEAT_SOCKETSERVER
+# else
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
rettv->vval.v_number = socket_server_peek_reply(serverid, &s);
-# endif
-# ifdef FEAT_X11
+# endif
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11)
{
if (check_connection() == FAIL)
rettv->vval.v_number = serverPeekReply(X_DISPLAY,
serverStrToWin(serverid), &s);
}
+# endif
# endif
-# endif
if (argvars[1].v_type != VAR_UNKNOWN && rettv->vval.v_number > 0)
{
set_var(retvar, &v.di_tv, FALSE);
vim_free(v.di_tv.vval.v_string);
}
-#else
+# else
rettv->vval.v_number = -1;
-#endif
+# endif
}
void
{
char_u *r = NULL;
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
char_u *serverid;
if (in_vim9script()
if (serverid != NULL && !check_restricted() && !check_secure())
{
int timeout = 0;
-# ifdef MSWIN
+# ifdef MSWIN
// The server's HWND is encoded in the 'id' parameter
long_u n = 0;
-# endif
+# endif
if (argvars[1].v_type != VAR_UNKNOWN)
timeout = tv_get_number(&argvars[1]);
-# ifdef MSWIN
+# ifdef MSWIN
sscanf((char *)serverid, SCANF_HEX_LONG_U, &n);
if (n != 0)
r = serverGetReply((HWND)n, FALSE, TRUE, TRUE, timeout);
if (r == NULL)
emsg(_(e_unable_to_read_server_reply));
-# else
-# ifdef FEAT_SOCKETSERVER
+# else
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET &&
socket_server_read_reply(serverid, &r, timeout * 1000) == FAIL)
emsg(_(e_unable_to_read_server_reply));
-# endif
-# ifdef FEAT_X11
+# endif
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11 &&
(check_connection() == FAIL
|| serverReadReply(X_DISPLAY, serverStrToWin(serverid),
&r, FALSE, timeout) < 0))
emsg(_(e_unable_to_read_server_reply));
+# endif
# endif
-# endif
}
-#endif
+# endif
rettv->v_type = VAR_STRING;
rettv->vval.v_string = r;
}
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_string_arg(argvars, 1) == FAIL
return;
remote_common(argvars, rettv, FALSE);
-#endif
+# endif
}
/*
void
f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
if (check_for_nonempty_string_arg(argvars, 0) == FAIL)
return;
}
char_u *server = tv_get_string_chk(&argvars[0]);
-# ifdef MSWIN
+# ifdef MSWIN
serverSetName(server);
-# else
-# ifdef FEAT_SOCKETSERVER
+# else
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
socket_server_init(server);
-# endif
-# ifdef FEAT_X11
+# endif
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11 &&
check_connection() == OK)
serverRegisterName(X_DISPLAY, server);
-# endif
-# endif
+# endif
+# endif
-#else
+# else
emsg(_(e_clientserver_feature_not_available));
-#endif
+# endif
}
void
f_server2client(typval_T *argvars UNUSED, typval_T *rettv)
{
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
char_u buf[NUMBUFLEN];
char_u *server;
char_u *reply;
if (server == NULL || reply == NULL)
return;
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET &&
socket_server_send_reply(server, reply) == FAIL)
goto fail;
-#endif
+# endif
-#ifdef FEAT_X11
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11 &&
check_connection() == FAIL)
return;
if (clientserver_method == CLIENTSERVER_METHOD_X11 &&
serverSendReply(server, reply) < 0)
-#endif
-#ifdef MSWIN
+# endif
+# ifdef MSWIN
if (serverSendReply(server, reply) < 0)
-#endif
-#if defined(FEAT_SOCKETSERVER) && !defined(FEAT_X11) && !defined(MSWIN)
+# endif
+# if defined(FEAT_SOCKETSERVER) && !defined(FEAT_X11) && !defined(MSWIN)
if (FALSE)
-#endif
+# endif
{
-#ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
fail:
-#endif
+# endif
emsg(_(e_unable_to_send_to_client));
return;
}
rettv->vval.v_number = 0;
-#else
+# else
rettv->vval.v_number = -1;
-#endif
+# endif
}
void
{
char_u *r = NULL;
-#ifdef FEAT_CLIENTSERVER
-# ifdef MSWIN
+# ifdef FEAT_CLIENTSERVER
+# ifdef MSWIN
r = serverGetVimNames();
-# else
-# ifdef FEAT_SOCKETSERVER
+# else
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
r = socket_server_list_sockets();
-# endif
-# ifdef FEAT_X11
+# endif
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11)
{
make_connection();
if (X_DISPLAY != NULL)
r = serverGetVimNames(X_DISPLAY);
}
+# endif
# endif
# endif
-#endif
rettv->v_type = VAR_STRING;
rettv->vval.v_string = r;
}
#if defined(FEAT_CLIPBOARD)
-#if defined(FEAT_WAYLAND_CLIPBOARD)
+# if defined(FEAT_WAYLAND_CLIPBOARD)
-# include "wayland.h"
+# include "wayland.h"
-# ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
// Structures used for focus stealing
typedef struct {
bool got_focus;
} clip_wl_fs_surface_T; // fs = focus steal
-# endif // FEAT_WAYLAND_CLIPBOARD_FS
+# endif // FEAT_WAYLAND_CLIPBOARD_FS
// Represents either the regular or primary selection
typedef struct {
// else NULL if we don't.
vwl_data_offer_T *offer; // Current offer for the selection
-# ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
bool requires_focus; // If focus needs to be given to us to
// work
-# endif
+# endif
bool own_success; // Used by clip_wl_own_selection()
bool available; // If selection is ready to serve/use
typedef struct {
vwl_seat_T *seat;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
clip_wl_buffer_store_T *fs_buffer;
-#endif
+# endif
clip_wl_selection_T regular;
clip_wl_selection_T primary;
static void clip_wl_lose_selection(Clipboard_T *cbd);
static void clip_wl_set_selection(Clipboard_T *cbd);
-# if defined(USE_SYSTEM)
+# if defined(USE_SYSTEM)
static bool clip_wl_owner_exists(Clipboard_T *cbd);
-# endif
+# endif
-#endif // FEAT_WAYLAND_CLIPBOARD
+# endif // FEAT_WAYLAND_CLIPBOARD
/*
* Selection stuff using Visual mode, for cutting and pasting text to other
static int
clip_gen_own_selection(Clipboard_T *cbd)
{
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
-# ifdef FEAT_GUI
+# if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
+# ifdef FEAT_GUI
if (gui.in_use)
return clip_mch_own_selection(cbd);
else
-# endif
+# endif
{
if (clipmethod == CLIPMETHOD_WAYLAND)
{
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
return clip_wl_own_selection(cbd);
-#endif
+# endif
}
else if (clipmethod == CLIPMETHOD_X11)
{
-#ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
return clip_xterm_own_selection(cbd);
-#endif
+# endif
}
}
return FAIL;
-#else
+# else
return clip_mch_own_selection(cbd);
-#endif
+# endif
}
void
* Also want to check somehow that we are reading from the keyboard rather
* than a mapping etc.
*/
-#if defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)
+# if defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)
// Always own the selection, we might have lost it without being
// notified, e.g. during a ":sh" command.
if (cbd->available)
redraw_curbuf_later(UPD_INVERTED_ALL);
}
}
-#else
+# else
// Only own the clipboard when we didn't own it yet.
if (!cbd->owned && cbd->available)
cbd->owned = (clip_gen_own_selection(cbd) == OK);
-#endif
+# endif
}
static void
clip_gen_lose_selection(Clipboard_T *cbd)
{
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
-# ifdef FEAT_GUI
+# if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
+# ifdef FEAT_GUI
if (gui.in_use)
clip_mch_lose_selection(cbd);
else
-# endif
+# endif
{
if (clipmethod == CLIPMETHOD_WAYLAND)
{
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
clip_wl_lose_selection(cbd);
-#endif
+# endif
}
else if (clipmethod == CLIPMETHOD_X11)
{
-#ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
clip_xterm_lose_selection(cbd);
-#endif
+# endif
}
}
-#else
+# else
clip_mch_lose_selection(cbd);
-#endif
+# endif
}
void
clip_lose_selection(Clipboard_T *cbd)
{
-#ifdef FEAT_X11
+# ifdef FEAT_X11
int was_owned = cbd->owned;
-#endif
+# endif
int visual_selection = FALSE;
if (cbd == &clip_star || cbd == &clip_plus)
if (visual_selection)
clip_clear_selection(cbd);
clip_gen_lose_selection(cbd);
-#ifdef FEAT_X11
+# ifdef FEAT_X11
if (visual_selection)
{
// May have to show a different kind of highlighting for the selected
out_flush_cursor(TRUE, FALSE);
}
}
-#endif
+# endif
}
static void
clip_isautosel_star(void)
{
return (
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
gui.in_use ? (vim_strchr(p_go, GO_ASEL) != NULL) :
-#endif
+# endif
clip_autoselect_star);
}
clip_isautosel_plus(void)
{
return (
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
gui.in_use ? (vim_strchr(p_go, GO_ASELPLUS) != NULL) :
-#endif
+# endif
clip_autoselect_plus);
}
}
// "how" flags for clip_invert_area()
-#define CLIP_CLEAR 1
-#define CLIP_SET 2
-#define CLIP_TOGGLE 3
+# define CLIP_CLEAR 1
+# define CLIP_SET 2
+# define CLIP_TOGGLE 3
/*
* Invert or un-invert a rectangle of the screen.
int height = height_arg;
int width = width_arg;
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
// this goes on top of all popup windows
screen_zindex = CLIP_ZINDEX;
}
if (height > cbd->max_row - row + 1)
height = cbd->max_row - row + 1;
-#endif
-#ifdef FEAT_GUI
+# endif
+# ifdef FEAT_GUI
if (gui.in_use)
gui_mch_invert_rectangle(row, col, height, width);
else
-#endif
+# endif
screen_draw_rectangle(row, col, height, width, invert);
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
screen_zindex = 0;
-#endif
+# endif
}
/*
int invert = FALSE;
int max_col;
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
max_col = cbd->max_col - 1;
-#else
+# else
max_col = Columns - 1;
-#endif
+# endif
if (how == CLIP_SET)
invert = TRUE;
* Find the starting and ending positions of the word at the given row and
* column. Only white-separated words are recognized here.
*/
-#define CHAR_CLASS(c) (c <= ' ' ? ' ' : vim_iswordc(c))
+# define CHAR_CLASS(c) (c <= ' ' ? ' ' : vim_iswordc(c))
static void
clip_get_word_boundaries(Clipboard_T *cb, int row, int col)
if (row >= screen_Rows || ScreenLines == NULL)
return 0;
for (i =
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
cbd->max_col;
-#else
+# else
screen_Columns;
-#endif
+# endif
i > 0; i--)
if (ScreenLines[LineOffset[row] + i - 1] != ' ')
break;
clip_start_selection(int col, int row, int repeated_click)
{
Clipboard_T *cb = &clip_star;
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
win_T *wp;
int row_cp = row;
int col_cp = col;
&& popup_is_in_scrollbar(wp, row_cp, col_cp))
// click or double click in scrollbar does not start a selection
return;
-#endif
+# endif
if (cb->state == SELECT_DONE)
clip_clear_selection(cb);
cb->end = cb->start;
cb->origin_row = (short_u)cb->start.lnum;
cb->state = SELECT_IN_PROGRESS;
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
if (wp != NULL && WIN_IS_POPUP(wp))
{
// Click in a popup window restricts selection to that window,
cb->min_row = 0;
cb->max_row = screen_Rows;
}
-#endif
+# endif
if (repeated_click)
{
else
cb->mode = SELECT_MODE_CHAR;
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
// clear the cursor until the selection is made
if (gui.in_use)
gui_undraw_cursor();
-#endif
+# endif
switch (cb->mode)
{
cb->prev = cb->start;
-#ifdef DEBUG_SELECTION
+# ifdef DEBUG_SELECTION
printf("Selection started at (%ld,%d)\n", cb->start.lnum, cb->start.col);
-#endif
+# endif
}
/*
// Check to make sure we have something selected
if (cb->start.lnum == cb->end.lnum && cb->start.col == cb->end.col)
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.in_use)
gui_update_cursor(FALSE, FALSE);
-#endif
+# endif
cb->state = SELECT_CLEARED;
return;
}
-#ifdef DEBUG_SELECTION
+# ifdef DEBUG_SELECTION
printf("Selection ended: (%ld,%d) to (%ld,%d)\n", cb->start.lnum,
cb->start.col, cb->end.lnum, cb->end.col);
-#endif
+# endif
if (clip_isautosel_star() || clip_isautosel_plus()
|| (
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
gui.in_use ? (vim_strchr(p_go, GO_ASELML) != NULL) :
-#endif
+# endif
clip_autoselectml))
clip_copy_modeless_selection(FALSE);
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.in_use)
gui_update_cursor(FALSE, FALSE);
-#endif
+# endif
cb->state = SELECT_DONE;
return;
// set state, for when using the right mouse button
cb->state = SELECT_IN_PROGRESS;
-#ifdef DEBUG_SELECTION
+# ifdef DEBUG_SELECTION
printf("Selection extending to (%d,%d)\n", row, col);
-#endif
+# endif
if (repeated_click && ++cb->mode > SELECT_MODE_LINE)
cb->mode = SELECT_MODE_CHAR;
cb->prev.lnum = row;
cb->prev.col = col;
-#ifdef DEBUG_SELECTION
+# ifdef DEBUG_SELECTION
printf("Selection is: (%ld,%d) to (%ld,%d)\n", cb->start.lnum,
cb->start.col, cb->end.lnum, cb->end.col);
-#endif
+# endif
}
# if defined(FEAT_GUI)
{
row = col1; col1 = col2; col2 = row;
}
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
if (col1 < clip_star.min_col)
col1 = clip_star.min_col;
if (col2 > clip_star.max_col)
row1 = clip_star.min_row;
if (row2 > clip_star.max_row)
row2 = clip_star.max_row;
-#endif
+# endif
// correct starting point for being on right half of double-wide char
p = ScreenLines + LineOffset[row1];
if (enc_dbcs != 0)
if (row == row1)
start_col = col1;
else
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
start_col = clip_star.min_col;
-#else
+# else
start_col = 0;
-#endif
+# endif
if (row == row2)
end_col = col2;
else
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
end_col = clip_star.max_col;
-#else
+# else
end_col = Columns;
-#endif
+# endif
line_end_col = clip_get_line_end(&clip_star, row);
// See if we need to nuke some trailing whitespace
if (end_col >=
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
clip_star.max_col
-#else
+# else
Columns
-#endif
+# endif
&& (row < row2 || end_col > line_end_col))
{
// Get rid of trailing whitespace
// Make the register contents available to the outside world.
clip_gen_set_selection(cbd);
-#ifdef FEAT_X11
+# ifdef FEAT_X11
if (both)
{
Clipboard_T *other = cbd == &clip_star ? &clip_plus : &clip_star;
clip_yank_selection(MCHAR, buffer, (long)(bufp - buffer), other);
clip_gen_set_selection(other);
}
-#endif
+# endif
vim_free(buffer);
}
return;
}
}
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
-# ifdef FEAT_GUI
+# if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
+# ifdef FEAT_GUI
if (gui.in_use)
clip_mch_set_selection(cbd);
else
-# endif
+# endif
{
if (clipmethod == CLIPMETHOD_WAYLAND)
{
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
clip_wl_set_selection(cbd);
-#endif
+# endif
}
else if (clipmethod == CLIPMETHOD_X11)
{
-#ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
clip_xterm_set_selection(cbd);
-#endif
+# endif
}
}
-#else
+# else
clip_mch_set_selection(cbd);
-#endif
+# endif
}
static void
clip_gen_request_selection(Clipboard_T *cbd)
{
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
-# ifdef FEAT_GUI
+# if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
+# ifdef FEAT_GUI
if (gui.in_use)
clip_mch_request_selection(cbd);
else
-# endif
+# endif
{
if (clipmethod == CLIPMETHOD_WAYLAND)
{
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
clip_wl_request_selection(cbd);
-#endif
+# endif
}
else if (clipmethod == CLIPMETHOD_X11)
{
-#ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
clip_xterm_request_selection(cbd);
-#endif
+# endif
}
}
-#else
+# else
clip_mch_request_selection(cbd);
-#endif
+# endif
}
-#if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) && defined(USE_SYSTEM)) \
-
+# if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) && defined(USE_SYSTEM))
static int
clip_x11_owner_exists(Clipboard_T *cbd)
{
return XGetSelectionOwner(X_DISPLAY, cbd->sel_atom) != None;
}
-#endif
+# endif
-#if (defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)) \
+# if (defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)) \
&& defined(USE_SYSTEM)
int
clip_gen_owner_exists(Clipboard_T *cbd UNUSED)
{
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
-# ifdef FEAT_GUI_GTK
+# if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
+# ifdef FEAT_GUI_GTK
if (gui.in_use)
return clip_gtk_owner_exists(cbd);
else
-# endif
+# endif
{
if (clipmethod == CLIPMETHOD_WAYLAND)
{
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
return clip_wl_owner_exists(cbd);
-#endif
+# endif
}
else if (clipmethod == CLIPMETHOD_X11)
{
-#ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
return clip_x11_owner_exists(cbd);
-#endif
+# endif
}
else
return FALSE;
}
-#else
+# else
return TRUE;
-#endif
+# endif
}
-#endif
+# endif
/*
* Stuff for the X clipboard. Shared between VMS and Unix.
*/
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11)
-# include <X11/Xatom.h>
-# include <X11/Intrinsic.h>
+# if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11)
+# include <X11/Xatom.h>
+# include <X11/Intrinsic.h>
/*
* Open the application context (if it hasn't been opened yet).
/*
* Property callback to get a timestamp for XtOwnSelection.
*/
-# if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
+# if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
static void
clip_x11_timestamp_cb(
Widget w,
XtAddEventHandler(w, PropertyChangeMask, False,
/*(XtEventHandler)*/clip_x11_timestamp_cb, (XtPointer)NULL);
}
-# endif
+# endif
static void
clip_x11_request_selection_cb(
text_prop.encoding = *type;
text_prop.format = *format;
text_prop.nitems = len;
-#if defined(X_HAVE_UTF8_STRING)
+# if defined(X_HAVE_UTF8_STRING)
if (*type == utf8_atom)
status = Xutf8TextPropertyToTextList(X_DISPLAY, &text_prop,
&text_list, &n_text);
else
-#endif
+# endif
status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
&text_list, &n_text);
if (status != Success || n_text < 1)
default: type = XA_STRING;
}
if (type == utf8_atom
-# if defined(X_HAVE_UTF8_STRING)
+# if defined(X_HAVE_UTF8_STRING)
&& !enc_utf8
-# endif
+# endif
)
// Only request utf-8 when 'encoding' is utf8 and
// Xutf8TextPropertyToTextList is available.
// event. When in the console we don't get events (the terminal gets
// them), Get the time by a zero-length append, clip_x11_timestamp_cb will
// be called with the current timestamp.
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.in_use)
{
if (XtOwnSelection(myShell, cbd->sel_atom,
return FAIL;
}
else
-#endif
+# endif
{
if (!XChangeProperty(XtDisplay(myShell), XtWindow(myShell),
cbd->sel_atom, timestamp_atom, 32, PropModeAppend, NULL, 0))
{
}
-#endif
+# endif
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
+# if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
/*
* Get the contents of the X CUT_BUFFER0 and put it in "cbd".
*/
}
}
}
-#endif
+# endif
/*
* SELECTION / PRIMARY ('*')
* 'permanent' of the two), otherwise the PRIMARY one.
* For now, use a hard-coded sanity limit of 1Mb of data.
*/
-#if defined(FEAT_X11) && defined(FEAT_CLIPBOARD)
+# if defined(FEAT_X11) && defined(FEAT_CLIPBOARD)
void
x11_export_final_selection(void)
{
long_u len = 0;
int motion_type = -1;
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.in_use)
dpy = X_DISPLAY;
else
-# endif
-# ifdef FEAT_XCLIPBOARD
+# endif
+# ifdef FEAT_XCLIPBOARD
dpy = xterm_dpy;
-# else
+# else
return;
-# endif
+# endif
// Get selection to export
if (clip_plus.owned)
vim_free(str);
}
-#endif
+# endif
void
clip_free_selection(Clipboard_T *cbd)
}
}
-#if defined(FEAT_WAYLAND_CLIPBOARD)
+# if defined(FEAT_WAYLAND_CLIPBOARD)
static clip_wl_selection_T *
clip_wl_get_selection(wayland_selection_T sel)
return WAYLAND_SELECTION_NONE;
}
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
/*
* If globals required for focus stealing method are available.
*/
void *user_data)
{
clip_wl_fs_surface_T *store;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
elapsed_T start_tv;
-#endif
+# endif
if (wayland_ct->gobjects.wl_compositor == NULL
|| wayland_ct->gobjects.xdg_wm_base == NULL
// Dispatch events until we receive the enter event. Add a max delay of
// 'p_wtm' when waiting for it (may be longer depending on how long we poll
// when dispatching events)
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
ELAPSED_INIT(start_tv);
-#endif
+# endif
while (vwl_connection_dispatch(wayland_ct) >= 0)
{
if (store->got_focus)
break;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
if (ELAPSED_FUNC(start_tv) >= p_wtm)
goto fail;
-#endif
+# endif
}
early_exit:
clip_wl_destroy_fs_surface(store);
return FAIL;
}
-#endif // FEAT_WAYLAND_CLIPBOARD_FS
+# endif // FEAT_WAYLAND_CLIPBOARD_FS
static bool
wl_data_offer_listener_event_offer(
clip_wl.primary.device = clip_wl.regular.device;
}
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
if (clip_wl.regular.available
&& clip_wl.regular.manager->protocol == VWL_DATA_PROTOCOL_CORE
&& clip_wl_focus_stealing_available())
// Initialize buffer to use for focus stealing
clip_wl.fs_buffer = clip_wl_init_buffer_store(1, 1);
}
-#endif
+# endif
if (!clip_wl.regular.available && !clip_wl.primary.available)
return FAIL;
clip_lose_selection(&clip_plus);
}
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
clip_wl_destroy_buffer_store(clip_wl.fs_buffer);
-#endif
+# endif
// Don't want to double free
if (clip_wl.regular.manager != clip_wl.primary.manager)
garray_T buf;
int motion_type = MAUTO;
ssize_t r = 0;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
struct pollfd pfd;
pfd.fd = fd;
pfd.events = POLLIN;
-#else
+# else
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
-#endif
+# endif
// Make pipe (read end) non-blocking
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == -1)
start = buf.ga_data;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
while (poll(&pfd, 1, p_wtm) > 0)
-#else
+# else
while (tv.tv_sec = p_wtm / 1000, tv.tv_usec = (p_wtm % 1000) * 1000,
select(fd + 1, &rfds, NULL, NULL, &tv) > 0)
-#endif
+# endif
{
r = read(fd, start, buf.ga_maxlen - 1 - buf.ga_len);
if (!sel->available)
goto clear;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
if (sel->requires_focus)
{
// We don't care about the on_focus callback since once we gain
goto clear;
}
else
-#endif
+# endif
{
// Dispatch any events that still queued up before checking for a data
// offer.
int offset = 0;
bool is_vim, is_vimenc;
size_t total = 0;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
struct pollfd pfd;
pfd.fd = fd;
pfd.events = POLLOUT;
-#else
+# else
fd_set wfds;
struct timeval tv;
FD_ZERO(&wfds);
FD_SET(fd, &wfds);
-#endif
+# endif
// Check if we actually have mime type
for (int i = 0; i < (int)ARRAY_LENGTH(supported_mimes); i++)
while (total < (size_t)length &&
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
poll(&pfd, 1, p_wtm) > 0)
-#else
+# else
((tv.tv_sec = p_wtm / 1000, tv.tv_usec = (p_wtm % 1000) * 1000),
select(fd + 1, NULL, &wfds, NULL, &tv) > 0))
-#endif
+# endif
{
ssize_t w = write(fd, string + total, length - total);
vwl_data_source_offer(sel->source, supported_mimes[i]);
sel->own_success = false;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
if (sel->requires_focus)
{
if (clip_wl_init_fs_surface(clip_wl.seat, clip_wl.fs_buffer,
goto fail;
}
else
-#endif
+# endif
clip_wl_do_set_selection(sel, 0);
if (!sel->own_success)
{
}
-#if defined(USE_SYSTEM)
+# if defined(USE_SYSTEM)
/*
* Return true if we own the selection corresponding to cbd or another client
* does.
return sel->available && (sel->source != NULL || sel->offer != NULL);
}
-#endif
+# endif
-#endif // FEAT_WAYLAND_CLIPBOARD
+# endif // FEAT_WAYLAND_CLIPBOARD
#endif // FEAT_CLIPBOARD
if (STRCMP(buf, "wayland") == 0)
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (!gui.in_use)
-#endif
+# endif
{
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
if (clip_wl.regular.available || clip_wl.primary.available)
method = CLIPMETHOD_WAYLAND;
-#endif
+# endif
}
}
else if (STRCMP(buf, "x11") == 0)
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (!gui.in_use)
-#endif
+# endif
{
-#ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
// x_IOerror_handler() in os_unix.c should set xterm_dpy to NULL if
// we lost connection to the X server.
if (xterm_dpy != NULL)
xterm_update();
method = CLIPMETHOD_X11;
}
-#endif
+# endif
}
}
else
{
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
// Check if name matches a clipboard provider
int r = clip_provider_is_available(buf);
}
}
else if (r == -1)
-#endif
+# endif
{
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
fail:
-#endif
+# endif
ret = CLIPMETHOD_FAIL;
goto exit;
}
case CLIPMETHOD_X11:
return (char_u *)"x11";
case CLIPMETHOD_PROVIDER:
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
return clip_provider;
-#endif
+# endif
default:
return (char_u *)"none";
}
// If GUI is running or we are not on a system with Wayland or X11, then always
// return CLIPMETHOD_NONE. System or GUI clipboard handling always overrides.
// This is unless a provider is being used.
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
-# if defined(FEAT_GUI)
+# if defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)
+# if defined(FEAT_GUI)
if (method != CLIPMETHOD_PROVIDER && gui.in_use)
{
-# ifdef FEAT_WAYLAND
+# ifdef FEAT_WAYLAND
// We only interact with Wayland for the clipboard, we can just deinit
// everything.
wayland_uninit_connection();
-# endif
+# endif
method = CLIPMETHOD_NONE;
goto lose_sel_exit;
}
-# endif
-#else
+# endif
+# else
// If on a system like windows or macos, then clipmethod is irrelevant, we
// use their way of accessing the clipboard. This is unless we are using the
// clipboard provider
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
if (method != CLIPMETHOD_PROVIDER)
-#endif
+# endif
{
method = CLIPMETHOD_NONE;
goto exit;
}
-#endif
+# endif
-#ifdef FEAT_CLIPBOARD
+# ifdef FEAT_CLIPBOARD
// Deinitialize clipboard if there is no way to access clipboard
if (method == CLIPMETHOD_NONE)
clip_init(FALSE);
// Disown clipboard if we are switching to a new method
else if (clipmethod != CLIPMETHOD_NONE && method != clipmethod)
{
-#if (defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)) \
+# if (defined(FEAT_XCLIPBOARD) || defined(FEAT_WAYLAND_CLIPBOARD)) \
&& defined(FEAT_GUI)
lose_sel_exit:
-#endif
+# endif
if (clip_star.owned)
clip_lose_selection(&clip_star);
if (clip_plus.owned)
clip_lose_selection(&clip_plus);
-#if defined(FEAT_GUI)
+# if defined(FEAT_GUI)
if (!gui.in_use)
-#endif
+# endif
{
clip_init(TRUE);
did_warn_clipboard = false;
}
}
-#endif // FEAT_CLIPBOARD
+# endif // FEAT_CLIPBOARD
-#if !defined(FEAT_XCLIPBOARD) && !defined(FEAT_WAYLAND_CLIPBOARD)
+# if !defined(FEAT_XCLIPBOARD) && !defined(FEAT_WAYLAND_CLIPBOARD)
exit:
-#endif
+# endif
clipmethod = method;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
set_vim_var_string(VV_CLIPMETHOD, (char_u*)clipmethod_to_str(method), -1);
-#endif
+# endif
return NULL;
}
void
adjust_clip_reg(int *rp)
{
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
if (clipmethod == CLIPMETHOD_PROVIDER)
{
if (*rp == 0 && clip_unnamed != 0)
*rp = ((clip_unnamed & CLIP_UNNAMED_PLUS)) ? '+' : '*';
return;
}
-#endif
-#ifdef FEAT_CLIPBOARD
+# endif
+# ifdef FEAT_CLIPBOARD
// If no reg. specified, and "unnamed" or "unnamedplus" is in 'clipboard',
// use '*' or '+' reg, respectively. "unnamedplus" prevails.
if (*rp == 0 && (clip_unnamed != 0 || clip_unnamed_saved != 0))
msg_warn_missing_clipboard();
*rp = 0;
}
-#endif
+# endif
}
/*
did_set_clipboard(optset_T *args UNUSED)
{
int new_unnamed = 0;
-#ifdef FEAT_CLIPBOARD
+# ifdef FEAT_CLIPBOARD
int new_autoselect_star = FALSE;
int new_autoselect_plus = FALSE;
int new_autoselectml = FALSE;
int new_html = FALSE;
-#endif
+# endif
regprog_T *new_exclude_prog = NULL;
char *errmsg = NULL;
char_u *p;
new_unnamed |= CLIP_UNNAMED_PLUS;
p += 11;
}
-#ifdef FEAT_CLIPBOARD
+# ifdef FEAT_CLIPBOARD
else if (STRNCMP(p, "autoselect", 10) == 0
&& (p[10] == ',' || p[10] == NUL))
{
errmsg = e_invalid_argument;
break;
}
-#endif
+# endif
else
{
errmsg = e_invalid_argument;
}
if (errmsg == NULL)
{
-#ifdef FEAT_CLIPBOARD
+# ifdef FEAT_CLIPBOARD
if (global_busy)
// clip_unnamed will be reset to clip_unnamed_saved
// at end_global_changes
clip_unnamed_saved = new_unnamed;
else
-#endif
+# endif
clip_unnamed = new_unnamed;
-#ifdef FEAT_CLIPBOARD
+# ifdef FEAT_CLIPBOARD
clip_autoselect_star = new_autoselect_star;
clip_autoselect_plus = new_autoselect_plus;
clip_autoselectml = new_autoselectml;
clip_html = new_html;
vim_regfree(clip_exclude_prog);
clip_exclude_prog = new_exclude_prog;
-#endif
-#ifdef FEAT_GUI_GTK
+# endif
+# ifdef FEAT_GUI_GTK
if (gui.in_use)
{
gui_gtk_set_selection_targets((GdkAtom)GDK_SELECTION_PRIMARY);
gui_gtk_set_selection_targets((GdkAtom)clip_plus.gtk_sel_atom);
gui_gtk_set_dnd_targets();
}
-#endif
+# endif
}
else
vim_regfree(new_exclude_prog);
#if defined(MSWIN)
// Using the platform's path separator (\) makes vim incorrectly
// treat it as an escape character, use '/' instead.
- #define TMP_PATHSEPSTR "/"
+# define TMP_PATHSEPSTR "/"
#else
- #define TMP_PATHSEPSTR PATHSEPSTR
+# define TMP_PATHSEPSTR PATHSEPSTR
#endif
// Loop over all entries in {path}.
static int crypt_sodium_init_(cryptstate_T *state, char_u *key, crypt_arg_T *arg);
static long crypt_sodium_buffer_decode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
static long crypt_sodium_buffer_encode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
-# if defined(FEAT_SODIUM)
+#if defined(FEAT_SODIUM)
static void crypt_long_long_to_char(long long n, char_u *s);
static void crypt_int_to_char(int n, char_u *s);
static long long crypt_char_to_long_long(char_u *s);
char_u *key UNUSED,
crypt_arg_T *arg UNUSED)
{
-# ifdef FEAT_SODIUM
+#ifdef FEAT_SODIUM
// crypto_box_SEEDBYTES == crypto_secretstream_xchacha20poly1305_KEYBYTES
unsigned char dkey[crypto_box_SEEDBYTES]; // 32
sodium_state_T *sd_state;
memlimit = crypto_pwhash_MEMLIMIT_INTERACTIVE;
alg = crypto_pwhash_ALG_DEFAULT;
-#if 0
+# if 0
// For testing
if (state->method_nr == CRYPT_M_SOD2)
{
opslimit = crypto_pwhash_OPSLIMIT_MODERATE;
memlimit = crypto_pwhash_MEMLIMIT_MODERATE;
}
-#endif
+# endif
// derive a key from the password
if (crypto_pwhash(dkey, sizeof(dkey), (const char *)key, STRLEN(key),
alg = crypt_char_to_int(p);
p += sizeof(alg);
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
crypt_sodium_report_hash_params(opslimit,
crypto_pwhash_OPSLIMIT_INTERACTIVE,
(size_t)memlimit, crypto_pwhash_MEMLIMIT_INTERACTIVE,
alg, crypto_pwhash_ALG_DEFAULT);
-#endif
+# endif
if (crypto_pwhash(dkey, sizeof(dkey), (const char *)key, STRLEN(key),
arg->cat_salt, opslimit, (size_t)memlimit, alg) != 0)
state->method_state = sd_state;
return OK;
-# else
+#else
emsg(_(e_libsodium_not_built_in));
return FAIL;
-# endif
+#endif
}
/*
char_u **buf_out UNUSED,
int last UNUSED)
{
-# ifdef FEAT_SODIUM
+#ifdef FEAT_SODIUM
// crypto_box_SEEDBYTES == crypto_secretstream_xchacha20poly1305_KEYBYTES
unsigned long long out_len;
char_u *ptr;
sod_st->count++;
return out_len + (first
? crypto_secretstream_xchacha20poly1305_HEADERBYTES : 0);
-# else
+#else
return -1;
-# endif
+#endif
}
/*
char_u **buf_out UNUSED,
int last UNUSED)
{
-# ifdef FEAT_SODIUM
+#ifdef FEAT_SODIUM
// crypto_box_SEEDBYTES == crypto_secretstream_xchacha20poly1305_KEYBYTES
sodium_state_T *sod_st = state->method_state;
unsigned char tag;
if (tag == crypto_secretstream_xchacha20poly1305_TAG_FINAL && !last)
emsg(_(e_libsodium_decryption_failed_premature));
return (long) out_len;
-# else
+#else
return -1;
-# endif
+#endif
}
-# if defined(FEAT_SODIUM)
+#if defined(FEAT_SODIUM)
void
crypt_sodium_lock_key(char_u *key)
{
return randombytes_random();
}
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
static void
crypt_sodium_report_hash_params(
unsigned long long opslimit,
verbose_leave();
}
}
-#endif
+# endif
static void
crypt_long_long_to_char(long long n, char_u *s)
}
return retval;
}
-# endif
+#endif
#endif // FEAT_CRYPT
static garray_T prof_ga = {0, 0, sizeof(struct debuggy), 4, NULL};
// Profiling caches results of regexp lookups for function/script name.
-#define N_PROF_HTAB 2
+# define N_PROF_HTAB 2
static hashtab_T prof_cache[N_PROF_HTAB];
-#define PROF_HTAB_FUNCS 0
-#define PROF_HTAB_FILES 1
+# define PROF_HTAB_FUNCS 0
+# define PROF_HTAB_FILES 1
static int prof_cache_initialized;
typedef struct profentry_S
{
char pen_flags; // cache data booleans: profiling, forceit
char_u pen_name[1]; // actually longer
} profentry_T;
-#define PEN_FLAG_PROFILING 1
-#define PEN_FLAG_FORCEIT 2
-#define PEN_SET_PROFILING(pe) ((pe)->pen_flags |= PEN_FLAG_PROFILING)
-#define PEN_SET_FORCEIT(pe) ((pe)->pen_flags |= PEN_FLAG_FORCEIT)
-#define PEN_IS_PROFILING(pe) (((pe)->pen_flags & PEN_FLAG_PROFILING) != 0)
-#define PEN_IS_FORCEIT(pe) (((pe)->pen_flags & PEN_FLAG_FORCEIT) != 0)
+# define PEN_FLAG_PROFILING 1
+# define PEN_FLAG_FORCEIT 2
+# define PEN_SET_PROFILING(pe) ((pe)->pen_flags |= PEN_FLAG_PROFILING)
+# define PEN_SET_FORCEIT(pe) ((pe)->pen_flags |= PEN_FLAG_FORCEIT)
+# define PEN_IS_PROFILING(pe) (((pe)->pen_flags & PEN_FLAG_PROFILING) != 0)
+# define PEN_IS_FORCEIT(pe) (((pe)->pen_flags & PEN_FLAG_FORCEIT) != 0)
-#define PE2HIKEY(pe) ((pe)->pen_name)
-#define HIKEY2PE(p) ((profentry_T *)((p) - (offsetof(profentry_T, pen_name))))
-#define HI2PE(hi) HIKEY2PE((hi)->hi_key)
+# define PE2HIKEY(pe) ((pe)->pen_name)
+# define HIKEY2PE(p) ((profentry_T *)((p) - (offsetof(profentry_T, pen_name))))
+# define HI2PE(hi) HIKEY2PE((hi)->hi_key)
static void prof_clear_cache(void);
-#define PROF_CLEAR_CACHE(gap) do {if ((gap) == &prof_ga) prof_clear_cache();} while (0)
+# define PROF_CLEAR_CACHE(gap) do {if ((gap) == &prof_ga) prof_clear_cache();} while (0)
// Can enable to get some info about profile caching
// #define PROF_CACHE_LOG
#else
-#define PROF_CLEAR_CACHE(gap) do {} while (0)
+# define PROF_CLEAR_CACHE(gap) do {} while (0)
#endif
#define DBG_FUNC 1
#define DBG_FILE 2
}
#if defined(FEAT_PROFILE)
-#if defined(PROF_CACHE_LOG)
+# if defined(PROF_CACHE_LOG)
static int count_lookups[2];
-#endif
+# endif
/*
* Return TRUE if profiling is on for a function or sourced file.
* Cache the results of debuggy_find().
PEN_SET_FORCEIT(pe);
}
hash_add_item(ht, hi, pe->pen_name, hash);
-#if defined(PROF_CACHE_LOG)
+# if defined(PROF_CACHE_LOG)
ch_log(NULL, "has_profiling: %s %s forceit %s, profile %s",
file ? "file" : "func", fname,
PEN_IS_FORCEIT(pe) ? "true" : "false",
PEN_IS_PROFILING(pe) ? "true" : "false");
-#endif
+# endif
}
else
pe = HI2PE(hi);
if (fp)
*fp = PEN_IS_FORCEIT(pe);
-#if defined(PROF_CACHE_LOG)
+# if defined(PROF_CACHE_LOG)
count_lookups[file ? PROF_HTAB_FILES : PROF_HTAB_FUNCS]++;
-#endif
+# endif
return PEN_IS_PROFILING(pe);
}
{
if (ht->ht_used > 0)
{
-#if defined(PROF_CACHE_LOG)
+# if defined(PROF_CACHE_LOG)
int idx = ht == &prof_cache[PROF_HTAB_FUNCS]
? PROF_HTAB_FUNCS : PROF_HTAB_FILES;
ch_log(NULL, "prof_clear_cache: %s, used: %ld, lookups: %d",
idx == PROF_HTAB_FUNCS ? "function" : "script",
ht->ht_used, count_lookups[idx]);
count_lookups[idx] = 0;
-#endif
+# endif
hash_clear_all(ht, offsetof(profentry_T, pen_name));
hash_init(ht);
}
static int diff_need_update = FALSE; // ex_diffupdate needs to be called
// flags obtained from the 'diffopt' option
-#define DIFF_FILLER 0x001 // display filler lines
-#define DIFF_IBLANK 0x002 // ignore empty lines
-#define DIFF_ICASE 0x004 // ignore case
-#define DIFF_IWHITE 0x008 // ignore change in white space
-#define DIFF_IWHITEALL 0x010 // ignore all white space changes
-#define DIFF_IWHITEEOL 0x020 // ignore change in white space at EOL
-#define DIFF_HORIZONTAL 0x040 // horizontal splits
-#define DIFF_VERTICAL 0x080 // vertical splits
-#define DIFF_HIDDEN_OFF 0x100 // diffoff when hidden
-#define DIFF_INTERNAL 0x200 // use internal xdiff algorithm
-#define DIFF_CLOSE_OFF 0x400 // diffoff when closing window
-#define DIFF_FOLLOWWRAP 0x800 // follow the wrap option
-#define DIFF_LINEMATCH 0x1000 // match most similar lines within diff
-#define DIFF_INLINE_NONE 0x2000 // no inline highlight
-#define DIFF_INLINE_SIMPLE 0x4000 // inline highlight with simple algorithm
-#define DIFF_INLINE_CHAR 0x8000 // inline highlight with character diff
-#define DIFF_INLINE_WORD 0x10000 // inline highlight with word diff
-#define DIFF_ANCHOR 0x20000 // use 'diffanchors' to anchor the diff
-#define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
-#define ALL_INLINE (DIFF_INLINE_NONE | DIFF_INLINE_SIMPLE | DIFF_INLINE_CHAR | DIFF_INLINE_WORD)
-#define ALL_INLINE_DIFF (DIFF_INLINE_CHAR | DIFF_INLINE_WORD)
+# define DIFF_FILLER 0x001 // display filler lines
+# define DIFF_IBLANK 0x002 // ignore empty lines
+# define DIFF_ICASE 0x004 // ignore case
+# define DIFF_IWHITE 0x008 // ignore change in white space
+# define DIFF_IWHITEALL 0x010 // ignore all white space changes
+# define DIFF_IWHITEEOL 0x020 // ignore change in white space at EOL
+# define DIFF_HORIZONTAL 0x040 // horizontal splits
+# define DIFF_VERTICAL 0x080 // vertical splits
+# define DIFF_HIDDEN_OFF 0x100 // diffoff when hidden
+# define DIFF_INTERNAL 0x200 // use internal xdiff algorithm
+# define DIFF_CLOSE_OFF 0x400 // diffoff when closing window
+# define DIFF_FOLLOWWRAP 0x800 // follow the wrap option
+# define DIFF_LINEMATCH 0x1000 // match most similar lines within diff
+# define DIFF_INLINE_NONE 0x2000 // no inline highlight
+# define DIFF_INLINE_SIMPLE 0x4000 // inline highlight with simple algorithm
+# define DIFF_INLINE_CHAR 0x8000 // inline highlight with character diff
+# define DIFF_INLINE_WORD 0x10000 // inline highlight with word diff
+# define DIFF_ANCHOR 0x20000 // use 'diffanchors' to anchor the diff
+# define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
+# define ALL_INLINE (DIFF_INLINE_NONE | DIFF_INLINE_SIMPLE | DIFF_INLINE_CHAR | DIFF_INLINE_WORD)
+# define ALL_INLINE_DIFF (DIFF_INLINE_CHAR | DIFF_INLINE_WORD)
static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF | DIFF_INLINE_CHAR;
static long diff_algorithm = XDF_INDENT_HEURISTIC;
-#define LBUFLEN 50 // length of line in diff file
+# define LBUFLEN 50 // length of line in diff file
// Max file size xdiff is equipped to deal with. The value (1GB - 1MB) comes
// from Git's implementation.
-#define MAX_XDIFF_SIZE (1024L * 1024 * 1023)
+# define MAX_XDIFF_SIZE (1024L * 1024 * 1023)
static int diff_a_works = MAYBE; // TRUE when "diff -a" works, FALSE when it
// doesn't work, MAYBE when not checked yet
-#if defined(MSWIN)
+# if defined(MSWIN)
static int diff_bin_works = MAYBE; // TRUE when "diff --binary" works, FALSE
// when it doesn't work, MAYBE when not
// checked yet
-#endif
+# endif
-#define MAX_DIFF_ANCHORS 20
+# define MAX_DIFF_ANCHORS 20
// used for diff input
typedef struct {
static int diff_file(diffio_T *diffio);
static int diff_equal_entry(diff_T *dp, int idx1, int idx2);
static int diff_cmp(char_u *s1, char_u *s2);
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
static void diff_fold_update(diff_T *dp, int skip_idx);
-#endif
+# endif
static void diff_read(int idx_orig, int idx_new, diffio_T *dio);
static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig, int idx_new);
static diff_T *diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp);
static int xdiff_out_unified(void *priv, mmbuffer_t *mb, int nbuf);
static int parse_diffanchors(int check_only, buf_T *buf, linenr_T *anchors, int *num_anchors);
-#define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \
+# define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \
for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next)
static void
redraw_win_later(wp, UPD_SOME_VALID);
if (wp != curwin)
wp_other = wp;
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
if (dofold && foldmethodIsDiff(wp))
foldUpdateAll(wp);
-#endif
+# endif
// A change may have made filler lines invalid, need to take care of
// that for other windows.
n = diff_check_fill(wp, wp->w_topline);
diff_internal(void)
{
return (diff_flags & DIFF_INTERNAL) != 0
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
&& *p_dex == NUL
-#endif
+# endif
;
}
mch_remove(diffio->dio_orig.din_fname);
}
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// When using 'diffexpr' break here.
if (*p_dex != NUL)
break;
-#endif
+# endif
-#if defined(MSWIN)
+# if defined(MSWIN)
// If the "-a" argument works, also check if "--binary" works.
if (ok && diff_a_works == MAYBE && diff_bin_works == MAYBE)
{
diff_bin_works = FALSE;
ok = TRUE;
}
-#endif
+# endif
// If we checked if "-a" works already, break here.
if (diff_a_works != MAYBE)
emsg(_(e_cannot_read_or_write_temp_files));
emsg(_(e_cannot_create_diffs));
diff_a_works = MAYBE;
-#if defined(MSWIN)
+# if defined(MSWIN)
diff_bin_works = MAYBE;
-#endif
+# endif
return FAIL;
}
return OK;
char_u *tmp_new = dio->dio_new.din_fname;
char_u *tmp_diff = dio->dio_diff.dout_fname;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (*p_dex != NUL)
{
// Use 'diffexpr' to generate the diff file.
return OK;
}
else
-#endif
+# endif
// Use xdiff for generating the diff.
if (dio->dio_internal)
return diff_file_internal(dio);
// non-zero when differences have been found.
vim_snprintf((char *)cmd, len, "diff %s%s%s%s%s%s%s%s %s",
diff_a_works == FALSE ? "" : "-a ",
-#if defined(MSWIN)
+# if defined(MSWIN)
diff_bin_works == TRUE ? "--binary " : "",
-#else
+# else
"",
-#endif
+# endif
(diff_flags & DIFF_IWHITE) ? "-b " : "",
(diff_flags & DIFF_IWHITEALL) ? "-w " : "",
(diff_flags & DIFF_IWHITEEOL) ? "-Z " : "",
size_t buflen;
win_T *old_curwin = curwin;
char_u *newname = NULL; // name of patched file buffer
-#ifdef UNIX
+# ifdef UNIX
char_u dirbuf[MAXPATHL];
char_u *fullname = NULL;
-#endif
-#ifdef FEAT_BROWSE
+# endif
+# ifdef FEAT_BROWSE
char_u *browseFile = NULL;
int save_cmod_flags = cmdmod.cmod_flags;
-#endif
+# endif
stat_T st;
char_u *esc_name = NULL;
-#ifdef FEAT_BROWSE
+# ifdef FEAT_BROWSE
if (cmdmod.cmod_flags & CMOD_BROWSE)
{
browseFile = do_browse(0, (char_u *)_("Patch file"),
eap->arg = browseFile;
cmdmod.cmod_flags &= ~CMOD_BROWSE; // don't let do_ecmd() browse again
}
-#endif
+# endif
// We need two temp file names.
tmp_orig = vim_tempname('o', FALSE);
NULL, FALSE, FALSE, FALSE, TRUE) == FAIL)
goto theend;
-#ifdef UNIX
+# ifdef UNIX
// Get the absolute path of the patchfile, changing directory below.
fullname = FullName_save(eap->arg, FALSE);
-#endif
+# endif
esc_name = vim_strsave_shellescape(
# ifdef UNIX
fullname != NULL ? fullname :
if (buf == NULL)
goto theend;
-#ifdef UNIX
+# ifdef UNIX
// Temporarily chdir to /tmp, to avoid patching files in the current
// directory when the patch file contains more than one patch. When we
// have our own temp dir use that instead, it will be cleaned up when we
dirbuf[0] = NUL;
else
{
-# ifdef TEMPDIRNAMES
+# ifdef TEMPDIRNAMES
if (vim_tempdir != NULL)
vim_ignored = mch_chdir((char *)vim_tempdir);
else
-# endif
+# endif
vim_ignored = mch_chdir("/tmp");
shorten_fnames(TRUE);
}
-#endif
+# endif
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (*p_pex != NUL)
// Use 'patchexpr' to generate the new file.
eval_patch(tmp_orig,
-# ifdef UNIX
+# ifdef UNIX
fullname != NULL ? fullname :
-# endif
+# endif
eap->arg, tmp_new);
else
-#endif
+# endif
{
if (check_restricted())
goto theend;
unblock_autocmds();
}
-#ifdef UNIX
+# ifdef UNIX
if (dirbuf[0] != NUL)
{
if (mch_chdir((char *)dirbuf) != 0)
emsg(_(e_cannot_go_back_to_previous_directory));
shorten_fnames(TRUE);
}
-#endif
+# endif
// patch probably has written over the screen
redraw_later(UPD_CLEAR);
STRCAT(newname, ".new");
}
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
need_mouse_correct = TRUE;
-#endif
+# endif
// don't use a new tab page, each tab page has its own diffs
cmdmod.cmod_tab = 0;
vim_free(tmp_new);
vim_free(newname);
vim_free(buf);
-#ifdef UNIX
+# ifdef UNIX
vim_free(fullname);
-#endif
+# endif
vim_free(esc_name);
-#ifdef FEAT_BROWSE
+# ifdef FEAT_BROWSE
vim_free(browseFile);
cmdmod.cmod_flags = save_cmod_flags;
-#endif
+# endif
}
/*
bufref_T old_curbuf;
set_bufref(&old_curbuf, curbuf);
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
need_mouse_correct = TRUE;
-#endif
+# endif
// Need to compute w_fraction when no redraw happened yet.
validate_cursor();
set_fraction(curwin);
wp->w_leftcol = 0;
}
}
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
free_string_option(wp->w_p_fdm);
wp->w_p_fdm = vim_strsave(
*wp->w_p_fdm_save ? wp->w_p_fdm_save : (char_u*)"manual");
: wp->w_p_fen_save;
foldUpdateAll(wp);
-#endif
+# endif
}
// remove filler lines
wp->w_topfill = 0;
if (idx == DB_COUNT)
return 0; // no diffs for buffer "buf"
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
// A closed fold never has filler lines.
if (hasFoldingWin(wp, lnum, NULL, NULL, TRUE, NULL))
return 0;
-#endif
+# endif
// search for a change that includes "lnum" in the list of diffblocks.
FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
changed_line_abv_curs_win(towin);
check_topfill(towin, FALSE);
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
(void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline,
NULL, TRUE, NULL);
-#endif
+# endif
}
/*
return added;
}
-#if defined(FEAT_FOLDING)
+# if defined(FEAT_FOLDING)
/*
* Return TRUE if line "lnum" is not close to a diff block, this line should
* be in a fold.
}
return TRUE;
}
-#endif
+# endif
/*
* "dp" and "do" commands.
exarg_T ea;
char_u buf[30];
-#ifdef FEAT_JOB_CHANNEL
+# ifdef FEAT_JOB_CHANNEL
if (bt_prompt(curbuf))
{
vim_beep(BO_OPER);
return;
}
-#endif
+# endif
if (count == 0)
ea.arg = (char_u *)"";
else
if (dfree != NULL)
{
// Diff is deleted, update folds in other windows.
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
diff_fold_update(dfree, idx_to);
-#endif
+# endif
clear_diffblock(dfree);
}
check_cursor();
changed_line_abv_curs();
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
// If all diffs are gone, update folds in all diff windows.
if (curtab->tp_first_diff == NULL)
{
if (wp->w_p_diff && wp->w_p_fdm[0] == 'd' && wp->w_p_fen)
foldUpdateAll(wp);
}
-#endif
+# endif
if (diff_need_update)
// redraw already done by ex_diffupdate()
}
}
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
/*
* Update folds for all diff buffers for entry "dp".
* Skip buffer with index "skip_idx".
foldUpdate(wp, dp->df_lnum[i],
dp->df_lnum[i] + dp->df_count[i]);
}
-#endif
+# endif
/*
* Return TRUE if buffer "buf" is in diff-mode.
{'P', 'M', 0x9e},
{'A', 'C', 0x9f},
{'N', 'S', 0xa0},
-# define DG_START_LATIN 0xa1
+# define DG_START_LATIN 0xa1
{'!', 'I', 0xa1},
{'~', '!', 0xa1}, // ¡ Vim 5.x compatible
{'C', 't', 0xa2},
{'y', ':', 0xff},
{'y', '"', 0xff}, // x XX Vim 5.x compatible
-# define USE_UNICODE_DIGRAPHS
+# define USE_UNICODE_DIGRAPHS
{'A', '-', 0x0100},
{'a', '-', 0x0101},
{'\'', '0', 0x02da},
{'\'', ';', 0x02db},
{'\'', '"', 0x02dd},
-# define DG_START_GREEK 0x0386
+# define DG_START_GREEK 0x0386
{'A', '%', 0x0386},
{'E', '%', 0x0388},
{'Y', '%', 0x0389},
{'p', '3', 0x03e1},
{'\'', '%', 0x03f4},
{'j', '3', 0x03f5},
-# define DG_START_CYRILLIC 0x0401
+# define DG_START_CYRILLIC 0x0401
{'I', 'O', 0x0401},
{'D', '%', 0x0402},
{'G', '%', 0x0403},
{'c', '3', 0x0481},
{'G', '3', 0x0490},
{'g', '3', 0x0491},
-# define DG_START_HEBREW 0x05d0
+# define DG_START_HEBREW 0x05d0
{'A', '+', 0x05d0},
{'B', '+', 0x05d1},
{'G', '+', 0x05d2},
{'R', '+', 0x05e8},
{'S', 'h', 0x05e9},
{'T', '+', 0x05ea},
-# define DG_START_ARABIC 0x060c
+# define DG_START_ARABIC 0x060c
{',', '+', 0x060c},
{';', '+', 0x061b},
{'?', '+', 0x061f},
{'7', 'a', 0x06f7},
{'8', 'a', 0x06f8},
{'9', 'a', 0x06f9},
-# define DG_START_LATIN_EXTENDED 0x1e02
+# define DG_START_LATIN_EXTENDED 0x1e02
{'B', '.', 0x1e02},
{'b', '.', 0x1e03},
{'B', '_', 0x1e06},
{'y', '2', 0x1ef7},
{'Y', '?', 0x1ef8},
{'y', '?', 0x1ef9},
-# define DG_START_GREEK_EXTENDED 0x1f00
+# define DG_START_GREEK_EXTENDED 0x1f00
{';', '\'', 0x1f00},
{',', '\'', 0x1f01},
{';', '!', 0x1f02},
{'?', ',', 0x1f05},
{'!', ':', 0x1f06},
{'?', ':', 0x1f07},
-# define DG_START_PUNCTUATION 0x2002
+# define DG_START_PUNCTUATION 0x2002
{'1', 'N', 0x2002},
{'1', 'M', 0x2003},
{'3', 'M', 0x2004},
{':', 'X', 0x203b},
{'\'', '-', 0x203e},
{'/', 'f', 0x2044},
-# define DG_START_SUB_SUPER 0x2070
+# define DG_START_SUB_SUPER 0x2070
{'0', 'S', 0x2070},
{'4', 'S', 0x2074},
{'5', 'S', 0x2075},
{'=', 's', 0x208c},
{'(', 's', 0x208d},
{')', 's', 0x208e},
-# define DG_START_CURRENCY 0x20a4
+# define DG_START_CURRENCY 0x20a4
{'L', 'i', 0x20a4},
{'P', 't', 0x20a7},
{'W', '=', 0x20a9},
{'E', 'u', 0x20ac}, // euro
{'=', 'R', 0x20bd}, // rouble
{'=', 'P', 0x20bd}, // rouble
-# define DG_START_OTHER1 0x2103
+# define DG_START_OTHER1 0x2103
{'o', 'C', 0x2103},
{'c', 'o', 0x2105},
{'o', 'F', 0x2109},
{'3', '8', 0x215c},
{'5', '8', 0x215d},
{'7', '8', 0x215e},
-# define DG_START_ROMAN 0x2160
+# define DG_START_ROMAN 0x2160
{'1', 'R', 0x2160},
{'2', 'R', 0x2161},
{'3', 'R', 0x2162},
{'a', 'r', 0x2179},
{'b', 'r', 0x217a},
{'c', 'r', 0x217b},
-# define DG_START_ARROWS 0x2190
+# define DG_START_ARROWS 0x2190
{'<', '-', 0x2190},
{'-', '!', 0x2191},
{'-', '>', 0x2192},
{'<', '=', 0x21d0},
{'=', '>', 0x21d2},
{'=', '=', 0x21d4},
-# define DG_START_MATH 0x2200
+# define DG_START_MATH 0x2200
{'F', 'A', 0x2200},
{'d', 'P', 0x2202},
{'T', 'E', 0x2203},
{'.', 'P', 0x22c5},
{':', '3', 0x22ee},
{'.', '3', 0x22ef},
-# define DG_START_TECHNICAL 0x2302
+# define DG_START_TECHNICAL 0x2302
{'E', 'h', 0x2302},
{'<', '7', 0x2308},
{'>', '7', 0x2309},
{'I', 'l', 0x2321},
{'<', '[', 0x27e8},
{']', '>', 0x27e9},
-# define DG_START_OTHER2 0x2423
+# define DG_START_OTHER2 0x2423
{'V', 's', 0x2423},
{'1', 'h', 0x2440},
{'3', 'h', 0x2441},
{'7', '.', 0x248e},
{'8', '.', 0x248f},
{'9', '.', 0x2490},
-# define DG_START_DRAWING 0x2500
+# define DG_START_DRAWING 0x2500
{'h', 'h', 0x2500},
{'H', 'H', 0x2501},
{'v', 'v', 0x2502},
{'V', 'H', 0x254b},
{'F', 'D', 0x2571},
{'B', 'D', 0x2572},
-# define DG_START_BLOCK 0x2580
+# define DG_START_BLOCK 0x2580
{'T', 'B', 0x2580},
{'L', 'B', 0x2584},
{'F', 'B', 0x2588},
{'.', 'S', 0x2591},
{':', 'S', 0x2592},
{'?', 'S', 0x2593},
-# define DG_START_SHAPES 0x25a0
+# define DG_START_SHAPES 0x25a0
{'f', 'S', 0x25a0},
{'O', 'S', 0x25a1},
{'R', 'O', 0x25a2},
{'I', 'c', 0x25d9},
{'F', 'd', 0x25e2},
{'B', 'd', 0x25e3},
-# define DG_START_SYMBOLS 0x2605
+# define DG_START_SYMBOLS 0x2605
{'*', '2', 0x2605},
{'*', '1', 0x2606},
{'<', 'H', 0x261c},
{'M', 'b', 0x266d},
{'M', 'x', 0x266e},
{'M', 'X', 0x266f},
-# define DG_START_DINGBATS 0x2713
+# define DG_START_DINGBATS 0x2713
{'O', 'K', 0x2713},
{'X', 'X', 0x2717},
{'-', 'X', 0x2720},
-# define DG_START_CJK_SYMBOLS 0x3000
+# define DG_START_CJK_SYMBOLS 0x3000
{'I', 'S', 0x3000},
{',', '_', 0x3001},
{'.', '_', 0x3002},
{'(', 'I', 0x3016},
{')', 'I', 0x3017},
{'-', '?', 0x301c},
-# define DG_START_HIRAGANA 0x3041
+# define DG_START_HIRAGANA 0x3041
{'A', '5', 0x3041},
{'a', '5', 0x3042},
{'I', '5', 0x3043},
{'0', '5', 0x309c},
{'*', '5', 0x309d},
{'+', '5', 0x309e},
-# define DG_START_KATAKANA 0x30a1
+# define DG_START_KATAKANA 0x30a1
{'a', '6', 0x30a1},
{'A', '6', 0x30a2},
{'i', '6', 0x30a3},
{'-', '6', 0x30fc},
{'*', '6', 0x30fd},
{'+', '6', 0x30fe},
-# define DG_START_BOPOMOFO 0x3105
+# define DG_START_BOPOMOFO 0x3105
{'b', '4', 0x3105},
{'p', '4', 0x3106},
{'m', '4', 0x3107},
{'v', '4', 0x312a},
{'n', 'G', 0x312b},
{'g', 'n', 0x312c},
-# define DG_START_OTHER3 0x3220
+# define DG_START_OTHER3 0x3220
{'1', 'c', 0x3220},
{'2', 'c', 0x3221},
{'3', 'c', 0x3222},
digr_T *dp;
static char_u r[3];
-#if defined(USE_UNICODE_DIGRAPHS)
+# if defined(USE_UNICODE_DIGRAPHS)
if (!enc_utf8)
{
char_u buf[6], *to;
(void)convert_setup(&vc, NULL, NULL);
}
}
-#endif
+# endif
for (use_defaults = 0; use_defaults <= 1; use_defaults++)
{
if (cmdline)
{
if (char2cells(c) == 1
-#if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
+# if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
&& cmdline_star == 0
-#endif
+# endif
)
putcmdline(c, TRUE);
}
++dp;
}
}
-#ifdef USE_UNICODE_DIGRAPHS
+# ifdef USE_UNICODE_DIGRAPHS
if (retval != 0 && !enc_utf8)
{
char_u buf[6], *to;
(void)convert_setup(&vc, NULL, NULL);
}
}
-#endif
+# endif
// Ignore multi-byte characters when not in multi-byte mode.
if (!has_mbyte && retval > 0xff)
}
}
-#if defined(USE_UNICODE_DIGRAPHS)
+# if defined(USE_UNICODE_DIGRAPHS)
static void
digraph_header(char *msg)
{
msg_outtrans_attr((char_u *)msg, HL_ATTR(HLF_CM));
msg_putchar('\n');
}
-#endif
+# endif
void
listdigraphs(int use_headers)
dp = digraphdefault;
while (dp->char1 != NUL && !got_int)
{
-#if defined(USE_UNICODE_DIGRAPHS)
+# if defined(USE_UNICODE_DIGRAPHS)
digr_T tmp;
// May need to convert the result to 'encoding'.
if (tmp.result != 0 && tmp.result != tmp.char2
&& (has_mbyte || tmp.result <= 255))
printdigraph(&tmp, use_headers ? &previous : NULL);
-#else
+# else
if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result
&& (has_mbyte || dp->result <= 255))
printdigraph(dp, use_headers ? &previous : NULL);
-#endif
+# endif
++dp;
ui_breakcheck();
}
dp = (digr_T *)user_digraphs.ga_data;
for (i = 0; i < user_digraphs.ga_len && !got_int; ++i)
{
-#if defined(USE_UNICODE_DIGRAPHS)
+# if defined(USE_UNICODE_DIGRAPHS)
if (previous >= 0 && use_headers)
digraph_header(_("Custom"));
previous = -1;
-#endif
+# endif
printdigraph(dp, NULL);
ui_breakcheck();
++dp;
dp = digraphdefault;
while (dp->char1 != NUL && !got_int)
{
-#ifdef USE_UNICODE_DIGRAPHS
+# ifdef USE_UNICODE_DIGRAPHS
digr_T tmp;
tmp.char1 = dp->char1;
if (tmp.result != 0 && tmp.result != tmp.char2
&& (has_mbyte || tmp.result <= 255))
digraph_getlist_appendpair(&tmp, rettv->vval.v_list);
-#else
+# else
if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result
&& (has_mbyte || dp->result <= 255))
digraph_getlist_appendpair(dp, rettv->vval.v_list);
-#endif
+# endif
++dp;
}
}
if (dp->result == 0)
return;
-#if defined(USE_UNICODE_DIGRAPHS)
+# if defined(USE_UNICODE_DIGRAPHS)
if (previous != NULL)
{
int i;
}
*previous = dp->result;
}
-#endif
+# endif
if (msg_col > cmdline_width - list_width)
msg_putchar('\n');
if (msg_col)
char_u *to;
} kmap_T;
-#define KMAP_MAXLEN 20 // maximum length of "from" or "to"
+# define KMAP_MAXLEN 20 // maximum length of "from" or "to"
static void keymap_unload(void);
char_u *p;
char_u *s;
kmap_T *kp;
-#define KMAP_LLEN 200 // max length of "to" and "from" together
+# define KMAP_LLEN 200 // max length of "to" and "from" together
char_u buf[KMAP_LLEN + 11];
int i;
char_u *save_cpo = p_cpo;
* Modern way of creating registry entries, also works on 64 bit windows when
* compiled as a 32 bit program.
*/
-# ifndef KEY_WOW64_64KEY
-# define KEY_WOW64_64KEY 0x0100
-# endif
-# ifndef KEY_WOW64_32KEY
-# define KEY_WOW64_32KEY 0x0200
-# endif
+#ifndef KEY_WOW64_64KEY
+# define KEY_WOW64_64KEY 0x0100
+#endif
+#ifndef KEY_WOW64_32KEY
+# define KEY_WOW64_32KEY 0x0200
+#endif
#ifdef __MINGW32__
# define UNUSED __attribute__((unused))
}
if (wlv->row == wlv->startrow
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
+ wlv->filler_lines && wlv->filler_todo <= 0
-#endif
+# endif
)
{
text_sign = (wlv->sattr.sat_text != NULL) ? wlv->sattr.sat_typenr : 0;
else
{
did_emsg = save_did_emsg;
-#ifdef SYN_TIME_LIMIT
+# ifdef SYN_TIME_LIMIT
if (!wp->w_s->b_syn_slow)
-#endif
+# endif
{
has_syntax = TRUE;
extra_check = TRUE;
// If a double-width char doesn't fit display a '>' in the
// last column.
if ((
-# ifdef FEAT_RIGHTLEFT
+#ifdef FEAT_RIGHTLEFT
wp->w_p_rl ? (wlv.col <= 0) :
-# endif
+#endif
(wlv.col >= wp->w_width - 1))
&& (*mb_char2cells)(mb_c) == 2)
{
// Illegal UTF-8 byte: display as <xx>.
// Non-BMP character : display as ? or fullwidth ?.
transchar_hex(wlv.extra, mb_c);
-# ifdef FEAT_RIGHTLEFT
+#ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl) // reverse
rl_mirror(wlv.extra);
-# endif
+#endif
wlv.p_extra = wlv.extra;
c = *wlv.p_extra;
mb_c = mb_ptr2char_adv(&wlv.p_extra);
// last column; the character is displayed at the start of the
// next line.
if ((
-# ifdef FEAT_RIGHTLEFT
+#ifdef FEAT_RIGHTLEFT
wp->w_p_rl ? (wlv.col <= 0) :
-# endif
+#endif
(wlv.col >= wp->w_width - 1))
&& (*mb_char2cells)(mb_c) == 2)
{
&& wlv.tocol > wlv.vcol
&& VIsual_mode != Ctrl_V
&& (
-# ifdef FEAT_RIGHTLEFT
+#ifdef FEAT_RIGHTLEFT
wp->w_p_rl ? (wlv.col >= 0) :
-# endif
+#endif
(wlv.col < wp->w_width))
&& !(noinvcur
&& lnum == wp->w_cursor.lnum
|| (wp->w_p_list &&
wp->w_lcs_chars.eol > 0)))
wlv.char_attr = wlv.line_attr;
-#ifdef FEAT_SIGNS
+# ifdef FEAT_SIGNS
// At end of line: if Sign is present with line highlight, reset char_attr
// but not when cursorline is active
if (sign_present && wlv.sattr.sat_linehl > 0 && wlv.draw_state == WL_LINE
&& !(wp->w_p_cul && lnum == wp->w_cursor.lnum))
wlv.char_attr = wlv.sattr.sat_linehl;
-#endif
+# endif
# ifdef FEAT_DIFF
if (wlv.diff_hlf == HLF_TXD || wlv.diff_hlf == HLF_TXA)
{
if (*p < 0x80 && u8cc[0] == 0)
{
ScreenLinesUC[idx] = 0;
-#ifdef FEAT_ARABIC
+# ifdef FEAT_ARABIC
prev_c = u8c;
-#endif
+# endif
}
else
{
-#ifdef FEAT_ARABIC
+# ifdef FEAT_ARABIC
if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
{
// Do Arabic shaping.
}
else
prev_c = u8c;
-#endif
+# endif
// Non-BMP character: display as ? or fullwidth ?.
ScreenLinesUC[idx] = u8c;
for (i = 0; i < Screen_mco; ++i)
len = n;
if (len > 0)
{
-#ifdef FEAT_RIGHTLEFT
+# ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
mch_memmove(current_ScreenLine, text, len);
else
-#endif
+# endif
mch_memmove(current_ScreenLine + col, text, len);
col += len;
}
++col;
}
-#ifdef FEAT_RIGHTLEFT
-# define RL_MEMSET(p, v, l) \
+# ifdef FEAT_RIGHTLEFT
+# define RL_MEMSET(p, v, l) \
do { \
if (wp->w_p_rl) \
for (ri = 0; ri < (l); ++ri) \
for (ri = 0; ri < (l); ++ri) \
ScreenAttrs[off + (p) + ri] = v; \
} while (0)
-#else
-# define RL_MEMSET(p, v, l) \
+# else
+# define RL_MEMSET(p, v, l) \
do { \
for (ri = 0; ri < l; ++ri) \
ScreenAttrs[off + (p) + ri] = v; \
} while (0)
-#endif
+# endif
// 2. Add the 'foldcolumn'
// Reduce the width when there is not enough space.
ch = mb_ptr2char_adv(&p);
else
ch = *p++;
-#ifdef FEAT_RIGHTLEFT
+# ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
idx = off + wp->w_width - i - 1 - col;
else
-#endif
+# endif
idx = off + col + i;
if (enc_utf8)
{
// text
RL_MEMSET(col, HL_ATTR(HLF_FL), wp->w_width - col);
-#ifdef FEAT_SIGNS
+# ifdef FEAT_SIGNS
// If signs are being displayed, add two spaces.
if (signcolumn_on(wp))
{
{
if (len > 2)
len = 2;
-# ifdef FEAT_RIGHTLEFT
+# ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
// the line number isn't reversed
copy_text_attr(off + wp->w_width - len - col,
(char_u *)" ", len, HL_ATTR(HLF_FL));
else
-# endif
+# endif
copy_text_attr(off + col, (char_u *)" ", len, HL_ATTR(HLF_FL));
col += len;
}
}
-#endif
+# endif
// 3. Add the 'number' or 'relativenumber' column
if (wp->w_p_nu || wp->w_p_rnu)
}
vim_snprintf((char *)buf, sizeof(buf), fmt, w, num);
-#ifdef FEAT_RIGHTLEFT
+# ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
// the line number isn't reversed
copy_text_attr(off + wp->w_width - len - col, buf, len,
HL_ATTR(HLF_FL));
else
-#endif
+# endif
copy_text_attr(off + col, buf, len, HL_ATTR(HLF_FL));
col += len;
}
col = text_to_screenline(wp, text, col);
// Fill the rest of the line with the fold filler
-#ifdef FEAT_RIGHTLEFT
+# ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
col -= txtcol;
-#endif
+# endif
while (col < wp->w_width
-#ifdef FEAT_RIGHTLEFT
+# ifdef FEAT_RIGHTLEFT
- (wp->w_p_rl ? txtcol : 0)
-#endif
+# endif
)
{
int c = wp->w_fill_chars.fold;
}
}
-#ifdef FEAT_SYN_HL
+# ifdef FEAT_SYN_HL
// Show colorcolumn in the fold line, but let cursorcolumn override it.
if (wp->w_p_cc_cols)
{
ScreenAttrs[off + txtcol] = hl_combine_attr(
ScreenAttrs[off + txtcol], HL_ATTR(HLF_CUC));
}
-#endif
+# endif
screen_line(wp, row + W_WINROW(wp), wp->w_wincol, wp->w_width, wp->w_width,
-1, 0);
else if (!scrolled_down)
srow += wp->w_lines[idx].wl_size;
++idx;
-# ifdef FEAT_FOLDING
+#ifdef FEAT_FOLDING
if (idx < wp->w_lines_valid && wp->w_lines[idx].wl_valid)
lnum = wp->w_lines[idx].wl_lnum;
else
-# endif
+#endif
++lnum;
}
srow += mid_start;
{
cursor_off();
updating_screen = TRUE;
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
// Remove the cursor before starting to do anything, because scrolling may
// make it difficult to redraw the text under it.
if (gui.in_use)
gui_undraw_cursor();
-#endif
-#ifdef FEAT_SEARCH_EXTRA
+# endif
+# ifdef FEAT_SEARCH_EXTRA
start_search_hl();
-#endif
-#ifdef FEAT_PROP_POPUP
+# endif
+# ifdef FEAT_PROP_POPUP
// Update popup_mask if needed.
may_update_popup_mask(must_redraw);
-#endif
+# endif
}
/*
if (!doit || updating_screen
|| State == MODE_ASKMORE || State == MODE_HITRETURN
|| msg_scrolled
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
|| gui.starting
-#endif
+# endif
|| starting)
return;
win_redr_status(wp, FALSE);
}
-#if defined(FEAT_TABPANEL)
+# if defined(FEAT_TABPANEL)
if (redraw_tabpanel)
draw_tabpanel();
-#endif
+# endif
update_finish();
}
update_prepare();
-#ifdef FEAT_CLIPBOARD
+# ifdef FEAT_CLIPBOARD
// When Visual area changed, may have to update selection.
if (clip_star.available && clip_isautosel_star())
clip_update_selection(&clip_star);
if (clip_plus.available && clip_isautosel_plus())
clip_update_selection(&clip_plus);
-#endif
+# endif
win_update(wp);
if (redraw_tabline)
draw_tabline();
-#if defined(FEAT_TABPANEL)
+# if defined(FEAT_TABPANEL)
if (redraw_tabpanel)
draw_tabpanel();
-#endif
+# endif
if (wp->w_redr_status || p_ru
# ifdef FEAT_STL_OPT
)
win_redr_status(wp, FALSE);
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
// Display popup windows on top of everything.
update_popups(win_update);
-#endif
+# endif
update_finish();
}
redraw_all_windows_later(int type)
{
redraw_all_later(type);
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
popup_redraw_all(); // redraw all popup windows
-#endif
+# endif
}
#endif
break;
case Ctrl_U: // delete all inserted text in current line
-# ifdef FEAT_COMPL_FUNC
+#ifdef FEAT_COMPL_FUNC
// CTRL-X CTRL-U completes with 'completefunc'.
if (ctrl_x_mode_function())
goto docomplete;
-# endif
+#endif
did_backspace = ins_bs(c, BACKSPACE_LINE, &inserted_space);
auto_format(FALSE, TRUE);
inserted_space = FALSE;
// Trigger CursorMoved if the cursor moved. Not when the popup menu is
// visible, the command might delete it.
if (ready && (has_cursormovedI()
-# ifdef FEAT_PROP_POPUP
+#ifdef FEAT_PROP_POPUP
|| popup_visible
-# endif
-# if defined(FEAT_CONCEAL)
+#endif
+#if defined(FEAT_CONCEAL)
|| curwin->w_p_cole > 0
-# endif
+#endif
)
&& !EQUAL_POS(last_cursormoved, curwin->w_cursor)
&& !pum_visible())
{
-# ifdef FEAT_SYN_HL
+#ifdef FEAT_SYN_HL
// Need to update the screen first, to make sure syntax
// highlighting is correct after making a change (e.g., inserting
// a "(". The autocommand may also require a redraw, so it's done
// again below, unfortunately.
if (syntax_present(curwin) && must_redraw)
update_screen(0);
-# endif
+#endif
if (has_cursormovedI())
{
// Make sure curswant is correct, an autocommand may call
if (popup_visible)
popup_check_cursor_pos();
#endif
-# ifdef FEAT_CONCEAL
+#ifdef FEAT_CONCEAL
if (curwin->w_p_cole > 0)
{
conceal_old_cursor_line = last_cursormoved.lnum;
conceal_new_cursor_line = curwin->w_cursor.lnum;
conceal_update_lines = TRUE;
}
-# endif
+#endif
last_cursormoved = curwin->w_cursor;
}
case K_KPAGEUP:
case K_PAGEDOWN:
case K_KPAGEDOWN:
-# ifdef MACOS_X
+#ifdef MACOS_X
case K_LEFT:
case K_RIGHT:
case K_UP:
case K_DOWN:
case K_END:
case K_HOME:
-# endif
+#endif
if (!(mod_mask & MOD_MASK_SHIFT))
break;
// FALLTHROUGH
add_to_showcmd_c(Ctrl_K);
}
-#ifdef USE_ON_FLY_SCROLL
+# ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; // disallow scrolling here
-#endif
+# endif
// don't map the digraph chars. This also prevents the
// mode message to be deleted when ESC is hit
INIT(= N_("E230: Cannot read from \"%s\""));
EXTERN char e_guifontwide_invalid[]
INIT(= N_("E231: 'guifontwide' invalid"));
-#ifdef FEAT_BEVAL_GUI
+# ifdef FEAT_BEVAL_GUI
EXTERN char e_cannot_create_ballooneval_with_both_message_and_callback[]
INIT(= "E232: Cannot create BalloonEval with both message and callback");
-#endif
+# endif
# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
EXTERN char e_cannot_open_display[]
INIT(= N_("E233: Cannot open display"));
INIT(= N_("E627: Missing colon: %s"));
EXTERN char e_missing_bang_or_slash_in_str[]
INIT(= N_("E628: Missing ! or / in: %s"));
-#ifdef NBDEBUG
+# ifdef NBDEBUG
EXTERN char e_bad_return_from_nb_do_cmd[]
INIT(= "E629: Bad return from nb_do_cmd");
-#endif
+# endif
#endif
#ifdef FEAT_JOB_CHANNEL
EXTERN char e_str_write_while_not_connected[]
INIT(= N_("E838: NetBeans is not supported with this GUI"));
#endif
// E839 unused
-# ifdef FEAT_COMPL_FUNC
+#ifdef FEAT_COMPL_FUNC
EXTERN char e_complete_function_deleted_text[]
INIT(= N_("E840: Completion function deleted text"));
-# endif
+#endif
EXTERN char e_reserved_name_cannot_be_used_for_user_defined_command[]
INIT(= N_("E841: Reserved name, cannot be used for user defined command"));
EXTERN char e_no_line_number_to_use_for_slnum[]
INIT(= N_("E1285: Could not clear timeout: %s"));
EXTERN char e_could_not_set_timeout_str[]
INIT(= N_("E1286: Could not set timeout: %s"));
-#ifndef PROF_NSEC
+# ifndef PROF_NSEC
EXTERN char e_could_not_set_handler_for_timeout_str[]
INIT(= N_("E1287: Could not set handler for timeout: %s"));
EXTERN char e_could_not_reset_handler_for_timeout_str[]
INIT(= N_("E1288: Could not reset handler for timeout: %s"));
EXTERN char e_could_not_check_for_pending_sigalrm_str[]
INIT(= N_("E1289: Could not check for pending SIGALRM: %s"));
-#endif
+# endif
#endif
#ifdef FEAT_EVAL
EXTERN char e_substitute_nesting_too_deep[]
INIT(= N_("E1290: substitute nesting too deep"));
-# ifdef MSWIN
+# ifdef MSWIN
EXTERN char e_invalid_argument_nr[]
INIT(= N_("E1291: Invalid argument: %ld"));
-# endif
+# endif
#endif
EXTERN char e_cmdline_window_already_open[]
INIT(= N_("E1292: Command-line window is already open"));
if (!abort)
abort = abort || set_ref_in_callback(&bp->b_prompt_interrupt, copyID);
# endif
-#ifdef FEAT_COMPL_FUNC
+# ifdef FEAT_COMPL_FUNC
if (!abort)
abort = abort || set_ref_in_callback(&bp->b_cfu_cb, copyID);
if (!abort)
if (!abort && bp->b_p_cpt_cb != NULL)
abort = abort || set_ref_in_cpt_callbacks(bp->b_p_cpt_cb,
bp->b_p_cpt_count, copyID);
-#endif
+# endif
if (!abort)
abort = abort || set_ref_in_callback(&bp->b_tfu_cb, copyID);
if (!abort)
dict_add_list(dict, "windows", windows);
}
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
// List of popup windows displaying this buffer
windows = list_alloc();
if (windows != NULL)
dict_add_list(dict, "popups", windows);
}
-#endif
+# endif
-#ifdef FEAT_SIGNS
+# ifdef FEAT_SIGNS
if (buf->b_signlist != NULL)
{
// List of signs placed in this buffer
dict_add_list(dict, "signs", signs);
}
}
-#endif
+# endif
-#ifdef FEAT_VIMINFO
+# ifdef FEAT_VIMINFO
dict_add_number(dict, "lastused", buf->b_last_used);
-#endif
+# endif
return dict;
}
switch_buffer(bufref_T *save_curbuf, buf_T *buf)
{
block_autocmds();
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
++disable_fold_update;
-#endif
+# endif
set_bufref(save_curbuf, curbuf);
--curbuf->b_nwindows;
curbuf = buf;
restore_buffer(bufref_T *save_curbuf)
{
unblock_autocmds();
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
--disable_fold_update;
-#endif
+# endif
// Check for valid buffer, just in case.
if (bufref_valid(save_curbuf))
{
{
colnr_T sc1, ec1, sc2, ec2;
- #ifdef FEAT_LINEBREAK
+#ifdef FEAT_LINEBREAK
int lbr_saved = reset_lbr();
- #endif
+#endif
getvvcol(curwin, p1, &sc1, NULL, &ec1);
getvvcol(curwin, p2, &sc2, NULL, &ec2);
- #ifdef FEAT_LINEBREAK
+#ifdef FEAT_LINEBREAK
restore_lbr(lbr_saved);
- #endif
+#endif
oap->motion_type = MBLOCK;
oap->inclusive = TRUE;
#if defined(FEAT_RELTIME)
proftime_T res;
profile_start(&res);
-# if defined(MSWIN)
+# if defined(MSWIN)
*x = (UINT32_T)res.LowPart;
-# else
+# else
*x = (UINT32_T)res.tv_fsec;
-# endif
+# endif
#else
*x = vim_time();
#endif
}
else
{
-#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
+# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
if (USE_24BIT)
modec = 'g';
else
-#endif
+# endif
if (t_colors > 1)
modec = 'c';
else
return OK;
}
-# if defined(FEAT_POSTSCRIPT)
+#if defined(FEAT_POSTSCRIPT)
int
eval_printexpr(char_u *fname, char_u *args)
{
}
return OK;
}
-# endif
+#endif
-# if defined(FEAT_DIFF)
+#if defined(FEAT_DIFF)
void
eval_diff(
char_u *origfile,
set_vim_var_string(VV_FNAME_OUT, NULL, -1);
current_sctx = saved_sctx;
}
-# endif
+#endif
#if defined(FEAT_SPELL)
/*
*tpp = tp;
return wp;
}
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
// popup windows are in separate lists
FOR_ALL_TABPAGES(tp)
FOR_ALL_POPUPWINS_IN_TAB(tp, wp)
*tpp = curtab; // any tabpage would do
return wp;
}
-#endif
+# endif
return NULL;
}
}
if (nr >= LOWEST_WIN_ID)
{
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
// check tab-local popup windows
for (wp = (tp == NULL ? curtab : tp)->tp_first_popupwin;
wp != NULL; wp = wp->w_next)
FOR_ALL_POPUPWINS(wp)
if (wp->w_id == nr)
return wp;
-#endif
+# endif
return NULL;
}
return wp;
dict_add_number(dict, "winrow", wp->w_winrow + 1);
dict_add_number(dict, "topline", wp->w_topline);
dict_add_number(dict, "botline", wp->w_botline - 1);
-#ifdef FEAT_MENU
+# ifdef FEAT_MENU
dict_add_number(dict, "winbar", wp->w_winbar_height);
-#endif
+# endif
dict_add_number(dict, "width", wp->w_width);
dict_add_number(dict, "wincol", wp->w_wincol + 1);
dict_add_number(dict, "textoff", win_col_off(wp));
dict_add_number(dict, "bufnr", wp->w_buffer->b_fnum);
dict_add_number(dict, "leftcol", wp->w_leftcol);
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
dict_add_number(dict, "terminal", bt_terminal(wp->w_buffer));
-#endif
-#ifdef FEAT_QUICKFIX
+# endif
+# ifdef FEAT_QUICKFIX
dict_add_number(dict, "quickfix", bt_quickfix(wp->w_buffer));
dict_add_number(dict, "loclist",
(bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL));
-#endif
+# endif
// Add a reference to window variables
dict_add_dict(dict, "variables", wp->w_vars);
return;
}
}
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
if (wparg != NULL)
{
tabnr = 0;
if (d != NULL)
list_append_dict(rettv->vval.v_list, d);
}
-#endif
+# endif
}
/*
if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
return;
-#if defined(FEAT_GUI) \
+# if defined(FEAT_GUI) \
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
|| defined(MSWIN)
{
(void)ui_get_winpos(&x, &y, timeout);
}
-#endif
+# endif
list_append_number(rettv->vval.v_list, (varnumber_T)x);
list_append_number(rettv->vval.v_list, (varnumber_T)y);
}
f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
{
rettv->vval.v_number = -1;
-#if defined(FEAT_GUI) \
+# if defined(FEAT_GUI) \
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
|| defined(MSWIN)
if (ui_get_winpos(&x, &y, 100) == OK)
rettv->vval.v_number = x;
}
-#endif
+# endif
}
/*
f_getwinposy(typval_T *argvars UNUSED, typval_T *rettv)
{
rettv->vval.v_number = -1;
-#if defined(FEAT_GUI) \
+# if defined(FEAT_GUI) \
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
|| defined(MSWIN)
{
if (ui_get_winpos(&x, &y, 100) == OK)
rettv->vval.v_number = y;
}
-#endif
+# endif
}
/*
pos_T curpos = wp->w_cursor;
char_u cwd[MAXPATHL];
int cwd_status = FAIL;
-#ifdef FEAT_AUTOCHDIR
+# ifdef FEAT_AUTOCHDIR
char_u autocwd[MAXPATHL];
int apply_acd = FALSE;
-#endif
+# endif
// Getting and setting directory can be slow on some systems, only do
// this when the current or target window/tab have a local directory or
|| (curtab != tp
&& (curtab->tp_localdir != NULL
|| tp->tp_localdir != NULL))
-#ifdef FEAT_AUTOCHDIR
+# ifdef FEAT_AUTOCHDIR
|| p_acd
-#endif
+# endif
))
cwd_status = mch_dirname(cwd, MAXPATHL);
-#ifdef FEAT_AUTOCHDIR
+# ifdef FEAT_AUTOCHDIR
// If 'acd' is set, check we are using that directory. If yes, then
// apply 'acd' afterwards, otherwise restore the current directory.
if (cwd_status == OK && p_acd)
apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
&& STRCMP(cwd, autocwd) == 0;
}
-#endif
+# endif
if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
{
execute_common(argvars, rettv, 1);
}
restore_win_noblock(&switchwin, TRUE);
-#ifdef FEAT_AUTOCHDIR
+# ifdef FEAT_AUTOCHDIR
if (apply_acd)
do_autochdir();
else
-#endif
+# endif
if (cwd_status == OK)
mch_chdir((char *)cwd);
if (text_or_buf_locked())
return;
-#if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL)
+# if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL)
if (popup_is_popup(curwin) && curbuf->b_term != NULL)
{
emsg(_(e_not_allowed_for_terminal_in_popup_window));
return;
}
-#endif
+# endif
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_id == id)
{
}
if (is_aucmd_win(wp))
rettv->vval.v_string = vim_strsave((char_u *)"autocmd");
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
else if (wp->w_p_pvw)
rettv->vval.v_string = vim_strsave((char_u *)"preview");
-#endif
-#ifdef FEAT_PROP_POPUP
+# endif
+# ifdef FEAT_PROP_POPUP
else if (WIN_IS_POPUP(wp))
rettv->vval.v_string = vim_strsave((char_u *)"popup");
-#endif
+# endif
else if (wp == cmdwin_win)
rettv->vval.v_string = vim_strsave((char_u *)"command");
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
else if (bt_quickfix(wp->w_buffer))
rettv->vval.v_string = vim_strsave((char_u *)
(wp->w_llist_ref != NULL ? "loclist" : "quickfix"));
-#endif
+# endif
}
if (dict_has_key(dict, "topline"))
set_topline(curwin, (linenr_T)dict_get_number(dict, "topline"));
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
if (dict_has_key(dict, "topfill"))
curwin->w_topfill = (int)dict_get_number(dict, "topfill");
-#endif
+# endif
if (dict_has_key(dict, "leftcol"))
curwin->w_leftcol = (colnr_T)dict_get_number(dict, "leftcol");
if (dict_has_key(dict, "skipcol"))
curwin->w_topline = 1;
if (curwin->w_topline > curbuf->b_ml.ml_line_count)
curwin->w_topline = curbuf->b_ml.ml_line_count;
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
check_topfill(curwin, TRUE);
-#endif
+# endif
}
/*
dict_add_number(dict, "curswant", (long)curwin->w_curswant);
dict_add_number(dict, "topline", (long)curwin->w_topline);
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
dict_add_number(dict, "topfill", (long)curwin->w_topfill);
-#endif
+# endif
dict_add_number(dict, "leftcol", (long)curwin->w_leftcol);
dict_add_number(dict, "skipcol", (long)curwin->w_skipcol);
}
char_u *nextcmd; // next command (NULL if none)
char_u *cmd; // the name of the command (except for :make)
char_u **cmdlinep; // pointer to pointer of allocated cmdline
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
char_u *cmdline_tofree; // free later
-#endif
+# endif
cmdidx_T cmdidx; // the index for the command
long argt; // flags for the command
int skip; // don't execute the command, only parse it
char *errmsg; // returned error message
char_u *(*ea_getline)(int, void *, int, getline_opt_T);
void *cookie; // argument for getline()
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
cstack_T *cstack; // condition stack for ":if" etc.
class_T *ea_class; // Name of class being defined. Used by :class
// and :enum commands.
-#endif
+# endif
};
-#define FORCE_BIN 1 // ":edit ++bin file"
-#define FORCE_NOBIN 2 // ":edit ++nobin file"
+# define FORCE_BIN 1 // ":edit ++bin file"
+# define FORCE_NOBIN 2 // ":edit ++nobin file"
// Values for "flags"
-#define EXFLAG_LIST 0x01 // 'l': list
-#define EXFLAG_NR 0x02 // '#': number
-#define EXFLAG_PRINT 0x04 // 'p': print
+# define EXFLAG_LIST 0x01 // 'l': list
+# define EXFLAG_NR 0x02 // '#': number
+# define EXFLAG_PRINT 0x04 // 'p': print
#endif
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
-#if defined(FEAT_BROWSE)
+# if defined(FEAT_BROWSE)
/*
* When wanting to write a file without a file name, ask the user for a name.
*/
buf->b_flags |= BF_NOTEDITED;
vim_free(fname);
}
-#endif
+# endif
/*
* Ask the user what to do when abandoning a changed buffer.
{
int empty_bufname;
-#ifdef FEAT_BROWSE
+# ifdef FEAT_BROWSE
// May get file name, when there is none
browse_save_fname(buf);
-#endif
+# endif
empty_bufname = buf->b_fname == NULL ? TRUE : FALSE;
if (empty_bufname)
buf_set_name(buf->b_fnum, (char_u *)"Untitled");
{
if (bufIsChanged(buf2)
&& (buf2->b_ffname != NULL
-#ifdef FEAT_BROWSE
+# ifdef FEAT_BROWSE
|| (cmdmod.cmod_flags & CMOD_BROWSE)
-#endif
+# endif
)
&& !bt_dontwrite(buf2)
&& !buf2->b_p_ro)
bufref_T bufref;
set_bufref(&bufref, buf2);
-#ifdef FEAT_BROWSE
+# ifdef FEAT_BROWSE
// May get file name, when there is none
browse_save_fname(buf2);
-#endif
+# endif
if (buf2->b_fname != NULL && check_overwrite(&ea, buf2,
buf2->b_fname, buf2->b_ffname, FALSE) == OK)
// didn't hit Cancel
break;
}
}
-#ifdef FEAT_PROFILE
+# ifdef FEAT_PROFILE
else if (do_profiling == PROF_YES
&& getline_equal(fgetline, cookie, getsourceline))
script_line_end();
-#endif
+# endif
// Check if a sourced file hit a ":finish" command.
if (source_finished(fgetline, cookie))
return *p == '"';
}
-# define CURRENT_WIN_NR current_win_nr(curwin)
-# define LAST_WIN_NR current_win_nr(NULL)
-# define CURRENT_TAB_NR current_tab_nr(curtab)
-# define LAST_TAB_NR current_tab_nr(NULL)
+#define CURRENT_WIN_NR current_win_nr(curwin)
+#define LAST_WIN_NR current_win_nr(NULL)
+#define CURRENT_TAB_NR current_tab_nr(curtab)
+#define LAST_TAB_NR current_tab_nr(NULL)
/*
* Execute one Ex command.
close_others(TRUE, forceit);
if (ONE_WINDOW)
ex_win_close(forceit, curwin, NULL);
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
need_mouse_correct = TRUE;
-# endif
+#endif
}
/*
{
if (window_layout_locked(CMD_only))
return;
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
need_mouse_correct = TRUE;
-# endif
+#endif
if (eap->addr_count > 0)
{
win_T *wp;
if (only_one_window()) // quit last window, exit Vim
getout(0);
not_exiting();
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
need_mouse_correct = TRUE;
-# endif
+#endif
// Quit current window, may free the buffer.
win_close(curwin, !buf_hide(curwin->w_buffer));
}
goto theend;
eap->arg = fname;
}
-# ifdef FEAT_BROWSE
+#ifdef FEAT_BROWSE
else if ((cmdmod.cmod_flags & CMOD_BROWSE)
&& eap->cmdidx != CMD_vnew
&& eap->cmdidx != CMD_new)
do_exedit(eap, old_curwin);
}
-# ifdef FEAT_BROWSE
+#ifdef FEAT_BROWSE
cmdmod.cmod_flags = save_cmod_flags;
-# endif
+#endif
theend:
vim_free(fname);
;
}
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
need_mouse_correct = TRUE;
-# endif
+#endif
n = atol((char *)eap->arg);
if (cmdmod.cmod_split & WSP_VERT)
{
#endif
{
// use NameBuff for home directory name
-# ifdef VMS
+#ifdef VMS
char_u *p;
p = mch_getenv((char_u *)"SYS$LOGIN");
NameBuff[0] = NUL;
else
vim_strncpy(NameBuff, p, MAXPATHL - 1);
-# else
+#else
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
-# endif
+#endif
new_dir = NameBuff;
}
dir_differs = pdir == NULL
{
long done = 0;
long wait_now;
-# ifdef ELAPSED_FUNC
+#ifdef ELAPSED_FUNC
elapsed_T start_tv;
// Remember at what time we started, so that we know how much longer we
// should wait after waiting for a bit.
ELAPSED_INIT(start_tv);
-# endif
+#endif
if (hide_cursor)
cursor_sleep();
parse_queued_messages();
#endif
-# ifdef ELAPSED_FUNC
+#ifdef ELAPSED_FUNC
// actual time passed
done = ELAPSED_FUNC(start_tv);
-# else
+#else
// guestimate time passed (will actually be more)
done += wait_now;
-# endif
+#endif
}
// If CTRL-C was typed to interrupt the sleep, drop the CTRL-C from the
(linenr_T)1, (linenr_T)MAXLNUM, eap->forceit, FALSE);
}
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
/*
* ":psearch"
*/
ex_findpat(eap);
g_do_tagpreview = 0;
}
-#endif
+# endif
static void
ex_findpat(exarg_T *eap)
#ifdef FEAT_CLIENTSERVER
case SPEC_CLIENT: // Source of last submitted input
-#ifdef MSWIN
+# ifdef MSWIN
sprintf((char *)strbuf, PRINTF_HEX_LONG_U,
(long_u)clientWindow);
result = strbuf;
-#else
-# ifdef FEAT_SOCKETSERVER
+# else
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET)
{
if (client_socket == NULL)
else
result = client_socket;
}
-# endif
-# ifdef FEAT_X11
+# endif
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11)
{
sprintf((char *)strbuf, PRINTF_HEX_LONG_U,
(long_u)clientWindow);
result = strbuf;
}
+# endif
# endif
-#endif
break;
#endif
}
# ifdef FEAT_CLIPBOARD
start_global_changes();
# endif
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
inc_clip_provider();
-#endif
+# endif
// First set the marks for all lines closed/open.
for (lnum = eap->line1; lnum <= eap->line2; ++lnum)
# ifdef FEAT_CLIPBOARD
end_global_changes();
# endif
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
dec_clip_provider();
-#endif
+# endif
}
#endif
int skiplen, patlen;
int found; // do_search() result
pos_T end_pos;
-#ifdef FEAT_RELTIME
+# ifdef FEAT_RELTIME
searchit_arg_T sia;
-#endif
+# endif
int next_char;
int use_last_pat;
int did_do_incsearch = is_state->did_incsearch;
if (search_first_line != 0)
search_flags += SEARCH_START;
ccline.cmdbuff[skiplen + patlen] = NUL;
-#ifdef FEAT_RELTIME
+# ifdef FEAT_RELTIME
CLEAR_FIELD(sia);
// Set the time limit to half a second.
sia.sa_tm = 500;
-#endif
+# endif
found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim,
ccline.cmdbuff + skiplen, patlen, count, search_flags,
-#ifdef FEAT_RELTIME
+# ifdef FEAT_RELTIME
&sia
-#else
+# else
NULL
-#endif
+# endif
);
ccline.cmdbuff[skiplen + patlen] = next_char;
--emsg_off;
*ignore_drag_release = TRUE;
else
*ignore_drag_release = FALSE;
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
// When GUI is active, also move when 'mouse' is empty
if (!gui.in_use)
-# endif
+#endif
if (!mouse_has(MOUSE_COMMAND))
return;
-# ifdef FEAT_CLIPBOARD
+#ifdef FEAT_CLIPBOARD
if (mouse_row < cmdline_row && (clip_star.available || clip_plus.available))
{
int button, is_click, is_drag;
clip_modeless(button, is_click, is_drag);
return;
}
-# endif
+#endif
set_cmdspos();
for (ccline.cmdpos = 0; ccline.cmdpos < ccline.cmdlen;
goto cmdline_not_changed; // Ignore mouse
case K_MIDDLEMOUSE:
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
// When GUI is active, also paste when 'mouse' is empty
if (!gui.in_use)
-# endif
+#endif
if (!mouse_has(MOUSE_COMMAND))
goto cmdline_not_changed; // Ignore mouse
-# ifdef FEAT_CLIPBOARD
+#ifdef FEAT_CLIPBOARD
if (clip_star.available)
cmdline_paste('*', TRUE, TRUE);
else
-# endif
+#endif
cmdline_paste(0, TRUE, TRUE);
redrawcmd();
goto cmdline_changed;
-# ifdef FEAT_DND
+#ifdef FEAT_DND
case K_DROP:
cmdline_paste('~', TRUE, FALSE);
redrawcmd();
goto cmdline_changed;
-# endif
+#endif
case K_LEFTDRAG:
case K_LEFTRELEASE:
return ccline.overstrike;
}
-# if defined(MCH_CURSOR_SHAPE) || defined(FEAT_GUI) || defined(FEAT_MOUSESHAPE)
+#if defined(MCH_CURSOR_SHAPE) || defined(FEAT_GUI) || defined(FEAT_MOUSESHAPE)
/*
* Return TRUE if the cursor is at the end of the cmdline.
*/
return NUL;
if (p->cmdfirstc == NUL)
return
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
(p->input_fn) ? '@' :
-# endif
+#endif
'-';
return p->cmdfirstc;
}
// Can't do this recursively. Can't do it when typing a password.
if (text_or_buf_locked()
|| cmdwin_type != 0
-# if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
+#if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
|| cmdline_star > 0
-# endif
+#endif
)
{
beep_flush();
#ifdef FEAT_FOLDING
curwin->w_p_fen = FALSE;
#endif
-# ifdef FEAT_RIGHTLEFT
+#ifdef FEAT_RIGHTLEFT
curwin->w_p_rl = cmdmsg_rl;
cmdmsg_rl = FALSE;
-# endif
+#endif
RESET_BINDING(curwin);
// Don't allow switching to another buffer.
RedrawingDisabled = save_RedrawingDisabled;
-# ifdef FEAT_FOLDING
+#ifdef FEAT_FOLDING
save_KeyTyped = KeyTyped;
-# endif
+#endif
// Trigger CmdwinLeave autocommands.
trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE);
-# ifdef FEAT_FOLDING
+#ifdef FEAT_FOLDING
// Restore KeyTyped in case it is modified by autocommands
KeyTyped = save_KeyTyped;
-# endif
+#endif
cmdwin_type = 0;
cmdwin_buf = NULL;
}
else
{
-# if defined(FEAT_EVAL)
+#if defined(FEAT_EVAL)
// autocmds may abort script processing
if (aborting() && cmdwin_result != K_IGNORE)
cmdwin_result = Ctrl_C;
-# endif
+#endif
// Set the new command line from the cmdline buffer.
dealloc_cmdbuff();
ccline.cmdpos = ccline.cmdlen;
}
-# ifdef FEAT_CONCEAL
+#ifdef FEAT_CONCEAL
// Avoid command-line window first character being concealed.
curwin->w_p_cole = 0;
-# endif
+#endif
// First go back to the original window.
wp = curwin;
set_bufref(&bufref, curbuf);
ga_clear(&winsizes);
restart_edit = save_restart_edit;
-# ifdef FEAT_RIGHTLEFT
+#ifdef FEAT_RIGHTLEFT
cmdmsg_rl = save_cmdmsg_rl;
-# endif
+#endif
State = save_State;
may_trigger_modechanged();
prompt = tv_get_string_chk(&argvars[0]);
-#ifdef NO_CONSOLE_INPUT
+# ifdef NO_CONSOLE_INPUT
// While starting up, there is no place to enter text. When running tests
// with --not-a-term we assume feedkeys() will be used.
if (no_console_input() && !is_not_a_term())
return;
-#endif
+# endif
cmd_silent = FALSE; // Want to see the prompt.
if (prompt != NULL)
#endif
#ifdef FEAT_ARABIC
# ifndef FEAT_RIGHTLEFT
-# define FEAT_RIGHTLEFT
+# define FEAT_RIGHTLEFT
# endif
#endif
* +socketserver Use UNIX domain sockets for clientserver communication
*/
#if defined(UNIX) && defined(WANT_SOCKETSERVER)
-#define FEAT_SOCKETSERVER
+# define FEAT_SOCKETSERVER
#endif
/*
else
{
filemess(curbuf, sfname, (char_u *)(
-# ifdef EFBIG
+#ifdef EFBIG
(errno == EFBIG) ? _("[File too big]") :
-# endif
-# ifdef EOVERFLOW
+#endif
+#ifdef EOVERFLOW
(errno == EOVERFLOW) ? _("[File too big]") :
-# endif
+#endif
_("[Permission Denied]")), 0);
curbuf->b_p_ro = TRUE; // must use "w!" now
}
{
found_bad = FALSE;
-# ifdef CP_UTF8 // VC 4.1 doesn't define CP_UTF8
+# ifdef CP_UTF8 // VC 4.1 doesn't define CP_UTF8
if (codepage == CP_UTF8)
{
// Handle CP_UTF8 input ourselves to be able to handle
}
}
else
-# endif
+# endif
{
// We don't know how long the byte sequence is, try
// from one to three bytes.
FALSE, NULL, eap);
if (msg_scrolled == n)
msg_scroll = m;
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
goto theend;
-# endif
+#endif
}
if (!(recoverymode && error))
cp = encname2codepage(ptr);
if (cp == 0)
{
-# ifdef CP_UTF8 // VC 4.1 doesn't define CP_UTF8
+# ifdef CP_UTF8 // VC 4.1 doesn't define CP_UTF8
if (STRCMP(ptr, "utf-8") == 0)
cp = CP_UTF8;
else
-# endif
+# endif
return 0;
}
return FIO_PUT_CP(cp) | FIO_CODEPAGE;
if (emsg_silent == 0 && !in_assert_fails)
{
out_flush();
- #ifdef FEAT_GUI
+#ifdef FEAT_GUI
if (!focus)
- #endif
+#endif
// give the user some time to think about it
ui_delay(1004L, TRUE);
{
if (mch_dirname(cwd, MAXPATHL) != FAIL)
{
-#ifdef BACKSLASH_IN_FILENAME
+# ifdef BACKSLASH_IN_FILENAME
slash_adjust(cwd);
-#endif
+# endif
rettv->vval.v_string = vim_strsave(cwd);
}
vim_free(cwd);
}
}
}
-#ifdef BACKSLASH_IN_FILENAME
+# ifdef BACKSLASH_IN_FILENAME
if (rettv->vval.v_string != NULL)
slash_adjust(rettv->vval.v_string);
-#endif
+# endif
}
/*
f_resolve(typval_T *argvars, typval_T *rettv)
{
char_u *p;
-#ifdef HAVE_READLINK
+# ifdef HAVE_READLINK
char_u *buf = NULL;
-#endif
+# endif
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return;
p = tv_get_string(&argvars[0]);
-#ifdef FEAT_SHORTCUT
+# ifdef FEAT_SHORTCUT
{
char_u *v = NULL;
else
rettv->vval.v_string = vim_strsave(p);
}
-#else
-# ifdef HAVE_READLINK
+# else
+# ifdef HAVE_READLINK
{
char_u *cpy;
int len;
rettv->vval.v_string = p;
}
-# else
+# else
rettv->vval.v_string = vim_strsave(p);
+# endif
# endif
-#endif
simplify_filename(rettv->vval.v_string);
-#ifdef HAVE_READLINK
+# ifdef HAVE_READLINK
fail:
vim_free(buf);
-#endif
+# endif
rettv->v_type = VAR_STRING;
}
int binary = FALSE;
int append = FALSE;
int defer = FALSE;
-#ifdef HAVE_FSYNC
+# ifdef HAVE_FSYNC
int do_fsync = p_fs;
-#endif
+# endif
char_u *fname;
FILE *fd;
int ret = 0;
append = TRUE;
if (vim_strchr(arg2, 'D') != NULL)
defer = TRUE;
-#ifdef HAVE_FSYNC
+# ifdef HAVE_FSYNC
if (vim_strchr(arg2, 's') != NULL)
do_fsync = TRUE;
else if (vim_strchr(arg2, 'S') != NULL)
do_fsync = FALSE;
-#endif
+# endif
}
fname = tv_get_string_chk(&argvars[1]);
if (write_list(fd, list, binary) == FAIL)
ret = -1;
}
-#ifdef HAVE_FSYNC
+# ifdef HAVE_FSYNC
if (ret == 0 && do_fsync)
// Ignore the error, the user wouldn't know what to do about
// it. May happen for a device.
vim_ignored = vim_fsync(fileno(fd));
-#endif
+# endif
fclose(fd);
}
}
ffname = FullName_save((*files)[i], FALSE);
if (ffname == NULL) // out of memory
break;
-# ifdef VMS
+#ifdef VMS
vms_remove_version(ffname);
-# endif
+#endif
if (match_file_list(p_wig, (*files)[i], ffname))
{
// remove this matching file from the list
if (cmd == NULL)
return -1;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (*cmd == '=') // `={expr}`: Expand expression
buffer = eval_to_string(cmd + 1, TRUE, FALSE);
else
-#endif
+# endif
buffer = get_cmd_output(cmd, NULL,
(flags & EW_SILENT) ? SHELL_SILENT : 0, NULL);
vim_free(cmd);
if ((flags & EW_ALLLINKS) ? mch_lstat((char *)buf, &sb) >= 0
: mch_getperm(buf) >= 0)
{
-#ifdef MACOS_CONVERT
+# ifdef MACOS_CONVERT
size_t precomp_len = STRLEN(buf)+1;
char_u *precomp_buf =
mac_precompose_path(buf, precomp_len, &precomp_len);
mch_memmove(buf, precomp_buf, precomp_len);
vim_free(precomp_buf);
}
-#endif
+# endif
addfile(gap, buf, flags);
}
}
file_to_find, search_ctx);
}
-# if defined(EXITFREE)
+#if defined(EXITFREE)
void
free_findfile(void)
{
VIM_CLEAR_STRING(ff_expand_buffer);
}
-# endif
+#endif
/*
* Find the directory name "ptr[len]" in the path.
static int did_findfile_init = FALSE;
char_u *file_name = NULL;
int rel_to_curdir;
-# ifdef AMIGA
+#ifdef AMIGA
struct Process *proc = (struct Process *)FindTask(0L);
APTR save_winptr = proc->pr_WindowPtr;
// Avoid a requester here for a volume that doesn't exist.
proc->pr_WindowPtr = (APTR)-1L;
-# endif
+#endif
static size_t file_to_findlen = 0;
if (first == TRUE)
if (vim_isAbsName(*file_to_find)
// "..", "../path", "." and "./path": don't use the path_option
|| rel_to_curdir
-# if defined(MSWIN)
+#if defined(MSWIN)
// handle "\tmp" as absolute path
|| vim_ispathsep((*file_to_find)[0])
// handle "c:name" as absolute path
|| ((*file_to_find)[0] != NUL && (*file_to_find)[1] == ':')
-# endif
-# ifdef AMIGA
+#endif
+#ifdef AMIGA
// handle ":tmp" as absolute path
|| (*file_to_find)[0] == ':'
-# endif
+#endif
)
{
/*
}
theend:
-# ifdef AMIGA
+#ifdef AMIGA
proc->pr_WindowPtr = save_winptr;
-# endif
+#endif
return file_name;
}
return find_file_name_in_path(ptr, len, options, count, rel_fname);
}
-# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
+#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
static char_u *
eval_includeexpr(char_u *ptr, int len)
{
current_sctx = save_sctx;
return res;
}
-# endif
+#endif
/*
* Return the name of the file ptr[len] in 'path'.
{
char_u *file_name;
int c;
-# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
+#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
char_u *tofree = NULL;
-# endif
+#endif
if (len == 0)
return NULL;
-# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
+#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL)
{
tofree = eval_includeexpr(ptr, len);
len = (int)STRLEN(ptr);
}
}
-# endif
+#endif
if (options & FNAME_EXP)
{
file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS,
TRUE, rel_fname, &file_to_find, &search_ctx);
-# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
+#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
/*
* If the file could not be found in a normal way, try applying
* 'includeexpr' (unless done already).
TRUE, rel_fname, &file_to_find, &search_ctx);
}
}
-# endif
+#endif
if (file_name == NULL && (options & FNAME_MESS))
{
c = ptr[len];
else
file_name = vim_strnsave(ptr, len);
-# if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
+#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
vim_free(tofree);
-# endif
+#endif
return file_name;
}
int
vim_ispathlistsep(int c)
{
-# ifdef UNIX
+#ifdef UNIX
return (c == ':');
-# else
+#else
return (c == ';'); // might not be right for every system...
-# endif
+#endif
}
/*
if (ga_grow(gap, 1) == FAIL)
break;
-# if defined(MSWIN)
+#if defined(MSWIN)
// Avoid the path ending in a backslash, it fails when a comma is
// appended.
if (buf[buflen - 1] == '\\')
buf[buflen - 1] = '/';
-# endif
+#endif
p = vim_strnsave(buf, buflen);
if (p == NULL)
int j = 0;
while ((fname[j] == path_part[i][j]
-# if defined(MSWIN)
+#if defined(MSWIN)
|| (vim_ispathsep(fname[j]) && vim_ispathsep(path_part[i][j]))
-# endif
+#endif
) && fname[j] != NUL && path_part[i][j] != NUL)
j++;
if (j > maxlen)
*/
short_name = shorten_fname(path, curdir);
if (short_name != NULL && short_name > path + 1
-# if defined(MSWIN)
+#if defined(MSWIN)
// On windows,
// shorten_fname("c:\a\a.txt", "c:\a\b")
// returns "\a\a.txt", which is not really the short
// name, hence:
&& !vim_ispathsep(*short_name)
-# endif
+#endif
)
{
vim_snprintf((char *)path, MAXPATHL, ".%s%s", PATHSEPSTR, short_name);
rettv->vval.v_float = 0.0;
}
-# if defined(HAVE_MATH_H)
+#if defined(HAVE_MATH_H)
/*
* "isinf()" function
*/
rettv->vval.v_number = argvars[0].v_type == VAR_FLOAT
&& isnan(argvars[0].vval.v_float);
}
-# endif
+#endif
/*
* "log()" function
// folds too
} fold_T;
-#define FD_OPEN 0 // fold is open (nested ones can be closed)
-#define FD_CLOSED 1 // fold is closed
-#define FD_LEVEL 2 // depends on 'foldlevel' (nested folds too)
+# define FD_OPEN 0 // fold is open (nested ones can be closed)
+# define FD_CLOSED 1 // fold is closed
+# define FD_LEVEL 2 // depends on 'foldlevel' (nested folds too)
-#define MAX_LEVEL 20 // maximum fold depth
+# define MAX_LEVEL 20 // maximum fold depth
// static functions {{{2
static void newFoldLevelWin(win_T *wp);
static int prev_lnum_lvl = -1;
// Flags used for "done" argument of setManualFold.
-#define DONE_NOTHING 0
-#define DONE_ACTION 1 // did close or open a fold
-#define DONE_FOLD 2 // did find a fold
+# define DONE_NOTHING 0
+# define DONE_ACTION 1 // did close or open a fold
+# define DONE_FOLD 2 // did find a fold
static int foldstartmarkerlen;
static char_u *foldendmarker;
}
// foldLevel() {{{2
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
/*
* Return fold level at line number "lnum" in the current window.
*/
return foldLevelWin(curwin, lnum);
}
-#endif
+# endif
// lineFolded() {{{2
/*
{
newFoldLevelWin(curwin);
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
if (foldmethodIsDiff(curwin) && curwin->w_p_scb)
{
win_T *wp;
}
}
}
-#endif
+# endif
}
static void
if (disable_fold_update > 0)
return;
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
if (need_diff_redraw)
// will update later
return;
-#endif
+# endif
if (wp->w_folds.ga_len > 0)
{
if (foldmethodIsIndent(wp)
|| foldmethodIsExpr(wp)
|| foldmethodIsMarker(wp)
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
|| foldmethodIsDiff(wp)
-#endif
+# endif
|| foldmethodIsSyntax(wp))
{
int save_got_int = got_int;
int recurse, // TRUE when closing/opening recursive
int *donep)
{
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
if (foldmethodIsDiff(curwin) && curwin->w_p_scb)
{
win_T *wp;
}
}
}
-#endif
+# endif
return setManualFoldWin(curwin, lnum, opening, recurse, donep);
}
char_u *buf)
{
char_u *text = NULL;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// an error occurred when evaluating 'fdt' setting
static int got_fdt_error = FALSE;
int save_did_emsg = did_emsg;
}
}
if (text == NULL)
-#endif
+# endif
{
long count = (long)(lnume - lnum + 1);
}
// foldtext_cleanup() {{{2
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
/*
* Remove 'foldmarker' and 'commentstring' from "str" (in-place).
*/
}
}
}
-#endif
+# endif
// Folding by indent, expr, marker and syntax. {{{1
// Define "fline_T", passed to get fold level for a line. {{{2
static void foldRemove(garray_T *gap, linenr_T top, linenr_T bot);
static void foldMerge(fold_T *fp1, garray_T *gap, fold_T *fp2);
static void foldlevelIndent(fline_T *flp);
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
static void foldlevelDiff(fline_T *flp);
-#endif
+# endif
static void foldlevelExpr(fline_T *flp);
static void foldlevelMarker(fline_T *flp);
static void foldlevelSyntax(fline_T *flp);
setSmallMaybe(&wp->w_folds);
}
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
// add the context for "diff" folding
if (foldmethodIsDiff(wp))
{
top = 1;
bot += diff_context;
}
-#endif
+# endif
// When deleting lines at the end of the buffer "top" can be past the end
// of the buffer.
}
else if (foldmethodIsSyntax(wp))
getlevel = foldlevelSyntax;
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
else if (foldmethodIsDiff(wp))
getlevel = foldlevelDiff;
-#endif
+# endif
else
{
getlevel = foldlevelIndent;
fp->fd_len = end - fp->fd_top;
}
-#define fold_end(fp) ((fp)->fd_top + (fp)->fd_len - 1)
-#define valid_fold(fp, gap) ((gap)->ga_len > 0 && (fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len))
-#define fold_index(fp, gap) ((size_t)((fp) - ((fold_T *)(gap)->ga_data)))
+# define fold_end(fp) ((fp)->fd_top + (fp)->fd_len - 1)
+# define valid_fold(fp, gap) ((gap)->ga_len > 0 && (fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len))
+# define fold_index(fp, gap) ((size_t)((fp) - ((fold_T *)(gap)->ga_data)))
void
foldMoveRange(garray_T *gap, linenr_T line1, linenr_T line2, linenr_T dest)
foldReverseOrder(gap, (linenr_T)(move_start + dest_index - move_end),
(linenr_T)(dest_index - 1));
}
-#undef fold_end
-#undef valid_fold
-#undef fold_index
+# undef fold_end
+# undef valid_fold
+# undef fold_index
// foldMerge() {{{2
/*
}
// foldlevelDiff() {{{2
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
/*
* Low level function to get the foldlevel for the "diff" method.
* Doesn't use any caching.
else
flp->lvl = 0;
}
-#endif
+# endif
// foldlevelExpr() {{{2
/*
static void
foldlevelExpr(fline_T *flp)
{
-#ifndef FEAT_EVAL
+# ifndef FEAT_EVAL
flp->start = FALSE;
flp->lvl = 0;
-#else
+# else
win_T *win;
int n;
int c;
curwin = win;
curbuf = curwin->w_buffer;
-#endif
+# endif
}
// parseMarker() {{{2
static void
foldlevelSyntax(fline_T *flp)
{
-#ifndef FEAT_SYN_HL
+# ifndef FEAT_SYN_HL
flp->start = 0;
flp->lvl = 0;
-#else
+# else
linenr_T lnum = flp->lnum + flp->off;
int n;
flp->lvl = n;
}
}
-#endif
+# endif
}
// functions for storing the fold state in a View {{{1
// put_folds() {{{2
-#if defined(FEAT_SESSION)
+# if defined(FEAT_SESSION)
static int put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off);
static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off);
static int put_fold_open_close(FILE *fd, fold_T *fp, linenr_T off);
return OK;
}
-#endif // FEAT_SESSION
+# endif // FEAT_SESSION
// }}}1
#endif // defined(FEAT_FOLDING)
return;
}
}
-#endif
+# endif
rettv->vval.v_number = -1;
}
#ifdef FEAT_NORMAL
// Add extra space to handle large OSC responses in bigger chunks (improve
// performance)
-#define TYPELEN_INIT (5 * (MAXMAPLEN + 3) + 2048)
+# define TYPELEN_INIT (5 * (MAXMAPLEN + 3) + 2048)
#else // Tiny version
-#define TYPELEN_INIT (5 * (MAXMAPLEN + 3))
+# define TYPELEN_INIT (5 * (MAXMAPLEN + 3))
#endif
static char_u typebuf_init[TYPELEN_INIT]; // initial typebuf.tb_buf
static char_u noremapbuf_init[TYPELEN_INIT]; // initial typebuf.tb_noremap
readbuf1.bh_first.b_next = NULL;
tp->save_readbuf2 = readbuf2;
readbuf2.bh_first.b_next = NULL;
-# ifdef USE_INPUT_BUF
+#ifdef USE_INPUT_BUF
tp->save_inputbuf = get_input_buf();
-# endif
+#endif
}
/*
readbuf1 = tp->save_readbuf1;
free_buff(&readbuf2);
readbuf2 = tp->save_readbuf2;
-# ifdef USE_INPUT_BUF
+#ifdef USE_INPUT_BUF
set_input_buf(tp->save_inputbuf, overwrite);
-# endif
+#endif
}
/*
if (called_emsg != called_emsg_start)
return;
-#ifdef MESSAGE_QUEUE
+# ifdef MESSAGE_QUEUE
// vpeekc() used to check for messages, but that caused problems, invoking
// a callback where it was not expected. Some plugins use getchar(1) in a
// loop to await a message, therefore make sure we check for messages here.
parse_queued_messages();
-#endif
+# endif
if (cursor_flag == 'h')
cursor_sleep();
if (win == NULL)
return;
(void)mouse_comp_pos(win, &row, &col, &lnum, NULL);
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
if (WIN_IS_POPUP(win))
winnr = 0;
else
-#endif
+# endif
for (wp = firstwin; wp != win && wp != NULL;
wp = wp->w_next)
++winnr;
if (has_sound_callback_in_queue())
invoke_sound_callback();
# endif
-#ifdef SIGUSR1
+# ifdef SIGUSR1
if (got_sigusr1)
{
apply_autocmds(EVENT_SIGUSR1, NULL, NULL, FALSE, curbuf);
got_sigusr1 = FALSE;
}
-#endif
+# endif
break;
}
// t_unknown - used for when the type is really unknown, e.g. global variables.
// Also for when a function may or may not return something.
-#define t_unknown (static_types[0])
-#define t_const_unknown (static_types[1])
+# define t_unknown (static_types[0])
+# define t_const_unknown (static_types[1])
// t_any - used for when the type can be anything, but excludes "void".
-#define t_any (static_types[2])
-#define t_const_any (static_types[3])
+# define t_any (static_types[2])
+# define t_const_any (static_types[3])
// t_void - used for a function not returning anything.
-#define t_void (static_types[4])
-#define t_const_void (static_types[5])
+# define t_void (static_types[4])
+# define t_const_void (static_types[5])
-#define t_bool (static_types[6])
-#define t_const_bool (static_types[7])
+# define t_bool (static_types[6])
+# define t_const_bool (static_types[7])
-#define t_null (static_types[8])
-#define t_const_null (static_types[9])
+# define t_null (static_types[8])
+# define t_const_null (static_types[9])
-#define t_none (static_types[10])
-#define t_const_none (static_types[11])
+# define t_none (static_types[10])
+# define t_const_none (static_types[11])
-#define t_number (static_types[12])
-#define t_const_number (static_types[13])
+# define t_number (static_types[12])
+# define t_const_number (static_types[13])
// t_number_bool - number that can be used as a bool
-#define t_number_bool (static_types[14])
-#define t_const_number_bool (static_types[15])
+# define t_number_bool (static_types[14])
+# define t_const_number_bool (static_types[15])
// t_number_float - number that can be used as a float
-#define t_number_float (static_types[16])
-#define t_const_number_float (static_types[17])
+# define t_number_float (static_types[16])
+# define t_const_number_float (static_types[17])
-#define t_float (static_types[18])
-#define t_const_float (static_types[19])
+# define t_float (static_types[18])
+# define t_const_float (static_types[19])
-#define t_string (static_types[20])
-#define t_const_string (static_types[21])
+# define t_string (static_types[20])
+# define t_const_string (static_types[21])
-#define t_blob (static_types[22])
-#define t_const_blob (static_types[23])
+# define t_blob (static_types[22])
+# define t_const_blob (static_types[23])
-#define t_blob_null (static_types[24])
-#define t_const_blob_null (static_types[25])
+# define t_blob_null (static_types[24])
+# define t_const_blob_null (static_types[25])
-#define t_job (static_types[26])
-#define t_const_job (static_types[27])
+# define t_job (static_types[26])
+# define t_const_job (static_types[27])
-#define t_channel (static_types[28])
-#define t_const_channel (static_types[29])
+# define t_channel (static_types[28])
+# define t_const_channel (static_types[29])
// t_number_or_string - Special value used for @#.
-#define t_number_or_string (static_types[30])
-#define t_const_number_or_string (static_types[31])
+# define t_number_or_string (static_types[30])
+# define t_const_number_or_string (static_types[31])
// t_func_unknown - function with any arguments and no or unknown return value
-#define t_func_unknown (static_types[32])
-#define t_const_func_unknown (static_types[33])
+# define t_func_unknown (static_types[32])
+# define t_const_func_unknown (static_types[33])
// t_func_void - function with any arguments and no return value
-#define t_func_void (static_types[34])
-#define t_const_func_void (static_types[35])
+# define t_func_void (static_types[34])
+# define t_const_func_void (static_types[35])
-#define t_func_any (static_types[36])
-#define t_const_func_any (static_types[37])
+# define t_func_any (static_types[36])
+# define t_const_func_any (static_types[37])
-#define t_func_number (static_types[38])
-#define t_const_func_number (static_types[39])
+# define t_func_number (static_types[38])
+# define t_const_func_number (static_types[39])
-#define t_func_string (static_types[40])
-#define t_const_func_string (static_types[41])
+# define t_func_string (static_types[40])
+# define t_const_func_string (static_types[41])
-#define t_func_bool (static_types[42])
-#define t_const_func_bool (static_types[43])
+# define t_func_bool (static_types[42])
+# define t_const_func_bool (static_types[43])
// t_func_0_void - function without arguments and nor return value
-#define t_func_0_void (static_types[44])
-#define t_const_func_0_void (static_types[45])
+# define t_func_0_void (static_types[44])
+# define t_const_func_0_void (static_types[45])
-#define t_func_0_any (static_types[46])
-#define t_const_func_0_any (static_types[47])
+# define t_func_0_any (static_types[46])
+# define t_const_func_0_any (static_types[47])
-#define t_func_0_number (static_types[48])
-#define t_const_func_0_number (static_types[49])
+# define t_func_0_number (static_types[48])
+# define t_const_func_0_number (static_types[49])
-#define t_func_0_string (static_types[50])
-#define t_const_func_0_string (static_types[51])
+# define t_func_0_string (static_types[50])
+# define t_const_func_0_string (static_types[51])
-#define t_list_any (static_types[52])
-#define t_const_list_any (static_types[53])
+# define t_list_any (static_types[52])
+# define t_const_list_any (static_types[53])
-#define t_dict_any (static_types[54])
-#define t_const_dict_any (static_types[55])
+# define t_dict_any (static_types[54])
+# define t_const_dict_any (static_types[55])
-#define t_list_empty (static_types[56])
-#define t_const_list_empty (static_types[57])
+# define t_list_empty (static_types[56])
+# define t_const_list_empty (static_types[57])
-#define t_dict_empty (static_types[58])
-#define t_const_dict_empty (static_types[59])
+# define t_dict_empty (static_types[58])
+# define t_const_dict_empty (static_types[59])
-#define t_list_bool (static_types[60])
-#define t_const_list_bool (static_types[61])
+# define t_list_bool (static_types[60])
+# define t_const_list_bool (static_types[61])
-#define t_list_number (static_types[62])
-#define t_const_list_number (static_types[63])
+# define t_list_number (static_types[62])
+# define t_const_list_number (static_types[63])
-#define t_list_string (static_types[64])
-#define t_const_list_string (static_types[65])
+# define t_list_string (static_types[64])
+# define t_const_list_string (static_types[65])
-#define t_list_job (static_types[66])
-#define t_const_list_job (static_types[67])
+# define t_list_job (static_types[66])
+# define t_const_list_job (static_types[67])
-#define t_list_dict_any (static_types[68])
-#define t_const_list_dict_any (static_types[69])
+# define t_list_dict_any (static_types[68])
+# define t_const_list_dict_any (static_types[69])
-#define t_list_list_any (static_types[70])
-#define t_const_list_list_any (static_types[71])
+# define t_list_list_any (static_types[70])
+# define t_const_list_list_any (static_types[71])
-#define t_list_list_number (static_types[72])
-#define t_const_list_list_number (static_types[73])
+# define t_list_list_number (static_types[72])
+# define t_const_list_list_number (static_types[73])
-#define t_list_list_string (static_types[74])
-#define t_const_list_list_string (static_types[75])
+# define t_list_list_string (static_types[74])
+# define t_const_list_list_string (static_types[75])
-#define t_list_list_list_number (static_types[76])
-#define t_const_list_list_list_number (static_types[77])
+# define t_list_list_list_number (static_types[76])
+# define t_const_list_list_list_number (static_types[77])
-#define t_dict_bool (static_types[78])
-#define t_const_dict_bool (static_types[79])
+# define t_dict_bool (static_types[78])
+# define t_const_dict_bool (static_types[79])
-#define t_dict_number (static_types[80])
-#define t_const_dict_number (static_types[81])
+# define t_dict_number (static_types[80])
+# define t_const_dict_number (static_types[81])
-#define t_dict_string (static_types[82])
-#define t_const_dict_string (static_types[83])
+# define t_dict_string (static_types[82])
+# define t_const_dict_string (static_types[83])
-#define t_super (static_types[84])
-#define t_const_super (static_types[85])
+# define t_super (static_types[84])
+# define t_const_super (static_types[85])
-#define t_object_any (static_types[86])
-#define t_const_object_any (static_types[87])
+# define t_object_any (static_types[86])
+# define t_const_object_any (static_types[87])
-#define t_class (static_types[88])
-#define t_const_class (static_types[89])
+# define t_class (static_types[88])
+# define t_const_class (static_types[89])
-#define t_typealias (static_types[90])
-#define t_const_typealias (static_types[91])
+# define t_typealias (static_types[90])
+# define t_const_typealias (static_types[91])
-#define t_tuple_any (static_types[92])
-#define t_const_tuple_any (static_types[93])
+# define t_tuple_any (static_types[92])
+# define t_const_tuple_any (static_types[93])
-#define t_tuple_empty (static_types[94])
-#define t_const_tuple_empty (static_types[95])
+# define t_tuple_empty (static_types[94])
+# define t_const_tuple_empty (static_types[95])
EXTERN type_T static_types[96]
-#ifdef DO_INIT
+# ifdef DO_INIT
= {
// 0: t_unknown
{VAR_UNKNOWN, 0, 0, TTFLAG_STATIC, NULL, NULL, NULL},
{VAR_TUPLE, 0, 0, TTFLAG_STATIC, NULL, NULL, NULL},
{VAR_TUPLE, 0, 0, TTFLAG_STATIC|TTFLAG_CONST, NULL, NULL, NULL},
}
-#endif
+# endif
;
EXTERN int did_source_packages INIT(= FALSE);
# endif
#endif
-# ifdef FEAT_MOUSESHAPE
+#ifdef FEAT_MOUSESHAPE
EXTERN int drag_status_line INIT(= FALSE); // dragging the status line
EXTERN int postponed_mouseshape INIT(= FALSE); // postponed updating the
// mouse pointer shape
EXTERN int drag_sep_line INIT(= FALSE); // dragging vert separator
-# endif
+#endif
#ifdef FEAT_DIFF
// terminated.
EXTERN int (*mb_head_off)(char_u *base, char_u *p) INIT(= latin_head_off);
-# if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
+#if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
// Pointers to functions and variables to be loaded at runtime
EXTERN size_t (*iconv) (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
EXTERN iconv_t (*iconv_open) (const char *tocode, const char *fromcode);
EXTERN int (*iconv_close) (iconv_t cd);
EXTERN int (*iconvctl) (iconv_t cd, int request, void *argument);
EXTERN int* (*iconv_errno) (void);
-# endif
+#endif
#ifdef FEAT_XIM
EXTERN int did_cursorhold INIT(= TRUE); // set when CursorHold t'gerd
EXTERN pos_T last_cursormoved // for CursorMoved event
-# ifdef DO_INIT
+#ifdef DO_INIT
= {0, 0, 0}
-# endif
+#endif
;
EXTERN int postponed_split INIT(= 0); // for CTRL-W CTRL-] command
// on Win32 only get_beval_info() is required
#if !defined(FEAT_GUI_MSWIN)
-#ifdef FEAT_GUI_GTK
-# if GTK_CHECK_VERSION(3,0,0)
-# include <gdk/gdkkeysyms-compat.h>
+# ifdef FEAT_GUI_GTK
+# if GTK_CHECK_VERSION(3,0,0)
+# include <gdk/gdkkeysyms-compat.h>
+# else
+# include <gdk/gdkkeysyms.h>
+# endif
+# include <gtk/gtk.h>
# else
-# include <gdk/gdkkeysyms.h>
+# include <X11/keysym.h>
+# include <Xm/PushB.h>
+# include <Xm/Separator.h>
+# include <Xm/List.h>
+# include <Xm/Label.h>
+# include <Xm/AtomMgr.h>
+# include <Xm/Protocols.h>
# endif
-# include <gtk/gtk.h>
-#else
-# include <X11/keysym.h>
-# include <Xm/PushB.h>
-# include <Xm/Separator.h>
-# include <Xm/List.h>
-# include <Xm/Label.h>
-# include <Xm/AtomMgr.h>
-# include <Xm/Protocols.h>
-#endif
-
-#ifndef FEAT_GUI_GTK
+
+# ifndef FEAT_GUI_GTK
extern Widget vimShell;
/*
* showing BalloonEval or NULL if none is showing.
*/
static BalloonEval *current_beval = NULL;
-#endif
+# endif
-#ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
static void addEventHandler(GtkWidget *, BalloonEval *);
static void removeEventHandler(BalloonEval *);
static gint target_event_cb(GtkWidget *, GdkEvent *, gpointer);
static void pointer_event(BalloonEval *, int, int, unsigned);
static void key_event(BalloonEval *, unsigned, int);
static gboolean timeout_cb(gpointer);
-# if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
static gboolean balloon_draw_event_cb (GtkWidget *, cairo_t *, gpointer);
-# else
+# else
static gint balloon_expose_event_cb (GtkWidget *, GdkEventExpose *, gpointer);
-# endif
-#else
+# endif
+# else
static void addEventHandler(Widget, BalloonEval *);
static void removeEventHandler(BalloonEval *);
static void pointerEventEH(Widget, XtPointer, XEvent *, Boolean *);
static void pointerEvent(BalloonEval *, XEvent *);
static void timerRoutine(XtPointer, XtIntervalId *);
-#endif
+# endif
static void cancelBalloon(BalloonEval *);
static void requestBalloon(BalloonEval *);
static void drawBalloon(BalloonEval *);
void (*mesgCB)(BalloonEval *, int),
void *clientData)
{
-#ifndef FEAT_GUI_GTK
+# ifndef FEAT_GUI_GTK
char *display_name; // get from gui.dpy
int screen_num;
char *p;
-#endif
+# endif
BalloonEval *beval;
if (mesg != NULL && mesgCB != NULL)
beval = ALLOC_CLEAR_ONE(BalloonEval);
if (beval != NULL)
{
-#ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
beval->target = GTK_WIDGET(target);
-#else
+# else
beval->target = (Widget)target;
beval->appContext = XtWidgetToApplicationContext((Widget)target);
-#endif
+# endif
beval->showState = ShS_NEUTRAL;
vim_free(beval->msg);
beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
addEventHandler(beval->target, beval);
createBalloonEvalWindow(beval);
-#ifndef FEAT_GUI_GTK
+# ifndef FEAT_GUI_GTK
/*
* Now create and save the screen width and height. Used in drawing.
*/
screen_num = 0;
beval->screen_width = DisplayWidth(gui.dpy, screen_num);
beval->screen_height = DisplayHeight(gui.dpy, screen_num);
-#endif
+# endif
}
return beval;
}
-#if defined(FEAT_BEVAL_TIP)
+# if defined(FEAT_BEVAL_TIP)
/*
* Destroy a balloon-eval and free its associated memory.
*/
cancelBalloon(beval);
removeEventHandler(beval);
// Children will automatically be destroyed
-# ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
gtk_widget_destroy(beval->balloonShell);
-# else
+# else
XtDestroyWidget(beval->balloonShell);
-# endif
-# ifdef FEAT_VARTABS
+# endif
+# ifdef FEAT_VARTABS
if (beval->vts)
vim_free(beval->vts);
-# endif
+# endif
vim_free(beval);
}
-#endif
+# endif
void
gui_mch_enable_beval_area(BalloonEval *beval)
removeEventHandler(beval);
}
-#if defined(FEAT_BEVAL_TIP)
+# if defined(FEAT_BEVAL_TIP)
/*
* This function returns the BalloonEval * associated with the currently
* displayed tooltip. Returns NULL if there is no tooltip currently showing.
{
return current_beval;
}
-#endif
+# endif
#endif // !FEAT_GUI_MSWIN
#if defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL)
#endif // FEAT_NETBEANS_INTG || FEAT_EVAL
#if !defined(FEAT_GUI_MSWIN)
-#if defined(FEAT_BEVAL_TIP)
+# if defined(FEAT_BEVAL_TIP)
/*
* Hide the given balloon.
*/
VIM_CLEAR(beval->msg);
undrawBalloon(beval);
}
-#endif
+# endif
-#ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
static void
addEventHandler(GtkWidget *target, BalloonEval *beval)
{
* GDK_POINTER_MOTION_HINT_MASK is set, thus we cannot obtain
* the coordinates from the GdkEventMotion struct directly.
*/
-# if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
{
GdkWindow * const win = gtk_widget_get_window(widget);
GdkDisplay * const dpy = gdk_window_get_display(win);
-# if GTK_CHECK_VERSION(3,20,0)
+# if GTK_CHECK_VERSION(3,20,0)
GdkSeat * const seat = gdk_display_get_default_seat(dpy);
GdkDevice * const dev = gdk_seat_get_pointer(seat);
-# else
+# else
GdkDeviceManager * const mngr = gdk_display_get_device_manager(dpy);
GdkDevice * const dev = gdk_device_manager_get_client_pointer(mngr);
-# endif
+# endif
gdk_window_get_device_position(win, dev , &x, &y, &state);
}
-# else
+# else
gdk_window_get_pointer(widget->window, &x, &y, &state);
-# endif
+# endif
pointer_event(beval, x, y, (unsigned int)state);
}
else
return FALSE; // don't call me again
}
-# if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
static gboolean
balloon_draw_event_cb(GtkWidget *widget,
cairo_t *cr,
return FALSE;
}
-# else
+# else
static gint
balloon_expose_event_cb(GtkWidget *widget,
GdkEventExpose *event,
return FALSE; // continue emission
}
-# endif // !GTK_CHECK_VERSION(3,0,0)
+# endif // !GTK_CHECK_VERSION(3,0,0)
-#else // !FEAT_GUI_GTK
+# else // !FEAT_GUI_GTK
static void
addEventHandler(Widget target, BalloonEval *beval)
requestBalloon(beval);
}
-#endif // !FEAT_GUI_GTK
+# endif // !FEAT_GUI_GTK
static void
requestBalloon(BalloonEval *beval)
drawBalloon(beval);
}
-#ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
/*
* Convert the string to UTF-8 if 'encoding' is not "utf-8".
* Replace any non-printable characters and invalid bytes sequences with
* "^X" or "<xx>" escapes, and apply SpecialKey highlighting to them.
* TAB and NL are passed through unscathed.
*/
-# define IS_NONPRINTABLE(c) (((c) < 0x20 && (c) != TAB && (c) != NL) \
+# define IS_NONPRINTABLE(c) (((c) < 0x20 && (c) != TAB && (c) != NL) \
|| (c) == DEL)
static void
set_printable_label_text(GtkLabel *label, char_u *text)
attrentry_T *aep;
PangoAttribute *attr;
guicolor_T pixel;
-#if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
GdkRGBA color = { 0.0, 0.0, 0.0, 1.0 };
-# if PANGO_VERSION_CHECK(1,38,0)
+# if PANGO_VERSION_CHECK(1,38,0)
PangoAttribute *attr_alpha;
-# endif
-#else
+# endif
+# else
GdkColor color = { 0, 0, 0, 0 };
-#endif
+# endif
// Look up the RGB values of the SpecialKey foreground color.
aep = syn_gui_attr2entry(HL_ATTR(HLF_8));
pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR;
if (pixel != INVALCOLOR)
-# if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
{
color.red = ((pixel & 0xff0000) >> 16) / 255.0;
color.green = ((pixel & 0xff00) >> 8) / 255.0;
color.blue = (pixel & 0xff) / 255.0;
color.alpha = 1.0;
}
-# else
+# else
gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea),
(unsigned long)pixel, &color);
-# endif
+# endif
pdest = buf;
p = text;
}
if (pixel != INVALCOLOR)
{
-#if GTK_CHECK_VERSION(3,0,0)
-# define DOUBLE2UINT16(val) ((guint16)((val) * 65535 + 0.5))
+# if GTK_CHECK_VERSION(3,0,0)
+# define DOUBLE2UINT16(val) ((guint16)((val) * 65535 + 0.5))
attr = pango_attr_foreground_new(
DOUBLE2UINT16(color.red),
DOUBLE2UINT16(color.green),
DOUBLE2UINT16(color.blue));
-# if PANGO_VERSION_CHECK(1,38,0)
+# if PANGO_VERSION_CHECK(1,38,0)
attr_alpha = pango_attr_foreground_alpha_new(
DOUBLE2UINT16(color.alpha));
-# endif
-# undef DOUBLE2UINT16
-#else
+# endif
+# undef DOUBLE2UINT16
+# else
attr = pango_attr_foreground_new(
color.red, color.green, color.blue);
-#endif
+# endif
attr->start_index = pdest - buf;
attr->end_index = pdest - buf + outlen;
pango_attr_list_insert(attr_list, attr);
-#if GTK_CHECK_VERSION(3,0,0)
-# if PANGO_VERSION_CHECK(1,38,0)
+# if GTK_CHECK_VERSION(3,0,0)
+# if PANGO_VERSION_CHECK(1,38,0)
attr_alpha->start_index = pdest - buf;
attr_alpha->end_index = pdest - buf + outlen;
pango_attr_list_insert(attr_list, attr_alpha);
-# endif
-#endif
+# endif
+# endif
}
pdest += outlen;
p += charlen;
gtk_label_set_attributes(label, attr_list);
pango_attr_list_unref(attr_list);
}
-# undef IS_NONPRINTABLE
+# undef IS_NONPRINTABLE
/*
* Draw a balloon.
int y_offset = EVAL_OFFSET_Y;
PangoLayout *layout;
-# if !GTK_CHECK_VERSION(3,22,2)
+# if !GTK_CHECK_VERSION(3,22,2)
GdkScreen *screen;
screen = gtk_widget_get_screen(beval->target);
gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
-# endif
+# endif
gui_gtk_get_screen_geom_of_win(beval->target, 0, 0,
&screen_x, &screen_y, &screen_w, &screen_h);
-# if !GTK_CHECK_VERSION(3,0,0)
+# if !GTK_CHECK_VERSION(3,0,0)
gtk_widget_ensure_style(beval->balloonShell);
gtk_widget_ensure_style(beval->balloonLabel);
-# endif
+# endif
set_printable_label_text(GTK_LABEL(beval->balloonLabel), beval->msg);
/*
* builtin maximum value of about 65 Latin characters.
*/
layout = gtk_label_get_layout(GTK_LABEL(beval->balloonLabel));
-# ifdef PANGO_WRAP_WORD_CHAR
+# ifdef PANGO_WRAP_WORD_CHAR
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
-# else
+# else
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
-# endif
+# endif
pango_layout_set_width(layout,
// try to come up with some reasonable width
PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width,
MAX(20, screen_w - 20)));
// Calculate the balloon's width and height.
-# if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
gtk_widget_get_preferred_size(beval->balloonShell, &requisition, NULL);
-# else
+# else
gtk_widget_size_request(beval->balloonShell, &requisition);
-# endif
+# endif
// Compute position of the balloon area
gdk_window_get_origin(gtk_widget_get_window(beval->target), &x, &y);
MAX(0, screen_y + screen_h - requisition.height));
// Show the balloon
-# if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
gtk_window_move(GTK_WINDOW(beval->balloonShell), x, y);
-# else
+# else
gtk_widget_set_uposition(beval->balloonShell, x, y);
-# endif
+# endif
gtk_widget_show(beval->balloonShell);
beval->showState = ShS_SHOWING;
gtk_widget_set_name(beval->balloonShell, "gtk-tooltips");
gtk_container_set_border_width(GTK_CONTAINER(beval->balloonShell), 4);
-# if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
g_signal_connect(G_OBJECT(beval->balloonShell), "draw",
G_CALLBACK(balloon_draw_event_cb), NULL);
-# else
+# else
gtk_signal_connect((GtkObject*)(beval->balloonShell), "expose_event",
GTK_SIGNAL_FUNC(balloon_expose_event_cb), NULL);
-# endif
+# endif
beval->balloonLabel = gtk_label_new(NULL);
gtk_label_set_line_wrap(GTK_LABEL(beval->balloonLabel), FALSE);
gtk_label_set_justify(GTK_LABEL(beval->balloonLabel), GTK_JUSTIFY_LEFT);
-# if GTK_CHECK_VERSION(3,16,0)
+# if GTK_CHECK_VERSION(3,16,0)
gtk_label_set_xalign(GTK_LABEL(beval->balloonLabel), 0.5);
gtk_label_set_yalign(GTK_LABEL(beval->balloonLabel), 0.5);
-# elif GTK_CHECK_VERSION(3,14,0)
+# elif GTK_CHECK_VERSION(3,14,0)
GValue align_val = G_VALUE_INIT;
g_value_init(&align_val, G_TYPE_FLOAT);
g_value_set_float(&align_val, 0.5);
g_object_set_property(G_OBJECT(beval->balloonLabel), "xalign", &align_val);
g_object_set_property(G_OBJECT(beval->balloonLabel), "yalign", &align_val);
g_value_unset(&align_val);
-# else
+# else
gtk_misc_set_alignment(GTK_MISC(beval->balloonLabel), 0.5f, 0.5f);
-# endif
+# endif
gtk_widget_set_name(beval->balloonLabel, "vim-balloon-label");
gtk_widget_show(beval->balloonLabel);
gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel);
}
-#else // !FEAT_GUI_GTK
+# else // !FEAT_GUI_GTK
/*
* Draw a balloon.
xmLabelWidgetClass, beval->balloonShell, args, n);
}
-#endif // !FEAT_GUI_GTK
+# endif // !FEAT_GUI_GTK
#endif // !FEAT_GUI_MSWIN
#endif // FEAT_BEVAL_GUI
gtk_menu_popup_at_pointer(GTK_MENU(menu->submenu_id),
(GdkEvent *)&trigger);
}
-#else
+# else
gtk_menu_popup(GTK_MENU(menu->submenu_id),
NULL, NULL,
(GtkMenuPositionFunc)NULL, NULL,
3U, gui.event_time);
-#endif
+# endif
}
// Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to
int wword = FALSE;
int mcase = !p_ic;
char_u *conv_buffer = NULL;
-# define CONV(message) convert_localized_message(&conv_buffer, (message))
+#define CONV(message) convert_localized_message(&conv_buffer, (message))
frdp = (do_replace) ? (&repl_widgets) : (&find_widgets);
#define __GTK_FORM_H__
#ifdef USE_GTK3
-#include <gtk/gtk.h>
+# include <gtk/gtk.h>
#else
-#include <gdk/gdk.h>
-#include <gtk/gtkcontainer.h>
+# include <gdk/gdk.h>
+# include <gtk/gtkcontainer.h>
#endif
#define GTK_TYPE_FORM (gui_gtk_form_get_type ())
#ifdef USE_GTK3
-#define GTK_FORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_FORM, GtkForm))
-#define GTK_FORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_FORM, GtkFormClass))
-#define GTK_IS_FORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_FORM))
-#define GTK_IS_FORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_FORM))
+# define GTK_FORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_FORM, GtkForm))
+# define GTK_FORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_FORM, GtkFormClass))
+# define GTK_IS_FORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_FORM))
+# define GTK_IS_FORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_FORM))
#else
-#define GTK_FORM(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_FORM, GtkForm))
-#define GTK_FORM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_FORM, GtkFormClass))
-#define GTK_IS_FORM(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_FORM))
-#define GTK_IS_FORM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FORM))
+# define GTK_FORM(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_FORM, GtkForm))
+# define GTK_FORM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_FORM, GtkFormClass))
+# define GTK_IS_FORM(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_FORM))
+# define GTK_IS_FORM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FORM))
#endif
#include "vim.h"
#ifdef USE_GRESOURCE
-#include "auto/gui_gtk_gresources.h"
+# include "auto/gui_gtk_gresources.h"
#endif
#ifdef FEAT_GUI_GNOME
* "Monospace" is a standard font alias that should be present
* on all proper Pango/fontconfig installations.
*/
-# define DEFAULT_FONT "Monospace 12"
+#define DEFAULT_FONT "Monospace 12"
#if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION)
# define USE_GNOME_SESSION
gui_mch_free_all(void)
{
vim_free(gui_argv);
-#if defined(USE_GNOME_SESSION)
+# if defined(USE_GNOME_SESSION)
vim_free(abs_restart_command);
-#endif
-#ifdef TRACK_RESIZE_HISTORY
+# endif
+# ifdef TRACK_RESIZE_HISTORY
free_all_resize_hist();
-#endif
+# endif
}
#endif
int_u vim_modifiers;
#if GTK_CHECK_VERSION(3,4,0)
static double acc_x, acc_y;
-#if !GTK_CHECK_VERSION(3,22,0)
+# if !GTK_CHECK_VERSION(3,22,0)
static guint32 last_smooth_event_time;
-#endif
-#define DT_X11 1
-#define DT_WAYLAND 2
+# endif
+# define DT_X11 1
+# define DT_WAYLAND 2
static int display_type;
if (!display_type)
display_type = gui_mch_get_display() ? DT_X11 : DT_WAYLAND;
// this event tells us to stop, without an actual moving
return FALSE;
}
-#if GTK_CHECK_VERSION(3,22,0)
+# if GTK_CHECK_VERSION(3,22,0)
if (gdk_device_get_axes(event->device) & GDK_AXIS_FLAG_WHEEL)
// this is from a wheel (as oppose to a touchpad / trackpoint)
-#else
+# else
if (event->time - last_smooth_event_time > 50)
// reset our accumulations after 50ms of silence
-#endif
+# endif
acc_x = acc_y = 0;
acc_x += event->delta_x;
acc_y += event->delta_y;
-#if !GTK_CHECK_VERSION(3,22,0)
+# if !GTK_CHECK_VERSION(3,22,0)
last_smooth_event_time = event->time;
-#endif
+# endif
break;
#endif
default: // This shouldn't happen
return FALSE;
}
-# ifdef FEAT_XIM
+#ifdef FEAT_XIM
// cancel any preediting
if (im_is_preediting())
xim_reset();
-# endif
+#endif
vim_modifiers = modifiers_gdk2mouse(event->state);
// for X11 we deal with unsmooth events, and so ignore the smooth ones
;
else
-#undef DT_X11
-#undef DT_WAYLAND
+# undef DT_X11
+# undef DT_WAYLAND
#endif
gui_send_mouse_event(button, (int)event->x, (int)event->y,
FALSE, vim_modifiers);
// otherwise the hints don't work.
width = gui_get_base_width();
height = gui_get_base_height();
-# ifdef FEAT_MENU
+#ifdef FEAT_MENU
height += tabline_height() * gui.char_height;
-# endif
+#endif
width += get_menu_tool_width();
height += get_menu_tool_height();
else
update_window_manager_hints(width, height);
-# if !GTK_CHECK_VERSION(3,0,0)
-# if 0
+#if !GTK_CHECK_VERSION(3,0,0)
+# if 0
if (!resize_idle_installed)
{
g_idle_add_full(GDK_PRIORITY_EVENTS + 10,
&force_shell_resize_idle, NULL, NULL);
resize_idle_installed = TRUE;
}
-# endif
-# endif // !GTK_CHECK_VERSION(3,0,0)
+# endif
+#endif // !GTK_CHECK_VERSION(3,0,0)
/*
* Wait until all events are processed to prevent a crash because the
* real size of the drawing area doesn't reflect Vim's internal ideas.
*/
static void gui_motif_add_actext(vimmenu_T *menu);
-#if (XmVersion >= 1002)
+# if (XmVersion >= 1002)
static void toggle_tearoff(Widget wid);
static void gui_mch_recurse_tearoffs(vimmenu_T *menu);
-#endif
+# endif
static void submenu_change(vimmenu_T *mp, int colors);
static void do_set_mnemonics(int enable);
if (flag)
{
XtManageChild(menuBar);
-#ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
if (XtIsManaged(XtParent(toolBar)))
{
// toolBar is attached to top form
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, menuBar,
NULL);
-#ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
if (showing_tabline)
{
XtVaSetValues(tabLine,
NULL);
}
else
-#endif
+# endif
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, XtParent(toolBar),
NULL);
}
else
-#endif
+# endif
{
-#ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
if (showing_tabline)
{
XtVaSetValues(tabLine,
NULL);
}
else
-#endif
+# endif
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, menuBar,
else
{
XtUnmanageChild(menuBar);
-#ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
if (XtIsManaged(XtParent(toolBar)))
{
XtVaSetValues(XtParent(toolBar),
XmNtopAttachment, XmATTACH_FORM,
NULL);
-#ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
if (showing_tabline)
{
XtVaSetValues(tabLine,
NULL);
}
else
-#endif
+# endif
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, XtParent(toolBar),
NULL);
}
else
-#endif
+# endif
{
-#ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
if (showing_tabline)
{
XtVaSetValues(tabLine,
NULL);
}
else
-#endif
+# endif
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_FORM,
NULL);
Widget shell;
vimmenu_T *parent = menu->parent;
-#ifdef MOTIF_POPUP
+# ifdef MOTIF_POPUP
if (menu_is_popup(menu->name))
{
Arg arg[2];
// Only create the popup menu when it's actually used, otherwise there
// is a delay when using the right mouse button.
-# if (XmVersion <= 1002)
+# if (XmVersion <= 1002)
if (mouse_model_popup())
-# endif
+# endif
{
if (gui.menu_bg_pixel != INVALCOLOR)
{
}
return;
}
-#endif
+# endif
if (!menu_is_menubar(menu->name)
|| (parent != NULL && parent->submenu_id == (Widget)0))
(parent == NULL) ? menuBar : parent->submenu_id,
XmNlabelString, label,
XmNmnemonic, p_wak[0] == 'n' ? NUL : menu->mnemonic,
-#if (XmVersion >= 1002)
+# if (XmVersion >= 1002)
// submenu: count the tearoff item (needed for LessTif)
XmNpositionIndex, idx + (parent != NULL
&& tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0),
-#endif
+# endif
NULL);
XmStringFree(label);
if (menu->submenu_id == (Widget)0) // failed
return;
-#if (XmVersion >= 1002)
+# if (XmVersion >= 1002)
// Set the colors for the tear off widget
toggle_tearoff(menu->submenu_id);
-#endif
+# endif
XtVaSetValues(menu->id,
XmNsubMenuId, menu->submenu_id,
void
gui_mch_toggle_tearoffs(int enable)
{
-#if (XmVersion >= 1002)
+# if (XmVersion >= 1002)
if (enable)
tearoff_val = (int)XmTEAR_OFF_ENABLED;
else
tearoff_val = (int)XmTEAR_OFF_DISABLED;
toggle_tearoff(menuBar);
gui_mch_recurse_tearoffs(root_menu);
-#endif
+# endif
}
-#if (XmVersion >= 1002)
+# if (XmVersion >= 1002)
/*
* Set the tearoff for one menu widget on or off, and set the color of the
* tearoff widget.
menu = menu->next;
}
}
-#endif
+# endif
int
gui_mch_text_area_extra_height(void)
XtVaSetValues(menuBar, XmNheight, gui.menu_height, NULL);
}
-#ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
/*
* Icons used by the toolbar code.
*/
-#include "gui_x11_pm.h"
+# include "gui_x11_pm.h"
static char **get_toolbar_pixmap(vimmenu_T *menu, char **fname);
}
return n;
}
-#endif // FEAT_TOOLBAR
+# endif // FEAT_TOOLBAR
void
gui_mch_add_menu_item(vimmenu_T *menu, int idx)
if (xms != NULL)
XmStringFree(xms);
-# ifdef FEAT_BEVAL_GUI
+# ifdef FEAT_BEVAL_GUI
gui_mch_menu_set_tip(menu);
-# endif
+# endif
menu->parent = parent;
menu->submenu_id = NULL;
{
menu->id = XtVaCreateWidget("subMenu",
xmSeparatorGadgetClass, parent->submenu_id,
-#if (XmVersion >= 1002)
+# if (XmVersion >= 1002)
// count the tearoff item (needed for LessTif)
XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED
? 1 : 0),
-#endif
+# endif
NULL);
gui_motif_menu_colors(menu->id);
return;
xmPushButtonWidgetClass, parent->submenu_id,
XmNlabelString, label,
XmNmnemonic, menu->mnemonic,
-#if (XmVersion >= 1002)
+# if (XmVersion >= 1002)
// count the tearoff item (needed for LessTif)
XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED
? 1 : 0),
-#endif
+# endif
NULL);
gui_motif_menu_colors(menu->id);
gui_motif_menu_fontlist(menu->id);
}
}
-#if (XmVersion <= 1002)
+# if (XmVersion <= 1002)
/*
* This function will destroy/create the popup menus dynamically,
* according to the value of 'mousemodel'.
++idx;
}
}
-#endif
+# endif
void
gui_mch_new_menu_colors(void)
if (menuBar == (Widget)0)
return;
gui_motif_menu_colors(menuBar);
-#ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
gui_motif_menu_colors(toolBarFrame);
gui_motif_menu_colors(toolBar);
-#endif
+# endif
submenu_change(root_menu, TRUE);
}
XtVaGetValues(vimShell, XtNwidth, &w, XtNheight, &h, NULL);
gui_resize_shell(w, h
-#ifdef FEAT_XIM
+# ifdef FEAT_XIM
- xim_get_status_area_height()
-#endif
+# endif
);
}
gui_set_shellsize(FALSE, TRUE, RESIZE_VERT);
ui_new_shellsize();
}
-#if defined(FEAT_BEVAL_GUI)
+# if defined(FEAT_BEVAL_GUI)
void
gui_mch_new_tooltip_font(void)
{
-# ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
vimmenu_T *menu;
if (toolBar == (Widget)0)
menu = gui_find_menu((char_u *)"ToolBar");
if (menu != NULL)
submenu_change(menu, FALSE);
-# endif
+# endif
}
void
gui_mch_new_tooltip_colors(void)
{
-# ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
vimmenu_T *toolbar;
if (toolBar == (Widget)0)
toolbar = gui_find_menu((char_u *)"ToolBar");
if (toolbar != NULL)
submenu_change(toolbar, TRUE);
-# endif
+# endif
}
-#endif
+# endif
static void
submenu_change(
if (colors)
{
gui_motif_menu_colors(mp->id);
-#ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
// For a toolbar item: Free the pixmap and allocate a new one,
// so that the background color is right.
if (mp->xpm != NULL)
n = add_pixmap_args(mp, args, n);
XtSetValues(mp->id, args, n);
}
-# ifdef FEAT_BEVAL_GUI
+# ifdef FEAT_BEVAL_GUI
// If we have a tooltip, then we need to change its font
if (mp->tip != NULL)
{
args[1].value = gui.tooltip_fg_pixel;
XtSetValues(mp->tip->balloonLabel, &args[0], XtNumber(args));
}
+# endif
# endif
-#endif
}
else
{
gui_motif_menu_fontlist(mp->id);
-#ifdef FEAT_BEVAL_GUI
+# ifdef FEAT_BEVAL_GUI
// If we have a tooltip, then we need to change its font
if (mp->tip != NULL)
{
&gui.tooltip_fontset);
XtSetValues(mp->tip->balloonLabel, &args[0], XtNumber(args));
}
-#endif
+# endif
}
}
if (mp->children != NULL)
{
-#if (XmVersion >= 1002)
+# if (XmVersion >= 1002)
// Set the colors/font for the tear off widget
if (mp->submenu_id != (Widget)0)
{
gui_motif_menu_fontlist(mp->submenu_id);
toggle_tearoff(mp->submenu_id);
}
-#endif
+# endif
// Set the colors for the children
submenu_change(mp->children, colors);
}
Widget parent;
parent = XtParent(menu->id);
-#if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI)
+# if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI)
if (parent == toolBar && menu->tip != NULL)
{
// We try to destroy this before the actual menu, because there are
gui_mch_destroy_beval_area(menu->tip);
menu->tip = NULL;
}
-#endif
+# endif
XtDestroyWidget(menu->id);
menu->id = (Widget)0;
if (parent == menuBar)
gui_mch_compute_menu_height((Widget)0);
-#ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
else if (parent == toolBar)
{
Cardinal num_children;
else
gui.toolbar_height = gui_mch_compute_toolbar_height();
}
-#endif
+# endif
}
void
gui_mch_show_popupmenu(vimmenu_T *menu UNUSED)
{
-#ifdef MOTIF_POPUP
+# ifdef MOTIF_POPUP
XmMenuPosition(menu->submenu_id, gui_x11_get_last_mouse_event());
XtManageChild(menu->submenu_id);
-#endif
+# endif
}
#endif // FEAT_MENU
{
XmFontList fl;
-#ifdef FONTSET_ALWAYS
+# ifdef FONTSET_ALWAYS
if (gui.fontset != NOFONTSET)
{
fl = gui_motif_fontset2fontlist((XFontSet *)&gui.fontset);
XmFontListFree(fl);
}
}
-#else
+# else
if (gui.norm_font != NOFONT)
{
fl = gui_motif_create_fontlist((XFontStruct *)gui.norm_font);
XmFontListFree(fl);
}
}
-#endif
+# endif
}
#endif
* file selector related stuff
*/
-#include <Xm/FileSB.h>
-#include <Xm/XmStrDefs.h>
+# include <Xm/FileSB.h>
+# include <Xm/XmStrDefs.h>
typedef struct dialog_callback_arg
{
dialogStatus = (int)(long)client_data + 1;
}
-#ifdef HAVE_XPM
+# ifdef HAVE_XPM
static Widget
create_pixmap_label(
return label;
}
-#endif
+# endif
int
gui_mch_dialog(
Widget separator = NULL;
int n;
Arg args[6];
-#ifdef HAVE_XPM
+# ifdef HAVE_XPM
char **icon_data = NULL;
Widget dialogpixmap = NULL;
-#endif
+# endif
if (title == NULL)
title = (char_u *)_("Vim dialog");
NULL);
XtManageChild(form);
-#ifdef HAVE_XPM
+# ifdef HAVE_XPM
// Add a pixmap, left of the message.
switch (type)
{
dialogpixmap = create_pixmap_label(form, "dialogPixmap",
icon_data, args, n);
XtManageChild(dialogpixmap);
-#endif
+# endif
// Create the dialog message.
// Since LessTif is apparently having problems with the creation of
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_FORM,
XmNtopOffset, 8,
-#ifdef HAVE_XPM
+# ifdef HAVE_XPM
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, dialogpixmap,
-#else
+# else
XmNleftAttachment, XmATTACH_FORM,
-#endif
+# endif
XmNleftOffset, 8,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 8,
}
gui.toolbar_height = gui_mch_compute_toolbar_height();
XtManageChild(XtParent(toolBar));
-#ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
if (showing_tabline)
{
XtVaSetValues(tabLine,
NULL);
}
else
-#endif
+# endif
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, XtParent(toolBar),
gui.toolbar_height = 0;
if (XtIsManaged(menuBar))
{
-#ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
if (showing_tabline)
{
XtVaSetValues(tabLine,
NULL);
}
else
-#endif
+# endif
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, menuBar,
}
else
{
-#ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
if (showing_tabline)
{
XtVaSetValues(tabLine,
NULL);
}
else
-#endif
+# endif
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_FORM,
NULL);
height = whgt;
}
}
-#ifdef LESSTIF_VERSION
+# ifdef LESSTIF_VERSION
// Hack: When starting up we get wrong dimensions.
if (height < 10)
height = 24;
-#endif
+# endif
return (int)(height + (borders << 1));
}
XtUnmanageChild(XtNameToWidget(tabLine, "MinorTabScrollerNext"));
XtUnmanageChild(XtNameToWidget(tabLine,
"MinorTabScrollerPrevious"));
-#ifdef FEAT_MENU
-# ifdef FEAT_TOOLBAR
+# ifdef FEAT_MENU
+# ifdef FEAT_TOOLBAR
if (XtIsManaged(XtParent(toolBar)))
XtVaSetValues(tabLine,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, XtParent(toolBar), NULL);
else
-# endif
+# endif
if (XtIsManaged(menuBar))
XtVaSetValues(tabLine,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, menuBar, NULL);
else
-#endif
+# endif
XtVaSetValues(tabLine,
XmNtopAttachment, XmATTACH_FORM, NULL);
XtVaSetValues(textAreaForm,
else
{
XtUnmanageChild(tabLine);
-#ifdef FEAT_MENU
-# ifdef FEAT_TOOLBAR
+# ifdef FEAT_MENU
+# ifdef FEAT_TOOLBAR
if (XtIsManaged(XtParent(toolBar)))
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, XtParent(toolBar), NULL);
else
-# endif
+# endif
if (XtIsManaged(menuBar))
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, menuBar, NULL);
else
-#endif
+# endif
XtVaSetValues(textAreaForm,
XmNtopAttachment, XmATTACH_FORM, NULL);
}
gui_motif_menu_fontlist(Widget id UNUSED)
{
#ifdef FEAT_MENU
-#ifdef FONTSET_ALWAYS
+# ifdef FONTSET_ALWAYS
if (gui.menu_fontset != NOFONTSET)
{
XmFontList fl;
XmFontListFree(fl);
}
}
-#else
+# else
if (gui.menu_font != NOFONT)
{
XmFontList fl;
XmFontListFree(fl);
}
}
-#endif
+# endif
#endif
}
}
}
}
-#ifndef FEAT_GUI_TEXTDIALOG
+# ifndef FEAT_GUI_TEXTDIALOG
dialog_result = PtAlert(
gui.vimWindow, NULL,
title,
message, NULL,
button_count, (const char **) button_array, NULL,
default_button, 0, Pt_MODAL);
-#else
+# else
// Writing the dialog ourselves lets us add extra features, like
// trapping the escape key and returning 0 to vim
{
PtDestroyWidget(dialog);
gui_ph_dialog_text = NULL;
}
-#endif
+# endif
}
vim_free(button_array);
g = PgGreenValue(gui_ph_mouse_color) ^ 255;
b = PgBlueValue(gui_ph_mouse_color) ^ 255;
-#ifndef FEAT_MOUSESHAPE
+# ifndef FEAT_MOUSESHAPE
gui_ph_mouse_color = PgRGB(r, g, b);
PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_COLOR,
gui_ph_mouse_color, 0);
-#endif
+# endif
}
#endif
// Menu
#ifdef FEAT_TOOLBAR
-#include "toolbar.phi"
+# include "toolbar.phi"
static PhImage_t *gui_ph_toolbar_images[] = {
&tb_new_phi,
n = 0;
PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0);
-#ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
if (menu_is_toolbar(parent->name))
{
if (menu_is_separator(menu->name))
PtRealizeWidget(menu->id);
}
else
-#endif
+# endif
if (menu_is_separator(menu->name))
{
menu->id = PtCreateWidget(PtSeparator, parent->submenu_id, n, args);
PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu);
-#ifdef USE_PANEL_GROUP
+# ifdef USE_PANEL_GROUP
if (gui_ph_is_buffer_item(menu, parent) == TRUE)
{
PtAddCallback(menu->id, Pt_CB_DESTROYED,
gui_ph_handle_buffer_remove, menu);
gui_ph_pg_add_buffer(menu->dname);
}
-#endif
+# endif
}
gui_ph_position_menu(menu->id, menu->priority);
# ifdef FONTSET_ALWAYS
XtNmenuFontSet,
XtCMenuFontSet,
-#else
+# else
XtNmenuFont,
XtCMenuFont,
-#endif
+# endif
XtRString,
sizeof(char *),
XtOffsetOf(gui_T, rsrc_menu_font_name),
# define CARDINAL (Cardinal *)
#else
# if XtSpecificationRelease == 4
-# define CARDINAL (Cardinal *)
+# define CARDINAL (Cardinal *)
# else
-# define CARDINAL (int *)
+# define CARDINAL (int *)
# endif
#endif
cmdline_options, XtNumber(cmdline_options),
CARDINAL &gui_argc, gui_argv);
-# if defined(LC_NUMERIC)
+#if defined(LC_NUMERIC)
{
// The call to XtOpenDisplay() may have set the locale from the
// environment. Set LC_NUMERIC to "C" to make sure that strtod() uses a
if (p == NULL || strcmp(p, "C") != 0)
setlocale(LC_NUMERIC, "C");
}
-# endif
+#endif
if (app_context == NULL || gui.dpy == NULL)
{
gui.dying = TRUE;
{
XrmValue from, to;
-#ifdef FONTSET_ALWAYS
+# ifdef FONTSET_ALWAYS
from.addr = (char *)gui.rsrc_menu_font_name;
from.size = strlen(from.addr);
to.addr = (XtPointer)&gui.menu_fontset;
{
// Failed. What to do?
}
-#else
+# else
from.addr = (char *)gui.rsrc_menu_font_name;
from.size = strlen(from.addr);
to.addr = (XtPointer)&gui.menu_font;
{
// Failed. What to do?
}
-#endif
+# endif
}
#endif
return extents->max_logical_extent.height;
}
-#if 0
+# if 0
// NOT USED YET
static int
fontset_descent(XFontSet fs)
extents = XExtentsOfFontSet (fs);
return extents->max_logical_extent.height + extents->max_logical_extent.y;
}
-#endif
+# endif
static int
fontset_ascent(XFontSet fs)
gui_mch_menu_hidden(menu, False);
if (grey
-#ifdef FEAT_GUI_MOTIF
+# ifdef FEAT_GUI_MOTIF
|| !menu->sensitive
-#endif
+# endif
)
XtSetSensitive(menu->id, False);
else
im_preedit_window_open(void)
{
char *preedit_string;
-#if !GTK_CHECK_VERSION(3,16,0)
+# if !GTK_CHECK_VERSION(3,16,0)
char buf[8];
-#endif
+# endif
PangoAttrList *attr_list;
PangoLayout *layout;
-#if GTK_CHECK_VERSION(3,0,0)
-# if !GTK_CHECK_VERSION(3,16,0)
+# if GTK_CHECK_VERSION(3,0,0)
+# if !GTK_CHECK_VERSION(3,16,0)
GdkRGBA color;
-# endif
-#else
+# endif
+# else
GdkColor color;
-#endif
+# endif
gint w, h;
if (preedit_window == NULL)
gtk_container_add(GTK_CONTAINER(preedit_window), preedit_label);
}
-#if GTK_CHECK_VERSION(3,16,0)
+# if GTK_CHECK_VERSION(3,16,0)
{
GtkStyleContext * const context
= gtk_widget_get_style_context(preedit_label);
g_free(fontsize_propval);
g_object_unref(provider);
}
-#elif GTK_CHECK_VERSION(3,0,0)
+# elif GTK_CHECK_VERSION(3,0,0)
gtk_widget_override_font(preedit_label, gui.norm_font);
vim_snprintf(buf, sizeof(buf), "#%06X", gui.norm_pixel);
gdk_rgba_parse(&color, buf);
gtk_widget_override_background_color(preedit_label, GTK_STATE_FLAG_NORMAL,
&color);
-#else
+# else
gtk_widget_modify_font(preedit_label, gui.norm_font);
vim_snprintf(buf, sizeof(buf), "#%06X", (unsigned)gui.norm_pixel);
vim_snprintf(buf, sizeof(buf), "#%06X", (unsigned)gui.back_pixel);
gdk_color_parse(buf, &color);
gtk_widget_modify_bg(preedit_window, GTK_STATE_NORMAL, &color);
-#endif
+# endif
gtk_im_context_get_preedit_string(xic, &preedit_string, &attr_list, NULL);
}
if (State & MODE_NORMAL
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
&& !term_use_loop()
-#endif
+# endif
)
{
im_preedit_cursor = 0;
int commit_with_preedit = TRUE;
char_u *im_str;
-#ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("im_commit_cb(): %s\n", str);
-#endif
+# endif
if (p_imst == IM_ON_THE_SPOT)
{
static void
im_preedit_start_cb(GtkIMContext *context UNUSED, gpointer data UNUSED)
{
-#ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("im_preedit_start_cb()\n");
-#endif
+# endif
im_is_active = TRUE;
preedit_is_active = TRUE;
static void
im_preedit_end_cb(GtkIMContext *context UNUSED, gpointer data UNUSED)
{
-#ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("im_preedit_end_cb()\n");
-#endif
+# endif
im_delete_preedit();
// Indicate that preediting has finished
preedit_start_col = MAXCOL;
xim_has_preediting = FALSE;
-#if 0
+# if 0
// Removal of this line suggested by Takuhiro Nishioka. Fixes that IM was
// switched off unintentionally. We now use preedit_is_active (added by
// SungHyun Nam).
im_is_active = FALSE;
-#endif
+# endif
preedit_is_active = FALSE;
gui_update_cursor(TRUE, FALSE);
im_show_info();
&preedit_string, NULL,
NULL);
-#ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("im_preedit_changed_cb(): %s\n", preedit_string);
-#endif
+# endif
g_return_if_fail(preedit_string != NULL); // just in case
void
xim_init(void)
{
-#ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("xim_init()\n");
-#endif
+# endif
g_return_if_fail(gui.drawarea != NULL);
g_return_if_fail(gtk_widget_get_window(gui.drawarea) != NULL);
void
im_shutdown(void)
{
-#ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("im_shutdown()\n");
-#endif
+# endif
if (xic != NULL)
{
void
xim_reset(void)
{
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (USE_IMACTIVATEFUNC)
call_imactivatefunc(im_is_active);
else
-# endif
+# endif
if (xic != NULL)
{
gtk_im_context_reset(xic);
int
xim_queue_key_press_event(GdkEventKey *event, int down)
{
-#ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
if (event->state & GDK_SUPER_MASK) return FALSE;
-#endif
+# endif
if (down)
{
// Workaround GTK2 XIM 'feature' that always converts keypad keys to
static int xim_real_init(Window x11_window, Display *x11_display);
-# ifdef USE_X11R6_XIM
+# ifdef USE_X11R6_XIM
static void
xim_instantiate_cb(
Display *display,
Window x11_window;
Display *x11_display;
-# ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("xim_instantiate_cb()\n");
-# endif
+# endif
gui_get_x11_windis(&x11_window, &x11_display);
if (display != x11_display)
Window x11_window;
Display *x11_display;
-# ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("xim_destroy_cb()\n");
- #endif
+# endif
gui_get_x11_windis(&x11_window, &x11_display);
xic = NULL;
XRegisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
xim_instantiate_cb, NULL);
}
-# endif
+# endif
void
xim_init(void)
Window x11_window;
Display *x11_display;
-# ifdef XIM_DEBUG
+# ifdef XIM_DEBUG
xim_log("xim_init()\n");
-# endif
+# endif
gui_get_x11_windis(&x11_window, &x11_display);
gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
-# ifdef USE_X11R6_XIM
+# ifdef USE_X11R6_XIM
XRegisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
xim_instantiate_cb, NULL);
-# endif
+# endif
}
static int
*ns,
*end,
tmp[1024];
-# define IMLEN_MAX 40
+# define IMLEN_MAX 40
char buf[IMLEN_MAX + 7];
XIM xim = NULL;
XIMStyles *xim_styles;
return FALSE;
}
-# ifdef USE_X11R6_XIM
+# ifdef USE_X11R6_XIM
{
XIMCallback destroy_cb;
if (XSetIMValues(xim, XNDestroyCallback, &destroy_cb, NULL))
emsg(_(e_warning_could_not_set_destroy_callback_to_im));
}
-# endif
+# endif
if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles)
{
// A crash was reported when trying to pass gui.norm_font as XNFontSet,
// thus that has been removed. Hopefully the default works...
-# ifdef FEAT_XFONTSET
+# ifdef FEAT_XFONTSET
if (gui.fontset != NOFONTSET)
{
preedit_list = XVaCreateNestedList(0,
NULL);
}
else
-# endif
+# endif
{
preedit_list = XVaCreateNestedList(0,
XNSpotLocation, &over_spot,
status_area.y = gui.char_height * Rows + gui.border_offset;
if (gui.which_scrollbars[SBAR_BOTTOM])
status_area.y += gui.scrollbar_height;
-#ifdef FEAT_MENU
+# ifdef FEAT_MENU
if (gui.menu_is_active)
status_area.y += gui.menu_height;
-#endif
+# endif
status_area.height = gui.char_height;
status_list = XVaCreateNestedList(0, XNArea, &status_area, NULL);
}
status_area.y = gui.char_height * Rows + gui.border_offset;
if (gui.which_scrollbars[SBAR_BOTTOM])
status_area.y += gui.scrollbar_height;
-#ifdef FEAT_MENU
+# ifdef FEAT_MENU
if (gui.menu_is_active)
status_area.y += gui.menu_height;
-#endif
+# endif
status_area.width = 0;
status_area.height = gui.char_height;
}
pre_area.width = gui.char_width * Columns - pre_area.x;
if (gui.which_scrollbars[SBAR_BOTTOM])
pre_area.y += gui.scrollbar_height;
-#ifdef FEAT_MENU
+# ifdef FEAT_MENU
if (gui.menu_is_active)
pre_area.y += gui.menu_height;
-#endif
+# endif
pre_area.height = gui.char_height;
preedit_list = XVaCreateNestedList(0, XNArea, &pre_area, NULL);
}
CLEAR_FIELD(settings);
settings.has_color = TRUE;
-# ifdef FEAT_POSTSCRIPT
+#ifdef FEAT_POSTSCRIPT
if (*eap->arg == '>')
{
char *errormsg = NULL;
}
else if (*eap->arg != NUL)
settings.arguments = eap->arg;
-# endif
+#endif
/*
* Initialise for printing. Ask the user for settings, unless forceit is
return col;
}
-# if defined(FEAT_POSTSCRIPT)
+#if defined(FEAT_POSTSCRIPT)
/*
* PS printer stuff.
* http://www.adobe.com
*/
-#define PRT_PS_DEFAULT_DPI (72) // Default user space resolution
-#define PRT_PS_DEFAULT_FONTSIZE (10)
-#define PRT_PS_DEFAULT_BUFFER_SIZE (80)
+# define PRT_PS_DEFAULT_DPI (72) // Default user space resolution
+# define PRT_PS_DEFAULT_FONTSIZE (10)
+# define PRT_PS_DEFAULT_BUFFER_SIZE (80)
struct prt_mediasize_S
{
float height;
};
-#define PRT_MEDIASIZE_LEN ARRAY_LENGTH(prt_mediasize)
+# define PRT_MEDIASIZE_LEN ARRAY_LENGTH(prt_mediasize)
static struct prt_mediasize_S prt_mediasize[] =
{
char *(ps_fontname[4]);
};
-#define PRT_PS_FONT_ROMAN (0)
-#define PRT_PS_FONT_BOLD (1)
-#define PRT_PS_FONT_OBLIQUE (2)
-#define PRT_PS_FONT_BOLDOBLIQUE (3)
+# define PRT_PS_FONT_ROMAN (0)
+# define PRT_PS_FONT_BOLD (1)
+# define PRT_PS_FONT_OBLIQUE (2)
+# define PRT_PS_FONT_BOLDOBLIQUE (3)
// Standard font metrics for Courier family
static struct prt_ps_font_S prt_ps_courier_font =
};
-#define CS_JIS_C_1978 (0x01)
-#define CS_JIS_X_1983 (0x02)
-#define CS_JIS_X_1990 (0x04)
-#define CS_NEC (0x08)
-#define CS_MSWINDOWS (0x10)
-#define CS_CP932 (0x20)
-#define CS_KANJITALK6 (0x40)
-#define CS_KANJITALK7 (0x80)
+# define CS_JIS_C_1978 (0x01)
+# define CS_JIS_X_1983 (0x02)
+# define CS_JIS_X_1990 (0x04)
+# define CS_NEC (0x08)
+# define CS_MSWINDOWS (0x10)
+# define CS_CP932 (0x20)
+# define CS_KANJITALK6 (0x40)
+# define CS_KANJITALK7 (0x80)
// Japanese encodings and charsets
static struct prt_ps_encoding_S j_encodings[] =
{"KANJITALK7", "90pv", CS_KANJITALK7}
};
-#define CS_GB_2312_80 (0x01)
-#define CS_GBT_12345_90 (0x02)
-#define CS_GBK2K (0x04)
-#define CS_SC_MAC (0x08)
-#define CS_GBT_90_MAC (0x10)
-#define CS_GBK (0x20)
-#define CS_SC_ISO10646 (0x40)
+# define CS_GB_2312_80 (0x01)
+# define CS_GBT_12345_90 (0x02)
+# define CS_GBK2K (0x04)
+# define CS_SC_MAC (0x08)
+# define CS_GBT_90_MAC (0x10)
+# define CS_GBK (0x20)
+# define CS_SC_ISO10646 (0x40)
// Simplified Chinese encodings and charsets
static struct prt_ps_encoding_S sc_encodings[] =
{"ISO10646", "UniGB", CS_SC_ISO10646}
};
-#define CS_CNS_PLANE_1 (0x01)
-#define CS_CNS_PLANE_2 (0x02)
-#define CS_CNS_PLANE_1_2 (0x04)
-#define CS_B5 (0x08)
-#define CS_ETEN (0x10)
-#define CS_HK_GCCS (0x20)
-#define CS_HK_SCS (0x40)
-#define CS_HK_SCS_ETEN (0x80)
-#define CS_MTHKL (0x100)
-#define CS_MTHKS (0x200)
-#define CS_DLHKL (0x400)
-#define CS_DLHKS (0x800)
-#define CS_TC_ISO10646 (0x1000)
+# define CS_CNS_PLANE_1 (0x01)
+# define CS_CNS_PLANE_2 (0x02)
+# define CS_CNS_PLANE_1_2 (0x04)
+# define CS_B5 (0x08)
+# define CS_ETEN (0x10)
+# define CS_HK_GCCS (0x20)
+# define CS_HK_SCS (0x40)
+# define CS_HK_SCS_ETEN (0x80)
+# define CS_MTHKL (0x100)
+# define CS_MTHKS (0x200)
+# define CS_DLHKL (0x400)
+# define CS_DLHKS (0x800)
+# define CS_TC_ISO10646 (0x1000)
// Traditional Chinese encodings and charsets
static struct prt_ps_encoding_S tc_encodings[] =
{"ISO10646", "UniCNS", CS_TC_ISO10646}
};
-#define CS_KR_X_1992 (0x01)
-#define CS_KR_MAC (0x02)
-#define CS_KR_X_1992_MS (0x04)
-#define CS_KR_ISO10646 (0x08)
+# define CS_KR_X_1992 (0x01)
+# define CS_KR_MAC (0x02)
+# define CS_KR_X_1992_MS (0x04)
+# define CS_KR_ISO10646 (0x08)
// Korean encodings and charsets
static struct prt_ps_encoding_S k_encodings[] =
};
// Types of PS resource file currently used
-#define PRT_RESOURCE_TYPE_PROCSET (0)
-#define PRT_RESOURCE_TYPE_ENCODING (1)
-#define PRT_RESOURCE_TYPE_CMAP (2)
+# define PRT_RESOURCE_TYPE_PROCSET (0)
+# define PRT_RESOURCE_TYPE_ENCODING (1)
+# define PRT_RESOURCE_TYPE_CMAP (2)
// The PS prolog file version number has to match - if the prolog file is
// updated, increment the number in the file and here. Version checking was
// VIM Prolog CIDProlog
// 6.2 1.3
// 7.0 1.4 1.0
-#define PRT_PROLOG_VERSION ((char_u *)"1.4")
-#define PRT_CID_PROLOG_VERSION ((char_u *)"1.0")
+# define PRT_PROLOG_VERSION ((char_u *)"1.4")
+# define PRT_CID_PROLOG_VERSION ((char_u *)"1.0")
// String versions of PS resource types - indexed by constants above so don't
// re-order!
};
// Strings to look for in a PS resource file
-#define PRT_RESOURCE_HEADER "%!PS-Adobe-"
-#define PRT_RESOURCE_RESOURCE "Resource-"
-#define PRT_RESOURCE_PROCSET "ProcSet"
-#define PRT_RESOURCE_ENCODING "Encoding"
-#define PRT_RESOURCE_CMAP "CMap"
+# define PRT_RESOURCE_HEADER "%!PS-Adobe-"
+# define PRT_RESOURCE_RESOURCE "Resource-"
+# define PRT_RESOURCE_PROCSET "ProcSet"
+# define PRT_RESOURCE_ENCODING "Encoding"
+# define PRT_RESOURCE_CMAP "CMap"
// Data for table based DSC comment recognition, easy to extend if VIM needs to
// read more comments.
-#define PRT_DSC_MISC_TYPE (-1)
-#define PRT_DSC_TITLE_TYPE (1)
-#define PRT_DSC_VERSION_TYPE (2)
-#define PRT_DSC_ENDCOMMENTS_TYPE (3)
+# define PRT_DSC_MISC_TYPE (-1)
+# define PRT_DSC_TITLE_TYPE (1)
+# define PRT_DSC_VERSION_TYPE (2)
+# define PRT_DSC_ENDCOMMENTS_TYPE (3)
-#define PRT_DSC_TITLE "%%Title:"
-#define PRT_DSC_VERSION "%%Version:"
-#define PRT_DSC_ENDCOMMENTS "%%EndComments:"
+# define PRT_DSC_TITLE "%%Title:"
+# define PRT_DSC_VERSION "%%Version:"
+# define PRT_DSC_ENDCOMMENTS "%%EndComments:"
struct prt_dsc_comment_S
{
};
-#define SIZEOF_CSTR(s) (sizeof(s) - 1)
+# define SIZEOF_CSTR(s) (sizeof(s) - 1)
static struct prt_dsc_comment_S prt_dsc_table[] =
{
{PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE},
}
// Convert size from font space to user space at current font scale
-#define PRT_PS_FONT_TO_USER(scale, size) ((size) * ((scale)/1000.0))
+# define PRT_PS_FONT_TO_USER(scale, size) ((size) * ((scale)/1000.0))
static void
prt_flush_buffer(void)
}
// PS CR and LF characters have platform independent values
-#define PSLF (0x0a)
-#define PSCR (0x0d)
+# define PSLF (0x0a)
+# define PSCR (0x0d)
// Static buffer to read initial comments in a resource file, some can have a
// couple of KB of comments!
-#define PRT_FILE_BUFFER_LEN (2048)
+# define PRT_FILE_BUFFER_LEN (2048)
struct prt_resfile_buffer_S
{
char_u buffer[PRT_FILE_BUFFER_LEN];
prt_write_file(prt_line_buffer);
}
-#define prt_dsc_atend(c) prt_dsc_text((c), "atend")
+# define prt_dsc_atend(c) prt_dsc_text((c), "atend")
static void
prt_dsc_ints(char *comment, int count, int *ints)
struct prt_ps_encoding_S *p_mbenc_first;
struct prt_ps_charset_S *p_mbchar = NULL;
-#if 0
+# if 0
/*
* TODO:
* If "forceit" is false: pop up a dialog to select:
*/
if (forceit)
s_pd.Flags |= PD_RETURNDEFAULT;
-#endif
+# endif
/*
* Set up font and encoding.
prt_dsc_resources(NULL, "encoding", buffer);
}
prt_dsc_requirements(prt_duplex, prt_tumble, prt_collate,
-#ifdef FEAT_SYN_HL
+# ifdef FEAT_SYN_HL
psettings->do_syntax
-#else
+# else
0
-#endif
+# endif
, prt_num_copies);
prt_dsc_noarg("EndComments");
prt_need_fgcol = TRUE;
}
-# endif //FEAT_POSTSCRIPT
+#endif //FEAT_POSTSCRIPT
#endif //FEAT_PRINTER
#endif
#ifdef FEAT_GUI
GuiFont sg_font; // GUI font handle
-#ifdef FEAT_XFONTSET
+# ifdef FEAT_XFONTSET
GuiFontset sg_fontset; // GUI fontset handle
-#endif
+# endif
char_u *sg_font_name; // GUI font or fontset name
int sg_gui_attr; // Screen attr for GUI mode
#endif
// fontset. Same for the Menu group.
if (do_normal)
gui_init_font(arg, TRUE);
-# if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
+# if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
if (do_menu)
{
-# ifdef FONTSET_ALWAYS
+# ifdef FONTSET_ALWAYS
gui.menu_fontset = HL_TABLE()[idx].sg_fontset;
-# else
+# else
// YIKES! This is a bug waiting to crash the program
gui.menu_font = HL_TABLE()[idx].sg_fontset;
-# endif
+# endif
gui_mch_new_menu_font();
}
-# ifdef FEAT_BEVAL_GUI
+# ifdef FEAT_BEVAL_GUI
if (do_tooltip)
{
// The Athena widget set could not handle switching between
gui.tooltip_fontset = (XFontSet)HL_TABLE()[idx].sg_fontset;
gui_mch_new_tooltip_font();
}
-# endif
# endif
+# endif
}
else
# endif
{
if (do_normal)
gui_init_font(arg, FALSE);
-#ifndef FONTSET_ALWAYS
-# if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
+# ifndef FONTSET_ALWAYS
+# if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
if (do_menu)
{
gui.menu_font = HL_TABLE()[idx].sg_font;
gui_mch_new_menu_font();
}
+# endif
# endif
-#endif
}
}
}
if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0)
{
-#if defined(FEAT_TERMGUICOLORS) && defined(FEAT_GUI)
+# if defined(FEAT_TERMGUICOLORS) && defined(FEAT_GUI)
if (gui.in_use)
-#endif
-#ifdef FEAT_GUI
+# endif
+# ifdef FEAT_GUI
return gui.norm_pixel;
-#endif
-#ifdef FEAT_TERMGUICOLORS
+# endif
+# ifdef FEAT_TERMGUICOLORS
if (cterm_normal_fg_gui_color != INVALCOLOR)
return cterm_normal_fg_gui_color;
// Guess that the foreground is black or white.
return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "black" : "white"));
-#endif
+# endif
}
if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0)
{
-#if defined(FEAT_TERMGUICOLORS) && defined(FEAT_GUI)
+# if defined(FEAT_TERMGUICOLORS) && defined(FEAT_GUI)
if (gui.in_use)
-#endif
-#ifdef FEAT_GUI
+# endif
+# ifdef FEAT_GUI
return gui.back_pixel;
-#endif
-#ifdef FEAT_TERMGUICOLORS
+# endif
+# ifdef FEAT_TERMGUICOLORS
if (cterm_normal_bg_gui_color != INVALCOLOR)
return cterm_normal_bg_gui_color;
// Guess that the background is white or black.
return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "white" : "black"));
-#endif
+# endif
}
return GUI_GET_COLOR(name);
return gui_adjust_rgb(color);
}
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// Returns the color currently mapped to the given name or INVALCOLOR if no
// such name exists in the color table. The convention is to use lowercase for
// all keys in the v:colornames dictionary. The value can be either a string in
return INVALCOLOR;
}
-#endif
+# endif
guicolor_T
gui_get_color_cmn(char_u *name)
if (entry != NULL)
return gui_adjust_rgb((guicolor_T)entry->key);
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
/*
* Not a traditional color. Load additional color aliases and then consult the alias table.
*/
}
return color;
-#else
+# else
return INVALCOLOR;
-#endif
+# endif
}
guicolor_T
#ifdef FEAT_GUI
static garray_T gui_attr_table = {0, 0, 0, 0, NULL};
-#define GUI_ATTR_ENTRY(idx) ((attrentry_T *)gui_attr_table.ga_data)[idx]
+# define GUI_ATTR_ENTRY(idx) ((attrentry_T *)gui_attr_table.ga_data)[idx]
#endif
/*
&& aep->ae_u.gui.sp_color
== taep->ae_u.gui.sp_color
&& aep->ae_u.gui.font == taep->ae_u.gui.font
-# ifdef FEAT_XFONTSET
+# ifdef FEAT_XFONTSET
&& aep->ae_u.gui.fontset == taep->ae_u.gui.fontset
-# endif
+# endif
))
||
#endif
attrentry_T at_en;
CLEAR_FIELD(at_en);
-#ifdef FEAT_TERMGUICOLORS
+# ifdef FEAT_TERMGUICOLORS
at_en.ae_u.cterm.fg_rgb = INVALCOLOR;
at_en.ae_u.cterm.bg_rgb = INVALCOLOR;
at_en.ae_u.cterm.ul_rgb = INVALCOLOR;
-#endif
+# endif
at_en.ae_attr = attr;
at_en.ae_u.cterm.fg_color = fg;
at_en.ae_u.cterm.bg_color = bg;
if (id <= 0 || id > highlight_ga.ga_len)
return NULL;
-#if defined(FEAT_GUI) || defined(FEAT_EVAL)
+# if defined(FEAT_GUI) || defined(FEAT_EVAL)
if (modec == 'g')
attr = HL_TABLE()[id - 1].sg_gui;
else
-#endif
+# endif
{
if (modec == 'c')
attr = HL_TABLE()[id - 1].sg_cterm;
// highlighting attributes, need to allocate an attr number.
if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0 &&
sgp->sg_cterm_ul == 0 && sgp->sg_cterm_font == 0
-# ifdef FEAT_TERMGUICOLORS
+#ifdef FEAT_TERMGUICOLORS
&& sgp->sg_gui_fg == INVALCOLOR
&& sgp->sg_gui_bg == INVALCOLOR
&& sgp->sg_gui_sp == INVALCOLOR
-# endif
+#endif
)
sgp->sg_cterm_attr = sgp->sg_cterm;
else
at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg;
at_en.ae_u.cterm.ul_color = sgp->sg_cterm_ul;
at_en.ae_u.cterm.font = sgp->sg_cterm_font;
-# ifdef FEAT_TERMGUICOLORS
+#ifdef FEAT_TERMGUICOLORS
at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_fg);
at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg);
// Only use the underline/undercurl color when used, it may clear the
at_en.ae_u.cterm.fg_rgb = CTERMCOLOR;
at_en.ae_u.cterm.bg_rgb = CTERMCOLOR;
}
-# endif
+#endif
sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en);
}
}
CLEAR_POINTER(&hlt[hlcnt + i]);
hlt[hlcnt + i].sg_term = highlight_attr[hlf];
hlt[hlcnt + i].sg_cterm = highlight_attr[hlf];
-# if defined(FEAT_GUI) || defined(FEAT_EVAL)
+# if defined(FEAT_GUI) || defined(FEAT_EVAL)
hlt[hlcnt + i].sg_gui = highlight_attr[hlf];
-# endif
+# endif
}
else
mch_memmove(&hlt[hlcnt + i],
hlt[hlcnt + i].sg_cterm_bg = hlt[id - 1].sg_cterm_bg;
if (hlt[id - 1].sg_cterm_font != hlt[id_S - 1].sg_cterm_font)
hlt[hlcnt + i].sg_cterm_font = hlt[id - 1].sg_cterm_font;
-# if defined(FEAT_GUI) || defined(FEAT_EVAL)
+# if defined(FEAT_GUI) || defined(FEAT_EVAL)
hlt[hlcnt + i].sg_gui ^=
hlt[id - 1].sg_gui ^ hlt[id_S - 1].sg_gui;
-# endif
-# ifdef FEAT_GUI
+# endif
+# ifdef FEAT_GUI
if (hlt[id - 1].sg_gui_fg != hlt[id_S - 1].sg_gui_fg)
hlt[hlcnt + i].sg_gui_fg = hlt[id - 1].sg_gui_fg;
if (hlt[id - 1].sg_gui_bg != hlt[id_S - 1].sg_gui_bg)
hlt[hlcnt + i].sg_gui_sp = hlt[id - 1].sg_gui_sp;
if (hlt[id - 1].sg_font != hlt[id_S - 1].sg_font)
hlt[hlcnt + i].sg_font = hlt[id - 1].sg_font;
-# ifdef FEAT_XFONTSET
+# ifdef FEAT_XFONTSET
if (hlt[id - 1].sg_fontset != hlt[id_S - 1].sg_fontset)
hlt[hlcnt + i].sg_fontset = hlt[id - 1].sg_fontset;
-# endif
# endif
+# endif
highlight_ga.ga_len = hlcnt + i + 1;
set_hl_attr(hlcnt + i); // At long last we can apply
table[i] = syn_id2attr(hlcnt + i + 1);
// Temporary buffer used to store the command string produced by hlset().
// IObuff cannot be used for this as the error messages produced by hlset()
// internally use IObuff.
-#define HLSETBUFSZ 512
+# define HLSETBUFSZ 512
static char_u hlsetBuf[HLSETBUFSZ + 1];
/*
#if defined(FEAT_CSCOPE)
-#include <sys/types.h>
-#include <sys/stat.h>
-#if defined(UNIX)
-# include <sys/wait.h>
-#endif
-
-#if defined (MSWIN)
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
+# include <sys/types.h>
+# include <sys/stat.h>
+# if defined(UNIX)
+# include <sys/wait.h>
# endif
-# include <windows.h>
-#endif
-#define CSCOPE_SUCCESS 0
-#define CSCOPE_FAILURE -1
+# if defined (MSWIN)
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <windows.h>
+# endif
-#define CSCOPE_DBFILE "cscope.out"
-#define CSCOPE_PROMPT ">> "
+# define CSCOPE_SUCCESS 0
+# define CSCOPE_FAILURE -1
+
+# define CSCOPE_DBFILE "cscope.out"
+# define CSCOPE_PROMPT ">> "
/*
* See ":help cscope-find" for the possible queries.
char * fname; // cscope db name
char * ppath; // path to prepend (the -P option)
char * flags; // additional cscope flags/options (e.g, -p2)
-#if defined(UNIX)
+# if defined(UNIX)
pid_t pid; // PID of the connected cscope process.
dev_t st_dev; // ID of dev containing cscope db
ino_t st_ino; // inode number of cscope db
-#else
-# if defined(MSWIN)
+# else
+# if defined(MSWIN)
DWORD pid; // PID of the connected cscope process.
HANDLE hProc; // cscope process handle
DWORD nVolume; // Volume serial number, instead of st_dev
DWORD nIndexHigh; // st_ino has no meaning in the Windows
DWORD nIndexLow;
+# endif
# endif
-#endif
FILE * fr_fp; // from cscope: FILE.
FILE * to_fp; // to cscope: FILE.
static int cs_check_for_tags(void);
static int cs_cnt_connections(void);
static int cs_create_connection(int i);
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
static void cs_file_results(FILE *, int *);
-#endif
+# endif
static void cs_fill_results(char *, int , int *, char ***,
char ***, int *);
static int cs_find(exarg_T *eap);
if (!ret)
{
(void)emsg(_(e_cstag_tag_not_founc));
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
g_do_tagpreview = 0;
-#endif
+# endif
}
}
*
* Note: All string comparisons are case sensitive!
*/
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
static int
cs_connection(int num, char_u *dbpath, char_u *ppath)
{
return FALSE;
}
-#endif
+# endif
/*
goto add_err;
while (fname[strlen(fname)-1] == '/'
-#ifdef MSWIN
+# ifdef MSWIN
|| fname[strlen(fname)-1] == '\\'
-#endif
+# endif
)
{
fname[strlen(fname)-1] = '\0';
semsg(_(e_error_reading_cscope_connection_nr), idx);
}
-#define CSREAD_BUFSIZE 2048
+# define CSREAD_BUFSIZE 2048
/*
* Count the number of matches for a given cscope connection.
*/
static int
cs_create_connection(int i)
{
-#ifdef UNIX
+# ifdef UNIX
int to_cs[2], from_cs[2];
-#endif
+# endif
int cmdlen;
int len;
char *prog, *cmd, *ppath = NULL;
size_t proglen;
-#ifdef MSWIN
+# ifdef MSWIN
int fd;
SECURITY_ATTRIBUTES sa;
PROCESS_INFORMATION pi;
HANDLE stdin_rd, stdout_rd;
HANDLE stdout_wr, stdin_wr;
BOOL created;
-#endif
+# endif
-#if defined(UNIX)
+# if defined(UNIX)
/*
* Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from
* from_cs[0] and writes to to_cs[1].
// close unused
(void)close(to_cs[1]);
(void)close(from_cs[0]);
-#else
+# else
// MSWIN
// Create pipes to communicate with cscope
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
}
return CSCOPE_FAILURE;
}
-#endif
+# endif
// expand the cscope exec for env var's
if ((prog = alloc(MAXPATHL + 1)) == NULL)
{
-#ifdef UNIX
+# ifdef UNIX
exit(EXIT_FAILURE);
-#else
+# else
// MSWIN
goto err_closing;
-#endif
+# endif
}
proglen = expand_env(p_csprg, (char_u *)prog, MAXPATHL);
if ((ppath = alloc(MAXPATHL + 1)) == NULL)
{
vim_free(prog);
-#ifdef UNIX
+# ifdef UNIX
exit(EXIT_FAILURE);
-#else
+# else
// MSWIN
goto err_closing;
-#endif
+# endif
}
cmdlen += (int)expand_env((char_u *)csinfo[i].ppath, (char_u *)ppath, MAXPATHL);
}
{
vim_free(prog);
vim_free(ppath);
-#ifdef UNIX
+# ifdef UNIX
exit(EXIT_FAILURE);
-#else
+# else
// MSWIN
goto err_closing;
-#endif
+# endif
}
// run the cscope command
-#ifdef UNIX
+# ifdef UNIX
vim_snprintf(cmd, cmdlen, "/bin/sh -c \"exec %s -dl -f %s",
prog, csinfo[i].fname);
-#else
+# else
vim_snprintf(cmd, cmdlen, "%s -dl -f %s", prog, csinfo[i].fname);
-#endif
+# endif
if (csinfo[i].ppath != NULL)
{
len = (int)STRLEN(cmd);
# endif
vim_free(ppath);
-#if defined(UNIX)
-# if defined(HAVE_SETSID) || defined(HAVE_SETPGID)
+# if defined(UNIX)
+# if defined(HAVE_SETSID) || defined(HAVE_SETPGID)
// Change our process group to avoid cscope receiving SIGWINCH.
-# if defined(HAVE_SETSID)
+# if defined(HAVE_SETSID)
(void)setsid();
-# else
+# else
if (setpgid(0, 0) == -1)
PERROR(_("cs_create_connection setpgid failed"));
+# endif
# endif
-# endif
if (build_argv_from_string((char_u *)cmd, &argv, &argc) == FAIL)
exit(EXIT_FAILURE);
(void)close(to_cs[0]);
(void)close(from_cs[1]);
}
-#else
+# else
// MSWIN
// Create a new process to run cscope and use pipes to talk with it
GetStartupInfo(&si);
CloseHandle(stdin_rd);
CloseHandle(stdout_wr);
-#endif // !UNIX
+# endif // !UNIX
return CSCOPE_SUCCESS;
}
char *cmd;
int *nummatches;
int totmatches;
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
char cmdletter;
char *qfpos;
&& apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)"cscope",
curbuf->b_fname, TRUE, curbuf))
{
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (aborting())
return FALSE;
-# endif
+# endif
}
}
-#endif
+# endif
// create the actual command to send to cscope
cmd = cs_create_cmd(opt, pat);
return FALSE;
}
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
if (qfpos != NULL && *qfpos != '0' && totmatches > 0)
{
// fill error list
return TRUE;
}
else
-#endif // FEAT_QUICKFIX
+# endif // FEAT_QUICKFIX
{
char **matches = NULL, **contexts = NULL;
int matched = 0;
csinfo[i].fname = NULL;
csinfo[i].ppath = NULL;
csinfo[i].flags = NULL;
-#if defined(UNIX)
+# if defined(UNIX)
csinfo[i].st_dev = (dev_t)0;
csinfo[i].st_ino = (ino_t)0;
-#else
+# else
csinfo[i].nVolume = 0;
csinfo[i].nIndexHigh = 0;
csinfo[i].nIndexLow = 0;
-#endif
+# endif
csinfo[i].pid = 0;
csinfo[i].fr_fp = NULL;
csinfo[i].to_fp = NULL;
-#if defined(MSWIN)
+# if defined(MSWIN)
csinfo[i].hProc = NULL;
-#endif
+# endif
}
/*
{
int i;
int j;
-#ifndef UNIX
+# ifndef UNIX
BY_HANDLE_FILE_INFORMATION bhfi;
switch (win32_fileinfo((char_u *)fname, &bhfi))
(void)emsg(_(e_cannot_get_cscope_database_information));
return -1;
}
-#endif
+# endif
i = -1; // can be set to the index of an empty item in csinfo
for (j = 0; j < csinfo_size; j++)
{
if (csinfo[j].fname != NULL
-#if defined(UNIX)
+# if defined(UNIX)
&& csinfo[j].st_dev == sb->st_dev && csinfo[j].st_ino == sb->st_ino
-#else
+# else
// compare pathnames first
&& ((fullpathcmp((char_u *)csinfo[j].fname,
(char_u *)fname, FALSE, TRUE) & FPC_SAME)
|| (csinfo[j].nVolume == bhfi.dwVolumeSerialNumber
&& csinfo[j].nIndexHigh == bhfi.nFileIndexHigh
&& csinfo[j].nIndexLow == bhfi.nFileIndexLow))
-#endif
+# endif
)
{
if (p_csverbose)
else
csinfo[i].flags = NULL;
-#if defined(UNIX)
+# if defined(UNIX)
csinfo[i].st_dev = sb->st_dev;
csinfo[i].st_ino = sb->st_ino;
-#else
+# else
csinfo[i].nVolume = bhfi.dwVolumeSerialNumber;
csinfo[i].nIndexLow = bhfi.nFileIndexLow;
csinfo[i].nIndexHigh = bhfi.nFileIndexHigh;
-#endif
+# endif
return i;
}
return name;
}
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
/*
* Write cscope find results to file.
*/
} // for all cscope connections
vim_free(buf);
}
-#endif
+# endif
/*
* Get parsed cscope output and calls cs_make_vim_style_matches to convert
{
s--;
if (*s == '/'
-#ifdef MSWIN
+# ifdef MSWIN
|| *s == '\\'
-#endif
+# endif
)
break;
}
}
if ((s > path && *s == '/')
-#ifdef MSWIN
+# ifdef MSWIN
|| (s > path && *s == '\\')
-#endif
+# endif
)
++s;
return s;
return CSCOPE_SUCCESS;
}
-#if defined(UNIX) && defined(SIGALRM)
+# if defined(UNIX) && defined(SIGALRM)
/*
* Used to catch and ignore SIGALRM below.
*/
{
// do nothing
}
-#endif
+# endif
/*
* Does the actual free'ing for the cs ptr with an optional flag of whether
(void)fputs("q\n", csinfo[i].to_fp);
(void)fflush(csinfo[i].to_fp);
}
-#if defined(UNIX)
+# if defined(UNIX)
{
int waitpid_errno;
int pstat;
pid_t pid;
-# if defined(HAVE_SIGACTION)
+# if defined(HAVE_SIGACTION)
struct sigaction sa, old;
// Use sigaction() to limit the waiting time to two seconds.
sigemptyset(&sa.sa_mask);
sa.sa_handler = sig_handler;
-# ifdef SA_NODEFER
+# ifdef SA_NODEFER
sa.sa_flags = SA_NODEFER;
-# else
+# else
sa.sa_flags = 0;
-# endif
+# endif
sigaction(SIGALRM, &sa, &old);
alarm(2); // 2 sec timeout
// cancel pending alarm if still there and restore signal
alarm(0);
sigaction(SIGALRM, &old, NULL);
-# else
+# else
int waited;
// Can't use sigaction(), loop for two seconds. First yield the CPU
break; // break unless the process is still running
mch_delay(50L, 0); // sleep 50 ms
}
-# endif
+# endif
/*
* If the cscope process is still running: kill it.
* Safety check: If the PID would be zero here, the entire X session
*/
if (pid < 0 && csinfo[i].pid > 1)
{
-# ifdef ECHILD
+# ifdef ECHILD
int alive = TRUE;
if (waitpid_errno == ECHILD)
}
}
if (alive)
-# endif
+# endif
{
kill(csinfo[i].pid, SIGKILL);
(void)waitpid(csinfo[i].pid, &pstat, 0);
}
}
}
-#else // !UNIX
+# else // !UNIX
if (csinfo[i].hProc != NULL)
{
// Give cscope a chance to exit normally
TerminateProcess(csinfo[i].hProc, 0);
CloseHandle(csinfo[i].hProc);
}
-#endif
+# endif
if (csinfo[i].fr_fp != NULL)
(void)fclose(csinfo[i].fr_fp);
if (csinfo[i].ppath != NULL
&& (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0)
&& (name[0] != '/')
-#ifdef MSWIN
+# ifdef MSWIN
&& name[0] != '\\' && name[1] != ':'
-#endif
+# endif
)
{
if ((fullname = alloc(len)) != NULL)
#include <lauxlib.h>
#if __STDC_VERSION__ >= 199901L
-# define LUAV_INLINE inline
+# define LUAV_INLINE inline
#else
-# define LUAV_INLINE
+# define LUAV_INLINE
#endif
// Only do the following when the feature is enabled. Needed for "make
// depend".
#if defined(FEAT_LUA)
-#define LUAVIM_CHUNKNAME "vim chunk"
-#define LUAVIM_NAME "vim"
-#define LUAVIM_EVALNAME "luaeval"
-#define LUAVIM_EVALHEADER "local _A=select(1,...) return "
+# define LUAVIM_CHUNKNAME "vim chunk"
+# define LUAVIM_NAME "vim"
+# define LUAVIM_EVALNAME "luaeval"
+# define LUAVIM_EVALHEADER "local _A=select(1,...) return "
-#ifdef LUA_RELEASE
-# define LUAVIM_VERSION LUA_RELEASE
-#else
-# define LUAVIM_VERSION LUA_VERSION
-#endif
+# ifdef LUA_RELEASE
+# define LUAVIM_VERSION LUA_RELEASE
+# else
+# define LUAVIM_VERSION LUA_VERSION
+# endif
typedef buf_T *luaV_Buffer;
typedef win_T *luaV_Window;
static const char LUAVIM_UDATA_CACHE[] = "luaV_udata_cache";
-#define luaV_getfield(L, s) \
+# define luaV_getfield(L, s) \
lua_pushlightuserdata((L), (void *)(s)); \
lua_rawget((L), LUA_REGISTRYINDEX)
-#define luaV_checksandbox(L) \
+# define luaV_checksandbox(L) \
if (sandbox) luaL_error((L), "not allowed in sandbox")
-#define luaV_msg(L) luaV_msgfunc((L), (msgfunc_T) msg)
-#define luaV_emsg(L) luaV_msgfunc((L), (msgfunc_T) emsg)
-#define luaV_checktypval(L, a, v, msg) \
+# define luaV_msg(L) luaV_msgfunc((L), (msgfunc_T) msg)
+# define luaV_emsg(L) luaV_msgfunc((L), (msgfunc_T) emsg)
+# define luaV_checktypval(L, a, v, msg) \
do { \
if (luaV_totypval(L, a, v) == FAIL) \
luaL_error(L, msg ": cannot convert value"); \
static int luaV_call_lua_func(int argcount, typval_T *argvars, typval_T *rettv, void *state);
static void luaV_call_lua_func_free(void *state);
-#if LUA_VERSION_NUM <= 501
-#define luaV_register(L, l) luaL_register(L, NULL, l)
-#define luaL_typeerror luaL_typerror
-#else
-#define luaV_register(L, l) luaL_setfuncs(L, l, 0)
-#endif
-
-#ifdef DYNAMIC_LUA
-
-#ifdef MSWIN
-# define load_dll vimLoadLib
-# define symbol_from_dll GetProcAddress
-# define close_dll FreeLibrary
-# define load_dll_error GetWin32Error
-#else
-# include <dlfcn.h>
-# define HANDLE void*
-# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
-# define symbol_from_dll dlsym
-# define close_dll dlclose
-# define load_dll_error dlerror
-#endif
+# if LUA_VERSION_NUM <= 501
+# define luaV_register(L, l) luaL_register(L, NULL, l)
+# define luaL_typeerror luaL_typerror
+# else
+# define luaV_register(L, l) luaL_setfuncs(L, l, 0)
+# endif
+
+# ifdef DYNAMIC_LUA
+
+# ifdef MSWIN
+# define load_dll vimLoadLib
+# define symbol_from_dll GetProcAddress
+# define close_dll FreeLibrary
+# define load_dll_error GetWin32Error
+# else
+# include <dlfcn.h>
+# define HANDLE void*
+# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
+# define symbol_from_dll dlsym
+# define close_dll dlclose
+# define load_dll_error dlerror
+# endif
// lauxlib
-#if LUA_VERSION_NUM <= 501
-#define luaL_register dll_luaL_register
-#define luaL_prepbuffer dll_luaL_prepbuffer
-#define luaL_openlib dll_luaL_openlib
-#define luaL_typerror dll_luaL_typerror
-#define luaL_loadfile dll_luaL_loadfile
-#define luaL_loadbuffer dll_luaL_loadbuffer
-#else
-#define luaL_prepbuffsize dll_luaL_prepbuffsize
-#define luaL_setfuncs dll_luaL_setfuncs
-#define luaL_loadfilex dll_luaL_loadfilex
-#define luaL_loadbufferx dll_luaL_loadbufferx
-#define luaL_argerror dll_luaL_argerror
-#endif
-#if LUA_VERSION_NUM >= 504
-#define luaL_typeerror dll_luaL_typeerror
-#endif
-#define luaL_checkany dll_luaL_checkany
-#define luaL_checklstring dll_luaL_checklstring
-#define luaL_checkinteger dll_luaL_checkinteger
-#define luaL_optinteger dll_luaL_optinteger
-#define luaL_checktype dll_luaL_checktype
-#define luaL_error dll_luaL_error
-#define luaL_newstate dll_luaL_newstate
-#define luaL_buffinit dll_luaL_buffinit
-#define luaL_addlstring dll_luaL_addlstring
-#define luaL_pushresult dll_luaL_pushresult
-#define luaL_loadstring dll_luaL_loadstring
-#define luaL_ref dll_luaL_ref
-#define luaL_unref dll_luaL_unref
+# if LUA_VERSION_NUM <= 501
+# define luaL_register dll_luaL_register
+# define luaL_prepbuffer dll_luaL_prepbuffer
+# define luaL_openlib dll_luaL_openlib
+# define luaL_typerror dll_luaL_typerror
+# define luaL_loadfile dll_luaL_loadfile
+# define luaL_loadbuffer dll_luaL_loadbuffer
+# else
+# define luaL_prepbuffsize dll_luaL_prepbuffsize
+# define luaL_setfuncs dll_luaL_setfuncs
+# define luaL_loadfilex dll_luaL_loadfilex
+# define luaL_loadbufferx dll_luaL_loadbufferx
+# define luaL_argerror dll_luaL_argerror
+# endif
+# if LUA_VERSION_NUM >= 504
+# define luaL_typeerror dll_luaL_typeerror
+# endif
+# define luaL_checkany dll_luaL_checkany
+# define luaL_checklstring dll_luaL_checklstring
+# define luaL_checkinteger dll_luaL_checkinteger
+# define luaL_optinteger dll_luaL_optinteger
+# define luaL_checktype dll_luaL_checktype
+# define luaL_error dll_luaL_error
+# define luaL_newstate dll_luaL_newstate
+# define luaL_buffinit dll_luaL_buffinit
+# define luaL_addlstring dll_luaL_addlstring
+# define luaL_pushresult dll_luaL_pushresult
+# define luaL_loadstring dll_luaL_loadstring
+# define luaL_ref dll_luaL_ref
+# define luaL_unref dll_luaL_unref
// lua
-#if LUA_VERSION_NUM <= 501
-#define lua_tonumber dll_lua_tonumber
-#define lua_tointeger dll_lua_tointeger
-#define lua_call dll_lua_call
-#define lua_pcall dll_lua_pcall
-#else
-#define lua_tonumberx dll_lua_tonumberx
-#define lua_tointegerx dll_lua_tointegerx
-#define lua_callk dll_lua_callk
-#define lua_pcallk dll_lua_pcallk
-#define lua_getglobal dll_lua_getglobal
-#define lua_setglobal dll_lua_setglobal
-#endif
-#if LUA_VERSION_NUM <= 502
-#define lua_replace dll_lua_replace
-#define lua_remove dll_lua_remove
-#endif
-#if LUA_VERSION_NUM >= 503
-#define lua_rotate dll_lua_rotate
-#define lua_copy dll_lua_copy
-#endif
-#define lua_typename dll_lua_typename
-#define lua_close dll_lua_close
-#define lua_gettop dll_lua_gettop
-#define lua_settop dll_lua_settop
-#define lua_pushvalue dll_lua_pushvalue
-#define lua_isnumber dll_lua_isnumber
-#define lua_isstring dll_lua_isstring
-#define lua_type dll_lua_type
-#define lua_rawequal dll_lua_rawequal
-#define lua_toboolean dll_lua_toboolean
-#define lua_tolstring dll_lua_tolstring
-#define lua_touserdata dll_lua_touserdata
-#define lua_pushnil dll_lua_pushnil
-#define lua_pushnumber dll_lua_pushnumber
-#define lua_pushinteger dll_lua_pushinteger
-#define lua_pushlstring dll_lua_pushlstring
-#define lua_pushstring dll_lua_pushstring
-#define lua_pushfstring dll_lua_pushfstring
-#define lua_pushcclosure dll_lua_pushcclosure
-#define lua_pushboolean dll_lua_pushboolean
-#define lua_pushlightuserdata dll_lua_pushlightuserdata
-#define lua_getfield dll_lua_getfield
-#define lua_rawget dll_lua_rawget
-#define lua_rawgeti dll_lua_rawgeti
-#define lua_createtable dll_lua_createtable
-#define lua_settable dll_lua_settable
-#if LUA_VERSION_NUM >= 504
- #define lua_newuserdatauv dll_lua_newuserdatauv
-#else
- #define lua_newuserdata dll_lua_newuserdata
-#endif
-#define lua_getmetatable dll_lua_getmetatable
-#define lua_setfield dll_lua_setfield
-#define lua_rawset dll_lua_rawset
-#define lua_rawseti dll_lua_rawseti
-#define lua_setmetatable dll_lua_setmetatable
-#define lua_next dll_lua_next
+# if LUA_VERSION_NUM <= 501
+# define lua_tonumber dll_lua_tonumber
+# define lua_tointeger dll_lua_tointeger
+# define lua_call dll_lua_call
+# define lua_pcall dll_lua_pcall
+# else
+# define lua_tonumberx dll_lua_tonumberx
+# define lua_tointegerx dll_lua_tointegerx
+# define lua_callk dll_lua_callk
+# define lua_pcallk dll_lua_pcallk
+# define lua_getglobal dll_lua_getglobal
+# define lua_setglobal dll_lua_setglobal
+# endif
+# if LUA_VERSION_NUM <= 502
+# define lua_replace dll_lua_replace
+# define lua_remove dll_lua_remove
+# endif
+# if LUA_VERSION_NUM >= 503
+# define lua_rotate dll_lua_rotate
+# define lua_copy dll_lua_copy
+# endif
+# define lua_typename dll_lua_typename
+# define lua_close dll_lua_close
+# define lua_gettop dll_lua_gettop
+# define lua_settop dll_lua_settop
+# define lua_pushvalue dll_lua_pushvalue
+# define lua_isnumber dll_lua_isnumber
+# define lua_isstring dll_lua_isstring
+# define lua_type dll_lua_type
+# define lua_rawequal dll_lua_rawequal
+# define lua_toboolean dll_lua_toboolean
+# define lua_tolstring dll_lua_tolstring
+# define lua_touserdata dll_lua_touserdata
+# define lua_pushnil dll_lua_pushnil
+# define lua_pushnumber dll_lua_pushnumber
+# define lua_pushinteger dll_lua_pushinteger
+# define lua_pushlstring dll_lua_pushlstring
+# define lua_pushstring dll_lua_pushstring
+# define lua_pushfstring dll_lua_pushfstring
+# define lua_pushcclosure dll_lua_pushcclosure
+# define lua_pushboolean dll_lua_pushboolean
+# define lua_pushlightuserdata dll_lua_pushlightuserdata
+# define lua_getfield dll_lua_getfield
+# define lua_rawget dll_lua_rawget
+# define lua_rawgeti dll_lua_rawgeti
+# define lua_createtable dll_lua_createtable
+# define lua_settable dll_lua_settable
+# if LUA_VERSION_NUM >= 504
+# define lua_newuserdatauv dll_lua_newuserdatauv
+# else
+# define lua_newuserdata dll_lua_newuserdata
+# endif
+# define lua_getmetatable dll_lua_getmetatable
+# define lua_setfield dll_lua_setfield
+# define lua_rawset dll_lua_rawset
+# define lua_rawseti dll_lua_rawseti
+# define lua_setmetatable dll_lua_setmetatable
+# define lua_next dll_lua_next
// libs
-#define luaopen_base dll_luaopen_base
-#define luaopen_table dll_luaopen_table
-#define luaopen_string dll_luaopen_string
-#define luaopen_math dll_luaopen_math
-#define luaopen_io dll_luaopen_io
-#define luaopen_os dll_luaopen_os
-#define luaopen_package dll_luaopen_package
-#define luaopen_debug dll_luaopen_debug
-#define luaL_openlibs dll_luaL_openlibs
+# define luaopen_base dll_luaopen_base
+# define luaopen_table dll_luaopen_table
+# define luaopen_string dll_luaopen_string
+# define luaopen_math dll_luaopen_math
+# define luaopen_io dll_luaopen_io
+# define luaopen_os dll_luaopen_os
+# define luaopen_package dll_luaopen_package
+# define luaopen_debug dll_luaopen_debug
+# define luaL_openlibs dll_luaL_openlibs
// lauxlib
-#if LUA_VERSION_NUM <= 501
+# if LUA_VERSION_NUM <= 501
void (*dll_luaL_register) (lua_State *L, const char *libname, const luaL_Reg *l);
char *(*dll_luaL_prepbuffer) (luaL_Buffer *B);
void (*dll_luaL_openlib) (lua_State *L, const char *libname, const luaL_Reg *l, int nup);
int (*dll_luaL_typerror) (lua_State *L, int narg, const char *tname);
int (*dll_luaL_loadfile) (lua_State *L, const char *filename);
int (*dll_luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, const char *name);
-#else
+# else
char *(*dll_luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
void (*dll_luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
int (*dll_luaL_loadfilex) (lua_State *L, const char *filename, const char *mode);
int (*dll_luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
int (*dll_luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
-#endif
-#if LUA_VERSION_NUM >= 504
+# endif
+# if LUA_VERSION_NUM >= 504
int (*dll_luaL_typeerror) (lua_State *L, int narg, const char *tname);
-#endif
+# endif
void (*dll_luaL_checkany) (lua_State *L, int narg);
const char *(*dll_luaL_checklstring) (lua_State *L, int numArg, size_t *l);
lua_Integer (*dll_luaL_checkinteger) (lua_State *L, int numArg);
void (*dll_luaL_pushresult) (luaL_Buffer *B);
int (*dll_luaL_loadstring) (lua_State *L, const char *s);
int (*dll_luaL_ref) (lua_State *L, int idx);
-#if LUA_VERSION_NUM <= 502
+# if LUA_VERSION_NUM <= 502
void (*dll_luaL_unref) (lua_State *L, int idx, int n);
-#else
+# else
void (*dll_luaL_unref) (lua_State *L, int idx, lua_Integer n);
-#endif
+# endif
// lua
-#if LUA_VERSION_NUM <= 501
+# if LUA_VERSION_NUM <= 501
lua_Number (*dll_lua_tonumber) (lua_State *L, int idx);
lua_Integer (*dll_lua_tointeger) (lua_State *L, int idx);
void (*dll_lua_call) (lua_State *L, int nargs, int nresults);
int (*dll_lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
-#else
+# else
lua_Number (*dll_lua_tonumberx) (lua_State *L, int idx, int *isnum);
lua_Integer (*dll_lua_tointegerx) (lua_State *L, int idx, int *isnum);
void (*dll_lua_callk) (lua_State *L, int nargs, int nresults, int ctx,
int ctx, lua_CFunction k);
void (*dll_lua_getglobal) (lua_State *L, const char *var);
void (*dll_lua_setglobal) (lua_State *L, const char *var);
-#endif
-#if LUA_VERSION_NUM <= 502
+# endif
+# if LUA_VERSION_NUM <= 502
void (*dll_lua_replace) (lua_State *L, int idx);
void (*dll_lua_remove) (lua_State *L, int idx);
-#endif
-#if LUA_VERSION_NUM >= 503
+# endif
+# if LUA_VERSION_NUM >= 503
void (*dll_lua_rotate) (lua_State *L, int idx, int n);
void (*dll_lua_copy) (lua_State *L, int fromidx, int toidx);
-#endif
+# endif
const char *(*dll_lua_typename) (lua_State *L, int tp);
void (*dll_lua_close) (lua_State *L);
int (*dll_lua_gettop) (lua_State *L);
void (*dll_lua_pushboolean) (lua_State *L, int b);
void (*dll_lua_pushlightuserdata) (lua_State *L, void *p);
void (*dll_lua_getfield) (lua_State *L, int idx, const char *k);
-#if LUA_VERSION_NUM <= 502
+# if LUA_VERSION_NUM <= 502
void (*dll_lua_rawget) (lua_State *L, int idx);
void (*dll_lua_rawgeti) (lua_State *L, int idx, int n);
-#else
+# else
int (*dll_lua_rawget) (lua_State *L, int idx);
int (*dll_lua_rawgeti) (lua_State *L, int idx, lua_Integer n);
-#endif
+# endif
void (*dll_lua_createtable) (lua_State *L, int narr, int nrec);
void (*dll_lua_settable) (lua_State *L, int idx);
-#if LUA_VERSION_NUM >= 504
+# if LUA_VERSION_NUM >= 504
void *(*dll_lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue);
-#else
+# else
void *(*dll_lua_newuserdata) (lua_State *L, size_t sz);
-#endif
+# endif
int (*dll_lua_getmetatable) (lua_State *L, int objindex);
void (*dll_lua_setfield) (lua_State *L, int idx, const char *k);
void (*dll_lua_rawset) (lua_State *L, int idx);
-#if LUA_VERSION_NUM <= 502
+# if LUA_VERSION_NUM <= 502
void (*dll_lua_rawseti) (lua_State *L, int idx, int n);
-#else
+# else
void (*dll_lua_rawseti) (lua_State *L, int idx, lua_Integer n);
-#endif
+# endif
int (*dll_lua_setmetatable) (lua_State *L, int objindex);
int (*dll_lua_next) (lua_State *L, int idx);
// libs
static const luaV_Reg luaV_dll[] = {
// lauxlib
-#if LUA_VERSION_NUM <= 501
+# if LUA_VERSION_NUM <= 501
{"luaL_register", (luaV_function) &dll_luaL_register},
{"luaL_prepbuffer", (luaV_function) &dll_luaL_prepbuffer},
{"luaL_openlib", (luaV_function) &dll_luaL_openlib},
{"luaL_typerror", (luaV_function) &dll_luaL_typerror},
{"luaL_loadfile", (luaV_function) &dll_luaL_loadfile},
{"luaL_loadbuffer", (luaV_function) &dll_luaL_loadbuffer},
-#else
+# else
{"luaL_prepbuffsize", (luaV_function) &dll_luaL_prepbuffsize},
{"luaL_setfuncs", (luaV_function) &dll_luaL_setfuncs},
{"luaL_loadfilex", (luaV_function) &dll_luaL_loadfilex},
{"luaL_loadbufferx", (luaV_function) &dll_luaL_loadbufferx},
{"luaL_argerror", (luaV_function) &dll_luaL_argerror},
-#endif
-#if LUA_VERSION_NUM >= 504
+# endif
+# if LUA_VERSION_NUM >= 504
{"luaL_typeerror", (luaV_function) &dll_luaL_typeerror},
-#endif
+# endif
{"luaL_checkany", (luaV_function) &dll_luaL_checkany},
{"luaL_checklstring", (luaV_function) &dll_luaL_checklstring},
{"luaL_checkinteger", (luaV_function) &dll_luaL_checkinteger},
{"luaL_ref", (luaV_function) &dll_luaL_ref},
{"luaL_unref", (luaV_function) &dll_luaL_unref},
// lua
-#if LUA_VERSION_NUM <= 501
+# if LUA_VERSION_NUM <= 501
{"lua_tonumber", (luaV_function) &dll_lua_tonumber},
{"lua_tointeger", (luaV_function) &dll_lua_tointeger},
{"lua_call", (luaV_function) &dll_lua_call},
{"lua_pcall", (luaV_function) &dll_lua_pcall},
-#else
+# else
{"lua_tonumberx", (luaV_function) &dll_lua_tonumberx},
{"lua_tointegerx", (luaV_function) &dll_lua_tointegerx},
{"lua_callk", (luaV_function) &dll_lua_callk},
{"lua_pcallk", (luaV_function) &dll_lua_pcallk},
{"lua_getglobal", (luaV_function) &dll_lua_getglobal},
{"lua_setglobal", (luaV_function) &dll_lua_setglobal},
-#endif
-#if LUA_VERSION_NUM <= 502
+# endif
+# if LUA_VERSION_NUM <= 502
{"lua_replace", (luaV_function) &dll_lua_replace},
{"lua_remove", (luaV_function) &dll_lua_remove},
-#endif
-#if LUA_VERSION_NUM >= 503
+# endif
+# if LUA_VERSION_NUM >= 503
{"lua_rotate", (luaV_function) &dll_lua_rotate},
{"lua_copy", (luaV_function) &dll_lua_copy},
-#endif
+# endif
{"lua_typename", (luaV_function) &dll_lua_typename},
{"lua_close", (luaV_function) &dll_lua_close},
{"lua_gettop", (luaV_function) &dll_lua_gettop},
{"lua_rawgeti", (luaV_function) &dll_lua_rawgeti},
{"lua_createtable", (luaV_function) &dll_lua_createtable},
{"lua_settable", (luaV_function) &dll_lua_settable},
-#if LUA_VERSION_NUM >= 504
+# if LUA_VERSION_NUM >= 504
{"lua_newuserdatauv", (luaV_function) &dll_lua_newuserdatauv},
-#else
+# else
{"lua_newuserdata", (luaV_function) &dll_lua_newuserdata},
-#endif
+# endif
{"lua_getmetatable", (luaV_function) &dll_lua_getmetatable},
{"lua_setfield", (luaV_function) &dll_lua_setfield},
{"lua_rawset", (luaV_function) &dll_lua_rawset},
}
return OK;
}
-#endif // DYNAMIC_LUA
+# endif // DYNAMIC_LUA
-#if defined(DYNAMIC_LUA)
+# if defined(DYNAMIC_LUA)
int
lua_enabled(int verbose)
{
return lua_link_init((char *)p_luadll, verbose) == OK;
}
-#endif
+# endif
-#if LUA_VERSION_NUM > 501 && LUA_VERSION_NUM < 504
+# if LUA_VERSION_NUM > 501 && LUA_VERSION_NUM < 504
static int
luaL_typeerror(lua_State *L, int narg, const char *tname)
{
tname, luaL_typename(L, narg));
return luaL_argerror(L, narg, msg);
}
-#endif
+# endif
static LUAV_INLINE void
luaV_getudata(lua_State *L, void *v)
return p;
}
-#define luaV_unbox(L,luatyp,ud) (*((luatyp *) lua_touserdata((L),(ud))))
+# define luaV_unbox(L,luatyp,ud) (*((luatyp *) lua_touserdata((L),(ud))))
-#define luaV_checkvalid(L,luatyp,ud) \
+# define luaV_checkvalid(L,luatyp,ud) \
luaV_checkcache((L), (void *) luaV_unbox((L),luatyp,(ud)))
static void *
lua_pop(L, 2); // original and modified strings
}
-#define luaV_newtype(typ,tname,luatyp,luatname) \
+# define luaV_newtype(typ,tname,luatyp,luatname) \
static luatyp * \
luaV_new##tname(lua_State *L, typ *obj) \
{ \
return o; \
}
-#define luaV_pushtype(typ,tname,luatyp) \
+# define luaV_pushtype(typ,tname,luatyp) \
static luatyp * \
luaV_push##tname(lua_State *L, typ *obj) \
{ \
return o; \
}
-#define luaV_type_tostring(tname,luatname) \
+# define luaV_type_tostring(tname,luatname) \
static int \
luaV_##tname##_tostring(lua_State *L) \
{ \
static int
luaV_dict_iter(lua_State *L UNUSED)
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
hashitem_T *hi = (hashitem_T *) lua_touserdata(L, lua_upvalueindex(1));
int n = lua_tointeger(L, lua_upvalueindex(2));
dictitem_T *di;
lua_pushinteger(L, n - 1);
lua_replace(L, lua_upvalueindex(2));
return 2;
-#else
+# else
return 0;
-#endif
+# endif
}
static int
{
buf_T *b = (buf_T *) luaV_checkvalid(L, luaV_Buffer, 1);
linenr_T n = (linenr_T) luaL_checkinteger(L, 2);
-#ifdef HAVE_SANDBOX
+# ifdef HAVE_SANDBOX
luaV_checksandbox(L);
-#endif
+# endif
if (n < 1 || n > b->b_ml.ml_line_count)
luaL_error(L, "invalid line number");
if (lua_isnil(L, 3)) // delete line
linenr_T n = (linenr_T) luaL_optinteger(L, 3, last);
buf_T *buf;
luaL_checktype(L, 2, LUA_TSTRING);
-#ifdef HAVE_SANDBOX
+# ifdef HAVE_SANDBOX
luaV_checksandbox(L);
-#endif
+# endif
// fix insertion line
if (n < 0) n = 0;
if (n > last) n = last;
int v = luaL_checkinteger(L, 3);
if (strncmp(s, "line", 4) == 0)
{
-#ifdef HAVE_SANDBOX
+# ifdef HAVE_SANDBOX
luaV_checksandbox(L);
-#endif
+# endif
if (v < 1 || v > w->w_buffer->b_ml.ml_line_count)
luaL_error(L, "line out of range");
w->w_cursor.lnum = v;
}
else if (strncmp(s, "col", 3) == 0)
{
-#ifdef HAVE_SANDBOX
+# ifdef HAVE_SANDBOX
luaV_checksandbox(L);
-#endif
+# endif
w->w_cursor.col = v - 1;
w->w_set_curswant = TRUE;
update_screen(UPD_VALID);
else if (strncmp(s, "width", 5) == 0)
{
win_T *win = curwin;
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
need_mouse_correct = TRUE;
-#endif
+# endif
curwin = w;
win_setwidth(v);
curwin = win;
else if (strncmp(s, "height", 6) == 0)
{
win_T *win = curwin;
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
need_mouse_correct = TRUE;
-#endif
+# endif
curwin = w;
win_setheight(v);
curwin = win;
luaV_open(lua_State *L)
{
char_u *s = NULL;
-#ifdef HAVE_SANDBOX
+# ifdef HAVE_SANDBOX
luaV_checksandbox(L);
-#endif
+# endif
if (lua_isstring(L, 1)) s = (char_u *) lua_tostring(L, 1);
luaV_pushbuffer(L, buflist_new(s, NULL, 1L, BLN_LISTED));
return 1;
return 0;
}
-#define LUA_VIM_FN_CODE \
+# define LUA_VIM_FN_CODE \
"vim.fn = setmetatable({}, {\n"\
" __index = function (t, key)\n"\
" local function _fn(...)\n"\
" end\n"\
" })"
-#define LUA_VIM_UPDATE_PACKAGE_PATHS \
+# define LUA_VIM_UPDATE_PACKAGE_PATHS \
"local last_vim_paths = {}\n"\
"vim._update_package_paths = function ()\n"\
" local cur_vim_paths = {}\n"\
" last_vim_paths = cur_vim_paths\n"\
"end"
-#define LUA_VIM_SETUP_VARIABLE_DICTS \
+# define LUA_VIM_SETUP_VARIABLE_DICTS \
"do\n"\
" local function make_dict_accessor(scope)\n"\
" local mt = {}\n"\
if (lua_isopen())
return OK;
-#ifdef DYNAMIC_LUA
+# ifdef DYNAMIC_LUA
if (!lua_enabled(TRUE))
{
emsg(_("Lua library cannot be loaded."));
return FAIL;
}
-#endif
+# endif
L = luaV_newstate();
return OK;
if (lua_isstring(L, -1)) // update line?
{
-#ifdef HAVE_SANDBOX
+# ifdef HAVE_SANDBOX
luaV_checksandbox(L);
-#endif
+# endif
ml_replace(l, luaV_toline(L, -1), TRUE);
changed_bytes(l, 0);
lua_pop(L, 1); // result from luaV_toline
}
}
-#define luaV_freetype(typ,tname) \
+# define luaV_freetype(typ,tname) \
void \
lua_##tname##_free(typ *o) \
{ \
# endif
static void (*dll_scheme_close_input_port)(Scheme_Object *port);
static void (*dll_scheme_count_lines)(Scheme_Object *port);
-#if MZSCHEME_VERSION_MAJOR < 360
+# if MZSCHEME_VERSION_MAJOR < 360
static Scheme_Object *(*dll_scheme_current_continuation_marks)(void);
-#else
+# else
static Scheme_Object *(*dll_scheme_current_continuation_marks)(Scheme_Object *prompt_tag);
-#endif
+# endif
static void (*dll_scheme_display)(Scheme_Object *obj, Scheme_Object *port);
static char *(*dll_scheme_display_to_string)(Scheme_Object *obj, OUTPUT_LEN_TYPE *len);
static int (*dll_scheme_eq)(Scheme_Object *obj1, Scheme_Object *obj2);
static void (*dll_scheme_set_config_path)(Scheme_Object *p);
# endif
-#if defined(DYNAMIC_MZSCHEME)
+# if defined(DYNAMIC_MZSCHEME)
// arrays are imported directly
-# define scheme_eof dll_scheme_eof
-# define scheme_false dll_scheme_false
-# define scheme_void dll_scheme_void
-# define scheme_null dll_scheme_null
-# define scheme_true dll_scheme_true
+# define scheme_eof dll_scheme_eof
+# define scheme_false dll_scheme_false
+# define scheme_void dll_scheme_void
+# define scheme_null dll_scheme_null
+# define scheme_true dll_scheme_true
// pointers are GetProcAddress'ed as pointers to pointer
-#if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE)
-# define scheme_current_thread (*dll_scheme_current_thread_ptr)
-# endif
-# define scheme_console_printf (*dll_scheme_console_printf_ptr)
-# define scheme_console_output (*dll_scheme_console_output_ptr)
-# define scheme_notify_multithread (*dll_scheme_notify_multithread_ptr)
+# if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE)
+# define scheme_current_thread (*dll_scheme_current_thread_ptr)
+# endif
+# define scheme_console_printf (*dll_scheme_console_printf_ptr)
+# define scheme_console_output (*dll_scheme_console_output_ptr)
+# define scheme_notify_multithread (*dll_scheme_notify_multithread_ptr)
// and functions in a usual way
-# define GC_malloc dll_GC_malloc
-# define GC_malloc_atomic dll_GC_malloc_atomic
-
-# define scheme_add_global dll_scheme_add_global
-# define scheme_add_global_symbol dll_scheme_add_global_symbol
-# define scheme_apply dll_scheme_apply
-# define scheme_basic_env dll_scheme_basic_env
-# define scheme_builtin_value dll_scheme_builtin_value
-# if MZSCHEME_VERSION_MAJOR >= 299
-# define scheme_byte_string_to_char_string dll_scheme_byte_string_to_char_string
-# define scheme_make_path dll_scheme_make_path
-# endif
-# define scheme_check_threads dll_scheme_check_threads
-# define scheme_close_input_port dll_scheme_close_input_port
-# define scheme_count_lines dll_scheme_count_lines
-# define scheme_current_continuation_marks \
+# define GC_malloc dll_GC_malloc
+# define GC_malloc_atomic dll_GC_malloc_atomic
+
+# define scheme_add_global dll_scheme_add_global
+# define scheme_add_global_symbol dll_scheme_add_global_symbol
+# define scheme_apply dll_scheme_apply
+# define scheme_basic_env dll_scheme_basic_env
+# define scheme_builtin_value dll_scheme_builtin_value
+# if MZSCHEME_VERSION_MAJOR >= 299
+# define scheme_byte_string_to_char_string dll_scheme_byte_string_to_char_string
+# define scheme_make_path dll_scheme_make_path
+# endif
+# define scheme_check_threads dll_scheme_check_threads
+# define scheme_close_input_port dll_scheme_close_input_port
+# define scheme_count_lines dll_scheme_count_lines
+# define scheme_current_continuation_marks \
dll_scheme_current_continuation_marks
-# define scheme_display dll_scheme_display
-# define scheme_display_to_string dll_scheme_display_to_string
-# define scheme_do_eval dll_scheme_do_eval
-# define scheme_dont_gc_ptr dll_scheme_dont_gc_ptr
-# define scheme_eq dll_scheme_eq
-# define scheme_eval dll_scheme_eval
-# define scheme_eval_string dll_scheme_eval_string
-# define scheme_eval_string_all dll_scheme_eval_string_all
-# define scheme_finish_primitive_module dll_scheme_finish_primitive_module
-# if MZSCHEME_VERSION_MAJOR < 299
-# define scheme_format dll_scheme_format
-# else
-# define scheme_format_utf8 dll_scheme_format_utf8
-# endif
-# define scheme_gc_ptr_ok dll_scheme_gc_ptr_ok
-# if MZSCHEME_VERSION_MAJOR < 299
-# define scheme_get_sized_byte_string_output dll_scheme_get_sized_string_output
-# else
-# define scheme_get_sized_byte_string_output \
+# define scheme_display dll_scheme_display
+# define scheme_display_to_string dll_scheme_display_to_string
+# define scheme_do_eval dll_scheme_do_eval
+# define scheme_dont_gc_ptr dll_scheme_dont_gc_ptr
+# define scheme_eq dll_scheme_eq
+# define scheme_eval dll_scheme_eval
+# define scheme_eval_string dll_scheme_eval_string
+# define scheme_eval_string_all dll_scheme_eval_string_all
+# define scheme_finish_primitive_module dll_scheme_finish_primitive_module
+# if MZSCHEME_VERSION_MAJOR < 299
+# define scheme_format dll_scheme_format
+# else
+# define scheme_format_utf8 dll_scheme_format_utf8
+# endif
+# define scheme_gc_ptr_ok dll_scheme_gc_ptr_ok
+# if MZSCHEME_VERSION_MAJOR < 299
+# define scheme_get_sized_byte_string_output dll_scheme_get_sized_string_output
+# else
+# define scheme_get_sized_byte_string_output \
dll_scheme_get_sized_byte_string_output
-# define scheme_get_param dll_scheme_get_param
-# endif
-# define scheme_intern_symbol dll_scheme_intern_symbol
-# define scheme_lookup_global dll_scheme_lookup_global
-# define scheme_make_closed_prim_w_arity dll_scheme_make_closed_prim_w_arity
-# define scheme_make_integer_value dll_scheme_make_integer_value
-# define scheme_make_pair dll_scheme_make_pair
-# define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity
-# if MZSCHEME_VERSION_MAJOR < 299
-# define scheme_make_byte_string dll_scheme_make_string
-# define scheme_make_byte_string_output_port dll_scheme_make_string_output_port
-# else
-# define scheme_make_byte_string dll_scheme_make_byte_string
-# define scheme_make_byte_string_output_port \
+# define scheme_get_param dll_scheme_get_param
+# endif
+# define scheme_intern_symbol dll_scheme_intern_symbol
+# define scheme_lookup_global dll_scheme_lookup_global
+# define scheme_make_closed_prim_w_arity dll_scheme_make_closed_prim_w_arity
+# define scheme_make_integer_value dll_scheme_make_integer_value
+# define scheme_make_pair dll_scheme_make_pair
+# define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity
+# if MZSCHEME_VERSION_MAJOR < 299
+# define scheme_make_byte_string dll_scheme_make_string
+# define scheme_make_byte_string_output_port dll_scheme_make_string_output_port
+# else
+# define scheme_make_byte_string dll_scheme_make_byte_string
+# define scheme_make_byte_string_output_port \
dll_scheme_make_byte_string_output_port
-# endif
-# define scheme_make_struct_instance dll_scheme_make_struct_instance
-# define scheme_make_struct_names dll_scheme_make_struct_names
-# define scheme_make_struct_type dll_scheme_make_struct_type
-# define scheme_make_struct_values dll_scheme_make_struct_values
-# define scheme_make_type dll_scheme_make_type
-# define scheme_make_vector dll_scheme_make_vector
-# define scheme_malloc_fail_ok dll_scheme_malloc_fail_ok
-# define scheme_open_input_file dll_scheme_open_input_file
-# define scheme_primitive_module dll_scheme_primitive_module
-# define scheme_proper_list_length dll_scheme_proper_list_length
-# define scheme_raise dll_scheme_raise
-# define scheme_read dll_scheme_read
-# define scheme_register_static dll_scheme_register_static
-# define scheme_set_stack_base dll_scheme_set_stack_base
-# define scheme_signal_error dll_scheme_signal_error
-# define scheme_wrong_type dll_scheme_wrong_type
-# if MZSCHEME_VERSION_MAJOR >= 299
-# define scheme_set_param dll_scheme_set_param
-# define scheme_current_config dll_scheme_current_config
-# define scheme_char_string_to_byte_string \
+# endif
+# define scheme_make_struct_instance dll_scheme_make_struct_instance
+# define scheme_make_struct_names dll_scheme_make_struct_names
+# define scheme_make_struct_type dll_scheme_make_struct_type
+# define scheme_make_struct_values dll_scheme_make_struct_values
+# define scheme_make_type dll_scheme_make_type
+# define scheme_make_vector dll_scheme_make_vector
+# define scheme_malloc_fail_ok dll_scheme_malloc_fail_ok
+# define scheme_open_input_file dll_scheme_open_input_file
+# define scheme_primitive_module dll_scheme_primitive_module
+# define scheme_proper_list_length dll_scheme_proper_list_length
+# define scheme_raise dll_scheme_raise
+# define scheme_read dll_scheme_read
+# define scheme_register_static dll_scheme_register_static
+# define scheme_set_stack_base dll_scheme_set_stack_base
+# define scheme_signal_error dll_scheme_signal_error
+# define scheme_wrong_type dll_scheme_wrong_type
+# if MZSCHEME_VERSION_MAJOR >= 299
+# define scheme_set_param dll_scheme_set_param
+# define scheme_current_config dll_scheme_current_config
+# define scheme_char_string_to_byte_string \
dll_scheme_char_string_to_byte_string
-# define scheme_char_string_to_path \
+# define scheme_char_string_to_path \
dll_scheme_char_string_to_path
-# define scheme_set_collects_path dll_scheme_set_collects_path
-# endif
-# define scheme_make_hash_table dll_scheme_make_hash_table
-# define scheme_hash_set dll_scheme_hash_set
-# define scheme_hash_get dll_scheme_hash_get
-# define scheme_make_double dll_scheme_make_double
-# define scheme_make_sized_byte_string dll_scheme_make_sized_byte_string
-# define scheme_namespace_require dll_scheme_namespace_require
-# define scheme_dynamic_wind dll_scheme_dynamic_wind
-# ifdef MZ_PRECISE_GC
-# define GC_malloc_one_tagged dll_GC_malloc_one_tagged
-# define GC_register_traversers dll_GC_register_traversers
-# endif
-# if MZSCHEME_VERSION_MAJOR >= 400
-# ifdef TRAMPOLINED_MZVIM_STARTUP
-# define scheme_main_setup dll_scheme_main_setup
-# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || MZSCHEME_VERSION_MAJOR >= 603
-# define scheme_register_tls_space dll_scheme_register_tls_space
+# define scheme_set_collects_path dll_scheme_set_collects_path
+# endif
+# define scheme_make_hash_table dll_scheme_make_hash_table
+# define scheme_hash_set dll_scheme_hash_set
+# define scheme_hash_get dll_scheme_hash_get
+# define scheme_make_double dll_scheme_make_double
+# define scheme_make_sized_byte_string dll_scheme_make_sized_byte_string
+# define scheme_namespace_require dll_scheme_namespace_require
+# define scheme_dynamic_wind dll_scheme_dynamic_wind
+# ifdef MZ_PRECISE_GC
+# define GC_malloc_one_tagged dll_GC_malloc_one_tagged
+# define GC_register_traversers dll_GC_register_traversers
+# endif
+# if MZSCHEME_VERSION_MAJOR >= 400
+# ifdef TRAMPOLINED_MZVIM_STARTUP
+# define scheme_main_setup dll_scheme_main_setup
+# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || MZSCHEME_VERSION_MAJOR >= 603
+# define scheme_register_tls_space dll_scheme_register_tls_space
+# endif
# endif
+# define scheme_init_collection_paths dll_scheme_init_collection_paths
+# define scheme_malloc_immobile_box dll_scheme_malloc_immobile_box
+# define scheme_free_immobile_box dll_scheme_free_immobile_box
+# endif
+# if MZSCHEME_VERSION_MAJOR >= 600
+# define scheme_embedded_load dll_scheme_embedded_load
+# define scheme_register_embedded_load dll_scheme_register_embedded_load
+# define scheme_set_config_path dll_scheme_set_config_path
# endif
-# define scheme_init_collection_paths dll_scheme_init_collection_paths
-# define scheme_malloc_immobile_box dll_scheme_malloc_immobile_box
-# define scheme_free_immobile_box dll_scheme_free_immobile_box
-# endif
-# if MZSCHEME_VERSION_MAJOR >= 600
-# define scheme_embedded_load dll_scheme_embedded_load
-# define scheme_register_embedded_load dll_scheme_register_embedded_load
-# define scheme_set_config_path dll_scheme_set_config_path
-# endif
-# ifndef PROTO
-# if MZSCHEME_VERSION_MAJOR >= 500
-# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC)
+# ifndef PROTO
+# if MZSCHEME_VERSION_MAJOR >= 500
+# if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC)
// define as function for macro in schthread.h
Thread_Local_Variables *
scheme_external_get_thread_local_variables(void)
{
return dll_scheme_external_get_thread_local_variables();
}
+# endif
# endif
# endif
-# endif
-#endif
+# endif
typedef struct
{
{"scheme_void", (void **)&dll_scheme_void},
{"scheme_null", (void **)&dll_scheme_null},
{"scheme_true", (void **)&dll_scheme_true},
-#if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE)
+# if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE)
{"scheme_current_thread", (void **)&dll_scheme_current_thread_ptr},
-#endif
+# endif
{"scheme_console_printf", (void **)&dll_scheme_console_printf_ptr},
{"scheme_console_output", (void **)&dll_scheme_console_output_ptr},
{"scheme_notify_multithread",
# else
{"scheme_format_utf8", (void **)&dll_scheme_format_utf8},
{"scheme_get_param", (void **)&dll_scheme_get_param},
-#endif
+# endif
{"scheme_gc_ptr_ok", (void **)&dll_scheme_gc_ptr_ok},
# if MZSCHEME_VERSION_MAJOR < 299
{"scheme_get_sized_string_output",
# else
{"scheme_get_sized_byte_string_output",
(void **)&dll_scheme_get_sized_byte_string_output},
-#endif
+# endif
{"scheme_intern_symbol", (void **)&dll_scheme_intern_symbol},
{"scheme_lookup_global", (void **)&dll_scheme_lookup_global},
{"scheme_make_closed_prim_w_arity",
{
// We can not unload the DLL. Racket's thread might be still alive.
#if 0
-#ifdef DYNAMIC_MZSCHEME
+# ifdef DYNAMIC_MZSCHEME
dynamic_mzscheme_end();
-#endif
+# endif
#endif
}
#endif
// setup 'current-library-collection-paths' parameter
-# if MZSCHEME_VERSION_MAJOR >= 299
+#if MZSCHEME_VERSION_MAJOR >= 299
{
Scheme_Object *coll_path = NULL;
int mustfree = FALSE;
if (mustfree)
vim_free(s);
}
-# ifdef MZSCHEME_COLLECTS
+# ifdef MZSCHEME_COLLECTS
if (coll_path == NULL)
{
coll_path = scheme_make_path(MZSCHEME_COLLECTS);
MZ_GC_CHECK();
}
-# endif
+# endif
if (coll_path != NULL)
{
scheme_set_collects_path(coll_path);
}
MZ_GC_UNREG();
}
-# else
-# ifdef MZSCHEME_COLLECTS
+#else
+# ifdef MZSCHEME_COLLECTS
{
Scheme_Object *coll_string = NULL;
Scheme_Object *coll_pair = NULL;
# endif
#endif
-# if MZSCHEME_VERSION_MAJOR >= 600
+#if MZSCHEME_VERSION_MAJOR >= 600
{
Scheme_Object *config_path = NULL;
int mustfree = FALSE;
if (mustfree)
vim_free(s);
}
-#ifdef MZSCHEME_CONFIGDIR
+# ifdef MZSCHEME_CONFIGDIR
if (config_path == NULL)
{
config_path = scheme_make_path(MZSCHEME_CONFIGDIR);
MZ_GC_CHECK();
}
-#endif
+# endif
if (config_path != NULL)
{
scheme_set_config_path(config_path);
}
MZ_GC_UNREG();
}
-# endif
+#endif
#if MZSCHEME_VERSION_MAJOR >= 400
scheme_init_collection_paths(environment, scheme_null);
MZ_GC_VAR_IN_REG(0, make_security_guard);
MZ_GC_REG();
-#if MZSCHEME_VERSION_MAJOR < 400
+# if MZSCHEME_VERSION_MAJOR < 400
{
Scheme_Object *make_security_guard_symbol = NULL;
MZ_GC_DECL_REG(1);
make_security_guard_symbol, environment);
MZ_GC_UNREG();
}
-#else
+# else
make_security_guard = scheme_builtin_value("make-security-guard");
MZ_GC_CHECK();
-#endif
+# endif
// setup sandbox guards
if (make_security_guard != NULL)
win = get_window_arg(prim->name, 1, argc, argv);
width = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
need_mouse_correct = TRUE;
-# endif
+#endif
savewin = curwin;
curwin = win->win;
tv->vval.v_string = vim_strsave(BYTE_STRING_VALUE(tmp));
MZ_GC_UNREG();
}
-#endif
+# endif
else if (SCHEME_VECTORP(obj) || SCHEME_NULLP(obj)
|| SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
{
Py_DECREF(output);
return 0;
}
-#define PyRun_String Vim_PyRun_String
-#define PyRun_SimpleString Vim_PyRun_SimpleString
+# define PyRun_String Vim_PyRun_String
+# define PyRun_SimpleString Vim_PyRun_SimpleString
#else // !defined(USE_LIMITED_API)
# if RUBY_VERSION >= 20
// USE_TYPEDDATA is not defined yet. We just check for 2.0.
# define rb_check_typeddata rb_check_typeddata_stub
-#endif
+# endif
# if RUBY_VERSION == 21
// Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
* this module:
*/
-#define MAX_PROP_WORDS 100000
+# define MAX_PROP_WORDS 100000
struct ServerReply
{
{
Window w;
XErrorHandler old_handler;
-#define MAX_NAME_LENGTH 100
+# define MAX_NAME_LENGTH 100
char_u propInfo[MAX_NAME_LENGTH + 20];
if (commProperty == None)
if (!got_x_error)
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
set_vim_var_string(VV_SEND_SERVER, name, -1);
-#endif
+# endif
serverName = vim_strsave(name);
need_maketitle = TRUE;
return 0;
return -2;
}
-#if defined(FEAT_GUI)
+# if defined(FEAT_GUI)
/*
* Clean out new ID from registry and set it as comm win.
* Change any registered window ID.
}
XUngrabServer(dpy);
}
-#endif
+# endif
/*
* Send to an instance of Vim via the X display.
if (commProperty == None && dpy != NULL && SendInit(dpy) < 0)
return -1;
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
ch_log(NULL, "serverSendToVim(%s, %s)", name, cmd);
-#endif
+# endif
// Execute locally if no display or target is ourselves
if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0))
}
}
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
ch_log(NULL, "serverSendToVim() result: %s",
pending.result == NULL ? "NULL" : (char *)pending.result);
-#endif
+# endif
if (result != NULL)
*result = pending.result;
else
time_t now;
XEvent event;
-#define UI_MSEC_DELAY 53
-#define SEND_MSEC_POLL 500
-#ifdef HAVE_SELECT
+# define UI_MSEC_DELAY 53
+# define SEND_MSEC_POLL 500
+# ifdef HAVE_SELECT
fd_set fds;
FD_ZERO(&fds);
FD_SET(ConnectionNumber(dpy), &fds);
-#else
+# else
struct pollfd fds;
fds.fd = ConnectionNumber(dpy);
fds.events = POLLIN;
-#endif
+# endif
time(&start);
while (TRUE)
if (seconds >= 0 && (now - start) >= seconds)
break;
-#ifdef FEAT_TIMERS
+# ifdef FEAT_TIMERS
check_due_timer();
-#endif
+# endif
// Just look out for the answer without calling back into Vim
if (localLoop)
{
-#ifdef HAVE_SELECT
+# ifdef HAVE_SELECT
struct timeval tv;
// Set the time every call, select() may change it to the remaining
tv.tv_usec = SEND_MSEC_POLL * 1000;
if (select(FD_SETSIZE, &fds, NULL, NULL, &tv) < 0)
break;
-#else
+# else
if (poll(&fds, 1, SEND_MSEC_POLL) < 0)
break;
-#endif
+# endif
}
else
{
int code;
char_u *tofree;
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
ch_log(NULL, "server_parse_message() numItems: %ld", numItems);
-#endif
+# endif
/*
* Several commands and results could arrive in the property at
enc = NULL;
while ((long_u)(p - propInfo) < numItems && *p == '-')
{
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
ch_log(NULL, "server_parse_message() item: %c, %s", p[-2], p);
-#endif
+# endif
switch (p[1])
{
case 'r':
{
return curbuf->b_p_si
&& !curbuf->b_p_cin
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
&& *curbuf->b_p_inde == NUL
-# endif
+#endif
&& !p_paste;
}
* Note: If you change CTRL-X submode, you must also maintain ctrl_x_msgs[] and
* ctrl_x_mode_names[] below.
*/
-# define CTRL_X_WANT_IDENT 0x100
-
-# define CTRL_X_NORMAL 0 // CTRL-N CTRL-P completion, default
-# define CTRL_X_NOT_DEFINED_YET 1
-# define CTRL_X_SCROLL 2
-# define CTRL_X_WHOLE_LINE 3
-# define CTRL_X_FILES 4
-# define CTRL_X_TAGS (5 + CTRL_X_WANT_IDENT)
-# define CTRL_X_PATH_PATTERNS (6 + CTRL_X_WANT_IDENT)
-# define CTRL_X_PATH_DEFINES (7 + CTRL_X_WANT_IDENT)
-# define CTRL_X_FINISHED 8
-# define CTRL_X_DICTIONARY (9 + CTRL_X_WANT_IDENT)
-# define CTRL_X_THESAURUS (10 + CTRL_X_WANT_IDENT)
-# define CTRL_X_CMDLINE 11
-# define CTRL_X_FUNCTION 12
-# define CTRL_X_OMNI 13
-# define CTRL_X_SPELL 14
-# define CTRL_X_LOCAL_MSG 15 // only used in "ctrl_x_msgs"
-# define CTRL_X_EVAL 16 // for builtin function complete()
-# define CTRL_X_CMDLINE_CTRL_X 17 // CTRL-X typed in CTRL_X_CMDLINE
-# define CTRL_X_REGISTER 18 // complete words from registers
-
-# define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT]
+#define CTRL_X_WANT_IDENT 0x100
+
+#define CTRL_X_NORMAL 0 // CTRL-N CTRL-P completion, default
+#define CTRL_X_NOT_DEFINED_YET 1
+#define CTRL_X_SCROLL 2
+#define CTRL_X_WHOLE_LINE 3
+#define CTRL_X_FILES 4
+#define CTRL_X_TAGS (5 + CTRL_X_WANT_IDENT)
+#define CTRL_X_PATH_PATTERNS (6 + CTRL_X_WANT_IDENT)
+#define CTRL_X_PATH_DEFINES (7 + CTRL_X_WANT_IDENT)
+#define CTRL_X_FINISHED 8
+#define CTRL_X_DICTIONARY (9 + CTRL_X_WANT_IDENT)
+#define CTRL_X_THESAURUS (10 + CTRL_X_WANT_IDENT)
+#define CTRL_X_CMDLINE 11
+#define CTRL_X_FUNCTION 12
+#define CTRL_X_OMNI 13
+#define CTRL_X_SPELL 14
+#define CTRL_X_LOCAL_MSG 15 // only used in "ctrl_x_msgs"
+#define CTRL_X_EVAL 16 // for builtin function complete()
+#define CTRL_X_CMDLINE_CTRL_X 17 // CTRL-X typed in CTRL_X_CMDLINE
+#define CTRL_X_REGISTER 18 // complete words from registers
+
+#define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT]
// Message for CTRL-X mode, index is ctrl_x_mode.
static char *ctrl_x_msgs[] =
};
// values for cp_flags
-# define CP_ORIGINAL_TEXT 1 // the original text when the expansion begun
-# define CP_FREE_FNAME 2 // cp_fname is allocated
-# define CP_CONT_S_IPOS 4 // use CONT_S_IPOS for compl_cont_status
-# define CP_EQUAL 8 // ins_compl_equal() always returns TRUE
-# define CP_ICASE 16 // ins_compl_equal() ignores case
-# define CP_FAST 32 // use fast_breakcheck instead of ui_breakcheck
+#define CP_ORIGINAL_TEXT 1 // the original text when the expansion begun
+#define CP_FREE_FNAME 2 // cp_fname is allocated
+#define CP_CONT_S_IPOS 4 // use CONT_S_IPOS for compl_cont_status
+#define CP_EQUAL 8 // ins_compl_equal() always returns TRUE
+#define CP_ICASE 16 // ins_compl_equal() ignores case
+#define CP_FAST 32 // use fast_breakcheck instead of ui_breakcheck
/*
* All the current matches are stored in a list.
// List of flags for method of completion.
static int compl_cont_status = 0;
-# define CONT_ADDING 1 // "normal" or "adding" expansion
-# define CONT_INTRPT (2 + 4) // a ^X interrupted the current expansion
+#define CONT_ADDING 1 // "normal" or "adding" expansion
+#define CONT_INTRPT (2 + 4) // a ^X interrupted the current expansion
// it's set only iff N_ADDS is set
-# define CONT_N_ADDS 4 // next ^X<> will add-new or expand-current
-# define CONT_S_IPOS 8 // next ^X<> will set initial_pos?
+#define CONT_N_ADDS 4 // next ^X<> will add-new or expand-current
+#define CONT_S_IPOS 8 // next ^X<> will set initial_pos?
// if so, word-wise-expansion will set SOL
-# define CONT_SOL 16 // pattern includes start of line, just for
+#define CONT_SOL 16 // pattern includes start of line, just for
// word-wise expansion, not set for ^X^L
-# define CONT_LOCAL 32 // for ctrl_x_mode 0, ^X^P/^X^N do a local
+#define CONT_LOCAL 32 // for ctrl_x_mode 0, ^X^P/^X^N do a local
// expansion, (eg use complete=.)
static int compl_opt_refresh_always = FALSE;
static void ins_compl_restart(void);
static void ins_compl_set_original_text(char_u *str, size_t len);
static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg);
-# if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL)
+#if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL)
static void ins_compl_add_list(list_T *list);
static void ins_compl_add_dict(dict_T *dict);
static int get_userdefined_compl_info(colnr_T curs_col, callback_T *cb, int *startcol);
static void get_cpt_func_completion_matches(callback_T *cb);
static callback_T *get_callback_if_cpt_func(char_u *p, int idx);
-# endif
+#endif
static int setup_cpt_sources(void);
static int is_cpt_func_refresh_always(void);
static void cpt_sources_clear(void);
// backticks (for security, the 'dict' option may have been set in
// a modeline).
copy_option_part(&dict, buf, LSIZE, ",");
-# ifdef FEAT_SPELL
+#ifdef FEAT_SPELL
if (!thesaurus && STRCMP(buf, "spell") == 0)
count = -1;
else
-# endif
+#endif
if (vim_strchr(buf, '`') != NULL
|| expand_wildcards(1, &buf, &count, &files,
EW_FILE|EW_SILENT) != OK)
count = 0;
}
-# ifdef FEAT_SPELL
+#ifdef FEAT_SPELL
if (count == -1)
{
// Complete from active spelling. Skip "\<" in the pattern, we
spell_dump_compl(ptr, regmatch.rm_ic, &dir, 0);
}
else
-# endif
+#endif
if (count > 0) // avoid warning for using "files" uninit
{
ins_compl_files(count, files, thesaurus, flags, ®match, buf,
void
set_buflocal_cpt_callbacks(buf_T *buf UNUSED)
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (buf == NULL || cpt_cb_count == 0)
return;
(void)copy_cpt_callbacks(&buf->b_p_cpt_cb, &buf->b_p_cpt_count, cpt_cb,
cpt_cb_count);
-#endif
+# endif
}
/*
{
int ret = OK;
listitem_T *item;
-#define CI_WHAT_MODE 0x01
-#define CI_WHAT_PUM_VISIBLE 0x02
-#define CI_WHAT_ITEMS 0x04
-#define CI_WHAT_SELECTED 0x08
-#define CI_WHAT_COMPLETED 0x10
-#define CI_WHAT_MATCHES 0x20
-#define CI_WHAT_PREINSERTED_TEXT 0x40
-#define CI_WHAT_ALL 0xff
+# define CI_WHAT_MODE 0x01
+# define CI_WHAT_PUM_VISIBLE 0x02
+# define CI_WHAT_ITEMS 0x04
+# define CI_WHAT_SELECTED 0x08
+# define CI_WHAT_COMPLETED 0x10
+# define CI_WHAT_MATCHES 0x20
+# define CI_WHAT_PREINSERTED_TEXT 0x40
+# define CI_WHAT_ALL 0xff
int what_flag;
if (what_list == NULL)
int is_cygpty(int fd);
int is_cygpty_used(void);
#else
-#define is_cygpty(fd) 0
-#define is_cygpty_used() 0
+# define is_cygpty(fd) 0
+# define is_cygpty_used() 0
#endif
#endif // _ISCYGPTY_H
status = job->jv_status == JOB_FAILED ? "fail"
: job->jv_status >= JOB_ENDED ? "dead"
: "run";
-# ifdef UNIX
+#ifdef UNIX
vim_snprintf((char *)buf, NUMBUFLEN,
"process %ld %s", (long)job->jv_pid, status);
-# elif defined(MSWIN)
+#elif defined(MSWIN)
vim_snprintf((char *)buf, NUMBUFLEN,
"process %ld %s",
(long)job->jv_proc_info.dwProcessId,
status);
-# else
+#else
// fall-back
vim_snprintf((char *)buf, NUMBUFLEN, "process ? %s", status);
-# endif
+#endif
return buf;
}
* toupper() and tolower() implementations only work for ASCII.
*/
#ifdef MSWIN
-# define TOUPPER_LOC(c) toupper_tab[(c) & 255]
-# define TOLOWER_LOC(c) tolower_tab[(c) & 255]
+# define TOUPPER_LOC(c) toupper_tab[(c) & 255]
+# define TOLOWER_LOC(c) tolower_tab[(c) & 255]
#else
# ifdef BROKEN_TOUPPER
# define TOUPPER_LOC(c) (SAFE_islower(c) ? SAFE_toupper(c) : (c))
# define mch_stat(n, p) stat(vms_fixfilename(n), (p))
#else
# if !defined(MSWIN) && !defined(PROTO)
-# define mch_access(n, p) access((n), (p))
+# define mch_access(n, p) access((n), (p))
# endif
// Use 64-bit fstat function on MS-Windows.
#define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))
#ifdef FEAT_MENU
-#define FOR_ALL_MENUS(m) \
+# define FOR_ALL_MENUS(m) \
for ((m) = root_menu; (m) != NULL; (m) = (m)->next)
-#define FOR_ALL_CHILD_MENUS(p, c) \
+# define FOR_ALL_CHILD_MENUS(p, c) \
for ((c) = (p)->children; (c) != NULL; (c) = (c)->next)
#endif
for ((sign) = (buf)->b_signlist; (sign) != NULL; (sign) = (sign)->se_next)
#ifdef FEAT_SPELL
-#define FOR_ALL_SPELL_LANGS(slang) \
+# define FOR_ALL_SPELL_LANGS(slang) \
for ((slang) = first_lang; (slang) != NULL; (slang) = (slang)->sl_next)
#endif
// Various parameters passed between main() and other functions.
static mparm_T params;
-#ifdef _IOLBF
+# ifdef _IOLBF
static void *s_vbuf = NULL; // buffer for setvbuf()
-#endif
+# endif
-#ifndef NO_VIM_MAIN // skip this for unittests
+# ifndef NO_VIM_MAIN // skip this for unittests
static char_u *start_dir = NULL; // current working dir on startup
static int has_dash_c_arg = FALSE;
-# ifdef VIMDLL
+# ifdef VIMDLL
__declspec(dllexport)
-# endif
+# endif
int
-# ifdef MSWIN
+# ifdef MSWIN
VimMain
-# else
+# else
main
-# endif
+# endif
(int argc, char **argv)
{
-#if defined(STARTUPTIME) || defined(CLEAN_RUNTIMEPATH)
+# if defined(STARTUPTIME) || defined(CLEAN_RUNTIMEPATH)
int i;
-#endif
+# endif
/*
* Do any system-specific initialisations. These can NOT use IObuff or
*/
mch_early_init();
-#ifdef MSWIN
+# ifdef MSWIN
/*
* MinGW expands command line arguments, which confuses our code to
* convert when 'encoding' changes. Get the unexpanded arguments.
*/
argc = get_cmd_argsW(&argv);
-#endif
+# endif
// Many variables are in "params" so that we can pass them to invoked
// functions without a lot of arguments. "argc" and "argv" are also
params.argc = argc;
params.argv = argv;
params.want_full_screen = TRUE;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
params.use_debug_break_level = -1;
-#endif
+# endif
params.window_count = -1;
autocmd_init();
-#ifdef FEAT_RUBY
+# ifdef FEAT_RUBY
{
int ruby_stack_start;
vim_ruby_init((void *)&ruby_stack_start);
}
-#endif
+# endif
-#ifdef FEAT_TCL
+# ifdef FEAT_TCL
vim_tcl_init(params.argv[0]);
-#endif
+# endif
-#ifdef MEM_PROFILE
+# ifdef MEM_PROFILE
atexit(vim_mem_profile_dump);
-#endif
+# endif
/*
* Various initialisations #1 shared with tests.
*/
common_init_1();
-#if defined(STARTUPTIME) || defined(FEAT_JOB_CHANNEL)
+# if defined(STARTUPTIME) || defined(FEAT_JOB_CHANNEL)
// Need to find "--startuptime" and "--log" before actually parsing
// arguments.
for (i = 1; i < argc - 1; ++i)
{
-# ifdef STARTUPTIME
+# ifdef STARTUPTIME
if (STRICMP(argv[i], "--startuptime") == 0 && time_fd == NULL)
{
time_fd = mch_fopen(argv[i + 1], "a");
TIME_MSG("--- VIM STARTING ---");
}
-# endif
-# ifdef FEAT_EVAL
+# endif
+# ifdef FEAT_EVAL
if (STRICMP(argv[i], "--log") == 0)
ch_logfile((char_u *)(argv[i + 1]), (char_u *)"ao");
-# endif
+# endif
}
-#endif
+# endif
-#ifdef CLEAN_RUNTIMEPATH
+# ifdef CLEAN_RUNTIMEPATH
// Need to find "--clean" before actually parsing arguments.
for (i = 1; i < argc; ++i)
if (STRICMP(argv[i], "--clean") == 0)
params.clean = TRUE;
break;
}
-#endif
-#ifdef MSWIN
+# endif
+# ifdef MSWIN
// Need to find "-register" and "-unregister" before loading any libraries.
for (i = 1; i < argc; ++i)
if ((STRICMP(argv[i] + 1, "register") == 0
found_register_arg = TRUE;
break;
}
-#endif
+# endif
/*
* Various initialisations #2 shared with tests.
*/
common_init_2(¶ms);
-#ifdef VIMDLL
+# ifdef VIMDLL
// Check if the current executable file is for the GUI subsystem.
gui.starting = mch_is_gui_executable();
-#elif defined(FEAT_GUI_MSWIN)
+# elif defined(FEAT_GUI_MSWIN)
gui.starting = TRUE;
-#endif
+# endif
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
/*
* Do the client-server stuff, unless "--servername ''" was used.
* This may exit Vim if the command was sent to the server.
*/
exec_on_server(¶ms);
-#endif
+# endif
/*
* Figure out the way to work from the command name argv[0].
* there is no terminal version, and on Windows we can't fork one off with
* :gui.
*/
-#ifdef ALWAYS_USE_GUI
+# ifdef ALWAYS_USE_GUI
gui.starting = TRUE;
-#else
-# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
+# else
+# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
/*
* Check if the GUI can be started. Reset gui.starting if not.
* Don't know about other systems, stay on the safe side and don't check.
mch_exit(1);
}
}
-# endif
-#endif
+# endif
+# endif
if (GARGCOUNT > 0)
{
-#ifdef EXPAND_FILENAMES
+# ifdef EXPAND_FILENAMES
/*
* Expand wildcards in file names.
*/
if (start_dir != NULL)
mch_chdir((char *)start_dir);
}
-#endif
+# endif
params.fname = alist_name(&GARGLIST[0]);
}
-#ifdef MSWIN
+# ifdef MSWIN
{
// Remember the number of entries in the argument list. If it changes
// we don't react on setting 'encoding'.
set_alist_count();
}
-#endif
+# endif
-#ifdef MSWIN
+# ifdef MSWIN
if (GARGCOUNT == 1 && params.full_path)
{
/*
if (start_dir != NULL)
mch_dirname(start_dir, MAXPATHL);
}
-#endif
+# endif
TIME_MSG("expanding arguments");
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
if (params.diff_mode && params.window_count == -1)
params.window_count = 0; // open up to 3 windows
-#endif
+# endif
// Don't redraw until much later.
++RedrawingDisabled;
* For GTK we can't be sure, but when started from the desktop it doesn't
* make sense to try using a terminal.
*/
-#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \
+# if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \
|| defined(VIMDLL)
if (gui.starting
-# ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
&& !isatty(2)
-# endif
+# endif
)
params.want_full_screen = FALSE;
-#endif
+# endif
/*
* mch_init() sets up the terminal (window) for use. This must be
mch_init();
TIME_MSG("shell init");
-#ifdef USE_XSMP
+# ifdef USE_XSMP
/*
* For want of anywhere else to do it, try to connect to xsmp here.
* Fitting it in after gui_mch_init, but before gui_init (via termcapinit).
TIME_MSG("xsmp init");
}
}
-#endif
+# endif
/*
* Print a warning if stdout is not a terminal.
*/
check_tty(¶ms);
-#ifdef _IOLBF
+# ifdef _IOLBF
if (silent_mode)
{
// Ensure output works usefully without a tty: buffer lines instead of
if (s_vbuf != NULL)
setvbuf(stdout, s_vbuf, _IOLBF, BUFSIZ);
}
-#endif
+# endif
// This message comes before term inits, but after setting "silent_mode"
// when the input is not a tty. Omit the message with --not-a-term.
*/
ui_get_shellsize(); // inits Rows and Columns
win_init_size();
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
// Set the 'diff' option now, so that it can be checked for in a .vimrc
// file. There is no buffer yet though.
if (params.diff_mode)
diff_win_options(firstwin, FALSE);
-#endif
+# endif
cmdline_row = Rows - p_ch;
cmdline_col_off = 0;
init_highlight(TRUE, FALSE); // set the default highlight groups
TIME_MSG("init highlight");
-#if defined(FEAT_TERMRESPONSE)
+# if defined(FEAT_TERMRESPONSE)
init_term_props(TRUE);
-#endif
+# endif
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// Set the break level after the terminal is initialized.
debug_break_level = params.use_debug_break_level;
-#endif
+# endif
// Reset 'loadplugins' for "-u NONE" before "--cmd" arguments.
// Allows for setting 'loadplugins' there.
// Source startup scripts.
source_startup_scripts(¶ms);
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
set_vim_var_nr(VV_VIM_DID_INIT, 1L);
-#endif
+# endif
-#ifdef FEAT_MZSCHEME
+# ifdef FEAT_MZSCHEME
/*
* Newer version of MzScheme (Racket) require earlier (trampolined)
* initialisation via scheme_main_setup.
* Do source startup scripts, so that 'mzschemedll' can be set.
*/
return mzscheme_main();
-#else
+# else
return vim_main2();
-#endif
+# endif
}
-#endif // NO_VIM_MAIN
+# endif // NO_VIM_MAIN
#endif // PROTO
#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) && defined(FEAT_CLIPBOARD)
vim_main2(void)
{
#ifndef NO_VIM_MAIN
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
/*
* Read all the plugin files.
* Only when compiled with +eval, since most plugins need it.
{
char_u *rtp_copy = NULL;
char_u *plugin_pattern = (char_u *)
-# if defined(VMS) || defined(AMIGA) // VMS and Amiga don't handle the "**".
+# if defined(VMS) || defined(AMIGA) // VMS and Amiga don't handle the "**".
"plugin/*.vim"
-# else
+# else
"plugin/**/*.vim"
-# endif
+# endif
;
// First add all package directories to 'runtimepath', so that their
source_runtime(plugin_pattern, DIP_ALL | DIP_AFTER);
TIME_MSG("loading after plugins");
}
-#endif
+# endif
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
// Decide about window layout for diff mode after reading vimrc.
if (params.diff_mode && params.window_layout == 0)
{
else
params.window_layout = WIN_VER; // use vertical split
}
-#endif
+# endif
/*
* Recovery mode without a file name: List swap files.
if (params.no_swap_file)
p_uc = 0;
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.starting)
{
-# if defined(UNIX) || defined(VMS)
+# if defined(UNIX) || defined(VMS)
// When something caused a message from a vimrc script, need to output
// an extra newline before the shell prompt.
if (did_emsg || msg_didout)
putchar('\n');
-# endif
+# endif
gui_start(NULL); // will set full_screen to TRUE
TIME_MSG("starting GUI");
mch_exit(1);
firstwin->w_prev_height = firstwin->w_height; // may have changed
}
-#endif
+# endif
-#ifdef FEAT_VIMINFO
+# ifdef FEAT_VIMINFO
/*
* Read in registers, history etc, but not marks, from the viminfo file.
* This is where v:oldfiles gets filled.
read_viminfo(NULL, VIF_WANT_INFO | VIF_GET_OLDFILES);
TIME_MSG("reading viminfo");
}
-#endif
-#ifdef FEAT_EVAL
+# endif
+# ifdef FEAT_EVAL
// It's better to make v:oldfiles an empty list than NULL.
if (get_vim_var_list(VV_OLDFILES) == NULL)
set_vim_var_list(VV_OLDFILES, list_alloc());
-#endif
+# endif
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
/*
* "-q errorfile": Load the error file now.
* If the error file can't be read, exit before doing anything else.
}
TIME_MSG("reading errorfile");
}
-#endif
+# endif
/*
* Start putting things on the screen.
if (!exmode_active)
msg_scroll = FALSE;
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
/*
* This seems to be required to make callbacks to be called now, instead
* of after things have been put on the screen, which then may be deleted
gui_wait_for_chars(50L, typebuf.tb_change_cnt);
TIME_MSG("GUI delay");
}
-#endif
+# endif
-#if defined(FEAT_GUI_PHOTON) && defined(FEAT_CLIPBOARD)
+# if defined(FEAT_GUI_PHOTON) && defined(FEAT_CLIPBOARD)
qnx_clip_init();
-#endif
+# endif
-#if defined(MACOS_X) && defined(FEAT_CLIPBOARD)
+# if defined(MACOS_X) && defined(FEAT_CLIPBOARD)
clip_init(TRUE);
-#endif
+# endif
-#ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
// Start using the X clipboard, unless the GUI was started.
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (!gui.in_use)
-# endif
+# endif
{
setup_term_clip();
TIME_MSG("setup x11 clipboard");
}
-#endif
+# endif
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
// Prepare for being a Vim server.
prepare_server(¶ms);
-#endif
+# endif
-#ifdef FEAT_WAYLAND
-# ifdef FEAT_GUI
+# ifdef FEAT_WAYLAND
+# ifdef FEAT_GUI
if (!gui.in_use)
-# endif
+# endif
{
sprintf(wayland_vim_special_mime, "application/x-vim-instance-%ld",
mch_get_pid());
{
TIME_MSG("connected to Wayland display");
-# ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
if (clip_init_wayland() == OK)
TIME_MSG("setup Wayland clipboard");
-# endif
+# endif
}
}
-#endif
+# endif
-#ifdef HAVE_CLIPMETHOD
+# ifdef HAVE_CLIPMETHOD
choose_clipmethod();
-#endif
+# endif
/*
* If "-" argument given: Read file from stdin.
if (params.edit_type == EDIT_STDIN && !recoverymode)
read_stdin();
-#if defined(UNIX) || defined(VMS)
+# if defined(UNIX) || defined(VMS)
// When switching screens and something caused a message from a vimrc
// script, need to output an extra newline on exit.
if ((did_emsg || msg_didout) && *T_TI != NUL && params.edit_type != EDIT_STDIN)
newline_on_exit = TRUE;
-#endif
+# endif
/*
* When done something that is not allowed or given an error message call
scroll_region_reset(); // In case Rows changed
scroll_start(); // may scroll the screen to the right position
-#if defined(UNIX) || defined(VMS) || defined(MACOS_X)
+# if defined(UNIX) || defined(VMS) || defined(MACOS_X)
term_push_title(SAVE_RESTORE_BOTH);
-#endif
+# endif
/*
* Don't clear the screen when starting in Ex mode, unless using the GUI.
*/
if (exmode_active
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-#endif
+# endif
)
set_must_redraw(UPD_CLEAR);
else
TIME_MSG("clearing screen");
}
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (params.ask_for_key)
{
crypt_check_current_method();
(void)crypt_get_key(TRUE, TRUE);
TIME_MSG("getting crypt key");
}
-#endif
+# endif
no_wait_return = TRUE;
create_windows(¶ms);
TIME_MSG("opening buffers");
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// clear v:swapcommand
set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);
-#endif
+# endif
// Ex starts at last line of the file
if (exmode_active)
TIME_MSG("BufEnter autocommands");
setpcmark();
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
/*
* When started with "-q errorfile" jump to first error now.
*/
qf_jump(NULL, 0, 0, FALSE);
TIME_MSG("jump to first error");
}
-#endif
+# endif
/*
* If opened more than one window, start editing files in the other
edit_buffers(¶ms, start_dir);
vim_free(start_dir);
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
if (params.diff_mode)
{
win_T *wp;
FOR_ALL_WINDOWS(wp)
diff_win_options(wp, TRUE);
}
-#endif
+# endif
/*
* Shorten any of the filenames, but only when absolute.
getout(1);
}
-#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
+# if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
// Temporarily set x_jump_env to here in case there is an X11 IO error,
// because x_jump_env is only actually set in main_loop(), before
// exe_commands(). May not be the best solution since commands passed via
if (jump_result == 0)
{
-#endif
+# endif
// Execute any "+", "-c" and "-S" arguments.
if (params.n_commands > 0)
exe_commands(¶ms);
-#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
+# if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
}
else
// Restore state and continue just like what main_loop() does.
x_restore_state();
-#endif
+# endif
// Must come before the may_req_ calls.
starting = 0;
-#if defined(FEAT_TERMRESPONSE)
+# if defined(FEAT_TERMRESPONSE)
// Must be done before redrawing, puts a few characters on the screen.
check_terminal_behavior();
-#endif
+# endif
RedrawingDisabled = 0;
redraw_all_later(UPD_NOT_VALID);
// 'autochdir' has been postponed
DO_AUTOCHDIR;
-#ifdef FEAT_TERMRESPONSE
+# ifdef FEAT_TERMRESPONSE
// Requesting the termresponse is postponed until here, so that a "-c q"
// argument doesn't make it appear in the shell Vim was started from.
may_req_termresponse();
may_req_bg_color();
-#endif
+# endif
// start in insert mode
if (p_im)
need_start_insertmode = TRUE;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
set_vim_var_nr(VV_VIM_DID_ENTER, 1L);
-#endif
+# endif
apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf);
TIME_MSG("VimEnter autocommands");
-#if defined(FEAT_EVAL) && defined(FEAT_CLIPBOARD)
+# if defined(FEAT_EVAL) && defined(FEAT_CLIPBOARD)
// Adjust default register name for "unnamed" in 'clipboard'. Can only be
// done after the clipboard is available and all initial commands that may
// modify the 'clipboard' setting have run; i.e. just before entering the
// main loop.
reset_reg_var();
-#endif
+# endif
-#if defined(FEAT_DIFF)
+# if defined(FEAT_DIFF)
// When a startup script or session file setup for diff'ing and
// scrollbind, sync the scrollbind now.
if (curwin->w_p_diff && curwin->w_p_scb)
check_scrollbind((linenr_T)0, 0L);
TIME_MSG("diff scrollbinding");
}
-#endif
+# endif
-#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
-# ifdef VIMDLL
+# if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
+# ifdef VIMDLL
if (!gui.in_use)
-# endif
+# endif
mch_set_winsize_now(); // Allow winsize changes from now on
-#endif
+# endif
-#if defined(FEAT_GUI)
+# if defined(FEAT_GUI)
// When tab pages were created, may need to update the tab pages line and
// scrollbars. This is skipped while creating them.
if (gui.in_use && first_tabpage->tp_next != NULL)
gui_update_scrollbars(TRUE);
}
need_mouse_correct = TRUE;
-#endif
+# endif
// If ":startinsert" command used, stuff a dummy command to be able to
// call normal_cmd(), which will then start Insert mode.
if (restart_edit != 0)
stuffcharReadbuff(K_NOP);
-#ifdef FEAT_NETBEANS_INTG
+# ifdef FEAT_NETBEANS_INTG
if (netbeansArg != NULL && strncmp("-nb", netbeansArg, 3) == 0)
{
-# ifdef FEAT_GUI
-# if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \
+# ifdef FEAT_GUI
+# if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \
&& !defined(FEAT_GUI_MSWIN)
if (gui.in_use)
{
mch_errmsg(_("netbeans is not supported with this GUI\n"));
mch_exit(2);
}
+# endif
# endif
-# endif
// Tell the client that it can start sending commands.
netbeans_open(netbeansArg + 3, TRUE);
}
-#endif
+# endif
// Redraw at least once, also when 'lazyredraw' is set, to make sure the
// window title gets updated.
initstr = gettail((char_u *)parmp->argv[0]);
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
set_vim_var_string(VV_PROGNAME, initstr, -1);
set_progpath((char_u *)parmp->argv[0]);
-#endif
+# endif
if (TOLOWER_ASC(initstr[0]) == 'r')
{
&& (TOLOWER_ASC(initstr[1]) == 'v'
|| TOLOWER_ASC(initstr[1]) == 'g'))
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
gui.starting = TRUE;
-#endif
+# endif
parmp->evim_mode = TRUE;
++initstr;
}
if (TOLOWER_ASC(initstr[0]) == 'g')
{
main_start_gui();
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
++initstr;
-#endif
-#ifdef GUI_MAY_SPAWN
+# endif
+# ifdef GUI_MAY_SPAWN
gui.dospawn = FALSE; // No need to spawn a new process.
-#endif
+# endif
}
-#ifdef GUI_MAY_SPAWN
+# ifdef GUI_MAY_SPAWN
else
gui.dospawn = TRUE; // Not "gvim". Need to spawn gvim.exe.
-#endif
+# endif
if (STRNICMP(initstr, "view", 4) == 0)
// Catch "[r][g]vimdiff" and "[r][g]viewdiff".
if (STRICMP(initstr, "diff") == 0)
{
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
parmp->diff_mode = TRUE;
-#else
+# else
mch_errmsg(_("This Vim was not compiled with the diff feature."));
mch_errmsg("\n");
mch_exit(2);
-#endif
+# endif
}
// Checking for "ex" here may catch some weird names, such as "vimex" or
{
want_argument = FALSE;
c = argv[0][argv_idx++];
-#if defined( VMS)
+# if defined( VMS)
/* 2025-05-13 SMS
* On sufficiently recent non-VAX systems, case preservation
* of the command line is possible/routine. And quotation
* the following (additional?) downcasing (which spoils the
* preserve-case results):
*/
-#endif /* defined( VMS) */
+# endif /* defined( VMS) */
switch (c)
{
case NUL: // "vim -" read from stdin
{
Columns = 80; // need to init Columns
info_message = TRUE; // use mch_msg(), not mch_errmsg()
-#if defined(FEAT_GUI) && !defined(ALWAYS_USE_GUI) && !defined(VIMDLL)
+# if defined(FEAT_GUI) && !defined(ALWAYS_USE_GUI) && !defined(VIMDLL)
gui.starting = FALSE; // not starting GUI, will exit
-#endif
+# endif
list_version();
msg_putchar('\n');
msg_didout = FALSE;
else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0)
{
parmp->use_vimrc = (char_u *)"DEFAULTS";
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
use_gvimrc = (char_u *)"NONE";
-#endif
+# endif
parmp->clean = TRUE;
set_option_value_give_err((char_u *)"vif",
0L, (char_u *)"NONE", 0);
}
else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0)
{
-#ifdef EXPAND_FILENAMES
+# ifdef EXPAND_FILENAMES
parmp->literal = TRUE;
-#endif
+# endif
}
else if (STRNICMP(argv[0] + argv_idx, "nofork", 6) == 0)
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
gui.dofork = FALSE; // don't fork() when starting GUI
-#endif
+# endif
}
else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0)
p_lpl = FALSE;
want_argument = TRUE;
argv_idx += 3;
}
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0)
; // already processed -- no arg
else if (STRNICMP(argv[0] + argv_idx, "servername", 10) == 0
|| STRNICMP(argv[0] + argv_idx, "serversend", 10) == 0
-# if defined(FEAT_X11) && defined(FEAT_SOCKETSERVER)
+# if defined(FEAT_X11) && defined(FEAT_SOCKETSERVER)
|| STRNICMP(argv[0] + argv_idx, "clientserver", 12) == 0
-# endif
+# endif
)
{
// already processed -- snatch the following arg
++argv;
}
}
-#endif
-#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)
-# ifdef FEAT_GUI_GTK
+# endif
+# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)
+# ifdef FEAT_GUI_GTK
else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0)
-# else
+# else
else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0)
-# endif
+# endif
{
// already processed -- snatch the following arg
if (argc > 1)
++argv;
}
}
-#endif
-#ifdef FEAT_GUI_GTK
+# endif
+# ifdef FEAT_GUI_GTK
else if (STRNICMP(argv[0] + argv_idx, "echo-wid", 8) == 0)
{
// already processed, skip
}
-#endif
+# endif
else
{
if (argv[0][argv_idx])
break;
case 'A': // "-A" start in Arabic mode
-#ifdef FEAT_ARABIC
+# ifdef FEAT_ARABIC
set_option_value_give_err((char_u *)"arabic", 1L, NULL, 0);
-#else
+# else
mch_errmsg(_(e_arabic_cannot_be_used_not_enabled_at_compile_time));
mch_exit(2);
-#endif
+# endif
break;
case 'b': // "-b" binary mode
case 'f': // "-f" GUI: run in foreground. Amiga: open
// window directly, not with newcli
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
gui.dofork = FALSE; // don't fork() when starting GUI
-#endif
+# endif
break;
case 'g': // "-g" start GUI
case '?': // "-?" give help message (for MS-Windows)
case 'h': // "-h" give help message
-#ifdef FEAT_GUI_GNOME
+# ifdef FEAT_GUI_GNOME
// Tell usage() to exit for "gvim".
gui.starting = FALSE;
-#endif
+# endif
usage();
break;
case 'H': // "-H" start in Hebrew mode: rl + hkmap set
-#ifdef FEAT_RIGHTLEFT
+# ifdef FEAT_RIGHTLEFT
p_hkmap = TRUE;
set_option_value_give_err((char_u *)"rl", 1L, NULL, 0);
-#else
+# else
mch_errmsg(_(e_hebrew_cannot_be_used_not_enabled_at_compile_time));
mch_exit(2);
-#endif
+# endif
break;
case 'l': // "-l" lisp mode, 'lisp' and 'showmatch' on
break;
case 'y': // "-y" easy mode
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
gui.starting = TRUE; // start GUI a bit later
-#endif
+# endif
parmp->evim_mode = TRUE;
break;
break;
case 'n': // "-n" no swap file
-#ifdef FEAT_NETBEANS_INTG
+# ifdef FEAT_NETBEANS_INTG
// checking for "-nb", netbeans parameters
if (argv[0][argv_idx] == 'b')
{
argv_idx = -1; // skip to next argument
}
else
-#endif
+# endif
parmp->no_swap_file = TRUE;
break;
case 'p': // "-p[N]" open N tab pages
-#ifdef TARGET_API_MAC_OSX
+# ifdef TARGET_API_MAC_OSX
// For some reason on MacOS X, an argument like:
// -psn_0_10223617 is passed in when invoke from Finder
// or with the 'open' command
main_start_gui();
break;
}
-#endif
+# endif
// default is 0: open window for each file
parmp->window_count = get_number_arg((char_u *)argv[0],
&argv_idx, 0);
parmp->window_layout = WIN_VER;
break;
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
case 'q': // "-q" QuickFix mode
if (parmp->edit_type != EDIT_NONE)
mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]);
else if (argc > 1) // "-q {errorfile}"
want_argument = TRUE;
break;
-#endif
+# endif
case 'R': // "-R" readonly mode
readonlymode = TRUE;
want_argument = TRUE;
break;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
case 'D': // "-D" Debugging
parmp->use_debug_break_level = 9999;
break;
-#endif
-#ifdef FEAT_DIFF
+# endif
+# ifdef FEAT_DIFF
case 'd': // "-d" 'diff'
-# ifdef AMIGA
+# ifdef AMIGA
// check for "-dev {device}"
if (argv[0][argv_idx] == 'e' && argv[0][argv_idx + 1] == 'v')
want_argument = TRUE;
else
-# endif
+# endif
parmp->diff_mode = TRUE;
break;
-#endif
+# endif
case 'V': // "-V{N}" Verbose level
// default is 10: a little bit verbose
p_verbose = get_number_arg((char_u *)argv[0], &argv_idx, 10);
case 'v': // "-v" Vi-mode (as if called "vi")
exmode_active = 0;
-#if defined(FEAT_GUI) && !defined(VIMDLL)
+# if defined(FEAT_GUI) && !defined(VIMDLL)
gui.starting = FALSE; // don't start GUI
-#endif
+# endif
break;
case 'w': // "-w{number}" set window height
want_argument = TRUE;
break;
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
case 'x': // "-x" encrypted reading/writing of files
parmp->ask_for_key = TRUE;
break;
-#endif
+# endif
case 'X': // "-X" don't connect to X server
-#if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11)
+# if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11)
x_no_connect = TRUE;
-#endif
+# endif
break;
case 'Y': // "-Y" don't connect to Wayland compositor
-#if defined(FEAT_WAYLAND)
+# if defined(FEAT_WAYLAND)
wayland_no_connect = TRUE;
-#endif
+# endif
break;
case 'Z': // "-Z" restricted mode
// FALLTHROUGH
case 'S': // "-S {file}" execute Vim script
case 'i': // "-i {viminfo}" use for viminfo
-#ifndef FEAT_DIFF
+# ifndef FEAT_DIFF
case 'd': // "-d {device}" device (for Amiga)
-#endif
+# endif
case 'T': // "-T {terminal}" terminal name
case 'u': // "-u {vimrc}" vim inits file
case 'U': // "-U {gvimrc}" gvim inits file
case 'W': // "-W {scriptout}" overwrite
-#ifdef FEAT_GUI_MSWIN
+# ifdef FEAT_GUI_MSWIN
case 'P': // "-P {parent title}" MDI parent
-#endif
+# endif
want_argument = TRUE;
break;
if (argv[-1][2] == 'g')
{
// without GUI ignore the argument
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
parmp->gui_dialog_file = (char_u *)argv[0];
-#endif
+# endif
}
// "--startuptime <file>" already handled
// case 'd': -d {device} is handled in mch_check_win() for the
// Amiga
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
case 'q': // "-q {errorfile}" QuickFix mode
parmp->use_ef = (char_u *)argv[0];
break;
-#endif
+# endif
case 'i': // "-i {viminfo}" use for viminfo
set_option_value_give_err((char_u *)"vif",
* HAVE_TERMLIB is supported it overrides the environment
* variable TERM.
*/
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (term_is_gui((char_u *)argv[0]))
gui.starting = TRUE; // start GUI a bit later
else
-#endif
+# endif
parmp->term = (char_u *)argv[0];
break;
break;
case 'U': // "-U {gvimrc}" gvim inits file
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
use_gvimrc = (char_u *)argv[0];
-#endif
+# endif
break;
case 'w': // "-w {nr}" 'window' value
}
break;
-#ifdef FEAT_GUI_MSWIN
+# ifdef FEAT_GUI_MSWIN
case 'P': // "-P {parent title}" MDI parent
gui_mch_set_parent(argv[0]);
break;
-#endif
+# endif
}
}
}
mainerr(ME_TOO_MANY_ARGS, (char_u *)argv[0]);
parmp->edit_type = EDIT_FILE;
-#ifdef MSWIN
+# ifdef MSWIN
// Remember if the argument was a full path before changing
// slashes to backslashes.
if (argv[0][0] != NUL && argv[0][1] == ':' && argv[0][2] == '\\')
parmp->full_path = TRUE;
-#endif
+# endif
// Add the file to the global argument list.
if (ga_grow(&global_alist.al_ga, 1) == FAIL
|| (p = vim_strsave((char_u *)argv[0])) == NULL)
mch_exit(2);
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
if (parmp->diff_mode && mch_isdir(p) && GARGCOUNT > 0
&& !mch_isdir(alist_name(&GARGLIST[0])))
{
p = r;
}
}
-#endif
-#ifdef __CYGWIN__
+# endif
+# ifdef __CYGWIN__
/*
* If vim is invoked by non-Cygwin tools, convert away any
* DOS paths, so things like .swp files are created correctly.
{
char posix_path[MAXPATHL];
-# if CYGWIN_VERSION_DLL_MAJOR >= 1007
+# if CYGWIN_VERSION_DLL_MAJOR >= 1007
cygwin_conv_path(CCP_WIN_A_TO_POSIX, p, posix_path, MAXPATHL);
-# else
+# else
cygwin_conv_to_posix_path(p, posix_path);
-# endif
+# endif
vim_free(p);
p = vim_strsave((char_u *)posix_path);
if (p == NULL)
mch_exit(2);
}
-#endif
+# endif
-#ifdef USE_FNAME_CASE
+# ifdef USE_FNAME_CASE
// Make the case of the file name match the actual file.
fname_case(p, 0);
-#endif
+# endif
alist_add(&global_alist, p,
-#ifdef EXPAND_FILENAMES
+# ifdef EXPAND_FILENAMES
parmp->literal ? 2 : 0 // add buffer nr after exp.
-#else
+# else
2 // add buffer number now and use curbuf
-#endif
+# endif
);
-#ifdef MSWIN
+# ifdef MSWIN
{
// Remember this argument has been added to the argument list.
// Needed when 'encoding' is changed.
used_file_arg(argv[0], parmp->literal, parmp->full_path,
-# ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
parmp->diff_mode
-# else
+# else
FALSE
-# endif
+# endif
);
}
-#endif
+# endif
}
/*
}
}
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// If there is a "+123" or "-c" command, set v:swapcommand to the first
// one.
if (parmp->n_commands > 0)
vim_free(p);
}
}
-#endif
+# endif
}
/*
silent_mode = TRUE;
}
else if (parmp->want_full_screen && (!stdout_isatty || !input_isatty)
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
// don't want the delay when started from the desktop
&& !gui.starting
-#endif
+# endif
&& !parmp->not_a_term)
{
-#ifdef NBDEBUG
+# ifdef NBDEBUG
/*
* This shouldn't be necessary. But if I run netbeans with the log
* output coming to the console and XOpenDisplay fails, I get vim
mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n"));
exit(1);
}
-#endif
-#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
+# endif
+# if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
if (
-# ifdef VIMDLL
+# ifdef VIMDLL
!gui.starting &&
-# endif
+# endif
is_cygpty_used())
{
-# if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \
+# if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \
&& defined(FEAT_GETTEXT)
char *s, *tofree = NULL;
s = "utf-8"; // Use "utf-8" by default.
(void)bind_textdomain_codeset(VIMPACKAGE, s);
vim_free(tofree);
-# endif
+# endif
mch_errmsg(_("Vim: Error: This version of Vim does not run in a Cygwin terminal\n"));
exit(1);
}
-#endif
+# endif
if (!stdout_isatty)
mch_errmsg(_("Vim: Warning: Output is not to a terminal\n"));
if (!input_isatty)
check_swap_exists_action();
-#if !(defined(AMIGA) || defined(MACOS_X))
+# if !(defined(AMIGA) || defined(MACOS_X))
// Dup stdin from stderr to read commands from, so that shell commands
// work.
// TODO: why is this needed, even though readfile() has done this?
close(0);
vim_ignored = dup(2);
-#endif
+# endif
}
/*
curbuf = curwin->w_buffer;
if (curbuf->b_ml.ml_mfp == NULL)
{
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
// Set 'foldlevel' to 'foldlevelstart' if it's not negative.
if (p_fdls >= 0)
curwin->w_p_fdl = p_fdls;
-#endif
+# endif
// When getting the ATTENTION prompt here, use a dialog
swap_exists_action = SEA_DIALOG;
// make the first window the current window
win = firstwin;
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
// Avoid making a preview window the current window.
while (win->w_p_pvw)
{
break;
}
}
-#endif
+# endif
win_enter(win, FALSE);
--autocmd_no_leave;
curwin->w_cursor.lnum = 0;
estack_push(ETYPE_ARGS, (char_u *)"command line", 0);
ESTACK_CHECK_SETUP;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
current_sctx.sc_sid = SID_CARG;
current_sctx.sc_seq = 0;
-#endif
+# endif
for (i = 0; i < parmp->n_commands; ++i)
{
do_cmdline_cmd(parmp->commands[i]);
}
ESTACK_CHECK_NOW;
estack_pop();
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
current_sctx.sc_sid = 0;
-#endif
+# endif
if (curwin->w_cursor.lnum == 0)
curwin->w_cursor.lnum = 1;
if (!exmode_active)
msg_scroll = FALSE;
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
// When started with "-q errorfile" jump to first error again.
if (parmp->edit_type == EDIT_QF)
qf_jump(NULL, 0, 0, FALSE);
-#endif
+# endif
TIME_MSG("executing command arguments");
}
else if (STRCMP(parmp->use_vimrc, "NONE") == 0
|| STRCMP(parmp->use_vimrc, "NORC") == 0)
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (use_gvimrc == NULL) // don't load gvimrc either
use_gvimrc = parmp->use_vimrc;
-#endif
+# endif
}
else
{
}
else if (!silent_mode)
{
-#ifdef AMIGA
+# ifdef AMIGA
struct Process *proc = (struct Process *)FindTask(0L);
APTR save_winptr = proc->pr_WindowPtr;
// Avoid a requester here for a volume that doesn't exist.
proc->pr_WindowPtr = (APTR)-1L;
-#endif
+# endif
/*
* Get system wide defaults, if the file name is defined.
*/
-#ifdef SYS_VIMRC_FILE
+# ifdef SYS_VIMRC_FILE
(void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, DOSO_NONE, NULL);
-#endif
-#ifdef MACOS_X
+# endif
+# ifdef MACOS_X
(void)do_source((char_u *)"$VIMRUNTIME/macmap.vim", FALSE,
DOSO_NONE, NULL);
-#endif
+# endif
/*
* Try to read initialization commands from the following places:
{
if (do_source((char_u *)USR_VIMRC_FILE, TRUE,
DOSO_VIMRC, NULL) == FAIL
-#ifdef USR_VIMRC_FILE2
+# ifdef USR_VIMRC_FILE2
&& do_source((char_u *)USR_VIMRC_FILE2, TRUE,
DOSO_VIMRC, NULL) == FAIL
-#endif
-#ifdef XDG_VIMRC_FILE
+# endif
+# ifdef XDG_VIMRC_FILE
&& do_source((char_u *)XDG_VIMRC_FILE, TRUE,
DOSO_VIMRC, NULL) == FAIL
-#endif
-#ifdef USR_VIMRC_FILE3
+# endif
+# ifdef USR_VIMRC_FILE3
&& do_source((char_u *)USR_VIMRC_FILE3, TRUE,
DOSO_VIMRC, NULL) == FAIL
-#endif
-#ifdef USR_VIMRC_FILE4
+# endif
+# ifdef USR_VIMRC_FILE4
&& do_source((char_u *)USR_VIMRC_FILE4, TRUE,
DOSO_VIMRC, NULL) == FAIL
-#endif
+# endif
&& process_env((char_u *)"EXINIT", FALSE) == FAIL
&& do_source((char_u *)USR_EXRC_FILE, FALSE,
DOSO_NONE, NULL) == FAIL
-#ifdef USR_EXRC_FILE2
+# ifdef USR_EXRC_FILE2
&& do_source((char_u *)USR_EXRC_FILE2, FALSE,
DOSO_NONE, NULL) == FAIL
-#endif
+# endif
&& !has_dash_c_arg)
{
// When no .vimrc file was found: source defaults.vim.
*/
if (p_exrc)
{
-#if defined(UNIX) || defined(VMS)
+# if defined(UNIX) || defined(VMS)
// If ".vimrc" file is not owned by user, set 'secure' mode.
if (!file_owned(VIMRC_FILE))
-#endif
+# endif
secure = p_secure;
i = FAIL;
if (fullpathcmp((char_u *)USR_VIMRC_FILE,
(char_u *)VIMRC_FILE, FALSE, TRUE) != FPC_SAME
-#ifdef USR_VIMRC_FILE2
+# ifdef USR_VIMRC_FILE2
&& fullpathcmp((char_u *)USR_VIMRC_FILE2,
(char_u *)VIMRC_FILE, FALSE, TRUE) != FPC_SAME
-#endif
-#ifdef USR_VIMRC_FILE3
+# endif
+# ifdef USR_VIMRC_FILE3
&& fullpathcmp((char_u *)USR_VIMRC_FILE3,
(char_u *)VIMRC_FILE, FALSE, TRUE) != FPC_SAME
-#endif
-#ifdef SYS_VIMRC_FILE
+# endif
+# ifdef SYS_VIMRC_FILE
&& fullpathcmp((char_u *)SYS_VIMRC_FILE,
(char_u *)VIMRC_FILE, FALSE, TRUE) != FPC_SAME
-#endif
+# endif
)
i = do_source((char_u *)VIMRC_FILE, TRUE, DOSO_VIMRC, NULL);
if (i == FAIL)
{
-#if defined(UNIX) || defined(VMS)
+# if defined(UNIX) || defined(VMS)
// if ".exrc" is not owned by user set 'secure' mode
if (!file_owned(EXRC_FILE))
secure = p_secure;
else
secure = 0;
-#endif
+# endif
if ( fullpathcmp((char_u *)USR_EXRC_FILE,
(char_u *)EXRC_FILE, FALSE, TRUE) != FPC_SAME
-#ifdef USR_EXRC_FILE2
+# ifdef USR_EXRC_FILE2
&& fullpathcmp((char_u *)USR_EXRC_FILE2,
(char_u *)EXRC_FILE, FALSE, TRUE) != FPC_SAME
-#endif
+# endif
)
(void)do_source((char_u *)EXRC_FILE, FALSE,
DOSO_NONE, NULL);
if (secure == 2)
need_wait_return = TRUE;
secure = 0;
-#ifdef AMIGA
+# ifdef AMIGA
proc->pr_WindowPtr = save_winptr;
-#endif
+# endif
}
TIME_MSG("sourcing vimrc file(s)");
}
static void
main_start_gui(void)
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
gui.starting = TRUE; // start GUI a bit later
-#else
+# else
mch_errmsg(_(e_gui_cannot_be_used_not_enabled_at_compile_time));
mch_errmsg("\n");
mch_exit(2);
-#endif
+# endif
}
#endif // NO_VIM_MAIN
N_("[file ..] edit specified file(s)"),
N_("- read text from stdin"),
N_("-t tag edit file where tag is defined"),
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
N_("-q [errorfile] edit file with first error")
-#endif
+# endif
};
-#if defined(UNIX) || defined(VMS)
+# if defined(UNIX) || defined(VMS)
reset_signals(); // kill us with CTRL-C here, if you like
-#endif
+# endif
init_longVersion();
mch_msg(longVersion);
break;
mch_msg(_("\n or:"));
}
-#if defined( VMS)
+# if defined( VMS)
mch_msg(_("\nWhere command is down-cased, prepend / (like: -/R) to treat flag as upper-case."));
mch_msg(_("\nOr, where supported, SET PROC/PARSE=EXT, or else quote upper-case material."));
-#endif /* defined( VMS) */
+# endif /* defined( VMS) */
mch_msg(_("\n\nArguments:\n"));
main_msg(_("--\t\t\tOnly file names after this"));
-#ifdef EXPAND_FILENAMES
+# ifdef EXPAND_FILENAMES
main_msg(_("--literal\t\tDon't expand wildcards"));
-#endif
-#ifdef FEAT_OLE
+# endif
+# ifdef FEAT_OLE
main_msg(_("-register\t\tRegister this gvim for OLE"));
main_msg(_("-unregister\t\tUnregister gvim for OLE"));
-#endif
-#ifdef FEAT_GUI
+# endif
+# ifdef FEAT_GUI
main_msg(_("-g\t\t\tRun using GUI (like \"gvim\")"));
main_msg(_("-f or --nofork\tForeground: Don't fork when starting GUI"));
-#endif
+# endif
main_msg(_("-v\t\t\tVi mode (like \"vi\")"));
main_msg(_("-e\t\t\tEx mode (like \"ex\")"));
main_msg(_("-E\t\t\tImproved Ex mode"));
main_msg(_("-s\t\t\tSilent (batch) mode (only for \"ex\")"));
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
main_msg(_("-d\t\t\tDiff mode (like \"vimdiff\")"));
-#endif
+# endif
main_msg(_("-y\t\t\tEasy mode (like \"evim\", modeless)"));
main_msg(_("-R\t\t\tReadonly mode (like \"view\")"));
main_msg(_("-Z\t\t\tRestricted mode (like \"rvim\")"));
main_msg(_("-C\t\t\tCompatible with Vi: 'compatible'"));
main_msg(_("-N\t\t\tNot fully Vi compatible: 'nocompatible'"));
main_msg(_("-V[N][fname]\t\tBe verbose [level N] [log messages to fname]"));
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
main_msg(_("-D\t\t\tDebugging mode"));
-#endif
+# endif
main_msg(_("-n\t\t\tNo swap file, use memory only"));
main_msg(_("-r\t\t\tList swap files and exit"));
main_msg(_("-r (with file name)\tRecover crashed session"));
main_msg(_("-L\t\t\tSame as -r"));
-#ifdef AMIGA
+# ifdef AMIGA
main_msg(_("-f\t\t\tDon't use newcli to open window"));
main_msg(_("-dev <device>\t\tUse <device> for I/O"));
-#endif
-#ifdef FEAT_ARABIC
+# endif
+# ifdef FEAT_ARABIC
main_msg(_("-A\t\t\tStart in Arabic mode"));
-#endif
-#ifdef FEAT_RIGHTLEFT
+# endif
+# ifdef FEAT_RIGHTLEFT
main_msg(_("-H\t\t\tStart in Hebrew mode"));
-#endif
+# endif
main_msg(_("-T <terminal>\tSet terminal type to <terminal>"));
main_msg(_("--not-a-term\t\tSkip warning for input/output not being a terminal"));
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
main_msg(_("--gui-dialog-file {fname} For testing: write dialog text"));
-#endif
+# endif
main_msg(_("--ttyfail\t\tExit if input or output is not a terminal"));
main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc"));
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc"));
-#endif
+# endif
main_msg(_("--noplugin\t\tDon't load plugin scripts"));
main_msg(_("-p[N]\t\tOpen N tab pages (default: one for each file)"));
main_msg(_("-o[N]\t\tOpen N windows (default: one for each file)"));
main_msg(_("-s <scriptin>\tRead Normal mode commands from file <scriptin>"));
main_msg(_("-w <scriptout>\tAppend all typed commands to file <scriptout>"));
main_msg(_("-W <scriptout>\tWrite all typed commands to file <scriptout>"));
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
main_msg(_("-x\t\t\tEdit encrypted files"));
-#endif
-#if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11)
-# if defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK)
- main_msg(_("-display <display>\tConnect Vim to this particular X-server"));
# endif
+# if (defined(UNIX) || defined(VMS)) && defined(FEAT_X11)
+# if defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK)
+ main_msg(_("-display <display>\tConnect Vim to this particular X-server"));
+# endif
main_msg(_("-X\t\t\tDo not connect to X server"));
-#endif
-#if defined(FEAT_WAYLAND)
+# endif
+# if defined(FEAT_WAYLAND)
main_msg(_("-Y\t\t\tDo not connect to Wayland compositor"));
-#endif
-#ifdef FEAT_CLIENTSERVER
-# if defined(FEAT_X11) && defined(FEAT_SOCKETSERVER)
- main_msg(_("--clientserver <socket|x11> Backend for clientserver communication"));
# endif
+# ifdef FEAT_CLIENTSERVER
+# if defined(FEAT_X11) && defined(FEAT_SOCKETSERVER)
+ main_msg(_("--clientserver <socket|x11> Backend for clientserver communication"));
+# endif
main_msg(_("--remote <files>\tEdit <files> in a Vim server if possible"));
main_msg(_("--remote-silent <files> Same, don't complain if there is no server"));
main_msg(_("--remote-wait <files> As --remote but wait for files to have been edited"));
main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result"));
main_msg(_("--serverlist\t\tList available Vim server names and exit"));
main_msg(_("--servername <name>\tSend to/become the Vim server <name>"));
-#endif
-#ifdef STARTUPTIME
+# endif
+# ifdef STARTUPTIME
main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>"));
-#endif
-#ifdef FEAT_JOB_CHANNEL
+# endif
+# ifdef FEAT_JOB_CHANNEL
main_msg(_("--log <file>\t\tStart logging to <file> early"));
-#endif
-#ifdef FEAT_VIMINFO
+# endif
+# ifdef FEAT_VIMINFO
main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo"));
-#endif
+# endif
main_msg(_("--clean\t\t'nocompatible', Vim defaults, no plugins, no viminfo"));
main_msg(_("-h or --help\tPrint Help (this message) and exit"));
main_msg(_("--version\t\tPrint version information and exit"));
-#ifdef FEAT_GUI_X11
-# ifdef FEAT_GUI_MOTIF
+# ifdef FEAT_GUI_X11
+# ifdef FEAT_GUI_MOTIF
mch_msg(_("\nArguments recognised by gvim (Motif version):\n"));
-# endif
+# endif
main_msg(_("-display <display>\tRun Vim on <display>"));
main_msg(_("-iconic\t\tStart Vim iconified"));
main_msg(_("-background <color>\tUse <color> for the background (also: -bg)"));
main_msg(_("-reverse\t\tUse reverse video (also: -rv)"));
main_msg(_("+reverse\t\tDon't use reverse video (also: +rv)"));
main_msg(_("-xrm <resource>\tSet the specified resource"));
-#endif // FEAT_GUI_X11
-#ifdef FEAT_GUI_GTK
+# endif // FEAT_GUI_X11
+# ifdef FEAT_GUI_GTK
mch_msg(_("\nArguments recognised by gvim (GTK+ version):\n"));
main_msg(_("-background <color>\tUse <color> for the background (also: -bg)"));
main_msg(_("-foreground <color>\tUse <color> for normal text (also: -fg)"));
main_msg(_("--role <role>\tSet a unique role to identify the main window"));
main_msg(_("--socketid <xid>\tOpen Vim inside another GTK widget"));
main_msg(_("--echo-wid\t\tMake gvim echo the Window ID on stdout"));
-#endif
-#ifdef FEAT_GUI_MSWIN
-# ifdef VIMDLL
- if (gui.starting)
# endif
+# ifdef FEAT_GUI_MSWIN
+# ifdef VIMDLL
+ if (gui.starting)
+# endif
{
main_msg(_("-P <parent title>\tOpen Vim inside parent application"));
main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget"));
}
-#endif
+# endif
-#ifdef FEAT_GUI_GNOME
+# ifdef FEAT_GUI_GNOME
// Gnome gives extra messages for --help if we continue, but not for -h.
if (gui.starting)
{
gui.dofork = FALSE;
}
else
-#endif
+# endif
mch_exit(0);
}
int prevcol_hl_flag = FALSE;
matchitem_T *cur; // points to the match list
-#if defined(FEAT_PROP_POPUP)
+# if defined(FEAT_PROP_POPUP)
// don't do this in a popup window
if (popup_is_popup(wp))
return FALSE;
-#endif
+# endif
// we're not really at that column when skipping some text
if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol)
return OK;
}
-#endif
+# endif
/*
* "clearmatches()" function
void
f_clearmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
-#ifdef FEAT_SEARCH_EXTRA
+# ifdef FEAT_SEARCH_EXTRA
win_T *win;
if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
win = get_optional_window(argvars, 0);
if (win != NULL)
clear_matches(win);
-#endif
+# endif
}
/*
void
f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
-#ifdef FEAT_SEARCH_EXTRA
+# ifdef FEAT_SEARCH_EXTRA
list_T *l;
listitem_T *li;
dict_T *d;
}
rettv->vval.v_number = 0;
}
-#endif
+# endif
}
/*
unsigned char tb = trail;
// convert process code to JIS
-# if defined(MSWIN) || defined(WIN32UNIX) || defined(MACOS_X)
+#if defined(MSWIN) || defined(WIN32UNIX) || defined(MACOS_X)
// process code is SJIS
if (lb <= 0x9f)
lb = (lb - 0x81) * 2 + 0x21;
tb -= 0x7e;
lb += 1;
}
-# else
+#else
/*
* XXX: Code page identification can not use with all
* system! So, some other encoding information
// assume process code is JAPANESE-EUC
lb &= 0x7f;
tb &= 0x7f;
-# endif
+#endif
// exceptions
switch (lb << 8 | tb)
{
n += 2;
}
else if ((str[n] == K_SPECIAL
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
|| str[n] == CSI
-# endif
+#endif
)
&& str[n + 1] == KS_EXTRA
&& str[n + 2] == (int)KE_CSI)
n += 2;
}
else if (str[n] == K_SPECIAL
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
|| str[n] == CSI
-# endif
+#endif
)
break; // a special key can't be a multibyte char
else
#endif
}
-# if defined(MSWIN) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD)
+#if defined(MSWIN) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD)
/*
* Convert an encoding name to an MS-Windows codepage.
* Returns zero if no codepage can be figured out.
return cp;
return 0;
}
-# endif
+#endif
-# if defined(USE_ICONV)
+#if defined(USE_ICONV)
/*
* Call iconv_open() with a check if iconv() works properly (there are broken
my_iconv_open(char_u *to, char_u *from)
{
iconv_t fd;
-#define ICONV_TESTLEN 400
+# define ICONV_TESTLEN 400
char_u tobuf[ICONV_TESTLEN];
char *p;
size_t tolen;
if (iconv_ok == FALSE)
return (void *)-1; // detected a broken iconv() previously
-#ifdef DYNAMIC_ICONV
+# ifdef DYNAMIC_ICONV
// Check if the iconv.dll can be found.
if (!iconv_enabled(TRUE))
return (void *)-1;
-#endif
+# endif
fd = iconv_open((char *)enc_skip(to), (char *)enc_skip(from));
return result;
}
-# if defined(DYNAMIC_ICONV)
+# if defined(DYNAMIC_ICONV)
/*
* Dynamically load the "iconv.dll" on Win32.
*/
-# ifndef DYNAMIC_ICONV // must be generating prototypes
-# define HINSTANCE int
-# endif
+# ifndef DYNAMIC_ICONV // must be generating prototypes
+# define HINSTANCE int
+# endif
static HINSTANCE hIconvDLL = 0;
static HINSTANCE hMsvcrtDLL = 0;
-# ifndef DYNAMIC_ICONV_DLL
-# define DYNAMIC_ICONV_DLL "iconv.dll"
-# define DYNAMIC_ICONV_DLL_ALT1 "libiconv.dll"
-# define DYNAMIC_ICONV_DLL_ALT2 "libiconv2.dll"
-# define DYNAMIC_ICONV_DLL_ALT3 "libiconv-2.dll"
-# endif
-# ifndef DYNAMIC_MSVCRT_DLL
-# define DYNAMIC_MSVCRT_DLL "msvcrt.dll"
-# endif
+# ifndef DYNAMIC_ICONV_DLL
+# define DYNAMIC_ICONV_DLL "iconv.dll"
+# define DYNAMIC_ICONV_DLL_ALT1 "libiconv.dll"
+# define DYNAMIC_ICONV_DLL_ALT2 "libiconv2.dll"
+# define DYNAMIC_ICONV_DLL_ALT3 "libiconv-2.dll"
+# endif
+# ifndef DYNAMIC_MSVCRT_DLL
+# define DYNAMIC_MSVCRT_DLL "msvcrt.dll"
+# endif
/*
* Try opening the iconv.dll and return TRUE if iconv() can be used.
// The iconv DLL file goes under different names, try them all.
// Do the "2" version first, it's newer.
-#ifdef DYNAMIC_ICONV_DLL_ALT2
+# ifdef DYNAMIC_ICONV_DLL_ALT2
if (hIconvDLL == 0)
hIconvDLL = vimLoadLib(DYNAMIC_ICONV_DLL_ALT2);
-#endif
-#ifdef DYNAMIC_ICONV_DLL_ALT3
+# endif
+# ifdef DYNAMIC_ICONV_DLL_ALT3
if (hIconvDLL == 0)
hIconvDLL = vimLoadLib(DYNAMIC_ICONV_DLL_ALT3);
-#endif
+# endif
if (hIconvDLL == 0)
hIconvDLL = vimLoadLib(DYNAMIC_ICONV_DLL);
-#ifdef DYNAMIC_ICONV_DLL_ALT1
+# ifdef DYNAMIC_ICONV_DLL_ALT1
if (hIconvDLL == 0)
hIconvDLL = vimLoadLib(DYNAMIC_ICONV_DLL_ALT1);
-#endif
+# endif
if (hIconvDLL != 0)
hMsvcrtDLL = vimLoadLib(DYNAMIC_MSVCRT_DLL);
hIconvDLL = 0;
hMsvcrtDLL = 0;
}
-# endif // DYNAMIC_ICONV
-# endif // USE_ICONV
+# endif // DYNAMIC_ICONV
+#endif // USE_ICONV
#if defined(FEAT_EVAL)
/*
*lenp = (int)(d - retval);
break;
-# ifdef MACOS_CONVERT
+#ifdef MACOS_CONVERT
case CONV_MAC_LATIN1:
retval = mac_string_convert(ptr, len, lenp, vcp->vc_fail,
'm', 'l', unconvlenp);
retval = mac_string_convert(ptr, len, lenp, vcp->vc_fail,
'u', 'm', unconvlenp);
break;
-# endif
+#endif
-# ifdef USE_ICONV
+#ifdef USE_ICONV
case CONV_ICONV: // conversion with output_conv.vc_fd
retval = iconv_string(vcp, ptr, len, unconvlenp, lenp);
break;
-# endif
-# ifdef MSWIN
+#endif
+#ifdef MSWIN
case CONV_CODEPAGE: // codepage -> codepage
{
int retlen;
vim_free(tmp);
break;
}
-# endif
+#endif
}
return retval;
return; // no memfile yet, nothing to do
old_method = crypt_method_nr_from_name(old_cm);
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (crypt_may_close_swapfile(buf, buf->b_p_key, crypt_get_method_nr(buf)))
return;
-#endif
+# endif
// First make sure the swapfile is in a consistent state, using the old
// key and method.
static int
swapfile_process_running(ZERO_BL *b0p, char_u *swap_fname UNUSED)
{
-#if defined(HAVE_SYSINFO) && defined(HAVE_SYSINFO_UPTIME)
+# if defined(HAVE_SYSINFO) && defined(HAVE_SYSINFO_UPTIME)
stat_T st;
struct sysinfo sinfo;
*/
char_u *p;
int i;
-# ifndef MSWIN
+#ifndef MSWIN
int shortname = curbuf->b_shortname;
curbuf->b_shortname = FALSE;
-# endif
+#endif
num_names = 0;
else
++num_names;
-# ifndef MSWIN
+#ifndef MSWIN
/*
* Also try with 'shortname' set, in case the file is on a DOS filesystem.
*/
curbuf->b_shortname = TRUE;
-#ifdef VMS
+# ifdef VMS
names[num_names] = modname(path, (char_u *)"_sw%", FALSE);
-#else
+# else
names[num_names] = modname(path, (char_u *)".sw?", FALSE);
-#endif
+# endif
if (names[num_names] == NULL)
goto end;
vim_free(names[num_names]);
else
++num_names;
-# endif
+#endif
end:
-# ifndef MSWIN
+#ifndef MSWIN
curbuf->b_shortname = shortname;
-# endif
+#endif
return num_names;
}
#if defined(FEAT_BYTEOFF)
-#define MLCS_MAXL 800 // max no of lines in chunk
-#define MLCS_MINL 400 // should be half of MLCS_MAXL
+# define MLCS_MAXL 800 // max no of lines in chunk
+# define MLCS_MINL 400 // should be half of MLCS_MAXL
/*
* Keep information for finding byte offset of a line, updtype may be one of:
end_idx = count - 1;
linecnt += rest;
}
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
if (buf->b_has_textprop)
{
int i;
+ (dp->db_index[i] & DB_INDEX_MASK)) + 1;
}
else
-#endif
+# endif
{
if (idx == 0) // first line in block, text at the end
text_end = dp->db_txt_end;
while ((lnum != 0 && curline < lnum) || (offset != 0 && size < offset))
{
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
size_t textprop_total = 0;
-#endif
+# endif
if (curline > buf->b_ml.ml_line_count
|| (hp = ml_find_line(buf, curline, ML_FIND)) == NULL)
extra = 0;
for (;;)
{
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
size_t textprop_size = 0;
if (buf->b_has_textprop)
: ((dp->db_index[idx - 1]) & DB_INDEX_MASK));
textprop_size = (l2 - l1) - (STRLEN(l1) + 1);
}
-#endif
+# endif
if (!(offset >= size
+ text_end - (int)((dp->db_index[idx]) & DB_INDEX_MASK)
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
- (long)(textprop_total + textprop_size)
-#endif
+# endif
+ ffdos))
break;
if (ffdos)
size++;
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
textprop_total += textprop_size;
-#endif
+# endif
if (idx == count - 1)
{
extra = 1;
idx++;
}
}
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
if (buf->b_has_textprop && lnum != 0)
{
int i;
}
}
else
-#endif
+# endif
len = text_end - ((dp->db_index[idx]) & DB_INDEX_MASK)
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
- (long)textprop_total
-#endif
+# endif
;
size += len;
if (offset != 0 && size >= offset)
else
*offp = offset - size + len
- (text_end - ((dp->db_index[idx - 1]) & DB_INDEX_MASK))
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
+ (long)textprop_total
-#endif
+# endif
;
curline += idx - start_idx + extra;
if (curline > buf->b_ml.ml_line_count)
idx = MENU_INDEX_INSERT;
else if (state & MODE_CMDLINE)
idx = MENU_INDEX_CMDLINE;
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
else if (term_use_loop())
idx = MENU_INDEX_TERMINAL;
-#endif
+# endif
else if (VIsual_active)
{
if (VIsual_select)
static int
get_menu_mode(void)
{
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
if (term_use_loop())
return MENU_INDEX_TERMINAL;
-#endif
+# endif
if (VIsual_active)
{
if (VIsual_select)
gui_mch_show_popupmenu(menu);
}
# endif
-# if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU)
+# if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU)
else
-# endif
-# if defined(FEAT_TERM_POPUP_MENU)
+# endif
+# if defined(FEAT_TERM_POPUP_MENU)
pum_show_popupmenu(menu);
-# endif
+# endif
}
#endif
// Never hide a toplevel menu, it may make the menubar resize or
// disappear. Same problem for ToolBar items.
if (vim_strchr(p_go, GO_GREY) != NULL || menu->parent == NULL
-# ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
|| menu_is_toolbar(menu->parent->name)
-# endif
+# endif
)
gui_mch_menu_grey(menu, grey);
else
t = pri_tab[pri_idx + 1];
pri_tab[pri_idx + 1] = 1;
-#ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
menuarg.iconfile = NULL;
menuarg.iconidx = -1;
menuarg.icon_builtin = FALSE;
-#endif
+# endif
menuarg.noremap[0] = REMAP_NONE;
menuarg.silent[0] = TRUE;
// doesn't fit, draw a single character here. Otherwise collect
// characters and draw them all at once later.
if (
-# ifdef FEAT_RIGHTLEFT
+#ifdef FEAT_RIGHTLEFT
cmdmsg_rl ||
-# endif
+#endif
(cw > 1 && msg_col + t_col >= wrap_col))
{
if (l > 1)
#if defined(USE_MCH_ERRMSG)
-#ifdef mch_errmsg
-# undef mch_errmsg
-#endif
-#ifdef mch_msg
-# undef mch_msg
-#endif
+# ifdef mch_errmsg
+# undef mch_errmsg
+# endif
+# ifdef mch_msg
+# undef mch_msg
+# endif
-#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
+# if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
static void
mch_errmsg_c(char *str)
{
fprintf(stderr, "%s", str);
}
}
-#endif
+# endif
/*
* Give an error message. To be used when the screen hasn't been initialized
void
mch_errmsg(char *str)
{
-#if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
+# if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
int len;
-#endif
+# endif
-#if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) && !defined(VIMDLL)
+# if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) && !defined(VIMDLL)
// On Unix use stderr if it's a tty.
// When not going to start the GUI also use stderr.
// On Mac, when started from Finder, stderr is the console.
if (
-# ifdef UNIX
-# ifdef MACOS_X
+# ifdef UNIX
+# ifdef MACOS_X
(isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
-# else
+# else
isatty(2)
-# endif
-# ifdef FEAT_GUI
+# endif
+# ifdef FEAT_GUI
||
+# endif
# endif
-# endif
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
!(gui.in_use || gui.starting)
-# endif
+# endif
)
{
fprintf(stderr, "%s", str);
return;
}
-#endif
+# endif
-#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
-# ifdef VIMDLL
+# if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
+# ifdef VIMDLL
if (!(gui.in_use || gui.starting))
-# endif
+# endif
{
mch_errmsg_c(str);
return;
}
-#endif
+# endif
-#if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
+# if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
// avoid a delay for a message that isn't there
emsg_on_display = FALSE;
{
mch_memmove((char_u *)error_ga.ga_data + error_ga.ga_len,
(char_u *)str, len);
-# ifdef UNIX
+# ifdef UNIX
// remove CR characters, they are displayed
{
char_u *p;
*p = ' ';
}
}
-# endif
+# endif
--len; // don't count the NUL at the end
error_ga.ga_len += len;
}
-#endif
+# endif
}
-#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
+# if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
static void
mch_msg_c(char *str)
{
printf("%s", str);
}
}
-#endif
+# endif
/*
* Give a message. To be used when the screen hasn't been initialized yet.
void
mch_msg(char *str)
{
-#if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) && !defined(VIMDLL)
+# if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI) && !defined(VIMDLL)
// On Unix use stdout if we have a tty. This allows "vim -h | more" and
// uses mch_errmsg() when started from the desktop.
// When not going to start the GUI also use stdout.
// On Mac, when started from Finder, stderr is the console.
if (
-# ifdef UNIX
-# ifdef MACOS_X
+# ifdef UNIX
+# ifdef MACOS_X
(isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
-# else
+# else
isatty(2)
-# endif
-# ifdef FEAT_GUI
+# endif
+# ifdef FEAT_GUI
||
+# endif
# endif
-# endif
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
!(gui.in_use || gui.starting)
-# endif
+# endif
)
{
printf("%s", str);
return;
}
-#endif
+# endif
-#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
-# ifdef VIMDLL
+# if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
+# ifdef VIMDLL
if (!(gui.in_use || gui.starting))
-# endif
+# endif
{
mch_msg_c(str);
return;
}
-#endif
-#if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
+# endif
+# if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
mch_errmsg(str);
-#endif
+# endif
}
#endif // USE_MCH_ERRMSG
int i;
tmode_T save_tmode;
-#ifndef NO_CONSOLE
+# ifndef NO_CONSOLE
// Don't output anything in silent mode ("ex -s")
if (silent_mode)
return dfltbutton; // return default option
-#endif
+# endif
-#ifdef FEAT_GUI_DIALOG
+# ifdef FEAT_GUI_DIALOG
// When GUI is running and 'c' not in 'guioptions', use the GUI dialog
if (gui.in_use && vim_strchr(p_go, GO_CONDIALOG) == NULL)
{
return c;
}
-#endif
+# endif
oldState = State;
State = MODE_CONFIRM;
int dfltbutton)
{
int len = 0;
-#define HOTK_LEN (has_mbyte ? MB_MAXBYTES : 1)
+# define HOTK_LEN (has_mbyte ? MB_MAXBYTES : 1)
int lenhotkey = HOTK_LEN; // count first button
char_u *hotk = NULL;
char_u *msgp = NULL;
char_u *hotkp = NULL;
char_u *r;
int copy;
-#define HAS_HOTKEY_LEN 30
+# define HAS_HOTKEY_LEN 30
char_u has_hotkey[HAS_HOTKEY_LEN];
int first_hotkey = FALSE; // first char of button is hotkey
int idx;
buf[i++] = 'x';
buf[i++] = '!';
}
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
else if (term_use_loop())
{
if (State & MODE_CMDLINE)
buf[i++] = 'c';
buf[i++] = 't';
}
-#endif
+# endif
else if (State == MODE_HITRETURN || State == MODE_ASKMORE
|| State == MODE_SETWSIZE
|| State == MODE_CONFIRM)
buf[i++] = 'i';
buf[i++] = restart_edit;
}
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
else if (term_in_normal_mode())
buf[i++] = 't';
-#endif
+# endif
}
buf[i] = NUL;
if (src[1] == '{')
# else
if (*src == '%')
-#endif
+# endif
++tail;
#endif
*var = NUL;
lazy_init_done = TRUE;
ga_init2(&ga_users, sizeof(char_u *), 20);
-# if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H)
+#if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H)
{
struct passwd* pw;
add_user((char_u *)pw->pw_name, TRUE);
endpwent();
}
-# elif defined(MSWIN)
+#elif defined(MSWIN)
{
DWORD nusers = 0, ntotal = 0, i;
PUSER_INFO_0 uinfo;
NetApiBufferFree(uinfo);
}
}
-# endif
-# if defined(HAVE_GETPWNAM)
+#endif
+#if defined(HAVE_GETPWNAM)
{
char_u *user_env = mch_getenv((char_u *)"USER");
}
}
}
-# endif
+#endif
}
/*
}
}
-# if defined(FEAT_SPELL)
+#if defined(FEAT_SPELL)
/*
* Like line_breakcheck() but check 100 times less often.
*/
#if defined(VIM_BACKTICK) || defined(FEAT_EVAL) \
|| (defined(HAVE_LOCALE_H) || defined(X_LOCALE))
-#ifndef SEEK_SET
-# define SEEK_SET 0
-#endif
-#ifndef SEEK_END
-# define SEEK_END 2
-#endif
+# ifndef SEEK_SET
+# define SEEK_SET 0
+# endif
+# ifndef SEEK_END
+# define SEEK_END 2
+# endif
/*
* Get the stdout of an external command.
mch_remove(tempname);
if (buffer == NULL)
goto done;
-#ifdef VMS
+# ifdef VMS
len = i; // VMS doesn't give us what we asked for...
-#endif
+# endif
if (i != len)
{
semsg(_(e_cant_read_file_str), tempname);
else
{
res = get_cmd_output(tv_get_string(&argvars[0]), infile, flags, NULL);
-#ifdef USE_CRNL
+# ifdef USE_CRNL
// translate <CR><NL> into <NL>
if (res != NULL)
{
}
*d = NUL;
}
-#endif
+# endif
rettv->vval.v_string = res;
res = NULL;
}
if (col > wcol || (!virtual_active() && one_more == 0))
{
idx -= 1;
-# ifdef FEAT_LINEBREAK
+#ifdef FEAT_LINEBREAK
// Don't count the chars from 'showbreak'.
csize -= head;
-# endif
+#endif
col -= csize;
}
* Table with names for mouse shapes. Keep in sync with all the tables for
* mch_set_mouse_shape()!.
*/
-#define STRING_INIT(s) \
+# define STRING_INIT(s) \
{(char_u *)(s), STRLEN_LITERAL(s)}
static string_T mshape_names[] =
{
STRING_INIT("up-arrow"),
{NULL, 0}
};
-#undef STRING_INIT
+# undef STRING_INIT
# define MSHAPE_NAMES_COUNT (ARRAY_LENGTH(mshape_names) - 1)
# endif
/*
* Repeat for all comma separated parts.
*/
-#ifdef FEAT_MOUSESHAPE
+# ifdef FEAT_MOUSESHAPE
if (what == SHAPE_MOUSE)
modep = p_mouseshape;
else
-#endif
+# endif
modep = p_guicursor;
while (*modep != NUL)
{
idx = all_idx--;
else if (round == 2)
{
-#ifdef FEAT_MOUSESHAPE
+# ifdef FEAT_MOUSESHAPE
if (what == SHAPE_MOUSE)
{
// Set the default, for the missing parts
shape_table[idx].mshape = 0;
}
else
-#endif
+# endif
{
// Set the defaults, for the missing parts
shape_table[idx].shape = SHAPE_BLOCK;
// Parse the part after the colon
for (p = colonp + 1; *p && *p != ','; )
{
-#ifdef FEAT_MOUSESHAPE
+# ifdef FEAT_MOUSESHAPE
if (what == SHAPE_MOUSE)
{
for (i = 0; ; ++i)
}
}
else // if (what == SHAPE_MOUSE)
-#endif
+# endif
{
/*
* First handle the ones with a number argument.
// If the 's' flag is not given, use the 'v' cursor for 's'
if (!found_ve)
{
-#ifdef FEAT_MOUSESHAPE
+# ifdef FEAT_MOUSESHAPE
if (what == SHAPE_MOUSE)
{
shape_table[SHAPE_IDX_VE].mshape = shape_table[SHAPE_IDX_V].mshape;
}
else
-#endif
+# endif
{
shape_table[SHAPE_IDX_VE].shape = shape_table[SHAPE_IDX_V].shape;
shape_table[SHAPE_IDX_VE].percentage =
int
get_shape_idx(int mouse)
{
-#ifdef FEAT_MOUSESHAPE
+# ifdef FEAT_MOUSESHAPE
if (mouse && (State == MODE_HITRETURN || State == MODE_ASKMORE))
{
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
int x, y;
gui_mch_getmouse(&x, &y);
if (Y_2_ROW(y) == Rows - 1)
return SHAPE_IDX_MOREL;
-# endif
+# endif
return SHAPE_IDX_MORE;
}
if (mouse && drag_status_line)
return SHAPE_IDX_SDRAG;
if (mouse && drag_sep_line)
return SHAPE_IDX_VDRAG;
-#endif
+# endif
if (!mouse && State == MODE_SHOWMATCH)
return SHAPE_IDX_SM;
if (State & VREPLACE_FLAG)
}
return SHAPE_IDX_N;
}
-#endif
+# endif
# if defined(FEAT_MOUSESHAPE)
static int current_mouse_shape = 0;
#if !defined(HAVE_SETENV) && !defined(HAVE_PUTENV) && !defined(PROTO)
-#define EXTRASIZE 5 // increment to add to env. size
+# define EXTRASIZE 5 // increment to add to env. size
static int envsize = -1; // current size of environment
extern char **environ; // the global which is your env.
filewritable(char_u *fname)
{
int retval = 0;
-#if defined(UNIX) || defined(VMS)
+# if defined(UNIX) || defined(VMS)
int perm = 0;
-#endif
+# endif
-#if defined(UNIX) || defined(VMS)
+# if defined(UNIX) || defined(VMS)
perm = mch_getperm(fname);
-#endif
+# endif
if (
# ifdef MSWIN
mch_writable(fname) &&
# else
-# if defined(UNIX) || defined(VMS)
+# if defined(UNIX) || defined(VMS)
(perm & 0222) &&
# endif
# endif
return (int)KE_IGNORE; // not recognized, ignore it
}
-# define HMT_NORMAL 1
-# define HMT_NETTERM 2
-# define HMT_DEC 4
-# define HMT_JSBTERM 8
-# define HMT_PTERM 16
-# define HMT_URXVT 32
-# define HMT_GPM 64
-# define HMT_SGR 128
-# define HMT_SGR_REL 256
+#define HMT_NORMAL 1
+#define HMT_NETTERM 2
+#define HMT_DEC 4
+#define HMT_JSBTERM 8
+#define HMT_PTERM 16
+#define HMT_URXVT 32
+#define HMT_GPM 64
+#define HMT_SGR 128
+#define HMT_SGR_REL 256
static int has_mouse_termcode = 0;
void
colnr_T col;
int width;
linenr_T lnum = pos->lnum;
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
int is_folded;
is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL);
-#endif
+# endif
row = plines_m_win(wp, wp->w_topline, lnum - 1, INT_MAX);
// "row" should be the screen line where line "lnum" begins, which can
// be negative if "lnum" is "w_topline" and "w_skipcol" is non-zero.
row -= adjust_plines_for_skipcol(wp);
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
// Add filler lines above this buffer line.
row += lnum == wp->w_topline ? wp->w_topfill
: diff_check_fill(wp, lnum);
-#endif
+# endif
colnr_T off = win_col_off(wp);
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
if (is_folded)
{
row += W_WINROW(wp) + 1;
coloff = wp->w_wincol + 1 + off;
}
else
-#endif
+# endif
{
getvcol(wp, pos, &scol, &ccol, &ecol);
int do_sms = curwin->w_p_wrap && curwin->w_p_sms;
if (do_sms
-# ifdef FEAT_FOLDING
+#ifdef FEAT_FOLDING
|| (byfold && hasAnyFolding(curwin))
-# endif
-# ifdef FEAT_DIFF
+#endif
+#ifdef FEAT_DIFF
|| (curwin->w_p_diff && !curwin->w_p_wrap)
-# endif
+#endif
)
{
int width1 = curwin->w_width - curwin_col_off();
// folding: count each sequence of folded lines as one logical line.
for (int todo = line_count; todo > 0; --todo)
{
-# ifdef FEAT_DIFF
+#ifdef FEAT_DIFF
if (curwin->w_topfill > 0)
--curwin->w_topfill;
else
-# endif
+#endif
{
linenr_T lnum = curwin->w_topline;
-# ifdef FEAT_FOLDING
+#ifdef FEAT_FOLDING
if (byfold)
// for a closed fold: go to the last line in the fold
(void)hasFolding(lnum, NULL, &lnum);
-# endif
+#endif
if (lnum == curwin->w_topline && do_sms)
{
// 'smoothscroll': increase "w_skipcol" until it goes over
// approximate w_botline
curwin->w_botline += lnum - curwin->w_topline;
curwin->w_topline = lnum;
-# ifdef FEAT_DIFF
+#ifdef FEAT_DIFF
curwin->w_topfill = diff_check_fill(curwin, lnum);
-# endif
+#endif
curwin->w_skipcol = 0;
if (todo > 1 && do_sms)
size = linetabsize_eol(curwin, curwin->w_topline);
// skip original window and windows with 'nocursorbind'
if (curwin != old_curwin && curwin->w_p_crb)
{
-# ifdef FEAT_DIFF
+#ifdef FEAT_DIFF
if (curwin->w_p_diff)
curwin->w_cursor.lnum =
diff_get_corresponding_line(old_curbuf, line);
else
-# endif
+#endif
curwin->w_cursor.lnum = line;
curwin->w_cursor.col = col;
curwin->w_cursor.coladd = coladd;
if (nb_channel != NULL)
{
// success
-# ifdef FEAT_BEVAL_GUI
+#ifdef FEAT_BEVAL_GUI
bevalServers |= BEVAL_NETBEANS;
-# endif
+#endif
// success, login
vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password);
int i;
int y;
int x;
-#if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
cairo_t *cr = NULL;
-#else
+# else
GdkDrawable *drawable = gui.drawarea->window;
-#endif
+# endif
if (!NETBEANS_OPEN)
return;
-#if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
cr = cairo_create(gui.surface);
cairo_set_source_rgba(cr,
gui.fgcolor->red, gui.fgcolor->green, gui.fgcolor->blue,
gui.fgcolor->alpha);
-#endif
+# endif
x = 0;
y = row * gui.char_height + 2;
for (i = 0; i < gui.char_height - 3; i++)
-#if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
cairo_rectangle(cr, x+2, y++, 1, 1);
-#else
+# else
gdk_draw_point(drawable, gui.text_gc, x+2, y++);
-#endif
+# endif
-#if GTK_CHECK_VERSION(3,0,0)
+# 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+2, y, 1, 1);
cairo_rectangle(cr, x+3, y++, 1, 1);
cairo_rectangle(cr, x+2, y, 1, 1);
-#else
+# else
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+2, y);
gdk_draw_point(drawable, gui.text_gc, x+3, y++);
gdk_draw_point(drawable, gui.text_gc, x+2, y);
-#endif
+# endif
-#if GTK_CHECK_VERSION(3,0,0)
+# if GTK_CHECK_VERSION(3,0,0)
cairo_destroy(cr);
-#endif
+# endif
}
#endif // FEAT_GUI_GTK
top = curwin->w_cursor.lnum;
bot = VIsual.lnum;
}
-# ifdef FEAT_FOLDING
+#ifdef FEAT_FOLDING
// Include closed folds as a whole.
(void)hasFolding(top, &top, NULL);
(void)hasFolding(bot, NULL, &bot);
-# endif
+#endif
lines = bot - top + 1;
if (VIsual_mode == Ctrl_V)
{
-# ifdef FEAT_LINEBREAK
+#ifdef FEAT_LINEBREAK
char_u *saved_sbr = p_sbr;
char_u *saved_w_sbr = curwin->w_p_sbr;
// Make 'sbr' empty for a moment to get the correct size.
p_sbr = empty_option;
curwin->w_p_sbr = empty_option;
-# endif
+#endif
getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol);
-# ifdef FEAT_LINEBREAK
+#ifdef FEAT_LINEBREAK
p_sbr = saved_sbr;
curwin->w_p_sbr = saved_w_sbr;
-# endif
+#endif
sprintf((char *)showcmd_buf, "%ldx%ld", lines,
(long)(rightcol - leftcol + 1));
}
}
else
clearopbeep(cap->oap);
-# ifdef FEAT_FOLDING
+#ifdef FEAT_FOLDING
if (cap->oap->op_type == OP_NOP
&& (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum)
&& (fdo_flags & FDO_MARK)
&& old_KeyTyped)
foldOpenCursor();
-# endif
+#endif
}
/*
i = VIsual_mode;
VIsual_mode = curbuf->b_visual.vi_mode;
curbuf->b_visual.vi_mode = i;
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
curbuf->b_visual_mode_eval = i;
-# endif
+#endif
i = curwin->w_curswant;
curwin->w_curswant = curbuf->b_visual.vi_curswant;
curbuf->b_visual.vi_curswant = i;
# define NVCMD(a, b, c, d) \
{a, b, c, d}
-#ifdef FEAT_GUI
-#define NV_VER_SCROLLBAR nv_ver_scrollbar
-#define NV_HOR_SCROLLBAR nv_hor_scrollbar
-#else
-#define NV_VER_SCROLLBAR nv_error
-#define NV_HOR_SCROLLBAR nv_error
-#endif
+# ifdef FEAT_GUI
+# define NV_VER_SCROLLBAR nv_ver_scrollbar
+# define NV_HOR_SCROLLBAR nv_hor_scrollbar
+# else
+# define NV_VER_SCROLLBAR nv_error
+# define NV_HOR_SCROLLBAR nv_error
+# endif
-#ifdef FEAT_GUI_TABLINE
-#define NV_TABLINE nv_tabline
-#define NV_TABMENU nv_tabmenu
-#else
-#define NV_TABLINE nv_error
-#define NV_TABMENU nv_error
-#endif
+# ifdef FEAT_GUI_TABLINE
+# define NV_TABLINE nv_tabline
+# define NV_TABMENU nv_tabmenu
+# else
+# define NV_TABLINE nv_error
+# define NV_TABMENU nv_error
+# endif
-#ifdef FEAT_NETBEANS_INTG
-#define NV_NBCMD nv_nbcmd
-#else
-#define NV_NBCMD nv_error
-#endif
+# ifdef FEAT_NETBEANS_INTG
+# define NV_NBCMD nv_nbcmd
+# else
+# define NV_NBCMD nv_error
+# endif
-#ifdef FEAT_DND
-#define NV_DROP nv_drop
-#else
-#define NV_DROP nv_error
-#endif
+# ifdef FEAT_DND
+# define NV_DROP nv_drop
+# else
+# define NV_DROP nv_error
+# endif
/*
* Function to be called for a Normal or Visual mode command.
typedef void (*nv_func_T)(cmdarg_T *cap);
// Values for cmd_flags.
-#define NV_NCH 0x01 // may need to get a second char
-#define NV_NCH_NOP (0x02|NV_NCH) // get second char when no operator pending
-#define NV_NCH_ALW (0x04|NV_NCH) // always get a second char
-#define NV_LANG 0x08 // second char needs language adjustment
+# define NV_NCH 0x01 // may need to get a second char
+# define NV_NCH_NOP (0x02|NV_NCH) // get second char when no operator pending
+# define NV_NCH_ALW (0x04|NV_NCH) // always get a second char
+# define NV_LANG 0x08 // second char needs language adjustment
-#define NV_SS 0x10 // may start selection
-#define NV_SSS 0x20 // may start selection with shift modifier
-#define NV_STS 0x40 // may stop selection without shift modif.
-#define NV_RL 0x80 // 'rightleft' modifies command
-#define NV_KEEPREG 0x100 // don't clear regname
-#define NV_NCW 0x200 // not allowed in command-line window
+# define NV_SS 0x10 // may start selection
+# define NV_SSS 0x20 // may start selection with shift modifier
+# define NV_STS 0x40 // may stop selection without shift modif.
+# define NV_RL 0x80 // 'rightleft' modifies command
+# define NV_KEEPREG 0x100 // don't clear regname
+# define NV_NCW 0x200 // not allowed in command-line window
/*
* Generally speaking, every Normal mode command should either clear any
static char *(p_bin_dep_opts[]) = {"textwidth", "wrapmargin", "modeline", "expandtab", NULL};
static char *(p_paste_dep_opts[]) = {"autoindent", "expandtab", "ruler", "showmatch", "smarttab",
"softtabstop", "textwidth", "wrapmargin",
-#ifdef FEAT_RIGHTLEFT
+# ifdef FEAT_RIGHTLEFT
"hkmap", "revins",
-#endif
-#ifdef FEAT_VARTABS
+# endif
+# ifdef FEAT_VARTABS
"varsofttabstop",
-#endif
+# endif
NULL};
static void didset_options_sctx(int opt_flags, char **buf);
#endif
options[opt_idx].def_val[VI_DEFAULT] = xdg_rtp;
p_pp = xdg_rtp;
-#if defined(XDG_VDIR) && defined(FEAT_SESSION)
+# if defined(XDG_VDIR) && defined(FEAT_SESSION)
if ((opt_idx = findoption((char_u *)"viewdir")) < 0)
goto theend;
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)XDG_VDIR;
p_vdir = (char_u *)XDG_VDIR;
-#endif
+# endif
theend:
vim_free(vimrc1);
char_u *p;
int opt_idx;
-# if defined(MSWIN) || defined(__MVS__)
+#if defined(MSWIN) || defined(__MVS__)
// MS-Windows has builtin support for conversion to and from Unicode, using
// "utf-8" for 'encoding' should work best for most users.
// z/OS built should default to UTF-8 mode as setlocale does not respect utf-8 environment variable locales
p = vim_strnsave((char_u *)ENC_DFLT, STRLEN_LITERAL(ENC_DFLT));
-# else
+#else
// enc_locale() will try to find the encoding of the current locale.
// This works best for properly configured systems, old and new.
p = enc_locale();
-# endif
+#endif
if (p == NULL)
return;
if (!(options[i].flags & P_NODEFAULT)
&& (opt_flags == 0
|| (options[i].var != (char_u *)&p_enc
-# if defined(FEAT_CRYPT)
+#if defined(FEAT_CRYPT)
&& options[i].var != (char_u *)&p_cm
&& options[i].var != (char_u *)&p_key
-# endif
+#endif
)))
set_option_default(i, opt_flags, p_cp);
|| fnamecmp(p, "powershell.exe") == 0
)
{
-# if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
if (do_sp)
{
p_sp = (char_u *)"2>&1 | Out-File -Encoding default";
options[idx_sp].def_val[VI_DEFAULT] = p_sp;
}
-# endif
+# endif
if (do_srr)
{
p_srr = (char_u *)"2>&1 | Out-File -Encoding default";
options[idx_srr].def_val[VI_DEFAULT] = p_srr;
}
}
-#endif
+# endif
else
// Always use POSIX shell style redirection if we reach this
if ( fnamecmp(p, "sh") == 0
switch ((int)options[opt_idx].indir)
{
case PV_WRAP: return &wp->w_p_wrap_flags;
-#ifdef FEAT_STL_OPT
+# ifdef FEAT_STL_OPT
case PV_STL: return &wp->w_p_stl_flags;
-#endif
-#ifdef FEAT_EVAL
-# ifdef FEAT_FOLDING
+# endif
+# ifdef FEAT_EVAL
+# ifdef FEAT_FOLDING
case PV_FDE: return &wp->w_p_fde_flags;
case PV_FDT: return &wp->w_p_fdt_flags;
-# endif
-# ifdef FEAT_BEVAL
+# endif
+# ifdef FEAT_BEVAL
case PV_BEXPR: return &wp->w_buffer->b_p_bexpr_flags;
-# endif
+# endif
case PV_INDE: return &wp->w_buffer->b_p_inde_flags;
case PV_FEX: return &wp->w_buffer->b_p_fex_flags;
-# ifdef FEAT_FIND_ID
+# ifdef FEAT_FIND_ID
case PV_INEX: return &wp->w_buffer->b_p_inex_flags;
+# endif
# endif
-#endif
}
else
// For global value of window-local options, use flags in w_allbuf_opt.
switch ((int)options[opt_idx].indir)
{
case PV_WRAP: return &wp->w_allbuf_opt.wo_wrap_flags;
-#if defined(FEAT_EVAL) && defined(FEAT_FOLDING)
+# if defined(FEAT_EVAL) && defined(FEAT_FOLDING)
case PV_FDE: return &wp->w_allbuf_opt.wo_fde_flags;
case PV_FDT: return &wp->w_allbuf_opt.wo_fdt_flags;
-#endif
+# endif
}
// Nothing special, return global flags field.
msg_source(HL_ATTR(HLF_W));
msg_attr(_(w_arabic), HL_ATTR(HLF_W));
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
-#endif
+# endif
}
// set 'delcombine'
{
// when 'modifiable' is changed, redraw the window title
-# ifdef FEAT_TERMINAL
+#ifdef FEAT_TERMINAL
// Cannot set 'modifiable' when in Terminal mode.
if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf)
&& curbuf->b_term != NULL && !term_is_finished(curbuf))))
curbuf->b_p_ma = FALSE;
return e_cannot_make_terminal_with_running_job_modifiable;
}
-# endif
+#endif
redraw_titles();
return NULL;
|| args->os_flags == 0)
&& !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
{
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (crypt_method_is_sodium(crypt_get_method_nr(curbuf)))
continue;
-#endif
+# endif
u_compute_hash(hash);
u_read_undo(NULL, hash, curbuf->b_fname);
}
if ((char_u **)varp == &p_pt) // 'pastetoggle'
*stringval = str2special_save(*(char_u **)(varp), FALSE,
FALSE);
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
// never return the value of the crypt key
else if ((char_u **)varp == &curbuf->b_p_key
&& **(char_u **)(varp) != NUL)
*stringval = vim_strnsave((char_u *)"*****", STRLEN_LITERAL("*****"));
-#endif
+# endif
else
*stringval = vim_strsave(*(char_u **)(varp));
}
case PV_AR:
buf->b_p_ar = -1;
break;
-#ifdef HAVE_FSYNC
+# ifdef HAVE_FSYNC
case PV_FS:
buf->b_p_fs = -1;
break;
-#endif
+# endif
case PV_BKC:
clear_string_option(&buf->b_p_bkc);
buf->b_bkc_flags = 0;
# ifdef VMS
# define DFLT_EFM "%A%p^,%C%%CC-%t-%m,%Cat line number %l in file %f,%f|%l| %m"
# else // Unix, probably
-#define DFLT_EFM "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-Gg%\\?make[%*\\d]: *** [%f:%l:%m,%-Gg%\\?make: *** [%f:%l:%m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m"
+# define DFLT_EFM "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-Gg%\\?make[%*\\d]: *** [%f:%l:%m,%-Gg%\\?make: *** [%f:%l:%m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m"
# endif
# endif
# endif
EXTERN int p_bk; // 'backup'
EXTERN char_u *p_bkc; // 'backupcopy'
EXTERN unsigned bkc_flags; // flags from 'backupcopy'
-# define BKC_YES 0x001
-# define BKC_AUTO 0x002
-# define BKC_NO 0x004
-# define BKC_BREAKSYMLINK 0x008
-# define BKC_BREAKHARDLINK 0x010
+#define BKC_YES 0x001
+#define BKC_AUTO 0x002
+#define BKC_NO 0x004
+#define BKC_BREAKSYMLINK 0x008
+#define BKC_BREAKHARDLINK 0x010
EXTERN char_u *p_bdir; // 'backupdir'
EXTERN char_u *p_bex; // 'backupext'
EXTERN char_u *p_bo; // 'belloff'
#endif
#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)
EXTERN char_u *p_guiligatures; // 'guiligatures'
-# endif
+#endif
#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
EXTERN long p_ghr; // 'guiheadroom'
#endif
EXTERN int p_ic; // 'ignorecase'
#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
EXTERN char_u *p_imak; // 'imactivatekey'
-#define IM_ON_THE_SPOT 0L
-#define IM_OVER_THE_SPOT 1L
+# define IM_ON_THE_SPOT 0L
+# define IM_OVER_THE_SPOT 1L
EXTERN long p_imst; // 'imstyle'
#endif
#if defined(FEAT_EVAL)
EXTERN long p_window; // 'window'
#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(LINT) \
|| defined (FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON)
-#define FEAT_WAK
+# define FEAT_WAK
EXTERN char_u *p_wak; // 'winaltkeys'
#endif
EXTERN char_u *p_wig; // 'wildignore'
# define PV_BRI OPT_WIN(WV_BRI)
# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
#endif
-# define PV_WCR OPT_WIN(WV_WCR)
+#define PV_WCR OPT_WIN(WV_WCR)
#ifdef FEAT_DIFF
# define PV_DIFF OPT_WIN(WV_DIFF)
#endif
-# define PV_EIW OPT_WIN(WV_EIW)
+#define PV_EIW OPT_WIN(WV_EIW)
#ifdef FEAT_FOLDING
# define PV_FDC OPT_WIN(WV_FDC)
# define PV_FEN OPT_WIN(WV_FEN)
# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
#endif
#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
-# define PV_WFB OPT_WIN(WV_WFB)
-# define PV_WFH OPT_WIN(WV_WFH)
-# define PV_WFW OPT_WIN(WV_WFW)
+#define PV_WFB OPT_WIN(WV_WFB)
+#define PV_WFH OPT_WIN(WV_WFH)
+#define PV_WFW OPT_WIN(WV_WFW)
#define PV_WRAP OPT_WIN(WV_WRAP)
#define PV_CRBIND OPT_WIN(WV_CRBIND)
#ifdef FEAT_CONCEAL
# define ISP_LATIN1 (char_u *)"@,161-255"
#endif
-# define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow,N:CursorLineNr,G:CursorLineSign,O:CursorLineFold,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,E:DiffTextAdd,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,k:PmenuMatch,<:PmenuMatchSel,[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb,j:PmenuBorder,H:PmenuShadow,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC,g:MsgArea,h:ComplMatchIns,%:TabPanel,^:TabPanelSel,&:TabPanelFill,I:PreInsert"
+#define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow,N:CursorLineNr,G:CursorLineSign,O:CursorLineFold,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,E:DiffTextAdd,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,k:PmenuMatch,<:PmenuMatchSel,[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb,j:PmenuBorder,H:PmenuShadow,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC,g:MsgArea,h:ComplMatchIns,%:TabPanel,^:TabPanelSel,&:TabPanelFill,I:PreInsert"
// Default python version for pyx* commands
#if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
(char_u *)&p_imaf, PV_NONE,
did_set_imactivatefunc, NULL,
{(char_u *)"", (char_u *)NULL}
-# else
+#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)NULL, (char_u *)0L}
-# endif
+#endif
SCTX_INIT},
{"imactivatekey","imak",P_STRING|P_VI_DEF,
#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
#ifdef FEAT_QUICKFIX
(char_u *)&p_sp, PV_NONE, NULL, NULL,
{
-#if defined(UNIX)
+# if defined(UNIX)
(char_u *)"| tee",
-#else
+# else
(char_u *)">",
-#endif
+# endif
(char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
#ifdef FEAT_VIMINFO
(char_u *)&p_viminfo, PV_NONE, did_set_viminfo, NULL,
-#if defined(MSWIN)
+# if defined(MSWIN)
{(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
-#elif defined(AMIGA)
+# elif defined(AMIGA)
{(char_u *)"",
(char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
-#else
+# else
{(char_u *)"", (char_u *)"'100,<50,s10,h"}
-#endif
+# endif
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)0L, (char_u *)0L}
#endif
#ifdef FEAT_CRYPT
static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2",
- # ifdef FEAT_SODIUM
+# ifdef FEAT_SODIUM
"xchacha20", "xchacha20v2",
- # endif
+# endif
NULL};
#endif
static char *(p_cmp_values[]) = {"internal", "keepascii", NULL};
free_string_option(*varp);
*varp = empty_option;
}
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
if (set_sid != SID_NONE)
{
sctx_T script_ctx;
}
set_option_sctx_idx(idx, opt_flags, script_ctx);
}
-# endif
+#endif
}
#if defined(FEAT_PROP_POPUP) || (defined(FEAT_DIFF) && defined(FEAT_FOLDING))
return ret;
}
-# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)
+#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)
static garray_T *expand_cb_ga;
static optexpand_T *expand_cb_args;
int result;
char **values;
int count, pos = 0, start = 0;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
dict_T *providers = get_vim_var_dict(VV_CLIPPROVIDERS);
-#else
+# else
dict_T *providers = NULL;
-#endif
+# endif
hashtab_T *ht = providers == NULL ? NULL : &providers->dv_hashtab;
count = (ht == NULL ? 0 : ht->ht_used);
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
count++;
start++;
-#endif
-#ifdef FEAT_XCLIPBOARD
+# endif
+# ifdef FEAT_XCLIPBOARD
count++;
start++;
-#endif
+# endif
values = ALLOC_MULT(char *, count + 1); // Add NULL terminator too
if (values == NULL)
return FAIL;
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
values[pos++] = "wayland";
-#endif
-#ifdef FEAT_XCLIPBOARD
+# endif
+# ifdef FEAT_XCLIPBOARD
values[pos++] = "x11";
-#endif
+# endif
if (ht != NULL)
for (long_u i = 0; i < ht->ht_mask + 1; i++)
{
char_u **varp = (char_u **)args->os_varp;
-#if defined(FEAT_LINEBREAK)
+# if defined(FEAT_LINEBREAK)
if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
return e_invalid_argument;
// When changing the 'signcolumn' to or from 'number', recompute the
|| (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) =='u'))
&& (curwin->w_p_nu || curwin->w_p_rnu))
curwin->w_nrwidth_line_count = 0;
-#endif
+# endif
return NULL;
}
mch_get_shellsize(void)
{
struct ConUnit *conUnit;
-#ifndef __amigaos4__
+# ifndef __amigaos4__
char id_a[sizeof(struct InfoData) + 3];
-#endif
+# endif
struct InfoData *id=0;
if (!term_console) // not an amiga window
goto out;
// insure longword alignment
-#ifdef __amigaos4__
+# ifdef __amigaos4__
if (!(id = AllocDosObject(DOS_INFODATA, 0)))
goto out;
-#else
+# else
id = (struct InfoData *)(((long)id_a + 3L) & ~3L);
-#endif
+# endif
/*
* Should make console aware of real window size, not the one we set.
return OK;
out:
-#ifdef __amigaos4__
+# ifdef __amigaos4__
FreeDosObject(DOS_INFODATA, id); // Safe to pass NULL
-#endif
+# endif
return FAIL;
}
//#include <proto/exec.h>
//#include <proto/dos.h>
-#include <exec/memory.h>
+# include <exec/memory.h>
/*
* Function - dos_packet written by Phil Lindsay, Carolyn Scheppner, and Andy
// is zero). Since we want to check for our own ^C's
#ifdef _DCC
-#define Chk_Abort chkabort
+# define Chk_Abort chkabort
#endif
#ifdef LATTICE
++p;
else
if (vim_strchr((char_u *)
-# ifdef VIM_BACKTICK
+#ifdef VIM_BACKTICK
"*?[(#$`"
-# else
+#else
"*?[(#$"
-# endif
+#endif
, *p) != NULL
|| (*p == '~' && p[1] != NUL))
return TRUE;
#ifdef FEAT_VIMINFO
# ifndef VIMINFO_FILE
-# define VIMINFO_FILE "VIM:.viminfo"
+# define VIMINFO_FILE "VIM:.viminfo"
# endif
#endif
if (strcasestr(buf, "utf-8") == NULL)
strcat(buf, ".UTF-8");
vim_setenv((char_u *)"LANG", (char_u *)buf);
-# ifdef HAVE_LOCALE_H
+#ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
-# endif
-# if defined(LC_NUMERIC)
+#endif
+#if defined(LC_NUMERIC)
// Make sure strtod() uses a decimal point, not a comma.
setlocale(LC_NUMERIC, "C");
-# endif
+#endif
}
}
#endif // MACOS_CONVERT
BYTE charset;
};
-#define STRING_INIT(s) \
+# define STRING_INIT(s) \
{(char_u *)(s), STRLEN_LITERAL(s)}
static struct charset_pair
charset_pairs[] =
# endif
{STRING_INIT("DEFAULT"), DEFAULT_QUALITY}
};
-#undef STRING_INIT
+# undef STRING_INIT
/*
* Convert a charset ID to a name.
// The default font height in 100% scaling (96dpi).
// (-16 in 96dpi equates to roughly 12pt)
-#define DEFAULT_FONT_HEIGHT (-16)
+# define DEFAULT_FONT_HEIGHT (-16)
static const LOGFONTW s_lfDefault =
{
#if defined(FEAT_GUI_PHOTON) && defined(FEAT_CLIPBOARD)
-#define CLIP_TYPE_VIM "VIMTYPE"
-#define CLIP_TYPE_TEXT "TEXT"
+# define CLIP_TYPE_VIM "VIMTYPE"
+# define CLIP_TYPE_TEXT "TEXT"
// Turn on the clipboard for a console vim when photon is running
void qnx_clip_init(void)
ss_msg_T cmd_msgs[SOCKET_SERVER_MAX_MSG]; // Array of messages
} ss_cmd_T;
-#define SS_CMD_INFO_SIZE (sizeof(char_u) + (sizeof(uint32_t) * 2))
-#define SS_MSG_INFO_SIZE (sizeof(char_u) + sizeof(uint32_t))
+# define SS_CMD_INFO_SIZE (sizeof(char_u) + (sizeof(uint32_t) * 2))
+# define SS_MSG_INFO_SIZE (sizeof(char_u) + sizeof(uint32_t))
// Represents a pending reply from a command sent to a Vim server. When a
// command is sent out, we generate unique serial number with it. When we
#if defined(HAVE_STACK_LIMIT)
static char *stack_limit = NULL;
-#if defined(_THREAD_SAFE) && defined(HAVE_PTHREAD_NP_H)
-# include <pthread.h>
-# include <pthread_np.h>
-#endif
+# if defined(_THREAD_SAFE) && defined(HAVE_PTHREAD_NP_H)
+# include <pthread.h>
+# include <pthread_np.h>
+# endif
/*
* Find out until how var the stack can grow without getting into trouble.
// limit doesn't fit in a long (rlim_cur might be "long long").
if (getrlimit(RLIMIT_STACK, &rlp) == 0
&& rlp.rlim_cur < ((rlim_t)1 << (sizeof(long_u) * 8 - 1))
-# ifdef RLIM_INFINITY
+# ifdef RLIM_INFINITY
&& rlp.rlim_cur != RLIM_INFINITY
-# endif
+# endif
)
{
lim = (long)rlp.rlim_cur;
-#if defined(_THREAD_SAFE) && defined(HAVE_PTHREAD_NP_H)
+# if defined(_THREAD_SAFE) && defined(HAVE_PTHREAD_NP_H)
{
pthread_attr_t attr;
size_t size;
}
pthread_attr_destroy(&attr);
}
-#endif
+# endif
if (stack_grows_downwards)
{
stack_limit = (char *)((long)&i - (lim / 16L * 15L));
else
got_tstp = TRUE;
-#if !defined(__ANDROID__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
+# if !defined(__ANDROID__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
// This is not required on all systems. On some systems (at least Android,
// OpenBSD, and DragonFlyBSD) this breaks suspending with CTRL-Z.
mch_signal(SIGTSTP, sig_tstp);
-#endif
+# endif
}
#endif
{
if (clip_star.owned || clip_plus.owned)
{
-#ifdef FEAT_X11
+# ifdef FEAT_X11
x11_export_final_selection();
-#endif
+# endif
if (clip_star.owned)
clip_lose_selection(&clip_star);
if (clip_plus.owned)
clip_lose_selection(&clip_plus);
-#ifdef FEAT_X11
+# ifdef FEAT_X11
if (x11_display != NULL)
XFlush(x11_display);
-#endif
+# endif
}
}
-#endif
+# endif
# if defined(USE_SYSTEM) && (defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD))
/*
// like the best alternative. Do preserve files, in case we crash.
ml_sync_all(FALSE, FALSE);
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (!gui.in_use)
-#endif
+# endif
msg((char *)IObuff);
return 0; // NOTREACHED
if (exiting || v_dying)
return FALSE;
-#if defined(FEAT_CLIENTSERVER)
+# if defined(FEAT_CLIENTSERVER)
if (x_force_connect)
return TRUE;
-#endif
+# endif
if (x_no_connect)
return FALSE;
return TRUE;
}
-#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
-# if defined(USING_SETJMP)
+# if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
+# if defined(USING_SETJMP)
/*
* An X IO Error handler, used to catch error while opening the display.
*/
{
// This function should not return, it causes exit(). Longjump instead.
LONGJMP(lc_jump_env, 1);
-# if defined(VMS) || defined(__CYGWIN__)
+# if defined(VMS) || defined(__CYGWIN__)
return 0; // avoid the compiler complains about missing return value
-# endif
+# endif
}
-# endif
+# endif
/*
* An X IO Error handler, used to catch terminal errors.
// This function should not return, it causes exit(). Longjump instead.
LONGJMP(x_jump_env, 1);
-# if defined(VMS) || defined(__CYGWIN__)
+# if defined(VMS) || defined(__CYGWIN__)
return 0; // avoid the compiler complains about missing return value
-# endif
+# endif
}
/*
{
--xterm_dpy_retry_count;
-# ifndef LESSTIF_VERSION
+# ifndef LESSTIF_VERSION
// This has been reported to avoid Vim getting stuck.
if (app_context != (XtAppContext)NULL)
{
app_context = (XtAppContext)NULL;
x11_display = NULL; // freed by XtDestroyApplicationContext()
}
-# endif
+# endif
setup_term_clip();
get_x11_title(FALSE);
may_restore_x11_clipboard();
choose_clipmethod();
}
-#endif
+# endif
/*
* Test if "dpy" and x11_window are valid by getting the window title.
{
char *winid;
static int result = -1;
-#define XD_NONE 0 // x11_display not set here
-#define XD_HERE 1 // x11_display opened here
-#define XD_GUI 2 // x11_display used from gui.dpy
-#define XD_XTERM 3 // x11_display used from xterm_dpy
+# define XD_NONE 0 // x11_display not set here
+# define XD_HERE 1 // x11_display opened here
+# define XD_GUI 2 // x11_display used from gui.dpy
+# define XD_XTERM 3 // x11_display used from xterm_dpy
static int x11_display_from = XD_NONE;
static int did_set_error_handler = FALSE;
did_set_error_handler = TRUE;
}
-#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
+# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
if (gui.in_use)
{
/*
x11_display = NULL;
x11_display_from = XD_NONE;
}
-#endif
+# endif
// When started with the "-X" argument, don't try connecting.
if (!x_connect_to_server())
if (x11_window == 0 && (winid = getenv("WINDOWID")) != NULL)
x11_window = (Window)atol(winid);
-#ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
if (xterm_dpy == x11_display)
// x11_display may have been set to xterm_dpy elsewhere
x11_display_from = XD_XTERM;
}
return OK;
}
-#endif
+# endif
if (x11_window == 0 || x11_display == NULL)
result = -1;
if (x11_window != 0 && x11_display == NULL)
{
-#ifdef SET_SIG_ALARM
+# ifdef SET_SIG_ALARM
sighandler_T sig_save;
-#endif
-#ifdef ELAPSED_FUNC
+# endif
+# ifdef ELAPSED_FUNC
elapsed_T start_tv;
if (p_verbose > 0)
ELAPSED_INIT(start_tv);
-#endif
+# endif
-#ifdef SET_SIG_ALARM
+# ifdef SET_SIG_ALARM
/*
* Opening the Display may hang if the DISPLAY setting is wrong, or
* the network connection is bad. Set an alarm timer to get out.
sig_alarm_called = FALSE;
sig_save = mch_signal(SIGALRM, sig_alarm);
alarm(2);
-#endif
+# endif
x11_display = XOpenDisplay(NULL);
-#ifdef SET_SIG_ALARM
+# ifdef SET_SIG_ALARM
alarm(0);
mch_signal(SIGALRM, sig_save);
if (p_verbose > 0 && sig_alarm_called)
verb_msg(_("Opening the X display timed out"));
-#endif
+# endif
if (x11_display != NULL)
{
# ifdef ELAPSED_FUNC
// systems X_HAVE_UTF8_STRING may be defined in a header file but
// Xutf8SetWMProperties() is not in the X11 library. Configure checks for
// that and defines HAVE_XUTF8SETWMPROPERTIES.
-#if defined(X_HAVE_UTF8_STRING)
-# if X_HAVE_UTF8_STRING && HAVE_XUTF8SETWMPROPERTIES
-# define USE_UTF8_STRING
+# if defined(X_HAVE_UTF8_STRING)
+# if X_HAVE_UTF8_STRING && HAVE_XUTF8SETWMPROPERTIES
+# define USE_UTF8_STRING
+# endif
# endif
-#endif
/*
* Set x11 Window Title
// XmbSetWMProperties() and Xutf8SetWMProperties() should use a STRING
// when possible, COMPOUND_TEXT otherwise. COMPOUND_TEXT isn't
// supported everywhere and STRING doesn't work for multi-byte titles.
-#ifdef USE_UTF8_STRING
+# ifdef USE_UTF8_STRING
if (enc_utf8)
Xutf8SetWMProperties(x11_display, x11_window, (const char *)title,
NULL, NULL, 0, NULL, NULL, NULL);
else
-#endif
+# endif
{
-#if XtSpecificationRelease >= 4
-# ifdef FEAT_XFONTSET
+# if XtSpecificationRelease >= 4
+# ifdef FEAT_XFONTSET
XmbSetWMProperties(x11_display, x11_window, (const char *)title,
NULL, NULL, 0, NULL, NULL, NULL);
-# else
+# else
XTextProperty text_prop;
char *c_title = (char *)title;
(void)XStringListToTextProperty(&c_title, 1, &text_prop);
XSetWMProperties(x11_display, x11_window, &text_prop,
NULL, NULL, 0, NULL, NULL, NULL);
-# endif
-#else
+# endif
+# else
XStoreName(x11_display, x11_window, (char *)title);
-#endif
+# endif
}
XFlush(x11_display);
}
set_x11_icon(char_u *icon)
{
// See above for comments about using X*SetWMProperties().
-#ifdef USE_UTF8_STRING
+# ifdef USE_UTF8_STRING
if (enc_utf8)
Xutf8SetWMProperties(x11_display, x11_window, NULL, (const char *)icon,
NULL, 0, NULL, NULL, NULL);
else
-#endif
+# endif
{
-#if XtSpecificationRelease >= 4
-# ifdef FEAT_XFONTSET
+# if XtSpecificationRelease >= 4
+# ifdef FEAT_XFONTSET
XmbSetWMProperties(x11_display, x11_window, NULL, (const char *)icon,
NULL, 0, NULL, NULL, NULL);
-# else
+# else
XTextProperty text_prop;
char *c_icon = (char *)icon;
(void)XStringListToTextProperty(&c_icon, 1, &text_prop);
XSetWMProperties(x11_display, x11_window, NULL, &text_prop,
NULL, 0, NULL, NULL, NULL);
-# endif
-#else
+# endif
+# else
XSetIconName(x11_display, x11_window, (char *)icon);
-#endif
+# endif
}
XFlush(x11_display);
}
} vim_acl_solaris_T;
# endif
-#if defined(HAVE_SELINUX)
+# if defined(HAVE_SELINUX)
/*
* Copy security info from "from_file" to "to_file".
*/
freecon(to_context);
freecon(from_context);
}
-#endif // HAVE_SELINUX
+# endif // HAVE_SELINUX
-#if defined(HAVE_SMACK) && !defined(PROTO)
+# if defined(HAVE_SMACK) && !defined(PROTO)
/*
* Copy security info from "from_file" to "to_file".
*/
}
}
}
-#endif // HAVE_SMACK
+# endif // HAVE_SMACK
-#if defined(FEAT_XATTR)
+# if defined(FEAT_XATTR)
/*
* Copy extended attributes from_file to to_file
*/
if (errmsg != NULL)
emsg(_(errmsg));
}
-#endif
+# endif
/*
* Return a pointer to the ACL of file "fname" in allocated memory.
mch_get_acl(char_u *fname UNUSED)
{
vim_acl_T ret = NULL;
-#ifdef HAVE_POSIX_ACL
+# ifdef HAVE_POSIX_ACL
ret = (vim_acl_T)acl_get_file((char *)fname, ACL_TYPE_ACCESS);
-#else
-#ifdef HAVE_SOLARIS_ZFS_ACL
+# else
+# ifdef HAVE_SOLARIS_ZFS_ACL
acl_t *aclent;
if (acl_get((char *)fname, 0, &aclent) < 0)
return NULL;
ret = (vim_acl_T)aclent;
-#else
-#ifdef HAVE_SOLARIS_ACL
+# else
+# ifdef HAVE_SOLARIS_ACL
vim_acl_solaris_T *aclent;
aclent = malloc(sizeof(vim_acl_solaris_T));
return NULL;
}
ret = (vim_acl_T)aclent;
-#else
-#if defined(HAVE_AIX_ACL)
+# else
+# if defined(HAVE_AIX_ACL)
int aclsize;
struct acl *aclent;
}
}
ret = (vim_acl_T)aclent;
-#endif // HAVE_AIX_ACL
-#endif // HAVE_SOLARIS_ACL
-#endif // HAVE_SOLARIS_ZFS_ACL
-#endif // HAVE_POSIX_ACL
+# endif // HAVE_AIX_ACL
+# endif // HAVE_SOLARIS_ACL
+# endif // HAVE_SOLARIS_ZFS_ACL
+# endif // HAVE_POSIX_ACL
return ret;
}
{
if (aclent == NULL)
return;
-#ifdef HAVE_POSIX_ACL
+# ifdef HAVE_POSIX_ACL
acl_set_file((char *)fname, ACL_TYPE_ACCESS, (acl_t)aclent);
-#else
-#ifdef HAVE_SOLARIS_ZFS_ACL
+# else
+# ifdef HAVE_SOLARIS_ZFS_ACL
acl_set((char *)fname, (acl_t *)aclent);
-#else
-#ifdef HAVE_SOLARIS_ACL
+# else
+# ifdef HAVE_SOLARIS_ACL
acl((char *)fname, SETACL, ((vim_acl_solaris_T *)aclent)->acl_cnt,
((vim_acl_solaris_T *)aclent)->acl_entry);
-#else
-#ifdef HAVE_AIX_ACL
+# else
+# ifdef HAVE_AIX_ACL
chacl((char *)fname, aclent, ((struct acl *)aclent)->acl_len);
-#endif // HAVE_AIX_ACL
-#endif // HAVE_SOLARIS_ACL
-#endif // HAVE_SOLARIS_ZFS_ACL
-#endif // HAVE_POSIX_ACL
+# endif // HAVE_AIX_ACL
+# endif // HAVE_SOLARIS_ACL
+# endif // HAVE_SOLARIS_ZFS_ACL
+# endif // HAVE_POSIX_ACL
}
void
{
if (aclent == NULL)
return;
-#ifdef HAVE_POSIX_ACL
+# ifdef HAVE_POSIX_ACL
acl_free((acl_t)aclent);
-#else
-#ifdef HAVE_SOLARIS_ZFS_ACL
+# else
+# ifdef HAVE_SOLARIS_ZFS_ACL
acl_free((acl_t *)aclent);
-#else
-#ifdef HAVE_SOLARIS_ACL
+# else
+# ifdef HAVE_SOLARIS_ACL
free(((vim_acl_solaris_T *)aclent)->acl_entry);
free(aclent);
-#else
-#ifdef HAVE_AIX_ACL
+# else
+# ifdef HAVE_AIX_ACL
free(aclent);
-#endif // HAVE_AIX_ACL
-#endif // HAVE_SOLARIS_ACL
-#endif // HAVE_SOLARIS_ZFS_ACL
-#endif // HAVE_POSIX_ACL
+# endif // HAVE_AIX_ACL
+# endif // HAVE_SOLARIS_ACL
+# endif // HAVE_SOLARIS_ZFS_ACL
+# endif // HAVE_POSIX_ACL
}
#endif
{
int tty_fd = fd;
-#if defined(HAVE_SVR4_PTYS) && defined(SUN_SYSTEM)
+# if defined(HAVE_SVR4_PTYS) && defined(SUN_SYSTEM)
// On SunOS: Get the terminal parameters from "fd", or the slave device of
// "fd" when it is a master device.
if (mch_isatty(fd) > 1)
if (tty_fd < 0)
return -1;
}
-#endif
+# endif
return tty_fd;
}
if (tty_fd < 0)
return -1;
-#ifdef NEW_TTY_SYSTEM
-# ifdef HAVE_TERMIOS_H
+# ifdef NEW_TTY_SYSTEM
+# ifdef HAVE_TERMIOS_H
retval = tcgetattr(tty_fd, (struct termios *)term);
-# else
+# else
retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
-# endif
-#else
+# endif
+# else
// for "old" tty systems
retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
-#endif
+# endif
if (tty_fd != fd)
close(tty_fd);
return retval;
{
static int first = TRUE;
-#ifdef NEW_TTY_SYSTEM
-# ifdef HAVE_TERMIOS_H
+# ifdef NEW_TTY_SYSTEM
+# ifdef HAVE_TERMIOS_H
static struct termios told;
struct termios tnew;
-# else
+# else
static struct termio told;
struct termio tnew;
-# endif
+# endif
if (first)
{
tnew.c_iflag &= ~(ICRNL |
(T_XON == NULL || *T_XON == NUL ? IXON : 0));
tnew.c_lflag &= ~(ICANON | ECHO | ISIG | ECHOE
-# if defined(IEXTEN)
+# if defined(IEXTEN)
| IEXTEN // IEXTEN enables typing ^V on SOLARIS
-# endif
+# endif
);
-# ifdef ONLCR
+# ifdef ONLCR
// Don't map NL -> CR NL, we do it ourselves.
// Also disable expanding tabs if possible.
-# ifdef XTABS
+# ifdef XTABS
tnew.c_oflag &= ~(ONLCR | XTABS);
-# else
-# ifdef TAB3
- tnew.c_oflag &= ~(ONLCR | TAB3);
# else
+# ifdef TAB3
+ tnew.c_oflag &= ~(ONLCR | TAB3);
+# else
tnew.c_oflag &= ~ONLCR;
+# endif
# endif
# endif
-# endif
tnew.c_cc[VMIN] = 1; // return after 1 char
tnew.c_cc[VTIME] = 0; // don't wait
}
tnew.c_cc[VTIME] = 0; // don't wait
}
-# if defined(HAVE_TERMIOS_H)
+# if defined(HAVE_TERMIOS_H)
{
int n = 10;
&& errno == EINTR && n > 0)
--n;
}
-# else
+# else
ioctl(read_cmd_fd, TCSETA, &tnew);
-# endif
+# endif
-#else
+# else
/*
* for "old" tty systems
*/
-# ifndef TIOCSETN
-# define TIOCSETN TIOCSETP // for hpux 9.0
-# endif
+# ifndef TIOCSETN
+# define TIOCSETN TIOCSETP // for hpux 9.0
+# endif
static struct sgttyb ttybold;
struct sgttyb ttybnew;
else if (tmode == TMODE_SLEEP)
ttybnew.sg_flags &= ~(ECHO);
ioctl(read_cmd_fd, TIOCSETN, &ttybnew);
-#endif
+# endif
mch_cur_tmode = tmode;
}
int
get_tty_info(int fd, ttyinfo_T *info)
{
-#ifdef NEW_TTY_SYSTEM
-# ifdef HAVE_TERMIOS_H
+# ifdef NEW_TTY_SYSTEM
+# ifdef HAVE_TERMIOS_H
struct termios keys;
-# else
+# else
struct termio keys;
-# endif
+# endif
if (mch_tcgetattr(fd, &keys) != -1)
{
info->nl_does_cr = FALSE;
return OK;
}
-#else
+# else
// for "old" tty systems
struct sgttyb keys;
info->nl_does_cr = TRUE;
return OK;
}
-#endif
+# endif
return FAIL;
}
void
check_mouse_termcode(void)
{
-# ifdef FEAT_MOUSE_XTERM
+#ifdef FEAT_MOUSE_XTERM
if (use_xterm_mouse()
# ifdef FEAT_MOUSE_URXVT
&& use_xterm_mouse() != 3
# endif
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-# endif
+# endif
)
{
set_mouse_termcode(KS_MOUSE, (char_u *)(term_is_8bit(T_NAME)
}
else
del_mouse_termcode(KS_MOUSE);
-# endif
+#endif
-# ifdef FEAT_MOUSE_GPM
+#ifdef FEAT_MOUSE_GPM
if (!use_xterm_mouse()
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-# endif
+# endif
)
set_mouse_termcode(KS_GPM_MOUSE, (char_u *)"\033MG");
else
del_mouse_termcode(KS_GPM_MOUSE);
-# endif
+#endif
-# ifdef FEAT_SYSMOUSE
+#ifdef FEAT_SYSMOUSE
if (!use_xterm_mouse()
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-# endif
+# endif
)
set_mouse_termcode(KS_MOUSE, (char_u *)"\033MS");
-# endif
+#endif
-# ifdef FEAT_MOUSE_JSB
+#ifdef FEAT_MOUSE_JSB
// Conflicts with xterm mouse: "\033[" and "\033[M" ???
if (!use_xterm_mouse()
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-# endif
+# endif
)
set_mouse_termcode(KS_JSBTERM_MOUSE, (char_u *)"\033[0~zw");
else
del_mouse_termcode(KS_JSBTERM_MOUSE);
-# endif
+#endif
-# ifdef FEAT_MOUSE_NET
+#ifdef FEAT_MOUSE_NET
// There is no conflict, but one may type "ESC }" from Insert mode. Don't
// define it in the GUI or when using an xterm.
if (!use_xterm_mouse()
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-# endif
+# endif
)
set_mouse_termcode(KS_NETTERM_MOUSE, (char_u *)"\033}");
else
del_mouse_termcode(KS_NETTERM_MOUSE);
-# endif
+#endif
-# ifdef FEAT_MOUSE_DEC
+#ifdef FEAT_MOUSE_DEC
// Conflicts with xterm mouse: "\033[" and "\033[M"
if (!use_xterm_mouse()
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-# endif
+# endif
)
set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
? "\233" : "\033["));
else
del_mouse_termcode(KS_DEC_MOUSE);
-# endif
-# ifdef FEAT_MOUSE_PTERM
+#endif
+#ifdef FEAT_MOUSE_PTERM
// same conflict as the dec mouse
if (!use_xterm_mouse()
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-# endif
+# endif
)
set_mouse_termcode(KS_PTERM_MOUSE, (char_u *)"\033[");
else
del_mouse_termcode(KS_PTERM_MOUSE);
-# endif
-# ifdef FEAT_MOUSE_URXVT
+#endif
+#ifdef FEAT_MOUSE_URXVT
if (use_xterm_mouse() == 3
-# ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& !gui.in_use
-# endif
+# endif
)
{
set_mouse_termcode(KS_URXVT_MOUSE, (char_u *)(term_is_8bit(T_NAME)
}
else
del_mouse_termcode(KS_URXVT_MOUSE);
-# endif
+#endif
if (use_xterm_mouse() == 4
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
&& !gui.in_use
-# endif
+#endif
)
{
set_mouse_termcode(KS_SGR_MOUSE, (char_u *)(term_is_8bit(T_NAME)
{
columns = ts.ts_cols;
rows = ts.ts_lines;
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "Got size with TIOCGSIZE: %ld x %ld", columns, rows);
-# endif
+# endif
}
}
# endif // TIOCGSIZE
if ((p = (char_u *)getenv("LINES")))
{
rows = atoi((char *)p);
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "Got 'lines' from $LINES: %ld", rows);
-# endif
+# endif
}
if ((p = (char_u *)getenv("COLUMNS")))
{
columns = atoi((char *)p);
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "Got 'columns' from $COLUMNS: %ld", columns);
-# endif
+# endif
}
}
-#ifdef HAVE_TGETENT
+# ifdef HAVE_TGETENT
/*
* 3. try reading "co" and "li" entries from termcap
*/
if (columns == 0 || rows == 0)
{
getlinecol(&columns, &rows);
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "Got size from termcap: %ld x %ld", columns, rows);
-# endif
+# endif
}
-#endif
+# endif
/*
* 4. If everything fails, use the old values
int retval = -1;
retval = ioctl(fd, TIOCGWINSZ, &ws);
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "ioctl(TIOCGWINSZ) %s", retval == 0 ? "success" : "failed");
-#endif
+# endif
if (retval == -1 || ws.ws_col == 0 || ws.ws_row == 0)
{
cs_out->cs_xpixel = x_cell_size;
cs_out->cs_ypixel = y_cell_size;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "Got cell pixel size with TIOCGWINSZ: %d x %d", x_cell_size, y_cell_size);
-#endif
+# endif
}
-#if defined(FEAT_TERMINAL)
+# if defined(FEAT_TERMINAL)
/*
* Report the windows size "rows" and "cols" to tty "fd".
*/
if (tty_fd < 0)
return FAIL;
-# if defined(TIOCSWINSZ)
+# if defined(TIOCSWINSZ)
struct winsize ws;
ws.ws_col = cols;
retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
ch_log(NULL, "ioctl(TIOCSWINSZ) %s", retval == 0 ? "success" : "failed");
-# elif defined(TIOCSSIZE)
+# elif defined(TIOCSSIZE)
struct ttysize ts;
ts.ts_cols = cols;
ts.ts_lines = rows;
retval = ioctl(tty_fd, TIOCSSIZE, &ts);
ch_log(NULL, "ioctl(TIOCSSIZE) %s", retval == 0 ? "success" : "failed");
-# endif
+# endif
if (tty_fd != fd)
close(tty_fd);
return retval == 0 ? OK : FAIL;
}
-#endif
+# endif
/*
* Try to set the window size to Rows and Columns.
// wait() sometimes hangs for no obvious reason. Use waitpid()
// instead and loop (like the GUI). Also needed for other interfaces,
// they might call system().
-# ifdef __NeXT__
+#ifdef __NeXT__
wait_pid = wait4(child, status, WNOHANG, (struct rusage *)0);
-# else
+#else
wait_pid = waitpid(child, status, WNOHANG);
-# endif
+#endif
if (wait_pid == 0)
{
// Wait for 1 to 10 msec before trying again.
continue;
}
if (wait_pid <= 0
-# ifdef ECHILD
+#ifdef ECHILD
&& errno == ECHILD
-# endif
+#endif
)
break;
}
// Leaving out O_NOCTTY may lead to waitpid() always returning
// 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
// adding O_NOCTTY always works when defined.
-#ifdef O_NOCTTY
+# ifdef O_NOCTTY
*pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
-#else
+# else
*pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
-#endif
+# endif
if (*pty_slave_fd < 0)
{
close(*pty_master_fd);
static void
may_send_sigint(int c UNUSED, pid_t pid UNUSED, pid_t wpid UNUSED)
{
-# ifdef SIGINT
+#ifdef SIGINT
if (c == Ctrl_C || c == intr_char)
{
-# ifdef HAVE_SETSID
+# ifdef HAVE_SETSID
kill(-pid, SIGINT);
-# else
+# else
kill(0, SIGINT);
-# endif
+# endif
if (wpid > 0)
kill(wpid, SIGINT);
}
-# endif
+#endif
}
#if !defined(USE_SYSTEM) || defined(FEAT_TERMINAL)
char_u *cmd,
int options) // SHELL_*, see vim.h
{
-#ifdef VMS
+# ifdef VMS
char *ifn = NULL;
char *ofn = NULL;
-#endif
+# endif
tmode_T tmode = cur_tmode;
char_u *newcmd; // only needed for unix
int x;
# if defined(FEAT_CLIPBOARD) && (defined(FEAT_X11) \
|| defined(FEAT_WAYLAND_CLIPBOARD))
-# if defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)
+# if defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)
save_clipboard();
-#endif
+# endif
loose_clipboard();
# endif
{
// CTRL-C sends a signal to the child, we ignore it
// ourselves
-# ifdef HAVE_SETSID
+# ifdef HAVE_SETSID
kill(-pid, SIGINT);
-# else
+# else
kill(0, SIGINT);
-# endif
+# endif
if (wpid > 0)
kill(wpid, SIGINT);
got_int = FALSE;
// Handle any X events, e.g. serving the clipboard.
clip_update();
# endif
-#ifdef FEAT_WAYLAND
+# ifdef FEAT_WAYLAND
// Handle Wayland events such as sending data as the source
// client.
wayland_update();
-#endif
+# endif
}
finished:
p_more = p_more_save;
# endif
got_int = FALSE;
}
-# ifdef __NeXT__
+# ifdef __NeXT__
wait_pid = wait4(pid, &status, WNOHANG, (struct rusage *)0);
-# else
+# else
wait_pid = waitpid(pid, &status, WNOHANG);
-# endif
+# endif
if ((wait_pid == (pid_t)-1 && errno == ECHILD)
|| (wait_pid == pid && WIFEXITED(status)))
{
break;
}
-#if defined(FEAT_XCLIPBOARD) && defined(FEAT_X11)
+# if defined(FEAT_XCLIPBOARD) && defined(FEAT_X11)
// Handle any X events, e.g. serving the clipboard.
clip_update();
-#endif
-#ifdef FEAT_WAYLAND
+# endif
+# ifdef FEAT_WAYLAND
// Handle Wayland events such as sending data as the source
// client.
wayland_update();
-#endif
+# endif
// Wait for 1 to 10 msec. 1 is faster but gives the child
// less time, gradually wait longer.
{
char *term = (char *)T_NAME;
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (term_is_gui(T_NAME))
// In the GUI 'term' is not what we want, use $TERM.
term = getenv("TERM");
-#endif
+# endif
// Use 'term' or $TERM if it starts with "xterm", otherwise fall
// back to "xterm" or "xterm-color".
if (term == NULL || *term == NUL || STRNCMP(term, "xterm", 5) != 0)
{
// push stream discipline modules
setup_slavepty(pty_slave_fd);
-# ifdef TIOCSCTTY
+# ifdef TIOCSCTTY
// Try to become controlling tty (probably doesn't work,
// unless run by root)
ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL);
-# endif
+# endif
}
// set up stdin for the child
sig = SIGINT;
else if (STRCMP(how, "kill") == 0)
sig = SIGKILL;
-#ifdef SIGWINCH
+# ifdef SIGWINCH
else if (STRCMP(how, "winch") == 0)
sig = SIGWINCH;
-#endif
+# endif
else if (SAFE_isdigit(*how))
sig = atoi((char *)how);
else
{
int ret;
int result;
-#if defined(FEAT_XCLIPBOARD) || defined(USE_XSMP) || defined(FEAT_MZSCHEME)
+# if defined(FEAT_XCLIPBOARD) || defined(USE_XSMP) || defined(FEAT_MZSCHEME)
static int busy = FALSE;
// May retry getting characters after an event was handled.
-# define MAY_LOOP
+# define MAY_LOOP
-# ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
// Remember at what time we started, so that we know how much longer we
// should wait after being interrupted.
long start_msec = msec;
if (msec > 0)
ELAPSED_INIT(start_tv);
-# endif
+# endif
// Handle being called recursively. This may happen for the session
// manager stuff, it may save the file, which does a breakcheck.
if (busy)
return 0;
-#endif
+# endif
-#ifdef MAY_LOOP
+# ifdef MAY_LOOP
for (;;)
-#endif
+# endif
{
-#ifdef MAY_LOOP
+# ifdef MAY_LOOP
int finished = TRUE; // default is to 'loop' just once
-# ifdef FEAT_MZSCHEME
+# ifdef FEAT_MZSCHEME
int mzquantum_used = FALSE;
+# endif
# endif
-#endif
-#ifdef FEAT_WAYLAND
+# ifdef FEAT_WAYLAND
int wayland_fd = -1;
-#endif
-#ifndef HAVE_SELECT
+# endif
+# ifndef HAVE_SELECT
// each channel may use in, out and err
struct pollfd fds[7 + 3 * MAX_OPEN_CHANNELS];
int nfd;
-# ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
int socket_server_idx = -1;
-# endif
-# ifdef FEAT_WAYLAND_CLIPBOARD
+# endif
+# ifdef FEAT_WAYLAND_CLIPBOARD
int wayland_idx = -1;
-# endif
-# ifdef FEAT_XCLIPBOARD
+# endif
+# ifdef FEAT_XCLIPBOARD
int xterm_idx = -1;
-# endif
-# ifdef FEAT_MOUSE_GPM
+# endif
+# ifdef FEAT_MOUSE_GPM
int gpm_idx = -1;
-# endif
-# ifdef USE_XSMP
+# endif
+# ifdef USE_XSMP
int xsmp_idx = -1;
-# endif
+# endif
int towait = (int)msec;
-# ifdef FEAT_MZSCHEME
+# ifdef FEAT_MZSCHEME
mzvim_check_threads();
if (mzthreads_allowed() && p_mzq > 0 && (msec < 0 || msec > p_mzq))
{
towait = (int)p_mzq; // don't wait longer than 'mzquantum'
mzquantum_used = TRUE;
}
-# endif
+# endif
fds[0].fd = fd;
fds[0].events = POLLIN;
nfd = 1;
-# ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
if (socket_server_fd != -1)
{
socket_server_idx = nfd;
fds[nfd].events = POLLIN;
nfd++;
}
-# endif
+# endif
-# ifdef FEAT_WAYLAND
+# ifdef FEAT_WAYLAND
if ((wayland_fd = wayland_prepare_read()) >= 0)
{
wayland_idx = nfd;
fds[nfd].events = POLLIN;
nfd++;
}
-# endif
-# ifdef FEAT_XCLIPBOARD
+# endif
+# ifdef FEAT_XCLIPBOARD
may_restore_clipboard();
if (xterm_Shell != (Widget)0)
{
fds[nfd].events = POLLIN;
nfd++;
}
-# endif
-# ifdef FEAT_MOUSE_GPM
+# endif
+# ifdef FEAT_MOUSE_GPM
if (check_for_gpm != NULL && gpm_flag && gpm_fd >= 0)
{
gpm_idx = nfd;
fds[nfd].events = POLLIN;
nfd++;
}
-# endif
-# ifdef USE_XSMP
+# endif
+# ifdef USE_XSMP
if (xsmp_icefd != -1)
{
xsmp_idx = nfd;
fds[nfd].events = POLLIN;
nfd++;
}
-# endif
-# ifdef FEAT_JOB_CHANNEL
+# endif
+# ifdef FEAT_JOB_CHANNEL
nfd = channel_poll_setup(nfd, &fds, &towait);
-# endif
+# endif
if (interrupted != NULL)
*interrupted = FALSE;
if (result == 0 && interrupted != NULL && ret > 0)
*interrupted = TRUE;
-# ifdef FEAT_MZSCHEME
+# ifdef FEAT_MZSCHEME
if (ret == 0 && mzquantum_used)
// MzThreads scheduling is required and timeout occurred
finished = FALSE;
-# endif
+# endif
-# ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
if (socket_server_idx >= 0)
{
if (fds[socket_server_idx].revents & POLLIN)
else if (fds[socket_server_idx].revents & (POLLHUP | POLLERR))
socket_server_uninit();
}
-# endif
+# endif
-# ifdef FEAT_WAYLAND
+# ifdef FEAT_WAYLAND
if (wayland_idx >= 0)
wayland_poll_check(fds[wayland_idx].revents);
-# endif
+# endif
-# ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
if (xterm_Shell != (Widget)0 && (fds[xterm_idx].revents & POLLIN))
{
xterm_update(); // Maybe we should hand out clipboard
// Try again
finished = FALSE;
}
-# endif
-# ifdef FEAT_MOUSE_GPM
+# endif
+# ifdef FEAT_MOUSE_GPM
if (gpm_idx >= 0 && (fds[gpm_idx].revents & POLLIN))
*check_for_gpm = 1;
-# endif
-# ifdef USE_XSMP
+# endif
+# ifdef USE_XSMP
if (xsmp_idx >= 0 && (fds[xsmp_idx].revents & (POLLIN | POLLHUP)))
{
if (fds[xsmp_idx].revents & POLLIN)
if (--ret == 0)
finished = FALSE; // Try again
}
-# endif
-# ifdef FEAT_JOB_CHANNEL
+# endif
+# ifdef FEAT_JOB_CHANNEL
// also call when ret == 0, we may be polling a keep-open channel
if (ret >= 0)
channel_poll_check(ret, &fds);
-# endif
+# endif
-#else // HAVE_SELECT
+# else // HAVE_SELECT
struct timeval tv;
struct timeval *tvp;
int maxfd;
long towait = msec;
-# ifdef FEAT_MZSCHEME
+# ifdef FEAT_MZSCHEME
mzvim_check_threads();
if (mzthreads_allowed() && p_mzq > 0 && (msec < 0 || msec > p_mzq))
{
towait = p_mzq; // don't wait longer than 'mzquantum'
mzquantum_used = TRUE;
}
-# endif
+# endif
if (towait >= 0)
{
FD_ZERO(&wfds);
FD_ZERO(&efds);
FD_SET(fd, &rfds);
-# ifndef __QNX__
+# ifndef __QNX__
// For QNX select() always returns 1 if this is set. Why?
FD_SET(fd, &efds);
-# endif
+# endif
maxfd = fd;
-# ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
if (socket_server_fd != -1)
{
FD_SET(socket_server_fd, &rfds);
if (maxfd < socket_server_fd)
maxfd = socket_server_fd;
}
-# endif
+# endif
-# ifdef FEAT_WAYLAND
+# ifdef FEAT_WAYLAND
if ((wayland_fd = wayland_prepare_read()) >= 0)
{
FD_SET(wayland_fd, &rfds);
if (maxfd < wayland_fd)
maxfd = wayland_fd;
}
-# endif
+# endif
-# ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
may_restore_x11_clipboard();
if (xterm_Shell != (Widget)0)
{
// particularly, XFlush may cause this.
xterm_update();
}
-# endif
-# ifdef FEAT_MOUSE_GPM
+# endif
+# ifdef FEAT_MOUSE_GPM
if (check_for_gpm != NULL && gpm_flag && gpm_fd >= 0)
{
FD_SET(gpm_fd, &rfds);
if (maxfd < gpm_fd)
maxfd = gpm_fd;
}
-# endif
-# ifdef USE_XSMP
+# endif
+# ifdef USE_XSMP
if (xsmp_icefd != -1)
{
FD_SET(xsmp_icefd, &rfds);
if (maxfd < xsmp_icefd)
maxfd = xsmp_icefd;
}
-# endif
-# ifdef FEAT_JOB_CHANNEL
+# endif
+# ifdef FEAT_JOB_CHANNEL
maxfd = channel_select_setup(maxfd, &rfds, &wfds, &tv, &tvp);
-# endif
+# endif
if (interrupted != NULL)
*interrupted = FALSE;
else if (interrupted != NULL && ret > 0)
*interrupted = TRUE;
-# ifdef EINTR
+# ifdef EINTR
if (ret == -1 && errno == EINTR)
{
// Check whether the EINTR is caused by SIGTSTP
// SIGWINCH.
if (do_resize)
{
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "calling handle_resize() in RealWaitForChar()");
-# endif
+# endif
handle_resize();
}
// external command after the process has finished.
goto select_eintr;
}
-# endif
-# ifdef __TANDEM
+# endif
+# ifdef __TANDEM
if (ret == -1 && errno == ENOTSUP)
{
FD_ZERO(&rfds);
FD_ZERO(&efds);
ret = 0;
}
-# endif
-# ifdef FEAT_MZSCHEME
+# endif
+# ifdef FEAT_MZSCHEME
if (ret == 0 && mzquantum_used)
// loop if MzThreads must be scheduled and timeout occurred
finished = FALSE;
-# endif
+# endif
-# ifdef FEAT_SOCKETSERVER
+# ifdef FEAT_SOCKETSERVER
if (ret > 0 && socket_server_fd != -1
&& FD_ISSET(socket_server_fd, &rfds)
&& socket_server_accept_client() == FAIL)
socket_server_uninit();
-# endif
+# endif
-# ifdef FEAT_WAYLAND
+# ifdef FEAT_WAYLAND
if (wayland_fd != -1)
wayland_select_check(ret > 0 && FD_ISSET(wayland_fd, &rfds));
-# endif
+# endif
-# ifdef FEAT_XCLIPBOARD
+# ifdef FEAT_XCLIPBOARD
if (ret > 0 && xterm_Shell != (Widget)0
&& FD_ISSET(ConnectionNumber(xterm_dpy), &rfds))
{
finished = FALSE;
}
}
-# endif
-# ifdef FEAT_MOUSE_GPM
+# endif
+# ifdef FEAT_MOUSE_GPM
if (ret > 0 && check_for_gpm != NULL && gpm_flag && gpm_fd >= 0)
{
if (FD_ISSET(gpm_fd, &efds))
else if (FD_ISSET(gpm_fd, &rfds))
*check_for_gpm = 1;
}
-# endif
-# ifdef USE_XSMP
+# endif
+# ifdef USE_XSMP
if (ret > 0 && xsmp_icefd != -1)
{
if (FD_ISSET(xsmp_icefd, &efds))
finished = FALSE; // keep going if event was only one
}
}
-# endif
-# ifdef FEAT_JOB_CHANNEL
+# endif
+# ifdef FEAT_JOB_CHANNEL
// also call when ret == 0, we may be polling a keep-open channel
if (ret >= 0)
(void)channel_select_check(ret, &rfds, &wfds);
-# endif
+# endif
-#endif // HAVE_SELECT
+# endif // HAVE_SELECT
-#ifdef MAY_LOOP
+# ifdef MAY_LOOP
if (finished || msec == 0)
break;
-# if defined(FEAT_CLIENTSERVER)
-# ifdef FEAT_X11
+# if defined(FEAT_CLIENTSERVER)
+# ifdef FEAT_X11
if (clientserver_method == CLIENTSERVER_METHOD_X11 && server_waiting())
break;
-# endif
-# ifdef FEAT_SOCKETSERVER
+# endif
+# ifdef FEAT_SOCKETSERVER
if (clientserver_method == CLIENTSERVER_METHOD_SOCKET &&
socket_server_waiting_accept())
break;
+# endif
# endif
-# endif
// We're going to loop around again, find out for how long
if (msec > 0)
{
-# ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
// Compute remaining wait time.
msec = start_msec - ELAPSED_FUNC(start_tv);
-# else
+# else
// Guess we got interrupted halfway.
msec = msec / 2;
-# endif
+# endif
if (msec <= 0)
break; // waited long enough
}
-#endif
+# endif
}
return result;
* file is pointer to array of pointers to matched file names
*/
-#ifndef SEEK_SET
-# define SEEK_SET 0
-#endif
-#ifndef SEEK_END
-# define SEEK_END 2
-#endif
+# ifndef SEEK_SET
+# define SEEK_SET 0
+# endif
+# ifndef SEEK_END
+# define SEEK_END 2
+# endif
-#define SHELL_SPECIAL (char_u *)"\t \"&'$;<>()\\|"
+# define SHELL_SPECIAL (char_u *)"\t \"&'$;<>()\\|"
int
mch_expand_wildcards(
size_t commandlen;
FILE *fd;
char_u *buffer;
-#define STYLE_ECHO 0 // use "echo", the default
-#define STYLE_GLOB 1 // use "glob", for csh
-#define STYLE_VIMGLOB 2 // use "vimglob", for Posix sh
-#define STYLE_PRINT 3 // use "print -N", for zsh
-#define STYLE_BT 4 // `cmd` expansion, execute the pattern directly
-#define STYLE_GLOBSTAR 5 // use extended shell glob for bash (this uses extended
+# define STYLE_ECHO 0 // use "echo", the default
+# define STYLE_GLOB 1 // use "glob", for csh
+# define STYLE_VIMGLOB 2 // use "vimglob", for Posix sh
+# define STYLE_PRINT 3 // use "print -N", for zsh
+# define STYLE_BT 4 // `cmd` expansion, execute the pattern directly
+# define STYLE_GLOBSTAR 5 // use extended shell glob for bash (this uses extended
// globbing functionality using globstar, needs bash > 4)
int shell_style = STYLE_ECHO;
int check_spaces;
static int did_find_nul = FALSE;
int ampersand = FALSE;
-#define STRING_INIT(s) \
+# define STRING_INIT(s) \
{(char_u *)(s), STRLEN_LITERAL(s)}
// vimglob() function to define for Posix shell
static string_T sh_vimglob_func = STRING_INIT("vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >");
// vimglob() function with globstar setting enabled, only for bash >= 4.X
static string_T sh_globstar_opt = STRING_INIT("[[ ${BASH_VERSINFO[0]} -ge 4 ]] && shopt -s globstar; ");
-#undef STRING_INIT
+# undef STRING_INIT
*num_file = 0; // default: no files found
{
// Count the length of the patterns in the same way as they are put in
// "command" below.
-#ifdef USE_SYSTEM
+# ifdef USE_SYSTEM
len += STRLEN(pat[i]) + 3; // add space and two quotes
-#else
+# else
++len; // add space
for (j = 0; pat[i][j] != NUL; ++j)
{
++len; // may add a backslash
++len;
}
-#endif
+# endif
}
command = alloc(len);
if (command == NULL)
// When using system() always add extra quotes, because the shell
// is started twice. Otherwise put a backslash before special
// characters, except inside ``.
-#ifdef USE_SYSTEM
+# ifdef USE_SYSTEM
commandlen += vim_snprintf((char *)command + commandlen, len, " \"%s\"", pat[i]);
-#else
+# else
int intick = FALSE;
p = command + commandlen;
}
*p = NUL;
commandlen = (size_t)(p - command);
-#endif
+# endif
}
}
if (flags & EW_SILENT)
* However with USE_SYSTEM, I don't know how to turn off error messages
* from the shell, so screen may still get messed up -- webb.
*/
-#ifndef USE_SYSTEM
+# ifndef USE_SYSTEM
if (!(flags & EW_SILENT))
-#endif
+# endif
{
redraw_later_clear(); // probably messed up screen
msg_putchar('\n'); // clear bottom line quickly
cmdline_row = Rows - 1; // continue on last line
-#ifdef USE_SYSTEM
+# ifdef USE_SYSTEM
if (!(flags & EW_SILENT))
-#endif
+# endif
{
msg(_(e_cannot_expand_wildcards));
msg_start(); // don't overwrite this message
{
static Gpm_Connect gpm_connect; // Must it be kept till closing ?
-#ifdef DYNAMIC_GPM
+# ifdef DYNAMIC_GPM
if (!gpm_available())
return 0;
-#endif
+# endif
if (gpm_flag)
return 1; // already open
Gpm_GetEvent(&gpm_event);
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
// Don't put events in the input queue now.
if (hold_gui_events)
return 0;
-#endif
+# endif
row = gpm_event.y - 1;
col = gpm_event.x - 1;
int buttons;
static int oldbuttons = 0;
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
// Don't put events in the input queue now.
if (hold_gui_events)
return;
-#endif
+# endif
mouse.operation = MOUSE_GETINFO;
if (ioctl(1, FBIO_GETMODE, &video.vi_mode) != -1
{
// There is an event to process.
XtAppNextEvent(app_context, &event);
-#ifdef FEAT_CLIENTSERVER
+# ifdef FEAT_CLIENTSERVER
{
XPropertyEvent *e = (XPropertyEvent *)&event;
&& e->atom == commProperty && e->state == PropertyNewValue)
serverEventProc(xterm_dpy, &event, 0);
}
-#endif
+# endif
XtDispatchEvent(&event);
}
else
{
char errorstring[80];
SmcCallbacks smcallbacks;
-#if 0
+# if 0
SmPropValue smname;
SmProp smnameprop;
SmProp *smprops[1];
-#endif
+# endif
if (p_verbose > 0)
verb_msg(_("XSMP opening connection"));
}
xsmp.iceconn = SmcGetIceConnection(xsmp.smcconn);
-#if 0
+# if 0
// ID ourselves
smname.value = "vim";
smname.length = 3;
smprops[0] = &smnameprop;
SmcSetProperties(xsmp.smcconn, 1, smprops);
-#endif
+# endif
}
timer_created = TRUE;
}
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "setting timeout timer to %d sec %ld nsec",
(int)interval.it_value.tv_sec, (long)interval.it_value.tv_nsec);
-# endif
+# endif
ret = timer_settime(timer_id, 0, &interval, NULL);
if (ret < 0)
semsg(_(e_could_not_set_timeout_str), strerror(errno));
}
serverName = vim_strsave(socket_server_path);
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
set_vim_var_string(VV_SEND_SERVER, serverName, -1);
-#endif
+# endif
socket_server_fd = fd;
-#ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
if (gui.in_use)
// Initialize source for GUI if we are using it
gui_gtk_init_socket_server();
-#endif
+# endif
vim_free(path);
return OK;
vim_free(socket_server_path);
socket_server_path = NULL;
}
-#ifdef FEAT_GUI_GTK
+# ifdef FEAT_GUI_GTK
if (gui.in_use)
gui_gtk_uninit_socket_server();
-#endif
+# endif
}
/*
if (socket_server_decode_cmd(&cmd, fd, 1000) == FAIL)
goto exit;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "accepted new client on socket %s", socket_server_path);
-#endif
+# endif
socket_server_exec_cmd(&cmd, fd);
socket_server_free_cmd(&cmd);
size_t sz;
char_u *final;
char_u *path;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
elapsed_T start_tv;
-#endif
+# endif
if (!socket_server_valid())
{
if (socket_fd == -1)
return -1;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "socket_server_send(%s, %s)", path, str);
-#endif
+# endif
// Execute locally if target is ourselves
if (serverName != NULL && STRICMP(path, serverName) == 0)
socket_server_init_pending_cmd(&pending);
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
ELAPSED_INIT(start_tv);
-#endif
+# endif
// Wait for server to send back result
while (socket_server_dispatch(500) >= 0)
if (pending.result != NULL)
break;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
if (ELAPSED_FUNC(start_tv) >= (timeout > 0 ? timeout : 1000))
break;
-#endif
+# endif
}
if (pending.result == NULL)
socket_server_read_reply(char_u *client, char_u **str, int timeout UNUSED)
{
ss_reply_T *reply = NULL;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
elapsed_T start_tv;
-#endif
+# endif
if (!socket_server_name_is_valid(client))
return -1;
if (!socket_server_valid())
return -1;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
if (timeout > 0)
ELAPSED_INIT(start_tv);
-#endif
+# endif
// Try seeing if there already is a reply in the queue
goto get_reply;
{
int fd;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
if (timeout > 0 && ELAPSED_FUNC(start_tv) >= timeout)
break;
-#endif
+# endif
get_reply:
reply = socket_server_get_reply(client, NULL);
size_t total_r = 0;
char_u *buf;
char_u *cur;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
elapsed_T start_tv;
-#endif
+# endif
// We also poll the socket server listening file descriptor to handle
// recursive remote calls between Vim instances, such as when one Vim
// instance calls remote_expr for an expression that calls remote_expr to
// itself again.
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
struct pollfd pfd;
pfd.fd = socket_fd;
pfd.events = POLLIN;
-#else
+# else
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(socket_fd, &rfds);
-#endif
+# endif
buf = alloc(SS_CMD_INFO_SIZE);
// want to free an uninitialized pointer.
memset(cmd, 0, sizeof(*cmd));
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
ELAPSED_INIT(start_tv);
-#endif
+# endif
while (TRUE)
{
int ret;
ssize_t r = 0;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
ret = poll(&pfd, 1, timeout);
-#else
+# else
tv.tv_sec = 0;
tv.tv_usec = 500 * 1000;
ret = select(socket_fd + 1, &rfds, NULL, NULL, &tv);
-#endif
+# endif
if (ret < 0)
goto fail;
if (ret == 0)
total_r += r;
continue_loop:
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
if (ELAPSED_FUNC(start_tv) >= timeout)
goto fail;
-#endif
+# endif
}
// Parse message data
{
char_u *cur = data;
size_t total_w = 0;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
elapsed_T start_tv;
-#endif
-#ifndef HAVE_SELECT
+# endif
+# ifndef HAVE_SELECT
struct pollfd pfd;
pfd.fd = socket_fd;
pfd.events = POLLOUT;
-#else
+# else
fd_set wfds;
struct timeval tv;
FD_ZERO(&wfds);
FD_SET(socket_fd, &wfds);
-#endif
+# endif
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
ELAPSED_INIT(start_tv);
-#endif
+# endif
while (total_w < sz)
{
ssize_t written;
errno = 0;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
ret = poll(&pfd, 1, timeout);
-#else
+# else
tv.tv_sec = 0;
tv.tv_usec = 500 * 1000;
ret = select(socket_fd + 1, NULL, &wfds, NULL, &tv);
-#endif
+# endif
if (ret < 0)
return FAIL;
else if (ret == 0)
total_w += written;
continue_loop:
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
if (ELAPSED_FUNC(start_tv) >= timeout)
return FAIL;
-#endif
+# endif
}
return OK;
}
}
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "socket_server_exec_cmd(): encoding: %s, result: %s",
enc == NULL ? (char_u *)"(null)" : enc,
str == NULL ? (char_u *)"(null)" : str);
-#endif
+# endif
if (cmd->cmd_type == SS_CMD_TYPE_EXPR ||
cmd->cmd_type == SS_CMD_TYPE_KEYSTROKES)
// Client wants to check if we are still responsive, send back a single
// byte as a YES.
char_u buf[1] = {1};
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
struct pollfd pfd;
pfd.fd = fd;
pfd.events = POLLIN;
-#else
+# else
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
-#endif
+# endif
if (write(fd, buf, 1) == -1)
return;
// Poll until client closes their end
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
poll(&pfd, 1, 1000);
-#else
+# else
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
-#endif
+# endif
return;
}
socket_server_dispatch(int timeout)
{
int ret;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
struct pollfd pfd;
pfd.fd = socket_server_fd;
pfd.events = POLLIN;
-#else
+# else
fd_set rfds;
fd_set efds;
struct timeval tv;
FD_ZERO(&efds);
FD_SET(socket_server_fd, &rfds);
FD_SET(socket_server_fd, &efds);
-#endif
+# endif
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
ret = poll(&pfd, 1, timeout);
-#else
+# else
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
ret = select(socket_server_fd + 1, &rfds, NULL, &efds, &tv);
-#endif
+# endif
if (ret < 0)
return -1;
else if (ret == 0)
return 1;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
if (pfd.revents & POLLIN)
-#else
+# else
if (FD_ISSET(socket_server_fd, &rfds))
-#endif
+# endif
{
socket_server_accept_client();
return 0;
}
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
else if (pfd.revents & (POLLHUP | POLLERR))
-#else
+# else
else if (FD_ISSET(socket_server_fd, &efds))
-#endif
+# endif
// Connection was closed
return -1;
else
size_t sz;
char_u *final;
char_u buf[1] = {0};
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
struct pollfd pfd;
-#else
+# else
fd_set rfds;
struct timeval tv;
-#endif
+# endif
socket_fd = socket_server_connect(name, NULL, TRUE);
if (socket_fd == -1)
return FALSE;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
pfd.fd = socket_fd;
pfd.events = POLLIN;
-#else
+# else
FD_ZERO(&rfds);
FD_SET(socket_fd, &rfds);
-#endif
+# endif
ss_cmd_T cmd;
vim_free(final);
// Poll for response
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
ret = poll(&pfd, 1, 1000);
-#else
+# else
tv.tv_sec = 1;
tv.tv_usec = 0;
ret = select(socket_fd + 1, &rfds, NULL, NULL, &tv);
-#endif
+# endif
if (ret > 0)
if (read(socket_fd, buf, 1) == -1)
socket_server_waiting_accept(void)
{
int ret;
-#ifndef HAVE_SELECT
+# ifndef HAVE_SELECT
struct pollfd pfd;
pfd.fd = socket_server_fd;
if (ret > 0 && pfd.revents & POLLIN)
return TRUE;
-#else
+# else
fd_set rfds;
struct timeval tv;
if (ret > 0 && FD_ISSET(socket_server_fd, &rfds))
return TRUE;
-#endif
+# endif
return FALSE;
}
#ifndef USR_VIMRC_FILE
# ifdef VMS
-# define USR_VIMRC_FILE "sys$login:.vimrc"
+# define USR_VIMRC_FILE "sys$login:.vimrc"
# else
# define USR_VIMRC_FILE "$HOME/.vimrc"
# endif
# ifdef VMS
# define USR_VIMRC_FILE2 "sys$login:vimfiles/vimrc"
# else
-# define USR_VIMRC_FILE2 "~/.vim/vimrc"
+# define USR_VIMRC_FILE2 "~/.vim/vimrc"
# endif
#endif
# define mch_memmove(to, from, len) bcopy((char *)(from), (char *)(to), len)
# else
// ifdef USEMEMCPY
-# define mch_memmove(to, from, len) memcpy((char *)(to), (char *)(from), len)
+# define mch_memmove(to, from, len) memcpy((char *)(to), (char *)(from), len)
# endif
#endif
* I don't understand why we don't want termios.h for apollo.
*/
#if defined(HAVE_TERMIOS_H) && !defined(apollo)
-# include <termios.h>
+# include <termios.h>
#else
# ifdef HAVE_TERMIO_H
# include <termio.h>
#else
// based on Alpha's gen64def.h; the file is absent on VAX
typedef struct _generic_64 {
-# pragma __nomember_alignment
+# pragma __nomember_alignment
__union { // You can treat me as...
// long long is not available on VAXen
// unsigned __int64 gen64$q_quadword; ...a single 64-bit value, or
#if !defined( __VAX) && (__CRTL_VER >= 70301000)
-#include <stdio.h>
-#include <unixlib.h>
+# include <stdio.h>
+# include <unixlib.h>
// Structure to hold a DECC$* feature name and its desired value
/* Get "vms_init()" into a valid, loaded LIB$INITIALIZE PSECT. */
-#pragma nostandard
+# pragma nostandard
/* Establish the LIB$INITIALIZE PSECTs, with proper alignment and
* other attributes. Note that "nopic" is significant only on VAX.
*/
-#pragma extern_model save
+# pragma extern_model save
-#pragma extern_model strict_refdef "LIB$INITIALIZE" 2, nopic, nowrt
+# pragma extern_model strict_refdef "LIB$INITIALIZE" 2, nopic, nowrt
void (*const x_vms_init)() = vms_init;
-#pragma extern_model strict_refdef "LIB$INITIALIZ" 2, nopic, nowrt
+# pragma extern_model strict_refdef "LIB$INITIALIZ" 2, nopic, nowrt
const int spare[ 8] = { 0 };
-#pragma extern_model restore
+# pragma extern_model restore
// Fake reference to ensure loading the LIB$INITIALIZE PSECT
-#pragma extern_model save
+# pragma extern_model save
int LIB$INITIALIZE(void);
-#pragma extern_model strict_refdef
+# pragma extern_model strict_refdef
int dmy_lib$initialize = (int) LIB$INITIALIZE;
-#pragma extern_model restore
+# pragma extern_model restore
-#pragma standard
+# pragma standard
#endif // !defined( __VAX) && (__CRTL_VER >= 70301000)
*/
#if defined(__VMS) || defined(__vms)
-#if !defined(VMS)
-#define VMS
-#endif
+# if !defined(VMS)
+# define VMS
+# endif
#endif
#include <decc$types.h> // Required early for large-file support
// Hardware specific
#if defined(__VAX) || defined(VAX)
-#undef HAVE_GETTIMEOFDAY
-#undef HAVE_USLEEP
-#undef HAVE_STRCASECMP
-#undef HAVE_STRINGS_H
-#undef HAVE_SIGSETJMP
-#undef HAVE_ISNAN
-#undef HAVE_XOS_R_H
-#define HAVE_NO_LONG_LONG
-#define LONG_LONG_MIN (-2147483647-1)
-#define LONG_LONG_MAX (2147483647)
-#define ULONG_LONG_MAX (4294967295U)
+# undef HAVE_GETTIMEOFDAY
+# undef HAVE_USLEEP
+# undef HAVE_STRCASECMP
+# undef HAVE_STRINGS_H
+# undef HAVE_SIGSETJMP
+# undef HAVE_ISNAN
+# undef HAVE_XOS_R_H
+# define HAVE_NO_LONG_LONG
+# define LONG_LONG_MIN (-2147483647-1)
+# define LONG_LONG_MAX (2147483647)
+# define ULONG_LONG_MAX (4294967295U)
#else // ALPHA, IA64, X86_64
-#define HAVE_FSEEKO /* Use off_t. */
-#define HAVE_GETTIMEOFDAY
-#define HAVE_USLEEP
-#define HAVE_STRCASECMP
-#define HAVE_STRINGS_H
-#define HAVE_SIGSETJMP
-#undef HAVE_XOS_R_H
-#undef HAVE_NO_LONG_LONG
-#define LONG_LONG_MIN (-9223372036854775807-1)
-#define LONG_LONG_MAX (9223372036854775807)
-#define ULONG_LONG_MAX (18446744073709551615U)
-
-#if defined(__DECC) && (__CRTL_VER >= 80500000) && (__STDC_VERSION__ >= 199901L) /* C99 */
-#define HAVE_ISINF
-#define HAVE_ISNAN
-#endif
-
-#define HAVE_XOS_R_H
+# define HAVE_FSEEKO /* Use off_t. */
+# define HAVE_GETTIMEOFDAY
+# define HAVE_USLEEP
+# define HAVE_STRCASECMP
+# define HAVE_STRINGS_H
+# define HAVE_SIGSETJMP
+# undef HAVE_XOS_R_H
+# undef HAVE_NO_LONG_LONG
+# define LONG_LONG_MIN (-9223372036854775807-1)
+# define LONG_LONG_MAX (9223372036854775807)
+# define ULONG_LONG_MAX (18446744073709551615U)
+
+# if defined(__DECC) && (__CRTL_VER >= 80500000) && (__STDC_VERSION__ >= 199901L) /* C99 */
+# define HAVE_ISINF
+# define HAVE_ISNAN
+# endif
+
+# define HAVE_XOS_R_H
#endif /* VAX [else] */
// Compiler specific
#if defined(VAXC) || defined(__VAXC)
-#undef HAVE_SELECT
-#undef HAVE_FCNTL_H
-#undef HAVE_UNISTD_H
-#undef HAVE_SYS_TIME_H
-#undef HAVE_LOCALE_H
-#define BROKEN_LOCALE
-#undef DYNAMIC_ICONV
-#undef HAVE_STRFTIME
+# undef HAVE_SELECT
+# undef HAVE_FCNTL_H
+# undef HAVE_UNISTD_H
+# undef HAVE_SYS_TIME_H
+# undef HAVE_LOCALE_H
+# define BROKEN_LOCALE
+# undef DYNAMIC_ICONV
+# undef HAVE_STRFTIME
#else // DECC
-#define HAVE_SELECT
-#define HAVE_FCNTL_H
-#define HAVE_UNISTD_H 1
-#define HAVE_SYS_TIME_H
-#define HAVE_LOCALE_H
-#define BROKEN_LOCALE
-#undef DYNAMIC_ICONV
-#define HAVE_STRFTIME
+# define HAVE_SELECT
+# define HAVE_FCNTL_H
+# define HAVE_UNISTD_H 1
+# define HAVE_SYS_TIME_H
+# define HAVE_LOCALE_H
+# define BROKEN_LOCALE
+# undef DYNAMIC_ICONV
+# define HAVE_STRFTIME
#endif
#if defined(USE_ICONV)
-#define HAVE_ICONV_H
-#define HAVE_ICONV
+# define HAVE_ICONV_H
+# define HAVE_ICONV
#else
-#undef HAVE_ICONV_H
-#undef HAVE_ICONV
+# undef HAVE_ICONV_H
+# undef HAVE_ICONV
#endif
// GUI support defines
#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK)
-#define X_INCLUDE_GRP_H // To use getgrgid
-#define XUSE_MTSAFE_API
-#define HAVE_X11
-#define WANT_X11
-#ifdef HAVE_XPM
-#define HAVE_X11_XPM_H
-#endif
-#define USE_FONTSET
-#undef X_LOCALE
+# define X_INCLUDE_GRP_H // To use getgrgid
+# define XUSE_MTSAFE_API
+# define HAVE_X11
+# define WANT_X11
+# ifdef HAVE_XPM
+# define HAVE_X11_XPM_H
+# endif
+# define USE_FONTSET
+# undef X_LOCALE
#endif
# define HAVE_MATH_H
#endif
#ifndef __GNUC__
-#define HAVE_STRICMP
-#define HAVE_STRNICMP
+# define HAVE_STRICMP
+# define HAVE_STRNICMP
#endif
#ifndef HAVE_STRFTIME
# define HAVE_STRFTIME // guessed
for (i = 0; i < 8; ++i)
wp->w_border_char[i] = 0;
-# ifdef FEAT_QUICKFIX
+#ifdef FEAT_QUICKFIX
if (type == TYPE_INFO)
{
wp->w_popup_pos = POPPOS_TOPLEFT;
add_border_left_right_padding(wp);
parse_completepopup(wp);
}
-# endif
+#endif
wp->w_want_scrollbar = 1;
wp->w_popup_fixed = 0;
id = (int)tv_get_number(argvars);
if (
-# ifdef FEAT_TERMINAL
+#ifdef FEAT_TERMINAL
// if the popup contains a terminal it will become hidden
curbuf->b_term == NULL &&
-# endif
+#endif
ERROR_IF_ANY_POPUP_WINDOW)
return;
// commands are disallowed then. When a terminal runs in the popup most
// things are allowed. When a terminal is finished it can be closed.
if (WIN_IS_POPUP(curwin)
-# ifdef FEAT_TERMINAL
+#ifdef FEAT_TERMINAL
&& (also_with_term || curbuf->b_term == NULL)
-# endif
+#endif
)
{
error_for_popup_window();
wp->w_popup_close == POPCLOSE_BUTTON ? "button"
: wp->w_popup_close == POPCLOSE_CLICK ? "click" : "none"));
-# if defined(FEAT_TIMERS)
+#if defined(FEAT_TIMERS)
dict_add_number(dict, "time", wp->w_popup_timer != NULL
? (long)wp->w_popup_timer->tr_interval : 0L);
-# endif
+#endif
}
-# if defined(FEAT_TERMINAL)
+#if defined(FEAT_TERMINAL)
/*
* Return TRUE if the current window is running a terminal in a popup window.
* Return FALSE when the job has ended.
}
return FALSE;
}
-# endif
+#endif
/*
* Reset all the "handled_flag" flags in global popup windows and popup windows
redraw_win_later(wp, UPD_VALID);
}
-# if defined(FEAT_QUICKFIX)
+#if defined(FEAT_QUICKFIX)
/*
* If there is a preview window, update the title.
* Used after changing directory.
if (wp != NULL)
popup_set_title(wp);
}
-# endif
+#endif
#endif // FEAT_PROP_POPUP
void
profile_start(proftime_T *tm)
{
-# ifdef MSWIN
+# ifdef MSWIN
QueryPerformanceCounter(tm);
-# else
+# else
PROF_GET_TIME(tm);
-# endif
+# endif
}
/*
{
proftime_T now;
-# ifdef MSWIN
+# ifdef MSWIN
QueryPerformanceCounter(&now);
tm->QuadPart = now.QuadPart - tm->QuadPart;
-# else
+# else
PROF_GET_TIME(&now);
tm->tv_fsec = now.tv_fsec - tm->tv_fsec;
tm->tv_sec = now.tv_sec - tm->tv_sec;
tm->tv_fsec += TV_FSEC_SEC;
--tm->tv_sec;
}
-# endif
+# endif
}
/*
void
profile_sub(proftime_T *tm, proftime_T *tm2)
{
-# ifdef MSWIN
+# ifdef MSWIN
tm->QuadPart -= tm2->QuadPart;
-# else
+# else
tm->tv_fsec -= tm2->tv_fsec;
tm->tv_sec -= tm2->tv_sec;
if (tm->tv_fsec < 0)
tm->tv_fsec += TV_FSEC_SEC;
--tm->tv_sec;
}
-# endif
+# endif
}
/*
{
static char buf[50];
-# ifdef MSWIN
+# ifdef MSWIN
LARGE_INTEGER fr;
QueryPerformanceFrequency(&fr);
sprintf(buf, "%10.6lf", (double)tm->QuadPart / (double)fr.QuadPart);
-# else
+# else
sprintf(buf, PROF_TIME_FORMAT, (long)tm->tv_sec, (long)tm->tv_fsec);
-# endif
+# endif
return buf;
}
float_T
profile_float(proftime_T *tm)
{
-# ifdef MSWIN
+# ifdef MSWIN
LARGE_INTEGER fr;
QueryPerformanceFrequency(&fr);
return (float_T)tm->QuadPart / (float_T)fr.QuadPart;
-# else
+# else
return (float_T)tm->tv_sec + (float_T)tm->tv_fsec / (float_T)TV_FSEC_SEC;
-# endif
+# endif
}
/*
profile_zero(tm);
else
{
-# ifdef MSWIN
+# ifdef MSWIN
LARGE_INTEGER fr;
QueryPerformanceCounter(tm);
QueryPerformanceFrequency(&fr);
tm->QuadPart += (LONGLONG)((double)msec / 1000.0 * (double)fr.QuadPart);
-# else
+# else
varnumber_T fsec; // this should be 64 bit if possible
PROF_GET_TIME(tm);
+ (varnumber_T)msec * (varnumber_T)(TV_FSEC_SEC / 1000);
tm->tv_fsec = fsec % (long)TV_FSEC_SEC;
tm->tv_sec += fsec / (long)TV_FSEC_SEC;
-# endif
+# endif
}
}
{
proftime_T now;
-# ifdef MSWIN
+# ifdef MSWIN
if (tm->QuadPart == 0) // timer was not set
return FALSE;
QueryPerformanceCounter(&now);
return (now.QuadPart > tm->QuadPart);
-# else
+# else
if (tm->tv_sec == 0) // timer was not set
return FALSE;
PROF_GET_TIME(&now);
return (now.tv_sec > tm->tv_sec
|| (now.tv_sec == tm->tv_sec && now.tv_fsec > tm->tv_fsec));
-# endif
+# endif
}
/*
void
profile_zero(proftime_T *tm)
{
-# ifdef MSWIN
+# ifdef MSWIN
tm->QuadPart = 0;
-# else
+# else
tm->tv_fsec = 0;
tm->tv_sec = 0;
-# endif
+# endif
}
# endif // FEAT_PROFILE || FEAT_RELTIME
-#if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_PROFILE)
-# if defined(HAVE_MATH_H)
-# include <math.h>
-# endif
+# if defined(FEAT_SYN_HL) && defined(FEAT_RELTIME) && defined(FEAT_PROFILE)
+# if defined(HAVE_MATH_H)
+# include <math.h>
+# endif
/*
* Divide the time "tm" by "count" and store in "tm2".
profile_zero(tm2);
else
{
-# ifdef MSWIN
+# ifdef MSWIN
tm2->QuadPart = tm->QuadPart / count;
-# else
+# else
double fsec = (tm->tv_sec * (float_T)TV_FSEC_SEC + tm->tv_fsec)
/ count;
tm2->tv_sec = floor(fsec / (float_T)TV_FSEC_SEC);
tm2->tv_fsec = vim_round(fsec - (tm2->tv_sec * (float_T)TV_FSEC_SEC));
-# endif
+# endif
}
}
-#endif
+# endif
# if defined(FEAT_PROFILE)
/*
void
profile_add(proftime_T *tm, proftime_T *tm2)
{
-# ifdef MSWIN
+# ifdef MSWIN
tm->QuadPart += tm2->QuadPart;
-# else
+# else
tm->tv_fsec += tm2->tv_fsec;
tm->tv_sec += tm2->tv_sec;
if (tm->tv_fsec >= TV_FSEC_SEC)
tm->tv_fsec -= TV_FSEC_SEC;
++tm->tv_sec;
}
-# endif
+# endif
}
/*
{
// Check that the result won't be negative. Can happen with recursive
// calls.
-#ifdef MSWIN
+# ifdef MSWIN
if (total->QuadPart <= children->QuadPart)
return;
-#else
+# else
if (total->tv_sec < children->tv_sec
|| (total->tv_sec == children->tv_sec
&& total->tv_fsec <= children->tv_fsec))
return;
-#endif
+# endif
profile_add(self, total);
profile_sub(self, children);
}
static int
profile_equal(proftime_T *tm1, proftime_T *tm2)
{
-# ifdef MSWIN
+# ifdef MSWIN
return (tm1->QuadPart == tm2->QuadPart);
-# else
+# else
return (tm1->tv_fsec == tm2->tv_fsec && tm1->tv_sec == tm2->tv_sec);
-# endif
+# endif
}
/*
int
profile_cmp(const proftime_T *tm1, const proftime_T *tm2)
{
-# ifdef MSWIN
+# ifdef MSWIN
return tm2->QuadPart == tm1->QuadPart ? 0 :
tm2->QuadPart > tm1->QuadPart ? 1 : -1;
-# else
+# else
if (tm1->tv_sec == tm2->tv_sec)
return tm2->tv_fsec == tm1->tv_fsec ? 0 :
tm2->tv_fsec > tm1->tv_fsec ? 1 : -1;
return tm2->tv_sec > tm1->tv_sec ? 1 : -1;
-# endif
+# endif
}
static char_u *profile_fname = NULL;
# include "profiler.pro"
# endif
# include "quickfix.pro"
-#ifdef FEAT_WAYLAND
-# include "wayland.pro"
-#endif
+# ifdef FEAT_WAYLAND
+# include "wayland.pro"
+# endif
# include "regexp.pro"
# include "register.pro"
# include "scriptfile.pro"
}
#if defined(HAVE_POSIX_OPENPT) && !defined(PTY_DONE)
-#define PTY_DONE
+# define PTY_DONE
int
mch_openpty(char **ttyn)
{
#endif
#if defined(OSX) && !defined(PTY_DONE)
-#define PTY_DONE
+# define PTY_DONE
int
mch_openpty(char **ttyn)
{
#if (defined(sequent) || defined(_SEQUENT_)) && defined(HAVE_GETPSEUDOTTY) \
&& !defined(PTY_DONE)
-#define PTY_DONE
+# define PTY_DONE
int
mch_openpty(char **ttyn)
{
if ((f = getpseudotty(&s, &m)) < 0)
return -1;
-#ifdef _SEQUENT_
+# ifdef _SEQUENT_
fvhangup(s);
-#endif
+# endif
vim_strncpy((char_u *)PtyName, (char_u *)m, sizeof(PtyName) - 1);
vim_strncpy((char_u *)TtyName, (char_u *)s, sizeof(TtyName) - 1);
initmaster(f);
#endif
#if defined(MIPS) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE)
-#define PTY_DONE
+# define PTY_DONE
int
mch_openpty(char **ttyn)
{
// NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work!
// Same for Mac OS X Leopard (10.5).
-#define PTY_DONE
+# define PTY_DONE
int
mch_openpty(char **ttyn)
{
#endif
#if defined(_AIX) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE)
-#define PTY_DONE
+# define PTY_DONE
-#ifdef _IBMR2
+# ifdef _IBMR2
static int aixhack = -1;
-#endif
+# endif
int
mch_openpty(char **ttyn)
close(f);
continue;
}
-#if defined(SUN_SYSTEM) && defined(TIOCGPGRP) && !defined(SUNOS3)
+# if defined(SUN_SYSTEM) && defined(TIOCGPGRP) && !defined(SUNOS3)
// Hack to ensure that the slave side of the pty is
// unused. May not work in anything other than SunOS4.1
{
continue;
}
}
-#endif
+# endif
initmaster(f);
*ttyn = TtyName;
return f;
int
mch_isatty(int fd)
{
-# if defined(I_STR) && defined(HAVE_SYS_PTMS_H) && defined(HAVE_SVR4_PTYS) \
+#if defined(I_STR) && defined(HAVE_SYS_PTMS_H) && defined(HAVE_SVR4_PTYS) \
&& defined(SUN_SYSTEM)
// On SunOS, isatty() for /dev/ptmx returns false or sometimes can hang up
// in the inner ioctl(), and therefore first determine whether "fd" is a
// Trick: return 2 in order to advice the caller that "fd" is a master
// device. cf. src/os_unix.c:get_tty_fd()
return 2;
-# endif
+#endif
return isatty(fd);
}
/*
* There is a stack of error lists.
*/
-#define INVALID_QFIDX (-1)
-#define INVALID_QFBUFNR (0)
+# define INVALID_QFIDX (-1)
+# define INVALID_QFBUFNR (0)
/*
* Quickfix list type.
static qf_info_T *ql_info; // points to ql_info_actual if memory allocation is successful.
static int_u last_qf_id = 0; // Last used quickfix list id
-#define FMT_PATTERNS 14 // maximum number of % recognized
+# define FMT_PATTERNS 14 // maximum number of % recognized
/*
* Structure used to hold the info of one part of 'errorformat'
static int entry_is_closer_to_target(qfline_T *entry, qfline_T *other_entry, int target_fnum, int target_lnum, int target_col);
// Quickfix window check helper macro
-#define IS_QF_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref == NULL)
+# define IS_QF_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref == NULL)
// Location list window check helper macro
-#define IS_LL_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref != NULL)
+# define IS_LL_WINDOW(wp) (bt_quickfix((wp)->w_buffer) && (wp)->w_llist_ref != NULL)
// Quickfix and location list stack check helper macros
-#define IS_QF_STACK(qi) ((qi)->qfl_type == QFLT_QUICKFIX)
-#define IS_LL_STACK(qi) ((qi)->qfl_type == QFLT_LOCATION)
-#define IS_QF_LIST(qfl) ((qfl)->qfl_type == QFLT_QUICKFIX)
-#define IS_LL_LIST(qfl) ((qfl)->qfl_type == QFLT_LOCATION)
+# define IS_QF_STACK(qi) ((qi)->qfl_type == QFLT_QUICKFIX)
+# define IS_LL_STACK(qi) ((qi)->qfl_type == QFLT_LOCATION)
+# define IS_QF_LIST(qfl) ((qfl)->qfl_type == QFLT_QUICKFIX)
+# define IS_LL_LIST(qfl) ((qfl)->qfl_type == QFLT_LOCATION)
/*
* Return location list for window 'wp'
* For location list window, return the referenced location list
*/
-#define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? (wp)->w_llist_ref : (wp)->w_llist)
+# define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? (wp)->w_llist_ref : (wp)->w_llist)
// Macro to loop through all the items in a quickfix list
// Quickfix item index starts from 1, so i below starts at 1
-#define FOR_ALL_QFL_ITEMS(qfl, qfp, i) \
+# define FOR_ALL_QFL_ITEMS(qfl, qfp, i) \
for ((i) = 1, (qfp) = (qfl)->qf_start; \
!got_int && (i) <= (qfl)->qf_count && (qfp) != NULL; \
++(i), (qfp) = (qfp)->qf_next)
/*
* Maximum number of bytes allowed per line while reading a errorfile.
*/
-#define LINE_MAXLEN 4096
+# define LINE_MAXLEN 4096
/*
* Patterns used. Keep in sync with qf_parse_fmt[].
{'c', "\\d\\+"}, // 5
{'k', "\\d\\+"}, // 6
{'t', "."}, // 7
-#define FMT_PATTERN_M 8
+# define FMT_PATTERN_M 8
{'m', ".\\+"}, // 8
-#define FMT_PATTERN_R 9
+# define FMT_PATTERN_R 9
{'r', ".*"}, // 9
{'p', "[- .]*"}, // 10
{'v', "\\d\\+"}, // 11
efminfo->addr[idx] = (char_u)++round;
*regpat++ = '\\';
*regpat++ = '(';
-#ifdef BACKSLASH_IN_FILENAME
+# ifdef BACKSLASH_IN_FILENAME
if (*efmpat == 'f')
{
// Also match "c:" in the file name, even when
STRCPY(regpat, "\\%(\\a:\\)\\=");
regpat += 10;
}
-#endif
+# endif
if (*efmpat == 'f' && efmpat[1] != NUL)
{
if (efmpat[1] != '\\' && efmpat[1] != '%')
sz = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2);
for (i = FMT_PATTERNS; i > 0; )
sz += (int)STRLEN(fmt_pat[--i].pattern);
-#ifdef BACKSLASH_IN_FILENAME
+# ifdef BACKSLASH_IN_FILENAME
sz += 12; // "%f" can become twelve chars longer (see efm_to_regpat)
-#else
+# else
sz += 2; // "%f" can become two chars longer
-#endif
+# endif
return sz;
}
if (state->linelen > 0 && state->linebuf[state->linelen - 1] == '\n')
{
state->linebuf[state->linelen - 1] = NUL;
-#ifdef USE_CRNL
+# ifdef USE_CRNL
if (state->linelen > 1 && state->linebuf[state->linelen - 2] == '\r')
state->linebuf[state->linelen - 2] = NUL;
-#endif
+# endif
}
remove_bom(state->linebuf);
vim_free(q);
}
}
-#ifdef ABORT_ON_INTERNAL_ERROR
+# ifdef ABORT_ON_INTERNAL_ERROR
if (quickfix_busy < 0)
{
emsg("quickfix_busy has become negative");
abort();
}
-#endif
+# endif
}
-#if defined(EXITFREE)
+# if defined(EXITFREE)
void
check_quickfix_busy(void)
{
if (quickfix_busy != 0)
{
semsg("quickfix_busy not zero on exit: %ld", (long)quickfix_busy);
-# ifdef ABORT_ON_INTERNAL_ERROR
+# ifdef ABORT_ON_INTERNAL_ERROR
abort();
-# endif
+# endif
}
}
-#endif
+# endif
/*
* Add an entry to the end of the list of errors.
if (fname == NULL || *fname == NUL) // no file name
return 0;
-#ifdef VMS
+# ifdef VMS
vms_remove_version(fname);
-#endif
-#ifdef BACKSLASH_IN_FILENAME
+# endif
+# ifdef BACKSLASH_IN_FILENAME
if (directory != NULL)
slash_adjust(directory);
slash_adjust(fname);
-#endif
+# endif
if (directory != NULL && !vim_isAbsName(fname)
&& (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
{
qf_jump_goto_line(qf_ptr->qf_lnum, qf_ptr->qf_col, qf_ptr->qf_viscol,
qf_ptr->qf_pattern);
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
if ((fdo_flags & FDO_QUICKFIX) && openfold)
foldOpenCursor();
-#endif
+# endif
if (print_message)
qf_jump_print_msg(qi, qf_index, qf_ptr, old_curbuf, old_lnum);
0L, (char_u *)"quickfix", OPT_LOCAL);
set_option_value_give_err((char_u *)"bh", 0L, (char_u *)"hide", OPT_LOCAL);
RESET_BINDING(curwin);
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
curwin->w_p_diff = FALSE;
-#endif
-#ifdef FEAT_FOLDING
+# endif
+# ifdef FEAT_FOLDING
set_option_value_give_err((char_u *)"fdm", 0L, (char_u *)"manual",
OPT_LOCAL);
-#endif
+# endif
}
/*
height = QF_WINHEIGHT;
reset_VIsual_and_resel(); // stop Visual mode
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
need_mouse_correct = TRUE;
-#endif
+# endif
// Find an existing quickfix window, or open a new one.
if (cmdmod.cmod_tab == 0)
char_u *name;
static int start = -1;
static int off = 0;
-#ifdef HAVE_LSTAT
+# ifdef HAVE_LSTAT
stat_T sb;
-#endif
+# endif
if (*p_mef == NUL)
{
sprintf((char *)name + (p - p_mef), "%d%d", start, off);
STRCAT(name, p + 2);
if (mch_getperm(name) < 0
-#ifdef HAVE_LSTAT
+# ifdef HAVE_LSTAT
// Don't accept a symbolic link, it's a security risk.
&& mch_lstat((char *)name, &sb) < 0
-#endif
+# endif
)
break;
vim_free(name);
if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
curbuf->b_fname, TRUE, curbuf))
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (aborting())
return;
-#endif
+# endif
}
enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
// let the shell know if we are redirecting output or not
do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0);
-#ifdef AMIGA
+# ifdef AMIGA
out_flush();
// read window status report and redraw before message
(void)char_avail();
-#endif
+# endif
incr_quickfix_busy();
if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
NULL, FALSE, curbuf))
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (aborting())
return;
-#endif
+# endif
}
enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
-#ifdef FEAT_BROWSE
+# ifdef FEAT_BROWSE
if (cmdmod.cmod_flags & CMOD_BROWSE)
{
char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg,
vim_free(browse_file);
}
else
-#endif
+# endif
if (*eap->arg != NUL)
set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0);
char_u *dirname_now)
{
int save_mls;
-#if defined(FEAT_SYN_HL)
+# if defined(FEAT_SYN_HL)
char_u *save_ei = NULL;
-#endif
+# endif
buf_T *buf;
-#if defined(FEAT_SYN_HL)
+# if defined(FEAT_SYN_HL)
// Don't do Filetype autocommands to avoid loading syntax and
// indent scripts, a great speed improvement.
save_ei = au_event_disable(",Filetype");
-#endif
+# endif
// Don't use modelines here, it's useless.
save_mls = p_mls;
p_mls = 0;
buf = load_dummy_buffer(fname, dirname_start, dirname_now);
p_mls = save_mls;
-#if defined(FEAT_SYN_HL)
+# if defined(FEAT_SYN_HL)
au_event_restore(save_ei);
-#endif
+# endif
return buf;
}
aucmd_prepbuf(&aco, buf);
if (curbuf == buf)
{
-#if defined(FEAT_SYN_HL)
+# if defined(FEAT_SYN_HL)
apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
buf->b_fname, TRUE, buf);
-#endif
+# endif
do_modelines(OPT_NOWIN);
aucmd_restbuf(&aco);
}
if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
curbuf->b_fname, TRUE, curbuf))
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (aborting())
return;
-#endif
+# endif
}
qi = qf_cmd_get_or_alloc_stack(eap, &wp);
// may have messed up things, need to redraw and recompute folds.
if (redraw_for_dummy)
{
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
foldUpdateAll(curwin);
-#else
+# else
redraw_later(UPD_NOT_VALID);
-#endif
+# endif
}
theend:
if (curbuf != buf && buf->b_nwindows == 0) // safety check
{
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
cleanup_T cs;
// Reset the error/interrupt/exception state here so that aborting()
// returns FALSE when wiping out the buffer. Otherwise it doesn't
// work when got_int is set.
enter_cleanup(&cs);
-#endif
+# endif
wipe_buffer(buf, TRUE);
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
// Restore the error/interrupt/exception state if not discarded by a
// new aborting error, interrupt, or uncaught exception.
leave_cleanup(&cs);
-#endif
+# endif
if (dirname_start != NULL)
// When autocommands/'autochdir' option changed directory: go back.
restore_start_dir(dirname_start);
restore_start_dir(dirname_start);
}
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
/*
* Copy the specified quickfix entry items into a new dict and append the dict
* to 'list'. Returns OK on success.
return abort;
}
-#endif
+# endif
/*
* Return the autocmd name for the :cbuffer Ex commands
if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
curbuf->b_fname, TRUE, curbuf))
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (aborting())
return;
-#endif
+# endif
}
// Must come after autocommands.
decr_quickfix_busy();
}
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
/*
* Return the autocmd name for the :cexpr Ex commands.
*/
(void)cexpr_core(eap, tv);
free_tv(tv);
}
-#endif
+# endif
/*
* Get the location list for ":lhelpgrep"
char_u *dirname,
regmatch_T *p_regmatch,
vimconv_T *p_vc
-#ifdef FEAT_MULTI_LANG
+# ifdef FEAT_MULTI_LANG
, char_u *lang
-#endif
+# endif
)
{
int fcount;
{
for (fi = 0; fi < fcount && !got_int; ++fi)
{
-#ifdef FEAT_MULTI_LANG
+# ifdef FEAT_MULTI_LANG
// Skip files for a different language.
if (lang != NULL
&& STRNICMP(lang, fnames[fi]
&& STRNICMP("txt", fnames[fi]
+ STRLEN(fnames[fi]) - 3, 3) == 0))
continue;
-#endif
+# endif
hgr_search_file(qfl, fnames[fi], p_vc, p_regmatch);
}
copy_option_part(&p, NameBuff, MAXPATHL, ",");
hgr_search_files_in_dir(qfl, NameBuff, p_regmatch, &vc
-#ifdef FEAT_MULTI_LANG
+# ifdef FEAT_MULTI_LANG
, lang
-#endif
+# endif
);
}
if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
curbuf->b_fname, TRUE, curbuf))
{
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (aborting())
return;
-#endif
+# endif
}
if (is_loclist_cmd(eap->cmdidx))
incr_quickfix_busy();
-#ifdef FEAT_MULTI_LANG
+# ifdef FEAT_MULTI_LANG
// Check for a specified language
lang = check_help_lang(eap->arg);
-#endif
+# endif
regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
regmatch.rm_ic = FALSE;
if (regmatch.regprog != NULL)
char_u *end = NULL;
FILE *f;
-#ifdef BT_REGEXP_LOG
+# ifdef BT_REGEXP_LOG
f = fopen("bt_regexp_log.log", "a");
-#else
+# else
f = stdout;
-#endif
+# endif
if (f == NULL)
return;
fprintf(f, "-------------------------------------\n\r\nregcomp(%s):\r\n", pattern);
fprintf(f, "must have \"%s\"", r->regmust);
fprintf(f, "\r\n");
-#ifdef BT_REGEXP_LOG
+# ifdef BT_REGEXP_LOG
fclose(f);
-#endif
+# endif
}
#endif // BT_REGEXP_DUMP
case NCLOSE:
p = "NCLOSE";
break;
-#ifdef FEAT_SYN_HL
+# ifdef FEAT_SYN_HL
case ZOPEN + 1:
case ZOPEN + 2:
case ZOPEN + 3:
buflen += sprintf(buf + buflen, "ZREF%d", OP(op) - ZREF);
p = NULL;
break;
-#endif
+# endif
case STAR:
p = "STAR";
break;
static int
nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl)
{
-# define CLASS_not 0x80
-# define CLASS_af 0x40
-# define CLASS_AF 0x20
-# define CLASS_az 0x10
-# define CLASS_AZ 0x08
-# define CLASS_o7 0x04
-# define CLASS_o9 0x02
-# define CLASS_underscore 0x01
+#define CLASS_not 0x80
+#define CLASS_af 0x40
+#define CLASS_AF 0x20
+#define CLASS_az 0x10
+#define CLASS_AZ 0x08
+#define CLASS_o7 0x04
+#define CLASS_o9 0x02
+#define CLASS_underscore 0x01
int newl = FALSE;
char_u *p;
case NFA_BACKREF7: STRCPY(code, "NFA_BACKREF7"); break;
case NFA_BACKREF8: STRCPY(code, "NFA_BACKREF8"); break;
case NFA_BACKREF9: STRCPY(code, "NFA_BACKREF9"); break;
-#ifdef FEAT_SYN_HL
+# ifdef FEAT_SYN_HL
case NFA_ZREF1: STRCPY(code, "NFA_ZREF1"); break;
case NFA_ZREF2: STRCPY(code, "NFA_ZREF2"); break;
case NFA_ZREF3: STRCPY(code, "NFA_ZREF3"); break;
case NFA_ZREF7: STRCPY(code, "NFA_ZREF7"); break;
case NFA_ZREF8: STRCPY(code, "NFA_ZREF8"); break;
case NFA_ZREF9: STRCPY(code, "NFA_ZREF9"); break;
-#endif
+# endif
case NFA_SKIP: STRCPY(code, "NFA_SKIP"); break;
case NFA_PREV_ATOM_NO_WIDTH:
STRCPY(code, "NFA_MCLOSE(x)");
code[11] = c - NFA_MCLOSE + '0';
break;
-#ifdef FEAT_SYN_HL
+# ifdef FEAT_SYN_HL
case NFA_ZOPEN:
case NFA_ZOPEN1:
case NFA_ZOPEN2:
STRCPY(code, "NFA_ZCLOSE(x)");
code[11] = c - NFA_ZCLOSE + '0';
break;
-#endif
+# endif
case NFA_EOL: STRCPY(code, "NFA_EOL "); break;
case NFA_BOL: STRCPY(code, "NFA_BOL "); break;
case NFA_EOW: STRCPY(code, "NFA_EOW "); break;
}
-#ifdef ENABLE_LOG
+# ifdef ENABLE_LOG
static FILE *log_fd;
static char_u e_log_open_failed[] = N_("Could not open temporary log file for writing, displaying on stderr... ");
fclose(debugf);
}
-#endif // ENABLE_LOG
+# endif // ENABLE_LOG
#endif // DEBUG
/*
++rex.nfa_listid;
if (prog->re_engine == AUTOMATIC_ENGINE
&& (rex.nfa_listid >= NFA_MAX_STATES
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
|| nfa_fail_for_testing
-# endif
+#endif
))
{
// too many states, retry with old engine
// When clipboard is not available, use register 0 instead of '+'
else if (clip_plus.available && regname == '+')
{
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
// We want to use the actual + register, since PLUS_REGISTER may be
// pointing to STAR_REGISTER.
if (clipmethod == CLIPMETHOD_PROVIDER)
i = REAL_PLUS_REGISTER;
else
-#endif
+# endif
i = PLUS_REGISTER;
ret = TRUE;
}
#ifdef FEAT_CLIPBOARD_PROVIDER
call_clip_provider_request(regname);
#endif
-# ifdef FEAT_CLIPBOARD
+#ifdef FEAT_CLIPBOARD
if (clipmethod != CLIPMETHOD_PROVIDER)
regname = may_get_selection(regname);
-# endif
+#endif
if (regname != NUL && !valid_yank_reg(regname, FALSE))
return MAUTO;
if (regname != NUL && !valid_yank_reg(regname, FALSE))
return NULL;
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
call_clip_provider_request(regname);
-#endif
+# endif
# ifdef FEAT_CLIPBOARD
if (clipmethod != CLIPMETHOD_PROVIDER)
regname = may_get_selection(regname);
finish_write_reg(name, old_y_previous, old_y_current);
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
call_clip_provider_set(name);
-#endif
+# endif
}
void
finish_write_reg(name, old_y_previous, old_y_current);
-#ifdef FEAT_CLIPBOARD_PROVIDER
+# ifdef FEAT_CLIPBOARD_PROVIDER
call_clip_provider_set(name);
-#endif
+# endif
}
#endif // FEAT_EVAL
if (endcol > Columns)
endcol = Columns;
-# ifdef FEAT_CLIPBOARD
+#ifdef FEAT_CLIPBOARD
clip_may_clear_selection(row, row);
-# endif
+#endif
off_from = (unsigned)(current_ScreenLine - ScreenLines);
off_to = LineOffset[row] + coloff;
curattr = attr;
else if (hltab[n].userhl < 0)
curattr = syn_id2attr(-hltab[n].userhl);
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
else if (wp != NULL && wp != curwin && bt_terminal(wp->w_buffer)
&& wp->w_status_height != 0)
curattr = highlight_stltermnc[hltab[n].userhl - 1];
else if (wp != NULL && bt_terminal(wp->w_buffer)
&& wp->w_status_height != 0)
curattr = highlight_stlterm[hltab[n].userhl - 1];
-#endif
+# endif
else if (wp != NULL && wp != curwin && wp->w_status_height != 0)
curattr = highlight_stlnc[hltab[n].userhl - 1];
else
int col;
int width;
-# ifdef FEAT_CLIPBOARD
+#ifdef FEAT_CLIPBOARD
clip_may_clear_selection(row, end - 1);
-# endif
+#endif
if (wp == NULL)
{
static spat_T saved_spats[ARRAY_LENGTH(spats)];
static char_u *saved_mr_pattern = NULL;
static size_t saved_mr_patternlen = 0;
-# ifdef FEAT_SEARCH_EXTRA
+#ifdef FEAT_SEARCH_EXTRA
static int saved_spats_last_idx = 0;
static int saved_spats_no_hlsearch = 0;
-# endif
+#endif
// allocated copy of pattern used by search_regcomp()
static char_u *mr_pattern = NULL;
spats[idx].magic = magic;
spats[idx].no_scs = FALSE;
spats[idx].off.dir = '/';
-#if defined(FEAT_EVAL)
+# if defined(FEAT_EVAL)
set_vv_searchforward();
-#endif
+# endif
spats[idx].off.line = FALSE;
spats[idx].off.end = FALSE;
spats[idx].off.off = 0;
break;
matchpos = regmatch.startpos[0];
endpos = regmatch.endpos[0];
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
submatch = first_submatch(®match);
-# endif
+#endif
// Need to get the line pointer again, a
// multi-line search may have made it invalid.
match_ok = TRUE;
matchpos = regmatch.startpos[0];
endpos = regmatch.endpos[0];
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
submatch = first_submatch(®match);
-# endif
+#endif
}
else
break;
char_u *already = NULL;
char_u *startp = NULL;
char_u *inc_opt = NULL;
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
win_T *curwin_save = NULL;
-#endif
+# endif
regmatch.regprog = NULL;
incl_regmatch.regprog = NULL;
{
found = TRUE;
if (depth == -1 && lnum == curwin->w_cursor.lnum
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
&& g_do_tagpreview == 0
-#endif
+# endif
)
emsg(_(e_match_is_on_current_line));
else if (action == ACTION_SHOW)
}
else
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
need_mouse_correct = TRUE;
-#endif
-#if defined(FEAT_QUICKFIX)
+# endif
+# if defined(FEAT_QUICKFIX)
// ":psearch" uses the preview window
if (g_do_tagpreview != 0)
{
curwin_save = curwin;
prepare_tagpreview(TRUE, TRUE, FALSE);
}
-#endif
+# endif
if (action == ACTION_SPLIT)
{
if (win_split(0, 0) == FAIL)
if (depth == -1)
{
// match in current file
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
{
if (!win_valid(curwin_save))
break; // failed to jump to file
}
else
-#endif
+# endif
setpcmark();
curwin->w_cursor.lnum = lnum;
check_cursor();
curwin->w_set_curswant = TRUE;
}
-#if defined(FEAT_QUICKFIX)
+# if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0
&& curwin != curwin_save && win_valid(curwin_save))
{
redraw_later(UPD_VALID);
win_enter(curwin_save, TRUE);
}
-# ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
else if (WIN_IS_POPUP(curwin))
// can't keep focus in popup window
win_enter(firstwin, TRUE);
+# endif
# endif
-#endif
break;
}
exit_matched:
}
save_last_search_pattern();
-#ifdef FEAT_SEARCH_EXTRA
+# ifdef FEAT_SEARCH_EXTRA
save_incsearch_state();
-#endif
+# endif
if (pattern != NULL)
{
if (*pattern == NUL)
the_end:
restore_last_search_pattern();
-#ifdef FEAT_SEARCH_EXTRA
+# ifdef FEAT_SEARCH_EXTRA
restore_incsearch_state();
-#endif
+# endif
}
#endif
if (buf->b_sfname != NULL
&& flagp == &ssop_flags
&& (ssop_flags & (SSOP_CURDIR | SSOP_SESDIR))
-#ifdef FEAT_AUTOCHDIR
+# ifdef FEAT_AUTOCHDIR
&& !p_acd
-#endif
+# endif
&& !did_lcd)
name = buf->b_sfname;
else
static int
ses_do_win(win_T *wp)
{
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
if (bt_terminal(wp->w_buffer))
return !term_is_finished(wp->w_buffer)
&& (ssop_flags & SSOP_TERMINAL)
&& term_should_restore(wp->w_buffer);
-#endif
+# endif
if (wp->w_buffer->b_fname == NULL
// When 'buftype' is "nofile" can't restore the window contents.
|| bt_nofilename(wp->w_buffer))
// No file in this buffer, just make it empty.
if (put_line(fd, "enew") == FAIL)
return FAIL;
-#ifdef FEAT_QUICKFIX
+# ifdef FEAT_QUICKFIX
if (wp->w_buffer->b_ffname != NULL)
{
// The buffer does have a name, but it's not a file name.
|| ses_fname(fd, wp->w_buffer, flagp, TRUE) == FAIL)
return FAIL;
}
-#endif
+# endif
do_cursor = FALSE;
}
}
if (*flagp & (SSOP_OPTIONS | SSOP_LOCALOPTIONS))
f = makeset(fd, OPT_LOCAL,
flagp == &vop_flags || !(*flagp & SSOP_OPTIONS));
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
else if (*flagp & SSOP_FOLDS)
f = makefoldset(fd);
-#endif
+# endif
else
f = OK;
curwin = save_curwin;
if (f == FAIL)
return FAIL;
-#ifdef FEAT_FOLDING
+# ifdef FEAT_FOLDING
// Save Folds when 'buftype' is empty and for help files.
if ((*flagp & SSOP_FOLDS)
&& wp->w_buffer->b_ffname != NULL
if (put_folds(fd, wp) == FAIL)
return FAIL;
}
-#endif
+# endif
// Set the cursor after creating folds, since that moves the cursor.
if (do_cursor)
return OK;
}
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
static int
store_session_globals(FILE *fd)
{
}
return OK;
}
-#endif
+# endif
/*
* Write openfile commands for the current buffers to an .exrc file.
int next_arg_idx = 0;
int ret = FAIL;
tabpage_T *tp;
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
hashtab_T terminal_bufs;
hash_init(&terminal_bufs);
-#endif
+# endif
if (ssop_flags & SSOP_BUFFERS)
only_save_windows = FALSE; // Save ALL buffers
// Begin by setting the this_session variable, and then other
// sessionable variables.
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (put_line(fd, "let v:this_session=expand(\"<sfile>:p\")") == FAIL)
goto fail;
if (ssop_flags & SSOP_GLOBALS)
if (store_session_globals(fd) == FAIL)
goto fail;
-#endif
+# endif
// Close all windows and tabs but one.
if (put_line(fd, "silent only") == FAIL)
goto fail;
}
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.in_use && (ssop_flags & SSOP_WINPOS))
{
int x, y;
goto fail;
}
}
-#endif
+# endif
// When there are two or more tabpages and 'showtabline' is 1 the tabline
// will be displayed when creating the next tab. That resizes the windows
continue;
if (put_view(fd, wp, tp, wp != edited_win, &ssop_flags,
cur_arg_idx,
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
&terminal_bufs
-#else
+# else
NULL
-#endif
+# endif
) == FAIL)
goto fail;
if (nr > 1 && put_line(fd, "wincmd w") == FAIL)
ret = OK;
fail:
-#ifdef FEAT_TERMINAL
+# ifdef FEAT_TERMINAL
hash_clear_all(&terminal_bufs, 0);
-#endif
+# endif
return ret;
}
else if (vim_ispathsep(*p))
{
*s++ = '=';
-#if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) || defined(VMS)
+# if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) || defined(VMS)
if (*p == ':')
*s++ = '-';
else
-#endif
+# endif
*s++ = '+';
}
else
if (put_line(fd, "let &g:so = s:so_save | let &g:siso = s:siso_save")
== FAIL)
failed = TRUE;
-#ifdef FEAT_SEARCH_EXTRA
+# ifdef FEAT_SEARCH_EXTRA
if (no_hlsearch && put_line(fd, "nohlsearch") == FAIL)
failed = TRUE;
-#endif
+# endif
if (put_line(fd, "doautoall SessionLoadPost") == FAIL)
failed = TRUE;
if (eap->cmdidx == CMD_mksession)
#if defined(FEAT_CRYPT) || defined(FEAT_PERSISTENT_UNDO)
-#define GET_UINT32(n, b, i) \
+# define GET_UINT32(n, b, i) \
{ \
(n) = ( (UINT32_T)(b)[(i) ] << 24) \
| ( (UINT32_T)(b)[(i) + 1] << 16) \
| ( (UINT32_T)(b)[(i) + 3] ); \
}
-#define PUT_UINT32(n,b,i) \
+# define PUT_UINT32(n,b,i) \
{ \
(b)[(i) ] = (char_u)((n) >> 24); \
(b)[(i) + 1] = (char_u)((n) >> 16); \
GET_UINT32(W[14], data, 56);
GET_UINT32(W[15], data, 60);
-#define SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
-#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
+# define SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
+# define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
-#define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
-#define S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
+# define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
+# define S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
-#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
-#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
+# define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
+# define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
-#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
-#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
+# define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
+# define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
-#define R(t) \
+# define R(t) \
( \
W[t] = S1(W[(t) - 2]) + W[(t) - 7] + \
S0(W[(t) - 15]) + W[(t) - 16] \
)
-#define P(a,b,c,d,e,f,g,h,x,K) \
+# define P(a,b,c,d,e,f,g,h,x,K) \
{ \
temp1 = (h) + S3(e) + F1(e, f, g) + (K) + (x); \
temp2 = S2(a) + F0(a, b, c); \
SPELL_EXTERN int did_set_spelltab;
// Values for "what" argument of spell_add_word()
-#define SPELL_ADD_GOOD 0
-#define SPELL_ADD_BAD 1
-#define SPELL_ADD_RARE 2
+# define SPELL_ADD_GOOD 0
+# define SPELL_ADD_BAD 1
+# define SPELL_ADD_RARE 2
typedef struct wordcount_S
{
char_u wc_word[1]; // word, actually longer
} wordcount_T;
-#define WC_KEY_OFF offsetof(wordcount_T, wc_word)
-#define HI2WC(hi) ((wordcount_T *)((hi)->hi_key - WC_KEY_OFF))
-#define MAXWORDCOUNT 0xffff
+# define WC_KEY_OFF offsetof(wordcount_T, wc_word)
+# define HI2WC(hi) ((wordcount_T *)((hi)->hi_key - WC_KEY_OFF))
+# define MAXWORDCOUNT 0xffff
// Remember what "z?" replaced.
SPELL_EXTERN char_u *repl_from SPELL_INIT(= NULL);
* compressing the tree.
* Based on code from Olaf Seibert.
*/
-#define PRINTLINESIZE 1000
-#define PRINTWIDTH 6
+# define PRINTLINESIZE 1000
+# define PRINTWIDTH 6
-#define PRINTSOME(l, depth, fmt, a1, a2) vim_snprintf(l + depth * PRINTWIDTH, \
+# define PRINTSOME(l, depth, fmt, a1, a2) vim_snprintf(l + depth * PRINTWIDTH, \
PRINTLINESIZE - PRINTWIDTH * depth, fmt, a1, a2)
static char line1[PRINTLINESIZE];
int fish_like;
char_u *shname;
int powershell;
-# ifdef MSWIN
+#ifdef MSWIN
int double_quotes;
-# endif
+#endif
// Only csh and similar shells expand '!' within single quotes. For sh and
// the like we must not put a backslash before it, it will be taken
// PowerShell uses its own version for quoting single quotes
shname = gettail(p_sh);
powershell = strstr((char *)shname, "pwsh") != NULL;
-# ifdef MSWIN
+#ifdef MSWIN
powershell = powershell || strstr((char *)shname, "powershell") != NULL;
// PowerShell only accepts single quotes so override shellslash.
double_quotes = !powershell && !p_ssl;
-# endif
+#endif
// First count the number of extra bytes required.
length = (unsigned)STRLEN(string) + 3; // two quotes and a trailing NUL
for (p = string; *p != NUL; MB_PTR_ADV(p))
{
-# ifdef MSWIN
+#ifdef MSWIN
if (double_quotes)
{
if (*p == '"')
++length; // " -> ""
}
else
-# endif
+#endif
if (*p == '\'')
{
if (powershell)
d = escaped_string;
// add opening quote
-# ifdef MSWIN
+#ifdef MSWIN
if (double_quotes)
*d++ = '"';
else
-# endif
+#endif
*d++ = '\'';
for (p = string; *p != NUL; )
{
-# ifdef MSWIN
+#ifdef MSWIN
if (double_quotes)
{
if (*p == '"')
}
}
else
-# endif
+#endif
if (*p == '\'')
{
if (powershell)
}
// add terminating quote and finish with a NUL
-# ifdef MSWIN
+#ifdef MSWIN
if (double_quotes)
*d++ = '"';
else
-# endif
+#endif
*d++ = '\'';
*d = NUL;
}
semsg(_(e_out_of_memory_allocating_nr_bytes), arglen);
}
-#define MAX_ALLOWED_STRING_WIDTH 1048576 // 1 MiB
+# define MAX_ALLOWED_STRING_WIDTH 1048576 // 1 MiB
static int
get_unsigned_int(
int any_arg = 0;
int arg_idx;
-#define CHECK_POS_ARG do { \
+# define CHECK_POS_ARG do { \
if (any_pos && any_arg) \
{ \
semsg(_( e_cannot_mix_positional_and_non_positional_str), fmt); \
# define w_p_briopt w_onebuf_opt.wo_briopt // 'breakindentopt'
#endif
char_u *wo_wcr;
-# define w_p_wcr w_onebuf_opt.wo_wcr // 'wincolor'
+#define w_p_wcr w_onebuf_opt.wo_wcr // 'wincolor'
#ifdef FEAT_DIFF
int wo_diff;
# define w_p_diff w_onebuf_opt.wo_diff // 'diff'
#endif
char_u *wo_eiw;
-# define w_p_eiw w_onebuf_opt.wo_eiw // 'eventignorewin'
+#define w_p_eiw w_onebuf_opt.wo_eiw // 'eventignorewin'
#ifdef FEAT_FOLDING
long wo_fdc;
# define w_p_fdc w_onebuf_opt.wo_fdc // 'foldcolumn'
# define w_p_fdn w_onebuf_opt.wo_fdn // 'foldnestmax'
# ifdef FEAT_EVAL
char_u *wo_fde;
-# define w_p_fde w_onebuf_opt.wo_fde // 'foldexpr'
+# define w_p_fde w_onebuf_opt.wo_fde // 'foldexpr'
char_u *wo_fdt;
# define w_p_fdt w_onebuf_opt.wo_fdt // 'foldtext'
# endif
int wo_wfb;
#define w_p_wfb w_onebuf_opt.wo_wfb // 'winfixbuf'
int wo_wfh;
-# define w_p_wfh w_onebuf_opt.wo_wfh // 'winfixheight'
+#define w_p_wfh w_onebuf_opt.wo_wfh // 'winfixheight'
int wo_wfw;
-# define w_p_wfw w_onebuf_opt.wo_wfw // 'winfixwidth'
+#define w_p_wfw w_onebuf_opt.wo_wfw // 'winfixwidth'
#if defined(FEAT_QUICKFIX)
int wo_pvw;
# define w_p_pvw w_onebuf_opt.wo_pvw // 'previewwindow'
#endif
#ifdef FEAT_LINEBREAK
char_u *wo_sbr;
-#define w_p_sbr w_onebuf_opt.wo_sbr // 'showbreak'
+# define w_p_sbr w_onebuf_opt.wo_sbr // 'showbreak'
#endif
#ifdef FEAT_STL_OPT
char_u *wo_stl;
-#define w_p_stl w_onebuf_opt.wo_stl // 'statusline'
+# define w_p_stl w_onebuf_opt.wo_stl // 'statusline'
#endif
int wo_scb;
#define w_p_scb w_onebuf_opt.wo_scb // 'scrollbind'
# define w_p_scl w_onebuf_opt.wo_scl // 'signcolumn'
#endif
long wo_siso;
-# define w_p_siso w_onebuf_opt.wo_siso // 'sidescrolloff' local value
+#define w_p_siso w_onebuf_opt.wo_siso // 'sidescrolloff' local value
long wo_so;
-# define w_p_so w_onebuf_opt.wo_so // 'scrolloff' local value
+#define w_p_so w_onebuf_opt.wo_so // 'scrolloff' local value
#ifdef FEAT_TERMINAL
char_u *wo_twk;
# define w_p_twk w_onebuf_opt.wo_twk // 'termwinkey'
expand_T *xpc; // struct being used for expansion, xp_pattern
// may point into cmdbuff
int xp_context; // type of expansion
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
char_u *xp_arg; // user-defined expansion arg
int input_fn; // when TRUE Invoked for input() function
-# endif
+#endif
} cmdline_info_T;
/*
#if defined(FEAT_SIGNS)
// Macros to get the sign group structure from the group name
-#define SGN_KEY_OFF offsetof(signgroup_T, sg_name)
-#define HI2SG(hi) ((signgroup_T *)((hi)->hi_key - SGN_KEY_OFF))
+# define SGN_KEY_OFF offsetof(signgroup_T, sg_name)
+# define HI2SG(hi) ((signgroup_T *)((hi)->hi_key - SGN_KEY_OFF))
// Default sign priority for highlighting
-#define SIGN_DEF_PRIO 10
+# define SIGN_DEF_PRIO 10
#endif
eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent"
char cs_lflags; // loop flags: CSL_ flags
} cstack_T;
-# define cs_rettv cs_pend.csp_rv
-# define cs_exception cs_pend.csp_ex
+#define cs_rettv cs_pend.csp_rv
+#define cs_exception cs_pend.csp_ex
// There is no CSF_IF, the lack of CSF_WHILE, CSF_FOR and CSF_TRY means ":if"
// was used.
-# define CSF_TRUE 0x0001 // condition was TRUE
-# define CSF_ACTIVE 0x0002 // current state is active
-# define CSF_ELSE 0x0004 // ":else" has been passed
-# define CSF_WHILE 0x0008 // is a ":while"
-# define CSF_FOR 0x0010 // is a ":for"
-# define CSF_BLOCK 0x0020 // is a "{" block
-
-# define CSF_TRY 0x0100 // is a ":try"
-# define CSF_FINALLY 0x0200 // ":finally" has been passed
-# define CSF_CATCH 0x0400 // ":catch" has been seen
-# define CSF_THROWN 0x0800 // exception thrown to this try conditional
-# define CSF_CAUGHT 0x1000 // exception caught by this try conditional
-# define CSF_FINISHED 0x2000 // CSF_CAUGHT was handled by finish_exception()
-# define CSF_SILENT 0x4000 // "emsg_silent" reset by ":try"
+#define CSF_TRUE 0x0001 // condition was TRUE
+#define CSF_ACTIVE 0x0002 // current state is active
+#define CSF_ELSE 0x0004 // ":else" has been passed
+#define CSF_WHILE 0x0008 // is a ":while"
+#define CSF_FOR 0x0010 // is a ":for"
+#define CSF_BLOCK 0x0020 // is a "{" block
+
+#define CSF_TRY 0x0100 // is a ":try"
+#define CSF_FINALLY 0x0200 // ":finally" has been passed
+#define CSF_CATCH 0x0400 // ":catch" has been seen
+#define CSF_THROWN 0x0800 // exception thrown to this try conditional
+#define CSF_CAUGHT 0x1000 // exception caught by this try conditional
+#define CSF_FINISHED 0x2000 // CSF_CAUGHT was handled by finish_exception()
+#define CSF_SILENT 0x4000 // "emsg_silent" reset by ":try"
// Note that CSF_ELSE is only used when CSF_TRY and CSF_WHILE are unset
// (an ":if"), and CSF_SILENT is only used when CSF_TRY is set.
-# define CSF_FUNC_DEF 0x8000 // a function was defined in this block
+#define CSF_FUNC_DEF 0x8000 // a function was defined in this block
/*
* What's pending for being reactivated at the ":endtry" of this try
* conditional:
*/
-# define CSTP_NONE 0 // nothing pending in ":finally" clause
-# define CSTP_ERROR 1 // an error is pending
-# define CSTP_INTERRUPT 2 // an interrupt is pending
-# define CSTP_THROW 4 // a throw is pending
-# define CSTP_BREAK 8 // ":break" is pending
-# define CSTP_CONTINUE 16 // ":continue" is pending
-# define CSTP_RETURN 24 // ":return" is pending
-# define CSTP_FINISH 32 // ":finish" is pending
+#define CSTP_NONE 0 // nothing pending in ":finally" clause
+#define CSTP_ERROR 1 // an error is pending
+#define CSTP_INTERRUPT 2 // an interrupt is pending
+#define CSTP_THROW 4 // a throw is pending
+#define CSTP_BREAK 8 // ":break" is pending
+#define CSTP_CONTINUE 16 // ":continue" is pending
+#define CSTP_RETURN 24 // ":return" is pending
+#define CSTP_FINISH 32 // ":finish" is pending
/*
* Flags for the cs_lflags item in cstack_T.
*/
-# define CSL_HAD_LOOP 1 // just found ":while" or ":for"
-# define CSL_HAD_ENDLOOP 2 // just found ":endwhile" or ":endfor"
-# define CSL_HAD_CONT 4 // just found ":continue"
-# define CSL_HAD_FINA 8 // just found ":finally"
+#define CSL_HAD_LOOP 1 // just found ":while" or ":for"
+#define CSL_HAD_ENDLOOP 2 // just found ":endwhile" or ":endfor"
+#define CSL_HAD_CONT 4 // just found ":continue"
+#define CSL_HAD_FINA 8 // just found ":finally"
/*
* A list of error messages that can be converted to an exception. "throw_msg"
{
int bs_idx; // index of pattern
int bs_flags; // flags for pattern
-#ifdef FEAT_CONCEAL
+# ifdef FEAT_CONCEAL
int bs_seqnr; // stores si_seqnr
int bs_cchar; // stores si_cchar
-#endif
+# endif
reg_extmatch_T *bs_extmatch; // external matches from start pattern
} bufstate_T;
short_u bg_color; // background color number
short_u ul_color; // underline color number
short_u font; // font number
-# ifdef FEAT_TERMGUICOLORS
+#ifdef FEAT_TERMGUICOLORS
guicolor_T fg_rgb; // foreground color RGB
guicolor_T bg_rgb; // background color RGB
guicolor_T ul_rgb; // underline color RGB
-# endif
+#endif
} cterm;
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
struct
{
guicolor_T fg_color; // foreground color handle
guicolor_T bg_color; // background color handle
guicolor_T sp_color; // special color handle
GuiFont font; // font handle
-# ifdef FEAT_XFONTSET
+# ifdef FEAT_XFONTSET
GuiFontset fontset; // fontset handle
-# endif
- } gui;
# endif
+ } gui;
+#endif
} ae_u;
} attrentry_T;
{
int vc_type; // zero or one of the CONV_ values
int vc_factor; // max. expansion factor
-# ifdef MSWIN
+#ifdef MSWIN
int vc_cpfrom; // codepage to convert from (CONV_CODEPAGE)
int vc_cpto; // codepage to convert to (CONV_CODEPAGE)
-# endif
-# ifdef USE_ICONV
+#endif
+#ifdef USE_ICONV
iconv_t vc_fd; // for CONV_ICONV
-# endif
+#endif
int vc_fail; // fail for invalid char, don't use '?'
} vimconv_T;
};
// flags used in uf_flags
-#define FC_ABORT 0x01 // abort function on error
-#define FC_RANGE 0x02 // function accepts range
-#define FC_DICT 0x04 // Dict function, uses "self"
-#define FC_CLOSURE 0x08 // closure, uses outer scope variables
-#define FC_DELETED 0x10 // :delfunction used while uf_refcount > 0
-#define FC_REMOVED 0x20 // function redefined while uf_refcount > 0
-#define FC_SANDBOX 0x40 // function defined in the sandbox
-#define FC_DEAD 0x80 // function kept only for reference to dfunc
-#define FC_EXPORT 0x100 // "export def Func()"
-#define FC_NOARGS 0x200 // no a: variables in lambda
-#define FC_VIM9 0x400 // defined in Vim9 script file
-#define FC_CFUNC 0x800 // defined as Lua C func
-#define FC_COPY 0x1000 // copy of another function by
+# define FC_ABORT 0x01 // abort function on error
+# define FC_RANGE 0x02 // function accepts range
+# define FC_DICT 0x04 // Dict function, uses "self"
+# define FC_CLOSURE 0x08 // closure, uses outer scope variables
+# define FC_DELETED 0x10 // :delfunction used while uf_refcount > 0
+# define FC_REMOVED 0x20 // function redefined while uf_refcount > 0
+# define FC_SANDBOX 0x40 // function defined in the sandbox
+# define FC_DEAD 0x80 // function kept only for reference to dfunc
+# define FC_EXPORT 0x100 // "export def Func()"
+# define FC_NOARGS 0x200 // no a: variables in lambda
+# define FC_VIM9 0x400 // defined in Vim9 script file
+# define FC_CFUNC 0x800 // defined as Lua C func
+# define FC_COPY 0x1000 // copy of another function by
// copy_lambda_to_global_func()
-#define FC_LAMBDA 0x2000 // one line "return {expr}"
+# define FC_LAMBDA 0x2000 // one line "return {expr}"
-#define FC_OBJECT 0x4000 // object method
-#define FC_NEW 0x8000 // constructor
-#define FC_ABSTRACT 0x10000 // abstract method
-#define FC_GENERIC 0x20000 // generic function
+# define FC_OBJECT 0x4000 // object method
+# define FC_NEW 0x8000 // constructor
+# define FC_ABSTRACT 0x10000 // abstract method
+# define FC_GENERIC 0x20000 // generic function
// Is "ufunc" an object method?
-#define IS_OBJECT_METHOD(ufunc) ((ufunc->uf_flags & FC_OBJECT) == FC_OBJECT)
+# define IS_OBJECT_METHOD(ufunc) ((ufunc->uf_flags & FC_OBJECT) == FC_OBJECT)
// Is "ufunc" a class new() constructor method?
-#define IS_CONSTRUCTOR_METHOD(ufunc) ((ufunc->uf_flags & FC_NEW) == FC_NEW)
+# define IS_CONSTRUCTOR_METHOD(ufunc) ((ufunc->uf_flags & FC_NEW) == FC_NEW)
// Is "ufunc" an abstract class method?
-#define IS_ABSTRACT_METHOD(ufunc) ((ufunc->uf_flags & FC_ABSTRACT) == FC_ABSTRACT)
-#define IS_GENERIC_FUNC(ufunc) (((ufunc)->uf_flags & FC_GENERIC) == FC_GENERIC)
+# define IS_ABSTRACT_METHOD(ufunc) ((ufunc->uf_flags & FC_ABSTRACT) == FC_ABSTRACT)
+# define IS_GENERIC_FUNC(ufunc) (((ufunc)->uf_flags & FC_GENERIC) == FC_GENERIC)
-#define MAX_FUNC_ARGS 20 // maximum number of function arguments
-#define VAR_SHORT_LEN 20 // short variable name length
-#define FIXVAR_CNT 12 // number of fixed variables
+# define MAX_FUNC_ARGS 20 // maximum number of function arguments
+# define VAR_SHORT_LEN 20 // short variable name length
+# define FIXVAR_CNT 12 // number of fixed variables
/*
* Structure to hold info for a function that is currently being executed.
ectx_T *fc_ectx; // execution context for :def function, NULL
// otherwise
-#ifdef FEAT_PROFILE
+# ifdef FEAT_PROFILE
proftime_T fc_prof_child; // time spent in a child
-#endif
+# endif
funccall_T *fc_caller; // calling function or NULL; or next funccal in
// list pointed to by previous_funccal.
};
// From user function to hashitem and back.
-#define UF2HIKEY(fp) ((fp)->uf_name)
-#define HIKEY2UF(p) ((ufunc_T *)((p) - offsetof(ufunc_T, uf_name)))
-#define HI2UF(hi) HIKEY2UF((hi)->hi_key)
+# define UF2HIKEY(fp) ((fp)->uf_name)
+# define HIKEY2UF(p) ((ufunc_T *)((p) - offsetof(ufunc_T, uf_name)))
+# define HI2UF(hi) HIKEY2UF((hi)->hi_key)
/*
* Holds the hashtab with variables local to each sourced script.
* HIKEY2SAV() converts a hashitem key pointer to a sallvar_T pointer.
* HI2SAV() converts a hashitem pointer to a sallvar_T pointer.
*/
-#define SAV2HIKEY(sav) ((sav)->sav_key)
-#define HIKEY2SAV(p) ((sallvar_T *)(p - offsetof(sallvar_T, sav_key)))
-#define HI2SAV(hi) HIKEY2SAV((hi)->hi_key)
+# define SAV2HIKEY(sav) ((sav)->sav_key)
+# define HIKEY2SAV(p) ((sallvar_T *)(p - offsetof(sallvar_T, sav_key)))
+# define HI2SAV(hi) HIKEY2SAV((hi)->hi_key)
-#define SVFLAG_TYPE_ALLOCATED 1 // call free_type() for "sv_type"
-#define SVFLAG_EXPORTED 2 // "export let var = val"
-#define SVFLAG_ASSIGNED 4 // assigned a value
+# define SVFLAG_TYPE_ALLOCATED 1 // call free_type() for "sv_type"
+# define SVFLAG_EXPORTED 2 // "export let var = val"
+# define SVFLAG_ASSIGNED 4 // assigned a value
/*
* Entry for "sn_var_vals". Used for script-local variables.
int imp_flags; // IMP_FLAGS_ values
} imported_T;
-#define IMP_FLAGS_RELOAD 2 // script reloaded, OK to redefine
-#define IMP_FLAGS_AUTOLOAD 4 // script still needs to be loaded
+# define IMP_FLAGS_RELOAD 2 // script reloaded, OK to redefine
+# define IMP_FLAGS_AUTOLOAD 4 // script still needs to be loaded
/*
* Info about an encountered script.
# endif
} scriptitem_T;
-#define SN_STATE_NEW 0 // newly loaded script, nothing done
-#define SN_STATE_NOT_LOADED 1 // script located but not loaded
-#define SN_STATE_RELOAD 2 // script loaded before, nothing done
-#define SN_STATE_HAD_COMMAND 9 // a command was executed
+# define SN_STATE_NEW 0 // newly loaded script, nothing done
+# define SN_STATE_NOT_LOADED 1 // script located but not loaded
+# define SN_STATE_RELOAD 2 // script loaded before, nothing done
+# define SN_STATE_HAD_COMMAND 9 // a command was executed
// Struct passed through eval() functions.
// See EVALARG_EVALUATE for a fixed value with eval_flags set to EVAL_EVALUATE.
} evalarg_T;
// Flag for expression evaluation.
-#define EVAL_EVALUATE 1 // when missing don't actually evaluate
+# define EVAL_EVALUATE 1 // when missing don't actually evaluate
# ifdef FEAT_PROFILE
/*
typedef struct {
sock_T ch_fd; // socket/stdin/stdout/stderr, -1 if not used
-# if defined(UNIX) && !defined(HAVE_SELECT)
+#if defined(UNIX) && !defined(HAVE_SELECT)
int ch_poll_idx; // used by channel_poll_setup()
-# endif
+#endif
#ifdef FEAT_GUI_X11
XtInputId ch_inputHandler; // Cookie for input
long b_syn_sync_linebreaks; // offset for multi-line pattern
char_u *b_syn_linecont_pat; // line continuation pattern
regprog_T *b_syn_linecont_prog; // line continuation program
-#ifdef FEAT_PROFILE
+# ifdef FEAT_PROFILE
syn_time_T b_syn_linecont_time;
-#endif
+# endif
int b_syn_linecont_ic; // ignore-case flag for above
int b_syn_topgrp; // for ":syntax include"
# ifdef FEAT_CONCEAL
char_u *b_p_bh; // 'bufhidden'
char_u *b_p_bt; // 'buftype'
#ifdef FEAT_QUICKFIX
-#define BUF_HAS_QF_ENTRY 1
-#define BUF_HAS_LL_ENTRY 2
+# define BUF_HAS_QF_ENTRY 1
+# define BUF_HAS_LL_ENTRY 2
int b_has_qf_entry;
#endif
int b_p_bl; // 'buflisted'
* struct to store values from 'guicursor' and 'mouseshape'
*/
// Indexes in shape_table[]
-#define SHAPE_IDX_N 0 // Normal mode
-#define SHAPE_IDX_V 1 // Visual mode
-#define SHAPE_IDX_I 2 // Insert mode
-#define SHAPE_IDX_R 3 // Replace mode
-#define SHAPE_IDX_C 4 // Command line Normal mode
-#define SHAPE_IDX_CI 5 // Command line Insert mode
-#define SHAPE_IDX_CR 6 // Command line Replace mode
-#define SHAPE_IDX_O 7 // Operator-pending mode
-#define SHAPE_IDX_VE 8 // Visual mode with 'selection' exclusive
-#define SHAPE_IDX_CLINE 9 // On command line
-#define SHAPE_IDX_STATUS 10 // A status line
-#define SHAPE_IDX_SDRAG 11 // dragging a status line
-#define SHAPE_IDX_VSEP 12 // A vertical separator line
-#define SHAPE_IDX_VDRAG 13 // dragging a vertical separator line
-#define SHAPE_IDX_MORE 14 // Hit-return or More
-#define SHAPE_IDX_MOREL 15 // Hit-return or More in last line
-#define SHAPE_IDX_SM 16 // showing matching paren
-#define SHAPE_IDX_COUNT 17
-
-#define SHAPE_BLOCK 0 // block cursor
-#define SHAPE_HOR 1 // horizontal bar cursor
-#define SHAPE_VER 2 // vertical bar cursor
-
-#define MSHAPE_NUMBERED 1000 // offset for shapes identified by number
-#define MSHAPE_HIDE 1 // hide mouse pointer
-
-#define SHAPE_MOUSE 1 // used for mouse pointer shape
-#define SHAPE_CURSOR 2 // used for text cursor shape
+# define SHAPE_IDX_N 0 // Normal mode
+# define SHAPE_IDX_V 1 // Visual mode
+# define SHAPE_IDX_I 2 // Insert mode
+# define SHAPE_IDX_R 3 // Replace mode
+# define SHAPE_IDX_C 4 // Command line Normal mode
+# define SHAPE_IDX_CI 5 // Command line Insert mode
+# define SHAPE_IDX_CR 6 // Command line Replace mode
+# define SHAPE_IDX_O 7 // Operator-pending mode
+# define SHAPE_IDX_VE 8 // Visual mode with 'selection' exclusive
+# define SHAPE_IDX_CLINE 9 // On command line
+# define SHAPE_IDX_STATUS 10 // A status line
+# define SHAPE_IDX_SDRAG 11 // dragging a status line
+# define SHAPE_IDX_VSEP 12 // A vertical separator line
+# define SHAPE_IDX_VDRAG 13 // dragging a vertical separator line
+# define SHAPE_IDX_MORE 14 // Hit-return or More
+# define SHAPE_IDX_MOREL 15 // Hit-return or More in last line
+# define SHAPE_IDX_SM 16 // showing matching paren
+# define SHAPE_IDX_COUNT 17
+
+# define SHAPE_BLOCK 0 // block cursor
+# define SHAPE_HOR 1 // horizontal bar cursor
+# define SHAPE_VER 2 // vertical bar cursor
+
+# define MSHAPE_NUMBERED 1000 // offset for shapes identified by number
+# define MSHAPE_HIDE 1 // hide mouse pointer
+
+# define SHAPE_MOUSE 1 // used for mouse pointer shape
+# define SHAPE_CURSOR 2 // used for text cursor shape
typedef struct cursor_entry
{
#ifdef FEAT_MENU
// Indices into vimmenu_T->strings[] and vimmenu_T->noremap[] for each mode
-#define MENU_INDEX_INVALID -1
-#define MENU_INDEX_NORMAL 0
-#define MENU_INDEX_VISUAL 1
-#define MENU_INDEX_SELECT 2
-#define MENU_INDEX_OP_PENDING 3
-#define MENU_INDEX_INSERT 4
-#define MENU_INDEX_CMDLINE 5
-#define MENU_INDEX_TERMINAL 6
-#define MENU_INDEX_TIP 7
-#define MENU_MODES 8
+# define MENU_INDEX_INVALID -1
+# define MENU_INDEX_NORMAL 0
+# define MENU_INDEX_VISUAL 1
+# define MENU_INDEX_SELECT 2
+# define MENU_INDEX_OP_PENDING 3
+# define MENU_INDEX_INSERT 4
+# define MENU_INDEX_CMDLINE 5
+# define MENU_INDEX_TERMINAL 6
+# define MENU_INDEX_TIP 7
+# define MENU_MODES 8
// Menu modes
-#define MENU_NORMAL_MODE (1 << MENU_INDEX_NORMAL)
-#define MENU_VISUAL_MODE (1 << MENU_INDEX_VISUAL)
-#define MENU_SELECT_MODE (1 << MENU_INDEX_SELECT)
-#define MENU_OP_PENDING_MODE (1 << MENU_INDEX_OP_PENDING)
-#define MENU_INSERT_MODE (1 << MENU_INDEX_INSERT)
-#define MENU_CMDLINE_MODE (1 << MENU_INDEX_CMDLINE)
-#define MENU_TERMINAL_MODE (1 << MENU_INDEX_TERMINAL)
-#define MENU_TIP_MODE (1 << MENU_INDEX_TIP)
-#define MENU_ALL_MODES ((1 << MENU_INDEX_TIP) - 1)
+# define MENU_NORMAL_MODE (1 << MENU_INDEX_NORMAL)
+# define MENU_VISUAL_MODE (1 << MENU_INDEX_VISUAL)
+# define MENU_SELECT_MODE (1 << MENU_INDEX_SELECT)
+# define MENU_OP_PENDING_MODE (1 << MENU_INDEX_OP_PENDING)
+# define MENU_INSERT_MODE (1 << MENU_INDEX_INSERT)
+# define MENU_CMDLINE_MODE (1 << MENU_INDEX_CMDLINE)
+# define MENU_TERMINAL_MODE (1 << MENU_INDEX_TERMINAL)
+# define MENU_TIP_MODE (1 << MENU_INDEX_TIP)
+# define MENU_ALL_MODES ((1 << MENU_INDEX_TIP) - 1)
// note MENU_INDEX_TIP is not a 'real' mode
// Start a menu name with this to not include it on the main menu bar
-#define MNU_HIDDEN_CHAR ']'
+# define MNU_HIDDEN_CHAR ']'
struct VimMenu
{
int enabled; // for which modes the menu is enabled
char_u *name; // Name of menu, possibly translated
char_u *dname; // Displayed Name ("name" without '&')
-#ifdef FEAT_MULTI_LANG
+# ifdef FEAT_MULTI_LANG
char_u *en_name; // "name" untranslated, NULL when "name"
// was not translated
char_u *en_dname; // "dname" untranslated, NULL when "dname"
// was not translated
-#endif
+# endif
char_u *actext; // accelerator text (after TAB)
int mnemonic; // mnemonic key (after '&')
int priority; // Menu order priority
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
void (*cb)(vimmenu_T *); // Call-back function
-#endif
-#ifdef FEAT_TOOLBAR
+# endif
+# ifdef FEAT_TOOLBAR
char_u *iconfile; // name of file for icon or NULL
int iconidx; // icon index (-1 if not set)
int icon_builtin; // icon names is BuiltIn{nr}
-#endif
+# endif
char_u *strings[MENU_MODES]; // Mapped string for each mode
int noremap[MENU_MODES]; // A REMAP_ flag for each mode
char silent[MENU_MODES]; // A silent flag for each mode
vimmenu_T *children; // Children of sub-menu
vimmenu_T *parent; // Parent of menu
vimmenu_T *next; // Next item in menu
-#ifdef FEAT_GUI_X11
+# ifdef FEAT_GUI_X11
Widget id; // Manage this to enable item
Widget submenu_id; // If this is submenu, add children here
-#endif
-#ifdef FEAT_GUI_GTK
+# endif
+# ifdef FEAT_GUI_GTK
GtkWidget *id; // Manage this to enable item
GtkWidget *submenu_id; // If this is submenu, add children here
-# if defined(GTK_CHECK_VERSION) && !GTK_CHECK_VERSION(3,4,0)
+# if defined(GTK_CHECK_VERSION) && !GTK_CHECK_VERSION(3,4,0)
GtkWidget *tearoff_handle;
-# endif
+# endif
GtkWidget *label; // Used by "set wak=" code.
-#endif
-#ifdef FEAT_GUI_MOTIF
+# endif
+# ifdef FEAT_GUI_MOTIF
int sensitive; // turn button on/off
char **xpm; // pixmap data
char *xpm_fname; // file with pixmap data
-#endif
-#ifdef FEAT_BEVAL_TIP
+# endif
+# ifdef FEAT_BEVAL_TIP
BalloonEval *tip; // tooltip for this menu item
-#endif
-#ifdef FEAT_GUI_MSWIN
+# endif
+# ifdef FEAT_GUI_MSWIN
UINT id; // Id of menu item
HMENU submenu_id; // If this is submenu, add children here
HWND tearoff_handle; // hWnd of tearoff if created
-#endif
-#ifdef FEAT_GUI_HAIKU
+# endif
+# ifdef FEAT_GUI_HAIKU
BMenuItem *id; // Id of menu item
BMenu *submenu_id; // If this is submenu, add children here
-# ifdef FEAT_TOOLBAR
+# ifdef FEAT_TOOLBAR
BPictureButton *button;
+# endif
# endif
-#endif
-#ifdef FEAT_GUI_PHOTON
+# ifdef FEAT_GUI_PHOTON
PtWidget_t *id;
PtWidget_t *submenu_id;
-#endif
+# endif
};
#else
// For generating prototypes when FEAT_MENU isn't defined.
#define DELETION_REGISTER 36
#if defined(FEAT_CLIPBOARD) || defined(HAVE_CLIPMETHOD)
# define STAR_REGISTER 37
-# if defined(FEAT_X11) || defined(FEAT_WAYLAND)
-# define PLUS_REGISTER 38
-# define REAL_PLUS_REGISTER PLUS_REGISTER
-# else
-# define PLUS_REGISTER STAR_REGISTER // there is only one
-# ifdef FEAT_EVAL
+# if defined(FEAT_X11) || defined(FEAT_WAYLAND)
+# define PLUS_REGISTER 38
+# define REAL_PLUS_REGISTER PLUS_REGISTER
+# else
+# define PLUS_REGISTER STAR_REGISTER // there is only one
+# ifdef FEAT_EVAL
// Make it so that if clipmethod is "none", the plus register is not available,
// but if clipmethod is a provider, then expose the plus register for use.
-# define REAL_PLUS_REGISTER 38
-# else
-# define REAL_PLUS_REGISTER STAR_REGISTER
-# endif
+# define REAL_PLUS_REGISTER 38
+# else
+# define REAL_PLUS_REGISTER STAR_REGISTER
# endif
+# endif
#endif
#ifdef FEAT_DND
# define TILDE_REGISTER (PLUS_REGISTER + 1)
}
#endif
-# if defined(EXITFREE)
+#if defined(EXITFREE)
void
free_tagfunc_option(void)
{
free_callback(&tfu_cb);
# endif
}
-# endif
+#endif
#if defined(FEAT_EVAL)
/*
if (use_tagstack && tagstackidx <= curwin->w_tagstacklen)
curwin->w_tagstackidx = tagstackidx;
postponed_split = 0; // don't split next time
-# ifdef FEAT_QUICKFIX
+#ifdef FEAT_QUICKFIX
g_do_tagpreview = 0; // don't do tag preview next time
-# endif
+#endif
vim_free(tofree);
#ifdef FEAT_CSCOPE
break;
}
-#ifdef FEAT_EMACS_TAGS
+# ifdef FEAT_EMACS_TAGS
len = 3;
-#else
+# else
len = 2;
-#endif
+# endif
res_name = NULL;
res_fname = NULL;
res_cmd = NULL;
*p++ = MT_GL_OTH + 1; // mtt
*p++ = TAG_SEP; // no tag file name
-#ifdef FEAT_EMACS_TAGS
+# ifdef FEAT_EMACS_TAGS
*p++ = TAG_SEP;
-#endif
+# endif
STRCPY(p, res_name);
p += STRLEN(p);
// When "!_TAG_FILE_SORTED" found: start binary search if
// flag set.
// For cscope, it's always linear.
-# ifdef FEAT_CSCOPE
+#ifdef FEAT_CSCOPE
if (st->linear || use_cscope)
-# else
+#else
if (st->linear)
-# endif
+#endif
st->state = TS_LINEAR;
else if (st->tag_file_sorted == NUL)
st->state = TS_BINARY;
if (st.stop_searching || st.linear || (!p_ic && noic) ||
st.orgpat->regmatch.rm_ic)
break;
-# ifdef FEAT_CSCOPE
+#ifdef FEAT_CSCOPE
if (use_cscope)
break;
-# endif
+#endif
// try another time while ignoring case
st.orgpat->regmatch.rm_ic = TRUE;
dictitem_T *di;
list_T *l = NULL;
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
// not allowed to alter the tag stack entries from inside tagfunc
if (tfu_in_use)
{
emsg(_(e_cannot_modify_tag_stack_within_tagfunc));
return FAIL;
}
-#endif
+# endif
if ((di = dict_find(d, (char_u *)"items", -1)) != NULL)
{
// Note: Keep this in sync with get_terminalopt_name.
-# define OPTARG_HAS(name) ((int)(p - cmd) == sizeof(name) - 1 \
+#define OPTARG_HAS(name) ((int)(p - cmd) == sizeof(name) - 1 \
&& STRNICMP(cmd, name, sizeof(name) - 1) == 0)
if (OPTARG_HAS("close"))
opt.jo_term_finish = 'c';
semsg(_(e_invalid_attribute_str), cmd);
goto theend;
}
-# undef OPTARG_HAS
+#undef OPTARG_HAS
cmd = skipwhite(p);
}
if (*cmd == NUL)
if (fprintf(fd, "terminal ++curwin ++cols=%d ++rows=%d ",
term->tl_cols, term->tl_rows) < 0)
return FAIL;
-#ifdef MSWIN
+# ifdef MSWIN
if (fprintf(fd, "++type=%s ", term->tl_job->jv_tty_type) < 0)
return FAIL;
-#endif
+# endif
if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0)
return FAIL;
if (put_eol(fd) != OK)
goto theend;
}
}
-# ifdef MSWIN
+#ifdef MSWIN
if (!enc_utf8 && has_mbyte && raw_c >= 0x80)
{
WCHAR wc;
if (MultiByteToWideChar(GetACP(), 0, (char*)mb, 2, &wc, 1) > 0)
raw_c = wc;
}
-# endif
+#endif
if (send_keys_to_term(curbuf->b_term, raw_c, mod_mask, TRUE) != OK)
{
if (raw_c == K_MOUSEMOVE)
if (cterm_normal_fg_color > 0)
{
cterm_color2vterm(cterm_normal_fg_color - 1, fg);
-# if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
-# ifdef VIMDLL
+#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
+# ifdef VIMDLL
if (!gui.in_use)
-# endif
+# endif
{
tmp = fg->red;
fg->red = fg->blue;
fg->blue = tmp;
}
-# endif
+#endif
}
-# ifdef FEAT_TERMRESPONSE
+#ifdef FEAT_TERMRESPONSE
else
term_get_fg_color(&fg->red, &fg->green, &fg->blue);
-# endif
+#endif
if (cterm_normal_bg_color > 0)
{
cterm_color2vterm(cterm_normal_bg_color - 1, bg);
-# if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
-# ifdef VIMDLL
+#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
+# ifdef VIMDLL
if (!gui.in_use)
-# endif
+# endif
{
tmp = fg->red;
fg->red = fg->blue;
fg->blue = tmp;
}
-# endif
+#endif
}
-# ifdef FEAT_TERMRESPONSE
+#ifdef FEAT_TERMRESPONSE
else
term_get_bg_color(&bg->red, &bg->green, &bg->blue);
-# endif
+#endif
}
}
term_use_palette(void)
{
if (0
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
|| gui.in_use
-#endif
-#ifdef FEAT_TERMGUICOLORS
+# endif
+# ifdef FEAT_TERMGUICOLORS
|| p_tgc
-#endif
+# endif
)
return TRUE;
return FALSE;
(int)STRLEN(term->tl_eof_chars), NULL);
channel_send(ch, PART_IN, (char_u *)"\r", 1, NULL);
}
-# ifdef MSWIN
+#ifdef MSWIN
else
// Default: CTRL-D
channel_send(ch, PART_IN, (char_u *)"\004\r", 2, NULL);
-# endif
+#endif
}
}
}
#endif
-# if defined(MSWIN)
+#if defined(MSWIN)
///////////////////////////////////////
// 2. MS-Windows implementation.
if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL)
goto failed;
-#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
+# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
if (term_use_palette())
{
if (term->tl_palette != NULL)
else
init_vterm_ansi_colors(term->tl_vterm);
}
-#endif
+# endif
channel_set_job(channel, job, opt);
job_set_options(job, opt);
return has_conpty;
}
-#define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul
-#define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull
-#define WINPTY_MOUSE_MODE_FORCE 2
+# define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul
+# define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull
+# define WINPTY_MOUSE_MODE_FORCE 2
void* (*winpty_config_new)(UINT64, void*);
void* (*winpty_open)(void*, void*);
BOOL (*winpty_set_size)(void*, int, int, void*);
HANDLE (*winpty_agent_process)(void*);
-#define WINPTY_DLL "winpty.dll"
+# define WINPTY_DLL "winpty.dll"
static HINSTANCE hWinPtyDLL = NULL;
if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL)
goto failed;
-#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
+# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
if (term_use_palette())
{
if (term->tl_palette != NULL)
else
init_vterm_ansi_colors(term->tl_vterm);
}
-#endif
+# endif
channel_set_job(channel, job, opt);
job_set_options(job, opt);
return dyn_winpty_init(FALSE) == OK || dyn_conpty_init(FALSE) == OK;
}
-# else
+#else
///////////////////////////////////////
// 3. Unix-like implementation.
if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL)
return FAIL;
-#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
+# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
if (term_use_palette())
{
if (term->tl_palette != NULL)
else
init_vterm_ansi_colors(term->tl_vterm);
}
-#endif
+# endif
// This may change a string in "argvar".
term->tl_job = job_start(argvar, argv, opt, &term->tl_job);
mch_signal_job(term->tl_job, (char_u *)"winch");
}
-# endif
+#endif
#endif // FEAT_TERMINAL
mouse_col = (time_t)tv_get_number(&argvars[1]) - 1;
}
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
static int
test_gui_drop_files(dict_T *args UNUSED)
{
-# if defined(HAVE_DROP_FILE)
+# if defined(HAVE_DROP_FILE)
int row;
int col;
int_u mods;
gui_handle_drop(TEXT_X(col - 1), TEXT_Y(row - 1), mods, fnames, count);
else
vim_free(fnames);
-# endif
+# endif
return TRUE;
}
-#if defined(FIND_REPLACE_DIALOG)
+# if defined(FIND_REPLACE_DIALOG)
static int
test_gui_find_repl(dict_T *args)
{
return retval;
}
-#endif
+# endif
static int
test_gui_mouse_event(dict_T *args)
return FALSE;
}
gui_drag_scrollbar(sb, value, dragging);
-# ifndef USE_ON_FLY_SCROLL
+# ifndef USE_ON_FLY_SCROLL
// need to loop through normal_cmd() to handle the scroll events
exec_normal(FALSE, TRUE, FALSE);
-# endif
+# endif
return TRUE;
}
static int
test_gui_tabline_event(dict_T *args UNUSED)
{
-# ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
int tabnr;
if (!dict_has_key(args, "tabnr"))
tabnr = (int)dict_get_number(args, "tabnr");
return send_tabline_event(tabnr);
-# else
+# else
return FALSE;
-# endif
+# endif
}
static int
test_gui_tabmenu_event(dict_T *args UNUSED)
{
-# ifdef FEAT_GUI_TABLINE
+# ifdef FEAT_GUI_TABLINE
int tabnr;
int item;
item = (int)dict_get_number(args, "item");
send_tabline_menu_event(tabnr, item);
-# endif
+# endif
return TRUE;
}
-# endif
+#endif
void
f_test_mswin_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
-# ifdef MSWIN
+#ifdef MSWIN
rettv->v_type = VAR_BOOL;
rettv->vval.v_number = FALSE;
char_u *event = tv_get_string(&argvars[0]);
rettv->vval.v_number = test_mswin_event(event, argvars[1].vval.v_dict);
-# endif
+#endif
}
void
f_test_gui_event(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
char_u *event;
rettv->v_type = VAR_BOOL;
event = tv_get_string(&argvars[0]);
if (STRCMP(event, "dropfiles") == 0)
rettv->vval.v_number = test_gui_drop_files(argvars[1].vval.v_dict);
-# if defined(FIND_REPLACE_DIALOG)
+# if defined(FIND_REPLACE_DIALOG)
else if (STRCMP(event, "findrepl") == 0)
rettv->vval.v_number = test_gui_find_repl(argvars[1].vval.v_dict);
-# endif
-# ifdef MSWIN
+# endif
+# ifdef MSWIN
else if (STRCMP(event, "key") == 0 || STRCMP(event, "mouse") == 0 || STRCMP(event, "set_keycode_trans_strategy") == 0)
rettv->vval.v_number = test_mswin_event(event, argvars[1].vval.v_dict);
-# endif
+# endif
else if (STRCMP(event, "mouse") == 0)
rettv->vval.v_number = test_gui_mouse_event(argvars[1].vval.v_dict);
else if (STRCMP(event, "scrollbar") == 0)
semsg(_(e_invalid_argument_str), event);
return;
}
-# endif
+#endif
}
void
if (cindent_on())
{
indent =
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
*curbuf->b_p_inde != NUL ? get_expr_indent() :
-# endif
+#endif
get_c_indent();
}
else
time_T
vim_time(void)
{
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
return time_for_testing == 0 ? time(NULL) : time_for_testing;
-# else
+#else
return time(NULL);
-# endif
+#endif
}
/*
#if defined(FEAT_EVAL)
-#if defined(MACOS_X)
-# include <time.h> // for time_t
-#endif
+# if defined(MACOS_X)
+# include <time.h> // for time_t
+# endif
/*
* "localtime()" function
proftime_T tm;
if (list2proftime(&argvars[0], &tm) == OK)
{
-# ifdef MSWIN
+# ifdef MSWIN
rettv->vval.v_string = vim_strsave((char_u *)profile_msg(&tm));
-# else
+# else
static char buf[50];
long usec = tm.tv_fsec / (TV_FSEC_SEC / 1000000);
vim_snprintf(buf, sizeof(buf), "%3ld.%06ld", (long)tm.tv_sec, usec);
rettv->vval.v_string = vim_strsave((char_u *)buf);
-# endif
+# endif
}
else if (in_vim9script())
emsg(_(e_invalid_argument));
return;
}
-# ifdef MSWIN
+# ifdef MSWIN
WCHAR result_buf[256];
WCHAR *wp;
result_buf[0] = NUL;
rettv->vval.v_string = utf16_to_enc(result_buf, NULL);
vim_free(wp);
-# else
+# else
char_u result_buf[256];
vimconv_T conv;
char_u *enc;
// Release conversion descriptors
convert_setup(&conv, NULL, NULL);
vim_free(enc);
-# endif
+# endif
}
# endif
typval_T rettv;
typval_T argv[2];
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
if (ch_log_active())
{
callback_T *cb = &timer->tr_callback;
ch_log(NULL, "invoking timer callback %s",
cb->cb_partial != NULL ? cb->cb_partial->pt_name : cb->cb_name);
}
-#endif
+# endif
argv[0].v_type = VAR_NUMBER;
argv[0].vval.v_number = (varnumber_T)timer->tr_id;
call_callback(&timer->tr_callback, -1, &rettv, 1, argv);
clear_tv(&rettv);
-#ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
ch_log(NULL, "timer callback finished");
-#endif
+# endif
}
/*
if (did_one)
redraw_after_callback(need_update_screen, FALSE);
-#ifdef FEAT_BEVAL_TERM
+# ifdef FEAT_BEVAL_TERM
if (bevalexpr_due_set)
{
this_due = proftime_time_left(&bevalexpr_due, &now);
else if (next_due == -1 || next_due > this_due)
next_due = this_due;
}
-#endif
-#ifdef FEAT_TERMINAL
+# endif
+# ifdef FEAT_TERMINAL
// Some terminal windows may need their buffer updated.
next_due = term_check_timers(next_due, &now);
-#endif
+# endif
return current_id != last_timer_id ? 1 : next_due;
}
return FALSE;
}
-# if defined(EXITFREE)
+# if defined(EXITFREE)
void
timer_free_all(void)
{
free_timer(timer);
}
}
-# endif
+# endif
/*
* "timer_info([timer])" function
emsg(_(e_using_special_value_as_float));
break;
case VAR_JOB:
-# ifdef FEAT_JOB_CHANNEL
+#ifdef FEAT_JOB_CHANNEL
emsg(_(e_using_job_as_float));
break;
-# endif
+#endif
case VAR_CHANNEL:
-# ifdef FEAT_JOB_CHANNEL
+#ifdef FEAT_JOB_CHANNEL
emsg(_(e_using_channel_as_float));
break;
-# endif
+#endif
case VAR_BLOB:
emsg(_(e_using_blob_as_float));
break;
int did_start_blocking = FALSE;
long wait_time;
long elapsed_time = 0;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
elapsed_T start_tv;
ELAPSED_INIT(start_tv);
-#endif
+# endif
// repeat until we got a character or waited long enough
for (;;)
if (resize_func != NULL)
resize_func(FALSE);
-#ifdef MESSAGE_QUEUE
+# ifdef MESSAGE_QUEUE
// Only process messages when waiting.
if (wtime != 0)
{
if (typebuf_changed(tb_change_cnt))
return 0;
}
-#endif
+# endif
if (wtime < 0 && did_start_blocking)
// blocking and already waited for p_ut
wait_time = -1;
else
// going to block after p_ut
wait_time = p_ut;
-#ifdef ELAPSED_FUNC
+# ifdef ELAPSED_FUNC
elapsed_time = ELAPSED_FUNC(start_tv);
-#endif
+# endif
wait_time -= elapsed_time;
// If the waiting time is now zero or less, we timed out. However,
}
}
-#ifdef FEAT_JOB_CHANNEL
+# ifdef FEAT_JOB_CHANNEL
if (wait_time < 0 || wait_time > 100L)
{
// Checking if a job ended requires polling. Do this at least
if (channel_any_readahead())
wait_time = 10L;
}
-#endif
-#ifdef FEAT_BEVAL_GUI
+# endif
+# ifdef FEAT_BEVAL_GUI
if (p_beval && wait_time > 100L)
// The 'balloonexpr' may indirectly invoke a callback while waiting
// for a character, need to check often.
wait_time = 100L;
-#endif
+# endif
// Wait for a character to be typed or another event, such as the winch
// signal or an event on the monitored file descriptors.
}
// Timed out or interrupted with no character available.
-#ifndef ELAPSED_FUNC
+# ifndef ELAPSED_FUNC
// estimate the elapsed time
elapsed_time += wait_time;
-#endif
+# endif
if ((resize_func != NULL && resize_func(TRUE))
-#if defined(FEAT_CLIENTSERVER) && defined(UNIX)
+# if defined(FEAT_CLIENTSERVER) && defined(UNIX)
|| (
-# ifdef FEAT_X11
+# ifdef FEAT_X11
(clientserver_method == CLIENTSERVER_METHOD_X11 &&
server_waiting())
-# endif
-# if defined(FEAT_X11) && defined(FEAT_SOCKETSERVER)
+# endif
+# if defined(FEAT_X11) && defined(FEAT_SOCKETSERVER)
||
-# endif
-# ifdef FEAT_SOCKETSERVER
+# endif
+# ifdef FEAT_SOCKETSERVER
(clientserver_method == CLIENTSERVER_METHOD_SOCKET &&
socket_server_waiting_accept())
-# endif
+# endif
)
-#endif
-#ifdef MESSAGE_QUEUE
+# endif
+# ifdef MESSAGE_QUEUE
|| interrupted
-#endif
+# endif
|| wait_time > 0
|| (wtime < 0 && !did_start_blocking))
// no character available, but something to be done, keep going
* descriptions which would otherwise overflow. The buffer is considered full
* when only this extra space (or part of it) remains.
*/
-#if defined(FEAT_JOB_CHANNEL) || defined(FEAT_CLIENTSERVER)
+# if defined(FEAT_JOB_CHANNEL) || defined(FEAT_CLIENTSERVER)
/*
* NetBeans stuffs debugger commands into the input buffer.
* This requires a larger buffer...
* (Madsen) Go with this for remote input as well ...
*/
-# define INBUFLEN 4096
-#else
-# define INBUFLEN 250
-#endif
+# define INBUFLEN 4096
+# else
+# define INBUFLEN 250
+# endif
static char_u inbuf[INBUFLEN + MAX_KEY_CODE_LEN];
static int inbufcount = 0; // number of chars in inbuf[]
return (inbufcount == 0);
}
-#if defined(FEAT_OLE)
+# if defined(FEAT_OLE)
int
vim_free_in_input_buf(void)
{
return (INBUFLEN - inbufcount);
}
-#endif
+# endif
-#if defined(FEAT_GUI_GTK)
+# if defined(FEAT_GUI_GTK)
int
vim_used_in_input_buf(void)
{
return inbufcount;
}
-#endif
+# endif
/*
* Return the current contents of the input buffer and make it empty.
void
fill_input_buf(int exit_on_error UNUSED)
{
-#if defined(UNIX) || defined(VMS) || defined(MACOS_X)
+# if defined(UNIX) || defined(VMS) || defined(MACOS_X)
int len;
int try;
static int did_read_something = FALSE;
static char_u *rest = NULL; // unconverted rest of previous read
static int restlen = 0;
int unconverted;
-#endif
+# endif
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.in_use
-# ifdef NO_CONSOLE_INPUT
+# ifdef NO_CONSOLE_INPUT
// Don't use the GUI input when the window hasn't been opened yet.
// We get here from ui_inchar() when we should try reading from stdin.
&& !no_console_input()
-# endif
+# endif
)
{
gui_mch_update();
return;
}
-#endif
-#if defined(UNIX) || defined(VMS) || defined(MACOS_X)
+# endif
+# if defined(UNIX) || defined(VMS) || defined(MACOS_X)
if (vim_is_input_buf_full())
return;
/*
// back to cooked mode, use another descriptor and set the mode to
// what it was.
settmode(TMODE_COOK);
-#ifdef HAVE_DUP
+# ifdef HAVE_DUP
// Use stderr for stdin, also works for shell commands.
close(0);
vim_ignored = dup(2);
-#else
+# else
read_cmd_fd = 2; // read from stderr instead of stdin
-#endif
+# endif
settmode(m);
}
if (!exit_on_error)
++inbufcount;
}
}
-#endif // UNIX || VMS || MACOS_X
+# endif // UNIX || VMS || MACOS_X
}
#endif // USE_INPUT_BUF
// line numbers, topline and botline can be invalid when displaying is
// postponed.
if (
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
(!gui.in_use || vim_strchr(p_go, GO_HORSCROLL) == NULL) &&
-# endif
+#endif
curwin->w_topline <= curwin->w_cursor.lnum
&& curwin->w_botline > curwin->w_cursor.lnum
&& curwin->w_botline <= curbuf->b_ml.ml_line_count + 1)
if (in_focus && last_time + 2 < time(NULL))
{
need_redraw = check_timestamps(
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
gui.in_use
-# else
+#else
FALSE
-# endif
+#endif
);
last_time = time(NULL);
}
stat_T st;
char_u *ffname = buf_ffname;
size_t ffnamelen;
-#ifdef HAVE_READLINK
+# ifdef HAVE_READLINK
char_u fname_buf[MAXPATHL];
-#endif
+# endif
if (ffname == NULL)
return NULL;
-#ifdef HAVE_READLINK
+# ifdef HAVE_READLINK
// Expand symlink in the file name, so that we put the undo file with the
// actual file instead of with the symlink.
if (resolve_symlink(ffname, fname_buf) == OK)
ffname = fname_buf;
-#endif
+# endif
ffnamelen = STRLEN(ffname);
// Loop over 'undodir'. When reading find the first file that exists.
break;
p = gettail(undo_file_name);
plen = (size_t)(ffnamelen - (p - undo_file_name));
-#ifdef VMS
+# ifdef VMS
// VMS can not handle more than one dot in the filenames
// use "dir/name" -> "dir/_un_name" - add _un_
// at the beginning to keep the extension
mch_memmove(p + 4, p, plen + 1);
mch_memmove(p, "_un_", 4);
-#else
+# else
// Use same directory as the ffname,
// "dir/name" -> "dir/.name.un~"
mch_memmove(p + 1, p, plen + 1);
*p = '.';
STRCPY(p + plen + 1, ".un~");
-#endif
+# endif
}
else
{
static int
undo_write(bufinfo_T *bi, char_u *ptr, size_t len)
{
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi->bi_buffer != NULL)
{
size_t len_todo = len;
}
return OK;
}
-#endif
+# endif
if (fwrite(ptr, len, (size_t)1, bi->bi_fp) != 1)
return FAIL;
return OK;
}
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
static int
undo_flush(bufinfo_T *bi)
{
}
return OK;
}
-#endif
+# endif
/*
* Write "ptr[len]" and crypt the bytes when needed.
static int
fwrite_crypt(bufinfo_T *bi, char_u *ptr, size_t len)
{
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
char_u *copy;
char_u small_buf[100];
size_t i;
vim_free(copy);
return i == 1 ? OK : FAIL;
}
-#endif
+# endif
return undo_write(bi, ptr, len);
}
static int
undo_read_4c(bufinfo_T *bi)
{
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi->bi_buffer != NULL)
{
char_u buf[4];
n = ((unsigned)buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
return n;
}
-#endif
+# endif
return get4c(bi->bi_fp);
}
static int
undo_read_2c(bufinfo_T *bi)
{
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi->bi_buffer != NULL)
{
char_u buf[2];
n = (buf[0] << 8) + buf[1];
return n;
}
-#endif
+# endif
return get2c(bi->bi_fp);
}
static int
undo_read_byte(bufinfo_T *bi)
{
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi->bi_buffer != NULL)
{
char_u buf[1];
undo_read(bi, buf, (size_t)1);
return buf[0];
}
-#endif
+# endif
return getc(bi->bi_fp);
}
static time_t
undo_read_time(bufinfo_T *bi)
{
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi->bi_buffer != NULL)
{
char_u buf[8];
n = (n << 8) + buf[i];
return n;
}
-#endif
+# endif
return get8ctime(bi->bi_fp);
}
{
int retval = OK;
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi->bi_buffer != NULL)
{
int size_todo = (int)size;
}
}
else
-#endif
+# endif
if (fread(buffer, size, 1, bi->bi_fp) != 1)
retval = FAIL;
// In case there are text properties there already is a NUL, but
// checking for that is more expensive than just adding a dummy byte.
ptr[len] = NUL;
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi->bi_state != NULL && bi->bi_buffer == NULL)
crypt_decode_inplace(bi->bi_state, ptr, len, FALSE);
-#endif
+# endif
return ptr;
}
// If the buffer is encrypted then all text bytes following will be
// encrypted. Numbers and other info is not crypted.
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (*buf->b_p_key != NUL)
{
char_u *header;
}
}
else
-#endif
+# endif
undo_write_bytes(bi, (long_u)UF_VERSION, 2);
if (uhp == NULL)
return NULL;
CLEAR_POINTER(uhp);
-#ifdef U_DEBUG
+# ifdef U_DEBUG
uhp->uh_magic = UH_MAGIC;
-#endif
+# endif
uhp->uh_next.seq = undo_read_4c(bi);
uhp->uh_prev.seq = undo_read_4c(bi);
uhp->uh_alt_next.seq = undo_read_4c(bi);
if (uep == NULL)
return NULL;
CLEAR_POINTER(uep);
-#ifdef U_DEBUG
+# ifdef U_DEBUG
uep->ue_magic = UE_MAGIC;
-#endif
+# endif
uep->ue_top = undo_read_4c(bi);
uep->ue_bot = undo_read_4c(bi);
uep->ue_lcount = undo_read_4c(bi);
u_header_T *uhp;
char_u *file_name;
int mark;
-#ifdef U_DEBUG
+# ifdef U_DEBUG
int headers_written = 0;
-#endif
+# endif
int fd;
FILE *fp = NULL;
int perm;
int write_ok = FALSE;
-#ifdef UNIX
+# ifdef UNIX
int st_old_valid = FALSE;
stat_T st_old;
stat_T st_new;
-#endif
+# endif
bufinfo_T bi;
CLEAR_FIELD(bi);
perm = 0600;
if (buf->b_ffname != NULL)
{
-#ifdef UNIX
+# ifdef UNIX
if (mch_stat((char *)buf->b_ffname, &st_old) >= 0)
{
perm = st_old.st_mode;
st_old_valid = TRUE;
}
-#else
+# else
perm = mch_getperm(buf->b_ffname);
if (perm < 0)
perm = 0600;
-#endif
+# endif
}
// strip any s-bit and executable bit
verbose_leave();
}
-#ifdef U_DEBUG
+# ifdef U_DEBUG
// Check there is no problem in undo info before writing.
u_check(FALSE);
-#endif
+# endif
-#ifdef UNIX
+# ifdef UNIX
/*
* Try to set the group of the undo file same as the original file. If
* this fails, set the protection bits for the group same as the
if (st_old_valid
&& mch_stat((char *)file_name, &st_new) >= 0
&& st_new.st_gid != st_old.st_gid
-# ifdef HAVE_FCHOWN // sequent-ptx lacks fchown()
+# ifdef HAVE_FCHOWN // sequent-ptx lacks fchown()
&& fchown(fd, (uid_t)-1, st_old.st_gid) != 0
-# endif
+# endif
)
mch_setperm(file_name, (perm & 0707) | ((perm & 07) << 3));
-# if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
+# if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
if (buf->b_ffname != NULL)
mch_copy_sec(buf->b_ffname, file_name);
+# endif
# endif
-#endif
fp = fdopen(fd, "w");
if (fp == NULL)
if (uhp->uh_walk != mark)
{
uhp->uh_walk = mark;
-#ifdef U_DEBUG
+# ifdef U_DEBUG
++headers_written;
-#endif
+# endif
if (serialize_uhp(&bi, uhp) == FAIL)
goto write_error;
}
if (undo_write_bytes(&bi, (long_u)UF_HEADER_END_MAGIC, 2) == OK)
write_ok = TRUE;
-#ifdef U_DEBUG
+# ifdef U_DEBUG
if (headers_written != buf->b_u_numhead)
{
semsg("Written %ld headers, ...", headers_written);
semsg("... but numhead is %ld", buf->b_u_numhead);
}
-#endif
+# endif
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi.bi_state != NULL && undo_flush(&bi) == FAIL)
write_ok = FALSE;
-#endif
+# endif
-#if defined(UNIX) && defined(HAVE_FSYNC)
+# if defined(UNIX) && defined(HAVE_FSYNC)
if ((buf->b_p_fs >= 0 ? buf->b_p_fs : p_fs) && fflush(fp) == 0
&& vim_fsync(fd) != 0)
write_ok = FALSE;
-#endif
+# endif
write_error:
fclose(fp);
if (!write_ok)
semsg(_(e_write_error_in_undo_file_str), file_name);
-#if defined(MSWIN)
+# if defined(MSWIN)
// Copy file attributes; for systems where this can only be done after
// closing the file.
if (buf->b_ffname != NULL)
(void)mch_copy_file_attribute(buf->b_ffname, file_name);
-#endif
-#ifdef HAVE_ACL
+# endif
+# ifdef HAVE_ACL
if (buf->b_ffname != NULL)
{
vim_acl_T acl;
mch_set_acl(file_name, acl);
mch_free_acl(acl);
}
-#endif
+# endif
theend:
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi.bi_state != NULL)
crypt_free_state(bi.bi_state);
vim_free(bi.bi_buffer);
-#endif
+# endif
if (file_name != name)
vim_free(file_name);
}
u_header_T **uhp_table = NULL;
char_u read_hash[UNDO_HASH_SIZE];
char_u magic_buf[UF_START_MAGIC_LEN];
-#ifdef U_DEBUG
+# ifdef U_DEBUG
int *uhp_table_used;
-#endif
-#ifdef UNIX
+# endif
+# ifdef UNIX
stat_T st_orig;
stat_T st_undo;
-#endif
+# endif
bufinfo_T bi;
CLEAR_FIELD(bi);
if (file_name == NULL)
return;
-#ifdef UNIX
+# ifdef UNIX
// For safety we only read an undo file if the owner is equal to the
// owner of the text file or equal to the current user.
if (mch_stat((char *)orig_name, &st_orig) >= 0
}
return;
}
-#endif
+# endif
}
else
file_name = name;
version = get2c(fp);
if (version == UF_VERSION_CRYPT)
{
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (*curbuf->b_p_key == NUL)
{
semsg(_(e_non_encrypted_file_has_encrypted_undo_file_str),
bi.bi_avail = 0;
bi.bi_used = 0;
}
-#else
+# else
semsg(_(e_undo_file_is_encrypted_str), file_name);
goto error;
-#endif
+# endif
}
else if (version != UF_VERSION)
{
goto error;
}
-#ifdef U_DEBUG
+# ifdef U_DEBUG
uhp_table_used = alloc_clear(sizeof(int) * num_head + 1);
-# define SET_FLAG(j) ++uhp_table_used[j]
-#else
-# define SET_FLAG(j)
-#endif
+# define SET_FLAG(j) ++uhp_table_used[j]
+# else
+# define SET_FLAG(j)
+# endif
// We have put all of the headers into a table. Now we iterate through the
// table and swizzle each sequence number we have stored in uh_*_seq into
curbuf->b_u_synced = TRUE;
vim_free(uhp_table);
-#ifdef U_DEBUG
+# ifdef U_DEBUG
for (i = 0; i < num_head; ++i)
if (uhp_table_used[i] == 0)
semsg("uhp_table entry %ld not used, leaking memory", i);
vim_free(uhp_table_used);
u_check(TRUE);
-#endif
+# endif
if (name != NULL)
smsg(_("Finished reading undo file %s"), file_name);
}
theend:
-#ifdef FEAT_CRYPT
+# ifdef FEAT_CRYPT
if (bi.bi_state != NULL)
crypt_free_state(bi.bi_state);
vim_free(bi.bi_buffer);
-#endif
+# endif
if (fp != NULL)
fclose(fp);
if (file_name != name)
return;
rettv->v_type = VAR_STRING;
-#ifdef FEAT_PERSISTENT_UNDO
+# ifdef FEAT_PERSISTENT_UNDO
{
char_u *fname = tv_get_string(&argvars[0]);
vim_free(ffname);
}
}
-#else
+# else
rettv->vval.v_string = NULL;
-#endif
+# endif
}
-#ifdef FEAT_PERSISTENT_UNDO
+# ifdef FEAT_PERSISTENT_UNDO
/*
* Reset undofile option and delete the undofile
*/
set_option_value_give_err((char_u *)"undofile", 0L, NULL, OPT_LOCAL);
}
- #endif
+# endif
/*
* "undotree(expr)" function
cmd_addr_T uc_addr_type; // The command's address type
sctx_T uc_script_ctx; // SCTX where the command was defined
int uc_flags; // some UC_ flags
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
char_u *uc_compl_arg; // completion argument if any
-# endif
+#endif
} ucmd_T;
// List of all user commands.
if (complp != NULL)
*complp = uc->uc_compl;
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
if (xp != NULL)
{
xp->xp_arg = uc->uc_compl_arg;
xp->xp_script_ctx = uc->uc_script_ctx;
xp->xp_script_ctx.sc_lnum += SOURCING_LNUM;
}
-# endif
+#endif
// Do not search for further abbreviations
// if this is an exact match.
matchlen = k;
char_u **compl_arg UNUSED)
{
char_u *arg = NULL;
-# if defined(FEAT_EVAL)
+#if defined(FEAT_EVAL)
size_t arglen = 0;
-# endif
+#endif
int i;
int valend = vallen;
keyvalue_T target;
if (value[i] == ',')
{
arg = &value[i + 1];
-# if defined(FEAT_EVAL)
+#if defined(FEAT_EVAL)
arglen = vallen - i - 1;
-# endif
+#endif
valend = i;
break;
}
*argt |= EX_XFILE;
if (
-# if defined(FEAT_EVAL)
+#if defined(FEAT_EVAL)
*complp != EXPAND_USER_DEFINED && *complp != EXPAND_USER_LIST
&&
-# endif
+#endif
arg != NULL)
{
emsg(_(e_completion_argument_only_allowed_for_custom_completion));
return FAIL;
}
-# if defined(FEAT_EVAL)
+#if defined(FEAT_EVAL)
if ((*complp == EXPAND_USER_DEFINED || *complp == EXPAND_USER_LIST)
&& arg == NULL)
{
if (arg != NULL)
*compl_arg = vim_strnsave(arg, arglen);
-# endif
+#endif
return OK;
}
vim_free(cmd->uc_name);
cmd->uc_namelen = 0;
vim_free(cmd->uc_rep);
-# if defined(FEAT_EVAL)
+#if defined(FEAT_EVAL)
vim_free(cmd->uc_compl_arg);
-# endif
+#endif
}
ga_clear(gap);
}
vim_free(cmd->uc_name);
vim_free(cmd->uc_rep);
-# if defined(FEAT_EVAL)
+#if defined(FEAT_EVAL)
vim_free(cmd->uc_compl_arg);
-# endif
+#endif
--gap->ga_len;
if (*ksp == K_SPECIAL
&& (start == NULL || ksp < start || end == NULL)
&& ((ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
|| (ksp[1] == KS_EXTRA && ksp[2] == (int)KE_CSI)
-# endif
+#endif
))
{
// K_SPECIAL has been put in the buffer as K_SPECIAL
* VAX C can't concatenate strings in the preprocessor.
*/
strcpy(longVersion, VIM_VERSION_LONG_DATE);
-#ifdef BUILD_DATE
+# ifdef BUILD_DATE
strcat(longVersion, BUILD_DATE);
-#else
+# else
strcat(longVersion, __DATE__);
strcat(longVersion, " ");
strcat(longVersion, __TIME__);
-#endif
+# endif
strcat(longVersion, ")");
}
if (longVersion != NULL)
return;
-#ifdef BUILD_DATE
+# ifdef BUILD_DATE
char *date_time = BUILD_DATE;
-#else
+# else
char *date_time = __DATE__ " " __TIME__;
-#endif
+# endif
char *msg = _("%s (%s, compiled %s)");
size_t len = strlen(msg)
+ strlen(VIM_VERSION_LONG_ONLY)
"-X11",
# endif
#endif
-# ifdef FEAT_XATTR
+#ifdef FEAT_XATTR
"+xattr",
-# else
+#else
"-xattr",
-# endif
+#endif
#ifdef FEAT_XFONTSET
"+xfontset",
#else
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2083,
/**/
2082,
/**/
version_msg(_("Compilation: "));
version_msg((char *)all_cflags);
version_msg("\n");
-#ifdef VMS
+# ifdef VMS
if (*compiler_version != NUL)
{
version_msg(_("Compiler: "));
version_msg((char *)compiler_version);
version_msg("\n");
}
-#endif
+# endif
version_msg(_("Linking: "));
version_msg((char *)all_lflags);
#endif
NULL,
NULL,
NULL,
-#ifdef MODIFIED_BY
+# ifdef MODIFIED_BY
NULL,
-#endif
+# endif
NULL,
NULL,
NULL,
// For details see https://github.com/vim/vim-win32-installer/pull/277
// and https://github.com/vim/vim-win32-installer/pull/285
#if VIM_VERSION_PATCHLEVEL < 10
-#define LEADZERO(x) 000 ## x
+# define LEADZERO(x) 000 ## x
#elif VIM_VERSION_PATCHLEVEL < 100
-#define LEADZERO(x) 00 ## x
+# define LEADZERO(x) 00 ## x
#elif VIM_VERSION_PATCHLEVEL < 1000
-#define LEADZERO(x) 0 ## x
+# define LEADZERO(x) 0 ## x
#else
-#define LEADZERO(x) x
+# define LEADZERO(x) x
#endif
#define VIM_VERSION_PATCHLEVEL_STR VIM_TOSTR(LEADZERO(VIM_VERSION_PATCHLEVEL))
*/
#ifndef VIM__H
-# define VIM__H
+#define VIM__H
#include "protodef.h"
* This guard will be removed once the remaining NeXT-specific code paths
* are deleted in a future release.
*/
-#if defined(NeXT) || defined(__NeXT__)
-# error "NeXTSTEP / OPENSTEP support has been deprecated."
-#endif
+# if defined(NeXT) || defined(__NeXT__)
+# error "NeXTSTEP / OPENSTEP support has been deprecated."
+# endif
# if (defined(__linux__) && !defined(__ANDROID__)) || defined(__CYGWIN__) || defined(__GNU__)
// Needed for strptime(). Needs to be done early, since header files can
# endif
#endif
#if defined(MACOS_X) && !defined(HAVE_CONFIG_H)
-# define VIM_SIZEOF_INT __SIZEOF_INT__
+# define VIM_SIZEOF_INT __SIZEOF_INT__
#endif
#if VIM_SIZEOF_INT < 4 && !defined(PROTO)
# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
# endif
-# define BUFFER_ESC_CHARS ((char_u *)" \t\n*?[`$\\%#'\"|!<")
+# define BUFFER_ESC_CHARS ((char_u *)" \t\n*?[`$\\%#'\"|!<")
#endif
// length of a buffer to store a number in ASCII (64 bits binary + NUL)
// STRICMP() only handles the system locale version, which often does not
// handle non-ascii properly.
-# define MB_STRICMP(d, s) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL)
-# define MB_STRNICMP(d, s, n) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n))
-# define MB_STRNICMP2(d, s, n1, n2) mb_strnicmp2((char_u *)(d), (char_u *)(s), (n1), (n2))
+#define MB_STRICMP(d, s) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL)
+#define MB_STRNICMP(d, s, n) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n))
+#define MB_STRNICMP2(d, s, n1, n2) mb_strnicmp2((char_u *)(d), (char_u *)(s), (n1), (n2))
#define STRCAT(d, s) strcat((char *)(d), (char *)(s))
#define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
* bits elsewhere. That causes memory corruption. Define time_T and use it
* for global variables to avoid that.
*/
-# ifdef MSWIN
+#ifdef MSWIN
typedef __time64_t time_T;
-# else
+#else
typedef time_t time_T;
-# endif
+#endif
#ifdef _WIN64
typedef __int64 sock_T;
short_u origin_end_col;
short_u word_start_col;
short_u word_end_col;
-#ifdef FEAT_PROP_POPUP
+# ifdef FEAT_PROP_POPUP
// limits for selection inside a popup window
short_u min_col;
short_u max_col;
short_u min_row;
short_u max_row;
-#endif
+# endif
pos_T prev; // Previous position
short_u state; // Current selection state
# define USE_MCH_ERRMSG
#endif
-# if defined(FEAT_EVAL) \
+#if defined(FEAT_EVAL) \
&& (!defined(FEAT_GUI_MSWIN) || !defined(FEAT_MBYTE_IME))
// Whether IME is supported by im_get_status() defined in mbyte.c.
// For Win32 GUI it's in gui_w32.c when FEAT_MBYTE_IME is defined.
#ifdef _MSC_VER
// Avoid useless warning "conversion from X to Y of greater size".
- #pragma warning(disable : 4312)
+# pragma warning(disable : 4312)
// Avoid warning for old style function declarators
- #pragma warning(disable : 4131)
+# pragma warning(disable : 4131)
// Avoid warning for conversion to type with smaller range
- #pragma warning(disable : 4244)
+# pragma warning(disable : 4244)
// Avoid warning for conversion to larger size
- #pragma warning(disable : 4306)
+# pragma warning(disable : 4306)
// Avoid warning for unreferenced formal parameter
- #pragma warning(disable : 4100)
+# pragma warning(disable : 4100)
// Avoid warning for differs in indirection to slightly different base type
- #pragma warning(disable : 4057)
+# pragma warning(disable : 4057)
// Avoid warning for constant conditional expression
- #pragma warning(disable : 4127)
+# pragma warning(disable : 4127)
// Avoid warning for assignment within conditional
- #pragma warning(disable : 4706)
+# pragma warning(disable : 4706)
#endif
// Note: a NULL argument for vim_realloc() is not portable, don't use it.
++viminfo_errcnt;
semsg(_(e_cant_rename_viminfo_file_to_str), fname);
}
-# ifdef MSWIN
+#ifdef MSWIN
// If the viminfo file was hidden then also hide the new file.
else if (hidden)
mch_hide(fname);
-# endif
+#endif
}
if (viminfo_errcnt > 0)
mch_remove(tempname);
static void
vwl_connection_destroy(vwl_connection_T *self)
{
-#ifdef FEAT_WAYLAND_CLIPBOARD
+# ifdef FEAT_WAYLAND_CLIPBOARD
VWL_DESTROY_GOBJECT(self, ext_data_control_manager_v1)
VWL_DESTROY_GOBJECT(self, zwlr_data_control_manager_v1)
-# ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
VWL_DESTROY_GOBJECT(self, wl_data_device_manager)
VWL_DESTROY_GOBJECT(self, wl_shm)
VWL_DESTROY_GOBJECT(self, wl_compositor)
VWL_DESTROY_GOBJECT(self, xdg_wm_base)
VWL_DESTROY_GOBJECT(self, zwp_primary_selection_device_manager_v1)
+# endif
# endif
-#endif
for (int i = 0; i < self->gobjects.seats.ga_len; i++)
vwl_seat_destroy(((vwl_seat_T **)self->gobjects.seats.ga_data)[i]);
return NULL;
}
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
/*
* Get keyboard object from seat and return it. NULL is returned on
* failure such as when a keyboard is not available for seat.
return wl_seat_get_keyboard(self->proxy);
}
-#endif
+# endif
#endif
if (zwlr_data_control_manager_v1_get_version(manager->proxy) >= 2)
*supported |= WAYLAND_SELECTION_PRIMARY;
}
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
else if (self->gobjects.wl_data_device_manager != NULL
&& req_sel == WAYLAND_SELECTION_REGULAR)
{
*supported |= WAYLAND_SELECTION_PRIMARY;
}
-#endif
+# endif
if (!(*supported & req_sel))
{
device->proxy = zwlr_data_control_manager_v1_get_data_device(
self->proxy, seat->proxy);
break;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
case VWL_DATA_PROTOCOL_CORE:
device->proxy = wl_data_device_manager_get_data_device(
self->proxy, seat->proxy);
device->proxy = zwp_primary_selection_device_manager_v1_get_device(
self->proxy, seat->proxy);
break;
-#endif
+# endif
default:
vim_free(device);
return NULL;
source->proxy = zwlr_data_control_manager_v1_create_data_source(
self->proxy);
break;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
case VWL_DATA_PROTOCOL_CORE:
source->proxy = wl_data_device_manager_create_data_source(
self->proxy);
zwp_primary_selection_device_manager_v1_create_source(
self->proxy);
break;
-#endif
+# endif
default:
vim_free(source);
return NULL;
return offer;
}
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
-# define VWL_CODE_DATA_PROXY_FS_DESTROY(type) \
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# define VWL_CODE_DATA_PROXY_FS_DESTROY(type) \
case VWL_DATA_PROTOCOL_CORE: \
wl_data_##type##_destroy(self->proxy); \
break; \
case VWL_DATA_PROTOCOL_PRIMARY: \
zwp_primary_selection_##type##_v1_destroy(self->proxy); \
break;
-#else
-# define VWL_CODE_DATA_PROXY_FS_DESTROY(type)
-#endif
+# else
+# define VWL_CODE_DATA_PROXY_FS_DESTROY(type)
+# endif
-#define VWL_FUNC_DATA_PROXY_DESTROY(type) \
+# define VWL_FUNC_DATA_PROXY_DESTROY(type) \
void \
vwl_data_##type##_destroy(vwl_data_##type##_T *self) \
{ \
case VWL_DATA_PROTOCOL_WLR:
zwlr_data_control_offer_v1_destroy(self->proxy);
break;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
case VWL_DATA_PROTOCOL_CORE:
wl_data_offer_destroy(self->proxy);
break;
case VWL_DATA_PROTOCOL_PRIMARY:
zwp_primary_selection_offer_v1_destroy(self->proxy);
break;
-#endif
+# endif
default:
break;
}
vim_free(self);
}
-#define VWL_FUNC_DATA_DEVICE_EVENT_DATA_OFFER(device_type, offer_type) \
+# define VWL_FUNC_DATA_DEVICE_EVENT_DATA_OFFER(device_type, offer_type) \
static void \
device_type##_listener_event_data_offer( \
void *data, \
// We want to set the offer to NULL after the selection callback, because the
// callback may free the offer, and we don't want a dangling pointer.
-#define VWL_FUNC_DATA_DEVICE_EVENT_SELECTION(device_type, offer_type) \
+# define VWL_FUNC_DATA_DEVICE_EVENT_SELECTION(device_type, offer_type) \
static void \
device_type##_listener_event_selection( \
void *data, \
self->offer = NULL; \
} \
-#define VWL_FUNC_DATA_DEVICE_EVENT_PRIMARY_SELECTION(device_type, offer_type) \
+# define VWL_FUNC_DATA_DEVICE_EVENT_PRIMARY_SELECTION(device_type, offer_type) \
static void \
device_type##_listener_event_primary_selection( \
void *data, \
self->offer = NULL; \
}
-#define VWL_FUNC_DATA_DEVICE_EVENT_FINISHED(device_type) \
+# define VWL_FUNC_DATA_DEVICE_EVENT_FINISHED(device_type) \
static void \
device_type##_listener_event_finished( \
void *data, \
ext_data_control_device_v1, ext_data_control_offer_v1)
VWL_FUNC_DATA_DEVICE_EVENT_DATA_OFFER(
zwlr_data_control_device_v1, zwlr_data_control_offer_v1)
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
VWL_FUNC_DATA_DEVICE_EVENT_DATA_OFFER(wl_data_device, wl_data_offer)
VWL_FUNC_DATA_DEVICE_EVENT_DATA_OFFER(
zwp_primary_selection_device_v1, zwp_primary_selection_offer_v1)
-#endif
+# endif
VWL_FUNC_DATA_DEVICE_EVENT_SELECTION(
ext_data_control_device_v1, ext_data_control_offer_v1
VWL_FUNC_DATA_DEVICE_EVENT_PRIMARY_SELECTION(
zwlr_data_control_device_v1, zwlr_data_control_offer_v1
)
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
VWL_FUNC_DATA_DEVICE_EVENT_SELECTION(
wl_data_device, wl_data_offer
)
VWL_FUNC_DATA_DEVICE_EVENT_PRIMARY_SELECTION(
zwp_primary_selection_device_v1, zwp_primary_selection_offer_v1)
-#endif
+# endif
VWL_FUNC_DATA_DEVICE_EVENT_FINISHED(ext_data_control_device_v1)
VWL_FUNC_DATA_DEVICE_EVENT_FINISHED(zwlr_data_control_device_v1)
zwlr_data_control_device_v1_listener_event_primary_selection,
.finished = zwlr_data_control_device_v1_listener_event_finished
};
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
static const struct wl_data_device_listener wl_data_device_listener = {
.data_offer = wl_data_device_listener_event_data_offer,
.selection = wl_data_device_listener_event_selection,
.selection =
zwp_primary_selection_device_v1_listener_event_primary_selection,
};
-# endif
+# endif
-# define VWL_FUNC_DATA_SOURCE_EVENT_SEND(source_type) \
+# define VWL_FUNC_DATA_SOURCE_EVENT_SEND(source_type) \
static void \
source_type##_listener_event_send( \
void *data, struct source_type *source UNUSED, \
self->listener->send(self->data, self, mime_type, fd); \
}
-# define VWL_FUNC_DATA_SOURCE_EVENT_CANCELLED(source_type) \
+# define VWL_FUNC_DATA_SOURCE_EVENT_CANCELLED(source_type) \
static void \
source_type##_listener_event_cancelled( \
void *data, struct source_type *source UNUSED) \
VWL_FUNC_DATA_SOURCE_EVENT_SEND(ext_data_control_source_v1)
VWL_FUNC_DATA_SOURCE_EVENT_SEND(zwlr_data_control_source_v1)
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
VWL_FUNC_DATA_SOURCE_EVENT_SEND(wl_data_source)
VWL_FUNC_DATA_SOURCE_EVENT_SEND(zwp_primary_selection_source_v1)
-#endif
+# endif
VWL_FUNC_DATA_SOURCE_EVENT_CANCELLED(ext_data_control_source_v1)
VWL_FUNC_DATA_SOURCE_EVENT_CANCELLED(zwlr_data_control_source_v1)
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
VWL_FUNC_DATA_SOURCE_EVENT_CANCELLED(wl_data_source)
VWL_FUNC_DATA_SOURCE_EVENT_CANCELLED(zwp_primary_selection_source_v1)
-#endif
+# endif
static const struct ext_data_control_source_v1_listener
ext_data_control_source_v1_listener = {
.send = zwlr_data_control_source_v1_listener_event_send,
.cancelled = zwlr_data_control_source_v1_listener_event_cancelled
};
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
static const struct wl_data_source_listener wl_data_source_listener = {
.send = wl_data_source_listener_event_send,
.cancelled = wl_data_source_listener_event_cancelled
.send = zwp_primary_selection_source_v1_listener_event_send,
.cancelled = zwp_primary_selection_source_v1_listener_event_cancelled
};
-#endif
+# endif
-#define VWL_FUNC_DATA_OFFER_EVENT_OFFER(offer_type) \
+# define VWL_FUNC_DATA_OFFER_EVENT_OFFER(offer_type) \
static void \
offer_type##_listener_event_offer( \
void *data, \
VWL_FUNC_DATA_OFFER_EVENT_OFFER(ext_data_control_offer_v1)
VWL_FUNC_DATA_OFFER_EVENT_OFFER(zwlr_data_control_offer_v1)
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
VWL_FUNC_DATA_OFFER_EVENT_OFFER(wl_data_offer)
VWL_FUNC_DATA_OFFER_EVENT_OFFER(zwp_primary_selection_offer_v1)
-#endif
+# endif
static const struct ext_data_control_offer_v1_listener
ext_data_control_offer_v1_listener = {
zwlr_data_control_offer_v1_listener = {
.offer = zwlr_data_control_offer_v1_listener_event_offer
};
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
static const struct wl_data_offer_listener
wl_data_offer_listener = {
.offer = wl_data_offer_listener_event_offer
zwp_primary_selection_offer_v1_listener = {
.offer = zwp_primary_selection_offer_v1_listener_event_offer
};
-#endif
+# endif
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
-# define VWL_CODE_DATA_PROXY_FS_ADD_LISTENER(type) \
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# define VWL_CODE_DATA_PROXY_FS_ADD_LISTENER(type) \
case VWL_DATA_PROTOCOL_CORE: \
wl_data_##type##_add_listener(self->proxy, \
&wl_data_##type##_listener, self); \
zwp_primary_selection_##type##_v1_add_listener(self->proxy, \
&zwp_primary_selection_##type##_v1_listener, self); \
break;
-#else
-# define VWL_CODE_DATA_PROXY_FS_ADD_LISTENER(type)
-#endif
+# else
+# define VWL_CODE_DATA_PROXY_FS_ADD_LISTENER(type)
+# endif
-#define VWL_FUNC_DATA_PROXY_ADD_LISTENER(type) \
+# define VWL_FUNC_DATA_PROXY_ADD_LISTENER(type) \
void \
vwl_data_##type##_add_listener( \
vwl_data_##type##_T *self, \
case VWL_DATA_PROTOCOL_WLR:
zwlr_data_control_device_v1_set_selection(self->proxy, proxy);
break;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
case VWL_DATA_PROTOCOL_CORE:
wl_data_device_set_selection(self->proxy, proxy, serial);
break;
-#endif
+# endif
default:
break;
}
self->proxy, proxy
);
break;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
case VWL_DATA_PROTOCOL_PRIMARY:
zwp_primary_selection_device_v1_set_selection(
self->proxy, proxy, serial);
break;
-#endif
+# endif
default:
break;
}
case VWL_DATA_PROTOCOL_WLR:
zwlr_data_control_source_v1_offer(self->proxy, mime_type);
break;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
case VWL_DATA_PROTOCOL_CORE:
wl_data_source_offer(self->proxy, mime_type);
break;
case VWL_DATA_PROTOCOL_PRIMARY:
zwp_primary_selection_source_v1_offer(self->proxy, mime_type);
break;
-#endif
+# endif
default:
break;
}
case VWL_DATA_PROTOCOL_WLR:
zwlr_data_control_offer_v1_receive(self->proxy, mime_type, fd);
break;
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
case VWL_DATA_PROTOCOL_CORE:
wl_data_offer_receive(self->proxy, mime_type, fd);
break;
case VWL_DATA_PROTOCOL_PRIMARY:
zwp_primary_selection_offer_v1_receive(self->proxy, mime_type, fd);
break;
-#endif
+# endif
default:
break;
}
VWL_DATA_PROTOCOL_NONE,
VWL_DATA_PROTOCOL_EXT,
VWL_DATA_PROTOCOL_WLR,
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
VWL_DATA_PROTOCOL_CORE,
VWL_DATA_PROTOCOL_PRIMARY
-#endif
+# endif
} vwl_data_protocol_T;
#endif // FEAT_WAYLAND_CLIPBOARD
vwl_data_protocol_T protocol;
};
-#ifdef FEAT_WAYLAND_CLIPBOARD_FS
+# ifdef FEAT_WAYLAND_CLIPBOARD_FS
// Dummy functions to handle keyboard events we don't care about.
-#define VWL_FUNCS_DUMMY_KEYBOARD_EVENTS() \
+# define VWL_FUNCS_DUMMY_KEYBOARD_EVENTS() \
static void \
clip_wl_fs_keyboard_listener_keymap( \
void *data UNUSED, \
{ \
}
-#endif
+# endif
#endif // FEAT_WAYLAND_CLIPBOARD
if (size != 0)
p_wiw = size;
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
// When 'guioptions' includes 'L' or 'R' may have to add scrollbars.
if (gui.in_use)
gui_init_which_components(NULL);
-# endif
+#endif
}
else
{
tv.vval.v_number = topline;
if (dict_add_tv(d, "topline", &tv) == FAIL)
break;
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
tv.vval.v_number = topfill;
-#else
+# else
tv.vval.v_number = 0;
-#endif
+# endif
if (dict_add_tv(d, "topfill", &tv) == FAIL)
break;
tv.vval.v_number = leftcol;
int width = wp->w_width - wp->w_last_width;
int height = wp->w_height - wp->w_last_height;
int topline = wp->w_topline - wp->w_last_topline;
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
int topfill = wp->w_topfill - wp->w_last_topfill;
-#endif
+# endif
int leftcol = wp->w_leftcol - wp->w_last_leftcol;
int skipcol = wp->w_skipcol - wp->w_last_skipcol;
dict_T *d = make_win_info_dict(width, height, topline,
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
topfill,
-#endif
+# endif
leftcol, skipcol);
if (d == NULL)
break;
tot_width += abs(width);
tot_height += abs(height);
tot_topline += abs(topline);
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
tot_topfill += abs(topfill);
-#endif
+# endif
tot_leftcol += abs(leftcol);
tot_skipcol += abs(skipcol);
}
alloc_tabpage(void)
{
tabpage_T *tp;
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
int i;
-# endif
+#endif
tp = ALLOC_CLEAR_ONE(tabpage_T);
if (tp == NULL)
return NULL;
-# ifdef FEAT_EVAL
+#ifdef FEAT_EVAL
// init t: variables
tp->tp_vars = dict_alloc_id(aid_newtabpage_tvars);
if (tp->tp_vars == NULL)
return NULL;
}
init_var_dict(tp->tp_vars, &tp->tp_winvar, VAR_SCOPE);
-# endif
+#endif
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
for (i = 0; i < 3; i++)
tp->tp_prev_which_scrollbars[i] = -1;
-# endif
-# ifdef FEAT_DIFF
+#endif
+#ifdef FEAT_DIFF
tp->tp_diff_invalid = TRUE;
-# endif
+#endif
tp->tp_ch_used = p_ch;
return tp;
{
int idx;
-# ifdef FEAT_DIFF
+#ifdef FEAT_DIFF
diff_clear(tp);
-# endif
-# ifdef FEAT_PROP_POPUP
+#endif
+#ifdef FEAT_PROP_POPUP
while (tp->tp_first_popupwin != NULL)
popup_close_tabpage(tp, tp->tp_first_popupwin->w_id, TRUE);
#endif
if (curtab == tp && win_valid(wp))
{
win_enter(wp, TRUE);
-# ifdef FEAT_GUI_TABLINE
+#ifdef FEAT_GUI_TABLINE
if (gui_use_tabline())
gui_mch_set_curtab(tabpage_index(curtab));
-# endif
+#endif
}
}
FOR_ALL_WINDOWS(wp)
if (wp->w_buffer != NULL
&& (!((bt_help(wp->w_buffer) && !bt_help(curbuf))
-# ifdef FEAT_QUICKFIX
+#ifdef FEAT_QUICKFIX
|| wp->w_p_pvw
-# endif
+#endif
) || wp == curwin) && !is_aucmd_win(wp))
++count;
return (count <= 1);
* FILE is defined on OS 4.x, not on 5.x (Solaris).
* if __SVR4 is defined (some Solaris versions), don't include this.
*/
-#if defined(sun) && defined(FILE) && !defined(__SVR4) && defined(__STDC__)
+# if defined(sun) && defined(FILE) && !defined(__SVR4) && defined(__STDC__)
# define __P(a) a
/* excerpt from my sun_stdlib.h */
extern int fprintf __P((FILE *, char *, ...));
}
else /* ASCII */
{
- #if defined(__MVS__) && __CHARSET_LIB == 0
+#if defined(__MVS__) && __CHARSET_LIB == 0
if (e >= 64)
return COLOR_GREEN;
- #else
+#else
if (e > 31 && e < 127)
return COLOR_GREEN;
- #endif
+#endif
else if (e == 9 || e == 10 || e == 13)
return COLOR_YELLOW;