linenoise.nim 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2015 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. type
  10. Completions* = object
  11. len*: csize
  12. cvec*: cstringArray
  13. CompletionCallback* = proc (a2: cstring; a3: ptr Completions) {.cdecl.}
  14. {.compile: "linenoise.c".}
  15. proc setCompletionCallback*(a2: ptr CompletionCallback) {.
  16. importc: "linenoiseSetCompletionCallback".}
  17. proc addCompletion*(a2: ptr Completions; a3: cstring) {.
  18. importc: "linenoiseAddCompletion".}
  19. proc readLine*(prompt: cstring): cstring {.importc: "linenoise".}
  20. proc historyAdd*(line: cstring): cint {.importc: "linenoiseHistoryAdd",
  21. discardable.}
  22. proc historySetMaxLen*(len: cint): cint {.importc: "linenoiseHistorySetMaxLen".}
  23. proc historySave*(filename: cstring): cint {.importc: "linenoiseHistorySave".}
  24. proc historyLoad*(filename: cstring): cint {.importc: "linenoiseHistoryLoad".}
  25. proc clearScreen*() {.importc: "linenoiseClearScreen".}
  26. proc setMultiLine*(ml: cint) {.importc: "linenoiseSetMultiLine".}
  27. proc printKeyCodes*() {.importc: "linenoisePrintKeyCodes".}
  28. proc free*(s: cstring) {.importc: "free", header: "<stdlib.h>".}