Skip to content

wolfterm: fix CSI erase modes and SGR on Windows - #1390

Open
ejohnstown wants to merge 3 commits into
wolfSSL:masterfrom
ejohnstown:wolfterm-csi
Open

ejohnstown wants to merge 3 commits into
wolfSSL:masterfrom
ejohnstown:wolfterm-csi

Conversation

@ejohnstown

@ejohnstown ejohnstown commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

The Windows console translator handles ED and EL modes 0-2 as ECMA-48
does and keeps every SGR attribute in one sequence.

  • ED keeps the scrollback above the window and clears to the buffer end
  • ESC[1;31m keeps the bold; SGR 0 resets mid-sequence
  • api-test checks the cells and attributes on an off-screen buffer

Issue: F-10556, F-11663, F-12549, F-15506

@ejohnstown

Copy link
Copy Markdown
Contributor Author

@claude review

Comment thread src/wolfterm.c Resolved
Comment thread src/wolfterm.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-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.

Fenrir Automated Review — PR #1390

Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

The Windows console translator handles ED and EL modes as ECMA-48 does:
an omitted mode is 0, mode 0 erases from the cursor to the end, mode 1
from the start through the cursor cell, and mode 2 the whole display or
line. Mode 1J now clears the display rows above the cursor too.

- ED 0-2 keep the scrollback above the console window; a window that
  does not hold the cursor is moved to it first
- ED 0 and 2 clear through the last buffer row, because CSI H addresses
  buffer rows and `clear` would otherwise leave old text below the
  first screen
- wolfSSH_ClearScreen() wraps at the buffer width, not the maximum
  window width

Issue: F-10556, F-12549
doDisplayAttributes() starts from the current console attributes,
applies each SGR argument to that value in order, and sets the result
once, so ESC[1;31m keeps the bold. SGR 0 resets to the default
attributes mid-sequence.

- SGR 25 (blink off) is a no-op; there is no blink to turn off

Issue: F-11663, F-15506
test_wolfSSH_ConvertConsole_csi() runs ED, EL and SGR sequences against
an off-screen console buffer and reads back the cells and attributes.
It repeats ED 0-2 with the window scrolled down two rows to check that
the rows outside it are kept. It returns early when no console is
attached.

Issue: F-10556, F-12549, F-11663, F-15506
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.

3 participants