Subversion Repositories Kolibri OS

Rev

Rev 619 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
616 bw 1
{}
2
 
3
type
4
  TKosPoint = packed record
5
    X: Longint;
6
    Y: Longint;
7
  end;
8
 
9
  TKosRect = packed record
10
  case Integer of
11
    0: (Left, Top, Width, Height: Longint);
12
    1: (TopLeft, HeightWidth: TKosPoint);
13
  end;
14
 
15
{ User interface }
16
procedure kos_definewindow(x, y, w, h: Word; style: DWord = $23FFFFFF; header: DWord = $008899FF; clframe: DWord = $008899FF);
17
procedure kos_movewindow(x, y, w, h: DWord);
18
function kos_getkey(): DWord;
19
function kos_getevent(wait: Boolean = True): DWord;
20
function kos_waitevent(timeout: DWord): DWord;
21
function kos_getbutton(): DWord;
22
function kos_getmousepos(): TKosPoint;
23
function kos_getmousewinpos(): TKosPoint;
24
function kos_getmousebuttons(): DWord;
25
procedure kos_maskevents(mask: DWord);
26
procedure kos_setcaption(caption: PChar);
27
 
28
{ Graphics }
29
procedure kos_begindraw();
30
procedure kos_enddraw();
31
procedure kos_putpixel(x, y: Word; color: DWord = $000000);
32
procedure kos_drawtext(x, y: Word; text: String; flags: DWord = $000000; bgcolor: DWord = $00FFFFFF);
33
procedure kos_drawrect(x, y, w, h: Word; color: DWord = $000000);
34
procedure kos_drawline(x1, y1, x2, y2: Word; color: DWord = $000000);
35
procedure kos_drawimage(x, y, w, h, depth: DWord; image: Pointer; palette: Pointer = nil; xoffset: DWord = 0);
36
procedure kos_drawimage24(x, y, w, h: DWord; image: Pointer);
37
 
38
{ Work with system }
39
 
40
{ Work with system - System services }
41
function kos_killthread(tid: TThreadID): Boolean;
42
procedure kos_setactivewindow(slot: TThreadSlot);
43
function kos_getthreadslot(tid: TThreadID): TThreadSlot;
44
 
45
{ Work with system - Set system parameters }
46
procedure kos_enablepci();
47
 
48
{ Work with system - Internal system services }
49
procedure kos_switchthread();
50
function kos_initheap(): DWord;
51
function kos_alloc(size: DWord): Pointer;
52
function kos_free(ptr: Pointer): Boolean;
53
function kos_loaddriver(name: PChar): THandle;
54
 
55
{ Processes and threads }
56
type
57
  PKosThreadInfo = ^TKosThreadInfo;
58
  TKosThreadInfo = packed record
59
    Speed: DWord;
60
    WindowID: Word;
61
    ThreadSlot: Word;
62
    Reserved1: Word;
63
    AppName: array[0..10] of Char;
64
    Reserved2: Byte;
65
    ProcessBase: Pointer;
66
    MemoryUsage: DWord;
67
    ThreadID: TThreadID;
68
    WindowRect: TKosRect;
69
    Unknown0: array[1..1066] of Byte;
70
  end;
71
 
72
  {Буфер IPC}
73
  PKosIPC = ^TKosIPC;
74
  TKosIPC = packed record
75
    Lock: LongBool;
76
    Size: DWord;
77
    {сообщение #1...}
78
    {сообщение #2...}
79
    {...}
80
  end;
81
 
82
  {Сообщение IPC}
83
  PKosMessage = ^TKosMessage;
84
  TKosMessage = packed record
85
    SenderID: TThreadID;
86
    Size: DWord;
87
    {тело сообщения...}
88
  end;
89
 
90
function kos_threadinfo(info: PKosThreadInfo; slot: TThreadSlot = -1): DWord;
91
function kos_newthread(entry, stack: Pointer): TThreadID;
92
procedure kos_initipc(ipc: PKosIPC; size: DWord);
93
function kos_sendmsg(tid: TThreadID; msg: Pointer; size: DWord): DWord;
94
function kos_resizemem(size: DWord): Boolean;
95
 
96
{ File system }
97
{ File system - Work with the current folder }
98
 
99
procedure kos_setdir(path: PChar);
100
function kos_getdir(path: PChar; size: DWord): DWord;
101
 
102
{ File system - Work with file system with long names support }
103
 
104
const
105
  kfReadOnly   = $01;
106
  kfHidden     = $02;
107
  kfSystem     = $04;
108
  kfLabel      = $08;
109
  kfFolder     = $10;
110
  kfNotArchive = $20;
111
 
112
type
113
  PKosFile = ^TKosFile;
114
  TKosFile = packed record
115
    SubFunc: DWord;
116
    Position, PositionReserved: DWord;
117
    Size: DWord;
118
    Data: Pointer;
119
    Name: array[0..0] of Char; {...ASCIIZ}
120
  end;
121
 
122
  PKosBDFE = ^TKosBDFE;
123
  TKosBDFE = packed record
124
    Attributes: DWord;
125
    NameType: Byte; {bit0 - 0:ascii, 1:unicode}
126
    Reserved: array[0..2] of Byte;
127
    CTime: DWord;  {ss,mm,hh,00}
128
    CDate: DWord;  {dd,mm,yyyy}
129
    ATime: DWord;
130
    ADate: DWord;
131
    MTime: DWord;
132
    MDate: DWord;
133
    Size: QWord;
134
    Name: array[0..519] of Char;
135
  end;
136
 
137
function kos_readfile(kosfile: PKosFile; var readed: Longint): DWord;
138
function kos_rewritefile(kosfile: PKosFile; var writed: Longint): DWord;
139
function kos_writefile(kosfile: PKosFile; var writed: Longint): DWord;
140
function kos_fileinfo(kosfile: PKosFile): DWord;
141
 
142
{ Work with hardware }
143
function kos_readport(index: DWord): DWord;
144
procedure kos_writeport(index, value: DWord);
145
function kos_reserveport(port: DWord): Boolean;
146
 
147
{ Work with hardware - Low-level access to PCI}
148
function kos_lastpcibus(): Byte;
149
function kos_readpcib(bus, dev, func, reg: Byte): Byte;
150
function kos_readpciw(bus, dev, func, reg: Byte): Word;
151
function kos_readpcid(bus, dev, func, reg: Byte): DWord;
152
 
153
{ Other }
154
procedure kos_delay(ms: DWord); {1/100 s}
155
 
156
{ my }
157
type
158
  TKosSign = array[0..7] of Byte;
159
  PKosHeader = ^TKosHeader;
160
  TKosHeader = packed record
161
    sign   : TKOSSign;
162
    version: DWord;
163
    start  : DWord;
164
    size   : DWord;
165
    memory : DWord;
166
    stack  : DWord;
167
    args   : PChar;
168
    path   : PChar;
169
  end;
170
 
171
{var
172
  KonsoleIPCBuffer: array[0..4096] of Byte;}
173
 
174
type
175
  PKonsole = ^TKonsole;
176
  TKonsole = object
177
  private
178
    FCaption: String;
179
    FLines: array of String;
180
    FCursor: TKosPoint;
181
    FMaxLines: Word;
182
    FThreadID: TThreadID;
183
    FThreadSlot: TThreadSlot;
184
    FIPCBuffer: PKosIPC;
185
    FIPCBufferSize: DWord;
186
    FTerminate: Boolean;
187
    FOpened: Boolean;
188
    FKeyPressed: Word;
189
    function ReceiveMessage(var Message: ShortString): Boolean;
190
    procedure ProcessMessage(Message: ShortString);
191
    procedure ProcessKeyboard(Key: Word);
192
    function GetRect(): TKosRect;
193
    function GetKeyPressed(): Word;
194
    procedure Paint(BottomRow: Boolean = False);
195
  public
196
    constructor Init(ACaption: String = '');
197
    destructor Done();
198
    procedure Write(Message: ShortString);
199
    property KeyPressed: Word read GetKeyPressed;
200
    property Opened: Boolean read FOpened;
201
    property ThreadID: TThreadID read FThreadID;       {JustForFun, must be hidden, do not use}
202
    property ThreadSlot: TThreadSlot read FThreadSlot; {JustForFun, must be hidden, do not use}
203
  end;
204
 
205
  IStreamIO = interface
206
    function Read(Size: DWord = 0): AnsiString;
207
    procedure Write(Str: AnsiString; Error: Boolean = False);
208
  end;