static void win_reset (WIN_t *q) {
SETw(q, Show_IDLEPS | Show_TASKON);
#ifndef SCROLLVAR_NO
- q->rc.maxtasks = q->usrseltyp = q->begpflg = q->begtask = q->varcolbeg = 0;
+ q->rc.maxtasks = q->usrseltyp = q->begpflg = q->begtask = q->begnext = q->varcolbeg = 0;
#else
- q->rc.maxtasks = q->usrseltyp = q->begpflg = q->begtask = 0;
+ q->rc.maxtasks = q->usrseltyp = q->begpflg = q->begtask = q->begnext = 0;
#endif
Monpidsidx = 0;
osel_clear(q);
#endif
}
if (Curwin->findstr[0]) {
- SETw(Curwin, INFINDS_xxx);
+ SETw(Curwin, NOPRINT_xxx);
for (i = Curwin->begtask; i < Frame_maxtask; i++) {
const char *row = task_show(Curwin, Curwin->ppt[i]);
if (*row && -1 < find_ofs(Curwin, row)) {
}
break;
case kbd_UP:
- if (VIZCHKw(w)) if (CHKw(w, Show_IDLEPS) && 0 < w->begtask) w->begtask -= 1;
+ if (VIZCHKw(w)) if (CHKw(w, Show_IDLEPS)) w->begnext = -1;
break;
case kbd_DOWN:
- if (VIZCHKw(w)) if (CHKw(w, Show_IDLEPS) && (w->begtask < Frame_maxtask - 1)) w->begtask += 1;
+ if (VIZCHKw(w)) if (CHKw(w, Show_IDLEPS)) w->begnext = +1;
break;
#ifdef USE_X_COLHDR // ------------------------------------
case kbd_LEFT:
case kbd_PGUP:
if (VIZCHKw(w)) {
if (CHKw(w, Show_IDLEPS) && 0 < w->begtask) {
- w->begtask -= (w->winlines - 1);
- if (0 > w->begtask) w->begtask = 0;
+ w->begnext = -(w->winlines - 1);
}
}
break;
case kbd_PGDN:
if (VIZCHKw(w)) {
if (CHKw(w, Show_IDLEPS) && w->begtask < Frame_maxtask - 1) {
- w->begtask += (w->winlines - 1);
- if (w->begtask > Frame_maxtask - 1) w->begtask = Frame_maxtask - 1;
- if (0 > w->begtask) w->begtask = 0;
+ w->begnext = +(w->winlines - 1);
}
}
break;
case kbd_END:
if (VIZCHKw(w)) {
if (CHKw(w, Show_IDLEPS)) {
- w->begtask = (Frame_maxtask - w->winlines) + 1;
- if (0 > w->begtask) w->begtask = 0;
+ w->begnext = (Frame_maxtask - w->winlines) + 1;
w->begpflg = w->endpflg;
#ifndef SCROLLVAR_NO
w->varcolbeg = 0;
case EU_XON:
case EU_XOF:
cp = NULL;
- if (!CHKw(q, INFINDS_xxx | NOHIFND_xxx | NOHISEL_xxx)) {
+ if (!CHKw(q, NOPRINT_xxx | NOHIFND_xxx | NOHISEL_xxx)) {
/* treat running tasks specially - entire row may get highlighted
so we needn't turn it on and we MUST NOT turn it off */
if (!('R' == p->state && CHKw(q, Show_HIROWS)))
#undef Jn
} // end: for 'maxpflgs'
- if (!CHKw(q, INFINDS_xxx)) {
+ if (!CHKw(q, NOPRINT_xxx)) {
const char *cap = ((CHKw(q, Show_HIROWS) && 'R' == p->state))
? q->capclr_rowhigh : q->capclr_rownorm;
char *row = rbuf;
} // end: task_show
+ /*
+ * A window_show *Helper* function ensuring that Curwin's 'begtask'
+ * represents a visible process (not any hidden/filtered-out task).
+ * In reality, this function is called:
+ * 1) exclusively for the current window
+ * 2) immediately after interacting with a user
+ * 3) with the only key stuck: up, down, pgup, pgdn or end */
+static void window_hlp (void) {
+ WIN_t *w = Curwin; // avoid gcc bloat with a local copy
+ int i;
+
+ SETw(w, NOPRINT_xxx);
+ w->begtask += w->begnext;
+ if (w->begtask < 0) w->begtask = 0;
+ if (w->begtask >= Frame_maxtask) w->begtask = Frame_maxtask - 1;
+
+ // potentially scroll forward ...
+ if (w->begnext > 0) {
+ for (i = w->begtask; i < Frame_maxtask; i++) {
+ if (user_matched(w, w->ppt[i])
+ && (*task_show(w, w->ppt[i])))
+ break;
+ }
+ if (i < Frame_maxtask) {
+ w->begtask = i;
+ goto wrap_up;
+ }
+ // no luck forward, so let's try backward
+ w->begtask = Frame_maxtask - 1;
+ }
+
+ // potentially scroll backward ...
+ for (i = w->begtask; i > 0; i--) {
+ if (user_matched(w, w->ppt[i])
+ && (*task_show(w, w->ppt[i])))
+ break;
+ }
+ w->begtask = i;
+
+wrap_up:
+ w->begnext = 0;
+ OFFw(w, NOPRINT_xxx);
+} // end: window_hlp
+
+
/*
* Squeeze as many tasks as we can into a single window,
* after sorting the passed proc table. */
qsort(q->ppt, Frame_maxtask, sizeof(proc_t*), Fieldstab[q->rc.sortindx].sort);
}
+ if (q->begnext) window_hlp();
+ else OFFw(q, NOPRINT_xxx);
+
i = q->begtask;
lwin = 1; // 1 for the column header
wmax = winMIN(wmax, q->winlines + 1); // ditto for winlines, too
Tree_idx = Pseudo_row = Msg_row = scrlins = 0;
summary_show();
Max_lines = (Screen_rows - Msg_row) - 1;
- OFFw(w, INFINDS_xxx);
// we're now on Msg_row so clear out any residual messages ...
putp(Cap_clr_eol);
#define Show_JRSTRS 0x040000 // 'j' - right justify "string" data cols
#define Show_JRNUMS 0x020000 // 'J' - right justify "numeric" data cols
// these flag(s) have no command as such - they're for internal use
-#define INFINDS_xxx 0x010000 // build rows for find_string, not display
+#define NOPRINT_xxx 0x010000 // build task rows only (not for display)
#define EQUWINS_xxx 0x000001 // rebalance all wins & tasks (off i,n,u/U)
#ifndef USE_X_COLHDR
#define NOHISEL_xxx 0x200000 // restrict Show_HICOLS for osel temporarily
begpflg, // scrolled beginning pos into pflgsall array
endpflg, // scrolled ending pos into pflgsall array
begtask, // scrolled beginning pos into Frame_maxtask
+ begnext, // new scrolled delta for next frame's begtask
#ifndef SCROLLVAR_NO
varcolbeg, // scrolled position within variable width col
#endif
//atic void summary_hlp (CPU_t *cpu, const char *pfx);
//atic void summary_show (void);
//atic const char *task_show (const WIN_t *q, const proc_t *p);
+//atic void window_hlp (void);
//atic int window_show (WIN_t *q, int wmax);
/*------ Entry point plus two ------------------------------------------*/
//atic void frame_hlp (int wix, int max);