Compare commits

...

14 Commits

16 changed files with 204 additions and 77 deletions

View File

@ -2,7 +2,7 @@
" You can also use this as a start for your own set of menus.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2007 Jan 09
" Last Change: 2007 Nov 19
" Note that ":an" (short for ":anoremenu") is often used to make a menu work
" in all modes and avoid side effects from mappings defined by the user.
@ -658,7 +658,6 @@ func! s:BMShow(...)
let buf = 1
while buf <= bufnr('$')
if bufexists(buf) && !isdirectory(bufname(buf)) && buflisted(buf)
\ && !getbufvar(buf, "&bufsecret")
let s:bmenu_count = s:bmenu_count + 1
endif
let buf = buf + 1
@ -671,7 +670,6 @@ func! s:BMShow(...)
let buf = 1
while buf <= bufnr('$')
if bufexists(buf) && !isdirectory(bufname(buf)) && buflisted(buf)
\ && !getbufvar(buf, "&bufsecret")
call <SID>BMFilename(bufname(buf), buf)
endif
let buf = buf + 1

View File

@ -2236,7 +2236,7 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
while (i < actual_len && (p - IObuff + 6) < IOSIZE)
#ifdef FEAT_MBYTE
if (has_mbyte)
p += mb_char2bytes(wca[i++], p);
p += (*mb_char2bytes)(wca[i++], p);
else
#endif
*(p++) = wca[i++];
@ -6444,8 +6444,10 @@ free_last_insert()
{
vim_free(last_insert);
last_insert = NULL;
# ifdef FEAT_INS_EXPAND
vim_free(compl_orig_text);
compl_orig_text = NULL;
# endif
}
#endif

View File

@ -15826,7 +15826,7 @@ f_system(argvars, rettv)
FILE *fd;
if (check_restricted() || check_secure())
return;
goto done;
if (argvars[1].v_type != VAR_UNKNOWN)
{
@ -15837,7 +15837,7 @@ f_system(argvars, rettv)
if ((infile = vim_tempname('i')) == NULL)
{
EMSG(_(e_notmp));
return;
goto done;
}
fd = mch_fopen((char *)infile, WRITEBIN);

View File

@ -4885,7 +4885,8 @@ do_sub(eap)
++line2;
/* move the cursor to the new line, like Vi */
++curwin->w_cursor.lnum;
STRCPY(new_start, p1 + 1); /* copy the rest */
/* copy the rest */
mch_memmove(new_start, p1 + 1, STRLEN(p1 + 1) + 1);
p1 = new_start - 1;
}
}

View File

@ -666,7 +666,7 @@ do_exmode(improved)
if (ex_pressedreturn)
{
/* go up one line, to overwrite the ":<CR>" line, so the
* output doensn't contain empty lines. */
* output doesn't contain empty lines. */
msg_row = prev_msg_row;
if (prev_msg_row == Rows - 1)
msg_row--;
@ -1741,7 +1741,9 @@ do_one_cmd(cmdlinep, sourcing,
}
/* ignore comment and empty lines */
if (*ea.cmd == '"' || *ea.cmd == NUL)
if (*ea.cmd == '"')
goto doend;
if (*ea.cmd == NUL)
{
ex_pressedreturn = TRUE;
goto doend;
@ -2760,7 +2762,7 @@ find_command(eap, full)
/*
* Isolate the command and search for it in the command table.
* Exeptions:
* Exceptions:
* - the 'k' command can directly be followed by any character.
* - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
* but :sre[wind] is another command, as are :scrip[tnames],
@ -2961,6 +2963,57 @@ find_ucmd(eap, p, full, xp, compl)
#endif
#if defined(FEAT_EVAL) || defined(PROTO)
static struct cmdmod
{
char *name;
int minlen;
int has_count; /* :123verbose :3tab */
} cmdmods[] = {
{"aboveleft", 3, FALSE},
{"belowright", 3, FALSE},
{"botright", 2, FALSE},
{"browse", 3, FALSE},
{"confirm", 4, FALSE},
{"hide", 3, FALSE},
{"keepalt", 5, FALSE},
{"keepjumps", 5, FALSE},
{"keepmarks", 3, FALSE},
{"leftabove", 5, FALSE},
{"lockmarks", 3, FALSE},
{"rightbelow", 6, FALSE},
{"sandbox", 3, FALSE},
{"silent", 3, FALSE},
{"tab", 3, TRUE},
{"topleft", 2, FALSE},
{"verbose", 4, TRUE},
{"vertical", 4, FALSE},
};
/*
* Return length of a command modifier (including optional count).
* Return zero when it's not a modifier.
*/
int
modifier_len(cmd)
char_u *cmd;
{
int i, j;
char_u *p = cmd;
if (VIM_ISDIGIT(*cmd))
p = skipwhite(skipdigits(cmd));
for (i = 0; i < sizeof(cmdmods) / sizeof(struct cmdmod); ++i)
{
for (j = 0; p[j] != NUL; ++j)
if (p[j] != cmdmods[i].name[j])
break;
if (!isalpha(p[j]) && j >= cmdmods[i].minlen
&& (p == cmd || cmdmods[i].has_count))
return j + (p - cmd);
}
return 0;
}
/*
* Return > 0 if an Ex command "name" exists.
* Return 2 if there is an exact match.
@ -2975,30 +3028,6 @@ cmd_exists(name)
int i;
int j;
char_u *p;
static struct cmdmod
{
char *name;
int minlen;
} cmdmods[] = {
{"aboveleft", 3},
{"belowright", 3},
{"botright", 2},
{"browse", 3},
{"confirm", 4},
{"hide", 3},
{"keepalt", 5},
{"keepjumps", 5},
{"keepmarks", 3},
{"leftabove", 5},
{"lockmarks", 3},
{"rightbelow", 6},
{"sandbox", 3},
{"silent", 3},
{"tab", 3},
{"topleft", 2},
{"verbose", 4},
{"vertical", 4},
};
/* Check command modifiers. */
for (i = 0; i < sizeof(cmdmods) / sizeof(struct cmdmod); ++i)
@ -6677,7 +6706,7 @@ ex_shell(eap)
* The list should be allocated using alloc(), as should each item in the
* list. This function takes over responsibility for freeing the list.
*
* XXX The list is made into the arggument list. This is freed using
* XXX The list is made into the argument list. This is freed using
* FreeWild(), which does a series of vim_free() calls, unless the two defines
* __EMX__ and __ALWAYS_HAS_TRAILING_NUL_POINTER are set. In this case, a
* routine _fnexplodefree() is used. This may cause problems, but as the drop
@ -7795,7 +7824,7 @@ ex_cd(eap)
if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged()
&& !eap->forceit)
{
EMSG(_("E747: Cannot change directory, buffer is modifed (add ! to override)"));
EMSG(_("E747: Cannot change directory, buffer is modified (add ! to override)"));
return;
}
@ -9391,7 +9420,7 @@ eval_vars(src, srcstart, usedlen, lnump, errormsg, escaped)
if (src > srcstart && src[-1] == '\\')
{
*usedlen = 0;
STRCPY(src - 1, src); /* remove backslash */
mch_memmove(src - 1, src, STRLEN(src) + 1); /* remove backslash */
return NULL;
}

View File

@ -2269,9 +2269,18 @@ ex_endfunction(eap)
has_loop_cmd(p)
char_u *p;
{
p = skipwhite(p);
while (*p == ':')
p = skipwhite(p + 1);
int len;
/* skip modifiers, white space and ':' */
for (;;)
{
while (*p == ' ' || *p == '\t' || *p == ':')
++p;
len = modifier_len(p);
if (len == 0)
break;
p += len;
}
if ((p[0] == 'w' && p[1] == 'h')
|| (p[0] == 'f' && p[1] == 'o' && p[2] == 'r'))
return TRUE;

View File

@ -290,6 +290,11 @@ static struct
/* Local variables */
static int s_button_pending = -1;
/* s_getting_focus is set when we got focus but didn't see mouse-up event yet,
* so don't reset s_button_pending. */
static int s_getting_focus = FALSE;
static int s_x_pending;
static int s_y_pending;
static UINT s_kFlags_pending;
@ -486,10 +491,11 @@ _OnDeadChar(
/*
* Convert Unicode character "ch" to bytes in "string[slen]".
* When "had_alt" is TRUE the ALT key was included in "ch".
* Return the length.
*/
static int
char_to_string(int ch, char_u *string, int slen)
char_to_string(int ch, char_u *string, int slen, int had_alt)
{
int len;
int i;
@ -522,8 +528,22 @@ char_to_string(int ch, char_u *string, int slen)
* "enc_codepage" is non-zero use the standard Win32 function,
* otherwise use our own conversion function (e.g., for UTF-8). */
if (enc_codepage > 0)
{
len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
string, slen, 0, NULL);
/* If we had included the ALT key into the character but now the
* upper bit is no longer set, that probably means the conversion
* failed. Convert the original character and set the upper bit
* afterwards. */
if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80)
{
wstring[0] = ch & 0x7f;
len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
string, slen, 0, NULL);
if (len == 1) /* safety check */
string[0] |= 0x80;
}
}
else
{
len = 1;
@ -573,7 +593,7 @@ _OnChar(
char_u string[40];
int len = 0;
len = char_to_string(ch, string, 40);
len = char_to_string(ch, string, 40, FALSE);
if (len == 1 && string[0] == Ctrl_C && ctrl_c_interrupts)
{
trash_input_buf();
@ -640,7 +660,7 @@ _OnSysChar(
{
/* Although the documentation isn't clear about it, we assume "ch" is
* a Unicode character. */
len += char_to_string(ch, string + len, 40 - len);
len += char_to_string(ch, string + len, 40 - len, TRUE);
}
add_to_input_buf(string, len);
@ -656,6 +676,8 @@ _OnMouseEvent(
{
int vim_modifiers = 0x0;
s_getting_focus = FALSE;
if (keyFlags & MK_SHIFT)
vim_modifiers |= MOUSE_SHIFT;
if (keyFlags & MK_CONTROL)
@ -777,6 +799,7 @@ _OnMouseMoveOrRelease(
{
int button;
s_getting_focus = FALSE;
if (s_button_pending > -1)
{
/* Delayed action for mouse down event */
@ -1775,7 +1798,7 @@ process_message(void)
int len;
/* Handle "key" as a Unicode character. */
len = char_to_string(key, string, 40);
len = char_to_string(key, string, 40, FALSE);
add_to_input_buf(string, len);
}
break;
@ -1936,8 +1959,10 @@ gui_mch_wait_for_chars(int wtime)
allow_scrollbar = FALSE;
/* Clear pending mouse button, the release event may have been
* taken by the dialog window. */
s_button_pending = -1;
* taken by the dialog window. But don't do this when getting
* focus, we need the mouse-up event then. */
if (!s_getting_focus)
s_button_pending = -1;
return OK;
}
@ -2687,6 +2712,7 @@ _OnSetFocus(
HWND hwndOldFocus)
{
gui_focus_change(TRUE);
s_getting_focus = TRUE;
(void)MyWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hwndOldFocus, 0);
}
@ -2696,6 +2722,7 @@ _OnKillFocus(
HWND hwndNewFocus)
{
gui_focus_change(FALSE);
s_getting_focus = FALSE;
(void)MyWindowProc(hwnd, WM_KILLFOCUS, (WPARAM)hwndNewFocus, 0);
}

View File

@ -2850,6 +2850,15 @@ repeat_message()
}
else if (State == HITRETURN || State == SETWSIZE)
{
if (msg_row == Rows - 1)
{
/* Avoid drawing the "hit-enter" prompt below the previous one,
* overwrite it. Esp. useful when regaining focus and a
* FocusGained autocmd exists but didn't draw anything. */
msg_didout = FALSE;
msg_col = 0;
msg_clr_eos();
}
hit_return_msg();
msg_row = Rows - 1;
}

View File

@ -964,7 +964,6 @@ free_all_mem()
{
buf_T *buf, *nextbuf;
static int entered = FALSE;
win_T *win;
/* When we cause a crash here it is caught and Vim tries to exit cleanly.
* Don't try freeing everything again. */
@ -972,15 +971,17 @@ free_all_mem()
return;
entered = TRUE;
# ifdef FEAT_AUTOCMD
block_autocmds(); /* don't want to trigger autocommands here */
# endif
#ifdef FEAT_WINDOWS
# ifdef FEAT_WINDOWS
/* close all tabs and windows */
if (first_tabpage->tp_next != NULL)
do_cmdline_cmd((char_u *)"tabonly!");
if (firstwin != lastwin)
do_cmdline_cmd((char_u *)"only!");
#endif
# endif
# if defined(FEAT_SPELL)
/* Free all spell info. */
@ -1031,8 +1032,12 @@ free_all_mem()
free_regexp_stuff();
free_tag_stuff();
free_cd_dir();
# ifdef FEAT_EVAL
set_expr_line(NULL);
# endif
# ifdef FEAT_DIFF
diff_clear(curtab);
# endif
clear_sb_text(); /* free any scrollback text */
/* Free some global vars. */
@ -1041,19 +1046,27 @@ free_all_mem()
vim_free(clip_exclude_prog);
# endif
vim_free(last_cmdline);
# ifdef FEAT_CMDHIST
vim_free(new_last_cmdline);
# endif
set_keep_msg(NULL, 0);
vim_free(ff_expand_buffer);
/* Clear cmdline history. */
p_hi = 0;
# ifdef FEAT_CMDHIST
init_history();
# endif
#ifdef FEAT_QUICKFIX
qf_free_all(NULL);
/* Free all location lists */
FOR_ALL_WINDOWS(win)
qf_free_all(win);
{
win_T *win;
qf_free_all(NULL);
/* Free all location lists */
FOR_ALL_WINDOWS(win)
qf_free_all(win);
}
#endif
/* Close all script inputs. */

View File

@ -927,8 +927,8 @@ get_register(name, copy)
int name;
int copy; /* make a copy, if FALSE make register empty. */
{
static struct yankreg *reg;
int i;
struct yankreg *reg;
int i;
#ifdef FEAT_CLIPBOARD
/* When Visual area changed, may have to update selection. Obtain the
@ -967,7 +967,7 @@ get_register(name, copy)
}
/*
* Put "reg" into register "name". Free any previous contents.
* Put "reg" into register "name". Free any previous contents and "reg".
*/
void
put_register(name, reg)
@ -977,6 +977,7 @@ put_register(name, reg)
get_yank_register(name, 0);
free_yank_all();
*y_current = *(struct yankreg *)reg;
vim_free(reg);
# ifdef FEAT_CLIPBOARD
/* Send text written to clipboard register to the clipboard. */

View File

@ -310,7 +310,7 @@ mch_write(s, len)
}
/*
* mch_inchar(): low level input funcion.
* mch_inchar(): low level input function.
* Get a characters from the keyboard.
* Return the number of characters that are available.
* If wtime == 0 do not wait for characters.
@ -1567,18 +1567,19 @@ get_x11_windis()
#ifdef FEAT_XCLIPBOARD
if (xterm_dpy != NULL && x11_window != 0)
{
/* Checked it already. */
if (x11_display_from == XD_XTERM)
return OK;
/*
* If the X11 display was opened here before, for the window where Vim
* was started, close that one now to avoid a memory leak.
*/
if (x11_display_from == XD_HERE && x11_display != NULL)
XCloseDisplay(x11_display);
x11_display = xterm_dpy;
x11_display_from = XD_XTERM;
/* We may have checked it already, but Gnome terminal can move us to
* another window, so we need to check every time. */
if (x11_display_from != XD_XTERM)
{
/*
* If the X11 display was opened here before, for the window where
* Vim was started, close that one now to avoid a memory leak.
*/
if (x11_display_from == XD_HERE && x11_display != NULL)
XCloseDisplay(x11_display);
x11_display = xterm_dpy;
x11_display_from = XD_XTERM;
}
if (test_x11_window(x11_display) == FAIL)
{
/* probably bad $WINDOWID */
@ -2421,7 +2422,7 @@ mch_isFullName(fname)
/*
* Set the case of the file name, if it already exists. This will cause the
* file name to remain exactly the same.
* Only required for file systems where case is ingored and preserved.
* Only required for file systems where case is ignored and preserved.
*/
/*ARGSUSED*/
void
@ -4653,7 +4654,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
ret = poll(fds, nfd, towait);
# ifdef FEAT_MZSCHEME
if (ret == 0 && mzquantum_used)
/* MzThreads scheduling is required and timeout occured */
/* MzThreads scheduling is required and timeout occurred */
finished = FALSE;
# endif
@ -4801,7 +4802,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
#endif
# ifdef FEAT_MZSCHEME
if (ret == 0 && mzquantum_used)
/* loop if MzThreads must be scheduled and timeout occured */
/* loop if MzThreads must be scheduled and timeout occurred */
finished = FALSE;
# endif
@ -5191,7 +5192,7 @@ mch_expand_wildcards(num_pat, pat, num_file, file, flags)
{
/* When using system() always add extra quotes, because the shell
* is started twice. Otherwise put a backslash before special
* characters, except insice ``. */
* characters, except inside ``. */
#ifdef USE_SYSTEM
STRCAT(command, " \"");
STRCAT(command, pat[i]);
@ -5675,7 +5676,7 @@ gpm_open()
/* gpm library tries to handling TSTP causes
* problems. Anyways, we close connection to Gpm whenever
* we are going to suspend or starting an external process
* so we should'nt have problem with this
* so we shouldn't have problem with this
*/
signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
return 1; /* succeed */

View File

@ -1521,7 +1521,12 @@ mch_inchar(
#endif
)
{
#ifdef FEAT_MBYTE
n = (*mb_char2bytes)(typeahead[typeaheadlen] | 0x80,
typeahead + typeaheadlen);
#else
typeahead[typeaheadlen] |= 0x80;
#endif
modifiers &= ~MOD_MASK_ALT;
}

View File

@ -5,6 +5,7 @@ int do_cmdline __ARGS((char_u *cmdline, char_u *(*getline)(int, void *, int), vo
int getline_equal __ARGS((char_u *(*fgetline)(int, void *, int), void *cookie, char_u *(*func)(int, void *, int)));
void *getline_cookie __ARGS((char_u *(*fgetline)(int, void *, int), void *cookie));
int checkforcmd __ARGS((char_u **pp, char *cmd, int len));
int modifier_len __ARGS((char_u *cmd));
int cmd_exists __ARGS((char_u *name));
char_u *set_one_cmd_context __ARGS((expand_T *xp, char_u *buff));
char_u *skip_range __ARGS((char_u *cmd, int *ctx));

View File

@ -2770,7 +2770,8 @@ skipchr()
{
#ifdef FEAT_MBYTE
if (enc_utf8)
prevchr_len += utf_char2len(mb_ptr2char(regparse + prevchr_len));
/* exclude composing chars that mb_ptr2len does include */
prevchr_len += utf_ptr2len(regparse + prevchr_len);
else if (has_mbyte)
prevchr_len += (*mb_ptr2len)(regparse + prevchr_len);
else

View File

@ -666,6 +666,34 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
169,
/**/
168,
/**/
167,
/**/
166,
/**/
165,
/**/
164,
/**/
163,
/**/
162,
/**/
161,
/**/
160,
/**/
159,
/**/
158,
/**/
157,
/**/
156,
/**/
155,
/**/

View File

@ -212,7 +212,7 @@ static void xxdline __P((FILE *, char *, int));
#define TRY_SEEK /* attempt to use lseek, or skip forward by reading */
#define COLS 256 /* change here, if you ever need more columns */
#define LLEN (9 + (5*COLS-1)/2 + 2 + COLS)
#define LLEN (11 + (9*COLS-1)/1 + COLS + 2)
char hexxa[] = "0123456789abcdef0123456789ABCDEF", *hexx = hexxa;
@ -590,7 +590,8 @@ char *argv[];
default: octspergrp = 0; break;
}
if (cols < 1 || (!hextype && (cols > COLS)))
if (cols < 1 || ((hextype == HEX_NORMAL || hextype == HEX_BITS)
&& (cols > COLS)))
{
fprintf(stderr, "%s: invalid number of columns (max. %d).\n", pname, COLS);
exit(1);
@ -750,6 +751,7 @@ char *argv[];
}
if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64];
/* When changing this update definition of LLEN above. */
l[11 + (grplen * cols - 1)/octspergrp + p] =
#ifdef __MVS__
(e >= 64)