Skip to content

Decouple alternate buffer switching from clearing#14

Merged
cowboyd merged 1 commit into
mainfrom
decouple-altbuffer-clear
Apr 17, 2026
Merged

Decouple alternate buffer switching from clearing#14
cowboyd merged 1 commit into
mainfrom
decouple-altbuffer-clear

Conversation

@cowboyd
Copy link
Copy Markdown
Contributor

@cowboyd cowboyd commented Apr 17, 2026

Motivation

alternateBuffer() uses xterm private mode 1049, which clears the alternate buffer every time it is entered. This makes it impossible to toggle between main and alternate buffers without losing the alternate buffer's contents.

Closes #13

Approach

Add a { clear?: boolean } option to ALTSCREEN() in termcodes.ts. When clear is false, it emits mode 47 instead of 1049, which switches to the alternate buffer without clearing it. The option is threaded through alternateBuffer() in settings.ts. MAINSCREEN() always uses mode 1049 since the clear concern only applies on entry.

Add `{ clear?: boolean }` option to `ALTSCREEN()` and
`alternateBuffer()`. When `clear` is false, uses xterm private mode 47
to switch without clearing the alternate buffer contents.

Closes #13
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 17, 2026

Open in StackBlitz

npm i https://pkg.pr.new/clayterm@14

commit: a42ed95

@cowboyd cowboyd merged commit a6b1ee1 into main Apr 17, 2026
5 checks passed
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.

Decouple alternate buffer switching from clearing

1 participant