'nimsuggest' compiles again
This commit is contained in:
parent
34b4e9fc96
commit
008b0f19bb
1 changed files with 13 additions and 11 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nim's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2015 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
## is used. This suffices because Windows' console already provides the
|
## is used. This suffices because Windows' console already provides the
|
||||||
## wanted functionality.
|
## wanted functionality.
|
||||||
|
|
||||||
|
{.deadCodeElim: on.}
|
||||||
|
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
proc readLineFromStdin*(prompt: string): TaintedString {.
|
proc readLineFromStdin*(prompt: string): TaintedString {.
|
||||||
tags: [ReadIOEffect, WriteIOEffect].} =
|
tags: [ReadIOEffect, WriteIOEffect].} =
|
||||||
|
|
@ -31,23 +33,23 @@ when defined(Windows):
|
||||||
stdout.write(prompt)
|
stdout.write(prompt)
|
||||||
result = readLine(stdin, line)
|
result = readLine(stdin, line)
|
||||||
|
|
||||||
proc getch(): cint {.header: "<conio.h>", importc: "_getch".}
|
|
||||||
|
|
||||||
proc readPasswordFromStdin*(prompt: string, password: var TaintedString) =
|
proc readPasswordFromStdin*(prompt: string, password: var TaintedString) =
|
||||||
## Reads a `password` from stdin without printing it. `password` must not
|
## Reads a `password` from stdin without printing it. `password` must not
|
||||||
## be ``nil``!
|
## be ``nil``!
|
||||||
|
proc getch(): cint {.header: "<conio.h>", importc: "_getch".}
|
||||||
|
|
||||||
password.setLen(0)
|
password.setLen(0)
|
||||||
var c: char
|
var c: char
|
||||||
echo prompt
|
echo prompt
|
||||||
while true:
|
while true:
|
||||||
c = getch().char
|
c = getch().char
|
||||||
case c
|
case c
|
||||||
of '\r', chr(0xA):
|
of '\r', chr(0xA):
|
||||||
break
|
break
|
||||||
of '\b':
|
of '\b':
|
||||||
password.setLen(result.len - 1)
|
password.setLen(password.len - 1)
|
||||||
else:
|
else:
|
||||||
password.add(c)
|
password.add(c)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
import readline, history, termios, unsigned
|
import readline, history, termios, unsigned
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue