summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-04-10 16:37:39 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-04-10 16:37:39 +0200
commitae2d2dbbe33a98cf41350ef37947c21461479d68 (patch)
tree2dde07d38270a13baf1dcd85af4004bc663e104e
Initial import
-rw-r--r--vt100.go62
-rw-r--r--vt100_test.go39
-rw-r--r--vt100test.txt60
3 files changed, 161 insertions, 0 deletions
diff --git a/vt100.go b/vt100.go
new file mode 100644
index 0000000..d3037fc
--- /dev/null
+++ b/vt100.go
@@ -0,0 +1,62 @@
+package vt100
+
+type (
+ Normal string
+ Bold string
+ Underline string
+ Blink string
+ Inverse string
+ DoubleWidth string
+ DoubleHeight string
+ DoubleHeightTop string
+ DoubleHeightBottom string
+)
+
+var (
+ esc = string(033)
+ normal = esc + "[0m"
+ bold = esc + "[1m"
+ underline = esc + "[4m"
+ blink = esc + "[5m"
+ inverse = esc + "[7m"
+ doubleWidth = esc + "#6"
+ doubleHeightTop = esc + "#3"
+ doubleHeightBottom = esc + "#4"
+)
+
+func (s Normal) String() string {
+ return normal + string(s) + normal
+}
+
+func (s Bold) String() string {
+ return bold + string(s) + normal
+}
+
+func (s Underline) String() string {
+ return underline + string(s) + normal
+}
+
+func (s Blink) String() string {
+ return blink + string(s) + normal
+}
+
+func (s Inverse) String() string {
+ return inverse + string(s) + normal
+}
+
+func (s DoubleWidth) String() string {
+ return doubleWidth + string(s) + normal
+}
+
+func (s DoubleHeight) String() string {
+ return DoubleHeightTop(s).String() + "\n" +
+ DoubleHeightBottom(s).String()
+}
+
+func (s DoubleHeightTop) String() string {
+ return doubleHeightTop + string(s) + normal
+}
+
+func (s DoubleHeightBottom) String() string {
+ return doubleHeightBottom + string(s) + normal
+}
diff --git a/vt100_test.go b/vt100_test.go
new file mode 100644
index 0000000..c2eb891
--- /dev/null
+++ b/vt100_test.go
@@ -0,0 +1,39 @@
+package vt100
+
+import "fmt"
+
+func ExampleNormal() {
+ fmt.Println(Normal("This is a normal line"))
+ // Output: This is a normal line
+}
+
+func ExampleBold() {
+ fmt.Println(Bold("This is a bold line"))
+ // Output: This is a bold line
+}
+
+func ExampleUnderline() {
+ fmt.Println(Underline("This line is underlined"))
+ // Output: This line is underlined
+}
+
+func ExampleBlink() {
+ fmt.Println(Blink("This is a blinking line"))
+ // Output: This is a blinking line
+}
+
+func ExampleInverse() {
+ fmt.Println(Inverse("This is inverse video"))
+ // Output: This is inverse video
+}
+
+func ExampleDoubleWidth() {
+ fmt.Println(DoubleWidth("This is double width"))
+ // Output: #6This is double width
+}
+
+func ExampleDoubleHeight() {
+ fmt.Println(DoubleHeight("This is double height"))
+ // Output: #3This is double height
+ // #4This is double height
+}
diff --git a/vt100test.txt b/vt100test.txt
new file mode 100644
index 0000000..d53d99d
--- /dev/null
+++ b/vt100test.txt
@@ -0,0 +1,60 @@
+\<>PrEM1\[?4h
+#6(0a`opqrs`(B This is the (0`srqpo`a(B
+#3VT100 series Torture Test Demonstration.
+#4VT100 series Torture Test Demonstration.
+#6 Watch the blinking lights 
+
+
+
+PrEM0\
+
+This file is a VT100-series Torture Test. It demonstrates all the visual
+attributes of the VT100 terminal.
+
+The top line is double-width/single-height with inverse-video line-drawing
+characters. The 2nd and 3rd lines are double-width/double-height in bold
+inverse video. They also show the limited scrolling region.
+
+The remaining lines will show NORMAL, BOLD, BLINK, INVERSE, and all 16
+combinations of those 4 attributes. They show that there is a difference
+between an underscore character and the underline attribute, and that
+lower-case decenders go below the underline.
+
+A window pane is drawn in the lower right to show how the line-drawing set
+can be used. At the lower left is the character set double-wide/double-high
+to show the dot-matrix used. Upper-case characters are 8 by 7 in a 10 by 10
+character cell, with 1 blank row on top and 2 on the bottom. The underline
+attribute uses the first bottom blank row, lower-case decenders use both.
+
+
+
+This is a normal line __________________________________________________y_
+This is a bold line (normal unless the Advanced Video Option is installed)
+This line is underlined _ " " " " " " _y_
+This is a blinking line _ " " " " " " _y_
+This is inverse video _ (underlined if no AVO and cursor is underline) _y_
+Normal gjpqy Underline  Blink Underline+Blink gjpqy
+Bold gjpqy Underline  Blink Underline+Blink gjpqy
+Inverse Underline  Blink Underline+Blink
+Bold+Inverse Underline  Blink Underline+Blink
+PrEM1\
+#6This is double width
+#3This is double height
+#4This is double height
+#6_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ioy
+#3_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ioy
+#4_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ioy
+ACEGIKMOQSUWY02468iy
+_BDFHJLNPRTVXZ13579o
+_BDFHJLNPRTVXZ13579o
+(0#6`abcdefghijklmnopqrstuvwxyz{|}~ lqwqk
+#3`abcdefghijklmnopqrstuvwxyz{|}~ tqnqu
+#4`abcdefghijklmnopqrstuvwxyz{|}~ tqnqu
+acegikmoqsuwy{}
+`bdfhjlnprtvxz|~
+`bdfhjlnprtvxz|~(B
+#6`abcdefghijklmnopqrstuvwxyz{|}~(0 mqvqj(B
+acegikmoqsuwy{}
+PrEM0\ $PrEM0 works on GIGI 
+ This test created by Joe Smith, 8-May-85 
+