summaryrefslogtreecommitdiff
path: root/src/actions.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-04-15 19:56:15 +0000
committersabetts <sabetts>2001-04-15 19:56:15 +0000
commitac84e85590a5a32c9db3979a4c05475e10d97a79 (patch)
tree6d2931bdabaa25260b8ee5c8430cd754283cf7e1 /src/actions.c
parent58214c0d8b72ade928ce491da191af70d789e83b (diff)
downloadratpoison-ac84e85590a5a32c9db3979a4c05475e10d97a79.zip
* src/messages.h (MESSAGE_WELCOME): new define
* src/manage.c (scanwins): ignore the help window (hide_window): increment window's iconizing variable * src/main.c (main): display welcoming message (init_screen): create the help window (init_screen): don't map the frame indicator window (clean_up): destroy the help window * src/list.c (add_to_window_list): initialize iconizing to 0 * src/events.c (new_window): skip help_window (unmap_notify): skip normal processing if the event is from iconizing the window. (unmap_notify): clean up the window's frame if it is being withdrawn. * src/data.h (struct screen_info): new variable help_window * src/bar.c (update_window_names): only print the window list if the bar is already displaying the window list. * src/actions.h (cmd_help): new prototype (cmd_quit): likewise * src/actions.c (initialize_default_keybindings): new keybinding for "help" (cmd_quit): new function (cmd_help): likewise
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c91
1 files changed, 82 insertions, 9 deletions
diff --git a/src/actions.c b/src/actions.c
index e77f632..1968ae7 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -134,6 +134,7 @@ initialize_default_keybindings (void)
add_keybinding (XK_R, 0, "remove");
add_keybinding (XK_f, 0, "curframe");
add_keybinding (XK_f, ControlMask, "curframe");
+ add_keybinding (XK_question, 0, "help");
}
user_command user_commands[] =
@@ -165,6 +166,8 @@ user_command user_commands[] =
{"remove", cmd_remove, arg_VOID},
{"banish", cmd_banish, arg_VOID},
{"curframe", cmd_curframe, arg_VOID},
+ {"help", cmd_help, arg_VOID},
+ {"quit", cmd_quit, arg_VOID},
/* the following screen commands may or may not be able to be
implemented. See the screen documentation for what should be
@@ -173,7 +176,6 @@ user_command user_commands[] =
{"stuff", cmd_unimplemented, arg_VOID},
{"number", cmd_unimplemented, arg_VOID},
{"hardcopy", cmd_unimplemented, arg_VOID},
- {"help", cmd_unimplemented, arg_VOID},
{"lastmsg", cmd_unimplemented, arg_VOID},
{"license", cmd_unimplemented, arg_VOID},
{"lockscreen", cmd_unimplemented, arg_VOID},
@@ -181,7 +183,6 @@ user_command user_commands[] =
{"msgwait", cmd_unimplemented, arg_VOID},
{"msgminwait", cmd_unimplemented, arg_VOID},
{"nethack", cmd_unimplemented, arg_VOID},
- {"quit", cmd_unimplemented, arg_VOID},
{"redisplay", cmd_unimplemented, arg_VOID},
{"screen", cmd_unimplemented, arg_VOID},
{"setenv", cmd_unimplemented, arg_VOID},
@@ -691,13 +692,13 @@ cmd_newwm(void *data)
/* Quit ratpoison. Thanks to
"Chr. v. Stuckrad" <stucki@math.fu-berlin.de> for the patch. */
-/* static void */
-/* bye(void *dummy) */
-/* { */
-/* PRINT_DEBUG ("Exiting\n"); */
-/* clean_up (); */
-/* exit (EXIT_SUCCESS); */
-/* } */
+void
+cmd_quit(void *data)
+{
+ PRINT_DEBUG ("Exiting\n");
+ clean_up ();
+ exit (EXIT_SUCCESS);
+}
/* Show the current time on the bar. Thanks to Martin Samuelsson
<cosis@lysator.liu.se> for the patch. Thanks to Jonathan Walther
@@ -866,3 +867,75 @@ cmd_curframe (void *data)
{
show_frame_indicator();
}
+
+void
+cmd_help (void *data)
+{
+ screen_info *s = current_screen();
+ XEvent ev;
+ Window fwin; /* Window currently in focus */
+ int revert;
+ int i;
+ int x = 10;
+ int y = 0;
+ int max_width = 0;
+ char *keysym_name;
+
+ XMapRaised (dpy, s->help_window);
+
+ XGetInputFocus (dpy, &fwin, &revert);
+ XSetInputFocus (dpy, s->help_window, RevertToPointerRoot, CurrentTime);
+
+ XDrawString (dpy, s->help_window, s->normal_gc,
+ 10, y + s->font->max_bounds.ascent,
+ "ratpoison key bindings", strlen ("ratpoison key bindings"));
+
+ y += FONT_HEIGHT (s->font) * 2;
+
+ XDrawString (dpy, s->help_window, s->normal_gc,
+ 10, y + s->font->max_bounds.ascent,
+ "Command key: ", strlen ("Command key: "));
+
+ keysym_name = keysym_to_string (prefix_key.sym, prefix_key.state);
+ XDrawString (dpy, s->help_window, s->normal_gc,
+ 10 + XTextWidth (s->font, "Command key: ", strlen ("Command key: ")),
+ y + s->font->max_bounds.ascent,
+ keysym_name, strlen (keysym_name));
+ free (keysym_name);
+
+ y += FONT_HEIGHT (s->font) * 2;
+
+ for (i=0; i<key_actions_last; i++)
+ {
+ keysym_name = keysym_to_string (key_actions[i].key, key_actions[i].state);
+
+ XDrawString (dpy, s->help_window, s->normal_gc,
+ x, y + s->font->max_bounds.ascent,
+ keysym_name, strlen (keysym_name));
+
+ if (XTextWidth (s->font, key_actions[i].data, strlen (key_actions[i].data))
+ + XTextWidth (s->font, keysym_name, strlen (keysym_name)) > max_width)
+ {
+ max_width = XTextWidth (s->font, key_actions[i].data, strlen (key_actions[i].data))
+ + XTextWidth (s->font, keysym_name, strlen (keysym_name));
+ }
+
+ XDrawString (dpy, s->help_window, s->normal_gc,
+ x + 90, y + s->font->max_bounds.ascent,
+ key_actions[i].data, strlen (key_actions[i].data));
+
+ free (keysym_name);
+
+ y += FONT_HEIGHT (s->font);
+ if (y > s->root_attr.height)
+ {
+ x += max_width + 10 + 90;
+ y = FONT_HEIGHT (s->font) * 4;
+ max_width = 0;
+ }
+ }
+
+ XMaskEvent (dpy, KeyPressMask, &ev);
+ XUnmapWindow (dpy, s->help_window);
+ XSetInputFocus (dpy, fwin, revert, CurrentTime);
+}