Skip to content

refactor: standardize terminal dimension naming to columns/rows#1755

Merged
gnodet merged 1 commit intomasterfrom
dust-macaw
Apr 8, 2026
Merged

refactor: standardize terminal dimension naming to columns/rows#1755
gnodet merged 1 commit intomasterfrom
dust-macaw

Conversation

@gnodet
Copy link
Copy Markdown
Member

@gnodet gnodet commented Apr 1, 2026

Summary

Standardize terminal dimension naming across the JLine API to use columns/rows consistently, aligning with the convention used by POSIX (ws_col/ws_row), ncurses, Lanterna, crossterm, xterm.js, and Node.js.

Inspired by the discussion in #1731.

API additions (non-breaking)

Class New methods
Size Size(Size) copy constructor
Terminal default int getColumns(), default int getRows()
Display getColumns(), getRows(), resize(Size)
ScreenTerminal getColumns(), getRows(), setSize(Size)

Deprecations

Class Deprecated Replacement
Terminal getWidth() getColumns()
Terminal getHeight() getRows()
ScreenTerminal getWidth() getColumns()
ScreenTerminal getHeight() getRows()
Display resize(int rows, int columns) resize(Size)

Caller migrations

  • All display.resize(size.getRows(), size.getColumns())display.resize(size)
  • All terminal.getWidth()/getHeight()terminal.getColumns()/getRows()
  • Renamed width/height parameters to columns/rows in constructors and methods across ScreenTerminal, SwingTerminal, WebTerminal, ConnectionData, TelnetIO

Not changed

  • TerminalGraphics.ImageOptions.size(int width, int height) — pixel dimensions, not terminal cells
  • SwingTerminal.dump(...) / Tmux.VirtualConsole.resize(...) — viewport rectangles
  • No existing public method signatures were removed or changed

Summary by CodeRabbit

  • Refactor

    • Standardized sizing across the UI to use "columns" and "rows" and migrated internal rendering to the new geometry model.
  • New Features

    • Added Size-based resize overload and new accessors for columns/rows.
  • Deprecation

    • Legacy width/height accessors preserved as deprecated aliases.
  • User-visible fixes

    • Improved consistency for layouts, wrapping, cursor placement, status-line centering and PTY sizing.
  • Documentation

    • Expanded Javadoc clarifying sizing, resize semantics and constructors.
  • Tests

    • Updated tests/helpers to use columns/rows and Size-based sizing.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06a25081-296e-49c0-8d03-7caf2e04af50

📥 Commits

Reviewing files that changed from the base of the PR and between bca81d1 and d47d323.

📒 Files selected for processing (35)
  • builtins/src/main/java/org/jline/builtins/Commands.java
  • builtins/src/main/java/org/jline/builtins/Less.java
  • builtins/src/main/java/org/jline/builtins/Nano.java
  • builtins/src/main/java/org/jline/builtins/PosixCommands.java
  • builtins/src/main/java/org/jline/builtins/ScreenTerminal.java
  • builtins/src/main/java/org/jline/builtins/SwingTerminal.java
  • builtins/src/main/java/org/jline/builtins/TTop.java
  • builtins/src/main/java/org/jline/builtins/Tmux.java
  • builtins/src/main/java/org/jline/builtins/WebTerminal.java
  • builtins/src/test/java/org/jline/builtins/ScreenTerminalTest.java
  • builtins/src/test/java/org/jline/example/Example.java
  • console-ui/src/main/java/org/jline/consoleui/prompt/AbstractPrompt.java
  • console-ui/src/main/java/org/jline/consoleui/prompt/ConsolePrompt.java
  • demo/src/main/java/org/apache/felix/gogo/jline/Shell.java
  • demo/src/main/java/org/jline/demo/Repl.java
  • demo/src/main/java/org/jline/demo/examples/DisplayExample.java
  • demo/src/main/java/org/jline/demo/examples/GraphemeClusterExample.java
  • demo/src/main/java/org/jline/demo/examples/MultiSegmentStatusExample.java
  • demo/src/main/java/org/jline/demo/examples/RemoteTerminalExample.java
  • demo/src/main/java/org/jline/demo/examples/ResponsiveUIExample.java
  • demo/src/main/java/org/jline/demo/examples/SwingTerminalExample.java
  • demo/src/main/java/org/jline/demo/examples/TerminalCursorExample.java
  • demo/src/main/java/org/jline/demo/examples/WebTerminalExample.java
  • jansi-core/src/main/java/org/jline/jansi/AnsiConsole.java
  • prompt/src/main/java/org/jline/prompt/impl/DefaultPrompter.java
  • reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
  • remote-ssh/src/main/java/org/jline/builtins/ssh/Ssh.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java
  • terminal/src/main/java/org/jline/terminal/Size.java
  • terminal/src/main/java/org/jline/terminal/Terminal.java
  • terminal/src/main/java/org/jline/utils/Display.java
  • terminal/src/main/java/org/jline/utils/Status.java
  • terminal/src/test/java/org/jline/utils/DisplayTest.java
  • terminal/src/test/java/org/jline/utils/ScreenTerminal.java

📝 Walkthrough

Walkthrough

Renames terminal dimension APIs/fields from width/height to columns/rows, adds Size-based Display.resize(Size) overload and Terminal.getColumns()/getRows() defaults (with deprecated getWidth()/getHeight() aliases), updates constructors/signatures and call sites to use Size or columns/rows, and adds Javadoc; behavior otherwise unchanged.

Changes

Cohort / File(s) Summary
Core terminal & Size
terminal/src/main/java/org/jline/terminal/Terminal.java, terminal/src/main/java/org/jline/terminal/Size.java
Added getColumns()/getRows() defaults and deprecated getWidth()/getHeight() aliases; clarified setSize(Size) Javadoc; added Size(Size) copy constructor.
Display API
terminal/src/main/java/org/jline/utils/Display.java, terminal/src/main/java/org/jline/utils/Status.java
Added resize(Size) overload delegating to existing resize; deprecated resize(int rows,int columns); added getColumns()/getRows() accessors; Status now calls display.resize(size).
ScreenTerminal implementation & tests
builtins/src/main/java/org/jline/builtins/ScreenTerminal.java, terminal/src/test/java/org/jline/utils/ScreenTerminal.java, builtins/src/test/java/org/jline/builtins/ScreenTerminalTest.java
Renamed internal fields/ctor params to (columns, rows); added getColumns()/getRows() and setSize(Size)/setSize(int columns,int rows); deprecated getWidth()/getHeight() aliases; refactored buffer row/column helpers; tests updated to use columns/rows.
Swing & Web terminals
builtins/src/main/java/org/jline/builtins/SwingTerminal.java, builtins/src/main/java/org/jline/builtins/WebTerminal.java
Constructor and nested component signatures changed to (columns, rows); component setSize signatures updated; rendering, preferred-size and buffer indexing use getColumns()/getRows().
Display.resize call sites (Size overload)
builtins/.../Less.java, builtins/.../Nano.java, builtins/.../TTop.java, builtins/.../Tmux.java, prompt/.../DefaultPrompter.java, console-ui/.../AbstractPrompt.java, reader/.../LineReaderImpl.java, demo/.../DisplayExample.java, demo/.../GraphemeClusterExample.java, demo/.../ResponsiveUIExample.java, demo/.../examples/*, console-ui/.../ConsolePrompt.java, demo/.../Example.java
Replaced multiple display.resize(rows, columns) / display.resize(size.getRows(), size.getColumns()) calls with display.resize(size); added/expanded Javadoc in many affected methods.
Width/height → columns/rows replacements
builtins/src/main/java/org/jline/builtins/Commands.java, builtins/src/main/java/org/jline/builtins/PosixCommands.java, builtins/src/main/java/org/jline/builtins/Tmux.java, builtins/src/main/java/org/jline/builtins/Nano.java, builtins/src/main/java/org/jline/builtins/Less.java, jansi-core/src/main/java/org/jline/jansi/AnsiConsole.java, demo/.../examples/*, demo/.../Repl.java, demo/.../SwingTerminalExample.java, demo/.../WebTerminalExample.java, demo/.../TerminalCursorExample.java, demo/.../RemoteTerminalExample.java, demo/src/main/java/org/apache/felix/gogo/jline/Shell.java, terminal/src/test/java/org/jline/utils/DisplayTest.java
Replaced getWidth()/getHeight() with getColumns()/getRows() in calculations, status strings, padding, cursor math, and suppliers; updated related Javadoc.
PTY, virtual consoles & remote I/O
remote-ssh/src/main/java/org/jline/builtins/ssh/Ssh.java, remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java, remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java
Switched PTY geometry APIs and setTerminalGeometry parameter names to (columns, rows); moved NAWS geometry helper into IACHandler inner class and preserved validation/defaulting and event emission.
Prompt & REPL callers
prompt/src/main/java/org/jline/prompt/impl/DefaultPrompter.java, console-ui/src/main/java/org/jline/consoleui/prompt/AbstractPrompt.java, console-ui/src/main/java/org/jline/consoleui/prompt/ConsolePrompt.java, demo REPL/examples
Updated display resize, cursor calculations, and paging to use Size or getColumns()/getRows(); added/expanded method Javadoc.
Misc utilities & I/O integration
jansi-core/src/main/java/org/jline/jansi/AnsiConsole.java, reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java, builtins/.../Commands.java
Adjusted width suppliers and references to use terminal::getColumns; Javadoc additions.
Tests & demos adjusted
terminal/src/test/java/org/jline/utils/DisplayTest.java, demo/.../examples/*, builtins/src/test/java/org/jline/builtins/ScreenTerminalTest.java
Updated tests and demos to use new size APIs and columns/rows terminology; Display.resize calls updated to accept Size.

Sequence Diagram(s)

(Skipped)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

chore

Poem

🐰 I hopped from width to columns with delight,
Rows now sit snug in the terminal night,
Size in my paws, I passed it along,
Deprecated echoes hum a soft song,
Screens settle neatly — a rabbit’s small cheer! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: standardize terminal dimension naming to columns/rows' accurately and concisely describes the primary change, which is a comprehensive refactoring to standardize terminal dimension terminology throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dust-macaw

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.1)
builtins/src/main/java/org/jline/builtins/Nano.java
reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java

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

@gnodet gnodet marked this pull request as ready for review April 1, 2026 13:16
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@builtins/src/main/java/org/jline/builtins/ScreenTerminal.java`:
- Around line 1749-1750: Clamp scroll_area_y0 to rows - 1 instead of rows to
prevent an out-of-bounds index after resize: change the adjustment logic for
scroll_area_y0 (and keep the existing handling for scroll_area_y1) so that
scroll_area_y0 = Math.min(rows - 1, scroll_area_y0) (ensuring rows > 0 as
needed) and preserve the scroll_area_y1 assignment logic using height/rows;
update any adjacent bounds checks that assume scroll_area_y0 < rows to rely on
the new clamp.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ccc3499a-2247-4780-bcdf-be73fbc5c1c2

📥 Commits

Reviewing files that changed from the base of the PR and between ed150d2 and 5b21f45.

📒 Files selected for processing (35)
  • builtins/src/main/java/org/jline/builtins/Commands.java
  • builtins/src/main/java/org/jline/builtins/Less.java
  • builtins/src/main/java/org/jline/builtins/Nano.java
  • builtins/src/main/java/org/jline/builtins/PosixCommands.java
  • builtins/src/main/java/org/jline/builtins/ScreenTerminal.java
  • builtins/src/main/java/org/jline/builtins/SwingTerminal.java
  • builtins/src/main/java/org/jline/builtins/TTop.java
  • builtins/src/main/java/org/jline/builtins/Tmux.java
  • builtins/src/main/java/org/jline/builtins/WebTerminal.java
  • builtins/src/test/java/org/jline/builtins/ScreenTerminalTest.java
  • builtins/src/test/java/org/jline/example/Example.java
  • console-ui/src/main/java/org/jline/consoleui/prompt/AbstractPrompt.java
  • console-ui/src/main/java/org/jline/consoleui/prompt/ConsolePrompt.java
  • demo/src/main/java/org/apache/felix/gogo/jline/Shell.java
  • demo/src/main/java/org/jline/demo/Repl.java
  • demo/src/main/java/org/jline/demo/examples/DisplayExample.java
  • demo/src/main/java/org/jline/demo/examples/GraphemeClusterExample.java
  • demo/src/main/java/org/jline/demo/examples/MultiSegmentStatusExample.java
  • demo/src/main/java/org/jline/demo/examples/RemoteTerminalExample.java
  • demo/src/main/java/org/jline/demo/examples/ResponsiveUIExample.java
  • demo/src/main/java/org/jline/demo/examples/SwingTerminalExample.java
  • demo/src/main/java/org/jline/demo/examples/TerminalCursorExample.java
  • demo/src/main/java/org/jline/demo/examples/WebTerminalExample.java
  • jansi-core/src/main/java/org/jline/jansi/AnsiConsole.java
  • prompt/src/main/java/org/jline/prompt/impl/DefaultPrompter.java
  • reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
  • remote-ssh/src/main/java/org/jline/builtins/ssh/Ssh.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java
  • terminal/src/main/java/org/jline/terminal/Size.java
  • terminal/src/main/java/org/jline/terminal/Terminal.java
  • terminal/src/main/java/org/jline/utils/Display.java
  • terminal/src/main/java/org/jline/utils/Status.java
  • terminal/src/test/java/org/jline/utils/DisplayTest.java
  • terminal/src/test/java/org/jline/utils/ScreenTerminal.java

Comment thread builtins/src/main/java/org/jline/builtins/ScreenTerminal.java Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
builtins/src/main/java/org/jline/builtins/ScreenTerminal.java (1)

2026-2027: Consider using direct field access instead of deprecated getters.

Since dump() is already synchronized, accessing the width and height fields directly would be more efficient than calling the synchronized getWidth() and getHeight() methods (even though reentrant locks make this safe).

♻️ Suggested optimization
-        int w = getWidth();
-        int h = getHeight();
+        int w = width;
+        int h = height;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@builtins/src/main/java/org/jline/builtins/ScreenTerminal.java` around lines
2026 - 2027, The dump() method currently calls the synchronized getters
getWidth() and getHeight(), which is unnecessary because dump() is already
synchronized; replace those calls with direct field access to width and height
(use the class fields width and height inside dump()) to avoid extra
synchronization overhead while preserving thread-safety; update any nearby
similar calls in dump() that read these dimensions to use the fields instead of
getWidth()/getHeight().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@builtins/src/main/java/org/jline/builtins/ScreenTerminal.java`:
- Around line 2026-2027: The dump() method currently calls the synchronized
getters getWidth() and getHeight(), which is unnecessary because dump() is
already synchronized; replace those calls with direct field access to width and
height (use the class fields width and height inside dump()) to avoid extra
synchronization overhead while preserving thread-safety; update any nearby
similar calls in dump() that read these dimensions to use the fields instead of
getWidth()/getHeight().

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6fbf85be-5ada-4d84-a788-1a1c06d0258e

📥 Commits

Reviewing files that changed from the base of the PR and between 5b21f45 and 973dc4a.

📒 Files selected for processing (1)
  • builtins/src/main/java/org/jline/builtins/ScreenTerminal.java

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings and committed to branch dust-macaw (commit: b5b3450fb9b14dadfde69e9eb08845367e177dfa)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java (2)

875-886: Consider renaming local variables for consistency.

For consistency with the broader standardization effort, consider renaming the local variables in handleNAWS() from width/height to columns/rows. According to the Javadoc at Line 172, NAWS sends (columns, rows), so using those terms would align with both the protocol semantics and the new API naming.

♻️ Optional refactor for naming consistency
 private void handleNAWS() throws IOException {
-    int width = read16int();
-    if (width == 255) {
-        width = read16int(); // handle doubled 255 value;
+    int columns = read16int();
+    if (columns == 255) {
+        columns = read16int(); // handle doubled 255 value;
     }
-    int height = read16int();
-    if (height == 255) {
-        height = read16int(); // handle doubled 255 value;
+    int rows = read16int();
+    if (rows == 255) {
+        rows = read16int(); // handle doubled 255 value;
     }
     skipToSE();
-    setTerminalGeometry(width, height);
+    setTerminalGeometry(columns, rows);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java` around
lines 875 - 886, Rename the local variables in handleNAWS() from width/height to
columns/rows to match the NAWS semantics and the API naming; update the two
places where read16int() results are assigned (currently using the 255-double
handling comments) to assign to columns and rows respectively, and pass columns
and rows into setTerminalGeometry(columns, rows); keep all existing logic
(including skipToSE() and the doubled-255 handling) intact while only changing
the variable names and their uses.

597-597: Optional: Consider moving method to IACHandler (per SonarCloud).

SonarCloud suggests moving setTerminalGeometry into the IACHandler inner class since it's only called from IACHandler.handleNAWS(). This would improve encapsulation and cohesion, though it's unrelated to the current refactoring effort.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java` at line
597, The setTerminalGeometry method is only used by IACHandler.handleNAWS(), so
move its implementation into the IACHandler inner class to improve
encapsulation: cut the private setTerminalGeometry(int columns, int rows) method
from TelnetIO and paste it inside the IACHandler class (make it private there),
update the call in IACHandler.handleNAWS() to call the new private method, and
remove the original declaration in TelnetIO; ensure any references to
outer-class members used by the method still compile (access via TelnetIO.this
if needed) and run tests to verify no visibility/qualification issues remain.
builtins/src/main/java/org/jline/builtins/WebTerminal.java (1)

546-550: Keep this override aligned with ScreenTerminal.setSize(...).

This now overrides the parent resize API. Adding @Override and mirroring the parent's synchronized modifier would make future signature drift obvious and keep the subclass contract consistent.

Proposed change
-        public boolean setSize(int columns, int rows) {
+        `@Override`
+        public synchronized boolean setSize(int columns, int rows) {
             if (columns < 10 || rows < 5 || columns > 200 || rows > 100) {
                 return false;
             }
             return super.setSize(columns, rows);
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@builtins/src/main/java/org/jline/builtins/WebTerminal.java` around lines 546
- 550, The WebTerminal.setSize(int columns, int rows) method overrides the
parent API but lacks the `@Override` annotation and the synchronized modifier
present in ScreenTerminal.setSize(...); update the WebTerminal method to declare
synchronized and add `@Override` while keeping the same parameter list and return
behavior (preserve the bounds check and return super.setSize(columns, rows)) so
the subclass method signature and concurrency contract match the parent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@builtins/src/main/java/org/jline/builtins/WebTerminal.java`:
- Around line 546-550: The WebTerminal.setSize(int columns, int rows) method
overrides the parent API but lacks the `@Override` annotation and the synchronized
modifier present in ScreenTerminal.setSize(...); update the WebTerminal method
to declare synchronized and add `@Override` while keeping the same parameter list
and return behavior (preserve the bounds check and return super.setSize(columns,
rows)) so the subclass method signature and concurrency contract match the
parent.

In `@remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java`:
- Around line 875-886: Rename the local variables in handleNAWS() from
width/height to columns/rows to match the NAWS semantics and the API naming;
update the two places where read16int() results are assigned (currently using
the 255-double handling comments) to assign to columns and rows respectively,
and pass columns and rows into setTerminalGeometry(columns, rows); keep all
existing logic (including skipToSE() and the doubled-255 handling) intact while
only changing the variable names and their uses.
- Line 597: The setTerminalGeometry method is only used by
IACHandler.handleNAWS(), so move its implementation into the IACHandler inner
class to improve encapsulation: cut the private setTerminalGeometry(int columns,
int rows) method from TelnetIO and paste it inside the IACHandler class (make it
private there), update the call in IACHandler.handleNAWS() to call the new
private method, and remove the original declaration in TelnetIO; ensure any
references to outer-class members used by the method still compile (access via
TelnetIO.this if needed) and run tests to verify no visibility/qualification
issues remain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9dde99e2-1f6c-4174-a7c3-35bff24c8177

📥 Commits

Reviewing files that changed from the base of the PR and between 973dc4a and 5fbc81e.

📒 Files selected for processing (33)
  • builtins/src/main/java/org/jline/builtins/Commands.java
  • builtins/src/main/java/org/jline/builtins/Less.java
  • builtins/src/main/java/org/jline/builtins/Nano.java
  • builtins/src/main/java/org/jline/builtins/PosixCommands.java
  • builtins/src/main/java/org/jline/builtins/ScreenTerminal.java
  • builtins/src/main/java/org/jline/builtins/SwingTerminal.java
  • builtins/src/main/java/org/jline/builtins/TTop.java
  • builtins/src/main/java/org/jline/builtins/Tmux.java
  • builtins/src/main/java/org/jline/builtins/WebTerminal.java
  • builtins/src/test/java/org/jline/example/Example.java
  • console-ui/src/main/java/org/jline/consoleui/prompt/AbstractPrompt.java
  • console-ui/src/main/java/org/jline/consoleui/prompt/ConsolePrompt.java
  • demo/src/main/java/org/apache/felix/gogo/jline/Shell.java
  • demo/src/main/java/org/jline/demo/Repl.java
  • demo/src/main/java/org/jline/demo/examples/DisplayExample.java
  • demo/src/main/java/org/jline/demo/examples/GraphemeClusterExample.java
  • demo/src/main/java/org/jline/demo/examples/MultiSegmentStatusExample.java
  • demo/src/main/java/org/jline/demo/examples/RemoteTerminalExample.java
  • demo/src/main/java/org/jline/demo/examples/ResponsiveUIExample.java
  • demo/src/main/java/org/jline/demo/examples/SwingTerminalExample.java
  • demo/src/main/java/org/jline/demo/examples/TerminalCursorExample.java
  • demo/src/main/java/org/jline/demo/examples/WebTerminalExample.java
  • jansi-core/src/main/java/org/jline/jansi/AnsiConsole.java
  • prompt/src/main/java/org/jline/prompt/impl/DefaultPrompter.java
  • reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
  • remote-ssh/src/main/java/org/jline/builtins/ssh/Ssh.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java
  • terminal/src/main/java/org/jline/terminal/Size.java
  • terminal/src/main/java/org/jline/terminal/Terminal.java
  • terminal/src/main/java/org/jline/utils/Display.java
  • terminal/src/main/java/org/jline/utils/Status.java
  • terminal/src/test/java/org/jline/utils/ScreenTerminal.java
✅ Files skipped from review due to trivial changes (11)
  • demo/src/main/java/org/jline/demo/examples/DisplayExample.java
  • demo/src/main/java/org/jline/demo/examples/ResponsiveUIExample.java
  • jansi-core/src/main/java/org/jline/jansi/AnsiConsole.java
  • demo/src/main/java/org/jline/demo/examples/RemoteTerminalExample.java
  • builtins/src/main/java/org/jline/builtins/PosixCommands.java
  • builtins/src/main/java/org/jline/builtins/TTop.java
  • builtins/src/main/java/org/jline/builtins/Less.java
  • terminal/src/main/java/org/jline/utils/Status.java
  • demo/src/main/java/org/jline/demo/Repl.java
  • prompt/src/main/java/org/jline/prompt/impl/DefaultPrompter.java
  • builtins/src/test/java/org/jline/example/Example.java
🚧 Files skipped from review as they are similar to previous changes (10)
  • demo/src/main/java/org/jline/demo/examples/TerminalCursorExample.java
  • demo/src/main/java/org/jline/demo/examples/WebTerminalExample.java
  • demo/src/main/java/org/jline/demo/examples/SwingTerminalExample.java
  • demo/src/main/java/org/jline/demo/examples/MultiSegmentStatusExample.java
  • console-ui/src/main/java/org/jline/consoleui/prompt/AbstractPrompt.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java
  • terminal/src/test/java/org/jline/utils/ScreenTerminal.java
  • reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
  • builtins/src/main/java/org/jline/builtins/SwingTerminal.java
  • builtins/src/main/java/org/jline/builtins/Tmux.java

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
builtins/src/main/java/org/jline/builtins/ScreenTerminal.java (1)

2068-2072: Consider renaming local variable to avoid shadowing field.

The local variable screen at line 2070 shadows the instance field screen declared at line 83. While this doesn't cause a bug (the method logic is correct), it reduces readability. Consider renaming to screenBuffer or dumpBuffer.

♻️ Suggested rename
         int cols = getColumns();
         int rows = getRows();
-        long[] screen = new long[cols * rows];
+        long[] screenBuffer = new long[cols * rows];
         int[] cursor = new int[2];
-        if (!dump(timeout, forceDump, screen, cursor)) {
+        if (!dump(timeout, forceDump, screenBuffer, cursor)) {
             return null;
         }

And update references at lines 2082:

-                long d = screen[y * cols + x];
+                long d = screenBuffer[y * cols + x];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@builtins/src/main/java/org/jline/builtins/ScreenTerminal.java` around lines
2068 - 2072, The local variable named "screen" in the method shadows the
instance field "screen"; rename the local to a clearer name (e.g., screenBuffer
or dumpBuffer) and update all its references in this method (including the call
to dump(timeout, forceDump, screen, cursor) and subsequent usages) so the method
no longer shadows the instance field and readability is improved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@builtins/src/main/java/org/jline/builtins/ScreenTerminal.java`:
- Around line 2068-2072: The local variable named "screen" in the method shadows
the instance field "screen"; rename the local to a clearer name (e.g.,
screenBuffer or dumpBuffer) and update all its references in this method
(including the call to dump(timeout, forceDump, screen, cursor) and subsequent
usages) so the method no longer shadows the instance field and readability is
improved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94e8ba1d-6429-4f2d-a156-bc55123737b0

📥 Commits

Reviewing files that changed from the base of the PR and between 6becb31 and 36d9322.

📒 Files selected for processing (1)
  • builtins/src/main/java/org/jline/builtins/ScreenTerminal.java

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@terminal/src/main/java/org/jline/utils/Display.java`:
- Around line 196-199: The Javadoc for Display.reset() is misleading because the
method only clears the cached oldLines but does not force a full repaint; update
the implementation of Display.reset() to both clear the cached model (oldLines)
and set the internal repaint flag (reset = true) and/or issue a terminal clear
so the next render repaints the entire display; locate the reset() method and
ensure it resets oldLines and toggles the reset flag used by render() (or
invokes the same code path as a full clear) so no stale content remains.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1018f654-29c0-41fe-82f1-437528c9ed0b

📥 Commits

Reviewing files that changed from the base of the PR and between 6becb31 and 569f154.

📒 Files selected for processing (9)
  • builtins/src/main/java/org/jline/builtins/ScreenTerminal.java
  • builtins/src/main/java/org/jline/builtins/SwingTerminal.java
  • demo/src/main/java/org/jline/demo/examples/DisplayExample.java
  • demo/src/main/java/org/jline/demo/examples/MultiSegmentStatusExample.java
  • demo/src/main/java/org/jline/demo/examples/ResponsiveUIExample.java
  • demo/src/main/java/org/jline/demo/examples/TerminalCursorExample.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java
  • terminal/src/main/java/org/jline/terminal/Terminal.java
  • terminal/src/main/java/org/jline/utils/Display.java
✅ Files skipped from review due to trivial changes (2)
  • demo/src/main/java/org/jline/demo/examples/DisplayExample.java
  • demo/src/main/java/org/jline/demo/examples/ResponsiveUIExample.java
🚧 Files skipped from review as they are similar to previous changes (5)
  • demo/src/main/java/org/jline/demo/examples/TerminalCursorExample.java
  • demo/src/main/java/org/jline/demo/examples/MultiSegmentStatusExample.java
  • builtins/src/main/java/org/jline/builtins/SwingTerminal.java
  • builtins/src/main/java/org/jline/builtins/ScreenTerminal.java
  • remote-telnet/src/main/java/org/jline/builtins/telnet/TelnetIO.java

Comment thread terminal/src/main/java/org/jline/utils/Display.java
@gnodet gnodet added this to the 4.1.0 milestone Apr 1, 2026
@gnodet gnodet force-pushed the dust-macaw branch 2 times, most recently from d9bf560 to bca81d1 Compare April 1, 2026 19:09
@Elec332 Elec332 mentioned this pull request Apr 1, 2026
@gnodet gnodet merged commit 7d21f09 into master Apr 8, 2026
1 of 10 checks passed
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 8, 2026

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant