summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-03-11 02:07:05 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-03-11 02:07:05 +0000
commit1528cfc9d7ab32ba9573382fa7aa80d0f8fc472f (patch)
tree0381d5cdd1ee5803231d40c6eae4bbad9002ebdd /src
parentbcb79f5030cde95d533966d749bb0773e1ac53cb (diff)
downloadirssi-1528cfc9d7ab32ba9573382fa7aa80d0f8fc472f.zip
All control chars in statusbar items are now displayed reversed.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2574 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-text/statusbar.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fe-text/statusbar.c b/src/fe-text/statusbar.c
index 7f3bbe3c..9d39ede7 100644
--- a/src/fe-text/statusbar.c
+++ b/src/fe-text/statusbar.c
@@ -653,6 +653,32 @@ const char *statusbar_item_get_value(SBAR_ITEM_REC *item)
return value;
}
+static char *reverse_controls(const char *str)
+{
+ GString *out;
+ char *ret;
+
+ out = g_string_new(NULL);
+
+ while (*str != '\0') {
+ if ((unsigned char) *str < 32 ||
+ (term_type == TERM_TYPE_8BIT &&
+ (unsigned char) (*str & 0x7f) < 32)) {
+ /* control char */
+ g_string_sprintfa(out, "%%8%c%%8",
+ 'A'-1 + (*str & 0x7f));
+ } else {
+ g_string_append_c(out, *str);
+ }
+
+ str++;
+ }
+
+ ret = out->str;
+ g_string_free(out, FALSE);
+ return ret;
+}
+
void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
const char *str, const char *data,
int escape_vars)
@@ -693,6 +719,11 @@ void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
tmpstr = strip_codes(tmpstr2);
g_free(tmpstr2);
+ /* show all control chars reversed */
+ tmpstr2 = reverse_controls(tmpstr);
+ g_free(tmpstr);
+
+ tmpstr = tmpstr2;
if (get_size_only) {
item->min_size = item->max_size = format_get_length(tmpstr);
} else {