aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/hardware/vt100.frt
blob: ca84bd6e6682ac6ee03804f1b4d27b77bf4ddfd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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