files
syscalls/doc/manual.md
Егор 186fbe426e Update manual
Add more funcs
2025-04-16 08:41:11 +02:00

234 lines
2.7 KiB
Markdown

# Manual
```lua
local syscalls = require("syscalls")
```
## Events
### `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`
## 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, w, h color)`
### `ReadPoint(x, y)`
return color
## Buttons
### `GetButton()`
return pressed button or nil
### buttons
button's ids that defined default by window with skin
```lua
syscalls.buttons.<Value>
```
+ `close`
+ `minimize`
## SystemColors
### SystemColors type
### `GetSystemColors()`
return SystemColors
### `SetSytemColors(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
}
```
## 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`