Index | Thread | Search

From:
"Ted Unangst" <tedu@tedunangst.com>
Subject:
Re: watch: tab + holizontal scroll
To:
"YASUOKA Masahiko" <yasuoka@openbsd.org>
Cc:
job@openbsd.org, tech@openbsd.org
Date:
Fri, 27 Jun 2025 13:35:46 -0400

Download raw body.

Thread
On 2025-06-27, Ted Unangst wrote:
> On 2025-06-27, YASUOKA Masahiko wrote:
> > Hi,
> > 
> > More care about TAB spaces seems to be needed for scrolling
> > horizontally.
> 
> This isn't quite right. I ran watch cat tabs.txt.

I think the fix is simple if we do it in child_input.

Does this work for you?

Index: watch.c
===================================================================
RCS file: /home/cvs/src/usr.bin/watch/watch.c,v
diff -u -p -r1.32 watch.c
--- watch.c	26 Jun 2025 21:34:45 -0000	1.32
+++ watch.c	27 Jun 2025 17:33:37 -0000
@@ -544,6 +544,13 @@ child_input(int sig, short event, void *
 		}
 		if (c == MAXCOLUMN)
 			continue;
+		if (wc == '\t') {
+			(*buf)[l][c++] = ' ';
+			while (c & 7 && c < MAXCOLUMN)
+				(*buf)[l][c++] = ' ';
+			continue;
+		}
+
 		(*buf)[l][c++] = wc;
 	}
 	display(buf, prev_buf, highlight_mode);