summaryrefslogtreecommitdiffstats
path: root/Action.c
diff options
context:
space:
mode:
authorryenus <ryenus@gmail.com>2017-08-03 17:43:28 +0800
committercgzones <cgzones@googlemail.com>2020-09-24 19:22:25 +0200
commitf4bb50294a31c0d46dbcd742c4002f4fbb20d2a8 (patch)
tree4ea66a688d2967e80888c5c73edb801668b2de60 /Action.c
parent52338171220af1ff009ea30114a290c80847b2dd (diff)
show selected command wrapped in a separate window
For a process with a very long command, especially with many long command line arguments, inspecting the command and its arguments could become inconvenient. Meanwhile htop supports the concept of "screen", or window, which is extended here to create a dedicated "CommandScreen", making it possible to display the command of the selected process in a separate window meanwhile being wrapped into multiple lines. Another benefit of using a command screen is, the user can navigate through the wrapped lines of the command and perform actions like searching and filtering.
Diffstat (limited to 'Action.c')
-rw-r--r--Action.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/Action.c b/Action.c
index eac7f1f6..f36e0bd2 100644
--- a/Action.c
+++ b/Action.c
@@ -13,6 +13,7 @@ in the source distribution for its full text.
#include "CategoriesPanel.h"
#include "CRT.h"
#include "EnvScreen.h"
+#include "CommandScreen.h"
#include "MainPanel.h"
#include "OpenFilesScreen.h"
#include "Process.h"
@@ -422,8 +423,8 @@ static const struct { const char* key; const char* info; } helpRight[] = {
{ .key = " e: ", .info = "show process environment" },
{ .key = " i: ", .info = "set IO priority" },
{ .key = " l: ", .info = "list open files with lsof" },
+ { .key = " M: ", .info = "show process command in multiple lines" },
{ .key = " s: ", .info = "trace syscalls with strace" },
- { .key = " ", .info = "" },
{ .key = " F2 C S: ", .info = "setup" },
{ .key = " F1 h: ", .info = "show this help screen" },
{ .key = " F10 q: ", .info = "quit" },
@@ -530,6 +531,16 @@ static Htop_Reaction actionShowEnvScreen(State* st) {
return HTOP_REFRESH | HTOP_REDRAW_BAR;
}
+static Htop_Reaction actionShowCommandScreen(State* st) {
+ Process* p = (Process*) Panel_getSelected(st->panel);
+ if (!p) return HTOP_OK;
+ CommandScreen* cmdScr = CommandScreen_new(p);
+ InfoScreen_run((InfoScreen*)cmdScr);
+ CommandScreen_delete((Object*)cmdScr);
+ clear();
+ CRT_enableDelay();
+ return HTOP_REFRESH | HTOP_REDRAW_BAR;
+}
void Action_setBindings(Htop_Action* keys) {
keys[KEY_RESIZE] = actionResize;
@@ -584,4 +595,5 @@ void Action_setBindings(Htop_Action* keys) {
keys['U'] = actionUntagAll;
keys['c'] = actionTagAllChildren;
keys['e'] = actionShowEnvScreen;
+ keys['M'] = actionShowCommandScreen;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy