Fixed input

This commit is contained in:
Łukasz Magiera 2016-01-15 19:58:26 +01:00
parent 47656b9240
commit 57c8b155fe
5 changed files with 20 additions and 12 deletions

View File

@ -12,12 +12,12 @@ static int handleStdin(int fd, void* data) {
char buf;
int r = read(fd, &buf, 1); //TODO: Wide chars?
if(r > 0) {
if(buf == 10) buf = 13;
//if(buf == 10) buf = 13;
lua_State* L = getL();
lua_getglobal(L, "pushEvent");
lua_pushstring(L, "key_down");
lua_pushstring(L, "TODO:SetThisUuid");
lua_pushstring(L, "TODO:SetThisUuid");//Also in textgpu.lua
lua_pushnumber(L, buf);
lua_pushnumber(L, -1);
lua_pushstring(L, "user");

View File

@ -31,10 +31,13 @@ void termutils_start(lua_State *L) {
struct termios old, new;
if (tcgetattr (STDOUT_FILENO, &old) != 0)
return;
new = old;
new.c_lflag &= ~ECHO;
if (tcsetattr (STDOUT_FILENO, TCSAFLUSH, &new) != 0)
return;
new = old;
cfmakeraw(&new);
if (tcsetattr (STDOUT_FILENO, TCSAFLUSH, &new) != 0)
return;
lua_createtable (L, 0, 1);
pushctuple(L, "getSize", l_get_term_sz);

View File

@ -28,7 +28,6 @@ function api.register(address, ctype, proxy, doc)
components[address].proxy = {}
for k,v in pairs(proxy) do
if type(v) == "function" then
print("Cfunc " .. k)
components[address].proxy[k] = setmetatable({name=k,address=address}, componentCallback)
else
components[address].proxy[k] = v

View File

@ -87,22 +87,28 @@ local keymap = {
[0x60 + 0x1B] = 0x15,
[0x60 + 0x1C] = 0x2C,
[13] = 28,
[13] = 28, --Return key
[127] = 14, --backspace
[9] = 15, --Tab
}
local asciitr = {
[127] = 8,
}
function computer.signalTransformers.key_down(s, a, ascii, key, user)
if key ~= -1 then
return s, a, ascii, key, user
end
return s, a, ascii, keymap[ascii] or key, user
return s, a, asciitr[ascii] or ascii, keymap[ascii] or key, user
end
function computer.signalTransformers.key_up(s, a, ascii, key, user)
if key ~= -1 then
return s, a, ascii, key, user
end
return s, a, ascii, keymap[ascii] or key, user
return s, a, asciitr[ascii] or ascii, keymap[ascii] or key, user
end
-----

View File

@ -51,7 +51,7 @@ function textgpu.start()
if isPaletteIndex then
return --TODO: Maybe?
end
local old = foreground
local old = background
background = tostring(math.floor(modules.color.nearest(color, mapping)))
io.write("\x1b[4" .. background .. "m")
io.flush()
@ -219,7 +219,7 @@ function textgpu.start()
gpu.setBackground(0x000000)
modules.component.api.register(nil, "gpu", gpu)
modules.component.api.register(nil, "screen", {getKeyboards = function() return {} end}) --verry dummy screen, TODO: make it better
modules.component.api.register(nil, "screen", {getKeyboards = function() return {"TODO:SetThisUuid"} end}) --verry dummy screen, TODO: make it better, kbd uuid also in epoll.c
deadhooks[#deadhooks + 1] = function()
io.write("\x1b[?25h") --Enable cursor on quit