diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-04 10:09:53 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-04 10:09:53 +0200 |
commit | 6ea81f4c8c1067471f50c936ed27e013ce50f222 (patch) | |
tree | 17e3fcc2b4c1d9daee2b5f074ba2a2beff81ec46 /src | |
parent | dc878c5b69d498e3edb225e1997455510579deed (diff) | |
download | weechat-6ea81f4c8c1067471f50c936ed27e013ce50f222.zip |
api: add support of colors with format "${color:xxx}" in function string_eval_expression and command /eval
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-command.c | 7 | ||||
-rw-r--r-- | src/core/wee-eval.c | 23 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 05116261b..b90bbd1fb 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -6379,9 +6379,10 @@ command_init () " \"50\" > \"100\" ==> 1\n\n" "Some variables are replaced in expression, using the " "format ${variable}, variable can be, by order of priority :\n" - " 1. the name of an option (file.section.option)\n" - " 2. the name of a local variable in buffer\n" - " 3. a hdata name/variable (the value is automatically " + " 1. a color (format: color:xxx)\n" + " 2. an option (format: file.section.option)\n" + " 3. a local variable in buffer\n" + " 4. a hdata name/variable (the value is automatically " "converted to string), by default \"window\" and \"buffer\" " "point to current window/buffer.\n" "Format for hdata can be one of following:\n" diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index 3db3cc8c2..0097103e8 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -215,9 +215,10 @@ end: /* * Replaces variables, which can be, by order of priority: * 1. an extra variable (from hashtable "extra_vars") - * 2. an name of option (file.section.option) - * 3. a buffer local variable - * 4. a hdata name/variable + * 2. a color (format: color:xxx) + * 3. an option (format: file.section.option) + * 4. a buffer local variable + * 5. a hdata name/variable * * Examples: * option: ${weechat.look.scroll_amount} @@ -245,12 +246,18 @@ eval_replace_vars_cb (void *data, const char *text) if (ptr_value) return strdup (ptr_value); - /* 2. look for name of option: if found, return this value */ + /* 2. look for a color */ + if (strncmp (text, "color:", 6) == 0) + { + ptr_value = gui_color_get_custom (text + 6); + return strdup ((ptr_value) ? ptr_value : ""); + } + + /* 3. look for name of option: if found, return this value */ if (strncmp (text, "sec.data.", 9) == 0) { ptr_value = hashtable_get (secure_hashtable_data, text + 9); - if (ptr_value) - return strdup (ptr_value); + return strdup ((ptr_value) ? ptr_value : ""); } else { @@ -277,7 +284,7 @@ eval_replace_vars_cb (void *data, const char *text) } } - /* 3. look for local variable in buffer */ + /* 4. look for local variable in buffer */ ptr_buffer = hashtable_get (pointers, "buffer"); if (ptr_buffer) { @@ -286,7 +293,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup (ptr_value); } - /* 4. look for hdata */ + /* 5. look for hdata */ value = NULL; hdata_name = NULL; list_name = NULL; |