From 32109a7867b06cdf9e66ad717f42aebb3e0fcaa4 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Tue, 21 Apr 2015 14:37:29 +0300 Subject: Don't run non-test code when defined(testing) --- lib/pure/terminal.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/pure/terminal.nim') diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index df637dcb6..a3c5cdcfb 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -375,7 +375,7 @@ when not defined(windows): result = stdin.readChar() discard fd.tcsetattr(TCSADRAIN, addr oldMode) -when isMainModule: +when not defined(testing) and isMainModule: system.addQuitProc(resetAttributes) write(stdout, "never mind") eraseLine() -- cgit 1.4.1-2-gfad0 From e5a186a419920b91f785e2d783da856637472eed Mon Sep 17 00:00:00 2001 From: def Date: Fri, 24 Apr 2015 19:41:12 +0200 Subject: Fix Termios wrapper --- lib/impure/rdstdin.nim | 2 +- lib/posix/termios.nim | 15 ++++++--------- lib/pure/terminal.nim | 13 +++++++------ 3 files changed, 14 insertions(+), 16 deletions(-) (limited to 'lib/pure/terminal.nim') diff --git a/lib/impure/rdstdin.nim b/lib/impure/rdstdin.nim index 55f8c5d32..f4d00979c 100644 --- a/lib/impure/rdstdin.nim +++ b/lib/impure/rdstdin.nim @@ -135,7 +135,7 @@ else: var cur, old: Termios discard fd.tcgetattr(cur.addr) old = cur - cur.lflag = cur.lflag and not Tcflag(ECHO) + cur.c_lflag = cur.c_lflag and not Tcflag(ECHO) discard fd.tcsetattr(TCSADRAIN, cur.addr) stdout.write prompt result = stdin.readLine(password) diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim index 0917ab514..710b2fa6b 100644 --- a/lib/posix/termios.nim +++ b/lib/posix/termios.nim @@ -19,15 +19,12 @@ const type Termios* {.importc: "struct termios", header: "".} = object - iflag*: Tcflag # input mode flags - oflag*: Tcflag # output mode flags - cflag*: Tcflag # control mode flags - lflag*: Tcflag # local mode flags - line*: cuchar # line discipline - cc*: array[NCCS, cuchar] # control characters - ispeed*: Speed # input speed - ospeed*: Speed # output speed - + c_iflag*: Tcflag # input mode flags + c_oflag*: Tcflag # output mode flags + c_cflag*: Tcflag # control mode flags + c_lflag*: Tcflag # local mode flags + c_line*: cuchar # line discipline + c_cc*: array[NCCS, cuchar] # control characters # cc characters diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index a3c5cdcfb..29f700db5 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -51,12 +51,13 @@ else: proc setRaw(fd: FileHandle, time: cint = TCSAFLUSH) = var mode: Termios discard fd.tcgetattr(addr mode) - mode.iflag = mode.iflag and not Tcflag(BRKINT or ICRNL or INPCK or ISTRIP or IXON) - mode.oflag = mode.oflag and not Tcflag(OPOST) - mode.cflag = (mode.cflag and not Tcflag(CSIZE or PARENB)) or CS8 - mode.lflag = mode.lflag and not Tcflag(ECHO or ICANON or IEXTEN or ISIG) - mode.cc[VMIN] = 1.cuchar - mode.cc[VTIME] = 0.cuchar + mode.c_iflag = mode.c_iflag and not Tcflag(BRKINT or ICRNL or INPCK or + ISTRIP or IXON) + mode.c_oflag = mode.c_oflag and not Tcflag(OPOST) + mode.c_cflag = (mode.c_cflag and not Tcflag(CSIZE or PARENB)) or CS8 + mode.c_lflag = mode.c_lflag and not Tcflag(ECHO or ICANON or IEXTEN or ISIG) + mode.c_cc[VMIN] = 1.cuchar + mode.c_cc[VTIME] = 0.cuchar discard fd.tcsetattr(time, addr mode) proc setCursorPos*(x, y: int) = -- cgit 1.4.1-2-gfad0