about summary refs log tree commit diff stats
path: root/src/bindings/termcap.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-11-21 23:31:29 +0100
committerbptato <nincsnevem662@gmail.com>2022-11-21 23:31:29 +0100
commitbd8e806b04b024f916b274650185c3480d3cff36 (patch)
tree2076cd4525a1d2672ff6986ae3fea9b1d364a13b /src/bindings/termcap.nim
parent95444650537805d414deec706ad98e37df8b88db (diff)
downloadchawan-bd8e806b04b024f916b274650185c3480d3cff36.tar.gz
Termcap support (?)
Diffstat (limited to 'src/bindings/termcap.nim')
-rw-r--r--src/bindings/termcap.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/bindings/termcap.nim b/src/bindings/termcap.nim
new file mode 100644
index 00000000..02962a67
--- /dev/null
+++ b/src/bindings/termcap.nim
@@ -0,0 +1,20 @@
+const termlib = (func(): string =
+  let libs = ["terminfo", "mytinfo", "termlib", "termcap", "tinfo", "ncurses", "curses"]
+  for lib in libs:
+    let res = staticExec("pkg-config --libs --silence-errors " & lib)
+    if res != "":
+      return res
+)()
+when termlib != "":
+  {.passl: termlib.}
+  {.push importc, cdecl.}
+  const termcap_found* = true
+  proc tgetent*(bp: cstring, name: cstring): cint
+  proc tgetnum*(id: cstring): cint
+  proc tgetflag*(id: cstring): cint
+  proc tgetstr*(id: cstring, area: ptr cstring): cstring
+  proc tgoto*(cap: cstring, x, y: cint): cstring
+  proc tputs*(str: cstring, len: cint, putc: proc(c: char): cint {.cdecl.}): cint
+  {.pop.}
+else:
+  const termcap_found* = false