diff options
author | Elliott Hughes <enh@google.com> | 2020-08-13 09:31:04 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-08-13 13:45:06 -0500 |
commit | 330c07adb8110876f1c3f4d08408fcd27580d09a (patch) | |
tree | 9c10d897c71e449ffcc2378c9908ad3252cbf6d8 /lib | |
parent | 1b276a864b311ea55d0b413b9031b8c4128bc7e5 (diff) | |
download | toybox-330c07adb8110876f1c3f4d08408fcd27580d09a.tar.gz |
list_signals: fit to window size.
Helps for terminals narrower than 80 columns (such as ConnectBot on a
current Android device).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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'); |