2 Library with ANSI routines
1998
3 Vassilis N
. Vlachoudis V
.Vlachoudis@cern
.ch
7 /* --- AnsiMode(mode
) --- */
8 /* 0 - 40x25 C
, 1 - 40x25 BW
, 3 - 80x25 C
.... */
10 call write
,'1B'x
||'[='arg(1)'h'
13 /* --- Clear Screen
--- */
15 call write
,'1B'x
||'[2J'
18 /* --- Erase until end of line
--- */
20 call write
,'1B'x
||'[K'
23 /* --- AnsiCursorUp
, n
-counts
--- */
24 AnsiCursorUp
: procedure
27 call write
,'1B'x
||'['n
'A'
30 /* --- AnsiCursorDown
--- */
31 AnsiCursorDown
: procedure
34 call write
,'1B'x
||'['n
'B'
37 /* --- AnsiCursorRight
--- */
38 AnsiCursorRight
: procedure
41 call write
,'1B'x
||'['n
'C'
44 /* --- AnsiCursorLeft
--- */
45 AnsiCursorLeft
: procedure
48 call write
,'1B'x
||'['n
'D'
51 /* --- AnsiGoto(X
,Y
) --- */
53 call write
,'1B'x
||'['arg(2)';'arg(1)'H'
56 /* --- AnsiSaveCursor
--- */
58 call write
,'1B'x
||'[s'
61 /* --- AnsiLoadCursor
--- */
63 call write
,'1B'x
||'[u'
66 /* --- AnsiColor(forecolor
[,backcolor
]) --- */
67 /* --- color can be
[BOLD
]color
--- */
70 colors
= "BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE"
72 if left(fg
,4) == "BOLD" then do
77 b
= wordpos(bg
,colors
)
78 if b
= 0 then return
"ERROR"
82 f
= wordpos(fg
,colors
)
83 if f
= 0 then return
"ERROR"
85 call write
,"1B"x
||"[1;3"||f
-1||back
||"m"
87 call write
,"1B"x
||"[3"||f
-1||back
||"m"
90 /* ----- Atributes
------ */
93 p
= wordpos(attr
,"NORMAL BOLD UNDERLINE BLINK REVERSE UNVISIBLE")
94 if p
= 0 then return
"ERROR"
95 call write
,"1B"x
||"["p
-1"m"