- row = 5;
- mvaddstr(row++, 0, "cpu user|"); clrtoeol();
- mvaddstr(row++, 0, " nice|"); clrtoeol();
- mvaddstr(row++, 0, " system|"); clrtoeol();
- mvaddstr(row++, 0, " idle|"); clrtoeol();
- row++;
- for (i = 0; i < DK_NDRIVE; i++)
- if (s.dk_mspw[i] != 0.0) {
- mvprintw(row++, 0, "%3.3s bps|", dr_name[i]);
- clrtoeol();
- mvaddstr(row++, 0, " tps|"); clrtoeol();
- mvaddstr(row++, 0, " mps|"); clrtoeol();
+ row = 0;
+ wmove(wnd, row, 0); wclrtobot(wnd);
+ mvwaddstr(wnd, row++, INSET,
+ "/0 /10 /20 /30 /40 /50 /60 /70 /80 /90 /100");
+ mvwaddstr(wnd, row++, 0, "cpu user|");
+ mvwaddstr(wnd, row++, 0, " nice|");
+ mvwaddstr(wnd, row++, 0, " system|");
+ mvwaddstr(wnd, row++, 0, " idle|");
+ if (numbers)
+ row = numlabels(row + 1);
+ else
+ row = barlabels(row + 1);
+}
+
+static
+numlabels(row)
+{
+ int i, col, regions, ndrives;
+
+#define COLWIDTH 14
+#define DRIVESPERLINE ((wnd->_maxx - INSET) / COLWIDTH)
+ for (ndrives = 0, i = 0; i < dk_ndrive; i++)
+ if (dk_select[i])
+ ndrives++;
+ regions = howmany(ndrives, DRIVESPERLINE);
+ /*
+ * Deduct -regions for blank line after each scrolling region.
+ */
+ linesperregion = (wnd->_maxy - row - regions) / regions;
+ /*
+ * Minimum region contains space for two
+ * label lines and one line of statistics.
+ */
+ if (linesperregion < 3)
+ linesperregion = 3;
+ col = 0;
+ for (i = 0; i < dk_ndrive; i++)
+ if (dk_select[i] && dk_mspw[i] != 0.0) {
+ if (col + COLWIDTH >= wnd->_maxx - INSET) {
+ col = 0, row += linesperregion + 1;
+ if (row > wnd->_maxy - (linesperregion + 1))
+ break;
+ }
+ mvwaddstr(wnd, row, col + 4, dr_name[i]);
+ mvwaddstr(wnd, row + 1, col, "bps tps msps");
+ col += COLWIDTH;