Skip to content

Commit

Permalink
Merge pull request #22 from glebm/htop-bindings
Browse files Browse the repository at this point in the history
Add (h)top compatibility commands: M, P, F10 / q
  • Loading branch information
gsass1 authored Feb 11, 2020
2 parents 1338b9f + fb5e228 commit 404000f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ntop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,9 @@ static void PrintHelp(const TCHAR *argv0)
) },
{ _T("n"), _T("Next in search.") },
{ _T("N"), _T("Previous in search.") },
{ _T("F10, q"), _T("Quit") },
{ _T("M"), _T("Sort by memory usage") },
{ _T("P"), _T("Sort by processor usage") },
};
PrintHelpEntries(_T("INTERACTIVE COMMANDS"), _countof(InteractiveCommands), InteractiveCommands);

Expand Down Expand Up @@ -1419,6 +1422,8 @@ static void ProcessInput(BOOL *Redraw)
*Redraw = TRUE;
}
break;
case VK_F10:
exit(EXIT_SUCCESS); // Top compatibility
default:
switch(InputRecord.Event.KeyEvent.uChar.AsciiChar) {
case 'K':
Expand Down Expand Up @@ -1478,11 +1483,17 @@ static void ProcessInput(BOOL *Redraw)
case 'k':
DoScroll(SCROLL_UP, Redraw);
break;
case 'q':
case 'Q':
SetViMessage(VI_NOTICE, "To exit, type :q");
// Top compatibility keys:
case 'M':
ChangeProcessSortType(SORT_BY_USED_MEMORY);
*Redraw = TRUE;
break;
case 'P':
ChangeProcessSortType(SORT_BY_PROCESSOR_TIME);
*Redraw = TRUE;
break;
case 'q':
exit(EXIT_SUCCESS);
}
break;
}
Expand Down

0 comments on commit 404000f

Please sign in to comment.