create buffer class && some warnings fixes && update manual && create vscode tasks

This commit is contained in:
2025-05-08 23:48:52 +05:00
parent 79a79c5409
commit 521d00fdb8
16 changed files with 547 additions and 107 deletions

View File

@@ -4,24 +4,24 @@ 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:
include this library:
```lua
local syscalls = require("syscalls")
```
## Events
### `SetEventMask(newMask)`
### SetEventMask(newMask)
### `CheckEvent()`
### CheckEvent()
check event
check [event](#events-list)
### `WaitEvent()`
### WaitEvent()
Endless wait event
Endless wait [event](#events-list)
### `WaitEventTimeout(timeout)`
### WaitEventTimeout(timeout)
Wait timeout 1/100 sec
@@ -44,37 +44,37 @@ syscalls.Event.<EventName>
## Window
### `CreateWindow(x, y, width, height, workColor, style, borderColor, titleColor)`
### CreateWindow(x, y, width, height, workColor, [style](#window-style), borderColor, titleColor)
Define window
`borderColor` and `borderColor` only for `FixSizes` and `CanChangeSizes` (without skin styles) style.
`borderColor` and borderColor` only for FixSizes` and CanChangeSizes` (without skin styles) style.
### `StartRedraw()`
### StartRedraw()
Start window redraw. Just call it before `CreateWindow`
Start window redraw. Just call it before CreateWindow`
### `EndRedraw()`
### EndRedraw()
End window redraw. Just call it after you done redraw window.
### `ChangeWindow(newX, newY, newWidth, newHeight)`
### ChangeWindow(newX, newY, newWidth, newHeight)
### `FocusWindow(slot)`
### FocusWindow(slot)
### `UnfocusWindow(slot)`
### UnfocusWindow(slot)
### `SetWindowTitle(newTitle)`
### SetWindowTitle(newTitle)
### `GetSkinHeight()`
### GetSkinHeight()
return skin height.
### `SetSkin(path)`
### SetSkin(path)
return error code
### `GetSkinTitleArea()`
### GetSkinTitleArea()
return table:
```lua
@@ -86,7 +86,7 @@ return table:
}
```
### Style
### Window Style
```lua
syscalls.windowStyle.<Value>
@@ -134,34 +134,35 @@ syscalls.textSize.<value>
+ `56x112`
+ `64x128`
### `DrawText(text, xPos, yPos, textColor, textScale, textLen, backgroundColor, encoding)`
### DrawText(text, xPos, yPos, textColor, [textScale](#text-sizes), textLen, backgroundColor, [encoding](#text-encoding))
### `DrawTextFixSize(text, xPos, yPos, textColor, textSize, textLen, backgroundColor, encoding)`
### DrawTextFixSize(text, xPos, yPos, textColor, [textScale](#text-sizes), textLen, backgroundColor, [encoding](#text-encoding))
Draw text.
textSize, textLen, backgroundColor, encoding are optional.
### `DrawLine(x1, y1, x2, y2)`
### DrawLine(x1, y1, x2, y2)
### `DrawRectangle(x, y, widht, height, color)`
### DrawRectangle(x, y, width, height, color)
### `ReadPoint(x, y)`
### ReadPoint(x, y)
return color
## Buttons
### `DefineButton(x, y, widht, height, id, color)`
### DefineButton(x, y, width, height, id, color)
### `DeleteButton(id)`
### DeleteButton(id)
### `GetButton()`
### GetButton()
return pressed button or `nil`
### `SetButtonStyle(style)`
### SetButtonStyle([style](#button-styles))
Set buttons style
### buttons
@@ -174,20 +175,23 @@ syscalls.buttons.<Value>
+ `close`
+ `minimization`
### ButtonStyles
### Button styles
```lua
syscalls.buttonStyle.<Value>
```
+ `Flat`
+ `Volume`
## Keyboard
### `GetKey()`
### GetKey()
return:
+ nil if buffer empty
+ `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
+ if key pressed and key input mode is ascii return string(1 char), else return [scancode](#scancodes)
example:
@@ -199,15 +203,15 @@ if key then
end
if hotkey then
print(hotkey pressed)
print("hotkey pressed")
end
```
### `SetKeyInputMode(mode)`
### SetKeyInputMode(mode)
by default is `ASCII`
### `GetKeyInputMode()`
### GetKeyInputMode()
return key input mode.
@@ -310,17 +314,18 @@ syscalls.SystemColors.new(
)
```
### `GetSystemColors()`
### GetSystemColors()
return SystemColors
return [SystemColors](#systemcolors-type)
### `SetSystemColors(SystemColors)`
### SetSystemColors([SystemColors](#systemcolors-type))
## Threads
### `ThreadInfo(pid)`
### ThreadInfo(pid)
return table:
```lua
{
name: string,
@@ -339,7 +344,7 @@ return table:
}
```
### `KillBySlot(slot)`
### KillBySlot(slot)
### Slot states
@@ -357,7 +362,9 @@ syscalls.slotState.<Value>
## Sockets
### `OpenSocket(domain, type, protocol)`
### OpenSocket([domain](#socket-types), [type](#address-families), [protocol](#ip-protocols))
return socket
```lua
local socket, err = syscalls.OpenSocket(
@@ -373,9 +380,9 @@ else
end
```
### `CloseSocket(socket)`
### CloseSocket(socket)
### `PairSocket()`
### PairSocket()
```lua
local first, second = PairSocket()
@@ -387,19 +394,19 @@ else
end
```
### `Bind(socket, address)`
### Bind(socket, address)
### `Listen(socket, backlog)`
### Listen(socket, backlog)
### `Connect(socket, address)`
### Connect(socket, address)
### `Accept(socket, , flags)`
### Accept(socket, , flags)
### `Receive(socket, , flags)`
### Receive(socket, , flags)
### `SetSocketOption(socket, opt)`
### SetSocketOption(socket, [opt](#socket-options))
### `GetSocketOption(socket, opt)`
### GetSocketOption(socket, [opt](#socket-options))
### Socket types
@@ -468,53 +475,116 @@ syscalls.SO.<Value>
}
```
### `DebugPutc(char)`
### DebugPutc(char)
Put char to debug board
### `DebugPuts(text)`
### DebugPuts(text)
Put string to debug board
### `GetRegisters(pid)`
### GetRegisters(pid)
The process must be loaded for debugging (as stated in the general description).
return registers table
### `SetRegisters(pid, registers)`
### SetRegisters(pid, [registers](#registers-type))
The process must be loaded for debugging (as stated in the general description).
### `Disconnect(pid)`
### 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)`
### Stop(pid)
The process must be loaded for debugging (as stated in the general description).
### `Continue(pid)`
### Continue(pid)
The process must be loaded for debugging (as stated in the general description).
### `ReadFromMem(pid, bytes, pointer, buffer)`
### 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)`
### WriteToMem(pid, bytes, pointer, buffer)
The process must be loaded for debugging (as stated in the general description).
return or `nil`
### `Done(pid)`
### Done(pid)
### `DefineBreakpoint(pid, index, condition, len)`
### DefineBreakpoint(pid, index, condition, len)
### `UndefBreakpoint(pid, index, condition, len)`
### UndefBreakpoint(pid, index, condition, len)
## IPC
### DefineIPCBuffer(size)
Define buffer for IPC receive
Return [buffer](#ipc_buffer) type
### SendIPCMessage(pid, [message](#ipc_msg))
Send message to process by pid
return [Error code](#ipc-error-codes)
### IPC Error codes
```lua
syscalls.IPCError.<Value>
```
+ `Ok`
+ `BufferLocked`
+ `BufferNotDefined`
+ `BufferOverflow`
+ `PIDNotExist`
### IPC_buffer
```lua
{
used: number,
lock: boolean,
Lock: (self: IPC_buffer) -> nil
Unlock: (self: IPC_buffer) -> nil
GetMessage: (self: IPC_buffer, i: number) -> IPC_msg
GetLastMessage: (self: IPC_buffer) -> IPC_msg
}
```
#### Lock(self)
Lock buffer
#### Unlock(self)
Unlock buffer
#### GetMessage(self, i)
return [message](#ipc_msg) that were send by number i
#### GetLastMessage(self)
return last sended [message](#ipc_msg)
### IPC_msg
```lua
{
pid: number,
size: number
}
```