Various Datatypes.
[AROS-Contrib.git] / rexx / lib / ansi.r
blob443e75d7005ad076852b59df1bb3ab6eefd7fdee
1 /*
2 Library with ANSI routines 1998
3 Vassilis N. Vlachoudis V.Vlachoudis@cern.ch
4 */
5 exit 1
7 /* --- AnsiMode(mode) --- */
8 /* 0 - 40x25 C, 1 - 40x25 BW, 3 - 80x25 C .... */
9 AnsiMode:
10 call write ,'1B'x||'[='arg(1)'h'
11 return
13 /* --- Clear Screen --- */
14 AnsiCls:
15 call write ,'1B'x||'[2J'
16 return
18 /* --- Erase until end of line --- */
19 AnsiEraseEOL:
20 call write ,'1B'x||'[K'
21 return
23 /* --- AnsiCursorUp, n-counts --- */
24 AnsiCursorUp: procedure
25 parse arg n
26 if n=="" then n=1
27 call write ,'1B'x||'['n'A'
28 return
30 /* --- AnsiCursorDown --- */
31 AnsiCursorDown: procedure
32 parse arg n
33 if n=="" then n=1
34 call write ,'1B'x||'['n'B'
35 return
37 /* --- AnsiCursorRight --- */
38 AnsiCursorRight: procedure
39 parse arg n
40 if n=="" then n=1
41 call write ,'1B'x||'['n'C'
42 return
44 /* --- AnsiCursorLeft --- */
45 AnsiCursorLeft: procedure
46 parse arg n
47 if n=="" then n=1
48 call write ,'1B'x||'['n'D'
49 return
51 /* --- AnsiGoto(X,Y) --- */
52 AnsiGoto:
53 call write ,'1B'x||'['arg(2)';'arg(1)'H'
54 return
56 /* --- AnsiSaveCursor --- */
57 AnsiSaveCursor:
58 call write ,'1B'x||'[s'
59 return
61 /* --- AnsiLoadCursor --- */
62 AnsiLoadCursor:
63 call write ,'1B'x||'[u'
64 return
66 /* --- AnsiColor(forecolor[,backcolor]) --- */
67 /* --- color can be [BOLD]color --- */
68 AnsiColor: procedure
69 arg fg,bg,attr
70 colors = "BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE"
71 bold = 0
72 if left(fg,4) == "BOLD" then do
73 bold = 1
74 fg = substr(fg,5)
75 end
76 if bg ^== "" then do
77 b = wordpos(bg,colors)
78 if b = 0 then return "ERROR"
79 back = ";4"||b-1
80 end; else
81 back = ""
82 f = wordpos(fg,colors)
83 if f = 0 then return "ERROR"
84 if bold then
85 call write ,"1B"x||"[1;3"||f-1||back||"m"
86 else
87 call write ,"1B"x||"[3"||f-1||back||"m"
88 return
90 /* ----- Atributes ------ */
91 AnsiAttr: procedure
92 arg attr
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"
96 return