wrappers/linenoise/linenoise

  Source   Edit

Types

CompletionCallback = proc (a2: cstring; a3: ptr Completions) {.cdecl.}
  Source   Edit
Completions = object
  len*: csize_t
  cvec*: cstringArray
  Source   Edit
LinenoiseData = object
  status: LinenoiseStatus
  Source   Edit
ReadLineResult = object
  line*: string
  status*: Status
  Source   Edit
Status = enum
  lnCtrlUnkown, lnCtrlC, lnCtrlD
  Source   Edit

Procs

proc addCompletion(a2: ptr Completions; a3: cstring) {.
    importc: "linenoiseAddCompletion", ...raises: [], tags: [].}
  Source   Edit
proc clearScreen() {.importc: "linenoiseClearScreen", ...raises: [], tags: [].}
  Source   Edit
proc free(s: cstring) {.importc: "free", header: "<stdlib.h>", ...raises: [],
                        tags: [].}
  Source   Edit
proc historyAdd(line: cstring): cint {.importc: "linenoiseHistoryAdd",
                                       discardable, ...raises: [], tags: [].}
  Source   Edit
proc historyLoad(filename: cstring): cint {.importc: "linenoiseHistoryLoad",
    ...raises: [], tags: [].}
  Source   Edit
proc historySave(filename: cstring): cint {.importc: "linenoiseHistorySave",
    ...raises: [], tags: [].}
  Source   Edit
proc historySetMaxLen(len: cint): cint {.importc: "linenoiseHistorySetMaxLen",
    ...raises: [], tags: [].}
  Source   Edit
proc printKeyCodes() {.importc: "linenoisePrintKeyCodes", ...raises: [], tags: [].}
  Source   Edit
proc readLine(prompt: cstring): cstring {.importc: "linenoise", ...raises: [],
    tags: [].}
  Source   Edit
proc readLineStatus(prompt: string; result: var ReadLineResult) {....raises: [],
    tags: [].}
line editing API that allows returning the line entered and an indicator of which control key was entered, allowing user to distinguish between for example ctrl-C vs ctrl-D.

Example: cmd: -d:nimExperimentalLinenoiseExtra -r:off

var ret: ReadLineResult
while true:
  readLineStatus("name: ", ret) # ctrl-D will exit, ctrl-C will go to next prompt
  if ret.line.len > 0: echo ret.line
  if ret.status == lnCtrlD: break
echo "exiting"
  Source   Edit
proc setCompletionCallback(a2: CompletionCallback) {.
    importc: "linenoiseSetCompletionCallback", ...raises: [], tags: [].}
  Source   Edit
proc setMultiLine(ml: cint) {.importc: "linenoiseSetMultiLine", ...raises: [],
                              tags: [].}
  Source   Edit