"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
tog: echo numeric prefix of compound key maps
To:
gameoftrees@openbsd.org
Date:
Mon, 27 Jun 2022 00:03:22 +1000

Download raw body.

Thread
Similar to less(1), echo the numbers at the bottom of the screen as they
are typed when entering a compound key map (e.g., 123j).

diff 3d589bee0bbbe812bb91f3b0284fbf2596304132 /home/mark/src/git/got-current
blob - e63f4a7c65678ce2cdbd63fb24abb940c2551358
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -896,12 +896,19 @@ view_search_start(struct tog_view *view)
 static int
 get_compound_key(struct tog_view *view, int c)
 {
-	int n = 0;
+	int x, n = 0;

 	view->count = 0;
 	halfdelay(5);  /* block for half a second */
+	wattron(view->window, A_BOLD);
+	wmove(view->window, view->nlines - 1, 0);
+	wclrtoeol(view->window);
+	waddch(view->window, ':');

 	do {
+		x = getcurx(view->window);
+		if (x != ERR && x < view->ncols)
+			waddch(view->window, c);
 		/*
 		 * Don't overflow. Max valid request should be the greatest
 		 * between the longest and total lines; cap at 10 million.
@@ -915,6 +922,7 @@ get_compound_key(struct tog_view *view, int c)
 	/* Massage excessive or inapplicable values at the input handler. */
 	view->count = n;

+	wattroff(view->window, A_BOLD);
 	cbreak();  /* return to blocking */
 	return c;
 }

-- 
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68