]> gitweb.factorcode.org Git - factor.git/commitdiff
io.styles: Add blink style.
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 28 May 2022 20:29:13 +0000 (15:29 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 28 May 2022 20:51:55 +0000 (15:51 -0500)
Try in terminal:

rlwrap ./factor

USING: system io.styles colors literals threads calendar colors.flex-hex hashtables io.streams.ansi random ; [
  "hello"
   named-colors random parse-color foreground associate
   named-colors random parse-color background pick set-at
   { underline blink bold-italic } font-style pick set-at format
] with-ansi

basis/io/styles/styles.factor
extra/io/streams/256color/256color.factor
extra/io/streams/ansi/ansi.factor
extra/io/streams/escape-codes/authors.txt [new file with mode: 0644]
extra/io/streams/escape-codes/escape-codes.factor [new file with mode: 0644]

index 8373811a3a2a834f275d0decab9b898fa1161825..39e19402447a9258bc9026dc8ebfff192edad12b 100644 (file)
@@ -114,6 +114,9 @@ SYMBOL: plain
 SYMBOL: bold
 SYMBOL: italic
 SYMBOL: bold-italic
+SYMBOL: faint
+SYMBOL: underline
+SYMBOL: blink
 
 ! Character styles
 SYMBOL: foreground
index be33f3c521078f906bdfefcc3e43a439278c9835..2401cfa7121120bb6e5626ffe004c1b5bf2c95d5 100644 (file)
@@ -2,9 +2,9 @@
 ! 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
 
@@ -66,13 +66,6 @@ intensities [| r i |
 : 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
index 8f81dd76a751d31fbbd83b62cece4fe84cbd0011..6a0231bae451cdfcc416a5f7585bb00156a92b25 100644 (file)
@@ -2,11 +2,11 @@
 ! 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{
@@ -47,13 +47,6 @@ 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
diff --git a/extra/io/streams/escape-codes/authors.txt b/extra/io/streams/escape-codes/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/io/streams/escape-codes/escape-codes.factor b/extra/io/streams/escape-codes/escape-codes.factor
new file mode 100644 (file)
index 0000000..bf85f75
--- /dev/null
@@ -0,0 +1,20 @@
+! 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 ;