Index | Thread | Search

From:
Lucas Gabriel Vuotto <lucas@sexy.is>
Subject:
Re: ksh: standout mode for horizontal scrolling indicators
To:
tech@openbsd.org
Date:
Mon, 30 Dec 2024 23:14:24 +0000

Download raw body.

Thread
On Mon, Dec 30, 2024 at 07:29:58PM +0000, Lucas Gabriel Vuotto wrote:
> Hi tech@,
> 
> I got slightly confused by a scrolling indicator that made me believe it
> was a file redirection. Given that ksh already uses curses on !SMALL
> builds, printing the indicator with standout enabled is easy. Tested
> both on the glass console and xterm.
> 
> Opinions?

Updated below; I missed a couple of preconditions in the ifs and added
some error handling to the first tputs.


diff /usr/src
path + /usr/src
commit - a556b9dbc0d568f20ed9322450b6206ba70d8a13
blob - 3c9b0074d81289a9638b0009a182ce139b8a497e
file + bin/ksh/emacs.c
--- bin/ksh/emacs.c
+++ bin/ksh/emacs.c
@@ -1081,7 +1081,19 @@ x_redraw(int limit)
 				i = '>';
 		} else if (xbp > xbuf)
 			i = '<';
-		x_e_putc(i);
+#ifndef SMALL
+		if (i != ' ' && cur_term && enter_standout_mode &&
+		    exit_standout_mode) {
+			int rmso = 0;
+
+			if (tputs(enter_standout_mode, 1, x_putc) != ERR)
+				rmso = 1;
+			x_e_putc(i);
+			if (rmso)
+				(void)tputs(exit_standout_mode, 1, x_putc);
+		} else
+#endif
+			x_e_putc(i);
 		j++;
 		while (j--)
 			x_e_putc('\b');
commit - a556b9dbc0d568f20ed9322450b6206ba70d8a13
blob - cdda9cb24b1a4a395547e081ff3adca380d3b6c1
file + bin/ksh/vi.c
--- bin/ksh/vi.c
+++ bin/ksh/vi.c
@@ -1962,7 +1962,19 @@ display(char *wb1, char *wb2, int leftside)
 		mc = ' ';
 	if (mc != morec) {
 		ed_mov_opt(pwidth + winwidth + 1, wb1);
-		x_putc(mc);
+#ifndef SMALL
+		if (mc != ' ' && cur_term && enter_standout_mode &&
+		    exit_standout_mode) {
+			int rmso = 0;
+
+			if (tputs(enter_standout_mode, 1, x_putc) != ERR)
+				rmso = 1;
+			x_putc(mc);
+			if (rmso)
+				(void)tputs(exit_standout_mode, 1, x_putc);
+		} else
+#endif
+			x_putc(mc);
 		cur_col++;
 		morec = mc;
 		lastb = -1;