mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 04:02:25 +00:00
module crt almost completed, crttest for reference
Former-commit-id: 4943886b64
This commit is contained in:
parent
88215c3480
commit
da0807d369
4 changed files with 257 additions and 30 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
VOC = /opt/voc/bin/voc
|
VOC = /opt/voc/bin/voc
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(VOC) -s vt100.Mod crt.Mod -M
|
$(VOC) -s vt100.Mod crt.Mod crttest.Mod -M
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm *.h
|
rm *.h
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,31 @@ MODULE crt;
|
||||||
IMPORT vt100, Unix, Console,
|
IMPORT vt100, Unix, Console,
|
||||||
Strings; (* strings to remove later ? *)
|
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
|
TYPE
|
||||||
PFdSet = POINTER TO Unix.FdSet;
|
PFdSet = POINTER TO Unix.FdSet;
|
||||||
|
|
||||||
|
|
@ -44,21 +69,127 @@ VAR tmpstr : ARRAY 23 OF CHAR;
|
||||||
i := Unix.Select(0, pfd^, pfd^, pfd^, tv);
|
i := Unix.Select(0, pfd^, pfd^, pfd^, tv);
|
||||||
END Delay;
|
END Delay;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE GotoXY* (x, y: INTEGER);
|
PROCEDURE GotoXY* (x, y: INTEGER);
|
||||||
BEGIN
|
BEGIN
|
||||||
vt100.CUP (y, x);
|
vt100.CUP (y, x);
|
||||||
END GotoXY;
|
END GotoXY;
|
||||||
|
|
||||||
|
PROCEDURE HighVideo*;
|
||||||
|
VAR tmpstr: ARRAY 5 OF CHAR;
|
||||||
BEGIN
|
BEGIN
|
||||||
(* test *)
|
|
||||||
EraseDisplay;
|
|
||||||
GotoXY (0, 0);
|
|
||||||
COPY (vt100.CSI, tmpstr);
|
COPY (vt100.CSI, tmpstr);
|
||||||
Strings.Append(vt100.Green, tmpstr);
|
Strings.Append(vt100.Bold, tmpstr);
|
||||||
Strings.Append("hello", tmpstr);
|
Console.String(tmpstr);
|
||||||
Console.String(tmpstr); Console.Ln;
|
END HighVideo;
|
||||||
Delay (2000);
|
|
||||||
|
|
||||||
|
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.
|
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;
|
MODULE vt100;
|
||||||
|
|
||||||
IMPORT Console, Strings, IntStr := oocIntStr;
|
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
|
CONST
|
||||||
|
|
||||||
Escape* = 1BX;
|
Escape* = 1BX;
|
||||||
SynchronousIdle = 16X;
|
SynchronousIdle* = 16X;
|
||||||
LeftCrotchet* = '[';
|
LeftCrotchet* = '[';
|
||||||
|
|
||||||
(* colors *)
|
(* formatting *)
|
||||||
Black* = "22;30m";
|
Bold* = "1m";
|
||||||
Red* = "22;31m";
|
Dim* = "2m";
|
||||||
Green* = "22;32m";
|
Underlined* = "4m";
|
||||||
Brown* = "22;33m";
|
Blink* = "5m"; (* does not work with most emulators, works in tty and xterm *)
|
||||||
Blue* = "22;34m";
|
Reverse* = "7m"; (* invert the foreground and background colors *)
|
||||||
Magenta* = "22;35m";
|
Hidden* = "8m"; (* useful for passwords *)
|
||||||
Cyan* = "22;36m";
|
|
||||||
Gray* = "22;37m";
|
(* reset *)
|
||||||
DarkGray* = "01;30m";
|
ResetAll* = "0m";
|
||||||
LightRed* = "01;31m";
|
ResetBold* = "21m";
|
||||||
LightGreen* = "01;32m";
|
ResetDim* = "22m";
|
||||||
Yellow* = "01;33m";
|
ResetUnderlined* = "24m";
|
||||||
LightBlue* = "01;34m";
|
ResetBlink* = "25m";
|
||||||
LightMagenta* = "01;35m";
|
ResetReverse* = "27m";
|
||||||
LightCyan* = "01;36m";
|
ResetHidden* = "28m";
|
||||||
White* = "01;37m";
|
|
||||||
|
(* 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
|
VAR
|
||||||
CSI* : ARRAY 5 OF CHAR;
|
CSI* : ARRAY 5 OF CHAR;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue