Skip to content

Keep the first N columns visible - #2099

Open
fasterit wants to merge 4 commits into
htop-dev:mainfrom
fasterit:keep-N-columns-visible
Open

Keep the first N columns visible#2099
fasterit wants to merge 4 commits into
htop-dev:mainfrom
fasterit:keep-N-columns-visible

Conversation

@fasterit

Copy link
Copy Markdown
Member

Closes #2098

Assisted-by: OpenCode Zen

Closes htop-dev#2098

Assisted-by: OpenCode Zen
@fasterit fasterit added the feature request Completely new feature requested label Aug 31, 2026
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds configurable sticky columns for process and I/O list screens. Users can set the count through --keep-visible[=N], the display options panel, or configuration files. Rendering keeps leading columns fixed during horizontal scrolling. Header clicks account for pinned width and scroll position. Horizontal scrolling is clamped to valid bounds.

Assessment against linked issues

Objective Addressed Explanation
Keep leading process and I/O list columns visible during horizontal scrolling [#2098]

Poem

Leading columns remain in view,
While wider rows pass by anew.
Scroll limits hold the viewport true,
Header clicks map to columns too.
The process list keeps its guide,
And I/O rows move side by side.

Merge Risk: 🔵 Low · up to abc81

The PR adds configurable sticky columns across command-line settings and display layout. Malformed or oversized numeric values may still be accepted, the settings UI limits the count to 100, and help/manual text do not fully match the behavior; these bounded issues warrant owner follow-up but do not indicate a security or availability risk.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 165ac4f7-ea30-43ee-bebe-3005e3e3ccdc

📥 Commits

Reviewing files that changed from the base of the PR and between e0dd9db and ae037ba.

📒 Files selected for processing (11)
  • CommandLine.c
  • DisplayOptionsPanel.c
  • MainPanel.c
  • Panel.c
  • Panel.h
  • Row.c
  • Row.h
  • Settings.c
  • Settings.h
  • Table.c
  • htop.1.in

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread CommandLine.c Outdated
Comment thread htop.1.in
Comment thread Row.c
Comment thread Settings.c Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2c0ae9ef-e19d-4d77-86d2-8d6f3851cda5

📥 Commits

Reviewing files that changed from the base of the PR and between 2796215 and f1e9775.

📒 Files selected for processing (9)
  • CommandLine.c
  • DisplayOptionsPanel.c
  • MainPanel.c
  • Row.c
  • Row.h
  • Settings.c
  • Settings.h
  • Table.c
  • htop.1.in

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread DisplayOptionsPanel.c
@BenBE
BenBE force-pushed the keep-N-columns-visible branch from f1e9775 to abc8116 Compare September 1, 2026 22:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 2a1a8f8d-e438-4023-aad6-50efee8176fb

📥 Commits

Reviewing files that changed from the base of the PR and between f1e9775 and abc8116.

📒 Files selected for processing (2)
  • CommandLine.c
  • Row.c

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread CommandLine.c
Comment on lines +364 to +374
if (sscanf(optarg, "%16zd", &parsed) != 1) {
fprintf(stderr, "Error: invalid value \"%s\" for --keep-visible.\n", optarg);
return STATUS_ERROR_EXIT;
}

if (parsed < 0) {
fprintf(stderr, "Error: --keep-visible must not be negative.\n");
return STATUS_ERROR_EXIT;
}

flags->keepColumnsVisible = (size_t) parsed;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- CommandLine.c target and application path ---'
sed -n '330,490p' CommandLine.c
printf '%s\n' '--- keepColumnsVisible declarations and uses ---'
rg -n -C 3 'keepColumnsVisible|keep-visible' --glob '*.{c,h}'

Repository: htop-dev/htop

Length of output: 5415


🏁 Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- tracked files defining the command-line settings type ---'
git ls-files | rg '(^|/)(CommandLine|Settings|Config).*\\.(c|h)$' || true
printf '%s\n' '--- all exact references ---'
rg -n -C 3 'keepColumnsVisible|keep-visible' . || true
printf '%s\n' '--- relevant status definitions ---'
rg -n -C 3 'STATUS_ERROR_EXIT|typedef enum.*CommandLine|CommandLineStatus' CommandLine.c CommandLine.h *.h *.c 2>/dev/null || true

Repository: htop-dev/htop

Length of output: 19508


Reject partial and out-of-range values for --keep-visible.

sscanf accepts numeric prefixes, so --keep-visible=1x succeeds. Values above INT_MAX are accepted and narrowed to int before assignment to settings->keepColumnsVisible. Parse the complete argument and reject values outside 0..INT_MAX.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fasterit sscanf is overkill here; strtoull + errno/retval check should do just fine and gives proper error handling.

@fasterit
fasterit marked this pull request as ready for review September 3, 2026 18:13
@BenBE BenBE added this to the 3.6.0 milestone Sep 5, 2026
Comment thread CommandLine.c
printf("-M --no-mouse Disable the mouse\n");
#endif
printf(" --no-meters Hide meters\n"
" --keep-visible[=N] Keep the first N columns visible when scrolling sideways (default 1)\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity, it's better to have the option argument of this mandatory. No need to document the behavior of --keep-visible (without option argument) as it's behavior is less stable than --keep-visible=1.

Comment thread CommandLine.c
}

if (parsed < 0) {
fprintf(stderr, "Error: --keep-visible must not be negative.\n");

@Explorer09 Explorer09 Sep 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message of this may be merged with the previous one. ("Invalid value") Save at least one line of code.

Comment thread Panel.c
case KEY_CTRL('B'):
if (this->scrollH > 0) {
this->scrollH -= MAXIMUM(CRT_scrollHAmount, 0);
this->scrollH = MAXIMUM(this->scrollH, 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be cheery picked into its own commit as this is a bug fix not related to the feature.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split a PR for this?

Comment thread Row.c
int nColumns = 0;
while (fields[nColumns])
nColumns++;
if (!nColumns)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!nColumns)
if (nColumns <= 0)

Comment thread Table.c

for (int i = 0; fields[i]; i++) {
int color;
bool pinned = (i < pinnedCount);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool pinned = (i < pinnedCount);
bool isPinned = (i < pinnedCount);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Completely new feature requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Sticky column(s) in process and I/O list screens

3 participants