Warning:
You MUST import process before importing this module. Uses stdout by default.
Example:
import src/nodejs/jsreadline import std/jsffi import jsprocess requireProcess() requireReadline() block: doAssert clearLine() doAssert clearScreenDown() doAssert cursorTo(x = 0.cint, y = 0.cint) doAssert moveCursor(dx = 0.cint, dy = 0.cint) block: let rl: Readline = newReadline() rl.setPrompt(">>>".cstring) # doAssert rl.getPrompt() == ">>>".cstring doAssert rl.getCursorPos() is JsObject rl.pause() rl.resume() rl.write("data".cstring) rl.close() # echo rl.line() # echo rl.cursor()
Example: cmd: -r:off
import src/nodejs/jsreadline import jsprocess requireProcess() requireReadline() let rl = newReadline() echo rl.line()
Types
Readline = ref object of JsRoot
- https://nodejs.org/api/readline.html#readline_readline
Procs
func clearLine(dir = 0.cint): bool {.importjs: "readline.$1(process.stout, #)", ...raises: [], tags: [].}
- https://nodejs.org/docs/latest/api/readline.html#readline_readline_clearline_stream_dir_callback
func clearScreenDown(): bool {.importjs: "readline.$1(process.stout)", ...raises: [], tags: [].}
- https://nodejs.org/docs/latest/api/readline.html#readline_readline_clearscreendown_stream_callback
func close(self: Readline) {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_close
func cursor(self: Readline): int {.importjs: "(() => { return #.cursor })()", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_cursor
func cursorTo(x, y: cint): bool {.importjs: "readline.$1(process.stout, #, #)", ...raises: [], tags: [].}
- https://nodejs.org/docs/latest/api/readline.html#readline_readline_cursorto_stream_x_y_callback
func getCursorPos(self: Readline): JsObject {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_getcursorpos
func getPrompt(self: Readline): cstring {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_getprompt
func importReadline() {.importjs: "import * as readline from \'readline\'@", ...raises: [], tags: [].}
- Alias for import * as module_name from 'module_name';. Must be called once before using the module
func line(self: Readline): cstring {.importjs: "(() => { return #.line })()", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_line
func moveCursor(dx, dy: cint): bool {.importjs: "readline.$1(process.stout, #, #)", ...raises: [], tags: [].}
- https://nodejs.org/docs/latest/api/readline.html#readline_readline_movecursor_stream_dx_dy_callback
func newReadline(): Readline {.importjs: "readline.createInterface({input: process.stdin, output: process.stdout})", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_readline
func pause(self: Readline) {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_pause
func prompt(self: Readline; preserveCursor: bool) {.importjs: "#.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_prompt_preservecursor
func question[T](self: Readline; query: cstring; callback: T) {. importjs: "#.$1(#, #)", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_question_query_options_callback
func requireReadline() {.importjs: "const readline = require(\'readline\')@", ...raises: [], tags: [].}
- Alias for const module_name = require('module_name');. Must be called once before using the module
func resume(self: Readline) {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_resume
func setPrompt(self: Readline; prompt: cstring) {.importjs: "#.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_setprompt_prompt
func write(self: Readline; data: cstring) {.importjs: "#.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_write_data_key
func write(self: Readline; data: cstring; ctrl: bool; meta: bool; shift: bool; name: cstring) {.importjs: "#.$1(#, {ctrl: #, meta: #, shift: #, name: #})", ...raises: [], tags: [].}
- https://nodejs.org/api/readline.html#readline_rl_write_data_key