Mqxx / deno_ansi

An ANSI escape codes library for Deno.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

deno_ansi

An ANSI escape codes library for Deno.

cursor

Cursor object.

syntax
const cursor: {...}


cursor.home()

Moves the cursor to the top left corner of the terminal.

syntax
function home() : Promise<void>
example
await cursor.home();


cursor.moveTo()

Moves the cursor to a specific position in the terminal. The index starts from 0.

If the position is positive outside the terminal, then the cursor is placed in the bottom right corner.
If the position is negative outside the terminal, then the cursor is placed in the top left corner.

syntax
function moveTo(position : cursorPosition) : Promise<void>
example
// Moves the cursor to the 10th row and to the 20th column.
await cursor.moveTo({row: 9, column: 19});


cursor.moveUp()

Moves the cursor a specified amount of rows up. The position in the column remains the same.

If the number is greater than the cursor can move up, then the cursor gets moved all the way up.

syntax
function moveUp(amount? : number) : Promise<void>
example
// Moves the cursor 5 rows up.
await cursor.moveUp(5);


cursor.moveDown()

Moves the cursor a specified amount of rows down. The position in the column remains the same.

If the number is greater than the cursor can move down, then the cursor gets moved all the way down.

syntax
function moveDown(amount? : number) : Promise<void>
example
// Moves the cursor 7 rows down.
await cursor.moveDown(7);


cursor.moveRight()

Moves the cursor a specified amount of columns to the right. The position in the row remains the same.

If the number is greater than the cursor can move to the right, then the cursor gets moved all the way to the right side.

syntax
function moveRight(amount? : number) : Promise<void>
example
// Moves the cursor 3 columns to the right.
await cursor.moveRight(3);


cursor.moveLeft()

Moves the cursor a specified amount of columns to the left. The position in the row remains the same.

If the number is greater than the cursor can move to the left, then the cursor gets moved all the way to the left side.

syntax
function moveLeft(amount? : number) : Promise<void>
example
// Moves the cursor 6 columns to the left.
await cursor.moveLeft(6);


cursor.moveDownStart()

Moves the cursor a specified amount of rows down. The position in the column is reset to the start.

If the number is greater than the cursor can move down, then the cursor gets moved all the way down.

syntax
function moveDownStart(amount? : number) : Promise<void>
example
// Moves the cursor 2 rows down.
await cursor.moveDownStart(2);


cursor.moveUpStart()

Moves the cursor a specified amount of columns up. The position in the column is reset to the start.

If the number is greater than the cursor can move up, then the cursor gets moved all the way up.

syntax
function moveUpStart(amount? : number) : Promise<void>
example
// Moves the cursor 2 rows up.
await cursor.moveUpStart(2);


cursor.moveToColumn()

Sets the cursor to an absolute position in the column. The position in the row remains the same.

If the absolute position is positive outside the terminal, then the cursor is set to the right side. If the absolute position is negative outside the terminal, then the cursor is set to the left side.

syntax
function moveToColumn(to : number) : Promise<void>
example
// Sets the cursor to the 9th absolute column.
await cursor.moveToColumn(9);


cursor.getPosition()

Get the current absolute position of the cursor.

syntax
function getPosition() : Promise<cursorPosition>
example
// Get the absolut cursor position.
const position = await cursor.getPosition();

// Log the row and column position
console.log(`Row: ${position.row}, Column: ${position.column}`);


cursor.savePosition()

Save the current absolute position of the cursor.

The position is stored internally. Only one position can be saved at a time.

syntax
function savePosition() : Promise<void>
example
await cursor.savePosition();


cursor.restorePosition()

Restore the currently saved absolute position of the cursor.

syntax
function restorePosition() : Promise<void>
example
await cursor.restorePosition();


cursor.show()

Show the cursor.

syntax
function show() : Promise<void>
example
await cursor.show();


cursor.hide()

Hide the cursor.

syntax
function hide() : Promise<void>
example
await cursor.hide();

About

An ANSI escape codes library for Deno.

License:GNU General Public License v2.0


Languages

Language:TypeScript 100.0%