From ca76af22ca2fc8e880317ad9dfd303ea791a2bd3 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 31 Jan 2013 00:00:00 -0600 Subject: [PATCH] top: lift the field management 6 col width restriction When two somewhat cryptic error messages were recently changed to more user friendly text, the logic limiting maximum columns was left unchanged at six. This always was a rather arbitrary limit but now the revised error message could actually be misleading (ok, a huge lie). With a 1 line code change (macro actually), this patch lifts the internal restriction on maximum columns. Now the real limit is based on a window's physical x-axis. (everything is perfectly justified plus right margins) (are completely filled, but of course it must be luck) Reference(s): commit 5a27c8095ef015e9c40709ba3186422bdf3fc069 http://www.freelists.org/post/procps/top-won-the-sigwinch-war,6 Signed-off-by: Jim Warner --- top/top.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/top/top.c b/top/top.c index 389879ee..1b06792d 100644 --- a/top/top.c +++ b/top/top.c @@ -1835,20 +1835,21 @@ static void calibrate_fields (void) { * xPRFX ----------______________________ xSUFX * ( xPRFX has pos 2 & 10 for 'extending' when at minimums ) * - * The first 4 screen rows are reserved for explanatory text, the - * maximum number of columns is currently 6 and a space is needed - * between columns. Thus, for example, with 40 fields a tty will + * The first 4 screen rows are reserved for explanatory text, and + * the maximum number of columns is Screen_cols / xPRFX + 1 space + * between columns. Thus, for example, with 42 fields a tty will * still remain useable under these extremes: - * rows cols displayed - * ---- ---- ------------------ - * 24 22 xPRFX only - * 24 66 full xPRFX + xSUFX - * 11 66 xPRFX only ( w/ room for +2 ) - * 11 198 full xPRFX + xSUFX ( w/ room for +2 ) + * rows columns what's + * tty top tty top displayed + * --- --- --- --- ------------------ + * 46 42 10 1 xPRFX only + * 46 42 32 1 full xPRFX + xSUFX + * 6 2 231 21 xPRFX only + * 10 6 231 7 full xPRFX + xSUFX */ static void display_fields (int focus, int extend) { #define mkERR { putp("\n"); putp(N_txt(XTRA_winsize_txt)); return; } - #define mxCOL 6 + #define mxCOL ( (Screen_cols / 11) > 0 ? (Screen_cols / 11) : 1 ) #define yRSVD 4 #define xSUFX 22 #define xPRFX (10 + xadd)