521 lines
6.7 KiB
Markdown
521 lines
6.7 KiB
Markdown
# Manual
|
|
|
|
This is KolibriOS lua syscalls library. Usually you shouldn't use this library
|
|
|
|
Better if you read before [KolibriOS syscalls wiki](http://wiki.kolibrios.org/wiki/)
|
|
|
|
include:
|
|
```lua
|
|
local syscalls = require("syscalls")
|
|
```
|
|
|
|
## Events
|
|
|
|
### `SetEventMask(newMask)`
|
|
|
|
### `CheckEvent()`
|
|
|
|
check event
|
|
|
|
### `WaitEvent()`
|
|
|
|
Endless wait event
|
|
|
|
### `WaitEventTimeout(timeout)`
|
|
|
|
Wait timeout 1/100 sec
|
|
|
|
return event or `nil`
|
|
|
|
### Events list
|
|
|
|
```lua
|
|
syscalls.Event.<EventName>
|
|
```
|
|
|
|
+ `Redraw`
|
|
+ `Button`
|
|
+ `Key`
|
|
+ `Desktop`
|
|
+ `Mouse`
|
|
+ `Network`
|
|
+ `IPC`
|
|
+ `Debug`
|
|
|
|
## Window
|
|
|
|
### `CreateWindow(x, y, width, height, workColor, style, borderColor, titleColor)`
|
|
|
|
Define window
|
|
|
|
`borderColor` and `borderColor` only for `FixSizes` and `CanChangeSizes` (without skin styles) style.
|
|
|
|
### `StartRedraw()`
|
|
|
|
Start window redraw. Just call it before `CreateWindow`
|
|
|
|
### `EndRedraw()`
|
|
|
|
End window redraw. Just call it after you done redraw window.
|
|
|
|
### `ChangeWindow(newX, newY, newWidth, newHeight)`
|
|
|
|
### `FocusWindow(slot)`
|
|
|
|
### `UnfocusWindow(slot)`
|
|
|
|
### `SetWindowTitle(newTitle)`
|
|
|
|
### `GetSkinHeight()`
|
|
|
|
return skin height.
|
|
|
|
### `SetSkin(path)`
|
|
|
|
return error code
|
|
|
|
### `GetSkinTitleArea()`
|
|
|
|
return table:
|
|
```lua
|
|
{
|
|
Left: number,
|
|
Right: number,
|
|
Top: number,
|
|
Bottom: number
|
|
}
|
|
```
|
|
|
|
### Style
|
|
|
|
```lua
|
|
syscalls.windowStyle.<Value>
|
|
```
|
|
|
|
+ `FixSizes`
|
|
+ `NoDraw` (you must draw window manually)
|
|
+ `CanChangeSizes`
|
|
+ `WithSkin` (usually use it)
|
|
+ `WithSkinFixSizes` (with skin, but window size fixed)
|
|
|
|
## Graphic
|
|
|
|
### Text encoding
|
|
|
|
```lua
|
|
syscalls.Encoding.<value>
|
|
```
|
|
|
|
+ `cp866`
|
|
+ `cp866_8x16`
|
|
+ `utf8`
|
|
+ `utf16`
|
|
|
|
### Text sizes
|
|
|
|
```lua
|
|
syscalls.textSize.<value>
|
|
```
|
|
|
|
+ `6x9` (cp866 only)
|
|
+ `8x16`
|
|
+ `12x18` (cp866 only)
|
|
+ `16x32`
|
|
+ `18x27` (cp866 only)
|
|
+ `24x36` (cp866 only)
|
|
+ `24x48`
|
|
+ `30x45` (cp866 only)
|
|
+ `32x64`
|
|
+ `36x54` (cp866 only)
|
|
+ `40x80`
|
|
+ `42x63` (cp866 only)
|
|
+ `48x72` (cp866 only)
|
|
+ `48x96`
|
|
+ `56x112`
|
|
+ `64x128`
|
|
|
|
### `DrawText(text, xPos, yPos, textColor, textScale, textLen, backgroundColor, encoding)`
|
|
|
|
### `DrawTextFixSize(text, xPos, yPos, textColor, textSize, textLen, backgroundColor, encoding)`
|
|
|
|
Draw text.
|
|
|
|
textSize, textLen, backgroundColor, encoding are optional.
|
|
|
|
### `DrawLine(x1, y1, x2, y2)`
|
|
|
|
### `DrawRectangle(x, y, widht, height, color)`
|
|
|
|
### `ReadPoint(x, y)`
|
|
|
|
return color
|
|
|
|
## Buttons
|
|
|
|
### `DefineButton(x, y, widht, height, id, color)`
|
|
|
|
### `DeleteButton(id)`
|
|
|
|
### `GetButton()`
|
|
|
|
return pressed button or `nil`
|
|
|
|
### `SetButtonStyle(style)`
|
|
|
|
|
|
### buttons
|
|
|
|
button's ids that defined default by window with skin
|
|
|
|
```lua
|
|
syscalls.buttons.<Value>
|
|
```
|
|
|
|
+ `close`
|
|
+ `minimization`
|
|
|
|
### ButtonStyles
|
|
|
|
```lua
|
|
syscalls.buttonStyle.<Value>
|
|
```
|
|
|
|
## Keyboard
|
|
|
|
### `GetKey()`
|
|
|
|
return:
|
|
+ nil if buffer empty
|
|
+ if hotkey return second number
|
|
+ if key pressed and key input mode is ascii return string(1 char), else return scancode
|
|
|
|
example:
|
|
|
|
```lua
|
|
local key, hotkey = syscalls.GetKey()
|
|
|
|
if key then
|
|
print("key pressed")
|
|
end
|
|
|
|
if hotkey then
|
|
print(hotkey pressed)
|
|
end
|
|
```
|
|
|
|
### `SetKeyInputMode(mode)`
|
|
|
|
by default is `ASCII`
|
|
|
|
### `GetKeyInputMode()`
|
|
|
|
return key input mode.
|
|
|
|
isn't syscall
|
|
|
|
### Scancodes
|
|
|
|
```lua
|
|
syscalls.scancode.<Value>
|
|
```
|
|
|
|
+ `A`
|
|
+ `B`
|
|
+ `C`
|
|
+ `D`
|
|
+ `E`
|
|
+ `F`
|
|
+ `G`
|
|
+ `H`
|
|
+ `J`
|
|
+ `K`
|
|
+ `L`
|
|
+ `M`
|
|
+ `O`
|
|
+ `P`
|
|
+ `Q`
|
|
+ `S`
|
|
+ `T`
|
|
+ `U`
|
|
+ `W`
|
|
+ `X`
|
|
+ `Y`
|
|
+ `Z`
|
|
+ `1`
|
|
+ `2`
|
|
+ `3`
|
|
+ `4`
|
|
+ `5`
|
|
+ `6`
|
|
+ `7`
|
|
+ `8`
|
|
+ `9`
|
|
+ `F1`
|
|
+ `F2`
|
|
+ `F3`
|
|
+ `F4`
|
|
+ `F5`
|
|
+ `F6`
|
|
+ `F7`
|
|
+ `F8`
|
|
+ `F9`
|
|
+ `F10`
|
|
+ `F11`
|
|
+ `F12`
|
|
+ `LeftShift`
|
|
+ `RightShift`
|
|
+ `LeftAlt`
|
|
+ `RightAlt`
|
|
+ `Tab`
|
|
|
|
## SystemColors
|
|
|
|
### SystemColors type
|
|
|
|
userdata
|
|
|
|
#### Fields
|
|
|
|
```lua
|
|
{
|
|
frameArea: number,
|
|
grabBar: number,
|
|
grabBarButton: number,
|
|
grabButtonText: number
|
|
grabText: number,
|
|
workArea: number,
|
|
workButton: number,
|
|
workButton: number,
|
|
workButtonText: number,
|
|
workGraph: number,
|
|
workText: number
|
|
}
|
|
```
|
|
|
|
#### Constructor
|
|
|
|
```lua
|
|
syscalls.SystemColors.new(
|
|
frameArea,
|
|
grabBar,
|
|
grabBarButton,
|
|
grabButtonText,
|
|
grabText,
|
|
workArea,
|
|
workButton,
|
|
workButton,
|
|
workButtonText,
|
|
workGraph,
|
|
workText
|
|
)
|
|
```
|
|
|
|
### `GetSystemColors()`
|
|
|
|
return SystemColors
|
|
|
|
### `SetSystemColors(SystemColors)`
|
|
|
|
## Threads
|
|
|
|
### `ThreadInfo(pid)`
|
|
|
|
return table:
|
|
```lua
|
|
{
|
|
name: string,
|
|
pid: number,
|
|
cpu_usage: number,
|
|
memused: number,
|
|
winXPos: number,
|
|
winYPos: number,
|
|
winXSize: number,
|
|
winYPos: number,
|
|
slotState: number,
|
|
windowState: number,
|
|
slotNumWindowStack: number,
|
|
posInWindowStack: number,
|
|
keyInputMode: number
|
|
}
|
|
```
|
|
|
|
### `KillBySlot(slot)`
|
|
|
|
### Slot states
|
|
|
|
```lua
|
|
syscalls.slotState.<Value>
|
|
```
|
|
|
|
+ `Running`
|
|
+ `Suspended`
|
|
+ `SuspendedWaitEvent`
|
|
+ `NormalTerm`
|
|
+ `ExceptTerm`
|
|
+ `WaitEvent`
|
|
+ `Free`
|
|
|
|
## Sockets
|
|
|
|
### `OpenSocket(domain, type, protocol)`
|
|
|
|
```lua
|
|
local socket, err = syscalls.OpenSocket(
|
|
syscalls.SOCK.STREAM,
|
|
syscalls.AF.INET,
|
|
syscalls.IPPROTO.IP
|
|
)
|
|
|
|
if err then
|
|
print("Error", err)
|
|
else
|
|
print("Ok")
|
|
end
|
|
```
|
|
|
|
### `CloseSocket(socket)`
|
|
|
|
### `PairSocket()`
|
|
|
|
```lua
|
|
local first, second = PairSocket()
|
|
|
|
if first then
|
|
print("OK")
|
|
else
|
|
print("Error:", second)
|
|
end
|
|
```
|
|
|
|
### `Bind(socket, address)`
|
|
|
|
### `Listen(socket, backlog)`
|
|
|
|
### `Connect(socket, address)`
|
|
|
|
### `Accept(socket, , flags)`
|
|
|
|
### `Receive(socket, , flags)`
|
|
|
|
### `SetSocketOption(socket, opt)`
|
|
|
|
### `GetSocketOption(socket, opt)`
|
|
|
|
### Socket types
|
|
|
|
```lua
|
|
syscalls.SOCK.<Value>
|
|
```
|
|
|
|
+ `STREAM`
|
|
+ `RAW`
|
|
+ `DGRAM`
|
|
|
|
### Address families
|
|
|
|
```lua
|
|
syscalls.AF.<Value>
|
|
```
|
|
|
|
+ `UNSPEC`
|
|
+ `LOCAL`
|
|
+ `INET`
|
|
+ `INET4`
|
|
+ `INET6`
|
|
|
|
### IP options
|
|
|
|
```lua
|
|
syscalls.IP.<Value>
|
|
```
|
|
|
|
+ `TTL`
|
|
|
|
### IP protocols
|
|
|
|
```lua
|
|
syscalls.IPPROTO.<Value>
|
|
```
|
|
|
|
+ `IP`
|
|
+ `ICMP`
|
|
+ `TCP`
|
|
+ `UDP`
|
|
+ `RAW`
|
|
|
|
### Socket options
|
|
|
|
```lua
|
|
syscalls.SO.<Value>
|
|
```
|
|
|
|
+ `BINDTODEVICE`
|
|
+ `NONBLOCK`
|
|
|
|
## Debug
|
|
|
|
### Registers type
|
|
|
|
```lua
|
|
{
|
|
eax: number
|
|
ebx: number,
|
|
esp: number,
|
|
esi: number,
|
|
edi: number,
|
|
eip: number,
|
|
eflags: number
|
|
}
|
|
```
|
|
|
|
### `DebugPutc(char)`
|
|
|
|
Put char to debug board
|
|
|
|
### `DebugPuts(text)`
|
|
|
|
Put string to debug board
|
|
|
|
### `GetRegisters(pid)`
|
|
|
|
The process must be loaded for debugging (as stated in the general description).
|
|
|
|
return registers table
|
|
|
|
### `SetRegisters(pid, registers)`
|
|
|
|
The process must be loaded for debugging (as stated in the general description).
|
|
|
|
### `Disconnect(pid)`
|
|
|
|
The process must be loaded for debugging (as stated in the general description).
|
|
|
|
If the process was suspended, it resumes execution.
|
|
|
|
### `Stop(pid)`
|
|
|
|
The process must be loaded for debugging (as stated in the general description).
|
|
|
|
### `Continue(pid)`
|
|
|
|
The process must be loaded for debugging (as stated in the general description).
|
|
|
|
### `ReadFromMem(pid, bytes, pointer, buffer)`
|
|
|
|
The process must be loaded for debugging (as stated in the general description).
|
|
|
|
return or `nil`
|
|
|
|
### `WriteToMem(pid, bytes, pointer, buffer)`
|
|
|
|
The process must be loaded for debugging (as stated in the general description).
|
|
|
|
return or `nil`
|
|
|
|
### `Done(pid)`
|
|
|
|
### `DefineBreakpoint(pid, index, condition, len)`
|
|
|
|
### `UndefBreakpoint(pid, index, condition, len)`
|
|
|