This repository was archived by the owner on Oct 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.pas
106 lines (81 loc) · 2.21 KB
/
utils.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
unit utils;
interface
uses
Windows;
const
NOIR = 0;
BLEU_FONCE = 1;
VERT_FONCE = 2;
CYAN_FONCE = 3;
ROUGE_FONCE = 4;
MAGENTA_FONCE = 5;
MARRON = 6;
GRIS_PALE = 7;
GRIS_FONCE = 8;
BLEU_PALE = 9;
VERT_PALE = 10;
CYAN_PALE = 11;
ROUGE_PALE = 12;
MAGENTA_PALE = 13;
JAUNE = 14;
BLANC = 15;
//CLIGNOTER = 128; //win98 seulement
procedure GotoXY(X: integer; Y: integer);
procedure GetCursorPosition(var X, Y : Integer);
function GetRealPath(Path : string) : string;
procedure SetColor(caractere: byte; fond: byte);
implementation
//------------------------------------------------------------------------------
procedure SetColor(caractere: byte; fond: byte);
begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
caractere + (fond * 16));
end;
//------------------------------------------------------------------------------
procedure GotoXY(X: integer; Y: integer);
var
pos: TCoord; { Variable pour l'appel de SetConsoleCursorPosition() }
begin
{ Placer nos valeurs dans la variable pos }
pos.x := x;
pos.y := y;
{ Positionner le curseur dans l'écran }
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
end;
//------------------------------------------------------------------------------
procedure GetCursorPosition(var X, Y : Integer);
var
info : CONSOLE_SCREEN_BUFFER_INFO;
begin
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), info);
X := info.dwCursorPosition.X;
Y := info.dwCursorPosition.Y;
end;
//------------------------------------------------------------------------------
function GetRealPath(Path : string) : string;
var
i : integer;
LastCharWasSeparator : Boolean;
begin
Result := '';
LastCharWasSeparator := False;
Path := Path + '\';
for i := 1 to Length(Path) do
begin
if Path[i] = '\' then
begin
if not LastCharWasSeparator then
begin
Result := Result + Path[i];
LastCharWasSeparator := True;
end
end
else
begin
LastCharWasSeparator := False;
Result := Result + Path[i];
end;
end;
end;
//------------------------------------------------------------------------------
end.