diff -r -u ratpoison/src/actions.c ratpoison-aliasshow/src/actions.c --- ratpoison/src/actions.c Fri Feb 8 03:46:00 2002 +++ ratpoison-aliasshow/src/actions.c Sat Feb 9 00:04:30 2002 @@ -127,6 +127,95 @@ static int alias_list_size; static int alias_list_last; +void +show_aliases () +{ + screen_info *s = current_screen(); + XEvent ev; + Window fwin; /* Window currently in focus */ + int revert; + int i, old_i; + int x = 10; + int y = 0; + int max_width = 0; + int drawing_aliases = 1; /* 1 if we are drawing alias names 0 if we are drawing complete commands */ + + 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 + defaults.font->max_bounds.ascent, + "ratpoison command aliases", strlen ("ratpoison command aliases")); + + y += FONT_HEIGHT (defaults.font) * 2; + + i = 0; + old_i = 0; + while (ihelp_window, s->normal_gc, + x, y + defaults.font->max_bounds.ascent, + alias_list[i].name, strlen (alias_list[i].name)); + + if (XTextWidth (defaults.font, alias_list[i].name, strlen (alias_list[i].name)) > max_width) + max_width = XTextWidth (defaults.font, alias_list[i].name, strlen (alias_list[i].name)); + } + else + { + XDrawString (dpy, s->help_window, s->normal_gc, + x, y + defaults.font->max_bounds.ascent, + alias_list[i].alias, strlen (alias_list[i].alias)); + + if (XTextWidth (defaults.font, alias_list[i].alias, strlen (alias_list[i].alias)) > max_width) + { + max_width = XTextWidth (defaults.font, alias_list[i].alias, strlen (alias_list[i].alias)); + } + } + + y += FONT_HEIGHT (defaults.font); + if (y > s->root_attr.height) + { + if (drawing_aliases) + { + x += max_width + 10; + drawing_aliases = 0; + i = old_i; + } + else + { + x += max_width + 20; + drawing_aliases = 1; + old_i = i; + } + + max_width = 0; + y = FONT_HEIGHT (defaults.font) * 2; + } + else + { + i++; + if (i >= alias_list_last && drawing_aliases) + { + x += max_width + 10; + drawing_aliases = 0; + y = FONT_HEIGHT (defaults.font) * 2; + i = old_i; + max_width = 0; + } + } + } + + XMaskEvent (dpy, KeyPressMask, &ev); + XUnmapWindow (dpy, s->help_window); + XSetInputFocus (dpy, fwin, revert, CurrentTime); + + return; +} + rp_action* find_keybinding_by_action (char *action) { @@ -2386,7 +2475,7 @@ if (data == NULL) { - message (" alias: At least one argument required "); + show_aliases(); return NULL; }