Remove redundant write function in Bun terminal_io implementation

This commit is contained in:
Timothy Warren 2024-01-09 10:52:11 -05:00
parent f5599b5192
commit 30230520a0
1 changed files with 3 additions and 4 deletions

View File

@ -20,15 +20,14 @@ const BunTerminalIO: ITerminal = {
},
getTerminalSize: async function getTerminalSize(): Promise<ITerminalSize> {
const encoder = new TextEncoder();
const write = (s: string) => Bun.write(Bun.stdout, encoder.encode(s));
// Tell the cursor to move to Row 999 and Column 999
// Since this command specifically doesn't go off the screen
// When we ask where the cursor is, we should get the size of the screen
await write(Ansi.moveCursorForward(999) + Ansi.moveCursorDown(999));
await BunTerminalIO.writeStdout(Ansi.moveCursorForward(999) + Ansi.moveCursorDown(999));
// Ask where the cursor is
await write(Ansi.GetCursorLocation);
await BunTerminalIO.writeStdout(Ansi.GetCursorLocation);
// Get the first chunk from stdin
// The response is \x1b[(rows);(cols)R..
@ -44,7 +43,7 @@ const BunTerminalIO: ITerminal = {
const cols = parseInt(scols, 10) ?? 80;
// Clear the screen
await write(Ansi.ClearScreen + Ansi.ResetCursor);
await BunTerminalIO.writeStdout(Ansi.ClearScreen + Ansi.ResetCursor);
return {
rows,