summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/special-vars.c5
-rw-r--r--src/core/special-vars.h1
-rw-r--r--src/fe-common/core/formats.c11
-rw-r--r--src/fe-common/core/themes.c8
4 files changed, 16 insertions, 9 deletions
diff --git a/src/core/special-vars.c b/src/core/special-vars.c
index 45bad34d..c1523319 100644
--- a/src/core/special-vars.c
+++ b/src/core/special-vars.c
@@ -202,6 +202,11 @@ static char *get_special_value(char **cmd, SERVER_REC *server, void *item,
char command, *value, *p;
int len;
+ if ((flags & PARSE_FLAG_ONLY_PARAMS) && !isdigit(**cmd)) {
+ *free_ret = TRUE;
+ return g_strdup_printf("$%c", **cmd);
+ }
+
if (**cmd == '!') {
/* find text from command history */
if (flags & PARSE_FLAG_GETNAME)
diff --git a/src/core/special-vars.h b/src/core/special-vars.h
index 45b41f52..d5ba0700 100644
--- a/src/core/special-vars.h
+++ b/src/core/special-vars.h
@@ -7,6 +7,7 @@
#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 % */
#define PARSE_FLAG_ESCAPE_THEME 0x08 /* if any arguments/variables contain { or } chars, escape them with % */
+#define PARSE_FLAG_ONLY_PARAMS 0x10 /* expand only arguments ($0 $1 etc.) but no other $variables */
typedef char* (*SPECIAL_HISTORY_FUNC)
(const char *text, void *item, int *free_ret);
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index cdc064d8..729a8b1e 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -27,6 +27,7 @@
#include "levels.h"
#include "fe-windows.h"
+#include "window-items.h"
#include "formats.h"
#include "themes.h"
#include "translation.h"
@@ -388,12 +389,10 @@ static char *format_get_text_args(TEXT_DEST_REC *dest,
/* argument */
char *ret;
- ret = parse_special((char **) &text,
- active_win == NULL ? NULL :
- active_win->active_server,
- active_win == NULL ? NULL :
- active_win->active, arglist,
- &need_free, NULL, 0);
+ ret = parse_special((char **) &text, dest->server,
+ dest->target == NULL ? NULL :
+ window_item_find(dest->server, dest->target),
+ arglist, &need_free, NULL, 0);
if (ret != NULL) {
/* string shouldn't end with \003 or it could
diff --git a/src/fe-common/core/themes.c b/src/fe-common/core/themes.c
index d5d2147d..9c72d567 100644
--- a/src/fe-common/core/themes.c
+++ b/src/fe-common/core/themes.c
@@ -119,7 +119,8 @@ static char *theme_replace_expand(THEME_REC *theme, int index,
abstract = theme_format_expand_data(theme, (const char **) &abstract,
default_fg, default_bg,
last_fg, last_bg, flags);
- ret = parse_special_string(abstract, NULL, NULL, data, NULL, 0);
+ ret = parse_special_string(abstract, NULL, NULL, data, NULL,
+ PARSE_FLAG_ONLY_PARAMS);
g_free(abstract);
return ret;
}
@@ -143,7 +144,7 @@ static void theme_format_append_variable(GString *str, const char **format)
(*format)++;
value = parse_special((char **) format, NULL, NULL,
- args, &free_ret, NULL, 0);
+ args, &free_ret, NULL, PARSE_FLAG_ONLY_PARAMS);
if (free_ret) g_free(value);
(*format)++;
@@ -300,7 +301,8 @@ static char *theme_format_expand_abstract(THEME_REC *theme,
g_free(tmp);
}
- ret = parse_special_string(abstract, NULL, NULL, data, NULL, 0);
+ ret = parse_special_string(abstract, NULL, NULL, data, NULL,
+ PARSE_FLAG_ONLY_PARAMS);
g_free(abstract);
g_free(data);
abstract = ret;