aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/hardware/vt100.frt
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-08-19 12:15:28 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-08-19 12:15:28 +0200
commit67d25d837ac55f28a366c0a3b262e439a6e75fc3 (patch)
treedf7715c7724c5935ab87c807f3b8b4ef529315e3 /amforth-6.5/common/lib/hardware/vt100.frt
parente0d6784e89dba33226c0edb815bb974486fa7c48 (diff)
Add AmForth
Diffstat (limited to 'amforth-6.5/common/lib/hardware/vt100.frt')
-rw-r--r--amforth-6.5/common/lib/hardware/vt100.frt59
1 files changed, 59 insertions, 0 deletions
diff --git a/amforth-6.5/common/lib/hardware/vt100.frt b/amforth-6.5/common/lib/hardware/vt100.frt
new file mode 100644
index 0000000..ca84bd6
--- /dev/null
+++ b/amforth-6.5/common/lib/hardware/vt100.frt
@@ -0,0 +1,59 @@
+\ ansi terminal codes
+
+: ESC[ #27 emit [char] ] emit ;
+
+\ some helper words: print a number *without*
+\ leading space in decimal
+: .n base @ swap decimal 0 u.r base ! ;
+: .;n [char] ; emit .n ;
+: ESC[ #27 emit [char] [ emit ;
+
+\ position curser on terminal
+: at-xy ( u1 u2 -- )
+ 1+ swap 1+ swap ESC[ .n .;n [char] H emit
+;
+
+\ clear page
+: page ( -- )
+ ESC[ ." 2J" 0 0 at-xy
+;
+
+\ more definitions based on gforth' ansi.fs
+
+: foreground ( n -- | set foreground color to n )
+ ESC[ #30 + .n [char] m emit
+;
+
+: background ( n -- | set background color to n )
+ ESC[ #40 + .n [char] m emit
+;
+
+: text_normal ( -- | set normal text display )
+ ESC[ [char] 0 emit [char] m emit
+;
+
+: text_bold ( -- | set bold text )
+ ESC[ [char] 1 emit [char] m emit
+;
+
+: text_underline ( -- | set underlined text )
+ ESC[ [char] 4 emit [char] m emit
+;
+
+: text_blink ( -- | set blinking text )
+ ESC[ [char] 5 emit [char] m emit
+;
+
+: text_reverse ( -- | set reverse video text )
+ ESC[ [char] 7 emit [char] m emit
+;
+
+
+#0 constant Black
+#1 constant Red
+#2 constant Green
+#3 constant Yellow
+#4 constant Blue
+#5 constant Brown
+#6 constant Cyan
+#7 constant White