Troubleshooters.Com®, Linux Library and Steve's ctwm Secret Stash Present:
Incorporating dmenu in ctwm
Copyright © 2017 by Steve Litt
See the Troubleshooters.Com Bookstore.
Contents:
You can skip this page if you're a 100% mouse kinda guy: This patch is only about keyboarding.
You can skip this page if you're willing to use ctwm's different but internally consistent menu keyboard interface, as described in the Ctwm Menu Unexpected Behavior document.
Please understand that the patch described in this document is a workaround, and in fact is a kludge, complete with so-far unknown side effects.
If, after reading the preceding three paragraphs, you still want the Enter key to behave in ctwm menus the way it does in other menus, you can install this patch. Keep in mind, I installed it, and later backed it out, preferring to deal with a stock ctwm executable.
Once again, what this patch does is make the Enter key show submenus on both submenus without defaults, and submenus with defaults. If you really want to run the default, it's still available among the choices of the submenu.
After a bunch of grep commands and some experimentation, it became obvious that one place to control ctwm's relationship between key pressed and menu navigation was in the event_handlers.c file. I was able to tweak event_handler.c's function HandleKeyPress's section pertaining to menus so I could navigate a ctwm menu with Vim-like j,k,h and l keys to go down, up, left and right respectively. The l key even did the right thing and executed the choice whether the choice executed a command or displayed a submenu. Cool!
And wrong. having the l key actually invoke a command would be as unexpected as Enter escaping the menu. Also, you don't take somebody else's software and vastly modify it's user interface like that. I backed out the Vim like menu keys, and put in a change that let the Enter key display submenus. However...
My change strongarmed an if statement to always be true. That if statement must have, at one time or another, had a reason for being there. So I hadn't fixed it, I'd worked around it by disabling the if statement, and whatever purpose that if statement had will no longer work. That non-working purpose is the side effect of my workaround.
I tested for several hours and couldn't find a side effect caused by my change. However, speaking to the ctwm maintainer, I found out that my patch causes malfunction of two esoteric features:
What I did was simple. I changed the following line:
if(!strcmp(keynam, "Return")) {
to the following:
if(!strcmp(keynam, "Return_prevent")) {
Because there's no keyboard key with the name "Return_prevent", the if statement will always be true.
I've created a patch file to enable you to make this change on your ctwm 4.0.1
event_handler.c. Just place event_handlers.patch.txt in the same directory as your event_handler.c, and run the following command:
patch -u event_handlers.c event_handlers.patch.txt
After doing that, make and make install as usual, and your ctwm will have keyboarder friendly menus.
[ Training | Troubleshooters.Com | Email Steve Litt ]