diff options
author | bptato <nincsnevem662@gmail.com> | 2024-08-17 01:52:31 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-08-17 02:08:31 +0200 |
commit | f5f841dc7528098c2a07bd06280fa9d1c4ea3164 (patch) | |
tree | b108c8b8668182b25ab3670df3878dd639712d72 /src/bindings | |
parent | ad66c25c72ce2b2ae43e3d7a848836fdea4ee572 (diff) | |
download | chawan-f5f841dc7528098c2a07bd06280fa9d1c4ea3164.tar.gz |
term: don't panic if termcap tgetent fails
If TERM is unrecognized by termcap, retry as dosansi. When that fails, just fall back to the non-termcap code path. (There is no reason to panic without termcap; it's just one of the several capability detection mechanisms we use.)
Diffstat (limited to 'src/bindings')
-rw-r--r-- | src/bindings/termcap.nim | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/bindings/termcap.nim b/src/bindings/termcap.nim index 6d3d0e37..2f5bb701 100644 --- a/src/bindings/termcap.nim +++ b/src/bindings/termcap.nim @@ -1,5 +1,6 @@ import std/os -const termlib = (proc(): string = + +const Termlib* = (proc(): string = const libs = [ "terminfo", "mytinfo", "termlib", "termcap", "tinfo", "ncurses", "curses" ] @@ -15,18 +16,18 @@ const termlib = (proc(): string = for dir in dirs: if fileExists(dir & "/lib" & lib & ".a"): return "-l" & lib + return "" )() -when termlib != "": - {.passl: termlib.} + +const TermcapFound* = Termlib != "" + +when TermcapFound: + {.passl: Termlib.} {.push importc, cdecl.} - const termcap_found* = true - proc tgetent*(bp: cstring; name: cstring): cint + 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*(str: cstring; len: cint; putc: proc(c: char): cint {.cdecl.}): - cint + proc tputs*(s: cstring; len: cint; putc: proc(c: char): cint {.cdecl.}): cint {.pop.} -else: - const termcap_found* = false |