comparison src/eval.c @ 7480:a49163681559 v7.4.1042

commit https://github.com/vim/vim/commit/ed767a2073ef150971b0439a58e7ee582af6984e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 3 22:49:16 2016 +0100 patch 7.4.1042 Problem: g-CTRL-G shows the word count, but there is no way to get the word count in a script. Solution: Add the wordcount() function. (Christian Brabandt)
author Christian Brabandt <cb@256bit.org>
date Sun, 03 Jan 2016 23:00:04 +0100
parents e583db6c4fd4
children 3fcd3d235f7b
comparison
equal deleted inserted replaced
7479:cae508519cf6 7480:a49163681559
778 static void f_winrestcmd __ARGS((typval_T *argvars, typval_T *rettv)); 778 static void f_winrestcmd __ARGS((typval_T *argvars, typval_T *rettv));
779 static void f_winrestview __ARGS((typval_T *argvars, typval_T *rettv)); 779 static void f_winrestview __ARGS((typval_T *argvars, typval_T *rettv));
780 static void f_winsaveview __ARGS((typval_T *argvars, typval_T *rettv)); 780 static void f_winsaveview __ARGS((typval_T *argvars, typval_T *rettv));
781 static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv)); 781 static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv));
782 static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv)); 782 static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
783 static void f_wordcount __ARGS((typval_T *argvars, typval_T *rettv));
783 static void f_xor __ARGS((typval_T *argvars, typval_T *rettv)); 784 static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
784 785
785 static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp)); 786 static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp));
786 static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum)); 787 static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
787 static int get_env_len __ARGS((char_u **arg)); 788 static int get_env_len __ARGS((char_u **arg));
8385 {"winnr", 0, 1, f_winnr}, 8386 {"winnr", 0, 1, f_winnr},
8386 {"winrestcmd", 0, 0, f_winrestcmd}, 8387 {"winrestcmd", 0, 0, f_winrestcmd},
8387 {"winrestview", 1, 1, f_winrestview}, 8388 {"winrestview", 1, 1, f_winrestview},
8388 {"winsaveview", 0, 0, f_winsaveview}, 8389 {"winsaveview", 0, 0, f_winsaveview},
8389 {"winwidth", 1, 1, f_winwidth}, 8390 {"winwidth", 1, 1, f_winwidth},
8391 {"wordcount", 0, 0, f_wordcount},
8390 {"writefile", 2, 3, f_writefile}, 8392 {"writefile", 2, 3, f_writefile},
8391 {"xor", 2, 2, f_xor}, 8393 {"xor", 2, 2, f_xor},
8392 }; 8394 };
8393 8395
8394 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) 8396 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
20215 #ifdef FEAT_VERTSPLIT 20217 #ifdef FEAT_VERTSPLIT
20216 rettv->vval.v_number = wp->w_width; 20218 rettv->vval.v_number = wp->w_width;
20217 #else 20219 #else
20218 rettv->vval.v_number = Columns; 20220 rettv->vval.v_number = Columns;
20219 #endif 20221 #endif
20222 }
20223
20224 /*
20225 * "wordcount()" function
20226 */
20227 static void
20228 f_wordcount(argvars, rettv)
20229 typval_T *argvars UNUSED;
20230 typval_T *rettv;
20231 {
20232 if (rettv_dict_alloc(rettv) == FAIL)
20233 return;
20234 cursor_pos_info(rettv->vval.v_dict);
20220 } 20235 }
20221 20236
20222 /* 20237 /*
20223 * Write list of strings to file 20238 * Write list of strings to file
20224 */ 20239 */