diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-10-23 18:32:13 +0200 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-10-23 19:08:47 +0200 |
| commit | 151632bfa4a15dbd479066354c48efbac8ea461c (patch) | |
| tree | c66bcd852461fb59dbe36fb383b69467232185c6 /src | |
| parent | 5c24b64fe5b242bdba68fe3d48489bed26b48eae (diff) | |
| download | chawan-151632bfa4a15dbd479066354c48efbac8ea461c.tar.gz | |
termcap: merge into term
again, not that useful to put it in a separate module if only term
uses it
Diffstat (limited to 'src')
| -rw-r--r-- | src/bindings/termcap.nim | 33 | ||||
| -rw-r--r-- | src/local/term.nim | 30 | ||||
| -rw-r--r-- | src/main.nim | 1 |
3 files changed, 29 insertions, 35 deletions
diff --git a/src/bindings/termcap.nim b/src/bindings/termcap.nim deleted file mode 100644 index 2f5bb701..00000000 --- a/src/bindings/termcap.nim +++ /dev/null @@ -1,33 +0,0 @@ -import std/os - -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 tgetflag*(id: cstring): cint - proc tgetstr*(id: cstring; area: ptr cstring): cstring - proc tgoto*(cap: cstring; x, y: cint): cstring - proc tputs*(s: cstring; len: cint; putc: proc(c: char): cint {.cdecl.}): cint - {.pop.} 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 diff --git a/src/main.nim b/src/main.nim index 9d946033..4f39a5f3 100644 --- a/src/main.nim +++ b/src/main.nim @@ -4,7 +4,6 @@ import std/options import std/os import std/posix -import bindings/termcap import chagashi/charset import config/chapath import config/config |