feat(phoenix): Make clear clear scrollback unless -x is given

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.
This commit is contained in:
Sam Atkins authored and Eric Dubé committed 2024-07-01 13:59:43 -04:00
1 parent d76e7130cb
commit 75a989a7b6
1 file changed
+10 -2
@@ -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');
}
};