1
0
forked from aniani/vim

updated for version 7.0173

This commit is contained in:
Bram Moolenaar
2005-12-18 22:10:00 +00:00
parent d35f9711d4
commit e3226be91a
13 changed files with 245 additions and 150 deletions

View File

@@ -121,7 +121,9 @@ static buf_T *ins_compl_next_buf __ARGS((buf_T *buf, int flag));
static int ins_compl_get_exp __ARGS((pos_T *ini, int dir));
static void ins_compl_delete __ARGS((void));
static void ins_compl_insert __ARGS((void));
static int ins_compl_next __ARGS((int allow_get_expansion));
static int ins_compl_next __ARGS((int allow_get_expansion, int count));
static int ins_compl_key2dir __ARGS((int c));
static int ins_compl_key2count __ARGS((int c));
static int ins_complete __ARGS((int c));
static int quote_meta __ARGS((char_u *dest, char_u *str, int len));
#endif /* FEAT_INS_EXPAND */
@@ -1043,6 +1045,8 @@ doESCkey:
case K_S_UP: /* <S-Up> */
case K_PAGEUP:
case K_KPAGEUP:
if (pum_visible())
goto docomplete;
ins_pageup();
break;
@@ -1056,6 +1060,8 @@ doESCkey:
case K_S_DOWN: /* <S-Down> */
case K_PAGEDOWN:
case K_KPAGEDOWN:
if (pum_visible())
goto docomplete;
ins_pagedown();
break;
@@ -1819,6 +1825,11 @@ vim_is_ctrl_x_key(c)
if (c == Ctrl_R)
return TRUE;
/* Accept <PageUp> and <PageDown> if the popup menu is visible. */
if (pum_visible() && (c == K_PAGEUP || c == K_KPAGEUP || c == K_S_UP
|| c == K_PAGEDOWN || c == K_KPAGEDOWN || c == K_S_DOWN))
return TRUE;
switch (ctrl_x_mode)
{
case 0: /* Not in any CTRL-X mode */
@@ -3272,11 +3283,14 @@ ins_compl_insert()
* calls this function with "allow_get_expansion" FALSE.
*/
static int
ins_compl_next(allow_get_expansion)
ins_compl_next(allow_get_expansion, count)
int allow_get_expansion;
int count; /* repeat completion this many times; should
be at least 1 */
{
int num_matches = -1;
int i;
int todo = count;
if (allow_get_expansion)
{
@@ -3284,24 +3298,41 @@ ins_compl_next(allow_get_expansion)
ins_compl_delete();
}
compl_pending = FALSE;
if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL)
compl_shown_match = compl_shown_match->cp_next;
else if (compl_shows_dir == BACKWARD && compl_shown_match->cp_prev != NULL)
compl_shown_match = compl_shown_match->cp_prev;
else
/* Repeat this for when <PageUp> or <PageDown> is typed. But don't wrap
* around. */
while (--todo >= 0)
{
compl_pending = TRUE;
if (allow_get_expansion)
if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL)
{
num_matches = ins_compl_get_exp(&compl_startpos, compl_direction);
if (compl_pending)
{
if (compl_direction == compl_shows_dir)
compl_shown_match = compl_curr_match;
}
compl_shown_match = compl_shown_match->cp_next;
if (compl_shown_match->cp_next != NULL
&& compl_shown_match->cp_next == compl_first_match)
break;
}
else if (compl_shows_dir == BACKWARD
&& compl_shown_match->cp_prev != NULL)
{
compl_shown_match = compl_shown_match->cp_prev;
if (compl_shown_match == compl_first_match)
break;
}
else
return -1;
{
compl_pending = TRUE;
if (allow_get_expansion)
{
num_matches = ins_compl_get_exp(&compl_startpos,
compl_direction);
if (compl_pending)
{
if (compl_direction == compl_shows_dir)
compl_shown_match = compl_curr_match;
}
}
else
return -1;
}
}
/* Insert the text of the new completion */
@@ -3376,17 +3407,49 @@ ins_compl_check_keys(frequency)
if (vim_is_ctrl_x_key(c) && c != Ctrl_X && c != Ctrl_R)
{
c = safe_vgetc(); /* Eat the character */
if (c == Ctrl_P || c == Ctrl_L)
compl_shows_dir = BACKWARD;
else
compl_shows_dir = FORWARD;
(void)ins_compl_next(FALSE);
compl_shows_dir = ins_compl_key2dir(c);
(void)ins_compl_next(FALSE, ins_compl_key2count(c));
}
else if (c != Ctrl_R)
compl_interrupted = TRUE;
}
if (compl_pending && !got_int)
(void)ins_compl_next(FALSE);
(void)ins_compl_next(FALSE, 1);
}
/*
* Decide the direction of Insert mode complete from the key typed.
* Returns BACKWARD or FORWARD.
*/
static int
ins_compl_key2dir(c)
int c;
{
if (c == Ctrl_P || c == Ctrl_L || (pum_visible()
&& (c == K_PAGEUP || c == K_KPAGEUP || c == K_S_UP)))
return BACKWARD;
return FORWARD;
}
/*
* Decide the number of completions to move forward.
* Returns 1 for most keys, height of the popup menu for page-up/down keys.
*/
static int
ins_compl_key2count(c)
int c;
{
int h;
if (pum_visible() && (c == K_PAGEUP || c == K_KPAGEUP || c == K_S_UP
|| c == K_PAGEDOWN || c == K_KPAGEDOWN || c == K_S_DOWN))
{
h = pum_get_height();
if (h > 3)
h -= 2; /* keep some context */
return h;
}
return 1;
}
/*
@@ -3403,10 +3466,7 @@ ins_complete(c)
colnr_T curs_col; /* cursor column */
int n;
if (c == Ctrl_P || c == Ctrl_L)
compl_direction = BACKWARD;
else
compl_direction = FORWARD;
compl_direction = ins_compl_key2dir(c);
if (!compl_started)
{
/* First time we hit ^N or ^P (in a row, I mean) */
@@ -3783,7 +3843,7 @@ ins_complete(c)
/*
* Find next match.
*/
n = ins_compl_next(TRUE);
n = ins_compl_next(TRUE, ins_compl_key2count(c));
/* may undisplay the popup menu */
ins_compl_upd_pum();

View File

@@ -2110,7 +2110,7 @@ del_char(fixpos)
return del_chars(1L, fixpos);
}
#endif
return del_bytes(1L, fixpos);
return del_bytes(1L, fixpos, TRUE);
}
#if defined(FEAT_MBYTE) || defined(PROTO)
@@ -2134,7 +2134,7 @@ del_chars(count, fixpos)
bytes += l;
p += l;
}
return del_bytes(bytes, fixpos);
return del_bytes(bytes, fixpos, TRUE);
}
#endif
@@ -2146,9 +2146,10 @@ del_chars(count, fixpos)
* return FAIL for failure, OK otherwise
*/
int
del_bytes(count, fixpos)
del_bytes(count, fixpos, use_delcombine)
long count;
int fixpos;
int use_delcombine; /* 'delcombine' option applies */
{
char_u *oldp, *newp;
colnr_T oldlen;
@@ -2169,7 +2170,8 @@ del_bytes(count, fixpos)
#ifdef FEAT_MBYTE
/* If 'delcombine' is set and deleting (less than) one character, only
* delete the last combining character. */
if (p_deco && enc_utf8 && utfc_ptr2len(oldp + col) >= count)
if (p_deco && use_delcombine && enc_utf8
&& utfc_ptr2len(oldp + col) >= count)
{
int c1, c2;
int n;

View File

@@ -1843,7 +1843,8 @@ op_delete(oap)
curwin->w_cursor.coladd = 0;
}
#endif
(void)del_bytes((long)n, restart_edit == NUL && !virtual_op);
(void)del_bytes((long)n, restart_edit == NUL && !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
}
else /* delete characters between lines */
{
@@ -1863,7 +1864,8 @@ op_delete(oap)
/* delete from start of line until op_end */
curwin->w_cursor.col = 0;
(void)del_bytes((long)(oap->end.col + 1 - !oap->inclusive),
restart_edit == NUL && !virtual_op);
restart_edit == NUL && !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
curwin->w_cursor = curpos; /* restore curwin->w_cursor */
(void)do_join(FALSE);
@@ -4509,7 +4511,7 @@ format_lines(line_count)
if (line_count < 0 && u_save_cursor() == FAIL)
break;
#ifdef FEAT_COMMENTS
(void)del_bytes((long)next_leader_len, FALSE);
(void)del_bytes((long)next_leader_len, FALSE, FALSE);
if (next_leader_len > 0)
mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
(long)-next_leader_len);

View File

@@ -139,8 +139,7 @@ mch_inchar(buf, maxlen, time, tb_change_cnt)
if (WaitForChar(raw_in, p_ut * 1000L) == 0)
{
#ifdef FEAT_AUTOCMD
if (!did_cursorhold && has_cursorhold()
&& get_real_state() == NORMAL_BUSY && maxlen >= 3)
if (trigger_cursorhold() && maxlen >= 3)
{
buf[0] = K_SPECIAL;
buf[1] = KS_EXTRA;

View File

@@ -1037,8 +1037,7 @@ mch_inchar(
if (WaitForChar(p_ut) == 0)
{
#ifdef FEAT_AUTOCMD
if (!did_cursorhold && has_cursorhold()
&& get_real_state() == NORMAL_BUSY && maxlen >= 3)
if (trigger_cursorhold() && maxlen >= 3)
{
buf[0] = K_SPECIAL;
buf[1] = KS_EXTRA;

View File

@@ -237,12 +237,28 @@ pum_set_selected(n)
if (pum_selected >= 0)
{
if (pum_first > pum_selected)
/* scroll down */
pum_first = pum_selected;
else if (pum_first < pum_selected - pum_height + 1)
/* scroll up */
pum_first = pum_selected - pum_height + 1;
if (pum_first > pum_selected - 4)
{
/* scroll down; when we did a jump it's probably a PageUp then
* scroll to put the selected entry at the bottom */
if (pum_first > pum_selected - 2)
{
pum_first = pum_selected - pum_height + 1;
if (pum_first < 0)
pum_first = 0;
}
else
pum_first = pum_selected;
}
else if (pum_first < pum_selected - pum_height + 5)
{
/* scroll up; when we did a jump it's probably a PageDown then
* scroll to put the selected entry at the top */
if (pum_first < pum_selected - pum_height + 1 + 2)
pum_first = pum_selected;
else
pum_first = pum_selected - pum_height + 1;
}
if (pum_height > 6)
{
@@ -298,4 +314,14 @@ pum_visible()
return pum_array != NULL;
}
/*
* Return the height of the popup menu, the number of entries visible.
* Only valid when pum_visible() returns TRUE!
*/
int
pum_get_height()
{
return pum_height;
}
#endif

View File

@@ -36,6 +36,7 @@ void aucmd_restbuf __ARGS((aco_save_T *aco));
int apply_autocmds __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf));
int apply_autocmds_retval __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, int *retval));
int has_cursorhold __ARGS((void));
int trigger_cursorhold __ARGS((void));
int has_autocmd __ARGS((EVENT_T event, char_u *sfname, buf_T *buf));
char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));

View File

@@ -1,94 +1,94 @@
/* misc1.c */
extern int get_indent __ARGS((void));
extern int get_indent_lnum __ARGS((linenr_T lnum));
extern int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
extern int get_indent_str __ARGS((char_u *ptr, int ts));
extern int set_indent __ARGS((int size, int flags));
extern int get_number_indent __ARGS((linenr_T lnum));
extern int open_line __ARGS((int dir, int flags, int old_indent));
extern int get_leader_len __ARGS((char_u *line, char_u **flags, int backward));
extern int plines __ARGS((linenr_T lnum));
extern int plines_win __ARGS((win_T *wp, linenr_T lnum, int winheight));
extern int plines_nofill __ARGS((linenr_T lnum));
extern int plines_win_nofill __ARGS((win_T *wp, linenr_T lnum, int winheight));
extern int plines_win_nofold __ARGS((win_T *wp, linenr_T lnum));
extern int plines_win_col __ARGS((win_T *wp, linenr_T lnum, long column));
extern int plines_m_win __ARGS((win_T *wp, linenr_T first, linenr_T last));
extern void ins_bytes __ARGS((char_u *p));
extern void ins_bytes_len __ARGS((char_u *p, int len));
extern void ins_char __ARGS((int c));
extern void ins_char_bytes __ARGS((char_u *buf, int charlen));
extern void ins_str __ARGS((char_u *s));
extern int del_char __ARGS((int fixpos));
extern int del_chars __ARGS((long count, int fixpos));
extern int del_bytes __ARGS((long count, int fixpos));
extern int truncate_line __ARGS((int fixpos));
extern void del_lines __ARGS((long nlines, int undo));
extern int gchar_pos __ARGS((pos_T *pos));
extern int gchar_cursor __ARGS((void));
extern void pchar_cursor __ARGS((int c));
extern int inindent __ARGS((int extra));
extern char_u *skip_to_option_part __ARGS((char_u *p));
extern void changed __ARGS((void));
extern void changed_bytes __ARGS((linenr_T lnum, colnr_T col));
extern void appended_lines __ARGS((linenr_T lnum, long count));
extern void appended_lines_mark __ARGS((linenr_T lnum, long count));
extern void deleted_lines __ARGS((linenr_T lnum, long count));
extern void deleted_lines_mark __ARGS((linenr_T lnum, long count));
extern void changed_lines __ARGS((linenr_T lnum, colnr_T col, linenr_T lnume, long xtra));
extern void unchanged __ARGS((buf_T *buf, int ff));
extern void check_status __ARGS((buf_T *buf));
extern void change_warning __ARGS((int col));
extern int ask_yesno __ARGS((char_u *str, int direct));
extern int get_keystroke __ARGS((void));
extern int get_number __ARGS((int colon, int *mouse_used));
extern int prompt_for_number __ARGS((int *mouse_used));
extern void msgmore __ARGS((long n));
extern void beep_flush __ARGS((void));
extern void vim_beep __ARGS((void));
extern void init_homedir __ARGS((void));
extern void free_homedir __ARGS((void));
extern void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
extern void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
extern char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
extern char_u *expand_env_save __ARGS((char_u *src));
extern void vim_setenv __ARGS((char_u *name, char_u *val));
extern char_u *get_env_name __ARGS((expand_T *xp, int idx));
extern void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
extern char_u *home_replace_save __ARGS((buf_T *buf, char_u *src));
extern int fullpathcmp __ARGS((char_u *s1, char_u *s2, int checkname));
extern char_u *gettail __ARGS((char_u *fname));
extern char_u *gettail_sep __ARGS((char_u *fname));
extern char_u *getnextcomp __ARGS((char_u *fname));
extern char_u *get_past_head __ARGS((char_u *path));
extern int vim_ispathsep __ARGS((int c));
extern int vim_ispathlistsep __ARGS((int c));
extern int dir_of_file_exists __ARGS((char_u *fname));
extern int vim_fnamecmp __ARGS((char_u *x, char_u *y));
extern int vim_fnamencmp __ARGS((char_u *x, char_u *y, size_t len));
extern char_u *concat_fnames __ARGS((char_u *fname1, char_u *fname2, int sep));
extern char_u *concat_str __ARGS((char_u *str1, char_u *str2));
extern void add_pathsep __ARGS((char_u *p));
extern char_u *FullName_save __ARGS((char_u *fname, int force));
extern pos_T *find_start_comment __ARGS((int ind_maxcomment));
extern void do_c_expr_indent __ARGS((void));
extern int cin_islabel __ARGS((int ind_maxcomment));
extern int cin_iscase __ARGS((char_u *s));
extern int cin_isscopedecl __ARGS((char_u *s));
extern int get_c_indent __ARGS((void));
extern int get_expr_indent __ARGS((void));
extern int get_lisp_indent __ARGS((void));
extern void prepare_to_exit __ARGS((void));
extern void preserve_exit __ARGS((void));
extern int vim_fexists __ARGS((char_u *fname));
extern void line_breakcheck __ARGS((void));
extern void fast_breakcheck __ARGS((void));
extern int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
extern int match_suffix __ARGS((char_u *fname));
extern int unix_expandpath __ARGS((garray_T *gap, char_u *path, int wildoff, int flags, int didstar));
extern int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
extern void addfile __ARGS((garray_T *gap, char_u *f, int flags));
extern char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags));
extern void FreeWild __ARGS((int count, char_u **files));
extern int goto_im __ARGS((void));
int get_indent __ARGS((void));
int get_indent_lnum __ARGS((linenr_T lnum));
int get_indent_buf __ARGS((buf_T *buf, linenr_T lnum));
int get_indent_str __ARGS((char_u *ptr, int ts));
int set_indent __ARGS((int size, int flags));
int get_number_indent __ARGS((linenr_T lnum));
int open_line __ARGS((int dir, int flags, int old_indent));
int get_leader_len __ARGS((char_u *line, char_u **flags, int backward));
int plines __ARGS((linenr_T lnum));
int plines_win __ARGS((win_T *wp, linenr_T lnum, int winheight));
int plines_nofill __ARGS((linenr_T lnum));
int plines_win_nofill __ARGS((win_T *wp, linenr_T lnum, int winheight));
int plines_win_nofold __ARGS((win_T *wp, linenr_T lnum));
int plines_win_col __ARGS((win_T *wp, linenr_T lnum, long column));
int plines_m_win __ARGS((win_T *wp, linenr_T first, linenr_T last));
void ins_bytes __ARGS((char_u *p));
void ins_bytes_len __ARGS((char_u *p, int len));
void ins_char __ARGS((int c));
void ins_char_bytes __ARGS((char_u *buf, int charlen));
void ins_str __ARGS((char_u *s));
int del_char __ARGS((int fixpos));
int del_chars __ARGS((long count, int fixpos));
int del_bytes __ARGS((long count, int fixpos, int use_delcombine));
int truncate_line __ARGS((int fixpos));
void del_lines __ARGS((long nlines, int undo));
int gchar_pos __ARGS((pos_T *pos));
int gchar_cursor __ARGS((void));
void pchar_cursor __ARGS((int c));
int inindent __ARGS((int extra));
char_u *skip_to_option_part __ARGS((char_u *p));
void changed __ARGS((void));
void changed_bytes __ARGS((linenr_T lnum, colnr_T col));
void appended_lines __ARGS((linenr_T lnum, long count));
void appended_lines_mark __ARGS((linenr_T lnum, long count));
void deleted_lines __ARGS((linenr_T lnum, long count));
void deleted_lines_mark __ARGS((linenr_T lnum, long count));
void changed_lines __ARGS((linenr_T lnum, colnr_T col, linenr_T lnume, long xtra));
void unchanged __ARGS((buf_T *buf, int ff));
void check_status __ARGS((buf_T *buf));
void change_warning __ARGS((int col));
int ask_yesno __ARGS((char_u *str, int direct));
int get_keystroke __ARGS((void));
int get_number __ARGS((int colon, int *mouse_used));
int prompt_for_number __ARGS((int *mouse_used));
void msgmore __ARGS((long n));
void beep_flush __ARGS((void));
void vim_beep __ARGS((void));
void init_homedir __ARGS((void));
void free_homedir __ARGS((void));
void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
char_u *expand_env_save __ARGS((char_u *src));
void vim_setenv __ARGS((char_u *name, char_u *val));
char_u *get_env_name __ARGS((expand_T *xp, int idx));
void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
char_u *home_replace_save __ARGS((buf_T *buf, char_u *src));
int fullpathcmp __ARGS((char_u *s1, char_u *s2, int checkname));
char_u *gettail __ARGS((char_u *fname));
char_u *gettail_sep __ARGS((char_u *fname));
char_u *getnextcomp __ARGS((char_u *fname));
char_u *get_past_head __ARGS((char_u *path));
int vim_ispathsep __ARGS((int c));
int vim_ispathlistsep __ARGS((int c));
int dir_of_file_exists __ARGS((char_u *fname));
int vim_fnamecmp __ARGS((char_u *x, char_u *y));
int vim_fnamencmp __ARGS((char_u *x, char_u *y, size_t len));
char_u *concat_fnames __ARGS((char_u *fname1, char_u *fname2, int sep));
char_u *concat_str __ARGS((char_u *str1, char_u *str2));
void add_pathsep __ARGS((char_u *p));
char_u *FullName_save __ARGS((char_u *fname, int force));
pos_T *find_start_comment __ARGS((int ind_maxcomment));
void do_c_expr_indent __ARGS((void));
int cin_islabel __ARGS((int ind_maxcomment));
int cin_iscase __ARGS((char_u *s));
int cin_isscopedecl __ARGS((char_u *s));
int get_c_indent __ARGS((void));
int get_expr_indent __ARGS((void));
int get_lisp_indent __ARGS((void));
void prepare_to_exit __ARGS((void));
void preserve_exit __ARGS((void));
int vim_fexists __ARGS((char_u *fname));
void line_breakcheck __ARGS((void));
void fast_breakcheck __ARGS((void));
int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
int match_suffix __ARGS((char_u *fname));
int unix_expandpath __ARGS((garray_T *gap, char_u *path, int wildoff, int flags, int didstar));
int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
void addfile __ARGS((garray_T *gap, char_u *f, int flags));
char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags));
void FreeWild __ARGS((int count, char_u **files));
int goto_im __ARGS((void));
/* vim: set ft=c : */

View File

@@ -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 Dec 17)"
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 17, compiled "
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 18)"
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Dec 18, compiled "