mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
/SET prompt - if target had %c or something in it, it shouldn't be
treated as color code. So color codes can now be used in /SET prompt string itself, but in none of the $variables it uses. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1324 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
9a5b97164e
commit
d4558de232
@ -435,6 +435,16 @@ char *parse_special(char **cmd, SERVER_REC *server, void *item,
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gstring_append_escaped(GString *str, const char *text)
|
||||||
|
{
|
||||||
|
while (*text != '\0') {
|
||||||
|
if (*text == '%')
|
||||||
|
g_string_append_c(str, '%');
|
||||||
|
g_string_append_c(str, *text);
|
||||||
|
text++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* parse the whole string. $ and \ chars are replaced */
|
/* parse the whole string. $ and \ chars are replaced */
|
||||||
char *parse_special_string(const char *cmd, SERVER_REC *server, void *item,
|
char *parse_special_string(const char *cmd, SERVER_REC *server, void *item,
|
||||||
const char *data, int *arg_used, int flags)
|
const char *data, int *arg_used, int flags)
|
||||||
@ -472,7 +482,10 @@ char *parse_special_string(const char *cmd, SERVER_REC *server, void *item,
|
|||||||
arglist, &need_free, arg_used,
|
arglist, &need_free, arg_used,
|
||||||
flags);
|
flags);
|
||||||
if (ret != NULL) {
|
if (ret != NULL) {
|
||||||
|
if ((flags & PARSE_FLAG_ESCAPE_VARS) == 0)
|
||||||
g_string_append(str, ret);
|
g_string_append(str, ret);
|
||||||
|
else
|
||||||
|
gstring_append_escaped(str, ret);
|
||||||
if (need_free) g_free(ret);
|
if (need_free) g_free(ret);
|
||||||
}
|
}
|
||||||
code = 0;
|
code = 0;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#define PARSE_FLAG_GETNAME 0x01 /* return argument name instead of it's value */
|
#define PARSE_FLAG_GETNAME 0x01 /* return argument name instead of it's value */
|
||||||
#define PARSE_FLAG_ISSET_ANY 0x02 /* arg_used field specifies that at least one of the $variables was non-empty */
|
#define PARSE_FLAG_ISSET_ANY 0x02 /* arg_used field specifies that at least one of the $variables was non-empty */
|
||||||
|
#define PARSE_FLAG_ESCAPE_VARS 0x04 /* if any arguments/variables contain % chars, escape them with another % */
|
||||||
|
|
||||||
typedef char* (*SPECIAL_HISTORY_FUNC)
|
typedef char* (*SPECIAL_HISTORY_FUNC)
|
||||||
(const char *text, void *item, int *free_ret);
|
(const char *text, void *item, int *free_ret);
|
||||||
|
@ -693,7 +693,8 @@ void window_update_prompt(void)
|
|||||||
|
|
||||||
prompt = parse_special_string(special, active_win->active_server,
|
prompt = parse_special_string(special, active_win->active_server,
|
||||||
active_win->active, "", &var_used,
|
active_win->active, "", &var_used,
|
||||||
PARSE_FLAG_ISSET_ANY);
|
PARSE_FLAG_ISSET_ANY |
|
||||||
|
PARSE_FLAG_ESCAPE_VARS);
|
||||||
if (!var_used && strchr(special, '$') != NULL) {
|
if (!var_used && strchr(special, '$') != NULL) {
|
||||||
/* none of the $vars had non-empty values, use empty prompt */
|
/* none of the $vars had non-empty values, use empty prompt */
|
||||||
*prompt = '\0';
|
*prompt = '\0';
|
||||||
|
Loading…
Reference in New Issue
Block a user