DEADSOFTWARE

more portable texture/sky preview
[d2df-editor.git] / src / shared / console.pas
1 unit console;
3 interface
5 procedure print(Text: string);
7 implementation
9 uses
10 windows;
12 procedure print(Text: string);
13 var
14 a, len: Integer;
15 attr: Word;
16 h: LongWord;
17 begin
18 h := GetStdHandle(STD_OUTPUT_HANDLE);
20 attr := FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_BLUE;
21 SetConsoleTextAttribute(h, attr);
23 len := Length(Text);
25 for a := 1 to len do
26 begin
27 if Text[a] = '^' then Continue;
28 if Byte(Text[a]) = 7 then Continue;
30 if (a = 1) or (Text[a-1] <> '^') then
31 begin
32 write(Text[a]);
33 Continue;
34 end;
36 if a < len then
37 begin
38 case Text[a] of
39 '1': attr := FOREGROUND_RED;
40 '2': attr := FOREGROUND_GREEN;
41 '3': attr := FOREGROUND_BLUE;
42 '4': attr := FOREGROUND_BLUE or FOREGROUND_RED;
43 '5': attr := FOREGROUND_GREEN or FOREGROUND_RED;
44 '6': attr := FOREGROUND_BLUE or FOREGROUND_GREEN;
45 '7': attr := FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED;
46 else Continue;
47 end;
49 if (a > 2) and (Text[a-2] = '^') then attr := attr or FOREGROUND_INTENSITY;
51 SetConsoleTextAttribute(h, attr)
52 end;
53 end;
55 WriteLn;
57 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_BLUE);
58 end;
60 end.