All Projects → enquirer → Readline Utils

enquirer / Readline Utils

Licence: mit
This repository has been archived, use Enquirer instead.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Readline Utils

Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (+253.33%)
Mutual labels:  readline, cursor
Postgresql cursor
ActiveRecord PostgreSQL Adapter extension for using a cursor to return a large result set
Stars: ✭ 384 (+2460%)
Mutual labels:  cursor
repline
Haskeline wrapper for GHCi-like REPL interfaces
Stars: ✭ 98 (+553.33%)
Mutual labels:  readline
PrettyPrompt
A cross-platform command line prompt library that provides syntax highlighting, autocompletion, history and multi-line input.
Stars: ✭ 45 (+200%)
Mutual labels:  readline
fastener
Functional Zipper for manipulating JSON
Stars: ✭ 54 (+260%)
Mutual labels:  cursor
React Native Input Scroll View
Perfect TextInput ScrollView
Stars: ✭ 323 (+2053.33%)
Mutual labels:  cursor
EyeControlledCursor
Controlling mouse cursor from eye.
Stars: ✭ 36 (+140%)
Mutual labels:  cursor
Readline Sync
Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).
Stars: ✭ 601 (+3906.67%)
Mutual labels:  readline
Paginator
Cursor-based pagination for Elixir Ecto
Stars: ✭ 374 (+2393.33%)
Mutual labels:  cursor
ng-caret-aware
AngularJS directive for caret aware elements
Stars: ✭ 12 (-20%)
Mutual labels:  cursor
markee
Visual text selection
Stars: ✭ 22 (+46.67%)
Mutual labels:  cursor
multi-cursor
🎉
Stars: ✭ 44 (+193.33%)
Mutual labels:  cursor
Console
The Hoa\Console library.
Stars: ✭ 354 (+2260%)
Mutual labels:  readline
enquirer
Stylish, intuitive and user-friendly prompts, for Node.js. Used by eslint, webpack, yarn, pm2, pnpm, RedwoodJS, FactorJS, salesforce, Cypress, Google Lighthouse, Generate, tencent cloudbase, lint-staged, gluegun, hygen, hardhat, AWS Amplify, GitHub Actions Toolkit, @airbnb/nimbus, and many others! Please follow Enquirer's author: https://github.…
Stars: ✭ 6,523 (+43386.67%)
Mutual labels:  readline
Replxx
A readline and libedit replacement that supports UTF-8, syntax highlighting, hints and Windows and is BSD licensed.
Stars: ✭ 446 (+2873.33%)
Mutual labels:  readline
macOS-cursors-for-Windows
Tested in Windows 10 & 11, 4K, 125%, 150%, 200%. With 2 versions, 2 types and 3 different sizes!
Stars: ✭ 578 (+3753.33%)
Mutual labels:  cursor
mongoose-graphql-pagination
GraphQL cursor pagination (Relay-like) for Mongoose models.
Stars: ✭ 29 (+93.33%)
Mutual labels:  cursor
Mongoose Paginate V2
A cursor based custom pagination library for Mongoose with customizable labels.
Stars: ✭ 283 (+1786.67%)
Mutual labels:  cursor
Readline
A Pure C# GNU-Readline like library for .NET/.NET Core
Stars: ✭ 740 (+4833.33%)
Mutual labels:  readline
Switch.vim
A simple Vim plugin to switch segments of text with predefined replacements
Stars: ✭ 506 (+3273.33%)
Mutual labels:  cursor

readline-utils NPM version NPM monthly downloads NPM total downloads Linux Build Status Windows Build Status

Readline utils, for moving the cursor, clearing lines, creating a readline interface, and more.

Install

Install with npm:

$ npm install --save readline-utils

Usage

var utils = require('readline-utils');

API

.createInterface

Create a readline interface with the given options.

Params

  • options {Object}

.up

Move cursor up by n lines.

Params

  • rl {Readline}: Readline interface
  • n {Number}: Lines up to move. Default is 1.

.down

Move cursor down by n lines.

Params

  • rl {Readline}: Readline interface
  • n {Number}: Lines down to move. Default is 1.

.left

Move cursor left by n colums.

Params

  • rl {Readline}: Readline interface
  • n {Number}: Characters to move left. Default is 1.

.right

Move cursor right by n colums.

Params

  • rl {Readline}: Readline interface
  • n {Number}: Characters to move right. Default is 1.

.move

Move cursor up, down, left or right by 1 line.

Params

  • rl {Readline}: Readline interface

Example

var utils = require('readline-utils');
var rl = utils.createInterface();
rl.input.on('keypress', function(str, key) {
  utils.move(rl, key);
});

.auto

Callback function for the keypress event, to automatically move cursor up, down, left or right by 1 line.

Params

  • rl {Readline}: Readline interface

Example

var utils = require('readline-utils');
var rl = utils.createInterface();
rl.input.on('keypress', utils.auto(rl));

.clearAfter

Clear n lines after the cursor.

Params

  • rl {Readline}: Readline interface
  • n {Number}: Number of lines to clear

.clearScreen

Clear the terminal.

Params

  • rl {Readline}: Readline interface
  • n {Number}: Number of lines to clear

.lastLine

Get the last line from the given str

Params

  • str {String}
  • returns {String}

.height

Get the height (rows) of the given str

Params

  • str {String}
  • returns {Number}

.hideCursor

Hide the cursor so it doesn't show during a prompt. This is useful for multiple-choice or list prompts, or any prompt where the user will not be entering input.

Params

  • rl {Readline}: Readline interface
  • returns {Object}: readline-utils object for chaining

.showCursor

Show the cursor.

Params

  • rl {Readline}: Readline interface
  • returns {Object}: readline-utils object for chaining

.close

Close the interface, remove event listeners, and restore/unmute prompt functionality

Params

  • rl {Readline}: Readline interface
  • returns {Object}: readline-utils object for chaining

.forceClose

Close the interface when the keypress is ^C

Params

  • rl {Readline}: Readline interface
  • returns {Object}: readline-utils object for chaining

.eraseLines

Erase n lines

Params

  • n {Number}
  • returns {String}: Returns the unicode to erase lines

Example

utils.eraseLines(3);

.clearTrailingLines

Remove lines from the bottom of the terminal.

Params

  • rl {Number}: Readline interface
  • lines {Number}: Number of lines to remove
  • height {Number}: Content height
  • returns {Object}: Returns the readline-utils object for chaining

.cursorPosition

Remember the cursor position

  • returns {Object}: readline-utils object

.restoreCursorPos

Restore the cursor position to where it has been previously stored.

  • returns {Object}: readline-utils object

.cliWidth

Get the width of the terminal

Params

  • fallback {Number}: A fallback width to use if the actual width is not found.
  • returns {Number}: Returns the number of columns.

.breakLines

Break lines longer than the cli width so we can normalize the natural line returns behavior accross terminals. (I don't see how this can work consistently. It seems brittle and will probably be replaced with https://github.com/jonschlinkert/word-wrap)

Params

  • lines {Array}: Array of lines
  • width {Number}: Terminal width

.forceLineReturn

Joins the lines returned from .breakLines.

Params

  • lines {Array|String}: String or array of lines.
  • width {Number}: Terminal width
  • returns {String}

.normalizeLF

Ensure the given str ends in a newline.

Params

  • str {String}: The input string
  • returns {String}

Example

console.log(utils.normalizeLF('foo'));
//=> 'foo\n'

.keypress

This module offers the internal "keypress" functionality from node-core's readline module, for your own programs and modules to use.

The keypress function accepts a readable Stream instance and makes it emit "keypress" events. Usage:

Params

  • {Stream}: stream

Example

require('keypress')(process.stdin);

process.stdin.on('keypress', function(ch, key) {
  console.log(ch, key);
  if (key.ctrl && key.name === 'c') {
    process.stdin.pause();
  }
});
proces.stdin.resume();

.enableMouse

Enables "mousepress" events on the input stream. Note that stream must be an output stream (i.e. a Writable Stream instance), usually process.stdout.

Params

  • {Stream}: stream writable stream instance

.disableMouse

Disables "mousepress" events from being sent to the input

stream. Note that stream must be an output stream (i.e. a Writable Stream instance), usually process.stdout.

Params

  • {Stream}: stream writable stream instance

Attribution

Some of this code was initially borrowed from [Inquirer][].

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Contributors

Commits Contributor
44 jonschlinkert
18 doowb

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on July 11, 2017.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].