7.8 KiB
Manual
This is KolibriOS lua syscalls library. Usually you shouldn't use this library
Better if you read before KolibriOS syscalls wiki
include this library:
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
syscalls.Event.<EventName>
RedrawButtonKeyDesktopMouseNetworkIPCDebug
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:
{
Left: number,
Right: number,
Top: number,
Bottom: number
}
Window Style
syscalls.windowStyle.<Value>
FixSizesNoDraw(you must draw window manually)CanChangeSizesWithSkin(usually use it)WithSkinFixSizes(with skin, but window size fixed)
Graphic
Text encoding
syscalls.Encoding.<value>
cp866cp866_8x16utf8utf16
Text sizes
syscalls.textSize.<value>
6x9(cp866 only)8x1612x18(cp866 only)16x3218x27(cp866 only)24x36(cp866 only)24x4830x45(cp866 only)32x6436x54(cp866 only)40x8042x63(cp866 only)48x72(cp866 only)48x9656x11264x128
DrawText(text, xPos, yPos, textColor, textScale, textLen, backgroundColor, encoding)
DrawTextFixSize(text, xPos, yPos, textColor, textScale, textLen, backgroundColor, encoding)
Draw text.
textSize, textLen, backgroundColor, encoding are optional.
DrawLine(x1, y1, x2, y2)
DrawRectangle(x, y, width, height, color)
ReadPoint(x, y)
return color
Buttons
DefineButton(x, y, width, height, id, color)
DeleteButton(id)
GetButton()
return pressed button or nil
SetButtonStyle(style)
Set buttons style
buttons
button's ids that defined default by window with skin
syscalls.buttons.<Value>
closeminimization
Button styles
syscalls.buttonStyle.<Value>
FlatVolume
Keyboard
GetKey()
return:
nilif buffer empty- if hotkey return second number
- if key pressed and key input mode is ascii return string(1 char), else return scancode
example:
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
syscalls.scancode.<Value>
ABCDEFGHJKLMOPQSTUWXYZ123456789F1F2F3F4F5F6F7F8F9F10F11F12LeftShiftRightShiftLeftAltRightAltTab
SystemColors
SystemColors type
userdata
Fields
{
frameArea: number,
grabBar: number,
grabBarButton: number,
grabButtonText: number
grabText: number,
workArea: number,
workButton: number,
workButton: number,
workButtonText: number,
workGraph: number,
workText: number
}
Constructor
syscalls.SystemColors.new(
frameArea,
grabBar,
grabBarButton,
grabButtonText,
grabText,
workArea,
workButton,
workButton,
workButtonText,
workGraph,
workText
)
GetSystemColors()
return SystemColors
SetSystemColors(SystemColors)
Threads
ThreadInfo(pid)
return table:
{
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
syscalls.slotState.<Value>
RunningSuspendedSuspendedWaitEventNormalTermExceptTermWaitEventFree
Sockets
OpenSocket(domain, type, protocol)
return socket
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()
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
syscalls.SOCK.<Value>
STREAMRAWDGRAM
Address families
syscalls.AF.<Value>
UNSPECLOCALINETINET4INET6
IP options
syscalls.IP.<Value>
TTL
IP protocols
syscalls.IPPROTO.<Value>
IPICMPTCPUDPRAW
Socket options
syscalls.SO.<Value>
BINDTODEVICENONBLOCK
Debug
Registers type
{
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)
IPC
DefineIPCBuffer(size)
Define buffer for IPC receive
Return buffer type
SendIPCMessage(pid, message)
Send message to process by pid
return Error code
IPC Error codes
syscalls.IPCError.<Value>
OkBufferLockedBufferNotDefinedBufferOverflowPIDNotExist
IPC_buffer
{
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 that were send by number i
GetLastMessage(self)
return last sended message
IPC_msg
{
pid: number,
size: number
}