added terminal.isatty; nimgrep version 0.9
This commit is contained in:
parent
0f96e72b18
commit
ba3f90cc25
3 changed files with 39 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
|
|
@ -307,6 +307,17 @@ proc setBackgroundColor*(bg: TBackgroundColor, bright=false) =
|
|||
gBG = ord(bg)
|
||||
if bright: inc(gBG, 60)
|
||||
stdout.write("\e[" & $gBG & 'm')
|
||||
|
||||
proc isatty*(f: TFile): bool =
|
||||
## returns true if `f` is associated with a terminal device.
|
||||
when defined(posix):
|
||||
proc isatty(fildes: TFileHandle): cint {.
|
||||
importc: "isatty", header: "<unistd.h>".}
|
||||
else:
|
||||
proc isatty(fildes: TFileHandle): cint {.
|
||||
importc: "_isatty", header: "<io.h>".}
|
||||
|
||||
result = isatty(fileHandle(f)) != 0'i32
|
||||
|
||||
# XXX:
|
||||
# These should be private, but there is no yet
|
||||
|
|
@ -317,7 +328,7 @@ proc styledEchoProcessArg*(style: set[TStyle]) = setStyle style
|
|||
proc styledEchoProcessArg*(color: TForegroundColor) = setForeGroundColor color
|
||||
proc styledEchoProcessArg*(color: TBackgroundColor) = setBackGroundColor color
|
||||
|
||||
macro styledEcho*(m: stmt): stmt =
|
||||
macro styledEcho*(m: stmt): stmt =
|
||||
result = newNimNode(nnkStmtList)
|
||||
|
||||
for i in countup(1, m.len - 1):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue