Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged from the latest developing branch.

git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1447 2a77ed30-b011-0410-a7ad-c7884a0aa172
  • Loading branch information...
commit a0107f3d4adb58ced858751751c7d350b52c9691 1 parent 57ef8dc
edyfox authored
View
246 src/ex_cmds.c
@@ -6543,20 +6543,7 @@ static int last_sign_typenr = MAX_TYPENR; /* is decremented */
static void sign_list_defined __ARGS((sign_T *sp));
static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev));
-/*
- * ":sign" command
- */
- void
-ex_sign(eap)
- exarg_T *eap;
-{
- char_u *arg = eap->arg;
- char_u *p;
- int idx;
- sign_T *sp;
- sign_T *sp_prev;
- buf_T *buf;
- static char *cmds[] = {
+static char *cmds[] = {
"define",
#define SIGNCMD_DEFINE 0
"undefine",
@@ -6569,22 +6556,51 @@ ex_sign(eap)
#define SIGNCMD_UNPLACE 4
"jump",
#define SIGNCMD_JUMP 5
+ NULL
#define SIGNCMD_LAST 6
- };
+};
+
+/*
+ * Find index of a ":sign" subcmd from its name.
+ * "*end_cmd" must be writable.
+ */
+ static int
+sign_cmd_idx(begin_cmd, end_cmd)
+ char *begin_cmd; /* begin of sign subcmd */
+ char *end_cmd; /* just after sign subcmd */
+{
+ int idx;
+ char save = *end_cmd;
+
+ *end_cmd = NUL;
+ for (idx = 0; ; ++idx)
+ if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0)
+ break;
+ *end_cmd = save;
+ return idx;
+}
+
+/*
+ * ":sign" command
+ */
+ void
+ex_sign(eap)
+ exarg_T *eap;
+{
+ char_u *arg = eap->arg;
+ char_u *p;
+ int idx;
+ sign_T *sp;
+ sign_T *sp_prev;
+ buf_T *buf;
/* Parse the subcommand. */
p = skiptowhite(arg);
- if (*p != NUL)
- *p++ = NUL;
- for (idx = 0; ; ++idx)
+ idx = sign_cmd_idx(arg, p);
+ if (idx == SIGNCMD_LAST)
{
- if (idx == SIGNCMD_LAST)
- {
- EMSG2(_("E160: Unknown sign command: %s"), arg);
- return;
- }
- if (STRCMP(arg, cmds[idx]) == 0)
- break;
+ EMSG2(_("E160: Unknown sign command: %s"), arg);
+ return;
}
arg = skipwhite(p);
@@ -7110,6 +7126,186 @@ free_signs()
}
#endif
+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
+static enum
+{
+ EXP_SUBCMD, /* expand :sign sub-commands */
+ EXP_DEFINE, /* expand :sign define {name} args */
+ EXP_PLACE, /* expand :sign place {id} args */
+ EXP_UNPLACE, /* expand :sign unplace" */
+ EXP_SIGN_NAMES /* expand with name of placed signs */
+} expand_what;
+
+/*
+ * Function given to ExpandGeneric() to obtain the sign command
+ * expansion.
+ */
+/*ARGSUSED*/
+ char_u *
+get_sign_name(xp, idx)
+ expand_T *xp;
+ int idx;
+{
+ sign_T *sp;
+ int current_idx;
+
+ switch (expand_what)
+ {
+ case EXP_SUBCMD:
+ return (char_u *)cmds[idx];
+ case EXP_DEFINE:
+ {
+ char *define_arg[] =
+ {
+ "icon=", "linehl=", "text=", "texthl=", NULL
+ };
+ return (char_u *)define_arg[idx];
+ }
+ case EXP_PLACE:
+ {
+ char *place_arg[] =
+ {
+ "line=", "name=", "file=", "buffer=", NULL
+ };
+ return (char_u *)place_arg[idx];
+ }
+ case EXP_UNPLACE:
+ {
+ char *unplace_arg[] = { "file=", "buffer=", NULL };
+ return (char_u *)unplace_arg[idx];
+ }
+ case EXP_SIGN_NAMES:
+ /* Complete with name of signs already defined */
+ current_idx = 0;
+ for (sp = first_sign; sp != NULL; sp = sp->sn_next)
+ if (current_idx++ == idx)
+ return sp->sn_name;
+ return NULL;
+ default:
+ return NULL;
+ }
+}
+
+/*
+ * Handle command line completion for :sign command.
+ */
+ void
+set_context_in_sign_cmd(xp, arg)
+ expand_T *xp;
+ char_u *arg;
+{
+ char_u *p;
+ char_u *end_subcmd;
+ char_u *last;
+ int cmd_idx;
+ char_u *begin_subcmd_args;
+
+ /* Default: expand subcommands. */
+ xp->xp_context = EXPAND_SIGN;
+ expand_what = EXP_SUBCMD;
+ xp->xp_pattern = arg;
+
+ end_subcmd = skiptowhite(arg);
+ if (*end_subcmd == NUL)
+ /* expand subcmd name
+ * :sign {subcmd}<CTRL-D>*/
+ return;
+
+ cmd_idx = sign_cmd_idx(arg, end_subcmd);
+
+ /* :sign {subcmd} {subcmd_args}
+ * |
+ * begin_subcmd_args */
+ begin_subcmd_args = skipwhite(end_subcmd);
+ p = skiptowhite(begin_subcmd_args);
+ if (*p == NUL)
+ {
+ /*
+ * Expand first argument of subcmd when possible.
+ * For ":jump {id}" and ":unplace {id}", we could
+ * possibly expand the ids of all signs already placed.
+ */
+ xp->xp_pattern = begin_subcmd_args;
+ switch (cmd_idx)
+ {
+ case SIGNCMD_LIST:
+ case SIGNCMD_UNDEFINE:
+ /* :sign list <CTRL-D>
+ * :sign undefine <CTRL-D> */
+ expand_what = EXP_SIGN_NAMES;
+ break;
+ default:
+ xp->xp_context = EXPAND_NOTHING;
+ }
+ return;
+ }
+
+ /* expand last argument of subcmd */
+
+ /* :sign define {name} {args}...
+ * |
+ * p */
+
+ /* Loop until reaching last argument. */
+ do
+ {
+ p = skipwhite(p);
+ last = p;
+ p = skiptowhite(p);
+ } while (*p != NUL);
+
+ p = vim_strchr(last, '=');
+
+ /* :sign define {name} {args}... {last}=
+ * | |
+ * last p */
+ if (p == NUL)
+ {
+ /* Expand last argument name (before equal sign). */
+ xp->xp_pattern = last;
+ switch (cmd_idx)
+ {
+ case SIGNCMD_DEFINE:
+ expand_what = EXP_DEFINE;
+ break;
+ case SIGNCMD_PLACE:
+ expand_what = EXP_PLACE;
+ break;
+ case SIGNCMD_JUMP:
+ case SIGNCMD_UNPLACE:
+ expand_what = EXP_UNPLACE;
+ break;
+ default:
+ xp->xp_context = EXPAND_NOTHING;
+ }
+ }
+ else
+ {
+ /* Expand last argument value (after equal sign). */
+ xp->xp_pattern = p + 1;
+ switch (cmd_idx)
+ {
+ case SIGNCMD_DEFINE:
+ if (STRNCMP(last, "texthl", p - last) == 0 ||
+ STRNCMP(last, "linehl", p - last) == 0)
+ xp->xp_context = EXPAND_HIGHLIGHT;
+ else if (STRNCMP(last, "icon", p - last) == 0)
+ xp->xp_context = EXPAND_FILES;
+ else
+ xp->xp_context = EXPAND_NOTHING;
+ break;
+ case SIGNCMD_PLACE:
+ if (STRNCMP(last, "name", p - last) == 0)
+ expand_what = EXP_SIGN_NAMES;
+ else
+ xp->xp_context = EXPAND_NOTHING;
+ break;
+ default:
+ xp->xp_context = EXPAND_NOTHING;
+ }
+ }
+}
+#endif
#endif
#if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO)
View
8 src/ex_docmd.c
@@ -3695,6 +3695,11 @@ set_one_cmd_context(xp, buff)
set_context_in_cscope_cmd(xp, arg, ea.cmdidx);
break;
#endif
+#ifdef FEAT_SIGNS
+ case CMD_sign:
+ set_context_in_sign_cmd(xp, arg);
+ break;
+#endif
#ifdef FEAT_LISTCMDS
case CMD_bdelete:
case CMD_bwipeout:
@@ -5218,6 +5223,9 @@ static struct
{EXPAND_MENUS, "menu"},
{EXPAND_SETTINGS, "option"},
{EXPAND_SHELLCMD, "shellcmd"},
+#if defined(FEAT_SIGNS)
+ {EXPAND_SIGN, "sign"},
+#endif
{EXPAND_TAGS, "tag"},
{EXPAND_TAGS_LISTFILES, "tag_listfiles"},
{EXPAND_USER_VARS, "var"},
View
8 src/ex_getln.c
@@ -325,7 +325,7 @@ getcmdline(firstc, count, indent)
#endif
#ifdef FEAT_DIGRAPHS
- do_digraph(-1); /* init digraph typahead */
+ do_digraph(-1); /* init digraph typeahead */
#endif
/*
@@ -4521,6 +4521,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
#ifdef FEAT_CSCOPE
{EXPAND_CSCOPE, get_cscope_name, TRUE},
#endif
+#ifdef FEAT_SIGNS
+ {EXPAND_SIGN, get_sign_name, TRUE},
+#endif
#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
{EXPAND_LANGUAGE, get_lang_arg, TRUE},
@@ -6073,6 +6076,9 @@ ex_window()
set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
curbuf->b_p_ma = TRUE;
+#ifdef FEAT_FOLDING
+ curwin->w_p_fen = FALSE;
+#endif
# ifdef FEAT_RIGHTLEFT
curwin->w_p_rl = cmdmsg_rl;
cmdmsg_rl = FALSE;
View
9 src/fileio.c
@@ -6846,10 +6846,11 @@ buf_reload(buf, orig_mode)
#endif
#ifdef FEAT_FOLDING
{
- win_T *wp;
+ win_T *wp;
+ tabpage_T *tp;
/* Update folds unless they are defined manually. */
- FOR_ALL_WINDOWS(wp)
+ FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer == curwin->w_buffer
&& !foldmethodIsManual(wp))
foldUpdateAll(wp);
@@ -8784,9 +8785,11 @@ apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
else
{
sfname = vim_strsave(fname);
- /* Don't try expanding FileType, Syntax, WindowID or QuickFixCmd* */
+ /* Don't try expanding FileType, Syntax, FuncUndefined, WindowID or
+ * QuickFixCmd* */
if (event == EVENT_FILETYPE
|| event == EVENT_SYNTAX
+ || event == EVENT_FUNCUNDEFINED
|| event == EVENT_REMOTEREPLY
|| event == EVENT_SPELLFILEMISSING
|| event == EVENT_QUICKFIXCMDPRE
View
7 src/mark.c
@@ -1023,6 +1023,9 @@ mark_adjust(line1, line2, amount, amount_after)
int fnum = curbuf->b_fnum;
linenr_T *lp;
win_T *win;
+#ifdef FEAT_WINDOWS
+ tabpage_T *tab;
+#endif
if (line2 < line1 && amount_after == 0L) /* nothing to do */
return;
@@ -1064,7 +1067,7 @@ mark_adjust(line1, line2, amount, amount_after)
/* quickfix marks */
qf_mark_adjust(NULL, line1, line2, amount, amount_after);
/* location lists */
- FOR_ALL_WINDOWS(win)
+ FOR_ALL_TAB_WINDOWS(tab, win)
qf_mark_adjust(win, line1, line2, amount, amount_after);
#endif
@@ -1086,7 +1089,7 @@ mark_adjust(line1, line2, amount, amount_after)
/*
* Adjust items in all windows related to the current buffer.
*/
- FOR_ALL_WINDOWS(win)
+ FOR_ALL_TAB_WINDOWS(tab, win)
{
#ifdef FEAT_JUMPLIST
if (!cmdmod.lockmarks)
View
9 src/misc1.c
@@ -2717,6 +2717,9 @@ changed_common(lnum, col, lnume, xtra)
long xtra;
{
win_T *wp;
+#ifdef FEAT_WINDOWS
+ tabpage_T *tp;
+#endif
int i;
#ifdef FEAT_JUMPLIST
int cols;
@@ -2769,7 +2772,7 @@ changed_common(lnum, col, lnume, xtra)
curbuf->b_changelistlen = JUMPLISTSIZE - 1;
mch_memmove(curbuf->b_changelist, curbuf->b_changelist + 1,
sizeof(pos_T) * (JUMPLISTSIZE - 1));
- FOR_ALL_WINDOWS(wp)
+ FOR_ALL_TAB_WINDOWS(tp, wp)
{
/* Correct position in changelist for other windows on
* this buffer. */
@@ -2777,7 +2780,7 @@ changed_common(lnum, col, lnume, xtra)
--wp->w_changelistidx;
}
}
- FOR_ALL_WINDOWS(wp)
+ FOR_ALL_TAB_WINDOWS(tp, wp)
{
/* For other windows, if the position in the changelist is
* at the end it stays at the end. */
@@ -2796,7 +2799,7 @@ changed_common(lnum, col, lnume, xtra)
#endif
}
- FOR_ALL_WINDOWS(wp)
+ FOR_ALL_TAB_WINDOWS(tp, wp)
{
if (wp->w_buffer == curbuf)
{
View
5 src/misc2.c
@@ -1075,11 +1075,12 @@ free_all_mem()
#ifdef FEAT_QUICKFIX
{
- win_T *win;
+ win_T *win;
+ tabpage_T *tab;
qf_free_all(NULL);
/* Free all location lists */
- FOR_ALL_WINDOWS(win)
+ FOR_ALL_TAB_WINDOWS(tab, win)
qf_free_all(win);
}
#endif
View
15 src/normal.c
@@ -3709,13 +3709,13 @@ clear_showcmd()
#ifdef FEAT_VISUAL
if (VIsual_active && !char_avail())
{
- int i = lt(VIsual, curwin->w_cursor);
+ int cursor_bot = lt(VIsual, curwin->w_cursor);
long lines;
colnr_T leftcol, rightcol;
linenr_T top, bot;
/* Show the size of the Visual area. */
- if (i)
+ if (cursor_bot)
{
top = VIsual.lnum;
bot = curwin->w_cursor.lnum;
@@ -3734,14 +3734,23 @@ clear_showcmd()
if (VIsual_mode == Ctrl_V)
{
+#ifdef FEAT_LINEBREAK
+ char_u *saved_sbr = p_sbr;
+
+ /* Make 'sbr' empty for a moment to get the correct size. */
+ p_sbr = empty_option;
+#endif
getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol);
+#ifdef FEAT_LINEBREAK
+ p_sbr = saved_sbr;
+#endif
sprintf((char *)showcmd_buf, "%ldx%ld", lines,
(long)(rightcol - leftcol + 1));
}
else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum)
sprintf((char *)showcmd_buf, "%ld", lines);
else
- sprintf((char *)showcmd_buf, "%ld", (long)(i
+ sprintf((char *)showcmd_buf, "%ld", (long)(cursor_bot
? curwin->w_cursor.col - VIsual.col
: VIsual.col - curwin->w_cursor.col) + (*p_sel != 'e'));
showcmd_buf[SHOWCMD_COLS] = NUL; /* truncate */
View
10 src/ops.c
@@ -392,7 +392,6 @@ shift_block(oap, amount)
colnr_T ws_vcol;
int i = 0, j = 0;
int len;
-
#ifdef FEAT_RIGHTLEFT
int old_p_ri = p_ri;
@@ -6284,11 +6283,20 @@ cursor_pos_info()
if (VIsual_mode == Ctrl_V)
{
+#ifdef FEAT_LINEBREAK
+ char_u * saved_sbr = p_sbr;
+
+ /* Make 'sbr' empty for a moment to get the correct size. */
+ p_sbr = empty_option;
+#endif
oparg.is_VIsual = 1;
oparg.block_mode = TRUE;
oparg.op_type = OP_NOP;
getvcols(curwin, &min_pos, &max_pos,
&oparg.start_vcol, &oparg.end_vcol);
+#ifdef FEAT_LINEBREAK
+ p_sbr = saved_sbr;
+#endif
if (curwin->w_curswant == MAXCOL)
oparg.end_vcol = MAXCOL;
/* Swap the start, end vcol if needed */
View
4 src/proto/ex_cmds.pro
@@ -40,7 +40,6 @@ void global_exe __ARGS((char_u *cmd));
int read_viminfo_sub_string __ARGS((vir_T *virp, int force));
void write_viminfo_sub_string __ARGS((FILE *fp));
void free_old_sub __ARGS((void));
-void free_signs __ARGS((void));
int prepare_tagpreview __ARGS((int undo_sync));
void ex_help __ARGS((exarg_T *eap));
char_u *check_help_lang __ARGS((char_u *arg));
@@ -56,5 +55,8 @@ int sign_get_attr __ARGS((int typenr, int line));
char_u *sign_get_text __ARGS((int typenr));
void *sign_get_image __ARGS((int typenr));
char_u *sign_typenr2name __ARGS((int typenr));
+void free_signs __ARGS((void));
+char_u *get_sign_name __ARGS((expand_T *xp, int idx));
+void set_context_in_sign_cmd __ARGS((expand_T *xp, char_u *arg));
void ex_drop __ARGS((exarg_T *eap));
/* vim: set ft=c : */
View
10 src/quickfix.c
@@ -2346,7 +2346,13 @@ ex_copen(eap)
set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
OPT_LOCAL);
set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
- set_option_value((char_u *)"diff", 0L, NULL, OPT_LOCAL);
+#ifdef FEAT_DIFF
+ curwin->w_p_diff = FALSE;
+#endif
+#ifdef FEAT_FOLDING
+ set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
+ OPT_LOCAL);
+#endif
}
/* Only set the height when still in the same tab page and there is no
@@ -2607,10 +2613,12 @@ qf_fill_buffer(qi)
curbuf->b_p_ma = FALSE;
#ifdef FEAT_AUTOCMD
+ keep_filetype = TRUE; /* don't detect 'filetype' */
apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
FALSE, curbuf);
apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
FALSE, curbuf);
+ keep_filetype = FALSE;
#endif
/* make sure it will be redrawn */
View
12 src/version.c
@@ -677,6 +677,18 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 166,
+/**/
+ 165,
+/**/
+ 164,
+/**/
+ 163,
+/**/
+ 162,
+/**/
+ 161,
+/**/
160,
/**/
159,
View
1  src/vim.h
@@ -709,6 +709,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#define EXPAND_USER_LIST 31
#define EXPAND_SHELLCMD 32
#define EXPAND_CSCOPE 33
+#define EXPAND_SIGN 34
/* Values for exmode_active (0 is no exmode) */
#define EXMODE_NORMAL 1
Please sign in to comment.
Something went wrong with that request. Please try again.