174 lines
2.0 KiB
Markdown
174 lines
2.0 KiB
Markdown
# Manual
|
|
|
|
```lua
|
|
local syscalls = require("syscalls")
|
|
```
|
|
|
|
|
|
|
|
## Events
|
|
|
|
```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
|
|
|
|
## 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`
|
|
|
|
|