Skip to content

Commit

Permalink
feat(cli): swap screen buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
RexSkz committed Feb 3, 2024
1 parent f0d1e69 commit 49ec424
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cli/show-in-terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ let columns = terminal.width;
let rows = terminal.height;

const showInTerminal = ([leftResult, rightResult]: readonly [DiffResult[], DiffResult[]]) => {
// Swap to an alternate screen buffer
// https://github.com/vadimdemedes/ink/issues/263#issuecomment-600927688
const enterAltScreenCommand = '\x1b[?1049h';
const leaveAltScreenCommand = '\x1b[?1049l';
process.stdout.write(enterAltScreenCommand);
process.on('exit', () => {
process.stdout.write(leaveAltScreenCommand);
});

showContent(leftResult, rightResult, columns, rows);

terminal.on('resize', (newColumns: number, newRows: number) => {
Expand Down

0 comments on commit 49ec424

Please sign in to comment.