From f37001be2965b8e5dfc1f4e8c89c6659124cd43a Mon Sep 17 00:00:00 2001 From: Egor00f Date: Thu, 2 Jan 2025 20:53:41 +0500 Subject: [PATCH 1/3] create documentation for syscalls && small updates in syscalls --- Makefile | 2 +- doc/contents.html | 69 ++++++++- doc/manual.html | 369 +++++++++++++++++++++++++++++++++++++++++++++- doc/readme.html | 24 +-- src/lsyscalls.c | 103 +++++++++++-- 5 files changed, 530 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index c606b61..5d06b27 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ V= 5.4 R= $V.7 -all help test clean: +shared static help test clean: @cd src && $(MAKE) $@ install: dummy diff --git a/doc/contents.html b/doc/contents.html index e171048..675bb85 100644 --- a/doc/contents.html +++ b/doc/contents.html @@ -11,7 +11,7 @@

Lua -Lua 5.4 Reference Manual +KolibriOS Lua 5.4 Reference Manual

@@ -131,6 +131,7 @@

Contents

  • 6.8 – Input and Output Facilities
  • 6.9 – Operating System Facilities
  • 6.10 – The Debug Library +
  • 6.11 – Syscalls
  • 7 – Lua Standalone @@ -234,9 +235,7 @@

    Lua functions

    file:setvbuf
    file:write
    - - -

     

    +

    math
    math.abs
    @@ -281,6 +280,10 @@

     

    os.time
    os.tmpname
    + + +

     

    +

    package
    package.config
    @@ -331,6 +334,64 @@

     

    utf8.len
    utf8.offset
    +

    +Syscalls
    + +Syscalls.createWindow
    +Syscalls.startRedraw
    +Syscalls.endRedraw
    +Syscalls.changeWindow
    +Syscalls.unfocusWindow
    +Syscalls.setWindowTitle
    + +Syscalls.defineButton
    +Syscalls.deleteButton
    +Syscalls.getButton
    + +Syscalls.waitEvent
    +Syscalls.checkEvent
    +Syscalls.waitEventTimeout
    + +Syscalls.backgroundSetSize
    +Syscalls.backgroundPutPixel
    +Syscalls.backgroundRedraw
    + +Syscalls.getRamSize
    +Syscalls.getFreeRam
    +Syscalls.getCPUClock
    +Syscalls.shutdownPowerOff
    +Syscalls.shutdownReboot
    +Syscalls.shutdownRestartKernel
    +Syscalls.getSystemColors
    +Syscalls.screenSize
    +Syscalls.drawLine
    +Syscalls.drawPixel
    +Syscalls.drawText
    +Syscalls.drawRectangle
    +Syscalls.setKeyInputMode
    +Syscalls.getKey
    +Syscalls.getControlKeyState
    + +Syscalls.threadInfo
    +Syscalls.killBySlot
    + +Syscalls.getMouseButtons
    +Syscalls.getMouseEvents
    +Syscalls.getMousePositionScreen
    +Syscalls.getMousePositionWindow
    +Syscalls.GetMouseSpeed
    +Syscalls.GetMouseSens
    +Syscalls.GetMouseDoubleClickDelay
    +Syscalls.GetMouseSettings
    +Syscalls.MouseSimulateState
    +Syscalls.SetMouseSpeed
    +Syscalls.SetMouseSens
    +Syscalls.SetMousePos
    +Syscalls.SetMouseDoubleClickDelay
    +Syscalls.SetMouseSettings
    + +

    +

    metamethods

    __add
    diff --git a/doc/manual.html b/doc/manual.html index 574c743..1fa2925 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -11,7 +11,7 @@

    Lua -Lua 5.4 Reference Manual +Lua 5.4 KolibriOS Reference Manual

    @@ -11568,6 +11568,368 @@

    6.10 – The Debug Library

    +

    10 – Syscalls

    + +

    + In this version you can use syscalls. All functions from here are similar to functions from system interrupts. + Functions get only integers or strings. +

    + +
    +

    createWindow(x, y, w, h, title, workAreaColor, style)

    + +

    + just create define window. + Params: +

    +

    + +

    + The position and size of the window are set the first time this function is called and are ignored on subsequent + calls; + to change the position and/or size of an already created window, use changeWindow function +

    + +

    + The window must fit on the screen. If the passed coordinates and dimensions do not satisfy this condition, then the + corresponding coordinate (or possibly both) is considered zero, and if this does not help, then the corresponding + size (or possibly both) is set to the screen size. +

    + +

    + The window dimensions are understood in terms of the coordinates of the lower right corner. + The same applies to all other functions. This means that the actual dimensions are 1 pixel larger. +

    + +
    +

    chageWindow(x, y, w, h)

    + +

    + A value of -1 for the parameter means "do not change" +

    + +

    + The function call for maximized windows is simply ignored. +

    + +
    +

    setWindowTitle(newTitle)

    + +
    +

    startRedraw()

    + +
    +

    endRedraw()

    + +
    +

    defineButton(x, y, w, h, id, color)

    + +

    + The button size must be greater than 0 and less than 0x8000. +

    + +

    + For windows with a skin, when defining a window (calling the 0th function), two standard buttons are created - + closing the window with the ID 1 and minimizing the window with the ID 0xffff. +

    + +

    + Creating two buttons with the same IDs is quite acceptable. +

    + +

    + The button with the ID 0xffff, when pressed, is interpreted by the system as a minimization button, the system + processes + such a press independently, without accessing the application. +

    + +

    + Otherwise, it is a regular button. +

    + +

    + The total number of buttons for all applications is limited to 4095. +

    + +
    +

    deleteButton(id)

    + +
    +

    getButton()

    + +

    + Takes the code of the pressed button from the buffer and code of pressed button. If buffer is empty return + nil, nil. +

    + +

    + When this function is called by an application with an inactive window, the response nil, nil is + returned. +

    + +
    +

    checkEvent()

    + +

    + If there is an event in the message queue, reads it and returns it. If the queue is empty, returns zero. +

    + +

    + Return event code. +

    + + +
    +

    waitEvent()

    + +

    + If the message queue is empty, then waits for a message to appear in the queue. In this state, the thread does not + receive processor time. Then reads the message from the queue. +

    + +

    + Return event code. +

    + + +
    +

    waitEventTimeout(timeout)

    + +

    + If the message queue is empty, waits for a message to appear in the queue, but no more than the specified time. + Then + reads the message from the queue. +

    + +

    + Params: +

    +

    + +

    + Return event code. +

    + + +
    +

    drawLine(XStart, YStart, XEnd, YEnd, color)

    + +

    + draw line in window. +

    + +
    +

    drawPixel(x, y, color)

    + +
    +

    drawText(text, x, y, color)

    + +
    +

    drawRectangle(x, y, w, h, color)

    + +
    +

    getSystemColors()

    + +
    +

    getKey()

    + +

    + Takes the code of the pressed key from the buffer. +

    + +

    + Return string with pressed button or scancode or nil + and hotkey or nil +

    + +

    + There is a system-wide buffer of 120 bytes of keystrokes, organized as a queue. +

    + +

    + There is another system-wide buffer of 120 "hot keys". +

    + +

    + However, hot keys are always returned as scancodes. +

    +

    + You can find out which key combinations correspond to which codes by running the keyascii and scancode + applications. +

    +

    + Scancodes are returned directly by the keyboard and are fixed; +

    + +
    +

    Scancodes

    + +

    + Cnscode is just number. Names of Scancodes: Scancode_* +

    + +

    + List of all Scancodes: +

    +

    + +
    +

    Events

    + +

    + Returning by functions waitEvent, waitEventTimeout and checkEvent +

    + +

    + List of all Events: +

    +

    + +
    +

    getMouseButtons

    + +

    + Return table of booleans: +

    + + + {
    + LeftButton, --pressed left mouse button
    + RightButton, --pressed right mouse button
    + MidleButton, --pressed midle mouse button
    + Button4, --pressed 4 mouse button
    + Button5 --pressed 5 mouse button
    + } +
    + +
    +

    getMouseEvents

    + +

    + Return table of booleans: +

    + + + {
    + LeftButton, --pressed left mouse button
    + RightButton, --pressed right mouse button
    + MidleButton, --pressed midle mouse button
    + Button4, --pressed 4 mouse button
    + Button5, --pressed 5 mouse button
    + getMouseEvents,
    + RightButtonPressed,
    + MButtonPressed,
    + VerticalScroll,
    + LeftButtonReleased,
    + RightButtonReleased,
    + MidleButtonReleased,
    + HorizontalScroll,
    + DoubleClick
    + } +
    @@ -12045,12 +12407,9 @@

    9 – The Complete Syntax of Lua

    - - -