mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-05 23:22:25 +00:00
module crt almost completed, crttest for reference
This commit is contained in:
parent
fd34af424e
commit
4943886b64
4 changed files with 257 additions and 30 deletions
|
|
@ -2,7 +2,7 @@
|
|||
VOC = /opt/voc/bin/voc
|
||||
|
||||
all:
|
||||
$(VOC) -s vt100.Mod crt.Mod -M
|
||||
$(VOC) -s vt100.Mod crt.Mod crttest.Mod -M
|
||||
|
||||
clean:
|
||||
rm *.h
|
||||
|
|
|
|||
|
|
@ -3,6 +3,31 @@ MODULE crt;
|
|||
IMPORT vt100, Unix, Console,
|
||||
Strings; (* strings to remove later ? *)
|
||||
|
||||
CONST
|
||||
|
||||
(* Foreground and background color constants *)
|
||||
Black* = 0;
|
||||
Blue* = 1;
|
||||
Green* = 2;
|
||||
Cyan* = 3;
|
||||
Red* = 4;
|
||||
Magenta* = 5;
|
||||
Brown* = 6;
|
||||
LightGray* = 7;
|
||||
|
||||
(* Foreground color constants *)
|
||||
DarkGray* = 8;
|
||||
LightBlue* = 9;
|
||||
LightGreen* = 10;
|
||||
LightCyan* = 11;
|
||||
LightRed* = 12;
|
||||
LightMagenta* = 13;
|
||||
Yellow* = 14;
|
||||
White* = 15;
|
||||
|
||||
(* Add-in for blinking *)
|
||||
Blink* = 128;
|
||||
|
||||
TYPE
|
||||
PFdSet = POINTER TO Unix.FdSet;
|
||||
|
||||
|
|
@ -44,21 +69,127 @@ VAR tmpstr : ARRAY 23 OF CHAR;
|
|||
i := Unix.Select(0, pfd^, pfd^, pfd^, tv);
|
||||
END Delay;
|
||||
|
||||
|
||||
PROCEDURE GotoXY* (x, y: INTEGER);
|
||||
BEGIN
|
||||
vt100.CUP (y, x);
|
||||
END GotoXY;
|
||||
|
||||
BEGIN
|
||||
(* test *)
|
||||
EraseDisplay;
|
||||
GotoXY (0, 0);
|
||||
COPY(vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.Green, tmpstr);
|
||||
Strings.Append("hello", tmpstr);
|
||||
Console.String(tmpstr); Console.Ln;
|
||||
Delay (2000);
|
||||
PROCEDURE HighVideo*;
|
||||
VAR tmpstr: ARRAY 5 OF CHAR;
|
||||
BEGIN
|
||||
COPY (vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.Bold, tmpstr);
|
||||
Console.String(tmpstr);
|
||||
END HighVideo;
|
||||
|
||||
PROCEDURE DelLine*;
|
||||
BEGIN
|
||||
vt100.EL(2);
|
||||
END DelLine;
|
||||
|
||||
PROCEDURE InsLine*;
|
||||
BEGIN
|
||||
vt100.SCP;
|
||||
Console.Ln;
|
||||
vt100.RCP;
|
||||
END InsLine;
|
||||
|
||||
PROCEDURE LowVideo*;
|
||||
VAR tmpstr : ARRAY 7 OF CHAR;
|
||||
BEGIN
|
||||
COPY (vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.ResetBold, tmpstr);
|
||||
Console.String(tmpstr);
|
||||
END LowVideo;
|
||||
|
||||
PROCEDURE NormVideo*;
|
||||
VAR tmpstr : ARRAY 7 OF CHAR;
|
||||
BEGIN
|
||||
COPY(vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.ResetAll, tmpstr);
|
||||
Console.String(tmpstr);
|
||||
END NormVideo;
|
||||
|
||||
PROCEDURE SetAttr(attr : ARRAY OF CHAR);
|
||||
VAR tmpstr : ARRAY 16 OF CHAR;
|
||||
BEGIN
|
||||
COPY(vt100.CSI, tmpstr);
|
||||
Strings.Append(attr, tmpstr);
|
||||
Console.String(tmpstr);
|
||||
END SetAttr;
|
||||
|
||||
PROCEDURE TextBackground*(color : SHORTINT);
|
||||
BEGIN
|
||||
IF color = Black THEN
|
||||
SetAttr(vt100.BBlack)
|
||||
ELSIF color = Blue THEN
|
||||
SetAttr(vt100.BBlue)
|
||||
ELSIF color = Green THEN
|
||||
SetAttr(vt100.BGreen)
|
||||
ELSIF color = Cyan THEN
|
||||
SetAttr(vt100.BCyan)
|
||||
ELSIF color = Red THEN
|
||||
SetAttr(vt100.BRed)
|
||||
ELSIF color = Magenta THEN
|
||||
SetAttr(vt100.BMagenta)
|
||||
ELSIF color = Brown THEN
|
||||
SetAttr(vt100.BYellow)
|
||||
ELSIF color = LightGray THEN
|
||||
SetAttr(vt100.BLightGray)
|
||||
ELSIF color = DarkGray THEN
|
||||
SetAttr(vt100.BDarkGray)
|
||||
ELSIF color = LightBlue THEN
|
||||
SetAttr(vt100.BLightBlue)
|
||||
ELSIF color = LightGreen THEN
|
||||
SetAttr(vt100.BLightBlue)
|
||||
ELSIF color = LightCyan THEN
|
||||
SetAttr(vt100.BLightCyan)
|
||||
ELSIF color = LightRed THEN
|
||||
SetAttr(vt100.BLightRed)
|
||||
ELSIF color = LightMagenta THEN
|
||||
SetAttr(vt100.BLightMagenta)
|
||||
ELSIF color = Yellow THEN
|
||||
SetAttr(vt100.BLightYellow)
|
||||
ELSIF color = White THEN
|
||||
SetAttr(vt100.BWhite)
|
||||
END;
|
||||
END TextBackground;
|
||||
|
||||
PROCEDURE TextColor*(color : SHORTINT);
|
||||
BEGIN
|
||||
IF color = Black THEN
|
||||
SetAttr(vt100.Black)
|
||||
ELSIF color = Blue THEN
|
||||
SetAttr(vt100.Blue)
|
||||
ELSIF color = Green THEN
|
||||
SetAttr(vt100.Green)
|
||||
ELSIF color = Cyan THEN
|
||||
SetAttr(vt100.Cyan)
|
||||
ELSIF color = Red THEN
|
||||
SetAttr(vt100.Red)
|
||||
ELSIF color = Magenta THEN
|
||||
SetAttr(vt100.Magenta)
|
||||
ELSIF color = Brown THEN
|
||||
SetAttr(vt100.Yellow)
|
||||
ELSIF color = LightGray THEN
|
||||
SetAttr(vt100.LightGray)
|
||||
ELSIF color = DarkGray THEN
|
||||
SetAttr(vt100.DarkGray)
|
||||
ELSIF color = LightBlue THEN
|
||||
SetAttr(vt100.LightBlue)
|
||||
ELSIF color = LightGreen THEN
|
||||
SetAttr(vt100.LightBlue)
|
||||
ELSIF color = LightCyan THEN
|
||||
SetAttr(vt100.LightCyan)
|
||||
ELSIF color = LightRed THEN
|
||||
SetAttr(vt100.LightRed)
|
||||
ELSIF color = LightMagenta THEN
|
||||
SetAttr(vt100.LightMagenta)
|
||||
ELSIF color = Yellow THEN
|
||||
SetAttr(vt100.LightYellow)
|
||||
ELSIF color = White THEN
|
||||
SetAttr(vt100.White)
|
||||
END;
|
||||
END TextColor;
|
||||
|
||||
END crt.
|
||||
|
|
|
|||
57
src/test/vt100/crttest.Mod
Normal file
57
src/test/vt100/crttest.Mod
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
MODULE crttest;
|
||||
|
||||
IMPORT crt, vt100, Console, Strings;
|
||||
|
||||
|
||||
VAR tmpstr : ARRAY 32 OF CHAR;
|
||||
BEGIN
|
||||
(* test *)
|
||||
crt.EraseDisplay;
|
||||
crt.GotoXY (0, 0);
|
||||
|
||||
COPY(vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.Yellow, tmpstr);
|
||||
(*Strings.Append(vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.BBlue, tmpstr);*)
|
||||
Strings.Append(vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.Blink, tmpstr);
|
||||
Strings.Append("hello", tmpstr);
|
||||
Strings.Append(vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.ResetAll, tmpstr);
|
||||
Console.String(tmpstr); Console.Ln;
|
||||
Console.Ln;
|
||||
|
||||
COPY(vt100.CSI, tmpstr);
|
||||
Strings.Append (vt100.BRed, tmpstr);
|
||||
Strings.Append (" ", tmpstr);
|
||||
Console.String (tmpstr); Console.Ln;
|
||||
|
||||
COPY(vt100.CSI, tmpstr);
|
||||
Strings.Append (vt100.BBlue, tmpstr);
|
||||
Strings.Append (" ", tmpstr);
|
||||
Console.String (tmpstr); Console.Ln;
|
||||
|
||||
COPY(vt100.CSI, tmpstr);
|
||||
Strings.Append (vt100.BYellow, tmpstr);
|
||||
Strings.Append (" ", tmpstr);
|
||||
Console.String (tmpstr); Console.Ln;
|
||||
|
||||
COPY(vt100.CSI, tmpstr);
|
||||
Strings.Append(vt100.ResetAll, tmpstr);
|
||||
Console.String(tmpstr); Console.Ln;
|
||||
|
||||
crt.HighVideo;
|
||||
Console.String("high video"); Console.Ln;
|
||||
Console.Ln;
|
||||
crt.LowVideo;
|
||||
Console.String("low video"); Console.Ln;
|
||||
|
||||
crt.TextColor(crt.Red); Console.String("red"); Console.Ln;
|
||||
crt.TextColor(crt.Green); Console.String("green"); Console.Ln;
|
||||
crt.TextBackground(crt.Yellow); crt.TextColor(crt.Blue); Console.String("blue on yellow"); Console.Ln;
|
||||
|
||||
Console.Ln; Console.Ln;
|
||||
crt.Delay (2000);
|
||||
|
||||
|
||||
END crttest.
|
||||
|
|
@ -1,30 +1,69 @@
|
|||
MODULE vt100;
|
||||
|
||||
IMPORT Console, Strings, IntStr := oocIntStr;
|
||||
(* reference http://en.wikipedia.org/wiki/ANSI_escape_code *)
|
||||
(* reference http://en.wikipedia.org/wiki/ANSI_escape_code
|
||||
& http://misc.flogisoft.com/bash/tip_colors_and_formatting
|
||||
*)
|
||||
CONST
|
||||
|
||||
Escape* = 1BX;
|
||||
SynchronousIdle = 16X;
|
||||
SynchronousIdle* = 16X;
|
||||
LeftCrotchet* = '[';
|
||||
|
||||
(* colors *)
|
||||
Black* = "22;30m";
|
||||
Red* = "22;31m";
|
||||
Green* = "22;32m";
|
||||
Brown* = "22;33m";
|
||||
Blue* = "22;34m";
|
||||
Magenta* = "22;35m";
|
||||
Cyan* = "22;36m";
|
||||
Gray* = "22;37m";
|
||||
DarkGray* = "01;30m";
|
||||
LightRed* = "01;31m";
|
||||
LightGreen* = "01;32m";
|
||||
Yellow* = "01;33m";
|
||||
LightBlue* = "01;34m";
|
||||
LightMagenta* = "01;35m";
|
||||
LightCyan* = "01;36m";
|
||||
White* = "01;37m";
|
||||
(* formatting *)
|
||||
Bold* = "1m";
|
||||
Dim* = "2m";
|
||||
Underlined* = "4m";
|
||||
Blink* = "5m"; (* does not work with most emulators, works in tty and xterm *)
|
||||
Reverse* = "7m"; (* invert the foreground and background colors *)
|
||||
Hidden* = "8m"; (* useful for passwords *)
|
||||
|
||||
(* reset *)
|
||||
ResetAll* = "0m";
|
||||
ResetBold* = "21m";
|
||||
ResetDim* = "22m";
|
||||
ResetUnderlined* = "24m";
|
||||
ResetBlink* = "25m";
|
||||
ResetReverse* = "27m";
|
||||
ResetHidden* = "28m";
|
||||
|
||||
(* foreground colors *)
|
||||
Black* = "30m";
|
||||
Red* = "31m";
|
||||
Green* = "32m";
|
||||
Yellow* = "33m";
|
||||
Blue* = "34m";
|
||||
Magenta* = "35m";
|
||||
Cyan* = "36m";
|
||||
LightGray* = "37m";
|
||||
Default* = "39m";
|
||||
DarkGray* = "90m";
|
||||
LightRed* = "91m";
|
||||
LightGreen* = "92m";
|
||||
LightYellow* = "93m";
|
||||
LightBlue* = "94m";
|
||||
LightMagenta* = "95m";
|
||||
LightCyan* = "96m";
|
||||
White* = "97m";
|
||||
|
||||
(* background colors *)
|
||||
BBlack* = "40m";
|
||||
BRed* = "41m";
|
||||
BGreen* = "42m";
|
||||
BYellow* = "43m";
|
||||
BBlue* = "44m";
|
||||
BMagenta* = "45m";
|
||||
BCyan* = "46m";
|
||||
BLightGray* = "47m";
|
||||
BDefault* = "49m";
|
||||
BDarkGray* = "100m";
|
||||
BLightRed* = "101m";
|
||||
BLightGreen* = "102m";
|
||||
BLightYellow* = "103m";
|
||||
BLightBlue* = "104m";
|
||||
BLightMagenta*= "105m";
|
||||
BLightCyan* = "106m";
|
||||
BWhite* = "107m";
|
||||
|
||||
VAR
|
||||
CSI* : ARRAY 5 OF CHAR;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue