forked from aniani/vim
updated for version 7.0051
This commit is contained in:
359
src/ex_getln.c
359
src/ex_getln.c
@@ -681,16 +681,29 @@ getcmdline(firstc, count, indent)
|
||||
if (c == '\n' || c == '\r' || c == K_KENTER || (c == ESC
|
||||
&& (!KeyTyped || vim_strchr(p_cpo, CPO_ESC) != NULL)))
|
||||
{
|
||||
gotesc = FALSE; /* Might have typed ESC previously, don't
|
||||
truncate the cmdline now. */
|
||||
if (ccheck_abbr(c + ABBR_OFF))
|
||||
goto cmdline_changed;
|
||||
if (!cmd_silent)
|
||||
/* In Ex mode a backslash escapes a newline. */
|
||||
if (exmode_active
|
||||
&& c != ESC
|
||||
&& ccline.cmdpos > 0
|
||||
&& ccline.cmdpos == ccline.cmdlen
|
||||
&& ccline.cmdbuff[ccline.cmdpos - 1] == '\\')
|
||||
{
|
||||
windgoto(msg_row, 0);
|
||||
out_flush();
|
||||
if (c == K_KENTER)
|
||||
c = '\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
gotesc = FALSE; /* Might have typed ESC previously, don't
|
||||
truncate the cmdline now. */
|
||||
if (ccheck_abbr(c + ABBR_OFF))
|
||||
goto cmdline_changed;
|
||||
if (!cmd_silent)
|
||||
{
|
||||
windgoto(msg_row, 0);
|
||||
out_flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1879,25 +1892,24 @@ getexline(c, dummy, indent)
|
||||
* Get an Ex command line for Ex mode.
|
||||
* In Ex mode we only use the OS supplied line editing features and no
|
||||
* mappings or abbreviations.
|
||||
* Returns a string in allocated memory or NULL.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
char_u *
|
||||
getexmodeline(c, dummy, indent)
|
||||
int c; /* normally ':', NUL for ":append" */
|
||||
getexmodeline(promptc, dummy, indent)
|
||||
int promptc; /* normally ':', NUL for ":append" and '?' for
|
||||
:s prompt */
|
||||
void *dummy; /* cookie not used */
|
||||
int indent; /* indent for inside conditionals */
|
||||
{
|
||||
garray_T line_ga;
|
||||
int len;
|
||||
int off = 0;
|
||||
char_u *pend;
|
||||
int finished = FALSE;
|
||||
#if defined(FEAT_GUI) || defined(NO_COOKED_INPUT)
|
||||
int startcol = 0;
|
||||
int c1;
|
||||
int escaped = FALSE; /* CTRL-V typed */
|
||||
int vcol = 0;
|
||||
#endif
|
||||
garray_T line_ga;
|
||||
char_u *pend;
|
||||
int startcol = 0;
|
||||
int c1;
|
||||
int escaped = FALSE; /* CTRL-V typed */
|
||||
int vcol = 0;
|
||||
char_u *p;
|
||||
int prev_char = 0;
|
||||
|
||||
/* Switch cursor on now. This avoids that it happens after the "\n", which
|
||||
* confuses the system function that computes tabstops. */
|
||||
@@ -1905,27 +1917,24 @@ getexmodeline(c, dummy, indent)
|
||||
|
||||
/* always start in column 0; write a newline if necessary */
|
||||
compute_cmdrow();
|
||||
if (msg_col)
|
||||
if ((msg_col || msg_didout) && promptc != '?')
|
||||
msg_putchar('\n');
|
||||
if (c == ':')
|
||||
if (promptc == ':')
|
||||
{
|
||||
/* indent that is only displayed, not in the line itself */
|
||||
msg_putchar(':');
|
||||
if (p_prompt)
|
||||
msg_putchar(':');
|
||||
while (indent-- > 0)
|
||||
msg_putchar(' ');
|
||||
#if defined(FEAT_GUI) || defined(NO_COOKED_INPUT)
|
||||
startcol = msg_col;
|
||||
#endif
|
||||
}
|
||||
|
||||
ga_init2(&line_ga, 1, 30);
|
||||
|
||||
/* autoindent for :insert and :append is in the line itself */
|
||||
if (c <= 0)
|
||||
if (promptc <= 0)
|
||||
{
|
||||
#if defined(FEAT_GUI) || defined(NO_COOKED_INPUT)
|
||||
vcol = indent;
|
||||
#endif
|
||||
while (indent >= 8)
|
||||
{
|
||||
ga_append(&line_ga, TAB);
|
||||
@@ -1938,198 +1947,180 @@ getexmodeline(c, dummy, indent)
|
||||
msg_putchar(' ');
|
||||
}
|
||||
}
|
||||
++no_mapping;
|
||||
++allow_keys;
|
||||
|
||||
/*
|
||||
* Get the line, one character at a time.
|
||||
*/
|
||||
got_int = FALSE;
|
||||
while (!got_int && !finished)
|
||||
while (!got_int)
|
||||
{
|
||||
if (ga_grow(&line_ga, 40) == FAIL)
|
||||
break;
|
||||
pend = (char_u *)line_ga.ga_data + line_ga.ga_len;
|
||||
|
||||
/* Get one character (inchar gets a third of maxlen characters!) */
|
||||
len = inchar(pend + off, 3, -1L, 0);
|
||||
if (len < 0)
|
||||
continue; /* end of input script reached */
|
||||
/* for a special character, we need at least three characters */
|
||||
if ((*pend == K_SPECIAL || *pend == CSI) && off + len < 3)
|
||||
{
|
||||
off += len;
|
||||
continue;
|
||||
}
|
||||
len += off;
|
||||
off = 0;
|
||||
/* Get one character at a time. Don't use inchar(), it can't handle
|
||||
* special characters. */
|
||||
c1 = vgetc();
|
||||
|
||||
/*
|
||||
* When using the GUI, and for systems that don't have cooked input,
|
||||
* handle line editing here.
|
||||
* Handle line editing.
|
||||
* Previously this was left to the system, putting the terminal in
|
||||
* cooked mode, but then CTRL-D and CTRL-T can't be used properly.
|
||||
*/
|
||||
#if defined(FEAT_GUI) || defined(NO_COOKED_INPUT)
|
||||
# ifndef NO_COOKED_INPUT
|
||||
if (gui.in_use)
|
||||
# endif
|
||||
if (got_int)
|
||||
{
|
||||
if (got_int)
|
||||
msg_putchar('\n');
|
||||
break;
|
||||
}
|
||||
|
||||
if (!escaped)
|
||||
{
|
||||
/* CR typed means "enter", which is NL */
|
||||
if (c1 == '\r')
|
||||
c1 = '\n';
|
||||
|
||||
if (c1 == BS || c1 == K_BS
|
||||
|| c1 == DEL || c1 == K_DEL || c1 == K_KDEL)
|
||||
{
|
||||
msg_putchar('\n');
|
||||
break;
|
||||
if (line_ga.ga_len > 0)
|
||||
{
|
||||
--line_ga.ga_len;
|
||||
goto redraw;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
if (c1 == Ctrl_U)
|
||||
{
|
||||
c1 = *pend++;
|
||||
--len;
|
||||
if ((c1 == K_SPECIAL
|
||||
# if !defined(NO_COOKED_INPUT) || defined(FEAT_GUI)
|
||||
|| c1 == CSI
|
||||
# endif
|
||||
) && len >= 2)
|
||||
msg_col = startcol;
|
||||
msg_clr_eos();
|
||||
line_ga.ga_len = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c1 == Ctrl_T)
|
||||
{
|
||||
p = (char_u *)line_ga.ga_data;
|
||||
p[line_ga.ga_len] = NUL;
|
||||
indent = get_indent_str(p, 8);
|
||||
indent += curbuf->b_p_sw - indent % curbuf->b_p_sw;
|
||||
add_indent:
|
||||
while (get_indent_str(p, 8) < indent)
|
||||
{
|
||||
c1 = TO_SPECIAL(pend[0], pend[1]);
|
||||
pend += 2;
|
||||
len -= 2;
|
||||
char_u *s = skipwhite(p);
|
||||
|
||||
ga_grow(&line_ga, 1);
|
||||
mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1);
|
||||
*s = ' ';
|
||||
++line_ga.ga_len;
|
||||
}
|
||||
|
||||
if (!escaped)
|
||||
redraw:
|
||||
/* redraw the line */
|
||||
msg_col = startcol;
|
||||
windgoto(msg_row, msg_col);
|
||||
vcol = 0;
|
||||
for (p = (char_u *)line_ga.ga_data;
|
||||
p < (char_u *)line_ga.ga_data + line_ga.ga_len; ++p)
|
||||
{
|
||||
/* CR typed means "enter", which is NL */
|
||||
if (c1 == '\r')
|
||||
c1 = '\n';
|
||||
|
||||
if (c1 == BS || c1 == K_BS
|
||||
|| c1 == DEL || c1 == K_DEL || c1 == K_KDEL)
|
||||
if (*p == TAB)
|
||||
{
|
||||
if (line_ga.ga_len > 0)
|
||||
do
|
||||
{
|
||||
int i, v;
|
||||
char_u *q;
|
||||
|
||||
--line_ga.ga_len;
|
||||
/* compute column that cursor should be in */
|
||||
v = 0;
|
||||
q = ((char_u *)line_ga.ga_data);
|
||||
for (i = 0; i < line_ga.ga_len; ++i)
|
||||
{
|
||||
if (*q == TAB)
|
||||
v += 8 - v % 8;
|
||||
else
|
||||
v += ptr2cells(q);
|
||||
++q;
|
||||
}
|
||||
/* erase characters to position cursor */
|
||||
while (vcol > v)
|
||||
{
|
||||
msg_putchar('\b');
|
||||
msg_putchar(' ');
|
||||
msg_putchar('\b');
|
||||
--vcol;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
msg_putchar(' ');
|
||||
} while (++vcol % 8);
|
||||
}
|
||||
|
||||
if (c1 == Ctrl_U)
|
||||
else
|
||||
{
|
||||
msg_col = startcol;
|
||||
msg_clr_eos();
|
||||
line_ga.ga_len = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c1 == Ctrl_T)
|
||||
c1 = TAB; /* very simplistic... */
|
||||
|
||||
if (c1 == Ctrl_D)
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
/* Delete one shiftwidth. */
|
||||
p = (char_u *)line_ga.ga_data;
|
||||
p[line_ga.ga_len] = NUL;
|
||||
indent = get_indent_str(p, 8);
|
||||
--indent;
|
||||
indent -= indent % 8;
|
||||
while (get_indent_str(p, 8) > indent)
|
||||
{
|
||||
char_u *s = skipwhite(p);
|
||||
|
||||
mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1);
|
||||
--line_ga.ga_len;
|
||||
}
|
||||
msg_col = startcol;
|
||||
for (vcol = 0; *p != NUL; ++p)
|
||||
{
|
||||
if (*p == TAB)
|
||||
{
|
||||
do
|
||||
{
|
||||
msg_putchar(' ');
|
||||
} while (++vcol % 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_outtrans_len(p, 1);
|
||||
vcol += char2cells(*p);
|
||||
}
|
||||
}
|
||||
msg_clr_eos();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c1 == Ctrl_V)
|
||||
{
|
||||
escaped = TRUE;
|
||||
continue;
|
||||
msg_outtrans_len(p, 1);
|
||||
vcol += char2cells(*p);
|
||||
}
|
||||
}
|
||||
msg_clr_eos();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IS_SPECIAL(c1))
|
||||
c1 = '?';
|
||||
((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1;
|
||||
if (c1 == '\n')
|
||||
msg_putchar('\n');
|
||||
else if (c1 == TAB)
|
||||
if (c1 == Ctrl_D)
|
||||
{
|
||||
/* Delete one shiftwidth. */
|
||||
p = (char_u *)line_ga.ga_data;
|
||||
if (prev_char == '0' || prev_char == '^')
|
||||
{
|
||||
/* Don't use chartabsize(), 'ts' can be different */
|
||||
do
|
||||
{
|
||||
msg_putchar(' ');
|
||||
} while (++vcol % 8);
|
||||
if (prev_char == '^')
|
||||
ex_keep_indent = TRUE;
|
||||
indent = 0;
|
||||
p[--line_ga.ga_len] = NUL;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_outtrans_len(
|
||||
((char_u *)line_ga.ga_data) + line_ga.ga_len, 1);
|
||||
vcol += char2cells(c1);
|
||||
p[line_ga.ga_len] = NUL;
|
||||
indent = get_indent_str(p, 8);
|
||||
--indent;
|
||||
indent -= indent % curbuf->b_p_sw;
|
||||
}
|
||||
++line_ga.ga_len;
|
||||
escaped = FALSE;
|
||||
while (get_indent_str(p, 8) > indent)
|
||||
{
|
||||
char_u *s = skipwhite(p);
|
||||
|
||||
mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1);
|
||||
--line_ga.ga_len;
|
||||
}
|
||||
goto add_indent;
|
||||
}
|
||||
windgoto(msg_row, msg_col);
|
||||
|
||||
if (c1 == Ctrl_V || c1 == Ctrl_Q)
|
||||
{
|
||||
escaped = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ignore special key codes: mouse movement, K_IGNORE, etc. */
|
||||
if (IS_SPECIAL(c1))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IS_SPECIAL(c1))
|
||||
c1 = '?';
|
||||
((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1;
|
||||
prev_char = c1;
|
||||
if (c1 == '\n')
|
||||
msg_putchar('\n');
|
||||
else if (c1 == TAB)
|
||||
{
|
||||
/* Don't use chartabsize(), 'ts' can be different */
|
||||
do
|
||||
{
|
||||
msg_putchar(' ');
|
||||
} while (++vcol % 8);
|
||||
}
|
||||
# ifndef NO_COOKED_INPUT
|
||||
else
|
||||
# endif
|
||||
#endif
|
||||
#ifndef NO_COOKED_INPUT
|
||||
{
|
||||
line_ga.ga_len += len;
|
||||
msg_outtrans_len(
|
||||
((char_u *)line_ga.ga_data) + line_ga.ga_len, 1);
|
||||
vcol += char2cells(c1);
|
||||
}
|
||||
#endif
|
||||
++line_ga.ga_len;
|
||||
escaped = FALSE;
|
||||
|
||||
windgoto(msg_row, msg_col);
|
||||
pend = (char_u *)(line_ga.ga_data) + line_ga.ga_len;
|
||||
if (line_ga.ga_len && pend[-1] == '\n')
|
||||
|
||||
/* we are done when a NL is entered, but not when it comes after a
|
||||
* backslash */
|
||||
if (line_ga.ga_len > 0 && pend[-1] == '\n'
|
||||
&& (line_ga.ga_len <= 1 || pend[-2] != '\\'))
|
||||
{
|
||||
finished = TRUE;
|
||||
--line_ga.ga_len;
|
||||
--pend;
|
||||
*pend = NUL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* note that cursor has moved, because of the echoed <CR> */
|
||||
screen_down();
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
|
||||
/* make following messages go to the next line */
|
||||
msg_didout = FALSE;
|
||||
msg_col = 0;
|
||||
@@ -3797,10 +3788,10 @@ addstar(fname, len, context)
|
||||
set_expand_context(xp)
|
||||
expand_T *xp;
|
||||
{
|
||||
/* only expansion for ':' and '>' commands */
|
||||
/* only expansion for ':', '>' and '=' command-lines */
|
||||
if (ccline.cmdfirstc != ':'
|
||||
#ifdef FEAT_EVAL
|
||||
&& ccline.cmdfirstc != '>'
|
||||
&& ccline.cmdfirstc != '>' && ccline.cmdfirstc != '='
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -3828,8 +3819,16 @@ set_cmd_context(xp, str, len, col)
|
||||
old_char = str[col];
|
||||
str[col] = NUL;
|
||||
nextcomm = str;
|
||||
while (nextcomm != NULL)
|
||||
nextcomm = set_one_cmd_context(xp, nextcomm);
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
if (ccline.cmdfirstc == '=')
|
||||
/* pass CMD_SIZE because there is no real command */
|
||||
set_context_for_expression(xp, str, CMD_SIZE);
|
||||
else
|
||||
#endif
|
||||
while (nextcomm != NULL)
|
||||
nextcomm = set_one_cmd_context(xp, nextcomm);
|
||||
|
||||
str[col] = old_char;
|
||||
}
|
||||
|
||||
@@ -5477,7 +5476,7 @@ ex_window()
|
||||
* Call the main loop until <CR> or CTRL-C is typed.
|
||||
*/
|
||||
cmdwin_result = 0;
|
||||
main_loop(TRUE);
|
||||
main_loop(TRUE, FALSE);
|
||||
|
||||
RedrawingDisabled = i;
|
||||
|
||||
|
||||
723
src/gui_mac.c
723
src/gui_mac.c
File diff suppressed because it is too large
Load Diff
22
src/ops.c
22
src/ops.c
@@ -1105,10 +1105,20 @@ do_execreg(regname, colon, addcr)
|
||||
int remap;
|
||||
|
||||
if (regname == '@') /* repeat previous one */
|
||||
{
|
||||
if (lastc == NUL)
|
||||
{
|
||||
EMSG(_("E748: No previously used register"));
|
||||
return FAIL;
|
||||
}
|
||||
regname = lastc;
|
||||
}
|
||||
/* check for valid regname */
|
||||
if (regname == '%' || regname == '#' || !valid_yank_reg(regname, FALSE))
|
||||
{
|
||||
emsg_invreg(regname);
|
||||
return FAIL;
|
||||
}
|
||||
lastc = regname;
|
||||
|
||||
#ifdef FEAT_CLIPBOARD
|
||||
@@ -3597,7 +3607,13 @@ error:
|
||||
else
|
||||
curbuf->b_op_end.col = 0;
|
||||
|
||||
if (flags & PUT_CURSEND)
|
||||
if (flags & PUT_CURSLINE)
|
||||
{
|
||||
/* ":put": put cursor on last inserte line */
|
||||
curwin->w_cursor.lnum = lnum;
|
||||
beginline(BL_WHITE | BL_FIX);
|
||||
}
|
||||
else if (flags & PUT_CURSEND)
|
||||
{
|
||||
/* put cursor after inserted text */
|
||||
if (y_type == MLINE)
|
||||
@@ -3616,7 +3632,7 @@ error:
|
||||
}
|
||||
else if (y_type == MLINE)
|
||||
{
|
||||
/* put cursor onfirst non-blank in first inserted line */
|
||||
/* put cursor on first non-blank in first inserted line */
|
||||
curwin->w_cursor.col = 0;
|
||||
if (dir == FORWARD)
|
||||
++curwin->w_cursor.lnum;
|
||||
@@ -5676,7 +5692,7 @@ write_reg_contents_ex(name, str, maxlen, must_append, yank_type, block_len)
|
||||
|
||||
if (!valid_yank_reg(name, TRUE)) /* check for valid reg name */
|
||||
{
|
||||
EMSG2(_("E354: Invalid register name: '%s'"), transchar(name));
|
||||
emsg_invreg(name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
61
src/option.c
61
src/option.c
@@ -1723,8 +1723,8 @@ static struct vimoption
|
||||
#endif
|
||||
},
|
||||
{"prompt", NULL, P_BOOL|P_VI_DEF,
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)0L}},
|
||||
(char_u *)&p_prompt, PV_NONE,
|
||||
{(char_u *)TRUE, (char_u *)0L}},
|
||||
{"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
|
||||
#ifdef FEAT_TEXTOBJ
|
||||
(char_u *)&p_qe, PV_QE,
|
||||
@@ -1922,6 +1922,9 @@ static struct vimoption
|
||||
(char_u *)NULL, PV_NONE,
|
||||
#endif
|
||||
{(char_u *)FALSE, (char_u *)0L}},
|
||||
{"shelltemp", "stmp", P_BOOL,
|
||||
(char_u *)&p_stmp, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)TRUE}},
|
||||
{"shelltype", "st", P_NUM|P_VI_DEF,
|
||||
#ifdef AMIGA
|
||||
(char_u *)&p_st, PV_NONE,
|
||||
@@ -2501,7 +2504,7 @@ static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
|
||||
static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
|
||||
#endif
|
||||
static char *(p_swb_values[]) = {"useopen", "split", NULL};
|
||||
static char *(p_debug_values[]) = {"msg", NULL};
|
||||
static char *(p_debug_values[]) = {"msg", "beep", NULL};
|
||||
#ifdef FEAT_VERTSPLIT
|
||||
static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
|
||||
#endif
|
||||
@@ -2593,7 +2596,10 @@ set_init_1()
|
||||
|
||||
/* Use POSIX compatibility when $VIM_POSIX is set. */
|
||||
if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
|
||||
{
|
||||
set_string_default("cpo", (char_u *)CPO_ALL);
|
||||
set_string_default("shm", (char_u *)"A");
|
||||
}
|
||||
|
||||
/*
|
||||
* Find default value for 'shell' option.
|
||||
@@ -2885,6 +2891,23 @@ set_init_1()
|
||||
vim_setenv("LANG", buf);
|
||||
}
|
||||
}
|
||||
# else
|
||||
# ifdef MACOS
|
||||
if (mch_getenv((char_u *)"LANG") == NULL)
|
||||
{
|
||||
char buf[20];
|
||||
if (LocaleRefGetPartString(NULL,
|
||||
kLocaleLanguageMask | kLocaleLanguageVariantMask |
|
||||
kLocaleRegionMask | kLocaleRegionVariantMask,
|
||||
sizeof buf, buf) == noErr && *buf)
|
||||
{
|
||||
vim_setenv("LANG", buf);
|
||||
# ifdef HAVE_LOCALE_H
|
||||
setlocale(LC_ALL, "");
|
||||
# endif
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* enc_locale() will try to find the encoding of the current locale. */
|
||||
@@ -3093,6 +3116,9 @@ set_init_2()
|
||||
* wrong when the window height changes.
|
||||
*/
|
||||
set_number_default("scroll", (long_u)Rows >> 1);
|
||||
idx = findoption((char_u *)"scroll");
|
||||
if (!(options[idx].flags & P_WAS_SET))
|
||||
set_option_default(idx, OPT_LOCAL, p_cp);
|
||||
comp_col();
|
||||
|
||||
/*
|
||||
@@ -3423,7 +3449,8 @@ do_set(arg, opt_flags)
|
||||
if (*arg == NUL)
|
||||
{
|
||||
showoptions(0, opt_flags);
|
||||
return OK;
|
||||
did_show = TRUE;
|
||||
goto theend;
|
||||
}
|
||||
|
||||
while (*arg != NUL) /* loop to process all options */
|
||||
@@ -3446,12 +3473,16 @@ do_set(arg, opt_flags)
|
||||
set_options_default(OPT_FREE | opt_flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
showoptions(1, opt_flags);
|
||||
did_show = TRUE;
|
||||
}
|
||||
}
|
||||
else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
|
||||
{
|
||||
showoptions(2, opt_flags);
|
||||
show_termcodes();
|
||||
did_show = TRUE;
|
||||
arg += 7;
|
||||
}
|
||||
else
|
||||
@@ -4187,6 +4218,19 @@ skip:
|
||||
arg = skipwhite(arg);
|
||||
}
|
||||
|
||||
theend:
|
||||
if (silent_mode && did_show)
|
||||
{
|
||||
/* After displaying option values in silent mode. */
|
||||
silent_mode = FALSE;
|
||||
info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
|
||||
msg_putchar('\n');
|
||||
cursor_on(); /* msg_start() switches it off */
|
||||
out_flush();
|
||||
silent_mode = TRUE;
|
||||
info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -7547,7 +7591,11 @@ showoneopt(p, opt_flags)
|
||||
struct vimoption *p;
|
||||
int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
|
||||
{
|
||||
char_u *varp;
|
||||
char_u *varp;
|
||||
int save_silent = silent_mode;
|
||||
|
||||
silent_mode = FALSE;
|
||||
info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
|
||||
|
||||
varp = get_varp_scope(p, opt_flags);
|
||||
|
||||
@@ -7567,6 +7615,9 @@ showoneopt(p, opt_flags)
|
||||
option_value2string(p, opt_flags);
|
||||
msg_outtrans(NameBuff);
|
||||
}
|
||||
|
||||
silent_mode = save_silent;
|
||||
info_message = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -174,10 +174,13 @@
|
||||
#define CPO_PARA '{' /* "{" is also a paragraph boundary */
|
||||
#define CPO_TSIZE '|' /* $LINES and $COLUMNS overrule term size */
|
||||
#define CPO_PRESERVE '&' /* keep swap file after :preserve */
|
||||
#define CPO_SUBPERCENT '/' /* % in :s string uses previous one */
|
||||
#define CPO_BACKSL '\\' /* \ is not special in [] */
|
||||
#define CPO_CHDIR '.' /* don't chdir if buffer is modified */
|
||||
/* default values for Vim, Vi and POSIX */
|
||||
#define CPO_VIM "aABceFs"
|
||||
#define CPO_VI "aAbBcCdDeEfFgHiIjJkKlLmMnoOpqrRsStuvwWxXyZ$!%*-+<>"
|
||||
#define CPO_ALL "aAbBcCdDeEfFgHiIjJkKlLmMnoOpqrRsStuvwWxXyZ$!%*-+<>#{|&"
|
||||
#define CPO_ALL "aAbBcCdDeEfFgHiIjJkKlLmMnoOpqrRsStuvwWxXyZ$!%*-+<>#{|&/\\."
|
||||
|
||||
/* characters for p_ww option: */
|
||||
#define WW_ALL "bshl<>[],~"
|
||||
@@ -479,6 +482,7 @@ EXTERN char_u *p_pfn; /* 'printfont' */
|
||||
EXTERN char_u *p_popt; /* 'printoptions' */
|
||||
EXTERN char_u *p_header; /* 'printheader' */
|
||||
#endif
|
||||
EXTERN int p_prompt; /* 'prompt' */
|
||||
#ifdef FEAT_GUI
|
||||
EXTERN char_u *p_guifont; /* 'guifont' */
|
||||
# ifdef FEAT_XFONTSET
|
||||
@@ -675,6 +679,7 @@ EXTERN char_u *p_srr; /* 'shellredir' */
|
||||
#ifdef AMIGA
|
||||
EXTERN long p_st; /* 'shelltype' */
|
||||
#endif
|
||||
EXTERN int p_stmp; /* 'shelltemp' */
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
EXTERN int p_ssl; /* 'shellslash' */
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,21 @@ extern char_u *mac_string_convert __ARGS((char_u *ptr, int len, int *lenp, int f
|
||||
extern int macroman2enc __ARGS((char_u *ptr, long *sizep, long real_size));
|
||||
extern int enc2macroman __ARGS((char_u *from, size_t fromlen, char_u *to, int *tolenp, int maxtolen, char_u *rest, int *restlenp));
|
||||
|
||||
extern void mac_conv_init __ARGS((void));
|
||||
extern void mac_conv_cleanup __ARGS((void));
|
||||
extern char_u *mac_utf16_to_enc __ARGS((UniChar *from, size_t fromLen, size_t *actualLen));
|
||||
extern UniChar *mac_enc_to_utf16 __ARGS((char_u *from, size_t fromLen, size_t *actualLen));
|
||||
extern CFStringRef mac_enc_to_cfstring __ARGS((char_u *from, size_t fromLen));
|
||||
extern char_u *mac_precompose_path __ARGS((char_u *decompPath, size_t decompLen, size_t *precompLen));
|
||||
|
||||
static char_u *mac_utf16_to_utf8 __ARGS((UniChar *from, size_t fromLen, size_t *actualLen));
|
||||
static UniChar *mac_utf8_to_utf16 __ARGS((char_u *from, size_t fromLen, size_t *actualLen));
|
||||
|
||||
/* Converter for composing decomposed HFS+ file paths */
|
||||
static TECObjectRef gPathConverter;
|
||||
/* Converter used by mac_utf16_to_utf8 */
|
||||
static TECObjectRef gUTF16ToUTF8Converter;
|
||||
|
||||
/*
|
||||
* A Mac version of string_convert_ext() for special cases.
|
||||
*/
|
||||
@@ -59,6 +74,8 @@ mac_string_convert(ptr, len, lenp, fail_on_error, from_enc, to_enc, unconvlenp)
|
||||
*unconvlenp = 0;
|
||||
cfstr = CFStringCreateWithBytes(NULL, ptr, len, from, 0);
|
||||
|
||||
if(cfstr == NULL)
|
||||
fprintf(stderr, "Encoding failed\n");
|
||||
/* When conversion failed, try excluding bytes from the end, helps when
|
||||
* there is an incomplete byte sequence. Only do up to 6 bytes to avoid
|
||||
* looping a long time when there really is something unconvertable. */
|
||||
@@ -70,6 +87,7 @@ mac_string_convert(ptr, len, lenp, fail_on_error, from_enc, to_enc, unconvlenp)
|
||||
}
|
||||
if (cfstr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (to == kCFStringEncodingUTF8)
|
||||
buflen = len * 6 + 1;
|
||||
else
|
||||
@@ -80,6 +98,22 @@ mac_string_convert(ptr, len, lenp, fail_on_error, from_enc, to_enc, unconvlenp)
|
||||
CFRelease(cfstr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
CFRange convertRange = CFRangeMake(0, CFStringGetLength(cfstr));
|
||||
/* Determine output buffer size */
|
||||
CFStringGetBytes(cfstr, convertRange, to, NULL, FALSE, NULL, 0, (CFIndex *)&buflen);
|
||||
retval = (buflen > 0) ? alloc(buflen) : NULL;
|
||||
if (retval == NULL) {
|
||||
CFRelease(cfstr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lenp)
|
||||
*lenp = buflen / sizeof(char_u);
|
||||
|
||||
if (!CFStringGetBytes(cfstr, convertRange, to, NULL, FALSE, retval, buflen, NULL))
|
||||
#endif
|
||||
if (!CFStringGetCString(cfstr, retval, buflen, to))
|
||||
{
|
||||
CFRelease(cfstr);
|
||||
@@ -89,6 +123,7 @@ mac_string_convert(ptr, len, lenp, fail_on_error, from_enc, to_enc, unconvlenp)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Trying char-by-char conversion...\n");
|
||||
/* conversion failed for the whole string, but maybe it will work
|
||||
* for each character */
|
||||
for (d = retval, in = 0, out = 0; in < len && out < buflen - 1;)
|
||||
@@ -128,6 +163,7 @@ mac_string_convert(ptr, len, lenp, fail_on_error, from_enc, to_enc, unconvlenp)
|
||||
CFRelease(cfstr);
|
||||
if (lenp != NULL)
|
||||
*lenp = strlen(retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -230,4 +266,291 @@ enc2macroman(from, fromlen, to, tolenp, maxtolen, rest, restlenp)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes text converters
|
||||
*/
|
||||
void
|
||||
mac_conv_init()
|
||||
{
|
||||
TextEncoding utf8_encoding;
|
||||
TextEncoding utf8_hfsplus_encoding;
|
||||
TextEncoding utf8_canon_encoding;
|
||||
TextEncoding utf16_encoding;
|
||||
|
||||
utf8_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
|
||||
kTextEncodingDefaultVariant, kUnicodeUTF8Format);
|
||||
utf8_hfsplus_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
|
||||
kUnicodeHFSPlusCompVariant, kUnicodeUTF8Format);
|
||||
utf8_canon_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
|
||||
kUnicodeCanonicalCompVariant, kUnicodeUTF8Format);
|
||||
utf16_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
|
||||
kTextEncodingDefaultVariant, kUnicode16BitFormat);
|
||||
|
||||
if (TECCreateConverter(&gPathConverter, utf8_encoding,
|
||||
utf8_hfsplus_encoding) != noErr)
|
||||
gPathConverter = NULL;
|
||||
|
||||
if (TECCreateConverter(&gUTF16ToUTF8Converter, utf16_encoding,
|
||||
utf8_canon_encoding) != noErr)
|
||||
gUTF16ToUTF8Converter = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys text converters
|
||||
*/
|
||||
void
|
||||
mac_conv_cleanup()
|
||||
{
|
||||
if (gUTF16ToUTF8Converter)
|
||||
{
|
||||
TECDisposeConverter(gUTF16ToUTF8Converter);
|
||||
gUTF16ToUTF8Converter = NULL;
|
||||
}
|
||||
|
||||
if (gPathConverter)
|
||||
{
|
||||
TECDisposeConverter(gPathConverter);
|
||||
gPathConverter = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion from UTF-16 UniChars to 'encoding'
|
||||
*/
|
||||
char_u *
|
||||
mac_utf16_to_enc(from, fromLen, actualLen)
|
||||
UniChar *from;
|
||||
size_t fromLen;
|
||||
size_t *actualLen;
|
||||
{
|
||||
/* Following code borrows somewhat from os_mswin.c */
|
||||
vimconv_T conv;
|
||||
size_t utf8_len;
|
||||
char_u *utf8_str;
|
||||
char_u *result = NULL;
|
||||
|
||||
/* Convert to utf-8 first, works better with iconv */
|
||||
utf8_len = 0;
|
||||
utf8_str = mac_utf16_to_utf8(from, fromLen, &utf8_len);
|
||||
|
||||
if (utf8_str)
|
||||
{
|
||||
/* We might be called before we have p_enc set up. */
|
||||
conv.vc_type = CONV_NONE;
|
||||
|
||||
/* If encoding (p_enc) is any unicode, it is actually in utf-8 (vim
|
||||
* internal unicode is always utf-8) so don't convert in such cases */
|
||||
|
||||
if ((enc_canon_props(p_enc) & ENC_UNICODE) == 0)
|
||||
convert_setup(&conv, (char_u *)"utf-8",
|
||||
p_enc? p_enc: (char_u *)"macroman");
|
||||
if (conv.vc_type == CONV_NONE)
|
||||
{
|
||||
/* p_enc is utf-8, so we're done. */
|
||||
result = utf8_str;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = string_convert(&conv, utf8_str, (int *)&utf8_len);
|
||||
vim_free(utf8_str);
|
||||
}
|
||||
|
||||
convert_setup(&conv, NULL, NULL);
|
||||
|
||||
if (actualLen)
|
||||
*actualLen = utf8_len;
|
||||
}
|
||||
else if (actualLen)
|
||||
*actualLen = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion from 'encoding' to UTF-16 UniChars
|
||||
*/
|
||||
UniChar *
|
||||
mac_enc_to_utf16(from, fromLen, actualLen)
|
||||
char_u *from;
|
||||
size_t fromLen;
|
||||
size_t *actualLen;
|
||||
{
|
||||
/* Following code borrows somewhat from os_mswin.c */
|
||||
vimconv_T conv;
|
||||
size_t utf8_len;
|
||||
char_u *utf8_str;
|
||||
UniChar *result = NULL;
|
||||
Boolean should_free_utf8 = FALSE;
|
||||
|
||||
do
|
||||
{
|
||||
/* Use MacRoman by default, we might be called before we have p_enc
|
||||
* set up. Convert to utf-8 first, works better with iconv(). Does
|
||||
* nothing if 'encoding' is "utf-8". */
|
||||
conv.vc_type = CONV_NONE;
|
||||
if ((enc_canon_props(p_enc) & ENC_UNICODE) == 0 &&
|
||||
convert_setup(&conv, p_enc ? p_enc : (char_u *)"macroman",
|
||||
(char_u *)"utf-8") == FAIL)
|
||||
break;
|
||||
|
||||
if (conv.vc_type != CONV_NONE)
|
||||
{
|
||||
utf8_len = fromLen;
|
||||
utf8_str = string_convert(&conv, from, (int *)&utf8_len);
|
||||
should_free_utf8 = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
utf8_str = from;
|
||||
utf8_len = fromLen;
|
||||
}
|
||||
|
||||
if (utf8_str == NULL)
|
||||
break;
|
||||
|
||||
convert_setup(&conv, NULL, NULL);
|
||||
|
||||
result = mac_utf8_to_utf16(utf8_str, utf8_len, actualLen);
|
||||
|
||||
if (should_free_utf8)
|
||||
vim_free(utf8_str);
|
||||
return result;
|
||||
}
|
||||
while (0);
|
||||
|
||||
if (actualLen)
|
||||
*actualLen = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts from UTF-16 UniChars to CFString
|
||||
*/
|
||||
CFStringRef
|
||||
mac_enc_to_cfstring(from, fromLen)
|
||||
char_u *from;
|
||||
size_t fromLen;
|
||||
{
|
||||
UniChar *utf16_str;
|
||||
size_t utf16_len;
|
||||
CFStringRef result = NULL;
|
||||
|
||||
utf16_str = mac_enc_to_utf16(from, fromLen, &utf16_len);
|
||||
if (utf16_str)
|
||||
{
|
||||
result = CFStringCreateWithCharacters(NULL, utf16_str, utf16_len/sizeof(UniChar));
|
||||
vim_free(utf16_str);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts a decomposed HFS+ UTF-8 path to precomposed UTF-8
|
||||
*/
|
||||
char_u *
|
||||
mac_precompose_path(decompPath, decompLen, precompLen)
|
||||
char_u *decompPath;
|
||||
size_t decompLen;
|
||||
size_t *precompLen;
|
||||
{
|
||||
char_u *result = NULL;
|
||||
size_t actualLen = 0;
|
||||
|
||||
if (gPathConverter)
|
||||
{
|
||||
result = alloc(decompLen);
|
||||
if (result)
|
||||
{
|
||||
if (TECConvertText(gPathConverter, decompPath,
|
||||
decompLen, &decompLen, result,
|
||||
decompLen, &actualLen) != noErr)
|
||||
{
|
||||
vim_free(result);
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (precompLen)
|
||||
*precompLen = actualLen;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts from UTF-16 UniChars to precomposed UTF-8
|
||||
*/
|
||||
char_u *
|
||||
mac_utf16_to_utf8(from, fromLen, actualLen)
|
||||
UniChar *from;
|
||||
size_t fromLen;
|
||||
size_t *actualLen;
|
||||
{
|
||||
ByteCount utf8_len;
|
||||
ByteCount inputRead;
|
||||
char_u *result;
|
||||
|
||||
if (gUTF16ToUTF8Converter)
|
||||
{
|
||||
result = alloc(fromLen * 6 + 1);
|
||||
if (result && TECConvertText(gUTF16ToUTF8Converter, (ConstTextPtr)from,
|
||||
fromLen, &inputRead, result,
|
||||
(fromLen*6+1)*sizeof(char_u), &utf8_len) == noErr)
|
||||
{
|
||||
TECFlushText(gUTF16ToUTF8Converter, result, (fromLen*6+1)*sizeof(char_u), &inputRead);
|
||||
utf8_len += inputRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
vim_free(result);
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
if (actualLen)
|
||||
*actualLen = result ? utf8_len : 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts from UTF-8 to UTF-16 UniChars
|
||||
*/
|
||||
UniChar *
|
||||
mac_utf8_to_utf16(from, fromLen, actualLen)
|
||||
char_u *from;
|
||||
size_t fromLen;
|
||||
size_t *actualLen;
|
||||
{
|
||||
CFStringRef utf8_str;
|
||||
CFRange convertRange;
|
||||
UniChar *result = NULL;
|
||||
|
||||
utf8_str = CFStringCreateWithBytes(NULL, from, fromLen,
|
||||
kCFStringEncodingUTF8, FALSE);
|
||||
|
||||
if (utf8_str == NULL) {
|
||||
if (actualLen)
|
||||
*actualLen = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
convertRange = CFRangeMake(0, CFStringGetLength(utf8_str));
|
||||
result = (UniChar *)alloc(convertRange.length * sizeof(UniChar));
|
||||
|
||||
CFStringGetCharacters(utf8_str, convertRange, result);
|
||||
|
||||
CFRelease(utf8_str);
|
||||
|
||||
if (actualLen)
|
||||
*actualLen = convertRange.length * sizeof(UniChar);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* FEAT_MBYTE */
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
# Please read README_mvc.txt before using this file.
|
||||
#
|
||||
|
||||
LANGUAGES = af ca cs de en_GB es fr it ja ko no pl ru sk sv uk zh_TW \
|
||||
LANGUAGES = af ca cs de en_GB es fr ga it ja ko no pl ru sk sv uk zh_TW \
|
||||
zh_TW.UTF-8 zh_CN zh_CN.UTF-8
|
||||
MOFILES = af.mo ca.mo cs.mo de.mo en_GB.mo es.mo fr.mo it.mo ja.mo \
|
||||
MOFILES = af.mo ca.mo cs.mo de.mo en_GB.mo es.mo fr.mo ga.mo it.mo ja.mo \
|
||||
ko.mo no.mo pl.mo ru.mo sk.mo sv.mo uk.mo \
|
||||
zh_TW.mo zh_TW.UTF-8.mo zh_CN.mo zh_CN.UTF-8.mo
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ int *func_dbg_tick __ARGS((void *cookie));
|
||||
int func_level __ARGS((void *cookie));
|
||||
int current_func_returned __ARGS((void));
|
||||
void set_internal_string_var __ARGS((char_u *name, char_u *value));
|
||||
int var_redir_start __ARGS((char_u *name, int append));
|
||||
void var_redir_str __ARGS((char_u *value, int len));
|
||||
void var_redir_stop __ARGS((void));
|
||||
int eval_charconvert __ARGS((char_u *enc_from, char_u *enc_to, char_u *fname_from, char_u *fname_to));
|
||||
int eval_printexpr __ARGS((char_u *fname, char_u *args));
|
||||
void eval_diff __ARGS((char_u *origfile, char_u *newfile, char_u *outfile));
|
||||
|
||||
12
src/screen.c
12
src/screen.c
@@ -6846,18 +6846,6 @@ screen_start()
|
||||
screen_cur_row = screen_cur_col = 9999;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that the cursor has gone down to the next line, column 0.
|
||||
* Used for Ex mode.
|
||||
*/
|
||||
void
|
||||
screen_down()
|
||||
{
|
||||
screen_cur_col = 0;
|
||||
if (screen_cur_row < Rows - 1)
|
||||
++screen_cur_row;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move the cursor to position "row","col" in the screen.
|
||||
* This tries to find the most efficient way to move, minimizing the number of
|
||||
|
||||
@@ -4715,7 +4715,7 @@ show_pat_in_path(line, type, did_show, action, fp, lnum, count)
|
||||
msg_puts_attr(IObuff, hl_attr(HLF_N));
|
||||
MSG_PUTS(" ");
|
||||
}
|
||||
msg_prt_line(line);
|
||||
msg_prt_line(line, FALSE);
|
||||
out_flush(); /* show one line at a time */
|
||||
|
||||
/* Definition continues until line that doesn't end with '\' */
|
||||
|
||||
@@ -307,7 +307,8 @@ struct m_block
|
||||
{
|
||||
mblock_T *mb_next; /* pointer to next allocated block */
|
||||
size_t mb_size; /* total size of all chunks in this block */
|
||||
minfo_T mb_info; /* head of free chuck list for this block */
|
||||
size_t mb_maxsize; /* size of largest fee chunk */
|
||||
minfo_T mb_info; /* head of free chunk list for this block */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1211,6 +1212,7 @@ struct file_buffer
|
||||
minfo_T *b_m_search; /* pointer to chunk before previously
|
||||
allocated/freed chunk */
|
||||
mblock_T *b_mb_current; /* block where m_search points in */
|
||||
|
||||
#ifdef FEAT_INS_EXPAND
|
||||
int b_scanned; /* ^N/^P have scanned this buffer */
|
||||
#endif
|
||||
|
||||
17
src/syntax.c
17
src/syntax.c
@@ -4397,8 +4397,19 @@ syn_cmd_keyword(eap, syncing)
|
||||
add_keyword(kw, syn_id, syn_opt_arg.flags,
|
||||
syn_opt_arg.cont_in_list,
|
||||
syn_opt_arg.next_list);
|
||||
if (p == NULL || p[1] == NUL || p[1] == ']')
|
||||
if (p == NULL)
|
||||
break;
|
||||
if (p[1] == NUL)
|
||||
{
|
||||
EMSG2(_("E747: Missing ']': %s"), kw);
|
||||
kw = p + 2; /* skip over the NUL */
|
||||
break;
|
||||
}
|
||||
if (p[1] == ']')
|
||||
{
|
||||
kw = p + 1; /* skip over the "]" */
|
||||
break;
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
@@ -4418,6 +4429,8 @@ syn_cmd_keyword(eap, syncing)
|
||||
}
|
||||
|
||||
vim_free(keyword_copy);
|
||||
vim_free(syn_opt_arg.cont_in_list);
|
||||
vim_free(syn_opt_arg.next_list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4426,8 +4439,6 @@ syn_cmd_keyword(eap, syncing)
|
||||
else
|
||||
EMSG2(_(e_invarg2), arg);
|
||||
|
||||
vim_free(syn_opt_arg.cont_in_list);
|
||||
vim_free(syn_opt_arg.next_list);
|
||||
redraw_curbuf_later(NOT_VALID);
|
||||
syn_stack_free_all(curbuf); /* Need to recompute all syntax. */
|
||||
}
|
||||
|
||||
@@ -1590,6 +1590,10 @@ set_termname(term)
|
||||
char_u *error_msg = NULL;
|
||||
char_u *bs_p, *del_p;
|
||||
|
||||
/* In silect mode (ex -s) we don't use the 'term' option. */
|
||||
if (silent_mode)
|
||||
return OK;
|
||||
|
||||
detected_8bit = FALSE; /* reset 8-bit detection */
|
||||
|
||||
if (term_is_builtin(term))
|
||||
@@ -3146,10 +3150,6 @@ settmode(tmode)
|
||||
|
||||
if (full_screen)
|
||||
{
|
||||
/* In Ex mode, never set to RAW */
|
||||
if (exmode_active == EXMODE_NORMAL)
|
||||
tmode = TMODE_COOK;
|
||||
|
||||
/*
|
||||
* When returning after calling a shell we want to really set the
|
||||
* terminal to raw mode, even though we think it already is, because
|
||||
|
||||
186
src/undo.c
186
src/undo.c
@@ -41,24 +41,33 @@
|
||||
* curbuf->b_u_curhead points to the header of the last undo (the next redo),
|
||||
* or is NULL if nothing has been undone.
|
||||
*
|
||||
* All data is allocated with u_alloc_line(), thus it will be freed as soon as
|
||||
* we switch files!
|
||||
* All data is allocated with U_ALLOC_LINE(), it will be freed as soon as the
|
||||
* buffer is unloaded.
|
||||
*/
|
||||
|
||||
#include "vim.h"
|
||||
|
||||
/* See below: use malloc()/free() for memory management. */
|
||||
#define U_USE_MALLOC 1
|
||||
|
||||
static u_entry_T *u_get_headentry __ARGS((void));
|
||||
static void u_getbot __ARGS((void));
|
||||
static int u_savecommon __ARGS((linenr_T, linenr_T, linenr_T));
|
||||
static void u_doit __ARGS((int count));
|
||||
static void u_undoredo __ARGS((void));
|
||||
static void u_undo_end __ARGS((void));
|
||||
static void u_freelist __ARGS((struct u_header *));
|
||||
static void u_freelist __ARGS((buf_T *buf, struct u_header *));
|
||||
static void u_freeentry __ARGS((u_entry_T *, long));
|
||||
|
||||
static char_u *u_blockalloc __ARGS((long_u));
|
||||
static void u_free_line __ARGS((char_u *, int keep));
|
||||
static char_u *u_alloc_line __ARGS((unsigned));
|
||||
#ifdef U_USE_MALLOC
|
||||
# define U_FREE_LINE(ptr) vim_free(ptr)
|
||||
# define U_ALLOC_LINE(size) lalloc((long_u)((size) + 1), FALSE)
|
||||
#else
|
||||
static void u_free_line __ARGS((char_u *ptr, int keep));
|
||||
static char_u *u_alloc_line __ARGS((unsigned size));
|
||||
# define U_FREE_LINE(ptr) u_free_line((ptr), FALSE)
|
||||
# define U_ALLOC_LINE(size) u_alloc_line(size)
|
||||
#endif
|
||||
static char_u *u_save_line __ARGS((linenr_T));
|
||||
|
||||
static long u_newcount, u_oldcount;
|
||||
@@ -227,13 +236,13 @@ u_savecommon(top, bot, newbot)
|
||||
* including curbuf->b_u_curhead
|
||||
*/
|
||||
while (curbuf->b_u_curhead != NULL)
|
||||
u_freelist(curbuf->b_u_newhead);
|
||||
u_freelist(curbuf, curbuf->b_u_newhead);
|
||||
|
||||
/*
|
||||
* free headers to keep the size right
|
||||
*/
|
||||
while (curbuf->b_u_numhead > p_ul && curbuf->b_u_oldhead != NULL)
|
||||
u_freelist(curbuf->b_u_oldhead);
|
||||
u_freelist(curbuf, curbuf->b_u_oldhead);
|
||||
|
||||
if (p_ul < 0) /* no undo at all */
|
||||
{
|
||||
@@ -244,7 +253,7 @@ u_savecommon(top, bot, newbot)
|
||||
/*
|
||||
* make a new header entry
|
||||
*/
|
||||
uhp = (struct u_header *)u_alloc_line((unsigned)
|
||||
uhp = (struct u_header *)U_ALLOC_LINE((unsigned)
|
||||
sizeof(struct u_header));
|
||||
if (uhp == NULL)
|
||||
goto nomem;
|
||||
@@ -364,7 +373,7 @@ u_savecommon(top, bot, newbot)
|
||||
/*
|
||||
* add lines in front of entry list
|
||||
*/
|
||||
uep = (u_entry_T *)u_alloc_line((unsigned)sizeof(u_entry_T));
|
||||
uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T));
|
||||
if (uep == NULL)
|
||||
goto nomem;
|
||||
|
||||
@@ -384,9 +393,9 @@ u_savecommon(top, bot, newbot)
|
||||
curbuf->b_u_newhead->uh_getbot_entry = uep;
|
||||
}
|
||||
|
||||
if (size)
|
||||
if (size > 0)
|
||||
{
|
||||
if ((uep->ue_array = (char_u **)u_alloc_line(
|
||||
if ((uep->ue_array = (char_u **)U_ALLOC_LINE(
|
||||
(unsigned)(sizeof(char_u *) * size))) == NULL)
|
||||
{
|
||||
u_freeentry(uep, 0L);
|
||||
@@ -609,9 +618,9 @@ u_undoredo()
|
||||
empty_buffer = FALSE;
|
||||
|
||||
/* delete the lines between top and bot and save them in newarray */
|
||||
if (oldsize)
|
||||
if (oldsize > 0)
|
||||
{
|
||||
if ((newarray = (char_u **)u_alloc_line(
|
||||
if ((newarray = (char_u **)U_ALLOC_LINE(
|
||||
(unsigned)(sizeof(char_u *) * oldsize))) == NULL)
|
||||
{
|
||||
do_outofmem_msg((long_u)(sizeof(char_u *) * oldsize));
|
||||
@@ -654,9 +663,9 @@ u_undoredo()
|
||||
ml_replace((linenr_T)1, uep->ue_array[i], TRUE);
|
||||
else
|
||||
ml_append(lnum, uep->ue_array[i], (colnr_T)0, FALSE);
|
||||
u_free_line(uep->ue_array[i], FALSE);
|
||||
U_FREE_LINE(uep->ue_array[i]);
|
||||
}
|
||||
u_free_line((char_u *)uep->ue_array, FALSE);
|
||||
U_FREE_LINE((char_u *)uep->ue_array);
|
||||
}
|
||||
|
||||
/* adjust marks */
|
||||
@@ -870,7 +879,8 @@ u_getbot()
|
||||
* u_freelist: free one entry list and adjust the pointers
|
||||
*/
|
||||
static void
|
||||
u_freelist(uhp)
|
||||
u_freelist(buf, uhp)
|
||||
buf_T *buf;
|
||||
struct u_header *uhp;
|
||||
{
|
||||
u_entry_T *uep, *nuep;
|
||||
@@ -881,21 +891,21 @@ u_freelist(uhp)
|
||||
u_freeentry(uep, uep->ue_size);
|
||||
}
|
||||
|
||||
if (curbuf->b_u_curhead == uhp)
|
||||
curbuf->b_u_curhead = NULL;
|
||||
if (buf->b_u_curhead == uhp)
|
||||
buf->b_u_curhead = NULL;
|
||||
|
||||
if (uhp->uh_next == NULL)
|
||||
curbuf->b_u_oldhead = uhp->uh_prev;
|
||||
buf->b_u_oldhead = uhp->uh_prev;
|
||||
else
|
||||
uhp->uh_next->uh_prev = uhp->uh_prev;
|
||||
|
||||
if (uhp->uh_prev == NULL)
|
||||
curbuf->b_u_newhead = uhp->uh_next;
|
||||
buf->b_u_newhead = uhp->uh_next;
|
||||
else
|
||||
uhp->uh_prev->uh_next = uhp->uh_next;
|
||||
|
||||
u_free_line((char_u *)uhp, FALSE);
|
||||
--curbuf->b_u_numhead;
|
||||
U_FREE_LINE((char_u *)uhp);
|
||||
--buf->b_u_numhead;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -907,8 +917,8 @@ u_freeentry(uep, n)
|
||||
long n;
|
||||
{
|
||||
while (n)
|
||||
u_free_line(uep->ue_array[--n], FALSE);
|
||||
u_free_line((char_u *)uep, FALSE);
|
||||
U_FREE_LINE(uep->ue_array[--n]);
|
||||
U_FREE_LINE((char_u *)uep);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -955,7 +965,7 @@ u_clearline()
|
||||
{
|
||||
if (curbuf->b_u_line_ptr != NULL)
|
||||
{
|
||||
u_free_line(curbuf->b_u_line_ptr, FALSE);
|
||||
U_FREE_LINE(curbuf->b_u_line_ptr);
|
||||
curbuf->b_u_line_ptr = NULL;
|
||||
curbuf->b_u_line_lnum = 0;
|
||||
}
|
||||
@@ -993,7 +1003,7 @@ u_undoline()
|
||||
}
|
||||
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, TRUE);
|
||||
changed_bytes(curbuf->b_u_line_lnum, 0);
|
||||
u_free_line(curbuf->b_u_line_ptr, FALSE);
|
||||
U_FREE_LINE(curbuf->b_u_line_ptr);
|
||||
curbuf->b_u_line_ptr = oldp;
|
||||
|
||||
t = curbuf->b_u_line_colnr;
|
||||
@@ -1004,7 +1014,40 @@ u_undoline()
|
||||
}
|
||||
|
||||
/*
|
||||
* storage allocation for the undo lines and blocks of the current file
|
||||
* There are two implementations of the memory management for undo:
|
||||
* 1. Use the standard malloc()/free() functions.
|
||||
* This should be fast for allocating memory, but when a buffer is
|
||||
* abandoned every single allocated chunk must be freed, which may be slow.
|
||||
* 2. Allocate larger blocks of memory and keep track of chunks ourselves.
|
||||
* This is fast for abandoning, but the use of linked lists is slow for
|
||||
* finding a free chunk. Esp. when a lot of lines are changed or deleted.
|
||||
* A bit of profiling showed that the first method is faster, especially when
|
||||
* making a large number of changes, under the condition that malloc()/free()
|
||||
* is implemented efficiently.
|
||||
*/
|
||||
#ifdef U_USE_MALLOC
|
||||
/*
|
||||
* Version of undo memory allocation using malloc()/free()
|
||||
*
|
||||
* U_FREE_LINE() and U_ALLOC_LINE() are macros that invoke vim_free() and
|
||||
* lalloc() directly.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Free all allocated memory blocks for the buffer 'buf'.
|
||||
*/
|
||||
void
|
||||
u_blockfree(buf)
|
||||
buf_T *buf;
|
||||
{
|
||||
while (buf->b_u_newhead != NULL)
|
||||
u_freelist(buf, buf->b_u_newhead);
|
||||
}
|
||||
|
||||
#else
|
||||
/*
|
||||
* Storage allocation for the undo lines and blocks of the current file.
|
||||
* Version where Vim keeps track of the available memory.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -1071,6 +1114,8 @@ u_undoline()
|
||||
# define M_OFFSET (sizeof(short_u))
|
||||
#endif
|
||||
|
||||
static char_u *u_blockalloc __ARGS((long_u));
|
||||
|
||||
/*
|
||||
* Allocate a block of memory and link it in the allocated block list.
|
||||
*/
|
||||
@@ -1092,6 +1137,7 @@ u_blockalloc(size)
|
||||
;
|
||||
p->mb_next = next; /* link in block list */
|
||||
p->mb_size = size;
|
||||
p->mb_maxsize = 0; /* nothing free yet */
|
||||
mp->mb_next = p;
|
||||
p->mb_info.m_next = NULL; /* clear free list */
|
||||
p->mb_info.m_size = 0;
|
||||
@@ -1135,6 +1181,7 @@ u_free_line(ptr, keep)
|
||||
minfo_T *mp;
|
||||
mblock_T *nextb;
|
||||
mblock_T *prevb;
|
||||
long_u maxsize;
|
||||
|
||||
if (ptr == NULL || ptr == IObuff)
|
||||
return; /* illegal address can happen in out-of-memory situations */
|
||||
@@ -1212,11 +1259,13 @@ u_free_line(ptr, keep)
|
||||
}
|
||||
else
|
||||
mp->m_next = next;
|
||||
maxsize = mp->m_size;
|
||||
|
||||
/* if *curr and *mp are concatenated, join them */
|
||||
if (prev != NULL && (char_u *)curr + curr->m_size == (char_u *)mp)
|
||||
{
|
||||
curr->m_size += mp->m_size;
|
||||
maxsize = curr->m_size;
|
||||
curr->m_next = mp->m_next;
|
||||
curbuf->b_m_search = prev;
|
||||
}
|
||||
@@ -1244,6 +1293,8 @@ u_free_line(ptr, keep)
|
||||
curbuf->b_mb_current = NULL;
|
||||
curbuf->b_m_search = NULL;
|
||||
}
|
||||
else if (curbuf->b_mb_current->mb_maxsize < maxsize)
|
||||
curbuf->b_mb_current->mb_maxsize = maxsize;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1282,48 +1333,56 @@ u_alloc_line(size)
|
||||
curbuf->b_m_search = &(curbuf->b_block_head.mb_info);
|
||||
}
|
||||
|
||||
/* search for space in free list */
|
||||
mprev = curbuf->b_m_search;
|
||||
/* Search for a block with enough space. */
|
||||
mbp = curbuf->b_mb_current;
|
||||
mp = curbuf->b_m_search->m_next;
|
||||
if (mp == NULL)
|
||||
while (mbp->mb_maxsize < size_align)
|
||||
{
|
||||
if (mbp->mb_next)
|
||||
if (mbp->mb_next != NULL)
|
||||
mbp = mbp->mb_next;
|
||||
else
|
||||
mbp = &curbuf->b_block_head;
|
||||
mp = curbuf->b_m_search = &(mbp->mb_info);
|
||||
}
|
||||
while (mp->m_size < size)
|
||||
{
|
||||
if (mp == curbuf->b_m_search) /* back where we started in free
|
||||
chunk list */
|
||||
if (mbp == curbuf->b_mb_current)
|
||||
{
|
||||
if (mbp->mb_next)
|
||||
mbp = mbp->mb_next;
|
||||
else
|
||||
mbp = &curbuf->b_block_head;
|
||||
mp = curbuf->b_m_search = &(mbp->mb_info);
|
||||
if (mbp == curbuf->b_mb_current) /* back where we started in
|
||||
block list */
|
||||
{
|
||||
int n = (size_align > (MEMBLOCKSIZE / 4)
|
||||
? size_align : MEMBLOCKSIZE);
|
||||
int n = (size_align > (MEMBLOCKSIZE / 4)
|
||||
? size_align : MEMBLOCKSIZE);
|
||||
|
||||
mp = (minfo_T *)u_blockalloc((long_u)n);
|
||||
if (mp == NULL)
|
||||
return (NULL);
|
||||
mp->m_size = n;
|
||||
u_free_line((char_u *)mp + M_OFFSET, TRUE);
|
||||
mp = curbuf->b_m_search;
|
||||
mbp = curbuf->b_mb_current;
|
||||
}
|
||||
/* Back where we started in block list: need to add a new block
|
||||
* with enough space. */
|
||||
mp = (minfo_T *)u_blockalloc((long_u)n);
|
||||
if (mp == NULL)
|
||||
return (NULL);
|
||||
mp->m_size = n;
|
||||
u_free_line((char_u *)mp + M_OFFSET, TRUE);
|
||||
mbp = curbuf->b_mb_current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mbp != curbuf->b_mb_current)
|
||||
curbuf->b_m_search = &(mbp->mb_info);
|
||||
|
||||
/* In this block find a chunk with enough space. */
|
||||
mprev = curbuf->b_m_search;
|
||||
mp = curbuf->b_m_search->m_next;
|
||||
while (1)
|
||||
{
|
||||
if (mp == NULL) /* at end of the list */
|
||||
mp = &(mbp->mb_info); /* wrap around to begin */
|
||||
if (mp->m_size >= size)
|
||||
break;
|
||||
if (mp == curbuf->b_m_search)
|
||||
{
|
||||
/* back where we started in free chunk list: "cannot happen" */
|
||||
EMSG2(_(e_intern2), "u_alloc_line()");
|
||||
return NULL;
|
||||
}
|
||||
mprev = mp;
|
||||
if ((mp = mp->m_next) == NULL) /* at end of the list */
|
||||
mp = &(mbp->mb_info); /* wrap around to begin */
|
||||
mp = mp->m_next;
|
||||
}
|
||||
|
||||
/* when using the largest chunk adjust mb_maxsize */
|
||||
if (mp->m_size >= mbp->mb_maxsize)
|
||||
mbp->mb_maxsize = 0;
|
||||
|
||||
/* if the chunk we found is large enough, split it up in two */
|
||||
if ((long)mp->m_size - size_align >= (long)(sizeof(minfo_T) + 1))
|
||||
{
|
||||
@@ -1340,11 +1399,18 @@ u_alloc_line(size)
|
||||
curbuf->b_m_search = mprev;
|
||||
curbuf->b_mb_current = mbp;
|
||||
|
||||
/* If using the largest chunk need to find the new largest chunk */
|
||||
if (mbp->mb_maxsize == 0)
|
||||
for (mp2 = &(mbp->mb_info); mp2 != NULL; mp2 = mp2->m_next)
|
||||
if (mbp->mb_maxsize < mp2->m_size)
|
||||
mbp->mb_maxsize = mp2->m_size;
|
||||
|
||||
mp = (minfo_T *)((char_u *)mp + M_OFFSET);
|
||||
*(char_u *)mp = NUL; /* set the first byte to NUL */
|
||||
|
||||
return ((char_u *)mp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* u_save_line(): allocate memory with u_alloc_line() and copy line 'lnum'
|
||||
@@ -1360,7 +1426,7 @@ u_save_line(lnum)
|
||||
|
||||
src = ml_get(lnum);
|
||||
len = (unsigned)STRLEN(src);
|
||||
if ((dst = u_alloc_line(len)) != NULL)
|
||||
if ((dst = U_ALLOC_LINE(len)) != NULL)
|
||||
mch_memmove(dst, src, (size_t)(len + 1));
|
||||
return (dst);
|
||||
}
|
||||
|
||||
@@ -36,5 +36,5 @@
|
||||
#define VIM_VERSION_NODOT "vim70aa"
|
||||
#define VIM_VERSION_SHORT "7.0aa"
|
||||
#define VIM_VERSION_MEDIUM "7.0aa ALPHA"
|
||||
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 12)"
|
||||
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 12, compiled "
|
||||
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 21)"
|
||||
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Feb 21, compiled "
|
||||
|
||||
Reference in New Issue
Block a user