io.streams.256color: adding a "256color-terminal?" word and minor cleanup.
parent
a8fae26b82
commit
9ab4053e46
|
@ -1,10 +1,10 @@
|
||||||
! Copyright (C) 2012 John Benediktsson
|
! Copyright (C) 2012 John Benediktsson
|
||||||
! See http://factorcode.org/license.txt for BSD license
|
! See http://factorcode.org/license.txt for BSD license
|
||||||
|
|
||||||
USING: accessors arrays assocs destructors formatting fry io
|
USING: accessors arrays assocs destructors environment
|
||||||
io.streams.string io.styles kernel locals math math.functions
|
formatting fry io io.streams.string io.styles kernel locals
|
||||||
math.ranges math.vectors namespaces sequences sequences.extras
|
math math.functions math.ranges math.vectors namespaces
|
||||||
strings strings.tables ;
|
sequences sequences.extras strings strings.tables ;
|
||||||
|
|
||||||
IN: io.streams.256color
|
IN: io.streams.256color
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ M: 256color stream-format
|
||||||
[
|
[
|
||||||
[ foreground swap at [ color>foreground ] [ "" ] if* ]
|
[ foreground swap at [ color>foreground ] [ "" ] if* ]
|
||||||
[ background swap at [ color>background ] [ "" ] if* ]
|
[ background swap at [ color>background ] [ "" ] if* ]
|
||||||
bi append "\u00001b[0m" surround
|
bi append [ "\u00001b[0m" surround ] unless-empty
|
||||||
] dip stream>> stream-write ;
|
] dip stream>> stream-write ;
|
||||||
|
|
||||||
M: 256color make-span-stream
|
M: 256color make-span-stream
|
||||||
|
@ -104,5 +104,8 @@ M: 256color dispose drop ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
: 256color-terminal? ( -- ? )
|
||||||
|
"TERM" os-env "-256color" tail? ;
|
||||||
|
|
||||||
: with-256color ( quot -- )
|
: with-256color ( quot -- )
|
||||||
output-stream get <256color> swap with-output-stream* ; inline
|
output-stream get <256color> swap with-output-stream* ; inline
|
||||||
|
|
Loading…
Reference in New Issue