add a scanw example

This commit is contained in:
ycz 2019-09-04 12:10:17 +08:00
parent 043fd9555d
commit 6f16800e43
1 changed files with 17 additions and 0 deletions

17
example/scanw.nim Normal file
View File

@ -0,0 +1,17 @@
# a scanw example
# reference: http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/scanw.html
import ../ncurses
var
mesg = "Enter a string: "
row: cint
col: cint
let pwin = initscr()
getmaxyx(pwin, row, col)
mvprintw(row div 2, (cint)((col - mesg.len) div 2), "%s", mesg)
getstr(mesg)
mvprintw(row - 2, 0, "You Entered: %s", mesg)
getch()
endwin()