Skip to content

Commit

Permalink
Remove the special handling for the "Command" column and add a warnin…
Browse files Browse the repository at this point in the history
…g that its length should be dynamic

Resolves #1199
  • Loading branch information
Daniel Lange authored and BenBE committed Dec 10, 2024
1 parent 04d0a54 commit f2b2828
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion AvailableColumnsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void AvailableColumnsPanel_addDynamicColumns(AvailableColumnsPanel* this,
// Handle remaining Platform Meter entries in the AvailableColumnsPanel
static void AvailableColumnsPanel_addPlatformColumns(AvailableColumnsPanel* this) {
for (int i = 1; i < LAST_PROCESSFIELD; i++) {
if (i != COMM && Process_fields[i].description) {
if (Process_fields[i].description) {
char description[256];
xSnprintf(description, sizeof(description), "%s - %s", Process_fields[i].name, Process_fields[i].description);
Panel_add(&this->super, (Object*) ListItem_new(description, i));
Expand Down
8 changes: 4 additions & 4 deletions ColumnsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
case KEY_ENTER:
case KEY_MOUSE:
case KEY_RECLICK:
if (selected < size - 1) {
if (selected < size) {
this->moving = !(this->moving);
Panel_setSelectionColor(super, this->moving ? PANEL_SELECTION_FOLLOW : PANEL_SELECTION_FOCUS);
ListItem* selectedItem = (ListItem*) Panel_getSelected(super);
Expand All @@ -63,7 +63,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
case KEY_F(7):
case '[':
case '-':
if (selected < size - 1)
if (selected < size)
Panel_moveSelectedUp(super);
result = HANDLED;
break;
Expand All @@ -74,13 +74,13 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
case KEY_F(8):
case ']':
case '+':
if (selected < size - 2)
if (selected < size - 1)
Panel_moveSelectedDown(super);
result = HANDLED;
break;
case KEY_F(9):
case KEY_DC:
if (selected < size - 1)
if (size > 1 && selected < size)
Panel_remove(super, selected);
result = HANDLED;
break;
Expand Down
2 changes: 1 addition & 1 deletion darwin/DarwinProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ in the source distribution for its full text.
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line (insert as last column only)", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)", .flags = 0, },
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
Expand Down
2 changes: 1 addition & 1 deletion dragonflybsd/DragonFlyBSDProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in the source distribution for its full text.
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line (insert as last column only)", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping (<20s), I Idle, Q Queued for Run, R running, D disk, Z zombie, T traced, W paging, B Blocked, A AskedPage, C Core, J Jailed)", .flags = 0, },
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
Expand Down
2 changes: 1 addition & 1 deletion freebsd/FreeBSDProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const char* const nodevStr = "nodev";
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line (insert as last column only)", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)", .flags = 0, },
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
Expand Down
3 changes: 3 additions & 0 deletions htop.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ is active, the executable path (/proc/[pid]/exe) and the command name

The program basename is highlighted if set in the configuration. Additional
highlighting can be configured for stale executables (cf. EXE column below).

The Command column should be the last column in each screen as can get very long
and profits from being able to extend its length dynamically.
.TP
.B COMM
The command name of the process obtained from /proc/[pid]/comm, if readable.
Expand Down
2 changes: 1 addition & 1 deletion linux/LinuxProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ in the source distribution for its full text.
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line (insert as last column only)", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging, I idle)", .flags = 0, },
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
Expand Down
2 changes: 1 addition & 1 deletion netbsd/NetBSDProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[COMM] = {
.name = "Command",
.title = "Command ",
.description = "Command line",
.description = "Command line (insert as last column only)",
.flags = 0,
},
[STATE] = {
Expand Down
2 changes: 1 addition & 1 deletion openbsd/OpenBSDProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[COMM] = {
.name = "Command",
.title = "Command ",
.description = "Command line",
.description = "Command line (insert as last column only)",
.flags = 0,
},
[STATE] = {
Expand Down
2 changes: 1 addition & 1 deletion pcp/PCPProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ in the source distribution for its full text.
const ProcessFieldData Process_fields[] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line (insert as last column only)", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging, I idle)", .flags = 0, },
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, },
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, },
Expand Down
2 changes: 1 addition & 1 deletion solaris/SolarisProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ in the source distribution for its full text.
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line (insert as last column only)", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, O onproc, Z zombie, T stopped, W waiting)", .flags = 0, },
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
Expand Down
2 changes: 1 addition & 1 deletion unsupported/UnsupportedProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ in the source distribution for its full text.
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line (insert as last column only)", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)", .flags = 0, },
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
Expand Down

0 comments on commit f2b2828

Please sign in to comment.