From e66c1a9de8ace65a50a39adf06a2535476f6d913 Mon Sep 17 00:00:00 2001 From: h-east Date: Sat, 13 Feb 2016 18:12:50 +0900 Subject: [PATCH] Closed #11 --- src/clpum.c | 22 +++++++++++----------- src/eval.c | 7 ++++--- src/ex_getln.c | 25 +++++++++++++++++-------- src/proto/clpum.pro | 12 ++++++------ src/proto/ex_getln.pro | 2 +- src/screen.c | 5 +++-- src/vim.h | 4 ++-- 7 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/clpum.c b/src/clpum.c index b7b84f9456734..dec146de75a2d 100644 --- a/src/clpum.c +++ b/src/clpum.c @@ -30,7 +30,7 @@ static int clpum_col; /* left column of pum */ static int clpum_do_redraw = FALSE; /* do redraw anyway */ -static int clpum_set_selected __ARGS((int n, int repeat)); +static int clpum_set_selected(int n, int repeat); #define CLPUM_DEF_HEIGHT 10 #define CLPUM_DEF_WIDTH 15 @@ -42,12 +42,12 @@ static int clpum_set_selected __ARGS((int n, int repeat)); * The menu appears above the screen line "row" or at "row" + "height" - 1. */ void -clpum_display(array, size, selected, disp_col) - pumitem_T *array; - int size; - int selected; /* index of initially selected item, none if +clpum_display( + pumitem_T *array, + int size, + int selected, /* index of initially selected item, none if out of range */ - int disp_col; + int disp_col) { int w; int def_width; @@ -184,7 +184,7 @@ clpum_display(array, size, selected, disp_col) * Redraw the popup menu, using "clpum_first" and "clpum_selected". */ void -clpum_redraw() +clpum_redraw(void) { int row = clpum_row; int col; @@ -390,7 +390,7 @@ clpum_set_selected( * Undisplay the popup menu (later). */ void -clpum_undisplay() +clpum_undisplay(void) { //FreeWild(clpum_size, clpum_array); clpum_array = NULL; @@ -407,7 +407,7 @@ clpum_undisplay() * displayed item. */ void -clpum_clear() +clpum_clear(void) { clpum_first = 0; } @@ -417,7 +417,7 @@ clpum_clear() * Overruled when "clpum_do_redraw" is set, used to redraw the status lines. */ int -clpum_visible() +clpum_visible(void) { return !clpum_do_redraw && clpum_array != NULL; } @@ -427,7 +427,7 @@ clpum_visible() * Only valid when clpum_visible() returns TRUE! */ int -clpum_get_height() +clpum_get_height(void) { return clpum_height; } diff --git a/src/eval.c b/src/eval.c index ab06d972cc216..cbf821f9ba452 100644 --- a/src/eval.c +++ b/src/eval.c @@ -513,6 +513,7 @@ static void f_changenr(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_clearmatches(typval_T *argvars, typval_T *rettv); +static void f_clpumvisible(typval_T *argvars, typval_T *rettv); static void f_col(typval_T *argvars, typval_T *rettv); #if defined(FEAT_INS_EXPAND) static void f_complete(typval_T *argvars, typval_T *rettv); @@ -10095,9 +10096,9 @@ f_clearmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED) * "clpumvisible()" function */ static void -f_clpumvisible(argvars, rettv) - typval_T *argvars UNUSED; - typval_T *rettv UNUSED; +f_clpumvisible( + typval_T *argvars UNUSED, + typval_T *rettv UNUSED) { #ifdef FEAT_CMDL_COMPL if (clpum_visible()) diff --git a/src/ex_getln.c b/src/ex_getln.c index 04d3a43268da9..46739e620fedd 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -177,9 +177,9 @@ static void clpum_compl_upd_pum(void); static void clpum_compl_del_pum(void); static int clpum_wanted(void); static int clpum_enough_matches(void); -static void clpum_compl_dictionaries(char_u *dict, char_u *pat, int flags, int thesaurus); -static void clpum_compl_files(int count, char_u **files, int thesaurus, int flags, regmatch_T *regmatch, char_u *buf, int *dir); -static char_u *find_line_end(char_u *ptr); +//static void clpum_compl_dictionaries(char_u *dict, char_u *pat, int flags, int thesaurus); +//static void clpum_compl_files(int count, char_u **files, int thesaurus, int flags, regmatch_T *regmatch, char_u *buf, int *dir); +//static char_u *find_line_end(char_u *ptr); static void clpum_compl_free(void); static void clpum_compl_clear(void); static int clpum_compl_bs(void); @@ -192,7 +192,7 @@ static void clpum_compl_set_original_text(char_u *str); static void clpum_compl_addfrommatch(void); static int clpum_compl_prep(int c); //static void clpum_compl_fixRedoBufForLeader(char_u *ptr_arg); -static buf_T *clpum_compl_next_buf(buf_T *buf, int flag); +//static buf_T *clpum_compl_next_buf(buf_T *buf, int flag); #if defined(FEAT_CMDL_COMPL) || defined(FEAT_EVAL) static void clpum_compl_add_list(list_T *list); static void clpum_compl_add_dict(dict_T *dict); @@ -1021,8 +1021,11 @@ getcmdline( * - wildcard expansion is only done when the 'wildchar' key is really * typed, not when it comes from a macro */ - if (!clpum_compl_started - && ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm)) + if ( +#ifdef FEAT_CMDL_COMPL + !clpum_compl_started && +#endif + ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm)) { if (xpc.xp_numfiles > 0) /* typed p_wc at least twice */ { @@ -1130,7 +1133,11 @@ getcmdline( gotesc = FALSE; /* goes to last match, in a clumsy way */ - if (!clpum_compl_started && c == K_S_TAB && KeyTyped) + if ( +#ifdef FEAT_CMDL_COMPL + !clpum_compl_started && +#endif + c == K_S_TAB && KeyTyped) { if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK @@ -3462,8 +3469,10 @@ redrawcmdline(void) need_wait_return = FALSE; compute_cmdrow(); redrawcmd(); +#ifdef FEAT_CMDL_COMPL if (clpum_visible()) showmode(); +#endif cursorcmd(); } @@ -8060,7 +8069,7 @@ clpum_compl_prep(int c) } #ifdef FEAT_CMDL_COMPL -static void expand_by_function __ARGS((char_u *base)); +static void expand_by_function(char_u *base); /* * Execute user defined complete function 'clcompletefunc' and diff --git a/src/proto/clpum.pro b/src/proto/clpum.pro index a7f99bad32103..41234ef0c82f7 100644 --- a/src/proto/clpum.pro +++ b/src/proto/clpum.pro @@ -1,8 +1,8 @@ /* clpum.c */ -void clpum_display __ARGS((pumitem_T *array, int size, int selected, int disp_col)); -void clpum_redraw __ARGS((void)); -void clpum_undisplay __ARGS((void)); -void clpum_clear __ARGS((void)); -int clpum_visible __ARGS((void)); -int clpum_get_height __ARGS((void)); +void clpum_display(pumitem_T *array, int size, int selected, int disp_col); +void clpum_redraw(void); +void clpum_undisplay(void); +void clpum_clear(void); +int clpum_visible(void); +int clpum_get_height(void); /* vim: set ft=c : */ diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro index a84c4c0cac75e..67d9f340a14bf 100644 --- a/src/proto/ex_getln.pro +++ b/src/proto/ex_getln.pro @@ -56,8 +56,8 @@ void write_viminfo_history(FILE *fp, int merge); void cmd_pchar(int c, int offset); int cmd_gchar(int offset); char_u *script_get(exarg_T *eap, char_u *cmd); - int vim_is_clpum_key(int c); +int clpum_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int dir, int flags); void clpum_compl_show_pum(void); int clpum_compl_active(void); int clpum_compl_add_tv(typval_T *tv, int dir); diff --git a/src/screen.c b/src/screen.c index a57d25289db52..84331b508527e 100644 --- a/src/screen.c +++ b/src/screen.c @@ -9954,10 +9954,11 @@ showmode(void) do_mode = ((p_smd && msg_silent == 0) && ((State & INSERT) || restart_edit -#ifdef FEAT_INS_EXPAND +#ifdef FEAT_CMDL_COMPL || (clpum_compl_active() - && p_ch > (get_cmdline_len() + 1) / Columns + 1))) + && p_ch > (get_cmdline_len() + 1) / Columns + 1) #endif + )) || VIsual_active; if (do_mode || Recording) { diff --git a/src/vim.h b/src/vim.h index c18046f67b000..b3f746c0b57f8 100644 --- a/src/vim.h +++ b/src/vim.h @@ -1897,8 +1897,8 @@ typedef int proftime_T; /* dummy for function prototypes */ #define VV_TRUE 64 #define VV_NULL 65 #define VV_NONE 66 -#define VV_LEN 67 /* number of v: vars */ -#define VV_CLCOMPLETED_ITEM 68 +#define VV_CLCOMPLETED_ITEM 67 +#define VV_LEN 68 /* number of v: vars */ /* used for v_number in VAR_SPECIAL */ #define VVAL_FALSE 0L