fix DrawText func && add enum with text encoding && update manual && other
This commit is contained in:
12
.vscode/settings.json
vendored
12
.vscode/settings.json
vendored
@@ -4,9 +4,14 @@
|
||||
"files.associations": {
|
||||
"stdlib.h": "c",
|
||||
"ksys.h": "c",
|
||||
"socket.h": "c"
|
||||
"socket.h": "c",
|
||||
"graphic.h": "c"
|
||||
},
|
||||
"cSpell.words": [
|
||||
"syscalls",
|
||||
"INET",
|
||||
"IPPROTO",
|
||||
"DGRAM",
|
||||
"ksys",
|
||||
"ksys_oskey_t",
|
||||
"LUALIB_API",
|
||||
@@ -15,17 +20,18 @@
|
||||
"tonumber",
|
||||
"luaL_newmetatable",
|
||||
"luaL_setmetatable",
|
||||
"lua_createtable",
|
||||
"luaL_setfuncs",
|
||||
"luaL_checkinteger",
|
||||
"luaL_checkstring",
|
||||
"luaL_checkudata",
|
||||
"luaL_optinteger",
|
||||
"lua_pushboolean",
|
||||
"lua_pushinteger",
|
||||
"lua_pushnumber",
|
||||
"luaL_optinteger",
|
||||
"lua_pushstring",
|
||||
"lua_pushnil",
|
||||
"lua_createtable",
|
||||
"lua_newtable",
|
||||
"lua_touserdata",
|
||||
"lua_setfield",
|
||||
"lua_getfield",
|
||||
|
2
Makefile
2
Makefile
@@ -15,7 +15,7 @@ else
|
||||
TOOLCHAIN_PATH = /home/autobuild/tools/win32
|
||||
endif
|
||||
|
||||
KOLIBRIOS_REPO = ../kolibrios
|
||||
KOLIBRIOS_REPO = $(abspath ../kolibrios)
|
||||
|
||||
|
||||
|
||||
|
@@ -12,18 +12,70 @@ local syscalls = require("syscalls")
|
||||
syscalls.Event.<EventName>
|
||||
```
|
||||
|
||||
|
||||
+ `Redraw`
|
||||
+ `Button`
|
||||
+ `Key`
|
||||
+ `Desktop`
|
||||
+ `Mouse`
|
||||
+ `Network`
|
||||
+ `IPC`
|
||||
+ `Debug`
|
||||
|
||||
## Graphic
|
||||
|
||||
### Text encoding
|
||||
|
||||
+ `cp866`
|
||||
+ `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, 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
|
||||
### `OpenSocket(domain, type, protocol)`
|
||||
|
||||
```lua
|
||||
local socket, err = syscalls.OpenSocket()
|
||||
local socket, err = syscalls.OpenSocket(
|
||||
syscalls.SOCK.STREAM,
|
||||
syscalls.AF.INET,
|
||||
syscalls.IPPROTO.IP
|
||||
)
|
||||
|
||||
if err then
|
||||
print("Error", err)
|
||||
@@ -32,9 +84,9 @@ else
|
||||
end
|
||||
```
|
||||
|
||||
### CloseSocket(socket)
|
||||
### `CloseSocket(socket)`
|
||||
|
||||
### PairSocket()
|
||||
### `PairSocket()`
|
||||
|
||||
```lua
|
||||
local first, second = PairSocket()
|
||||
@@ -46,19 +98,19 @@ else
|
||||
end
|
||||
```
|
||||
|
||||
### Bind(socket, address)
|
||||
### `Bind(socket, address)`
|
||||
|
||||
### Listen(socket, backlog)
|
||||
### `Listen(socket, backlog)`
|
||||
|
||||
### Connect()
|
||||
### `Connect(socket, address)`
|
||||
|
||||
### Accept
|
||||
### `Accept(socket, , flags)`
|
||||
|
||||
### Receive
|
||||
### `Receive(socket, , flags)`
|
||||
|
||||
## SetSocketOption
|
||||
### `SetSocketOption(socket, opt)`
|
||||
|
||||
### GetSocketOption
|
||||
### `GetSocketOption(socket, opt)`
|
||||
|
||||
### Socket types
|
||||
|
||||
|
@@ -29,16 +29,16 @@ int syscalls_drawLine(lua_State* L)
|
||||
}
|
||||
|
||||
|
||||
static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_color_t color, enum TextScale size, uint32_t len, bool fillBackground, ksys_color_t backgroundColor)
|
||||
static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_color_t color, enum TextScale size, uint32_t len, bool fillBackground, ksys_color_t backgroundColor, enum DrawTextEncoding encoding)
|
||||
{
|
||||
enum DrawTextEncoding
|
||||
|
||||
enum DrawTextEncoding_
|
||||
{
|
||||
cp866_6x9 = 0,
|
||||
cp866_8x16 = 1,
|
||||
utf8 = 3,
|
||||
utf16 = 4
|
||||
cp866_8x16 = 1
|
||||
};
|
||||
|
||||
|
||||
enum scale
|
||||
{
|
||||
scale_x1 = 0,
|
||||
@@ -55,19 +55,20 @@ static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_colo
|
||||
|
||||
color |= (fillBackground << 30);
|
||||
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case TextScale_SIZE_6x9:
|
||||
color |= (cp866_8x16 << 28) | (scale_x1 << 24);
|
||||
color |= (cp866_6x9 << 28) | (scale_x1 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_8x16:
|
||||
color |= (cp866_8x16 << 28);
|
||||
color |= (encoding << 28) | (scale_x1 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_12x18:
|
||||
color |= (cp866_6x9 << 28) | (scale_x2 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_16x32:
|
||||
color |= (cp866_8x16 << 28) | (scale_x2 << 24);
|
||||
color |= (encoding << 28) | (scale_x2 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_18x27:
|
||||
color |= (cp866_6x9 << 28) | (scale_x3 << 24);
|
||||
@@ -76,16 +77,19 @@ static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_colo
|
||||
color |= (cp866_6x9 << 28) | (scale_x4 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_24x48:
|
||||
color |= (cp866_8x16 << 28) | (scale_x3 << 24);
|
||||
color |= (encoding << 28) | (scale_x3 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_30x45:
|
||||
color |= (cp866_6x9 << 28) | (scale_x5 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_32x64:
|
||||
color |= (encoding << 28) | (scale_x4 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_36x54:
|
||||
color |= (cp866_6x9 << 28) | (scale_x6 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_40x80:
|
||||
color |= (cp866_8x16 << 28) | (scale_x5 << 24);
|
||||
color |= (encoding << 28) | (scale_x5 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_42x63:
|
||||
color |= (cp866_6x9 << 28) | (scale_x7 << 24);
|
||||
@@ -94,19 +98,19 @@ static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_colo
|
||||
color |= (cp866_6x9 << 28) | (scale_x8 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_48x96:
|
||||
color |= (cp866_8x16 << 28) | (scale_x6 << 24);
|
||||
color |= (encoding << 28) | (scale_x6 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_56x112:
|
||||
color |= (cp866_8x16 << 28) | (scale_x7 << 24);
|
||||
color |= (encoding << 28) | (scale_x7 << 24);
|
||||
break;
|
||||
case TextScale_SIZE_64x128:
|
||||
color |= (cp866_8x16 << 28) | (scale_x8 << 24);
|
||||
color |= (encoding << 28) | (scale_x8 << 24);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
if (len <= 0)
|
||||
if (len == NULL)
|
||||
color |= (1 << 31);
|
||||
|
||||
asm_inline(
|
||||
@@ -120,15 +124,19 @@ static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_colo
|
||||
|
||||
int syscalls_drawText(lua_State* L)
|
||||
{
|
||||
LUA_INTEGER backgroundColor = luaL_optinteger(L, 7, 0);
|
||||
|
||||
syscall_drawText(
|
||||
luaL_checkstring(L, 1),
|
||||
luaL_checkinteger(L, 2),
|
||||
luaL_checkinteger(L, 3),
|
||||
luaL_checkinteger(L, 4),
|
||||
luaL_optinteger(L, 5, TextScale_SIZE_8x16),
|
||||
luaL_optinteger(L, 6, 0),
|
||||
luaL_optinteger(L, 7, 0),
|
||||
luaL_optinteger(L, 8, 0));
|
||||
luaL_optinteger(L, 6, NULL),
|
||||
backgroundColor << 32,
|
||||
backgroundColor,
|
||||
luaL_optinteger(L, 8, cp866)
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -24,6 +24,13 @@ enum TextScale
|
||||
TextScale_SIZE_64x128 // 8x 8x16
|
||||
};
|
||||
|
||||
enum DrawTextEncoding
|
||||
{
|
||||
cp866 = 1,
|
||||
utf8 = 3,
|
||||
utf16 = 4
|
||||
};
|
||||
|
||||
int syscalls_drawLine(lua_State* L);
|
||||
int syscalls_drawText(lua_State* L);
|
||||
int syscalls_drawRectangle(lua_State* L);
|
||||
@@ -85,4 +92,22 @@ inline void syscalls_push_textSizes(lua_State* L)
|
||||
lua_setfield(L, -2, "textSize");
|
||||
}
|
||||
|
||||
#endif // __GRAPHIC_H__
|
||||
inline void syscalls_push_Encoding(lua_State* L)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
||||
lua_pushinteger(L, cp866);
|
||||
lua_setfield(L, -2, "cp866");
|
||||
|
||||
lua_pushinteger(L, utf8);
|
||||
lua_setfield(L, -2, "utf8");
|
||||
|
||||
lua_pushinteger(L, utf16);
|
||||
lua_setfield(L, -2, "utf16");
|
||||
|
||||
lua_setfield(L, -2, "Encoding");
|
||||
}
|
||||
|
||||
#define syscalls_push_graphic(L) syscalls_push_textSizes(L); syscalls_push_Encoding(L);
|
||||
|
||||
#endif // __GRAPHIC_H__
|
||||
|
@@ -1855,7 +1855,7 @@ LUALIB_API int luaopen_syscalls(lua_State* L)
|
||||
syscalls_push_windowStyles(L);
|
||||
syscalls_push_buttons(L);
|
||||
syscalls_push_connectionStatus(L);
|
||||
syscalls_push_textSizes(L);
|
||||
syscalls_push_graphic(L);
|
||||
|
||||
syscalls_register_ARPEntry(L);
|
||||
syscalls_register_SystemColors(L);
|
||||
|
@@ -53,4 +53,4 @@ inline void syscalls_ReturnStringOrNil(LUA_INTEGER cond, const char* value, lua_
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __SYSCALLS_H__
|
||||
#endif // __SYSCALLS_H__
|
||||
|
Reference in New Issue
Block a user