☰

# std/linenoise

Theme:

- Manual
- Standard library
- Index
- Compiler docs
- Fusion docs
- devel, stable

Search:
Source Edit

# Types

    CompletionCallback = proc (a2: cstring; a3: ptr Completions) {.cdecl.}

  Source Edit

    Completions = object
      len*: csize_t
      cvec*: cstringArray

  Source Edit

    LinenoiseData = object

  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: [], forbids: [].}

  Source Edit

    proc clearScreen() {.importc: "linenoiseClearScreen", ...raises: [], tags: [],
                         forbids: [].}

  Source Edit

    proc free(s: cstring) {.importc: "free", header: "<stdlib.h>", ...raises: [],
                            tags: [], forbids: [].}

  Source Edit

    proc historyAdd(line: cstring): cint {.importc: "linenoiseHistoryAdd",
                                           discardable, ...raises: [], tags: [],
                                           forbids: [].}

  Source Edit

    proc historyLoad(filename: cstring): cint {.importc: "linenoiseHistoryLoad",
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc historySave(filename: cstring): cint {.importc: "linenoiseHistorySave",
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc historySetMaxLen(len: cint): cint {.importc: "linenoiseHistorySetMaxLen",
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc printKeyCodes() {.importc: "linenoisePrintKeyCodes", ...raises: [], tags: [],
                           forbids: [].}

  Source Edit

    proc readLine(prompt: cstring): cstring {.importc: "linenoise", ...raises: [],
        tags: [], forbids: [].}

  Source Edit

    proc readLineStatus(prompt: string; result: var ReadLineResult) {....raises: [],
        tags: [], forbids: [].}

  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: -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: [], forbids: [].}

  Source Edit

    proc setMultiLine(ml: cint) {.importc: "linenoiseSetMultiLine", ...raises: [],
                                  tags: [], forbids: [].}

  Source Edit