Skip to content

Commit

Permalink
feat(phoenix): Make clear clear scrollback unless -x is given
Browse files Browse the repository at this point in the history
From what I understand, we shouldn't need both `\x1B[2J` and `\x1B[3J`
sequences to clear everything, but xterm.js would not correctly clear
the visible region with only `\x1B[3J`. So, we have both.
  • Loading branch information
AtkinsSJ authored and KernelDeimos committed Jul 1, 2024
1 parent d76e713 commit 75a989a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/phoenix/src/puter-shell/coreutils/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ export default {
usage: 'clear',
description: 'Clear the terminal output.',
args: {
// TODO: add 'none-parser'
$: 'simple-parser',
allowPositionals: false
allowPositionals: false,
options: {
'keep-scrollback': {
description: 'Only clear the visible portion of the screen, and keep the scrollback.',
type: 'boolean',
short: 'x',
}
},
},
execute: async ctx => {
await ctx.externs.out.write('\x1B[H\x1B[2J');
if (!ctx.locals.values['keep-scrollback'])
await ctx.externs.out.write('\x1B[H\x1B[3J');
}
};

0 comments on commit 75a989a

Please sign in to comment.