diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-09-10 19:26:26 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-09-10 19:26:26 +0000 |
commit | 6efa2b30f4315ac9c15e1e0bb91e31153ee583a4 (patch) | |
tree | d0f216e30fbd47771ecd11beb53b41130d36a36a /src | |
parent | dcca87b3947554e12e568f7f216f6ebd2af25d8f (diff) | |
download | vim-6efa2b30f4315ac9c15e1e0bb91e31153ee583a4.zip |
updated for version 7.0145
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index 689af1fbf..600a0207e 100644 --- a/src/eval.c +++ b/src/eval.c @@ -534,6 +534,7 @@ static void f_indent __ARGS((typval_T *argvars, typval_T *rettv)); static void f_index __ARGS((typval_T *argvars, typval_T *rettv)); static void f_input __ARGS((typval_T *argvars, typval_T *rettv)); static void f_inputdialog __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_inputlist __ARGS((typval_T *argvars, typval_T *rettv)); static void f_inputrestore __ARGS((typval_T *argvars, typval_T *rettv)); static void f_inputsave __ARGS((typval_T *argvars, typval_T *rettv)); static void f_inputsecret __ARGS((typval_T *argvars, typval_T *rettv)); @@ -6800,6 +6801,7 @@ static struct fst {"index", 2, 4, f_index}, {"input", 1, 2, f_input}, {"inputdialog", 1, 3, f_inputdialog}, + {"inputlist", 1, 1, f_inputlist}, {"inputrestore", 0, 0, f_inputrestore}, {"inputsave", 0, 0, f_inputsave}, {"inputsecret", 1, 2, f_inputsecret}, @@ -10887,6 +10889,50 @@ f_inputdialog(argvars, rettv) f_input(argvars, rettv); } +/* + * "inputlist()" function + */ + static void +f_inputlist(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + listitem_T *li; + int selected; + int mouse_used; + + rettv->vval.v_number = 0; +#ifdef NO_CONSOLE_INPUT + /* While starting up, there is no place to enter text. */ + if (no_console_input()) + return; +#endif + if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL) + { + EMSG2(_(e_listarg), "inputlist()"); + return; + } + + msg_start(); + lines_left = Rows; /* avoid more prompt */ + msg_scroll = TRUE; + msg_clr_eos(); + + for (li = argvars[0].vval.v_list->lv_first; li != NULL; li = li->li_next) + { + msg_puts(get_tv_string(&li->li_tv)); + msg_putchar('\n'); + } + + /* Ask for choice. */ + selected = prompt_for_number(&mouse_used); + if (mouse_used) + selected -= lines_left; + + rettv->vval.v_number = selected; +} + + static garray_T ga_userinput = {0, 0, sizeof(tasave_T), 4, NULL}; /* |