aboutsummaryrefslogtreecommitdiff
path: root/src/format.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/format.nim')
-rw-r--r--src/format.nim10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/format.nim b/src/format.nim
index b1659fc..c3a7e5e 100644
--- a/src/format.nim
+++ b/src/format.nim
@@ -1,5 +1,5 @@
import
- future, options, sequtils, strutils, times, unicode,
+ future, options, posix, sequtils, strutils, times, unicode,
utils
type
@@ -52,6 +52,13 @@ proc getWindowSize(): tuple[width: int, height: int] =
else:
(0, 0)
+proc tcflush(fd: cint, queueSelector: cint): cint
+ {.importc, header: "<termios.h>".}
+
+proc discardStream() =
+ if isatty(0) != 0:
+ discard tcflush(0, 0)
+
proc printError*(color: bool, s: string) =
stderr.writeLine(^Color.red, trp"error: ", ^Color.normal, s)
@@ -232,6 +239,7 @@ proc printColonUserInput*(color: bool, s: string,
default
else:
try:
+ discardStream()
stdin.readLine()
except EOFError:
cancel