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 2024-06-26 20:01:01 +01:00 committed by Eric Dubé
parent d76e7130cb
commit 75a989a7b6

View File

@ -21,11 +21,19 @@ export default {
usage: 'clear', usage: 'clear',
description: 'Clear the terminal output.', description: 'Clear the terminal output.',
args: { args: {
// TODO: add 'none-parser'
$: 'simple-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 => { execute: async ctx => {
await ctx.externs.out.write('\x1B[H\x1B[2J'); await ctx.externs.out.write('\x1B[H\x1B[2J');
if (!ctx.locals.values['keep-scrollback'])
await ctx.externs.out.write('\x1B[H\x1B[3J');
} }
}; };