1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 12:56:37 +02:00

core: add cut of string in evaluation of expressions

The syntax is: ${cut:max,suffix,string}.
The string is cut after max chars. If the string is cut, the optional suffix is
added after.
This commit is contained in:
Sébastien Helleu
2017-03-14 07:25:03 +01:00
parent db0ecc07fe
commit 9a8ec36cbd
8 changed files with 143 additions and 27 deletions
+10
View File
@@ -218,6 +218,16 @@ TEST(Eval, EvalExpression)
WEE_CHECK_EVAL("********", "${hide:*,password}");
WEE_CHECK_EVAL("\u2603\u2603\u2603", "${hide:${esc:\u2603},abc}");
/* test cut of chars */
WEE_CHECK_EVAL("", "${cut:0,,}");
WEE_CHECK_EVAL("", "${cut:0,+,}");
WEE_CHECK_EVAL("", "${cut:0,,test}");
WEE_CHECK_EVAL("+", "${cut:0,+,test}");
WEE_CHECK_EVAL("te", "${cut:2,,test}");
WEE_CHECK_EVAL("te+", "${cut:2,+,test}");
WEE_CHECK_EVAL("éà", "${cut:2,,éàô}");
WEE_CHECK_EVAL("éà+", "${cut:2,+,éàô}");
/* test color */
WEE_CHECK_EVAL(gui_color_get_custom ("green"), "${color:green}");
WEE_CHECK_EVAL(gui_color_get_custom ("*214"), "${color:*214}");