diff options
author | sabetts <sabetts> | 2006-11-17 11:48:01 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2006-11-17 11:48:01 +0000 |
commit | df8d155eb949041943aa36baa4d0d485136922f9 (patch) | |
tree | fb4a0241981c75dda365f423f2acc96c027d4941 /src | |
parent | 823f6297c6813ac9b55af456892910f08178d873 (diff) | |
download | ratpoison-df8d155eb949041943aa36baa4d0d485136922f9.zip |
* src/split.c (show_frame_indicator): use defaults.frame_fmt
(show_frame_message): format frame_fmt string with format_string
* src/messages.h (MESSAGE_FRAME_STRING): removed
* src/main.c (init_defaults): init defaults.frame_fmt
* src/data.h (struct rp_defaults): add frame_fmt
* src/actions.c (set_framefmt): new function
(init_set_vars): new set var "framefmt"
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 14 | ||||
-rw-r--r-- | src/data.h | 3 | ||||
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/messages.h | 1 | ||||
-rw-r--r-- | src/split.c | 20 |
5 files changed, 35 insertions, 4 deletions
diff --git a/src/actions.c b/src/actions.c index 4a0b8f3..da01aba 100644 --- a/src/actions.c +++ b/src/actions.c @@ -57,6 +57,7 @@ static cmdret * set_inputwidth (struct cmdarg **args); static cmdret * set_waitcursor (struct cmdarg **args); static cmdret * set_winfmt (struct cmdarg **args); static cmdret * set_winname (struct cmdarg **args); +static cmdret * set_framefmt (struct cmdarg **args); static cmdret * set_fgcolor (struct cmdarg **args); static cmdret * set_bgcolor (struct cmdarg **args); static cmdret * set_barpadding (struct cmdarg **args); @@ -111,6 +112,7 @@ init_set_vars(void) add_set_var ("waitcursor", set_waitcursor, 1, "", arg_NUMBER); add_set_var ("winfmt", set_winfmt, 1, "", arg_REST); add_set_var ("winname", set_winname, 1, "", arg_STRING); + add_set_var ("framefmt", set_framefmt, 1, "", arg_REST); add_set_var ("fgcolor", set_fgcolor, 1, "", arg_STRING); add_set_var ("bgcolor", set_bgcolor, 1, "", arg_STRING); add_set_var ("barpadding", set_barpadding, 2, "", arg_NUMBER, "", arg_NUMBER); @@ -3721,6 +3723,18 @@ set_winname (struct cmdarg **args) } static cmdret * +set_framefmt (struct cmdarg **args) +{ + if (args[0] == NULL) + return cmdret_new (RET_SUCCESS, "%s", defaults.frame_fmt); + + free (defaults.frame_fmt); + defaults.frame_fmt = xstrdup (ARG_STRING(0)); + + return cmdret_new (RET_SUCCESS, NULL); +} + +static cmdret * set_fgcolor (struct cmdarg **args) { int i; @@ -252,6 +252,9 @@ struct rp_defaults /* The name of the top level keymap */ char *top_kmap; + + /* Frame indicator format */ + char *frame_fmt; }; /* Information about a child process. */ @@ -532,6 +532,7 @@ init_defaults (void) defaults.window_fmt = xstrdup ("%n%s%t"); defaults.info_fmt = xstrdup ("(%H, %W) %n(%t)"); + defaults.frame_fmt = xstrdup ("Current Frame"); defaults.win_name = WIN_NAME_TITLE; defaults.startup_message = 1; diff --git a/src/messages.h b/src/messages.h index 3e458b5..e85b5d4 100644 --- a/src/messages.h +++ b/src/messages.h @@ -50,6 +50,5 @@ #define MESSAGE_PROMPT_VAR_VALUE "Value: " #define MESSAGE_WELCOME "Welcome to ratpoison! Hit `%s %s' for help." -#define MESSAGE_FRAME_STRING "Current Frame" #endif /* ! _RATPOISON_MESSAGES_H */ diff --git a/src/split.c b/src/split.c index 93da642..ba4cd3b 100644 --- a/src/split.c +++ b/src/split.c @@ -960,7 +960,7 @@ void show_frame_indicator (void) { hide_frame_indicator (); - show_frame_message (MESSAGE_FRAME_STRING); + show_frame_message (defaults.frame_fmt); alarm (defaults.frame_indicator_timeout); } @@ -970,10 +970,22 @@ show_frame_message (char *msg) rp_screen *s = current_screen (); int width, height; rp_frame *frame; + rp_window *win; + rp_group *g; + rp_window_elem *elem; + struct sbuf *msgbuf; frame = current_frame(); - width = defaults.bar_x_padding * 2 + XmbTextEscapement (defaults.font, msg, strlen (msg)); + win = current_window (); + g = groups_find_group_by_window (win); + elem = group_find_window (&g->mapped_windows, win); + msgbuf = sbuf_new (0); + + format_string (msg, elem, msgbuf); + + width = defaults.bar_x_padding * 2 + XmbTextEscapement (defaults.font, msgbuf->data, + msgbuf->len); height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2); /* We don't want another frame indicator to be displayed on another @@ -993,7 +1005,9 @@ show_frame_message (char *msg) XmbDrawString (dpy, s->frame_window, defaults.font, s->normal_gc, defaults.bar_x_padding, defaults.bar_y_padding + rp_font_ascent, - msg, strlen (msg)); + msgbuf->data, msgbuf->len); + + sbuf_free (msgbuf); } rp_frame * |