SYMBOL: bold
SYMBOL: italic
SYMBOL: bold-italic
+SYMBOL: faint
+SYMBOL: underline
+SYMBOL: blink
! Character styles
SYMBOL: foreground
! See http://factorcode.org/license.txt for BSD license
USING: accessors arrays assocs destructors environment
-formatting io io.streams.string io.styles kernel math
-math.functions math.vectors namespaces ranges sequences strings
-strings.tables ;
+formatting io io.streams.escape-codes io.streams.string
+io.styles kernel math math.functions math.vectors namespaces
+ranges sequences strings strings.tables ;
IN: io.streams.256color
: color>background ( color -- string )
color>256color "\e[48;5;%sm" sprintf ;
-: font-styles ( font-style -- string )
- H{
- { bold "\e[1m" }
- { italic "\e[3m" }
- { bold-italic "\e[1m\e[3m" }
- } at "" or ;
-
TUPLE: 256color < filter-writer ;
C: <256color> 256color
! See http://factorcode.org/license.txt for BSD license
USING: accessors arrays assocs destructors formatting io
-io.streams.string io.styles kernel math math.functions
-math.vectors namespaces sequences strings strings.tables ;
+io.streams.escape-codes io.streams.string io.styles kernel math
+math.functions math.vectors namespaces sequences strings
+strings.tables ;
IN: io.streams.ansi
-
<PRIVATE
CONSTANT: colors H{
: color>background ( color -- string )
color>ansi [ 40 + ] [ "m" ";1m" ? ] bi* "\e[%d%s" sprintf ;
-: font-styles ( font-style -- string )
- H{
- { bold "\e[1m" }
- { italic "\e[3m" }
- { bold-italic "\e[1m\e[3m" }
- } at "" or ;
-
TUPLE: ansi < filter-writer ;
C: <ansi> ansi
--- /dev/null
+Doug Coleman
--- /dev/null
+! Copyright (C) 2022 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs io.styles kernel sequences ;
+IN: io.streams.escape-codes
+
+CONSTANT: font-style-assoc H{
+ { bold "\e[1m" }
+ { faint "\e[2m" }
+ { italic "\e[3m" }
+ { bold-italic "\e[1m\e[3m" }
+ { underline "\e[4m" }
+ { blink "\e[5m" }
+}
+
+: font-styles ( font-style -- string )
+ dup sequence? [
+ [ font-style-assoc at ] map concat
+ ] [
+ font-style-assoc at
+ ] if "" or ;