1.0.5 • Published 2 years ago

simple-terminal v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

API

Simple Terminal is a module aimed at allowing users to quickly begin building basic terminal applications in node such as text games or CLI utilities.

It's built to intercept and relay keypresses using the input-handler module. And is built to be an automated module. You can technically manually render but it's not recommended.

You can instantiate a terminal as follows:

// You'll only need these two lines if you want to semi-manually render the terminal.
let simpleTerminal = require('simple-terminal');
let terminal = new simpleTerminal();

// If you want this to be handled automatically you can add this line.
// By default it will rely on input-handler to intercept keypresses.
termial.automate();

For interfacing with the terminal you have the collowing options:

// You can intercept extraneous keypresses.
terminal.on('keypress', (key) => {
	terminal.print(`Key "${key.name}" was pressed`);
});

// You can intercept typed user input
terminal.on('inputSent', (query) => {
	terminal.print (`User typed: "${query.input}"`)
})

// You can intercept when the terminal is ready for use.
terminal.on('ready', () => {
	terminal.print('Ready!');
})

// You can push new messages to the terminal, like this
terminal.print('Hello, World!');

// You can manually force the terminal to render.
terminal.render();
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago