]> gitweb.factorcode.org Git - factor.git/commitdiff
add unicode control-picturizer and docs
authorPi <pi+git@pihost.us>
Sun, 22 Oct 2017 19:04:48 +0000 (12:04 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 23 Oct 2017 23:34:58 +0000 (16:34 -0700)
extra/unicode/control-pictures/authors.txt [new file with mode: 0644]
extra/unicode/control-pictures/control-pictures-docs.factor [new file with mode: 0644]
extra/unicode/control-pictures/control-pictures.factor [new file with mode: 0644]

diff --git a/extra/unicode/control-pictures/authors.txt b/extra/unicode/control-pictures/authors.txt
new file mode 100644 (file)
index 0000000..1137f8e
--- /dev/null
@@ -0,0 +1 @@
+Pi
diff --git a/extra/unicode/control-pictures/control-pictures-docs.factor b/extra/unicode/control-pictures/control-pictures-docs.factor
new file mode 100644 (file)
index 0000000..f294ff1
--- /dev/null
@@ -0,0 +1,16 @@
+! Copyright (C) 2017 Pi.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax help.topics strings ;
+IN: unicode.control-pictures
+
+HELP: control-pictures
+{ $values
+    { "string" string }
+}
+{ $description "Transforms C0 control characters into their corresponding Control Picture block codepoints." } ;
+
+ARTICLE: "unicode.control-pictures" "Control Pictures"
+"The " { $vocab-link "unicode.control-pictures" } " vocabulary provides a utility word " { $link control-pictures } " for transforming characters in the nonprintable ASCII C0 block to their representations in the Control Pictures block. It has no effect on any other characters."
+;
+
+ABOUT: "unicode.control-pictures"
diff --git a/extra/unicode/control-pictures/control-pictures.factor b/extra/unicode/control-pictures/control-pictures.factor
new file mode 100644 (file)
index 0000000..94a439c
--- /dev/null
@@ -0,0 +1,18 @@
+! Copyright (C) 2017 Pi.
+! See http://factorcode.org/license.txt for BSD license.
+USING: combinators kernel math sequences ;
+IN: unicode.control-pictures
+
+<PRIVATE
+
+: char>control-picture ( char -- char' )
+    {
+        { [ dup 0x20 < ] [ 0x2400 bitor ] }
+        { [ dup 0x7f = ] [ drop 0x2421 ] }
+        [ ]
+    } cond ;
+
+PRIVATE>
+
+: control-pictures ( string -- string )
+    [ char>control-picture ] map ;