ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RP] help showing unbound commands?


From: Martin Samuelsson
Subject: Re: [RP] help showing unbound commands?
Date: Wed Feb 20 04:38:05 2002
User-agent: Mutt/1.2.5i

On Sat, Feb 09, 2002 at 12:10:50AM +0100, Martin Samuelsson wrote:
> > It sounds like you just volunteered Martin :-)
> 
> you all know that i can not code...
> 
> but here's my try.
> 
> i guess the show_aliases function shouldn't be in actions.c, but i don't know
> where it's supposed to be.
>
> 
> would it be a good idea to make some kind of generic function for information
> display screens?

i got no feed back on this code?

did anyone look at it? was it buggy, bad written or do you consider 
completeness beeing bloat?
--
/martin

> 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 (i<alias_list_last || drawing_aliases)
> +    {
> +      if (drawing_aliases)
> +     {
> +       XDrawString (dpy, s->help_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;
>      }
>  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]