Skip to content

Commit

Permalink
Merge branch 'traviscross:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
arekm authored Aug 21, 2024
2 parents 4e6f565 + 49662a9 commit 689ce52
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 30 deletions.
2 changes: 1 addition & 1 deletion man/mtr.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ a short interval, will use up a lot of file descriptors.
Set the mark for each packet sent through this socket similar to the
netfilter MARK target but socket-based.
.I MARK
is 32 unsigned integer. See
is a 32-bit unsigned integer. See
.BR socket (7)
for full description of this socket option.
.SH ENVIRONMENT
Expand Down
63 changes: 36 additions & 27 deletions ui/curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ int mtr_curses_keyaction(
return ActionReset;
case 'd':
return ActionDisplay;
case 'c':
return ActionCompact;
case 'e':
return ActionMPLS;
case 'n':
Expand Down Expand Up @@ -345,6 +347,7 @@ int mtr_curses_keyaction(
printw(" ?|h help\n");
printw(" p pause (SPACE to resume)\n");
printw(" d switching display mode\n");
printw(" c switching compact mode\n");
printw(" e toggle MPLS information on/off\n");
printw(" n toggle DNS on/off\n");
printw(" r reset all counters\n");
Expand Down Expand Up @@ -689,7 +692,7 @@ void mtr_curses_redraw(
erase();
getmaxyx(stdscr, __unused_int, maxx);

rowstat = 5;
rowstat = !ctl->CompactLayout;

move(0, 0);
attron(A_BOLD);
Expand All @@ -698,34 +701,38 @@ void mtr_curses_redraw(
pwcenter(buf);
attroff(A_BOLD);

mvprintw(1, 0, "%s (%s) -> %s (%s)",
mvprintw(rowstat, 0, "%s (%s) -> %s (%s)",
ctl->LocalHostname, net_localaddr(),
ctl->Hostname, net_remoteaddr());
t = time(NULL);
mvprintw(1, maxx - 25, "%s", iso_time(&t));
printw("\n");
mvprintw(rowstat, maxx - 25, "%s", iso_time(&t));
if (rowstat) {
printw("\n");

printw("Keys: ");
attron(A_BOLD);
printw("H");
attroff(A_BOLD);
printw("elp ");
attron(A_BOLD);
printw("D");
attroff(A_BOLD);
printw("isplay mode ");
attron(A_BOLD);
printw("R");
attroff(A_BOLD);
printw("estart statistics ");
attron(A_BOLD);
printw("O");
attroff(A_BOLD);
printw("rder of fields ");
attron(A_BOLD);
printw("q");
attroff(A_BOLD);
printw("uit\n");
printw("Keys: ");
attron(A_BOLD);
printw("H");
attroff(A_BOLD);
printw("elp ");
attron(A_BOLD);
printw("D");
attroff(A_BOLD);
printw("isplay mode ");
attron(A_BOLD);
printw("R");
attroff(A_BOLD);
printw("estart statistics ");
attron(A_BOLD);
printw("O");
attroff(A_BOLD);
printw("rder of fields ");
attron(A_BOLD);
printw("q");
attroff(A_BOLD);
printw("uit\n");
}

rowstat = rowstat ? 5 : 1;

if (ctl->display_mode == DisplayModeDefault) {
for (i = 0; i < MAXFLD; i++) {
Expand Down Expand Up @@ -761,8 +768,10 @@ void mtr_curses_redraw(
maxx <= SAVED_PINGS + padding ? maxx - padding : SAVED_PINGS;
startstat = padding - 2;

snprintf(msg, sizeof(msg), " Last %3d pings", max_cols);
mvprintw(rowstat - 1, startstat, "%s", msg);
if (rowstat > 1) {
snprintf(msg, sizeof(msg), " Last %3d pings", max_cols);
mvprintw(rowstat - 1, startstat, "%s", msg);
}

attroff(A_BOLD);
move(rowstat, 0);
Expand Down
2 changes: 1 addition & 1 deletion ui/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/* Don't put a trailing comma in enumeration lists. Some compilers
(notably the one on Irix 5.2) do not like that. */
enum { ActionNone, ActionQuit, ActionReset, ActionDisplay,
enum { ActionNone, ActionQuit, ActionReset, ActionDisplay, ActionCompact,
ActionClear, ActionPause, ActionResume, ActionMPLS, ActionDNS,
#ifdef HAVE_IPINFO
ActionII, ActionAS,
Expand Down
2 changes: 1 addition & 1 deletion ui/mtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct mtr_ctl {
ForceMaxPing:1,
use_dns:1,
show_ips:1,
enablempls:1, dns:1, reportwide:1, Interactive:1, DisplayMode:5;
enablempls:1, dns:1, reportwide:1, Interactive:1, DisplayMode:5, CompactLayout:1;
#ifdef HAVE_IPINFO
#ifdef ENABLE_IPV6
char *ipinfo_provider6;
Expand Down
4 changes: 4 additions & 0 deletions ui/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ void select_loop(
ctl->display_mode =
(ctl->display_mode + 1) % DisplayModeMAX;
break;
case ActionCompact:
ctl->CompactLayout = !ctl->CompactLayout;
display_clear(ctl);
break;
case ActionClear:
display_clear(ctl);
break;
Expand Down

0 comments on commit 689ce52

Please sign in to comment.