summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-10-18 22:47:45 +0000
committersabetts <sabetts>2001-10-18 22:47:45 +0000
commit89c4411a9cc3bdb756cff8746f4333df610ab455 (patch)
treecdf25ccc98325d272c8d8f6ccd477c43833f24d6
parent0b7d45f2a5590f332f7528b7455b82513f28b9dc (diff)
downloadratpoison-89c4411a9cc3bdb756cff8746f4333df610ab455.zip
* src/split.c (show_frame_indicator): call XSync after clearing the window.
* src/input.c (get_more_input): clear the window after it is raised. Call XSync aftwards. * src/conf.h (MAX_LINK_DEPTH): new define * src/bar.c (marked_message): clear the window after it is raised. Call XSync aftwards. * src/actions.h (cmd_link): new prototype * src/actions.c (user_command): new command 'link' (find_command_by_keydesc): new function (resolve_command_from_keydesc): likewise (cmd_link): likewise
-rw-r--r--ChangeLog17
-rw-r--r--NEWS4
-rw-r--r--doc/ratpoison.texi5
-rw-r--r--src/actions.c60
-rw-r--r--src/actions.h1
-rw-r--r--src/bar.c8
-rw-r--r--src/conf.h3
-rw-r--r--src/input.c4
-rw-r--r--src/split.c3
9 files changed, 96 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 56d1649..65b5670 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2001-10-18 shawn <sabetts@vcn.bc.ca>
+ * src/split.c (show_frame_indicator): call XSync after clearing the window.
+
+ * src/input.c (get_more_input): clear the window after it is
+ raised. Call XSync aftwards.
+
+ * src/conf.h (MAX_LINK_DEPTH): new define
+
+ * src/bar.c (marked_message): clear the window after it is
+ raised. Call XSync aftwards.
+
+ * src/actions.h (cmd_link): new prototype
+
+ * src/actions.c (user_command): new command 'link'
+ (find_command_by_keydesc): new function
+ (resolve_command_from_keydesc): likewise
+ (cmd_link): likewise
+
* src/split.h (find_last_frame): new prototype
* src/split.c (update_last_access): new function
diff --git a/NEWS b/NEWS
index bf02ee9..b7ec283 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,10 @@
ratpoison NEWS --- history of user-visible changes. -*- outline -*-
* Changes since 1.0.0
+** new command "link"
+Call the command that a keybinding is bound to. for instance, 'link
+C-t' would call the command 'other'.
+
** new command "focuslast"
Switch between the current frame and the last focused frame. It is
bound to C-t M-Tab.
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index 2b3efbe..94c8dac 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -491,6 +491,11 @@ misbehaving window this command should do the trick. Also available as
@item lastmsg
Display the last message.
+@item link @var{key}
+Call the command that @var{key} is bound to. For instance
+@command{link C-t} would call the command @command{other} and switch
+to the last window.
+
@item redisplay
Redisplay the current window, just like @kbd{C-t l} would do.
diff --git a/src/actions.c b/src/actions.c
index 3f10ffe..0efc8c3 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -77,6 +77,7 @@ static user_command user_commands[] =
{"lastmsg", cmd_lastmsg, arg_VOID},
{"restart", cmd_restart, arg_VOID},
{"startup_message", cmd_startup_message, arg_STRING},
+ {"link", cmd_link, arg_STRING},
/* Commands to set default behavior. */
{"defbarloc", cmd_defbarloc, arg_STRING},
@@ -139,6 +140,46 @@ find_keybinding (KeySym keysym, int state)
return NULL;
}
+static char *
+find_command_by_keydesc (char *desc)
+{
+ int i = 0;
+ char *keysym_name;
+
+ while (i < key_actions_last)
+ {
+ keysym_name = keysym_to_string (key_actions[i].key, key_actions[i].state);
+ if (!strcmp (keysym_name, desc))
+ {
+ free (keysym_name);
+ return key_actions[i].data;
+ }
+ free (keysym_name);
+ i++;
+ }
+
+ return NULL;
+}
+
+static char *
+resolve_command_from_keydesc (char *desc, int depth)
+{
+ char *cmd, *command;
+
+ command = find_command_by_keydesc (desc);
+ if (!command)
+ return NULL;
+
+ /* is it a link? */
+ if (strncmp (command, "link", 4) || depth > MAX_LINK_DEPTH)
+ /* it is not */
+ return command;
+
+ cmd = resolve_command_from_keydesc (&command[5], depth + 1);
+ return (cmd != NULL) ? cmd : command;
+}
+
+
static void
add_keybinding (KeySym keysym, int state, char *cmd)
{
@@ -1227,9 +1268,7 @@ cmd_help (int interactive, void *data)
keysym_name, strlen (keysym_name));
if (XTextWidth (defaults.font, keysym_name, strlen (keysym_name)) > max_width)
- {
- max_width = XTextWidth (defaults.font, keysym_name, strlen (keysym_name));
- }
+ max_width = XTextWidth (defaults.font, keysym_name, strlen (keysym_name));
free (keysym_name);
}
@@ -1938,3 +1977,18 @@ cmd_focuslast (int interactive, void *data)
return NULL;
}
+
+char *
+cmd_link (int interactive, void *data)
+{
+ char *cmd = NULL;
+
+ if (!data)
+ return NULL;
+
+ cmd = resolve_command_from_keydesc ((char *)data, 0);
+ if (cmd)
+ return command (interactive, cmd);
+
+ return NULL;
+}
diff --git a/src/actions.h b/src/actions.h
index c675374..04175e8 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -102,6 +102,7 @@ char * cmd_focusright (int interactive, void *data);
char * cmd_restart (int interactive, void *data);
char * cmd_startup_message (int interactive, void *data);
char * cmd_focuslast (int interactive, void *data);
+char * cmd_link (int interactive, void *data);
/* void cmd_xterm (void *data); */
diff --git a/src/bar.c b/src/bar.c
index fc7e8c2..8e34d25 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -186,15 +186,15 @@ marked_message (char *msg, int mark_start, int mark_end)
width,
height);
- XClearWindow (dpy, s->bar_window);
XRaiseWindow (dpy, s->bar_window);
-
+ XClearWindow (dpy, s->bar_window);
+ XSync (dpy, False);
XDrawString (dpy, s->bar_window, s->normal_gc,
defaults.bar_x_padding,
defaults.bar_y_padding + defaults.font->max_bounds.ascent,
msg, strlen (msg));
-
-
+ XSync (dpy, False);
+
/* Crop to boundary conditions. */
if (mark_start < 0)
mark_start = 0;
diff --git a/src/conf.h b/src/conf.h
index d8eeed7..47e2289 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -47,4 +47,7 @@
mostly for use with hand-helds. */
#define UNMANAGED_WINDOW_LIST "xapm","xclock","xscribble"
+/* Maximum depth of a link. Used in the 'link' command. */
+#define MAX_LINK_DEPTH 16
+
#endif /* !_ _RATPOISON_CONF_H */
diff --git a/src/input.c b/src/input.c
index cf8e833..9c6c14b 100644
--- a/src/input.c
+++ b/src/input.c
@@ -281,6 +281,7 @@ update_input_window (screen_info *s, char *prompt, char *input, int input_len)
(FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2));
XClearWindow (dpy, s->input_window);
+ XSync (dpy, False);
XDrawString (dpy, s->input_window, s->normal_gc,
defaults.bar_x_padding,
@@ -333,8 +334,9 @@ get_more_input (char *prompt, char *preinput)
hide_bar (s);
XMapWindow (dpy, s->input_window);
- XClearWindow (dpy, s->input_window);
XRaiseWindow (dpy, s->input_window);
+ XClearWindow (dpy, s->input_window);
+ XSync (dpy, False);
update_input_window (s, prompt, str, cur_len);
diff --git a/src/split.c b/src/split.c
index 2090b53..f63412d 100644
--- a/src/split.c
+++ b/src/split.c
@@ -630,8 +630,9 @@ show_frame_indicator ()
width, height);
XMapRaised (dpy, current_screen()->frame_window);
-
XClearWindow (dpy, s->frame_window);
+ XSync (dpy, False);
+
XDrawString (dpy, s->frame_window, s->normal_gc,
defaults.bar_x_padding,
defaults.bar_y_padding + defaults.font->max_bounds.ascent,