mirror of
https://github.com/zoriya/vim.git
synced 2025-12-19 13:45:18 +00:00
patch 8.1.2127: the indent.c file is a bit big
Problem: The indent.c file is a bit big.
Solution: Move C-indent code a a new cindent.c file. Move other
indent-related code to indent.c. (Yegappan Lakshmanan,
closes #5031)
This commit is contained in:
2
Filelist
2
Filelist
@@ -25,6 +25,7 @@ SRC_ALL = \
|
|||||||
src/change.c \
|
src/change.c \
|
||||||
src/channel.c \
|
src/channel.c \
|
||||||
src/charset.c \
|
src/charset.c \
|
||||||
|
src/cindent.c \
|
||||||
src/cmdexpand.c \
|
src/cmdexpand.c \
|
||||||
src/cmdhist.c \
|
src/cmdhist.c \
|
||||||
src/crypt.c \
|
src/crypt.c \
|
||||||
@@ -191,6 +192,7 @@ SRC_ALL = \
|
|||||||
src/proto/change.pro \
|
src/proto/change.pro \
|
||||||
src/proto/channel.pro \
|
src/proto/channel.pro \
|
||||||
src/proto/charset.pro \
|
src/proto/charset.pro \
|
||||||
|
src/proto/cindent.pro \
|
||||||
src/proto/cmdexpand.pro \
|
src/proto/cmdexpand.pro \
|
||||||
src/proto/cmdhist.pro \
|
src/proto/cmdhist.pro \
|
||||||
src/proto/crypt.pro \
|
src/proto/crypt.pro \
|
||||||
|
|||||||
@@ -712,6 +712,7 @@ OBJ = \
|
|||||||
$(OUTDIR)/bufwrite.o \
|
$(OUTDIR)/bufwrite.o \
|
||||||
$(OUTDIR)/change.o \
|
$(OUTDIR)/change.o \
|
||||||
$(OUTDIR)/charset.o \
|
$(OUTDIR)/charset.o \
|
||||||
|
$(OUTDIR)/cindent.o \
|
||||||
$(OUTDIR)/cmdexpand.o \
|
$(OUTDIR)/cmdexpand.o \
|
||||||
$(OUTDIR)/cmdhist.o \
|
$(OUTDIR)/cmdhist.o \
|
||||||
$(OUTDIR)/crypt.o \
|
$(OUTDIR)/crypt.o \
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ SRC = arabic.c \
|
|||||||
bufwrite.c \
|
bufwrite.c \
|
||||||
change.c \
|
change.c \
|
||||||
charset.c \
|
charset.c \
|
||||||
|
cindent.c \
|
||||||
cmdexpand.c \
|
cmdexpand.c \
|
||||||
cmdhist.c \
|
cmdhist.c \
|
||||||
crypt.c \
|
crypt.c \
|
||||||
|
|||||||
@@ -719,6 +719,7 @@ OBJ = \
|
|||||||
$(OUTDIR)\bufwrite.obj \
|
$(OUTDIR)\bufwrite.obj \
|
||||||
$(OUTDIR)\change.obj \
|
$(OUTDIR)\change.obj \
|
||||||
$(OUTDIR)\charset.obj \
|
$(OUTDIR)\charset.obj \
|
||||||
|
$(OUTDIR)\cindent.obj \
|
||||||
$(OUTDIR)\cmdexpand.obj \
|
$(OUTDIR)\cmdexpand.obj \
|
||||||
$(OUTDIR)\cmdhist.obj \
|
$(OUTDIR)\cmdhist.obj \
|
||||||
$(OUTDIR)\crypt.obj \
|
$(OUTDIR)\crypt.obj \
|
||||||
@@ -1464,6 +1465,8 @@ $(OUTDIR)/change.obj: $(OUTDIR) change.c $(INCL)
|
|||||||
|
|
||||||
$(OUTDIR)/charset.obj: $(OUTDIR) charset.c $(INCL)
|
$(OUTDIR)/charset.obj: $(OUTDIR) charset.c $(INCL)
|
||||||
|
|
||||||
|
$(OUTDIR)/cindent.obj: $(OUTDIR) cindent.c $(INCL)
|
||||||
|
|
||||||
$(OUTDIR)/cmdexpand.obj: $(OUTDIR) cmdexpand.c $(INCL)
|
$(OUTDIR)/cmdexpand.obj: $(OUTDIR) cmdexpand.c $(INCL)
|
||||||
|
|
||||||
$(OUTDIR)/cmdhist.obj: $(OUTDIR) cmdhist.c $(INCL)
|
$(OUTDIR)/cmdhist.obj: $(OUTDIR) cmdhist.c $(INCL)
|
||||||
@@ -1794,6 +1797,7 @@ proto.h: \
|
|||||||
proto/bufwrite.pro \
|
proto/bufwrite.pro \
|
||||||
proto/change.pro \
|
proto/change.pro \
|
||||||
proto/charset.pro \
|
proto/charset.pro \
|
||||||
|
proto/cindent.pro \
|
||||||
proto/cmdexpand.pro \
|
proto/cmdexpand.pro \
|
||||||
proto/cmdhist.pro \
|
proto/cmdhist.pro \
|
||||||
proto/crypt.pro \
|
proto/crypt.pro \
|
||||||
|
|||||||
@@ -318,6 +318,7 @@ SRC = \
|
|||||||
bufwrite.c \
|
bufwrite.c \
|
||||||
change.c \
|
change.c \
|
||||||
charset.c \
|
charset.c \
|
||||||
|
cindent.c \
|
||||||
cmdexpand.c \
|
cmdexpand.c \
|
||||||
cmdhist.c \
|
cmdhist.c \
|
||||||
crypt.c \
|
crypt.c \
|
||||||
@@ -420,6 +421,7 @@ OBJ = \
|
|||||||
bufwrite.obj \
|
bufwrite.obj \
|
||||||
change.obj \
|
change.obj \
|
||||||
charset.obj \
|
charset.obj \
|
||||||
|
cindent.obj \
|
||||||
cmdexpand.obj \
|
cmdexpand.obj \
|
||||||
cmdhist.obj \
|
cmdhist.obj \
|
||||||
crypt.obj \
|
crypt.obj \
|
||||||
@@ -700,6 +702,10 @@ charset.obj : charset.c vim.h [.auto]config.h feature.h os_unix.h \
|
|||||||
ascii.h keymap.h term.h macros.h structs.h regexp.h \
|
ascii.h keymap.h term.h macros.h structs.h regexp.h \
|
||||||
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
|
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
|
||||||
globals.h
|
globals.h
|
||||||
|
cindent.obj : cindent.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||||
|
ascii.h keymap.h term.h macros.h structs.h regexp.h \
|
||||||
|
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
|
||||||
|
globals.h
|
||||||
cmdexpand.obj : cmdexpand.c vim.h [.auto]config.h feature.h os_unix.h \
|
cmdexpand.obj : cmdexpand.c vim.h [.auto]config.h feature.h os_unix.h \
|
||||||
ascii.h keymap.h term.h macros.h structs.h regexp.h \
|
ascii.h keymap.h term.h macros.h structs.h regexp.h \
|
||||||
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
|
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
|
||||||
|
|||||||
10
src/Makefile
10
src/Makefile
@@ -1585,6 +1585,7 @@ BASIC_SRC = \
|
|||||||
buffer.c \
|
buffer.c \
|
||||||
change.c \
|
change.c \
|
||||||
charset.c \
|
charset.c \
|
||||||
|
cindent.c \
|
||||||
cmdexpand.c \
|
cmdexpand.c \
|
||||||
cmdhist.c \
|
cmdhist.c \
|
||||||
crypt.c \
|
crypt.c \
|
||||||
@@ -1725,6 +1726,7 @@ OBJ_COMMON = \
|
|||||||
objects/change.o \
|
objects/change.o \
|
||||||
objects/blob.o \
|
objects/blob.o \
|
||||||
objects/blowfish.o \
|
objects/blowfish.o \
|
||||||
|
objects/cindent.o \
|
||||||
objects/cmdexpand.o \
|
objects/cmdexpand.o \
|
||||||
objects/cmdhist.o \
|
objects/cmdhist.o \
|
||||||
objects/crypt.o \
|
objects/crypt.o \
|
||||||
@@ -1878,6 +1880,7 @@ PRO_AUTO = \
|
|||||||
buffer.pro \
|
buffer.pro \
|
||||||
change.pro \
|
change.pro \
|
||||||
charset.pro \
|
charset.pro \
|
||||||
|
cindent.pro \
|
||||||
cmdexpand.pro \
|
cmdexpand.pro \
|
||||||
cmdhist.pro \
|
cmdhist.pro \
|
||||||
crypt.pro \
|
crypt.pro \
|
||||||
@@ -3081,6 +3084,9 @@ objects/change.o: change.c
|
|||||||
objects/charset.o: charset.c
|
objects/charset.o: charset.c
|
||||||
$(CCC) -o $@ charset.c
|
$(CCC) -o $@ charset.c
|
||||||
|
|
||||||
|
objects/cindent.o: cindent.c
|
||||||
|
$(CCC) -o $@ cindent.c
|
||||||
|
|
||||||
objects/cmdexpand.o: cmdexpand.c
|
objects/cmdexpand.o: cmdexpand.c
|
||||||
$(CCC) -o $@ cmdexpand.c
|
$(CCC) -o $@ cmdexpand.c
|
||||||
|
|
||||||
@@ -3621,6 +3627,10 @@ objects/charset.o: charset.c vim.h protodef.h auto/config.h feature.h os_unix.h
|
|||||||
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||||
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||||
proto.h globals.h
|
proto.h globals.h
|
||||||
|
objects/cindent.o: cindent.c vim.h protodef.h auto/config.h feature.h os_unix.h \
|
||||||
|
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||||
|
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||||
|
proto.h globals.h
|
||||||
objects/cmdexpand.o: cmdexpand.c vim.h protodef.h auto/config.h feature.h os_unix.h \
|
objects/cmdexpand.o: cmdexpand.c vim.h protodef.h auto/config.h feature.h os_unix.h \
|
||||||
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
|
||||||
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ blob.c | blob data type
|
|||||||
buffer.c | manipulating buffers (loaded files)
|
buffer.c | manipulating buffers (loaded files)
|
||||||
bufwrite.c | writing a buffer to file
|
bufwrite.c | writing a buffer to file
|
||||||
change.c | handling changes to text
|
change.c | handling changes to text
|
||||||
|
cindent.c | C and Lisp indentation
|
||||||
cmdexpand.c | command-line completion
|
cmdexpand.c | command-line completion
|
||||||
cmdhist.c | command-line history
|
cmdhist.c | command-line history
|
||||||
debugger.c | vim script debugger
|
debugger.c | vim script debugger
|
||||||
@@ -46,7 +47,7 @@ findfile.c | search for files in 'path'
|
|||||||
fold.c | folding
|
fold.c | folding
|
||||||
getchar.c | getting characters and key mapping
|
getchar.c | getting characters and key mapping
|
||||||
highlight.c | syntax highlighting
|
highlight.c | syntax highlighting
|
||||||
indent.c | C and Lisp indentation
|
indent.c | text indentation
|
||||||
insexpand.c | Insert mode completion
|
insexpand.c | Insert mode completion
|
||||||
mark.c | marks
|
mark.c | marks
|
||||||
map.c | mapping and abbreviations
|
map.c | mapping and abbreviations
|
||||||
|
|||||||
145
src/change.c
145
src/change.c
@@ -1250,151 +1250,6 @@ del_bytes(
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy the indent from ptr to the current line (and fill to size)
|
|
||||||
* Leaves the cursor on the first non-blank in the line.
|
|
||||||
* Returns TRUE if the line was changed.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
copy_indent(int size, char_u *src)
|
|
||||||
{
|
|
||||||
char_u *p = NULL;
|
|
||||||
char_u *line = NULL;
|
|
||||||
char_u *s;
|
|
||||||
int todo;
|
|
||||||
int ind_len;
|
|
||||||
int line_len = 0;
|
|
||||||
int tab_pad;
|
|
||||||
int ind_done;
|
|
||||||
int round;
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
int ind_col;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Round 1: compute the number of characters needed for the indent
|
|
||||||
// Round 2: copy the characters.
|
|
||||||
for (round = 1; round <= 2; ++round)
|
|
||||||
{
|
|
||||||
todo = size;
|
|
||||||
ind_len = 0;
|
|
||||||
ind_done = 0;
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
ind_col = 0;
|
|
||||||
#endif
|
|
||||||
s = src;
|
|
||||||
|
|
||||||
// Count/copy the usable portion of the source line
|
|
||||||
while (todo > 0 && VIM_ISWHITE(*s))
|
|
||||||
{
|
|
||||||
if (*s == TAB)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
#else
|
|
||||||
tab_pad = (int)curbuf->b_p_ts
|
|
||||||
- (ind_done % (int)curbuf->b_p_ts);
|
|
||||||
#endif
|
|
||||||
// Stop if this tab will overshoot the target
|
|
||||||
if (todo < tab_pad)
|
|
||||||
break;
|
|
||||||
todo -= tab_pad;
|
|
||||||
ind_done += tab_pad;
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
ind_col += tab_pad;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
--todo;
|
|
||||||
++ind_done;
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
++ind_col;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
++ind_len;
|
|
||||||
if (p != NULL)
|
|
||||||
*p++ = *s;
|
|
||||||
++s;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill to next tabstop with a tab, if possible
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
#else
|
|
||||||
tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
|
|
||||||
#endif
|
|
||||||
if (todo >= tab_pad && !curbuf->b_p_et)
|
|
||||||
{
|
|
||||||
todo -= tab_pad;
|
|
||||||
++ind_len;
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
ind_col += tab_pad;
|
|
||||||
#endif
|
|
||||||
if (p != NULL)
|
|
||||||
*p++ = TAB;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add tabs required for indent
|
|
||||||
if (!curbuf->b_p_et)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
if (todo < tab_pad)
|
|
||||||
break;
|
|
||||||
todo -= tab_pad;
|
|
||||||
++ind_len;
|
|
||||||
ind_col += tab_pad;
|
|
||||||
if (p != NULL)
|
|
||||||
*p++ = TAB;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
while (todo >= (int)curbuf->b_p_ts)
|
|
||||||
{
|
|
||||||
todo -= (int)curbuf->b_p_ts;
|
|
||||||
++ind_len;
|
|
||||||
if (p != NULL)
|
|
||||||
*p++ = TAB;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count/add spaces required for indent
|
|
||||||
while (todo > 0)
|
|
||||||
{
|
|
||||||
--todo;
|
|
||||||
++ind_len;
|
|
||||||
if (p != NULL)
|
|
||||||
*p++ = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p == NULL)
|
|
||||||
{
|
|
||||||
// Allocate memory for the result: the copied indent, new indent
|
|
||||||
// and the rest of the line.
|
|
||||||
line_len = (int)STRLEN(ml_get_curline()) + 1;
|
|
||||||
line = alloc(ind_len + line_len);
|
|
||||||
if (line == NULL)
|
|
||||||
return FALSE;
|
|
||||||
p = line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append the original line
|
|
||||||
mch_memmove(p, ml_get_curline(), (size_t)line_len);
|
|
||||||
|
|
||||||
// Replace the line
|
|
||||||
ml_replace(curwin->w_cursor.lnum, line, FALSE);
|
|
||||||
|
|
||||||
// Put the cursor after the indent.
|
|
||||||
curwin->w_cursor.col = ind_len;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* open_line: Add a new line below or above the current line.
|
* open_line: Add a new line below or above the current line.
|
||||||
*
|
*
|
||||||
|
|||||||
4133
src/cindent.c
Normal file
4133
src/cindent.c
Normal file
File diff suppressed because it is too large
Load Diff
341
src/edit.c
341
src/edit.c
@@ -37,7 +37,6 @@ static void check_spell_redraw(void);
|
|||||||
#endif
|
#endif
|
||||||
static void stop_insert(pos_T *end_insert_pos, int esc, int nomove);
|
static void stop_insert(pos_T *end_insert_pos, int esc, int nomove);
|
||||||
static int echeck_abbr(int);
|
static int echeck_abbr(int);
|
||||||
static void replace_join(int off);
|
|
||||||
static void mb_replace_pop_ins(int cc);
|
static void mb_replace_pop_ins(int cc);
|
||||||
static void replace_flush(void);
|
static void replace_flush(void);
|
||||||
static void replace_do_bs(int limit_col);
|
static void replace_do_bs(int limit_col);
|
||||||
@@ -76,9 +75,6 @@ static int ins_tab(void);
|
|||||||
static int ins_digraph(void);
|
static int ins_digraph(void);
|
||||||
#endif
|
#endif
|
||||||
static int ins_ctrl_ey(int tc);
|
static int ins_ctrl_ey(int tc);
|
||||||
#ifdef FEAT_SMARTINDENT
|
|
||||||
static void ins_try_si(int c);
|
|
||||||
#endif
|
|
||||||
#if defined(FEAT_EVAL)
|
#if defined(FEAT_EVAL)
|
||||||
static char_u *do_insert_char_pre(int c);
|
static char_u *do_insert_char_pre(int c);
|
||||||
#endif
|
#endif
|
||||||
@@ -97,8 +93,6 @@ static int did_restart_edit; /* "restart_edit" when calling edit() */
|
|||||||
static int can_cindent; /* may do cindenting on this line */
|
static int can_cindent; /* may do cindenting on this line */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int old_indent = 0; /* for ^^D command in insert mode */
|
|
||||||
|
|
||||||
#ifdef FEAT_RIGHTLEFT
|
#ifdef FEAT_RIGHTLEFT
|
||||||
static int revins_on; /* reverse insert mode on */
|
static int revins_on; /* reverse insert mode on */
|
||||||
static int revins_chars; /* how much to skip after edit */
|
static int revins_chars; /* how much to skip after edit */
|
||||||
@@ -1762,248 +1756,6 @@ undisplay_dollar(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Insert an indent (for <Tab> or CTRL-T) or delete an indent (for CTRL-D).
|
|
||||||
* Keep the cursor on the same character.
|
|
||||||
* type == INDENT_INC increase indent (for CTRL-T or <Tab>)
|
|
||||||
* type == INDENT_DEC decrease indent (for CTRL-D)
|
|
||||||
* type == INDENT_SET set indent to "amount"
|
|
||||||
* if round is TRUE, round the indent to 'shiftwidth' (only with _INC and _Dec).
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
change_indent(
|
|
||||||
int type,
|
|
||||||
int amount,
|
|
||||||
int round,
|
|
||||||
int replaced, /* replaced character, put on replace stack */
|
|
||||||
int call_changed_bytes) /* call changed_bytes() */
|
|
||||||
{
|
|
||||||
int vcol;
|
|
||||||
int last_vcol;
|
|
||||||
int insstart_less; /* reduction for Insstart.col */
|
|
||||||
int new_cursor_col;
|
|
||||||
int i;
|
|
||||||
char_u *ptr;
|
|
||||||
int save_p_list;
|
|
||||||
int start_col;
|
|
||||||
colnr_T vc;
|
|
||||||
colnr_T orig_col = 0; /* init for GCC */
|
|
||||||
char_u *new_line, *orig_line = NULL; /* init for GCC */
|
|
||||||
|
|
||||||
/* VREPLACE mode needs to know what the line was like before changing */
|
|
||||||
if (State & VREPLACE_FLAG)
|
|
||||||
{
|
|
||||||
orig_line = vim_strsave(ml_get_curline()); /* Deal with NULL below */
|
|
||||||
orig_col = curwin->w_cursor.col;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for the following tricks we don't want list mode */
|
|
||||||
save_p_list = curwin->w_p_list;
|
|
||||||
curwin->w_p_list = FALSE;
|
|
||||||
vc = getvcol_nolist(&curwin->w_cursor);
|
|
||||||
vcol = vc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For Replace mode we need to fix the replace stack later, which is only
|
|
||||||
* possible when the cursor is in the indent. Remember the number of
|
|
||||||
* characters before the cursor if it's possible.
|
|
||||||
*/
|
|
||||||
start_col = curwin->w_cursor.col;
|
|
||||||
|
|
||||||
/* determine offset from first non-blank */
|
|
||||||
new_cursor_col = curwin->w_cursor.col;
|
|
||||||
beginline(BL_WHITE);
|
|
||||||
new_cursor_col -= curwin->w_cursor.col;
|
|
||||||
|
|
||||||
insstart_less = curwin->w_cursor.col;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the cursor is in the indent, compute how many screen columns the
|
|
||||||
* cursor is to the left of the first non-blank.
|
|
||||||
*/
|
|
||||||
if (new_cursor_col < 0)
|
|
||||||
vcol = get_indent() - vcol;
|
|
||||||
|
|
||||||
if (new_cursor_col > 0) /* can't fix replace stack */
|
|
||||||
start_col = -1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the new indent. The cursor will be put on the first non-blank.
|
|
||||||
*/
|
|
||||||
if (type == INDENT_SET)
|
|
||||||
(void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int save_State = State;
|
|
||||||
|
|
||||||
/* Avoid being called recursively. */
|
|
||||||
if (State & VREPLACE_FLAG)
|
|
||||||
State = INSERT;
|
|
||||||
shift_line(type == INDENT_DEC, round, 1, call_changed_bytes);
|
|
||||||
State = save_State;
|
|
||||||
}
|
|
||||||
insstart_less -= curwin->w_cursor.col;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to put cursor on same character.
|
|
||||||
* If the cursor is at or after the first non-blank in the line,
|
|
||||||
* compute the cursor column relative to the column of the first
|
|
||||||
* non-blank character.
|
|
||||||
* If we are not in insert mode, leave the cursor on the first non-blank.
|
|
||||||
* If the cursor is before the first non-blank, position it relative
|
|
||||||
* to the first non-blank, counted in screen columns.
|
|
||||||
*/
|
|
||||||
if (new_cursor_col >= 0)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* When changing the indent while the cursor is touching it, reset
|
|
||||||
* Insstart_col to 0.
|
|
||||||
*/
|
|
||||||
if (new_cursor_col == 0)
|
|
||||||
insstart_less = MAXCOL;
|
|
||||||
new_cursor_col += curwin->w_cursor.col;
|
|
||||||
}
|
|
||||||
else if (!(State & INSERT))
|
|
||||||
new_cursor_col = curwin->w_cursor.col;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Compute the screen column where the cursor should be.
|
|
||||||
*/
|
|
||||||
vcol = get_indent() - vcol;
|
|
||||||
curwin->w_virtcol = (colnr_T)((vcol < 0) ? 0 : vcol);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Advance the cursor until we reach the right screen column.
|
|
||||||
*/
|
|
||||||
vcol = last_vcol = 0;
|
|
||||||
new_cursor_col = -1;
|
|
||||||
ptr = ml_get_curline();
|
|
||||||
while (vcol <= (int)curwin->w_virtcol)
|
|
||||||
{
|
|
||||||
last_vcol = vcol;
|
|
||||||
if (has_mbyte && new_cursor_col >= 0)
|
|
||||||
new_cursor_col += (*mb_ptr2len)(ptr + new_cursor_col);
|
|
||||||
else
|
|
||||||
++new_cursor_col;
|
|
||||||
vcol += lbr_chartabsize(ptr, ptr + new_cursor_col, (colnr_T)vcol);
|
|
||||||
}
|
|
||||||
vcol = last_vcol;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* May need to insert spaces to be able to position the cursor on
|
|
||||||
* the right screen column.
|
|
||||||
*/
|
|
||||||
if (vcol != (int)curwin->w_virtcol)
|
|
||||||
{
|
|
||||||
curwin->w_cursor.col = (colnr_T)new_cursor_col;
|
|
||||||
i = (int)curwin->w_virtcol - vcol;
|
|
||||||
ptr = alloc(i + 1);
|
|
||||||
if (ptr != NULL)
|
|
||||||
{
|
|
||||||
new_cursor_col += i;
|
|
||||||
ptr[i] = NUL;
|
|
||||||
while (--i >= 0)
|
|
||||||
ptr[i] = ' ';
|
|
||||||
ins_str(ptr);
|
|
||||||
vim_free(ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When changing the indent while the cursor is in it, reset
|
|
||||||
* Insstart_col to 0.
|
|
||||||
*/
|
|
||||||
insstart_less = MAXCOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
curwin->w_p_list = save_p_list;
|
|
||||||
|
|
||||||
if (new_cursor_col <= 0)
|
|
||||||
curwin->w_cursor.col = 0;
|
|
||||||
else
|
|
||||||
curwin->w_cursor.col = (colnr_T)new_cursor_col;
|
|
||||||
curwin->w_set_curswant = TRUE;
|
|
||||||
changed_cline_bef_curs();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* May have to adjust the start of the insert.
|
|
||||||
*/
|
|
||||||
if (State & INSERT)
|
|
||||||
{
|
|
||||||
if (curwin->w_cursor.lnum == Insstart.lnum && Insstart.col != 0)
|
|
||||||
{
|
|
||||||
if ((int)Insstart.col <= insstart_less)
|
|
||||||
Insstart.col = 0;
|
|
||||||
else
|
|
||||||
Insstart.col -= insstart_less;
|
|
||||||
}
|
|
||||||
if ((int)ai_col <= insstart_less)
|
|
||||||
ai_col = 0;
|
|
||||||
else
|
|
||||||
ai_col -= insstart_less;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For REPLACE mode, may have to fix the replace stack, if it's possible.
|
|
||||||
* If the number of characters before the cursor decreased, need to pop a
|
|
||||||
* few characters from the replace stack.
|
|
||||||
* If the number of characters before the cursor increased, need to push a
|
|
||||||
* few NULs onto the replace stack.
|
|
||||||
*/
|
|
||||||
if (REPLACE_NORMAL(State) && start_col >= 0)
|
|
||||||
{
|
|
||||||
while (start_col > (int)curwin->w_cursor.col)
|
|
||||||
{
|
|
||||||
replace_join(0); /* remove a NUL from the replace stack */
|
|
||||||
--start_col;
|
|
||||||
}
|
|
||||||
while (start_col < (int)curwin->w_cursor.col || replaced)
|
|
||||||
{
|
|
||||||
replace_push(NUL);
|
|
||||||
if (replaced)
|
|
||||||
{
|
|
||||||
replace_push(replaced);
|
|
||||||
replaced = NUL;
|
|
||||||
}
|
|
||||||
++start_col;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For VREPLACE mode, we also have to fix the replace stack. In this case
|
|
||||||
* it is always possible because we backspace over the whole line and then
|
|
||||||
* put it back again the way we wanted it.
|
|
||||||
*/
|
|
||||||
if (State & VREPLACE_FLAG)
|
|
||||||
{
|
|
||||||
/* If orig_line didn't allocate, just return. At least we did the job,
|
|
||||||
* even if you can't backspace. */
|
|
||||||
if (orig_line == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Save new line */
|
|
||||||
new_line = vim_strsave(ml_get_curline());
|
|
||||||
if (new_line == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* We only put back the new line up to the cursor */
|
|
||||||
new_line[curwin->w_cursor.col] = NUL;
|
|
||||||
|
|
||||||
/* Put back original line */
|
|
||||||
ml_replace(curwin->w_cursor.lnum, orig_line, FALSE);
|
|
||||||
curwin->w_cursor.col = orig_col;
|
|
||||||
|
|
||||||
/* Backspace from cursor to start of line */
|
|
||||||
backspace_until_column(0);
|
|
||||||
|
|
||||||
/* Insert new stuff into line again */
|
|
||||||
ins_bytes(new_line);
|
|
||||||
|
|
||||||
vim_free(new_line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Truncate the space at the end of a line. This is to be used only in an
|
* Truncate the space at the end of a line. This is to be used only in an
|
||||||
* insert mode. It handles fixing the replace stack for REPLACE and VREPLACE
|
* insert mode. It handles fixing the replace stack for REPLACE and VREPLACE
|
||||||
@@ -3840,7 +3592,7 @@ replace_pop(void)
|
|||||||
* Join the top two items on the replace stack. This removes to "off"'th NUL
|
* Join the top two items on the replace stack. This removes to "off"'th NUL
|
||||||
* encountered.
|
* encountered.
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
replace_join(
|
replace_join(
|
||||||
int off) /* offset for which NUL to remove */
|
int off) /* offset for which NUL to remove */
|
||||||
{
|
{
|
||||||
@@ -6070,97 +5822,6 @@ ins_ctrl_ey(int tc)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEAT_SMARTINDENT
|
|
||||||
/*
|
|
||||||
* Try to do some very smart auto-indenting.
|
|
||||||
* Used when inserting a "normal" character.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
ins_try_si(int c)
|
|
||||||
{
|
|
||||||
pos_T *pos, old_pos;
|
|
||||||
char_u *ptr;
|
|
||||||
int i;
|
|
||||||
int temp;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* do some very smart indenting when entering '{' or '}'
|
|
||||||
*/
|
|
||||||
if (((did_si || can_si_back) && c == '{') || (can_si && c == '}'))
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* for '}' set indent equal to indent of line containing matching '{'
|
|
||||||
*/
|
|
||||||
if (c == '}' && (pos = findmatch(NULL, '{')) != NULL)
|
|
||||||
{
|
|
||||||
old_pos = curwin->w_cursor;
|
|
||||||
/*
|
|
||||||
* If the matching '{' has a ')' immediately before it (ignoring
|
|
||||||
* white-space), then line up with the start of the line
|
|
||||||
* containing the matching '(' if there is one. This handles the
|
|
||||||
* case where an "if (..\n..) {" statement continues over multiple
|
|
||||||
* lines -- webb
|
|
||||||
*/
|
|
||||||
ptr = ml_get(pos->lnum);
|
|
||||||
i = pos->col;
|
|
||||||
if (i > 0) /* skip blanks before '{' */
|
|
||||||
while (--i > 0 && VIM_ISWHITE(ptr[i]))
|
|
||||||
;
|
|
||||||
curwin->w_cursor.lnum = pos->lnum;
|
|
||||||
curwin->w_cursor.col = i;
|
|
||||||
if (ptr[i] == ')' && (pos = findmatch(NULL, '(')) != NULL)
|
|
||||||
curwin->w_cursor = *pos;
|
|
||||||
i = get_indent();
|
|
||||||
curwin->w_cursor = old_pos;
|
|
||||||
if (State & VREPLACE_FLAG)
|
|
||||||
change_indent(INDENT_SET, i, FALSE, NUL, TRUE);
|
|
||||||
else
|
|
||||||
(void)set_indent(i, SIN_CHANGED);
|
|
||||||
}
|
|
||||||
else if (curwin->w_cursor.col > 0)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* when inserting '{' after "O" reduce indent, but not
|
|
||||||
* more than indent of previous line
|
|
||||||
*/
|
|
||||||
temp = TRUE;
|
|
||||||
if (c == '{' && can_si_back && curwin->w_cursor.lnum > 1)
|
|
||||||
{
|
|
||||||
old_pos = curwin->w_cursor;
|
|
||||||
i = get_indent();
|
|
||||||
while (curwin->w_cursor.lnum > 1)
|
|
||||||
{
|
|
||||||
ptr = skipwhite(ml_get(--(curwin->w_cursor.lnum)));
|
|
||||||
|
|
||||||
/* ignore empty lines and lines starting with '#'. */
|
|
||||||
if (*ptr != '#' && *ptr != NUL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (get_indent() >= i)
|
|
||||||
temp = FALSE;
|
|
||||||
curwin->w_cursor = old_pos;
|
|
||||||
}
|
|
||||||
if (temp)
|
|
||||||
shift_line(TRUE, FALSE, 1, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* set indent of '#' always to 0
|
|
||||||
*/
|
|
||||||
if (curwin->w_cursor.col > 0 && can_si && c == '#')
|
|
||||||
{
|
|
||||||
/* remember current indent for next line */
|
|
||||||
old_indent = get_indent();
|
|
||||||
(void)set_indent(0, SIN_CHANGED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust ai_col, the char at this position can be deleted. */
|
|
||||||
if (ai_col > curwin->w_cursor.col)
|
|
||||||
ai_col = curwin->w_cursor.col;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the value that w_virtcol would have when 'list' is off.
|
* Get the value that w_virtcol would have when 'list' is off.
|
||||||
* Unless 'cpo' contains the 'L' flag.
|
* Unless 'cpo' contains the 'L' flag.
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ static void f_ceil(typval_T *argvars, typval_T *rettv);
|
|||||||
#endif
|
#endif
|
||||||
static void f_changenr(typval_T *argvars, typval_T *rettv);
|
static void f_changenr(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_char2nr(typval_T *argvars, typval_T *rettv);
|
static void f_char2nr(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_cindent(typval_T *argvars, typval_T *rettv);
|
|
||||||
static void f_col(typval_T *argvars, typval_T *rettv);
|
static void f_col(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_confirm(typval_T *argvars, typval_T *rettv);
|
static void f_confirm(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_copy(typval_T *argvars, typval_T *rettv);
|
static void f_copy(typval_T *argvars, typval_T *rettv);
|
||||||
@@ -108,7 +107,6 @@ static void f_hlID(typval_T *argvars, typval_T *rettv);
|
|||||||
static void f_hlexists(typval_T *argvars, typval_T *rettv);
|
static void f_hlexists(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_hostname(typval_T *argvars, typval_T *rettv);
|
static void f_hostname(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_iconv(typval_T *argvars, typval_T *rettv);
|
static void f_iconv(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_indent(typval_T *argvars, typval_T *rettv);
|
|
||||||
static void f_index(typval_T *argvars, typval_T *rettv);
|
static void f_index(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_input(typval_T *argvars, typval_T *rettv);
|
static void f_input(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_inputdialog(typval_T *argvars, typval_T *rettv);
|
static void f_inputdialog(typval_T *argvars, typval_T *rettv);
|
||||||
@@ -128,7 +126,6 @@ static void f_libcall(typval_T *argvars, typval_T *rettv);
|
|||||||
static void f_libcallnr(typval_T *argvars, typval_T *rettv);
|
static void f_libcallnr(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_line(typval_T *argvars, typval_T *rettv);
|
static void f_line(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_line2byte(typval_T *argvars, typval_T *rettv);
|
static void f_line2byte(typval_T *argvars, typval_T *rettv);
|
||||||
static void f_lispindent(typval_T *argvars, typval_T *rettv);
|
|
||||||
static void f_localtime(typval_T *argvars, typval_T *rettv);
|
static void f_localtime(typval_T *argvars, typval_T *rettv);
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
static void f_log(typval_T *argvars, typval_T *rettv);
|
static void f_log(typval_T *argvars, typval_T *rettv);
|
||||||
@@ -1491,29 +1488,6 @@ f_char2nr(typval_T *argvars, typval_T *rettv)
|
|||||||
rettv->vval.v_number = tv_get_string(&argvars[0])[0];
|
rettv->vval.v_number = tv_get_string(&argvars[0])[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* "cindent(lnum)" function
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
f_cindent(typval_T *argvars UNUSED, typval_T *rettv)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_CINDENT
|
|
||||||
pos_T pos;
|
|
||||||
linenr_T lnum;
|
|
||||||
|
|
||||||
pos = curwin->w_cursor;
|
|
||||||
lnum = tv_get_lnum(argvars);
|
|
||||||
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
|
|
||||||
{
|
|
||||||
curwin->w_cursor.lnum = lnum;
|
|
||||||
rettv->vval.v_number = get_c_indent();
|
|
||||||
curwin->w_cursor = pos;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
rettv->vval.v_number = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
win_T *
|
win_T *
|
||||||
get_optional_window(typval_T *argvars, int idx)
|
get_optional_window(typval_T *argvars, int idx)
|
||||||
{
|
{
|
||||||
@@ -3945,21 +3919,6 @@ f_iconv(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
vim_free(to);
|
vim_free(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* "indent()" function
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
f_indent(typval_T *argvars, typval_T *rettv)
|
|
||||||
{
|
|
||||||
linenr_T lnum;
|
|
||||||
|
|
||||||
lnum = tv_get_lnum(argvars);
|
|
||||||
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
|
|
||||||
rettv->vval.v_number = get_indent_lnum(lnum);
|
|
||||||
else
|
|
||||||
rettv->vval.v_number = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "index()" function
|
* "index()" function
|
||||||
*/
|
*/
|
||||||
@@ -4450,29 +4409,6 @@ f_line2byte(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* "lispindent(lnum)" function
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
f_lispindent(typval_T *argvars UNUSED, typval_T *rettv)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_LISP
|
|
||||||
pos_T pos;
|
|
||||||
linenr_T lnum;
|
|
||||||
|
|
||||||
pos = curwin->w_cursor;
|
|
||||||
lnum = tv_get_lnum(argvars);
|
|
||||||
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
|
|
||||||
{
|
|
||||||
curwin->w_cursor.lnum = lnum;
|
|
||||||
rettv->vval.v_number = get_lisp_indent();
|
|
||||||
curwin->w_cursor = pos;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
rettv->vval.v_number = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "localtime()" function
|
* "localtime()" function
|
||||||
*/
|
*/
|
||||||
|
|||||||
215
src/ex_cmds.c
215
src/ex_cmds.c
@@ -660,221 +660,6 @@ sortend:
|
|||||||
emsg(_(e_interr));
|
emsg(_(e_interr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* ":retab".
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ex_retab(exarg_T *eap)
|
|
||||||
{
|
|
||||||
linenr_T lnum;
|
|
||||||
int got_tab = FALSE;
|
|
||||||
long num_spaces = 0;
|
|
||||||
long num_tabs;
|
|
||||||
long len;
|
|
||||||
long col;
|
|
||||||
long vcol;
|
|
||||||
long start_col = 0; /* For start of white-space string */
|
|
||||||
long start_vcol = 0; /* For start of white-space string */
|
|
||||||
long old_len;
|
|
||||||
char_u *ptr;
|
|
||||||
char_u *new_line = (char_u *)1; /* init to non-NULL */
|
|
||||||
int did_undo; /* called u_save for current line */
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
int *new_vts_array = NULL;
|
|
||||||
char_u *new_ts_str; /* string value of tab argument */
|
|
||||||
#else
|
|
||||||
int temp;
|
|
||||||
int new_ts;
|
|
||||||
#endif
|
|
||||||
int save_list;
|
|
||||||
linenr_T first_line = 0; /* first changed line */
|
|
||||||
linenr_T last_line = 0; /* last changed line */
|
|
||||||
|
|
||||||
save_list = curwin->w_p_list;
|
|
||||||
curwin->w_p_list = 0; /* don't want list mode here */
|
|
||||||
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
new_ts_str = eap->arg;
|
|
||||||
if (!tabstop_set(eap->arg, &new_vts_array))
|
|
||||||
return;
|
|
||||||
while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',')
|
|
||||||
++(eap->arg);
|
|
||||||
|
|
||||||
// This ensures that either new_vts_array and new_ts_str are freshly
|
|
||||||
// allocated, or new_vts_array points to an existing array and new_ts_str
|
|
||||||
// is null.
|
|
||||||
if (new_vts_array == NULL)
|
|
||||||
{
|
|
||||||
new_vts_array = curbuf->b_p_vts_array;
|
|
||||||
new_ts_str = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
|
|
||||||
#else
|
|
||||||
new_ts = getdigits(&(eap->arg));
|
|
||||||
if (new_ts < 0)
|
|
||||||
{
|
|
||||||
emsg(_(e_positive));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (new_ts == 0)
|
|
||||||
new_ts = curbuf->b_p_ts;
|
|
||||||
#endif
|
|
||||||
for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum)
|
|
||||||
{
|
|
||||||
ptr = ml_get(lnum);
|
|
||||||
col = 0;
|
|
||||||
vcol = 0;
|
|
||||||
did_undo = FALSE;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (VIM_ISWHITE(ptr[col]))
|
|
||||||
{
|
|
||||||
if (!got_tab && num_spaces == 0)
|
|
||||||
{
|
|
||||||
/* First consecutive white-space */
|
|
||||||
start_vcol = vcol;
|
|
||||||
start_col = col;
|
|
||||||
}
|
|
||||||
if (ptr[col] == ' ')
|
|
||||||
num_spaces++;
|
|
||||||
else
|
|
||||||
got_tab = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (got_tab || (eap->forceit && num_spaces > 1))
|
|
||||||
{
|
|
||||||
/* Retabulate this string of white-space */
|
|
||||||
|
|
||||||
/* len is virtual length of white string */
|
|
||||||
len = num_spaces = vcol - start_vcol;
|
|
||||||
num_tabs = 0;
|
|
||||||
if (!curbuf->b_p_et)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
int t, s;
|
|
||||||
|
|
||||||
tabstop_fromto(start_vcol, vcol,
|
|
||||||
curbuf->b_p_ts, new_vts_array, &t, &s);
|
|
||||||
num_tabs = t;
|
|
||||||
num_spaces = s;
|
|
||||||
#else
|
|
||||||
temp = new_ts - (start_vcol % new_ts);
|
|
||||||
if (num_spaces >= temp)
|
|
||||||
{
|
|
||||||
num_spaces -= temp;
|
|
||||||
num_tabs++;
|
|
||||||
}
|
|
||||||
num_tabs += num_spaces / new_ts;
|
|
||||||
num_spaces -= (num_spaces / new_ts) * new_ts;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (curbuf->b_p_et || got_tab ||
|
|
||||||
(num_spaces + num_tabs < len))
|
|
||||||
{
|
|
||||||
if (did_undo == FALSE)
|
|
||||||
{
|
|
||||||
did_undo = TRUE;
|
|
||||||
if (u_save((linenr_T)(lnum - 1),
|
|
||||||
(linenr_T)(lnum + 1)) == FAIL)
|
|
||||||
{
|
|
||||||
new_line = NULL; /* flag out-of-memory */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* len is actual number of white characters used */
|
|
||||||
len = num_spaces + num_tabs;
|
|
||||||
old_len = (long)STRLEN(ptr);
|
|
||||||
new_line = alloc(old_len - col + start_col + len + 1);
|
|
||||||
if (new_line == NULL)
|
|
||||||
break;
|
|
||||||
if (start_col > 0)
|
|
||||||
mch_memmove(new_line, ptr, (size_t)start_col);
|
|
||||||
mch_memmove(new_line + start_col + len,
|
|
||||||
ptr + col, (size_t)(old_len - col + 1));
|
|
||||||
ptr = new_line + start_col;
|
|
||||||
for (col = 0; col < len; col++)
|
|
||||||
ptr[col] = (col < num_tabs) ? '\t' : ' ';
|
|
||||||
ml_replace(lnum, new_line, FALSE);
|
|
||||||
if (first_line == 0)
|
|
||||||
first_line = lnum;
|
|
||||||
last_line = lnum;
|
|
||||||
ptr = new_line;
|
|
||||||
col = start_col + len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
got_tab = FALSE;
|
|
||||||
num_spaces = 0;
|
|
||||||
}
|
|
||||||
if (ptr[col] == NUL)
|
|
||||||
break;
|
|
||||||
vcol += chartabsize(ptr + col, (colnr_T)vcol);
|
|
||||||
if (has_mbyte)
|
|
||||||
col += (*mb_ptr2len)(ptr + col);
|
|
||||||
else
|
|
||||||
++col;
|
|
||||||
}
|
|
||||||
if (new_line == NULL) /* out of memory */
|
|
||||||
break;
|
|
||||||
line_breakcheck();
|
|
||||||
}
|
|
||||||
if (got_int)
|
|
||||||
emsg(_(e_interr));
|
|
||||||
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
// If a single value was given then it can be considered equal to
|
|
||||||
// either the value of 'tabstop' or the value of 'vartabstop'.
|
|
||||||
if (tabstop_count(curbuf->b_p_vts_array) == 0
|
|
||||||
&& tabstop_count(new_vts_array) == 1
|
|
||||||
&& curbuf->b_p_ts == tabstop_first(new_vts_array))
|
|
||||||
; /* not changed */
|
|
||||||
else if (tabstop_count(curbuf->b_p_vts_array) > 0
|
|
||||||
&& tabstop_eq(curbuf->b_p_vts_array, new_vts_array))
|
|
||||||
; /* not changed */
|
|
||||||
else
|
|
||||||
redraw_curbuf_later(NOT_VALID);
|
|
||||||
#else
|
|
||||||
if (curbuf->b_p_ts != new_ts)
|
|
||||||
redraw_curbuf_later(NOT_VALID);
|
|
||||||
#endif
|
|
||||||
if (first_line != 0)
|
|
||||||
changed_lines(first_line, 0, last_line + 1, 0L);
|
|
||||||
|
|
||||||
curwin->w_p_list = save_list; /* restore 'list' */
|
|
||||||
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
if (new_ts_str != NULL) /* set the new tabstop */
|
|
||||||
{
|
|
||||||
// If 'vartabstop' is in use or if the value given to retab has more
|
|
||||||
// than one tabstop then update 'vartabstop'.
|
|
||||||
int *old_vts_ary = curbuf->b_p_vts_array;
|
|
||||||
|
|
||||||
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1)
|
|
||||||
{
|
|
||||||
set_string_option_direct((char_u *)"vts", -1, new_ts_str,
|
|
||||||
OPT_FREE|OPT_LOCAL, 0);
|
|
||||||
curbuf->b_p_vts_array = new_vts_array;
|
|
||||||
vim_free(old_vts_ary);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 'vartabstop' wasn't in use and a single value was given to
|
|
||||||
// retab then update 'tabstop'.
|
|
||||||
curbuf->b_p_ts = tabstop_first(new_vts_array);
|
|
||||||
vim_free(new_vts_array);
|
|
||||||
}
|
|
||||||
vim_free(new_ts_str);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
curbuf->b_p_ts = new_ts;
|
|
||||||
#endif
|
|
||||||
coladvance(curwin->w_curswant);
|
|
||||||
|
|
||||||
u_clearline();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* :move command - move lines line1-line2 to line dest
|
* :move command - move lines line1-line2 to line dest
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -843,6 +843,8 @@ EXTERN int can_si INIT(= FALSE);
|
|||||||
EXTERN int can_si_back INIT(= FALSE);
|
EXTERN int can_si_back INIT(= FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
EXTERN int old_indent INIT(= 0); // for ^^D command in insert mode
|
||||||
|
|
||||||
EXTERN pos_T saved_cursor // w_cursor before formatting text.
|
EXTERN pos_T saved_cursor // w_cursor before formatting text.
|
||||||
#ifdef DO_INIT
|
#ifdef DO_INIT
|
||||||
= {0, 0, 0}
|
= {0, 0, 0}
|
||||||
|
|||||||
6132
src/indent.c
6132
src/indent.c
File diff suppressed because it is too large
Load Diff
556
src/misc1.c
556
src/misc1.c
@@ -24,542 +24,6 @@
|
|||||||
// All user names (for ~user completion as done by shell).
|
// All user names (for ~user completion as done by shell).
|
||||||
static garray_T ga_users;
|
static garray_T ga_users;
|
||||||
|
|
||||||
/*
|
|
||||||
* Count the size (in window cells) of the indent in the current line.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
get_indent(void)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
return get_indent_str_vtab(ml_get_curline(), (int)curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array, FALSE);
|
|
||||||
#else
|
|
||||||
return get_indent_str(ml_get_curline(), (int)curbuf->b_p_ts, FALSE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Count the size (in window cells) of the indent in line "lnum".
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
get_indent_lnum(linenr_T lnum)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
return get_indent_str_vtab(ml_get(lnum), (int)curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array, FALSE);
|
|
||||||
#else
|
|
||||||
return get_indent_str(ml_get(lnum), (int)curbuf->b_p_ts, FALSE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(FEAT_FOLDING) || defined(PROTO)
|
|
||||||
/*
|
|
||||||
* Count the size (in window cells) of the indent in line "lnum" of buffer
|
|
||||||
* "buf".
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
get_indent_buf(buf_T *buf, linenr_T lnum)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
return get_indent_str_vtab(ml_get_buf(buf, lnum, FALSE),
|
|
||||||
(int)curbuf->b_p_ts, buf->b_p_vts_array, FALSE);
|
|
||||||
#else
|
|
||||||
return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts, FALSE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* count the size (in window cells) of the indent in line "ptr", with
|
|
||||||
* 'tabstop' at "ts"
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
get_indent_str(
|
|
||||||
char_u *ptr,
|
|
||||||
int ts,
|
|
||||||
int list) /* if TRUE, count only screen size for tabs */
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for ( ; *ptr; ++ptr)
|
|
||||||
{
|
|
||||||
if (*ptr == TAB)
|
|
||||||
{
|
|
||||||
if (!list || lcs_tab1) /* count a tab for what it is worth */
|
|
||||||
count += ts - (count % ts);
|
|
||||||
else
|
|
||||||
/* In list mode, when tab is not set, count screen char width
|
|
||||||
* for Tab, displays: ^I */
|
|
||||||
count += ptr2cells(ptr);
|
|
||||||
}
|
|
||||||
else if (*ptr == ' ')
|
|
||||||
++count; /* count a space for one */
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
/*
|
|
||||||
* Count the size (in window cells) of the indent in line "ptr", using
|
|
||||||
* variable tabstops.
|
|
||||||
* if "list" is TRUE, count only screen size for tabs.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
get_indent_str_vtab(char_u *ptr, int ts, int *vts, int list)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for ( ; *ptr; ++ptr)
|
|
||||||
{
|
|
||||||
if (*ptr == TAB) /* count a tab for what it is worth */
|
|
||||||
{
|
|
||||||
if (!list || lcs_tab1)
|
|
||||||
count += tabstop_padding(count, ts, vts);
|
|
||||||
else
|
|
||||||
/* In list mode, when tab is not set, count screen char width
|
|
||||||
* for Tab, displays: ^I */
|
|
||||||
count += ptr2cells(ptr);
|
|
||||||
}
|
|
||||||
else if (*ptr == ' ')
|
|
||||||
++count; /* count a space for one */
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the indent of the current line.
|
|
||||||
* Leaves the cursor on the first non-blank in the line.
|
|
||||||
* Caller must take care of undo.
|
|
||||||
* "flags":
|
|
||||||
* SIN_CHANGED: call changed_bytes() if the line was changed.
|
|
||||||
* SIN_INSERT: insert the indent in front of the line.
|
|
||||||
* SIN_UNDO: save line for undo before changing it.
|
|
||||||
* Returns TRUE if the line was changed.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
set_indent(
|
|
||||||
int size, /* measured in spaces */
|
|
||||||
int flags)
|
|
||||||
{
|
|
||||||
char_u *p;
|
|
||||||
char_u *newline;
|
|
||||||
char_u *oldline;
|
|
||||||
char_u *s;
|
|
||||||
int todo;
|
|
||||||
int ind_len; /* measured in characters */
|
|
||||||
int line_len;
|
|
||||||
int doit = FALSE;
|
|
||||||
int ind_done = 0; /* measured in spaces */
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
int ind_col = 0;
|
|
||||||
#endif
|
|
||||||
int tab_pad;
|
|
||||||
int retval = FALSE;
|
|
||||||
int orig_char_len = -1; /* number of initial whitespace chars when
|
|
||||||
'et' and 'pi' are both set */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* First check if there is anything to do and compute the number of
|
|
||||||
* characters needed for the indent.
|
|
||||||
*/
|
|
||||||
todo = size;
|
|
||||||
ind_len = 0;
|
|
||||||
p = oldline = ml_get_curline();
|
|
||||||
|
|
||||||
/* Calculate the buffer size for the new indent, and check to see if it
|
|
||||||
* isn't already set */
|
|
||||||
|
|
||||||
/* if 'expandtab' isn't set: use TABs; if both 'expandtab' and
|
|
||||||
* 'preserveindent' are set count the number of characters at the
|
|
||||||
* beginning of the line to be copied */
|
|
||||||
if (!curbuf->b_p_et || (!(flags & SIN_INSERT) && curbuf->b_p_pi))
|
|
||||||
{
|
|
||||||
/* If 'preserveindent' is set then reuse as much as possible of
|
|
||||||
* the existing indent structure for the new indent */
|
|
||||||
if (!(flags & SIN_INSERT) && curbuf->b_p_pi)
|
|
||||||
{
|
|
||||||
ind_done = 0;
|
|
||||||
|
|
||||||
/* count as many characters as we can use */
|
|
||||||
while (todo > 0 && VIM_ISWHITE(*p))
|
|
||||||
{
|
|
||||||
if (*p == TAB)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
#else
|
|
||||||
tab_pad = (int)curbuf->b_p_ts
|
|
||||||
- (ind_done % (int)curbuf->b_p_ts);
|
|
||||||
#endif
|
|
||||||
/* stop if this tab will overshoot the target */
|
|
||||||
if (todo < tab_pad)
|
|
||||||
break;
|
|
||||||
todo -= tab_pad;
|
|
||||||
++ind_len;
|
|
||||||
ind_done += tab_pad;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
--todo;
|
|
||||||
++ind_len;
|
|
||||||
++ind_done;
|
|
||||||
}
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
/* These diverge from this point. */
|
|
||||||
ind_col = ind_done;
|
|
||||||
#endif
|
|
||||||
/* Set initial number of whitespace chars to copy if we are
|
|
||||||
* preserving indent but expandtab is set */
|
|
||||||
if (curbuf->b_p_et)
|
|
||||||
orig_char_len = ind_len;
|
|
||||||
|
|
||||||
/* Fill to next tabstop with a tab, if possible */
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
#else
|
|
||||||
tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
|
|
||||||
#endif
|
|
||||||
if (todo >= tab_pad && orig_char_len == -1)
|
|
||||||
{
|
|
||||||
doit = TRUE;
|
|
||||||
todo -= tab_pad;
|
|
||||||
++ind_len;
|
|
||||||
/* ind_done += tab_pad; */
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
ind_col += tab_pad;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* count tabs required for indent */
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
if (todo < tab_pad)
|
|
||||||
break;
|
|
||||||
if (*p != TAB)
|
|
||||||
doit = TRUE;
|
|
||||||
else
|
|
||||||
++p;
|
|
||||||
todo -= tab_pad;
|
|
||||||
++ind_len;
|
|
||||||
ind_col += tab_pad;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
while (todo >= (int)curbuf->b_p_ts)
|
|
||||||
{
|
|
||||||
if (*p != TAB)
|
|
||||||
doit = TRUE;
|
|
||||||
else
|
|
||||||
++p;
|
|
||||||
todo -= (int)curbuf->b_p_ts;
|
|
||||||
++ind_len;
|
|
||||||
/* ind_done += (int)curbuf->b_p_ts; */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/* count spaces required for indent */
|
|
||||||
while (todo > 0)
|
|
||||||
{
|
|
||||||
if (*p != ' ')
|
|
||||||
doit = TRUE;
|
|
||||||
else
|
|
||||||
++p;
|
|
||||||
--todo;
|
|
||||||
++ind_len;
|
|
||||||
/* ++ind_done; */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return if the indent is OK already. */
|
|
||||||
if (!doit && !VIM_ISWHITE(*p) && !(flags & SIN_INSERT))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Allocate memory for the new line. */
|
|
||||||
if (flags & SIN_INSERT)
|
|
||||||
p = oldline;
|
|
||||||
else
|
|
||||||
p = skipwhite(p);
|
|
||||||
line_len = (int)STRLEN(p) + 1;
|
|
||||||
|
|
||||||
/* If 'preserveindent' and 'expandtab' are both set keep the original
|
|
||||||
* characters and allocate accordingly. We will fill the rest with spaces
|
|
||||||
* after the if (!curbuf->b_p_et) below. */
|
|
||||||
if (orig_char_len != -1)
|
|
||||||
{
|
|
||||||
newline = alloc(orig_char_len + size - ind_done + line_len);
|
|
||||||
if (newline == NULL)
|
|
||||||
return FALSE;
|
|
||||||
todo = size - ind_done;
|
|
||||||
ind_len = orig_char_len + todo; /* Set total length of indent in
|
|
||||||
* characters, which may have been
|
|
||||||
* undercounted until now */
|
|
||||||
p = oldline;
|
|
||||||
s = newline;
|
|
||||||
while (orig_char_len > 0)
|
|
||||||
{
|
|
||||||
*s++ = *p++;
|
|
||||||
orig_char_len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip over any additional white space (useful when newindent is less
|
|
||||||
* than old) */
|
|
||||||
while (VIM_ISWHITE(*p))
|
|
||||||
++p;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
todo = size;
|
|
||||||
newline = alloc(ind_len + line_len);
|
|
||||||
if (newline == NULL)
|
|
||||||
return FALSE;
|
|
||||||
s = newline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put the characters in the new line. */
|
|
||||||
/* if 'expandtab' isn't set: use TABs */
|
|
||||||
if (!curbuf->b_p_et)
|
|
||||||
{
|
|
||||||
/* If 'preserveindent' is set then reuse as much as possible of
|
|
||||||
* the existing indent structure for the new indent */
|
|
||||||
if (!(flags & SIN_INSERT) && curbuf->b_p_pi)
|
|
||||||
{
|
|
||||||
p = oldline;
|
|
||||||
ind_done = 0;
|
|
||||||
|
|
||||||
while (todo > 0 && VIM_ISWHITE(*p))
|
|
||||||
{
|
|
||||||
if (*p == TAB)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
#else
|
|
||||||
tab_pad = (int)curbuf->b_p_ts
|
|
||||||
- (ind_done % (int)curbuf->b_p_ts);
|
|
||||||
#endif
|
|
||||||
/* stop if this tab will overshoot the target */
|
|
||||||
if (todo < tab_pad)
|
|
||||||
break;
|
|
||||||
todo -= tab_pad;
|
|
||||||
ind_done += tab_pad;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
--todo;
|
|
||||||
++ind_done;
|
|
||||||
}
|
|
||||||
*s++ = *p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill to next tabstop with a tab, if possible */
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
#else
|
|
||||||
tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
|
|
||||||
#endif
|
|
||||||
if (todo >= tab_pad)
|
|
||||||
{
|
|
||||||
*s++ = TAB;
|
|
||||||
todo -= tab_pad;
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
ind_done += tab_pad;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
p = skipwhite(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts,
|
|
||||||
curbuf->b_p_vts_array);
|
|
||||||
if (todo < tab_pad)
|
|
||||||
break;
|
|
||||||
*s++ = TAB;
|
|
||||||
todo -= tab_pad;
|
|
||||||
ind_done += tab_pad;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
while (todo >= (int)curbuf->b_p_ts)
|
|
||||||
{
|
|
||||||
*s++ = TAB;
|
|
||||||
todo -= (int)curbuf->b_p_ts;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
while (todo > 0)
|
|
||||||
{
|
|
||||||
*s++ = ' ';
|
|
||||||
--todo;
|
|
||||||
}
|
|
||||||
mch_memmove(s, p, (size_t)line_len);
|
|
||||||
|
|
||||||
// Replace the line (unless undo fails).
|
|
||||||
if (!(flags & SIN_UNDO) || u_savesub(curwin->w_cursor.lnum) == OK)
|
|
||||||
{
|
|
||||||
ml_replace(curwin->w_cursor.lnum, newline, FALSE);
|
|
||||||
if (flags & SIN_CHANGED)
|
|
||||||
changed_bytes(curwin->w_cursor.lnum, 0);
|
|
||||||
|
|
||||||
// Correct saved cursor position if it is in this line.
|
|
||||||
if (saved_cursor.lnum == curwin->w_cursor.lnum)
|
|
||||||
{
|
|
||||||
if (saved_cursor.col >= (colnr_T)(p - oldline))
|
|
||||||
// cursor was after the indent, adjust for the number of
|
|
||||||
// bytes added/removed
|
|
||||||
saved_cursor.col += ind_len - (colnr_T)(p - oldline);
|
|
||||||
else if (saved_cursor.col >= (colnr_T)(s - newline))
|
|
||||||
// cursor was in the indent, and is now after it, put it back
|
|
||||||
// at the start of the indent (replacing spaces with TAB)
|
|
||||||
saved_cursor.col = (colnr_T)(s - newline);
|
|
||||||
}
|
|
||||||
#ifdef FEAT_TEXT_PROP
|
|
||||||
{
|
|
||||||
int added = ind_len - (colnr_T)(p - oldline);
|
|
||||||
|
|
||||||
// When increasing indent this behaves like spaces were inserted at
|
|
||||||
// the old indent, when decreasing indent it behaves like spaces
|
|
||||||
// were deleted at the new indent.
|
|
||||||
adjust_prop_columns(curwin->w_cursor.lnum,
|
|
||||||
(colnr_T)(added > 0 ? (p - oldline) : ind_len), added, 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
retval = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
vim_free(newline);
|
|
||||||
|
|
||||||
curwin->w_cursor.col = ind_len;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the indent of the current line after a number. Return -1 if no
|
|
||||||
* number was found. Used for 'n' in 'formatoptions': numbered list.
|
|
||||||
* Since a pattern is used it can actually handle more than numbers.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
get_number_indent(linenr_T lnum)
|
|
||||||
{
|
|
||||||
colnr_T col;
|
|
||||||
pos_T pos;
|
|
||||||
|
|
||||||
regmatch_T regmatch;
|
|
||||||
int lead_len = 0; /* length of comment leader */
|
|
||||||
|
|
||||||
if (lnum > curbuf->b_ml.ml_line_count)
|
|
||||||
return -1;
|
|
||||||
pos.lnum = 0;
|
|
||||||
|
|
||||||
/* In format_lines() (i.e. not insert mode), fo+=q is needed too... */
|
|
||||||
if ((State & INSERT) || has_format_option(FO_Q_COMS))
|
|
||||||
lead_len = get_leader_len(ml_get(lnum), NULL, FALSE, TRUE);
|
|
||||||
|
|
||||||
regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
|
|
||||||
if (regmatch.regprog != NULL)
|
|
||||||
{
|
|
||||||
regmatch.rm_ic = FALSE;
|
|
||||||
|
|
||||||
/* vim_regexec() expects a pointer to a line. This lets us
|
|
||||||
* start matching for the flp beyond any comment leader... */
|
|
||||||
if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0))
|
|
||||||
{
|
|
||||||
pos.lnum = lnum;
|
|
||||||
pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum));
|
|
||||||
pos.coladd = 0;
|
|
||||||
}
|
|
||||||
vim_regfree(regmatch.regprog);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL)
|
|
||||||
return -1;
|
|
||||||
getvcol(curwin, &pos, &col, NULL, NULL);
|
|
||||||
return (int)col;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(FEAT_LINEBREAK) || defined(PROTO)
|
|
||||||
/*
|
|
||||||
* Return appropriate space number for breakindent, taking influencing
|
|
||||||
* parameters into account. Window must be specified, since it is not
|
|
||||||
* necessarily always the current one.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
get_breakindent_win(
|
|
||||||
win_T *wp,
|
|
||||||
char_u *line) /* start of the line */
|
|
||||||
{
|
|
||||||
static int prev_indent = 0; /* cached indent value */
|
|
||||||
static long prev_ts = 0L; /* cached tabstop value */
|
|
||||||
static char_u *prev_line = NULL; /* cached pointer to line */
|
|
||||||
static varnumber_T prev_tick = 0; /* changedtick of cached value */
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
static int *prev_vts = NULL; /* cached vartabs values */
|
|
||||||
#endif
|
|
||||||
int bri = 0;
|
|
||||||
/* window width minus window margin space, i.e. what rests for text */
|
|
||||||
const int eff_wwidth = wp->w_width
|
|
||||||
- ((wp->w_p_nu || wp->w_p_rnu)
|
|
||||||
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
|
|
||||||
? number_width(wp) + 1 : 0);
|
|
||||||
|
|
||||||
/* used cached indent, unless pointer or 'tabstop' changed */
|
|
||||||
if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
|
|
||||||
|| prev_tick != CHANGEDTICK(wp->w_buffer)
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
|| prev_vts != wp->w_buffer->b_p_vts_array
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
|
||||||
prev_line = line;
|
|
||||||
prev_ts = wp->w_buffer->b_p_ts;
|
|
||||||
prev_tick = CHANGEDTICK(wp->w_buffer);
|
|
||||||
#ifdef FEAT_VARTABS
|
|
||||||
prev_vts = wp->w_buffer->b_p_vts_array;
|
|
||||||
prev_indent = get_indent_str_vtab(line,
|
|
||||||
(int)wp->w_buffer->b_p_ts,
|
|
||||||
wp->w_buffer->b_p_vts_array, wp->w_p_list);
|
|
||||||
#else
|
|
||||||
prev_indent = get_indent_str(line,
|
|
||||||
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
bri = prev_indent + wp->w_p_brishift;
|
|
||||||
|
|
||||||
/* indent minus the length of the showbreak string */
|
|
||||||
if (wp->w_p_brisbr)
|
|
||||||
bri -= vim_strsize(p_sbr);
|
|
||||||
|
|
||||||
/* Add offset for number column, if 'n' is in 'cpoptions' */
|
|
||||||
bri += win_col_off2(wp);
|
|
||||||
|
|
||||||
/* never indent past left window margin */
|
|
||||||
if (bri < 0)
|
|
||||||
bri = 0;
|
|
||||||
/* always leave at least bri_min characters on the left,
|
|
||||||
* if text width is sufficient */
|
|
||||||
else if (bri > eff_wwidth - wp->w_p_brimin)
|
|
||||||
bri = (eff_wwidth - wp->w_p_brimin < 0)
|
|
||||||
? 0 : eff_wwidth - wp->w_p_brimin;
|
|
||||||
|
|
||||||
return bri;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_leader_len() returns the length in bytes of the prefix of the given
|
* get_leader_len() returns the length in bytes of the prefix of the given
|
||||||
* string which introduces a comment. If this string is not a comment then
|
* string which introduces a comment. If this string is not a comment then
|
||||||
@@ -1075,26 +539,6 @@ pchar_cursor(int c)
|
|||||||
+ curwin->w_cursor.col) = c;
|
+ curwin->w_cursor.col) = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* When extra == 0: Return TRUE if the cursor is before or on the first
|
|
||||||
* non-blank in the line.
|
|
||||||
* When extra == 1: Return TRUE if the cursor is before the first non-blank in
|
|
||||||
* the line.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
inindent(int extra)
|
|
||||||
{
|
|
||||||
char_u *ptr;
|
|
||||||
colnr_T col;
|
|
||||||
|
|
||||||
for (col = 0, ptr = ml_get_curline(); VIM_ISWHITE(*ptr); ++col)
|
|
||||||
++ptr;
|
|
||||||
if (col >= curwin->w_cursor.col + extra)
|
|
||||||
return TRUE;
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skip to next part of an option argument: Skip space and comma.
|
* Skip to next part of an option argument: Skip space and comma.
|
||||||
*/
|
*/
|
||||||
|
|||||||
107
src/ops.c
107
src/ops.c
@@ -590,90 +590,6 @@ block_insert(
|
|||||||
State = oldstate;
|
State = oldstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(PROTO)
|
|
||||||
/*
|
|
||||||
* op_reindent - handle reindenting a block of lines.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
op_reindent(oparg_T *oap, int (*how)(void))
|
|
||||||
{
|
|
||||||
long i;
|
|
||||||
char_u *l;
|
|
||||||
int amount;
|
|
||||||
linenr_T first_changed = 0;
|
|
||||||
linenr_T last_changed = 0;
|
|
||||||
linenr_T start_lnum = curwin->w_cursor.lnum;
|
|
||||||
|
|
||||||
/* Don't even try when 'modifiable' is off. */
|
|
||||||
if (!curbuf->b_p_ma)
|
|
||||||
{
|
|
||||||
emsg(_(e_modifiable));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = oap->line_count; --i >= 0 && !got_int; )
|
|
||||||
{
|
|
||||||
/* it's a slow thing to do, so give feedback so there's no worry that
|
|
||||||
* the computer's just hung. */
|
|
||||||
|
|
||||||
if (i > 1
|
|
||||||
&& (i % 50 == 0 || i == oap->line_count - 1)
|
|
||||||
&& oap->line_count > p_report)
|
|
||||||
smsg(_("%ld lines to indent... "), i);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Be vi-compatible: For lisp indenting the first line is not
|
|
||||||
* indented, unless there is only one line.
|
|
||||||
*/
|
|
||||||
#ifdef FEAT_LISP
|
|
||||||
if (i != oap->line_count - 1 || oap->line_count == 1
|
|
||||||
|| how != get_lisp_indent)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
l = skipwhite(ml_get_curline());
|
|
||||||
if (*l == NUL) /* empty or blank line */
|
|
||||||
amount = 0;
|
|
||||||
else
|
|
||||||
amount = how(); /* get the indent for this line */
|
|
||||||
|
|
||||||
if (amount >= 0 && set_indent(amount, SIN_UNDO))
|
|
||||||
{
|
|
||||||
/* did change the indent, call changed_lines() later */
|
|
||||||
if (first_changed == 0)
|
|
||||||
first_changed = curwin->w_cursor.lnum;
|
|
||||||
last_changed = curwin->w_cursor.lnum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++curwin->w_cursor.lnum;
|
|
||||||
curwin->w_cursor.col = 0; /* make sure it's valid */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* put cursor on first non-blank of indented line */
|
|
||||||
curwin->w_cursor.lnum = start_lnum;
|
|
||||||
beginline(BL_SOL | BL_FIX);
|
|
||||||
|
|
||||||
/* Mark changed lines so that they will be redrawn. When Visual
|
|
||||||
* highlighting was present, need to continue until the last line. When
|
|
||||||
* there is no change still need to remove the Visual highlighting. */
|
|
||||||
if (last_changed != 0)
|
|
||||||
changed_lines(first_changed, 0,
|
|
||||||
oap->is_VIsual ? start_lnum + oap->line_count :
|
|
||||||
last_changed + 1, 0L);
|
|
||||||
else if (oap->is_VIsual)
|
|
||||||
redraw_curbuf_later(INVERTED);
|
|
||||||
|
|
||||||
if (oap->line_count > p_report)
|
|
||||||
{
|
|
||||||
i = oap->line_count - (i + 1);
|
|
||||||
smsg(NGETTEXT("%ld line indented ",
|
|
||||||
"%ld lines indented ", i), i);
|
|
||||||
}
|
|
||||||
/* set '[ and '] marks */
|
|
||||||
curbuf->b_op_start = oap->start;
|
|
||||||
curbuf->b_op_end = oap->end;
|
|
||||||
}
|
|
||||||
#endif /* defined(FEAT_LISP) || defined(FEAT_CINDENT) */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stuff a string into the typeahead buffer, such that edit() will insert it
|
* Stuff a string into the typeahead buffer, such that edit() will insert it
|
||||||
* literally ("literally" TRUE) or interpret is as typed characters.
|
* literally ("literally" TRUE) or interpret is as typed characters.
|
||||||
@@ -1917,29 +1833,6 @@ adjust_cursor_eol(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) || defined(PROTO)
|
|
||||||
/*
|
|
||||||
* Return TRUE if lines starting with '#' should be left aligned.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
preprocs_left(void)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
# ifdef FEAT_SMARTINDENT
|
|
||||||
# ifdef FEAT_CINDENT
|
|
||||||
(curbuf->b_p_si && !curbuf->b_p_cin) ||
|
|
||||||
# else
|
|
||||||
curbuf->b_p_si
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# ifdef FEAT_CINDENT
|
|
||||||
(curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE)
|
|
||||||
&& curbuf->b_ind_hash_comment == 0)
|
|
||||||
# endif
|
|
||||||
;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If "process" is TRUE and the line begins with a comment leader (possibly
|
* If "process" is TRUE and the line begins with a comment leader (possibly
|
||||||
* after some white space), return a pointer to the text after it. Put a boolean
|
* after some white space), return a pointer to the text after it. Put a boolean
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ extern int _stricoll(char *a, char *b);
|
|||||||
# include "bufwrite.pro"
|
# include "bufwrite.pro"
|
||||||
# include "change.pro"
|
# include "change.pro"
|
||||||
# include "charset.pro"
|
# include "charset.pro"
|
||||||
|
# include "cindent.pro"
|
||||||
# include "cmdexpand.pro"
|
# include "cmdexpand.pro"
|
||||||
# include "cmdhist.pro"
|
# include "cmdhist.pro"
|
||||||
# include "if_cscope.pro"
|
# include "if_cscope.pro"
|
||||||
|
|||||||
10
src/proto/cindent.pro
Normal file
10
src/proto/cindent.pro
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/* cindent.c */
|
||||||
|
int cin_is_cinword(char_u *line);
|
||||||
|
pos_T *find_start_comment(int ind_maxcomment);
|
||||||
|
int cindent_on(void);
|
||||||
|
void parse_cino(buf_T *buf);
|
||||||
|
int get_c_indent(void);
|
||||||
|
int in_cinkeys(int keytyped, int when, int line_is_empty);
|
||||||
|
void do_c_expr_indent(void);
|
||||||
|
void f_cindent(typval_T *argvars, typval_T *rettv);
|
||||||
|
/* vim: set ft=c : */
|
||||||
@@ -8,7 +8,6 @@ int prompt_curpos_editable(void);
|
|||||||
void edit_unputchar(void);
|
void edit_unputchar(void);
|
||||||
void display_dollar(colnr_T col);
|
void display_dollar(colnr_T col);
|
||||||
void undisplay_dollar(void);
|
void undisplay_dollar(void);
|
||||||
void change_indent(int type, int amount, int round, int replaced, int call_changed_bytes);
|
|
||||||
void truncate_spaces(char_u *line);
|
void truncate_spaces(char_u *line);
|
||||||
void backspace_until_column(int col);
|
void backspace_until_column(int col);
|
||||||
int get_literal(void);
|
int get_literal(void);
|
||||||
@@ -30,6 +29,7 @@ char_u *get_last_insert(void);
|
|||||||
char_u *get_last_insert_save(void);
|
char_u *get_last_insert_save(void);
|
||||||
void replace_push(int c);
|
void replace_push(int c);
|
||||||
int replace_push_mb(char_u *p);
|
int replace_push_mb(char_u *p);
|
||||||
|
void replace_join(int off);
|
||||||
int hkmap(int c);
|
int hkmap(int c);
|
||||||
int bracketed_paste(paste_mode_T mode, int drop, garray_T *gap);
|
int bracketed_paste(paste_mode_T mode, int drop, garray_T *gap);
|
||||||
void ins_scroll(void);
|
void ins_scroll(void);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
void do_ascii(exarg_T *eap);
|
void do_ascii(exarg_T *eap);
|
||||||
void ex_align(exarg_T *eap);
|
void ex_align(exarg_T *eap);
|
||||||
void ex_sort(exarg_T *eap);
|
void ex_sort(exarg_T *eap);
|
||||||
void ex_retab(exarg_T *eap);
|
|
||||||
int do_move(linenr_T line1, linenr_T line2, linenr_T dest);
|
int do_move(linenr_T line1, linenr_T line2, linenr_T dest);
|
||||||
void ex_copy(linenr_T line1, linenr_T line2, linenr_T n);
|
void ex_copy(linenr_T line1, linenr_T line2, linenr_T n);
|
||||||
void free_prev_shellcmd(void);
|
void free_prev_shellcmd(void);
|
||||||
|
|||||||
@@ -1,21 +1,9 @@
|
|||||||
/* indent.c */
|
/* indent.c */
|
||||||
int cin_is_cinword(char_u *line);
|
|
||||||
pos_T *find_start_comment(int ind_maxcomment);
|
|
||||||
int cindent_on(void);
|
|
||||||
void parse_cino(buf_T *buf);
|
|
||||||
int get_c_indent(void);
|
|
||||||
int get_expr_indent(void);
|
|
||||||
int in_cinkeys(int keytyped, int when, int line_is_empty);
|
|
||||||
int get_lisp_indent(void);
|
|
||||||
void do_c_expr_indent(void);
|
|
||||||
void fixthisline(int (*get_the_indent)(void));
|
|
||||||
void fix_indent(void);
|
|
||||||
int tabstop_set(char_u *var, int **array);
|
int tabstop_set(char_u *var, int **array);
|
||||||
int tabstop_padding(colnr_T col, int ts_arg, int *vts);
|
int tabstop_padding(colnr_T col, int ts_arg, int *vts);
|
||||||
int tabstop_at(colnr_T col, int ts, int *vts);
|
int tabstop_at(colnr_T col, int ts, int *vts);
|
||||||
colnr_T tabstop_start(colnr_T col, int ts, int *vts);
|
colnr_T tabstop_start(colnr_T col, int ts, int *vts);
|
||||||
void tabstop_fromto(colnr_T start_col, colnr_T end_col, int ts_arg, int *vts, int *ntabs, int *nspcs);
|
void tabstop_fromto(colnr_T start_col, colnr_T end_col, int ts_arg, int *vts, int *ntabs, int *nspcs);
|
||||||
int tabstop_eq(int *ts1, int *ts2);
|
|
||||||
int *tabstop_copy(int *oldts);
|
int *tabstop_copy(int *oldts);
|
||||||
int tabstop_count(int *ts);
|
int tabstop_count(int *ts);
|
||||||
int tabstop_first(int *ts);
|
int tabstop_first(int *ts);
|
||||||
@@ -23,4 +11,25 @@ long get_sw_value(buf_T *buf);
|
|||||||
long get_sw_value_indent(buf_T *buf);
|
long get_sw_value_indent(buf_T *buf);
|
||||||
long get_sw_value_col(buf_T *buf, colnr_T col);
|
long get_sw_value_col(buf_T *buf, colnr_T col);
|
||||||
long get_sts_value(void);
|
long get_sts_value(void);
|
||||||
|
int get_indent(void);
|
||||||
|
int get_indent_lnum(linenr_T lnum);
|
||||||
|
int get_indent_buf(buf_T *buf, linenr_T lnum);
|
||||||
|
int get_indent_str(char_u *ptr, int ts, int list);
|
||||||
|
int get_indent_str_vtab(char_u *ptr, int ts, int *vts, int list);
|
||||||
|
int set_indent(int size, int flags);
|
||||||
|
int get_number_indent(linenr_T lnum);
|
||||||
|
int get_breakindent_win(win_T *wp, char_u *line);
|
||||||
|
int inindent(int extra);
|
||||||
|
void op_reindent(oparg_T *oap, int (*how)(void));
|
||||||
|
int preprocs_left(void);
|
||||||
|
void ins_try_si(int c);
|
||||||
|
void change_indent(int type, int amount, int round, int replaced, int call_changed_bytes);
|
||||||
|
int copy_indent(int size, char_u *src);
|
||||||
|
void ex_retab(exarg_T *eap);
|
||||||
|
int get_expr_indent(void);
|
||||||
|
int get_lisp_indent(void);
|
||||||
|
void fixthisline(int (*get_the_indent)(void));
|
||||||
|
void fix_indent(void);
|
||||||
|
void f_indent(typval_T *argvars, typval_T *rettv);
|
||||||
|
void f_lispindent(typval_T *argvars, typval_T *rettv);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
/* misc1.c */
|
/* misc1.c */
|
||||||
int get_indent(void);
|
|
||||||
int get_indent_lnum(linenr_T lnum);
|
|
||||||
int get_indent_buf(buf_T *buf, linenr_T lnum);
|
|
||||||
int get_indent_str(char_u *ptr, int ts, int list);
|
|
||||||
int get_indent_str_vtab(char_u *ptr, int ts, int *vts, int list);
|
|
||||||
int set_indent(int size, int flags);
|
|
||||||
int get_number_indent(linenr_T lnum);
|
|
||||||
int get_breakindent_win(win_T *wp, char_u *line);
|
|
||||||
int get_leader_len(char_u *line, char_u **flags, int backward, int include_space);
|
int get_leader_len(char_u *line, char_u **flags, int backward, int include_space);
|
||||||
int get_last_leader_offset(char_u *line, char_u **flags);
|
int get_last_leader_offset(char_u *line, char_u **flags);
|
||||||
int plines(linenr_T lnum);
|
int plines(linenr_T lnum);
|
||||||
@@ -19,7 +11,6 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last);
|
|||||||
int gchar_pos(pos_T *pos);
|
int gchar_pos(pos_T *pos);
|
||||||
int gchar_cursor(void);
|
int gchar_cursor(void);
|
||||||
void pchar_cursor(int c);
|
void pchar_cursor(int c);
|
||||||
int inindent(int extra);
|
|
||||||
char_u *skip_to_option_part(char_u *p);
|
char_u *skip_to_option_part(char_u *p);
|
||||||
void check_status(buf_T *buf);
|
void check_status(buf_T *buf);
|
||||||
int ask_yesno(char_u *str, int direct);
|
int ask_yesno(char_u *str, int direct);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ int swapchar(int op_type, pos_T *pos);
|
|||||||
void op_insert(oparg_T *oap, long count1);
|
void op_insert(oparg_T *oap, long count1);
|
||||||
int op_change(oparg_T *oap);
|
int op_change(oparg_T *oap);
|
||||||
void adjust_cursor_eol(void);
|
void adjust_cursor_eol(void);
|
||||||
int preprocs_left(void);
|
|
||||||
char_u *skip_comment(char_u *line, int process, int include_space, int *is_comment);
|
char_u *skip_comment(char_u *line, int process, int include_space, int *is_comment);
|
||||||
int do_join(long count, int insert_space, int save_undo, int use_formatoptions, int setmark);
|
int do_join(long count, int insert_space, int save_undo, int use_formatoptions, int setmark);
|
||||||
int fex_format(linenr_T lnum, long count, int c);
|
int fex_format(linenr_T lnum, long count, int c);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* eval.c: User defined function support
|
* userfunc.c: User defined function support
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vim.h"
|
#include "vim.h"
|
||||||
|
|||||||
@@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2127,
|
||||||
/**/
|
/**/
|
||||||
2126,
|
2126,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user