summaryrefslogtreecommitdiff
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
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".
-rw-r--r--ChangeLog17
-rw-r--r--NEWS6
-rw-r--r--src/actions.c32
-rw-r--r--src/actions.h2
-rw-r--r--src/bar.c26
-rw-r--r--src/bar.h1
6 files changed, 84 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 050c097..4f485c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2001-09-18 shawn <sabetts@diggin.lamenet.tmp>
+
+ * 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".
+
2001-09-17 shawn <sabetts@diggin.lamenet.tmp>
* src/actions.h (cmd_unsetenv): new prototype
diff --git a/NEWS b/NEWS
index 6434a8e..b2863c3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
ratpoison NEWS --- history of user-visible changes. -*- outline -*-
* Changes since 1.0.0
+** New command lastmsg
+Display the last message.
+
+** New command info
+display information about the current window.
+
** New command unsetenv
Remove an environment variable from...well...the environment.
diff --git a/src/actions.c b/src/actions.c
index 5bf33ea..7bb7c57 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -68,6 +68,8 @@ static user_command user_commands[] =
{"setenv", cmd_setenv, arg_STRING},
{"chdir", cmd_chdir, arg_STRING},
{"unsetenv", cmd_unsetenv, arg_STRING},
+ {"info", cmd_info, arg_VOID},
+ {"lastmsg", cmd_lastmsg, arg_VOID},
/* Commands to set default behavior. */
{"defbarloc", cmd_defbarloc, arg_STRING},
@@ -228,10 +230,14 @@ initialize_default_keybindings (void)
add_keybinding (XK_colon, 0, "colon");
add_keybinding (XK_exclam, 0, "exec");
add_keybinding (XK_exclam, ControlMask, "colon exec " TERM_PROG " -e ");
+ add_keybinding (XK_i, 0, "info");
+ add_keybinding (XK_i, ControlMask, "info");
add_keybinding (XK_k, 0, "delete");
add_keybinding (XK_k, ControlMask, "delete");
add_keybinding (XK_l, 0, "redisplay");
add_keybinding (XK_l, ControlMask, "redisplay");
+ add_keybinding (XK_m, 0, "lastmsg");
+ add_keybinding (XK_m, ControlMask, "lastmsg");
add_keybinding (XK_n, 0, "next");
add_keybinding (XK_n, ControlMask, "next");
add_keybinding (XK_p, 0, "prev");
@@ -1839,3 +1845,29 @@ cmd_unsetenv (int interactive, void *data)
return NULL;
}
+
+char *
+cmd_info (int interactive, void *data)
+{
+ if (current_window() == NULL)
+ {
+ marked_message_printf (0, 0, " (%d, %d) No window ",
+ current_screen()->root_attr.width,
+ current_screen()->root_attr.height);
+ }
+ else
+ {
+ rp_window *win = current_window();
+ marked_message_printf (0, 0, " (%d,%d) %d(%s) ", win->width, win->height,
+ win->number, window_name (win));
+ }
+
+ return NULL;
+}
+
+char *
+cmd_lastmsg (int interactive, void *data)
+{
+ show_last_message();
+ return NULL;
+}
diff --git a/src/actions.h b/src/actions.h
index c73fdba..d64cf87 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -93,6 +93,8 @@ char * cmd_defbgcolor (int interactive, void *data);
char * cmd_setenv (int interactive, void *data);
char * cmd_chdir (int interactive, void *data);
char * cmd_unsetenv (int interactive, void *data);
+char * cmd_info (int interactive, void *data);
+char * cmd_lastmsg (int interactive, void *data);
/* void cmd_xterm (void *data); */
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);
}
diff --git a/src/bar.h b/src/bar.h
index 96733eb..d2b7dc6 100644
--- a/src/bar.h
+++ b/src/bar.h
@@ -31,5 +31,6 @@ int bar_x (screen_info *s, int width);
#define message(msg) marked_message (msg, 0, 0)
void marked_message (char *msg, int hl_start, int hl_end);
void marked_message_printf (int mark_start, int mark_end, char *fmt, ...);
+void show_last_message ();
#endif /* ! _RATPOISON_BAR_H */