core: add support of full color option name in command /eval and API function string_eval_expression()
This commit is contained in:
parent
0f333ee630
commit
d322389e04
@ -19,6 +19,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
|
||||
=== New features
|
||||
|
||||
* core: add support of full color option name in command /eval
|
||||
* core: use environment variable WEECHAT_HOME on startup (closes #391)
|
||||
* core: remove WeeChat version from config files (closes #407)
|
||||
* core: add options weechat.look.quote_{nick_prefix|nick_suffix|time_format} to
|
||||
@ -32,7 +33,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
* core: add option "-s" in command /eval to split expression before evaluating
|
||||
it (no more split by default) (closes #324)
|
||||
* core: add priority in plugins to initialize them in order
|
||||
* api: add support of full option name in function color()
|
||||
* api: add support of full color option name in functions color() and
|
||||
string_eval_expression()
|
||||
* api: add "_chat_line" (line pointer) in hashtable of hook_focus
|
||||
* irc: add support of SHA-256 and SHA-512 algorithms in server option
|
||||
"ssl_fingerprint" (closes #281)
|
||||
|
@ -1922,7 +1922,8 @@ expanded to last):
|
||||
`test`
|
||||
|
||||
| `${color:name}` |
|
||||
WeeChat color code (the name of color has optional attributes) |
|
||||
WeeChat color code (the name of color has optional attributes),
|
||||
see function <<_color,weechat_color>> for supported formats |
|
||||
`${color:red}red text` +
|
||||
`${color:*214}bold orange text` |
|
||||
`red text` (in red) +
|
||||
|
@ -1962,7 +1962,8 @@ première étendue à la dernière) :
|
||||
`test`
|
||||
|
||||
| `${color:nom}` |
|
||||
Code couleur WeeChat (le nom de couleur a des attributs facultatifs) |
|
||||
Code couleur WeeChat (le nom de couleur a des attributs facultatifs),
|
||||
voir la fonction <<_color,weechat_color>> pour les formats supportés |
|
||||
`${color:red}texte rouge` +
|
||||
`${color:*214}texte orange gras` |
|
||||
`texte rouge` (en rouge) +
|
||||
|
@ -1990,7 +1990,8 @@ expanded to last):
|
||||
`test`
|
||||
|
||||
| `${color:name}` |
|
||||
WeeChat color code (the name of color has optional attributes) |
|
||||
WeeChat color code (the name of color has optional attributes),
|
||||
see function <<_color,weechat_color>> for supported formats |
|
||||
`${color:red}red text` +
|
||||
`${color:*214}bold orange text` |
|
||||
`red text` (in red) +
|
||||
|
@ -1922,8 +1922,10 @@ char *weechat_string_eval_expression (const char *expr,
|
||||
`${re:1}` |
|
||||
`test`
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| `${color:name}` |
|
||||
WeeChat 色コード (色名部分はオプション属性をとることも可能です) |
|
||||
WeeChat 色コード (色名部分はオプション属性をとることも可能です),
|
||||
see function <<_color,weechat_color>> for supported formats |
|
||||
`${color:red}red text` +
|
||||
`${color:*214}bold orange text` |
|
||||
`red text` (赤色で) +
|
||||
|
@ -325,6 +325,9 @@ eval_replace_vars_cb (void *data, const char *text)
|
||||
/* 5. color code */
|
||||
if (strncmp (text, "color:", 6) == 0)
|
||||
{
|
||||
ptr_value = gui_color_search_config (text + 6);
|
||||
if (ptr_value)
|
||||
return strdup (ptr_value);
|
||||
ptr_value = gui_color_get_custom (text + 6);
|
||||
return strdup ((ptr_value) ? ptr_value : "");
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
struct t_config_option;
|
||||
|
||||
/*
|
||||
* Color from configuration options.
|
||||
* When changing some colors below:
|
||||
@ -173,6 +175,7 @@ extern struct t_weelist *gui_color_list_with_alias;
|
||||
|
||||
/* color functions */
|
||||
|
||||
extern const char *gui_color_from_option (struct t_config_option *option);
|
||||
extern const char *gui_color_search_config (const char *color_name);
|
||||
extern int gui_color_attr_get_flag (char c);
|
||||
extern void gui_color_attr_build_string (int color, char *str_attr);
|
||||
|
@ -27,6 +27,7 @@ extern "C"
|
||||
#include <regex.h>
|
||||
#include "src/core/wee-eval.h"
|
||||
#include "src/core/wee-config.h"
|
||||
#include "src/core/wee-config-file.h"
|
||||
#include "src/core/wee-hashtable.h"
|
||||
#include "src/core/wee-string.h"
|
||||
#include "src/core/wee-version.h"
|
||||
@ -38,6 +39,7 @@ extern "C"
|
||||
value = eval_expression (__expr, pointers, extra_vars, options); \
|
||||
STRCMP_EQUAL(__result, value); \
|
||||
free (value);
|
||||
|
||||
TEST_GROUP(Eval)
|
||||
{
|
||||
};
|
||||
@ -171,6 +173,7 @@ TEST(Eval, EvalCondition)
|
||||
TEST(Eval, EvalExpression)
|
||||
{
|
||||
struct t_hashtable *pointers, *extra_vars, *options;
|
||||
struct t_config_option *ptr_option;
|
||||
char *value, str_value[256];
|
||||
|
||||
pointers = NULL;
|
||||
@ -209,6 +212,20 @@ TEST(Eval, EvalExpression)
|
||||
/* test color */
|
||||
WEE_CHECK_EVAL(gui_color_get_custom ("green"), "${color:green}");
|
||||
WEE_CHECK_EVAL(gui_color_get_custom ("*214"), "${color:*214}");
|
||||
snprintf (str_value, sizeof (str_value),
|
||||
"%s-test-",
|
||||
gui_color_from_option (config_color_chat_delimiters));
|
||||
WEE_CHECK_EVAL(str_value, "${color:chat_delimiters}-test-");
|
||||
config_file_search_with_string ("irc.color.message_join", NULL, NULL,
|
||||
&ptr_option, NULL);
|
||||
if (!ptr_option)
|
||||
{
|
||||
FAIL("ERROR: option irc.color.message_join not found.");
|
||||
}
|
||||
snprintf (str_value, sizeof (str_value),
|
||||
"%s-test-", gui_color_from_option (ptr_option));
|
||||
WEE_CHECK_EVAL(str_value, "${color:irc.color.message_join}-test-");
|
||||
WEE_CHECK_EVAL("test", "${option.not.found}test");
|
||||
|
||||
/* test info */
|
||||
WEE_CHECK_EVAL(version_get_version (), "${info:version}");
|
||||
|
Loading…
x
Reference in New Issue
Block a user