Re: [hackers] [dvtm] Command keys in status bar patch

2015-10-07 Thread Marc André Tanner
On Fri, Oct 02, 2015 at 01:38:14PM -0400, Ross Mohn wrote:
> The attached patch is to display command keypresses in the status bar
> while a multiple keypress command is being entered. Almost all commands
> in dvtm begin with MOD, so require multiple keypresses. Command keys are
> displayed as they are pressed, and appear between the layout symbol and
> the status text. The keys are cleared from the status bar after the
> final key of a command is pressed, or if the key combination is not
> bound to a command. For example, if your MOD is set to ^G and you are
> toggling the view of tag 4, it first displays '^g' after you press MOD,
> then '^gV' after you press 'V', and then is cleared after you complete
> the command by pressing '4'. Please review.

Thanks, I will try it out and see whether I like it. Otherwise we could
also add it to the patches section. 

I would place curly braces around the while block. Also maybe drawbar
should reposition the cursor in the selected window (yes the (re)drawing
code is a bit of a mess).

-- 
 Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0



Re: [hackers] [dvtm] Command keys in status bar patch

2015-10-02 Thread Greg Reagle

I like it.  I haven't reviewed the code, but I compiled it and am using it.

--
"No data yet," he answered.  "It is a capital mistake to theorize before you 
have all the evidence.  It biases the judgement."

by Arthur Conan Doyle via his character Sherlock Holmes



[hackers] [dvtm] Command keys in status bar patch

2015-10-02 Thread Ross Mohn
The attached patch is to display command keypresses in the status bar
while a multiple keypress command is being entered. Almost all commands
in dvtm begin with MOD, so require multiple keypresses. Command keys are
displayed as they are pressed, and appear between the layout symbol and
the status text. The keys are cleared from the status bar after the
final key of a command is pressed, or if the key combination is not
bound to a command. For example, if your MOD is set to ^G and you are
toggling the view of tag 4, it first displays '^g' after you press MOD,
then '^gV' after you press 'V', and then is cleared after you complete
the command by pressing '4'. Please review.

Thanks -Ross

diff --git a/dvtm.c b/dvtm.c
index e337061..42809ad 100644
--- a/dvtm.c
+++ b/dvtm.c
@@ -220,6 +220,7 @@ extern Screen screen;
 static unsigned int waw, wah, wax, way;
 static Client *clients = NULL;
 static char *title;
+static KeyCombo keys;
 
 #include "config.h"
 
@@ -345,6 +346,15 @@ drawbar(void) {
 	attrset(TAG_NORMAL);
 	addstr(layout->symbol);
 
+	if(keys) {
+		unsigned int keycount = 0;
+		while (keycount < MAX_KEYS && keys[keycount])
+			if (keys[keycount] < ' ')
+printw("^%c", 'a' - 1 + keys[keycount++]);
+			else
+printw("%c", keys[keycount++]);
+	}
+
 	getyx(stdscr, y, x);
 	(void)y;
 	int maxwidth = screen.w - x - 2;
@@ -1710,7 +1720,6 @@ parse_args(int argc, char *argv[]) {
 
 int
 main(int argc, char *argv[]) {
-	KeyCombo keys;
 	unsigned int key_index = 0;
 	memset(keys, 0, sizeof(keys));
 	sigset_t emptyset, blockset;
@@ -1797,6 +1806,9 @@ main(int argc, char *argv[]) {
 	memset(keys, 0, sizeof(keys));
 	keypress(code);
 }
+drawbar();
+if (is_content_visible(sel))
+	wnoutrefresh(sel->window);
 			}
 			if (r == 1) /* no data available on pty's */
 continue;