mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
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.
This commit is contained in:
14
Action.c
14
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user