all repos — minline @ cbf31768d2721a660d3a79b831cc79abece092bd

A minimalist but highly-customizable line editing library.

Using native putch and getch on Windows.
Fabio Cevasco h3rald@h3rald.com
Sun, 16 Jul 2017 13:08:37 +0200
commit

cbf31768d2721a660d3a79b831cc79abece092bd

parent

a049ece45f3ceee22c6dc0a31ae9bef5691026d3

1 files changed, 8 insertions(+), 4 deletions(-)

jump to
M nimline.nimnimline.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