Skip to content

Commit

Permalink
itrafmon.c: fix window switching
Browse files Browse the repository at this point in the history
Fix a bug: keys were not handled by the correct window; the window
switch (by Tab key) was not properly propagated into upper function.

Fixes: e939820 ("ipmon(): move keypress handling into separate function")
Reported-by: Augusto Mecking Caringi <augustocaringi@gmail.com>
Signed-off-by: Vitezslav Samel <vitezslav@samel.cz>
Signed-off-by: Nikola Pajkovsky <n.pajkovsky@gmail.com>
  • Loading branch information
vsamel authored and Nikola Pajkovsky committed Jul 15, 2014
1 parent 86f59c2 commit d786695
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/itrafmon.c
Expand Up @@ -535,7 +535,7 @@ static int checkrvnamed(void)
return 1;
}

static void ipmon_process_key(int ch, int curwin, struct tcptable *table, struct othptable *othptbl)
static void ipmon_process_key(int ch, int *curwin, struct tcptable *table, struct othptable *othptbl)
{
static int keymode = 0;
static WINDOW *sortwin;
Expand All @@ -544,19 +544,19 @@ static void ipmon_process_key(int ch, int curwin, struct tcptable *table, struct
if (keymode == 0) {
switch (ch) {
case KEY_UP:
if (curwin)
if (*curwin)
scroll_othp(othptbl, SCROLLDOWN, 1);
else
move_tcp_bar(table, SCROLLDOWN, 1);
break;
case KEY_DOWN:
if (curwin)
if (*curwin)
scroll_othp(othptbl, SCROLLUP, 1);
else
move_tcp_bar(table, SCROLLUP, 1);
break;
case KEY_RIGHT:
if (!curwin)
if (!*curwin)
break;

if (othptbl->strindex != VSCRL_OFFSET)
Expand All @@ -565,7 +565,7 @@ static void ipmon_process_key(int ch, int curwin, struct tcptable *table, struct
refresh_othwindow(othptbl);
break;
case KEY_LEFT:
if (!curwin)
if (!*curwin)
break;

if (othptbl->strindex != 0)
Expand All @@ -575,26 +575,26 @@ static void ipmon_process_key(int ch, int curwin, struct tcptable *table, struct
break;
case KEY_PPAGE:
case '-':
if (curwin)
if (*curwin)
scroll_othp(othptbl, SCROLLDOWN, othptbl->oimaxy);
else
move_tcp_bar(table, SCROLLDOWN, table->imaxy);
break;
case KEY_NPAGE:
case ' ':
if (curwin)
if (*curwin)
scroll_othp(othptbl, SCROLLUP, othptbl->oimaxy);
else
move_tcp_bar(table, SCROLLUP, table->imaxy);
break;
case KEY_HOME:
if (curwin)
if (*curwin)
scroll_othp(othptbl, SCROLLDOWN, INT_MAX);
else
move_tcp_bar(table, SCROLLDOWN, INT_MAX);
break;
case KEY_END:
if (curwin)
if (*curwin)
scroll_othp(othptbl, SCROLLUP, INT_MAX);
else
move_tcp_bar(table, SCROLLUP, INT_MAX);
Expand All @@ -603,14 +603,14 @@ static void ipmon_process_key(int ch, int curwin, struct tcptable *table, struct
case 'w':
case 'W':
case 9:
curwin = !curwin;
markactive(curwin, table->borderwin,
*curwin = !*curwin;
markactive(*curwin, table->borderwin,
othptbl->borderwin);
uniq_help(curwin);
uniq_help(*curwin);
break;
case 'm':
case 'M':
if (curwin)
if (*curwin)
break;
table->mode = (table->mode + 1) % 3;
if ((table->mode == 1) && !options.mac)
Expand Down Expand Up @@ -1012,7 +1012,7 @@ void ipmon(time_t facilitytime, char *ifptr)
}

if (ch != ERR)
ipmon_process_key(ch, curwin, &table, &othptbl);
ipmon_process_key(ch, &curwin, &table, &othptbl);

if (pkt.pkt_len > 0) {
total_pkts++;
Expand Down

0 comments on commit d786695

Please sign in to comment.