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 5a27c8095e
http://www.freelists.org/post/procps/top-won-the-sigwinch-war,6

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2013-01-31 00:00:00 -06:00 committed by Craig Small
parent dedaf6e1a8
commit ca76af22ca

View File

@ -1835,20 +1835,21 @@ static void calibrate_fields (void) {
* xPRFX ----------______________________ xSUFX * xPRFX ----------______________________ xSUFX
* ( xPRFX has pos 2 & 10 for 'extending' when at minimums ) * ( xPRFX has pos 2 & 10 for 'extending' when at minimums )
* *
* The first 4 screen rows are reserved for explanatory text, the * The first 4 screen rows are reserved for explanatory text, and
* maximum number of columns is currently 6 and a space is needed * the maximum number of columns is Screen_cols / xPRFX + 1 space
* between columns. Thus, for example, with 40 fields a tty will * between columns. Thus, for example, with 42 fields a tty will
* still remain useable under these extremes: * still remain useable under these extremes:
* rows cols displayed * rows columns what's
* ---- ---- ------------------ * tty top tty top displayed
* 24 22 xPRFX only * --- --- --- --- ------------------
* 24 66 full xPRFX + xSUFX * 46 42 10 1 xPRFX only
* 11 66 xPRFX only ( w/ room for +2 ) * 46 42 32 1 full xPRFX + xSUFX
* 11 198 full xPRFX + xSUFX ( w/ room for +2 ) * 6 2 231 21 xPRFX only
* 10 6 231 7 full xPRFX + xSUFX
*/ */
static void display_fields (int focus, int extend) { static void display_fields (int focus, int extend) {
#define mkERR { putp("\n"); putp(N_txt(XTRA_winsize_txt)); return; } #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 yRSVD 4
#define xSUFX 22 #define xSUFX 22
#define xPRFX (10 + xadd) #define xPRFX (10 + xadd)