Giter Site home page Giter Site logo

sdgluck / node-crossterm Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 2.33 MB

Node bindings for Rust's crossterm

License: MIT License

JavaScript 24.75% Rust 64.32% Batchfile 6.82% Visual Basic 4.10%
nodejs rust terminal cursor-position node-native node-module

node-crossterm's Introduction

node-crossterm

Node bindings for Rust's crossterm

Install

$ npm install node-crossterm

Example

const crossterm = require("node-crossterm");
crossterm.clear(crossterm.ClearType.All);
crossterm.goto(13, 37);
crossterm.pos();

API

All methods of Terminal and TerminalCursor are available as methods on the default export.

Other features of crossterm like AlternateScreen and Screen are not available in this library (yet).

Cursor

crossterm.pos()

Get the terminal cursor position.

Returns object with x and y properties.

crossterm.set_pos(x, y)

Set terminal cursor position.

crossterm.move_{up,down,right,left}(n)

Move the terminal cursor by n in direction specified by function name.

crossterm.save_position()

Save the terminal cursor position.

crossterm.reset_position()

Restore the terminal cursor position.

crossterm.hide()

Hide the terminal cursor.

crossterm.show()

Show the terminal cursor.

crossterm.blink(b)

Set cursor blink on or off.

Terminal

crossterm.ClearType

JavaScript equivalent of crossterm ClearType enum.

{
    All,
    FromCursorDown,
    FromCursorUp,
    CurrentLine,
    UntilNewLine
}

crossterm.clear(clear_type)

Clear the terminal according to the given clear_type.

// Example: clear all lines of the terminal
crossterm.clear(crossterm.ClearType.All);

crossterm.terminal_size()

Get the terminal size.

Returns object with width and height properties.

crossterm.scroll_up(n)

Scroll the terminal up n rows.

crossterm.scroll_down(n)

Scroll the terminal down n rows.

crossterm.set_size(width, height)

Set the terminal width and height.

crossterm.exit()

Exit the current process.

crossterm.write(str)

Write a string to the terminal.

Terminal Support

From the crossterm docs:

  • Windows Powershell
    • Windows 10 (pro)
  • Windows CMD
    • Windows 10 (pro)
    • Windows 8.1 (N)
  • Ubuntu Desktop Terminal
    • Ubuntu 17.10
  • (Arch, Manjaro) KDE Konsole
  • Linux Mint

License

MIT © Sam Gluck

node-crossterm's People

Contributors

sdgluck avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.