Using native putch and getch on Windows.
Fabio Cevasco h3rald@h3rald.com
Sun, 16 Jul 2017 13:08:37 +0200
1 files changed,
8 insertions(+),
4 deletions(-)
jump to
M
nimline.nim
→
nimline.nim
@@ -8,11 +8,15 @@ os
system.addQuitProc(resetAttributes) -proc putchr*(c: cint) = - stdout.write(c.chr) +when defined(windows): + proc getchr*(): cint {.header: "<conio.h>", importc: "_getch".} + proc putchr*(c: cint): cint {.discardable, header: "<conio.h>", importc: "_putch".} +else: + proc putchr*(c: cint) = + stdout.write(c.chr) -proc getchr*(): cint = - return getch().ord + proc getchr*(): cint = + return getch().ord # Types