Ctrl-C: Handles sigint much more elegantly
This commit is contained in:
parent
87982fdcbc
commit
8e21117986
|
@ -65,6 +65,10 @@ proc newShellCommandException(msg: string, command: string, line=0, col=0, while
|
|||
proc eval(cmd: string): string
|
||||
proc substitute(strm: Stream, delim = ";\p"): string
|
||||
|
||||
# ctrlc is the ctrl-c handler
|
||||
proc ctrlc() {.noconv.} =
|
||||
raise newException(InterruptCtrlC, "")
|
||||
|
||||
# skipSpaces reads the stream until a non-space character is found
|
||||
proc skipSpaces(strm: Stream): int =
|
||||
while not strm.atEnd():
|
||||
|
@ -322,6 +326,8 @@ proc eval(cmd: string): string =
|
|||
strm.close
|
||||
|
||||
when isMainModule:
|
||||
# ctrlc handler
|
||||
setControlCHook(ctrlc)
|
||||
let stdinstrm = stdin.newFileStream
|
||||
while not stdinstrm.atEnd():
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue