diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-04-24 22:37:49 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-04-24 22:37:49 +0200 |
commit | 112bebcddf99d5187ede8ebbe765abc75373c4f2 (patch) | |
tree | 3430bc6a930518eb0fe325c93bd7217d823083c6 /src/core/wee-eval.c | |
parent | 0470a71af9e9da57b39702f94705f5f43cec5448 (diff) | |
download | weechat-112bebcddf99d5187ede8ebbe765abc75373c4f2.zip |
core: add a way to count the suffix length in max chars displayed in cut of string ("cut:" and "cutscr:") (closes #963)
The format to use is one of:
- ${cut:+max,suffix,string}
- ${cutscr:+max,suffix,string}
With the "+" before max, WeeChat ensures there are at most "max" chars in
output, including the length of suffix string.
Diffstat (limited to 'src/core/wee-eval.c')
-rw-r--r-- | src/core/wee-eval.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index 016d99c2d..4e5af5e95 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -326,6 +326,7 @@ eval_replace_vars_cb (void *data, const char *text) struct t_hdata *hdata; void *pointer; int i, length_hide_char, length, index, rc, extra_vars_eval, screen; + int count_suffix; long number; long unsigned int ptr; time_t date; @@ -436,6 +437,12 @@ eval_replace_vars_cb (void *data, const char *text) pos = strchr (text + length, ','); if (!pos) return strdup (""); + count_suffix = 0; + if (text[length] == '+') + { + length++; + count_suffix = 1; + } pos2 = strchr (pos + 1, ','); if (!pos2) return strdup (""); @@ -452,7 +459,7 @@ eval_replace_vars_cb (void *data, const char *text) tmp = strndup (pos + 1, pos2 - pos - 1); if (!tmp) return strdup (""); - value = string_cut (pos2 + 1, number, screen, tmp); + value = string_cut (pos2 + 1, number, count_suffix, screen, tmp); free (tmp); return value; } |