First off, sorry for the bump, not that this forum is particularly loaded with new threads… And secondly, this post probably belongs in one of the scripting forums, but I didn’t want to break up the thread.
I’m new to FVWM, but the prospect of writing a control scheme styled after vi was one reason that I fetched it in the first place (although if I recall there’s a wm that offers that feature exclusively, and probably a little better than you can get it through FVWM without some hassles). This thread never really seemed to have been resolved, so I thought I should mention the easiest (and probably one of the better) ways to implement this rc.
The basic design is one of various self-contained, generic functions that represent possible states of the interface; the key hooks themselves specifying the state, and not some variable as theBlackDragon was pondering.
So, for your grokking pleasure, a few excerpts of my rc vi implementation (code-named castrati, for obvious reasons ).
First of all, an inital state should be set-up, much like the inital state of vi:
+ I Func_Clearkeys
+ I Key K A L Direction North (AcceptsFocus) Focus
+ I Key J A L Direction South (AcceptsFocus) Focus
+ I Key H A L Direction West (AcceptsFocus) Focus
+ I Key L A L Direction East (AcceptsFocus) Focus
+ I Key Escape A L Beep
+ I Key K A L -
+ I Key J A L -
+ I Key H A L -
+ I Key L A L -
Of course, just selecting windows with the H/J/K/L keys doesn’t make it a vi interface, does it? Of course not, so an expansion is an order. Here is where this design really shines, as expansions are fairly trivial (aside from Func_Clearkeys). Lets define a command to delete a window in a selected direction, somewhat like vi’s kill command, d. In order to do this, a new mode will have to be declared that uses Direction to perform a command based on the user’s input, and then we need to expose this mode with a new basicmode command:
+ I Func_Clearkeys
+ I Key K A L Func_Singleshot "Direction North $0"
+ I Key J A L Func_Singleshot "Direction South $0"
+ I Key H A L Func_Singleshot "Direction West $0"
+ I Key L A L Func_Singleshot "Direction East $0"
+ I Key $1 A L Func_Singleshot $0
+ I Key Escape A L Func_BasicMode
+ I $0
+ I Func_BasicMode
+ I Key D A L Func_DoThereMode Delete D
+ I Key D A L -
Of course, having only read the FVWM manpage yesterday, I’m sure there’s some shortcut I’m missing, and some optimizations; but I can’t imagine it being much more maintainable than that.
One final note from experience: xmodmap is definatly not the solution here, as you can fairly easily screw up the keymapping if you don’t take special care in handling its input and output, making your X session completely unusable.