diff options
Diffstat (limited to 'src/local/term.nim')
| -rw-r--r-- | src/local/term.nim | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/local/term.nim b/src/local/term.nim index 903b145b..cbf2d6a9 100644 --- a/src/local/term.nim +++ b/src/local/term.nim @@ -5,7 +5,6 @@ import std/strutils import std/tables import std/termios -import bindings/termcap import chagashi/charset import chagashi/decoder import chagashi/encoder @@ -21,6 +20,35 @@ import utils/twtstr import utils/twtuni #TODO switch away from termcap... +const Termlib* = (proc(): string = + const 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 + # Apparently on some systems pkg-config will fail to locate ncurses. + const dirs = [ + "/lib", "/usr/lib", "/usr/local/lib" + ] + for lib in libs: + for dir in dirs: + if fileExists(dir & "/lib" & lib & ".a"): + return "-l" & lib + return "" +)() + +const TermcapFound* = Termlib != "" + +when TermcapFound: + {.passl: Termlib.} + {.push importc, cdecl.} + proc tgetent(bp, name: cstring): cint + proc tgetnum(id: cstring): cint + proc tgetstr(id: cstring; area: ptr cstring): cstring + proc tgoto(cap: cstring; x, y: cint): cstring + {.pop.} type TermcapCap = enum |