comparison src/evalfunc.c @ 17652:9efb4dda9720

patch 8.1.1823: command line history code is spread out commit https://github.com/vim/vim/commit/d7663c22c6c1ff0f86b81371586fbc851d3a3e9e Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 6 21:59:57 2019 +0200 patch 8.1.1823: command line history code is spread out Problem: Command line history code is spread out. Solution: Put the code in a new file. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4779) Also graduate the +cmdline_hist feature.
author Bram Moolenaar <Bram@vim.org>
date Tue, 06 Aug 2019 22:00:08 +0200
parents 1687c8935ab6
children 1be29c149103
comparison
equal deleted inserted replaced
17651:826360df7aff 17652:9efb4dda9720
180 static void f_globpath(typval_T *argvars, typval_T *rettv); 180 static void f_globpath(typval_T *argvars, typval_T *rettv);
181 static void f_glob2regpat(typval_T *argvars, typval_T *rettv); 181 static void f_glob2regpat(typval_T *argvars, typval_T *rettv);
182 static void f_has(typval_T *argvars, typval_T *rettv); 182 static void f_has(typval_T *argvars, typval_T *rettv);
183 static void f_haslocaldir(typval_T *argvars, typval_T *rettv); 183 static void f_haslocaldir(typval_T *argvars, typval_T *rettv);
184 static void f_hasmapto(typval_T *argvars, typval_T *rettv); 184 static void f_hasmapto(typval_T *argvars, typval_T *rettv);
185 static void f_histadd(typval_T *argvars, typval_T *rettv);
186 static void f_histdel(typval_T *argvars, typval_T *rettv);
187 static void f_histget(typval_T *argvars, typval_T *rettv);
188 static void f_histnr(typval_T *argvars, typval_T *rettv);
189 static void f_hlID(typval_T *argvars, typval_T *rettv); 185 static void f_hlID(typval_T *argvars, typval_T *rettv);
190 static void f_hlexists(typval_T *argvars, typval_T *rettv); 186 static void f_hlexists(typval_T *argvars, typval_T *rettv);
191 static void f_hostname(typval_T *argvars, typval_T *rettv); 187 static void f_hostname(typval_T *argvars, typval_T *rettv);
192 static void f_iconv(typval_T *argvars, typval_T *rettv); 188 static void f_iconv(typval_T *argvars, typval_T *rettv);
193 static void f_indent(typval_T *argvars, typval_T *rettv); 189 static void f_indent(typval_T *argvars, typval_T *rettv);
6112 "clipboard", 6108 "clipboard",
6113 #endif 6109 #endif
6114 #ifdef FEAT_CMDL_COMPL 6110 #ifdef FEAT_CMDL_COMPL
6115 "cmdline_compl", 6111 "cmdline_compl",
6116 #endif 6112 #endif
6117 #ifdef FEAT_CMDHIST
6118 "cmdline_hist", 6113 "cmdline_hist",
6119 #endif
6120 #ifdef FEAT_COMMENTS 6114 #ifdef FEAT_COMMENTS
6121 "comments", 6115 "comments",
6122 #endif 6116 #endif
6123 #ifdef FEAT_CONCEAL 6117 #ifdef FEAT_CONCEAL
6124 "conceal", 6118 "conceal",
6683 6677
6684 if (map_to_exists(name, mode, abbr)) 6678 if (map_to_exists(name, mode, abbr))
6685 rettv->vval.v_number = TRUE; 6679 rettv->vval.v_number = TRUE;
6686 else 6680 else
6687 rettv->vval.v_number = FALSE; 6681 rettv->vval.v_number = FALSE;
6688 }
6689
6690 /*
6691 * "histadd()" function
6692 */
6693 static void
6694 f_histadd(typval_T *argvars UNUSED, typval_T *rettv)
6695 {
6696 #ifdef FEAT_CMDHIST
6697 int histype;
6698 char_u *str;
6699 char_u buf[NUMBUFLEN];
6700 #endif
6701
6702 rettv->vval.v_number = FALSE;
6703 if (check_secure())
6704 return;
6705 #ifdef FEAT_CMDHIST
6706 str = tv_get_string_chk(&argvars[0]); /* NULL on type error */
6707 histype = str != NULL ? get_histtype(str) : -1;
6708 if (histype >= 0)
6709 {
6710 str = tv_get_string_buf(&argvars[1], buf);
6711 if (*str != NUL)
6712 {
6713 init_history();
6714 add_to_history(histype, str, FALSE, NUL);
6715 rettv->vval.v_number = TRUE;
6716 return;
6717 }
6718 }
6719 #endif
6720 }
6721
6722 /*
6723 * "histdel()" function
6724 */
6725 static void
6726 f_histdel(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
6727 {
6728 #ifdef FEAT_CMDHIST
6729 int n;
6730 char_u buf[NUMBUFLEN];
6731 char_u *str;
6732
6733 str = tv_get_string_chk(&argvars[0]); /* NULL on type error */
6734 if (str == NULL)
6735 n = 0;
6736 else if (argvars[1].v_type == VAR_UNKNOWN)
6737 /* only one argument: clear entire history */
6738 n = clr_history(get_histtype(str));
6739 else if (argvars[1].v_type == VAR_NUMBER)
6740 /* index given: remove that entry */
6741 n = del_history_idx(get_histtype(str),
6742 (int)tv_get_number(&argvars[1]));
6743 else
6744 /* string given: remove all matching entries */
6745 n = del_history_entry(get_histtype(str),
6746 tv_get_string_buf(&argvars[1], buf));
6747 rettv->vval.v_number = n;
6748 #endif
6749 }
6750
6751 /*
6752 * "histget()" function
6753 */
6754 static void
6755 f_histget(typval_T *argvars UNUSED, typval_T *rettv)
6756 {
6757 #ifdef FEAT_CMDHIST
6758 int type;
6759 int idx;
6760 char_u *str;
6761
6762 str = tv_get_string_chk(&argvars[0]); /* NULL on type error */
6763 if (str == NULL)
6764 rettv->vval.v_string = NULL;
6765 else
6766 {
6767 type = get_histtype(str);
6768 if (argvars[1].v_type == VAR_UNKNOWN)
6769 idx = get_history_idx(type);
6770 else
6771 idx = (int)tv_get_number_chk(&argvars[1], NULL);
6772 /* -1 on type error */
6773 rettv->vval.v_string = vim_strsave(get_history_entry(type, idx));
6774 }
6775 #else
6776 rettv->vval.v_string = NULL;
6777 #endif
6778 rettv->v_type = VAR_STRING;
6779 }
6780
6781 /*
6782 * "histnr()" function
6783 */
6784 static void
6785 f_histnr(typval_T *argvars UNUSED, typval_T *rettv)
6786 {
6787 int i;
6788
6789 #ifdef FEAT_CMDHIST
6790 char_u *history = tv_get_string_chk(&argvars[0]);
6791
6792 i = history == NULL ? HIST_CMD - 1 : get_histtype(history);
6793 if (i >= HIST_CMD && i < HIST_COUNT)
6794 i = get_history_idx(i);
6795 else
6796 #endif
6797 i = -1;
6798 rettv->vval.v_number = i;
6799 } 6682 }
6800 6683
6801 /* 6684 /*
6802 * "highlightID(name)" function 6685 * "highlightID(name)" function
6803 */ 6686 */