diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-07-18 15:45:49 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-07-18 15:45:49 +0200 |
commit | dc536095ac452c12e9bb4c69b473d28d51e8d4b9 (patch) | |
tree | c9cb78c565a0f42f5a82a519d9f191772831627d /src/eval.c | |
parent | 72597a57b526a8df333e77ef8a837b595baa18c7 (diff) |
Added strdisplaywidth() function.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index a344cd2a52..3a0d85c1f4 100644 --- a/src/eval.c +++ b/src/eval.c @@ -710,6 +710,7 @@ static void f_strlen __ARGS((typval_T *argvars, typval_T *rettv)); static void f_strpart __ARGS((typval_T *argvars, typval_T *rettv)); static void f_strridx __ARGS((typval_T *argvars, typval_T *rettv)); static void f_strtrans __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_strdisplaywidth __ARGS((typval_T *argvars, typval_T *rettv)); static void f_strwidth __ARGS((typval_T *argvars, typval_T *rettv)); static void f_submatch __ARGS((typval_T *argvars, typval_T *rettv)); static void f_substitute __ARGS((typval_T *argvars, typval_T *rettv)); @@ -7859,6 +7860,7 @@ static struct fst #endif {"str2nr", 1, 2, f_str2nr}, {"strchars", 1, 1, f_strchars}, + {"strdisplaywidth", 1, 2, f_strdisplaywidth}, #ifdef HAVE_STRFTIME {"strftime", 1, 2, f_strftime}, #endif @@ -16805,6 +16807,23 @@ f_strchars(argvars, rettv) } /* + * "strdisplaywidth()" function + */ + static void +f_strdisplaywidth(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + char_u *s = get_tv_string(&argvars[0]); + int col = 0; + + if (argvars[1].v_type != VAR_UNKNOWN) + col = get_tv_number(&argvars[1]); + + rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s)); +} + +/* * "strwidth()" function */ static void |