summaryrefslogtreecommitdiff
path: root/src/bar.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-09-18 07:19:46 +0000
committersabetts <sabetts>2001-09-18 07:19:46 +0000
commit6f27c1d05acd301d7ce344d3177773b969b1ae65 (patch)
tree41dffa31721be37363fb57700c5b21fdbc592dd0 /src/bar.c
parent3417b6981960f0c8ca0a5bf18a75386a10fdc719 (diff)
downloadratpoison-6f27c1d05acd301d7ce344d3177773b969b1ae65.zip
* src/actions.h (cmd_info): new prototype
(cmd_lastmsg): likewise * src/bar.h (show_last_message): new prototype * src/bar.c: new static globals last_msg, lash_mark_start, and last_mark_end. (marked_message): Store the message in last_msg. (show_last_message): new function * src/actions.c (cmd_info): new function (cmd_lastmsg): likewise (user_commands): new commands "info" and "lastmsg" (initialize_default_keybindings): Add key bindings for "info" and "lastmsg".
Diffstat (limited to 'src/bar.c')
-rw-r--r--src/bar.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/bar.c b/src/bar.c
index dc51c37..c359919 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -39,6 +39,11 @@
#define BAR_IS_WINDOW_LIST 1
#define BAR_IS_MESSAGE 2
+/* A copy of the last message displayed in the message bar. */
+static char *last_msg = NULL;
+static int last_mark_start = 0;
+static int last_mark_end = 0;
+
/* Hide the bar from sight. */
int
hide_bar (screen_info *s)
@@ -221,4 +226,25 @@ marked_message (char *msg, int mark_start, int mark_end)
XFillRectangle (dpy, s->bar_window, lgc, start, 0, end, height);
}
+
+ /* Keep a record of the message. */
+ if (last_msg)
+ free (last_msg);
+ last_msg = xstrdup (msg);
+ last_mark_start = mark_start;
+ last_mark_end = mark_end;
+}
+
+void
+show_last_message ()
+{
+ char *msg;
+
+ /* A little kludge to avoid last_msg in marked_message from being
+ strdup'd right after freeing the pointer. Note: in this case
+ marked_message's msg arg would have been the same as
+ last_msg. */
+ msg = xstrdup (last_msg);
+ marked_message (msg, last_mark_start, last_mark_end);
+ free (msg);
}