On Sun, Feb 08, 2009 at 02:44:15AM +0000, Thomas Adam wrote: > Hello all, > > Something I've seen an increase of lately, on the fvwm list and > particularly on IRC and the forums, is the question of: "What are the > default mouse/key bindings of fvwm"? To which the answer varies, > since invariably the question is: "Can I list all my bindings fvwm > knows about?" > > Well, with the attached patch, you can. I've added it to PrintInfo, > since it really is only useful in certain circumstances. > > Dominik: I've deliberately not restructured this patch to sit on top > of the InitialMapCommand patches -- so if you consider applying this > patch along with that one, you might get some conflicts in NEWS, > AUTHORS and Changelog. Hopefully shouldn't be a problem though.
That's no problem. > Comment/suggestions welcome as always. See below. > Index: AUTHORS > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/AUTHORS,v > retrieving revision 1.130 > diff -u -r1.130 AUTHORS > --- AUTHORS 19 Oct 2008 12:04:12 -0000 1.130 > +++ AUTHORS 8 Feb 2009 02:27:54 -0000 > @@ -15,6 +15,7 @@ > StartShaded style option. > Introduce the command expansion placeholder: $[w.visiblename] > Make style matching honour a window's visible name (c.f. $[w.visiblename]) > +Added "bindings" option to PrintInfo command useful for debugging. > > Serge (gentoosiast) Koksharov: > Documentation fixes, bug fixes. > Index: ChangeLog > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v > retrieving revision 1.3061 > diff -u -r1.3061 ChangeLog > --- ChangeLog 30 Dec 2008 13:32:40 -0000 1.3061 > +++ ChangeLog 8 Feb 2009 02:28:04 -0000 > @@ -1,3 +1,16 @@ > +2009-02-05 Thomas Adam <thomas.ada...@gmail.com> > + * libs/charmap.c (charmap_table_to_string): > + * libs/charmap.h: > + Introduce charmap_to_string function which is used to build up a > + binding string, for use with PrintInfo. > + > + * fvwm/bindings.c (print_bindings): > + Introduce print_bindings to print all bindings known to fvwm. > + > + * fvwm/builtins.c (CMD_PrintInfo): > + * fvwm/builtins.h: > + Add support for "binding" as an option to PrintInfo. > + > 2008-12-29 Alexandre Julliard <julli...@winehq.org> > > * fvwm/ewmh_events.c (ewmh_WMStateMaxHoriz): > Index: NEWS > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/NEWS,v > retrieving revision 1.767 > diff -u -r1.767 NEWS > --- NEWS 30 Dec 2008 13:32:40 -0000 1.767 > +++ NEWS 8 Feb 2009 02:28:05 -0000 > @@ -18,6 +18,9 @@ > ... is now honoured. Useful with IndexedWindowName as a style > option. > > + - New option to PrintInfo, "bindings" which prints out all of the Key, > + PointerKey, Mouse and Stroke bindings which fvwm knows about. > + > * Bug fixes: > > - Fixed compilation without XRender support. > Index: doc/commands/PrintInfo.xml > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/doc/commands/PrintInfo.xml,v > retrieving revision 1.4 > diff -u -r1.4 PrintInfo.xml > --- doc/commands/PrintInfo.xml 16 Jun 2007 12:38:46 -0000 1.4 > +++ doc/commands/PrintInfo.xml 8 Feb 2009 02:28:05 -0000 > @@ -57,4 +57,10 @@ > <replaceable>verbose</replaceable> > can be 1.</para> > > +<para><fvwmopt cms="PrintInfo" opt="bindings"/> > +which prints information on all the bindings fvwm has: key, mouse and > +stroke bindings. > +<replaceable>verbose</replaceable> > +has no effect with this option.</para> > + > </section> > Index: fvwm/bindings.c > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/fvwm/bindings.c,v > retrieving revision 1.103 > diff -u -r1.103 bindings.c > --- fvwm/bindings.c 23 Nov 2007 08:49:11 -0000 1.103 > +++ fvwm/bindings.c 8 Feb 2009 02:28:10 -0000 > @@ -639,6 +639,60 @@ > return; > } > > +void print_bindings(int verbose) If the verbose flag has no effect, why is it an argument to the function? > +{ > + Binding *b; > + > + fprintf(stderr, "Current list of bindings:\n\n"); > + > + for (b = Scr.AllBindings; b != NULL; b = b->NextBinding) > + { > + /* Key, PointerKey, Mouse, Stroke. */ > + char *binding_type = NULL; > + char type[20]; > + switch (b->type) > + { > + case BIND_KEYPRESS: > + binding_type = "Key"; > + sprintf(type, "%s", b->key_name); > + break; > + case BIND_PKEYPRESS: > + binding_type = "PointerKey"; > + sprintf(type, "%s", b->key_name); > + break; > + case BIND_BUTTONPRESS: > + case BIND_BUTTONRELEASE: > + binding_type = "Mouse"; > + sprintf(type, "%d", b->Button_Key); > + break; > + case BIND_STROKE: > + binding_type = "Stroke"; > + sprintf(type, "%s\t%d", (char *)b->Stroke_Seq, > + b->Button_Key); I think we shouldn't copy arbitrary strings into a fixed length buffer. I'm sure there are key names that are longer than 19 characters. > + break; > + } > + > + char *mod_string = charmap_table_to_string( > + MaskUsedModifiers(b->Modifier),key_modifiers); > + char *context_string = charmap_table_to_string( > + b->Context, win_contexts); > + char win_name[260] = ""; Uh, I know we have hard coded some length limit to the window name, but that's just because there was or is a bug in the X system that caused a crash. > + > + if (b->windowName != NULL) > + sprintf(win_name, " (%s)", b->windowName); > + > + fprintf(stderr, "%s %s\t%s\t%s\t%s\t%s\n", > + binding_type, win_name, type, > + context_string, mod_string, > + (char *)b->Action); > + > + free (mod_string); > + free (context_string); > + } > + > + > +} > + > /* ---------------------------- interface functions ------------------------ > */ > > /* Removes all unused modifiers from in_modifiers */ > Index: fvwm/builtins.c > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/fvwm/builtins.c,v > retrieving revision 1.432 > diff -u -r1.432 builtins.c > --- fvwm/builtins.c 28 Nov 2008 23:29:27 -0000 1.432 > +++ fvwm/builtins.c 8 Feb 2009 02:28:12 -0000 > @@ -2700,6 +2700,10 @@ > { > PicturePrintImageCache(verbose); > } > + else if (StrEquals(subject, "Bindings")) > + { > + print_bindings(verbose); > + } > else > { > fvwm_msg(ERR, "PrintInfo", > Index: fvwm/builtins.h > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/fvwm/builtins.h,v > retrieving revision 1.22 > diff -u -r1.22 builtins.h > --- fvwm/builtins.h 29 Jun 2003 19:53:23 -0000 1.22 > +++ fvwm/builtins.h 8 Feb 2009 02:28:12 -0000 > @@ -10,5 +10,6 @@ > Bool ReadDecorFace(char *s, DecorFace *df, int button, int verbose); > void FreeDecorFace(Display *dpy, DecorFace *df); > void update_fvwm_colorset(int cset); > +void print_bindings(int verbose); > > #endif /* BUILTINS_H */ > Index: libs/charmap.c > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/libs/charmap.c,v > retrieving revision 1.2 > diff -u -r1.2 charmap.c > --- libs/charmap.c 2 Nov 2003 17:04:44 -0000 1.2 > +++ libs/charmap.c 8 Feb 2009 02:28:19 -0000 > @@ -19,8 +19,10 @@ > #include "config.h" > #include <stdio.h> > #include <ctype.h> > +#include <string.h> You can't rely on string.h being present. On some systems, it's callend strings.h. Luckily you don't have to take care of that yourself: config.h already includes the proper file, so you can just delete this line. > > #include "charmap.h" > +#include "safemalloc.h" Should be libs/safemalloc.h. Maybe I should remove libs from the include path. > /* ---------------------------- local definitions -------------------------- > */ > > @@ -102,3 +104,30 @@ > > return c; > } > + > +/* Used from "PrintInfo Bindings". */ > +char *charmap_table_to_string(int mask, charmap_t *table) > +{ > + char *allmods = safemalloc (sizeof(table)); > + memset (allmods, '\0', sizeof(table)); Are you sure you want to reserve sizeof(table) bytes? This would reserve space to store a pointer, not space to store a charmap_t. > + > + int modmask = mask; Please don't declare variables in the middle of a block. This does not compile with oplder compilers. > + > + for (; table->key !=0; table++) > + { > + char *c = safemalloc (sizeof(table->key)); > + memset (c, '\0', sizeof(c)); > + > + strcpy(c, (char *)&table->key); > + *c = toupper(*c); > + > + if (modmask & table->value) > + { > + modmask |= table->value; > + strcat(allmods, c); > + } > + modmask &= ~table->value; > + free(c); > + } > + return allmods; > +} > Index: libs/charmap.h > =================================================================== > RCS file: /home/cvs/fvwm/fvwm/libs/charmap.h,v > retrieving revision 1.1 > diff -u -r1.1 charmap.h > --- libs/charmap.h 5 Jul 2003 01:37:47 -0000 1.1 > +++ libs/charmap.h 8 Feb 2009 02:28:19 -0000 > @@ -27,4 +27,6 @@ > int *ret, const char *string, charmap_t *table, char *errstring); > char charmap_mask_to_char(int mask, charmap_t *table); > > +char *charmap_table_to_string(int mask, charmap_t *table); > + > #endif /* CHARMAP_H */ Ciao Dominik ^_^ ^_^ -- Dominik Vogt