Helps for terminals narrower than 80 columns (such as ConnectBot on a
current Android device).
---
 lib/lib.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
From 8b8cde8f2306ebc8aea281e5f048693f6b73e662 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Thu, 13 Aug 2020 09:31:04 -0700
Subject: [PATCH] list_signals: fit to window size.

Helps for terminals narrower than 80 columns (such as ConnectBot on a
current Android device).
---
 lib/lib.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/lib.c b/lib/lib.c
index 03529a22..7fe3611e 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -901,16 +901,19 @@ void sigatexit(void *handler)
   toys.xexit = al;
 }
 
-// Output a nicely formatted 80-column table of all the signals.
+// Output a nicely formatted table of all the signals.
 void list_signals()
 {
   int i = 0, count = 0;
+  unsigned cols = 80;
   char *name;
 
+  terminal_size(&cols, 0);
+  cols /= 16;
   for (; i<=NSIG; i++) {
     if ((name = num_to_sig(i))) {
       printf("%2d) SIG%-9s", i, name);
-      if (++count % 5 == 0) putchar('\n');
+      if (++count % cols == 0) putchar('\n');
     }
   }
   putchar('\n');
-- 
2.28.0.220.ged08abb693-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to