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; char buf;
int r = read(fd, &buf, 1); //TODO: Wide chars? int r = read(fd, &buf, 1); //TODO: Wide chars?
if(r > 0) { if(r > 0) {
if(buf == 10) buf = 13; //if(buf == 10) buf = 13;
lua_State* L = getL(); lua_State* L = getL();
lua_getglobal(L, "pushEvent"); lua_getglobal(L, "pushEvent");
lua_pushstring(L, "key_down"); 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, buf);
lua_pushnumber(L, -1); lua_pushnumber(L, -1);
lua_pushstring(L, "user"); lua_pushstring(L, "user");

View File

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

View File

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

View File

@ -87,22 +87,28 @@ local keymap = {
[0x60 + 0x1B] = 0x15, [0x60 + 0x1B] = 0x15,
[0x60 + 0x1C] = 0x2C, [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) function computer.signalTransformers.key_down(s, a, ascii, key, user)
if key ~= -1 then if key ~= -1 then
return s, a, ascii, key, user return s, a, ascii, key, user
end end
return s, a, ascii, keymap[ascii] or key, user return s, a, asciitr[ascii] or ascii, keymap[ascii] or key, user
end end
function computer.signalTransformers.key_up(s, a, ascii, key, user) function computer.signalTransformers.key_up(s, a, ascii, key, user)
if key ~= -1 then if key ~= -1 then
return s, a, ascii, key, user return s, a, ascii, key, user
end end
return s, a, ascii, keymap[ascii] or key, user return s, a, asciitr[ascii] or ascii, keymap[ascii] or key, user
end end
----- -----

View File

@ -51,7 +51,7 @@ function textgpu.start()
if isPaletteIndex then if isPaletteIndex then
return --TODO: Maybe? return --TODO: Maybe?
end end
local old = foreground local old = background
background = tostring(math.floor(modules.color.nearest(color, mapping))) background = tostring(math.floor(modules.color.nearest(color, mapping)))
io.write("\x1b[4" .. background .. "m") io.write("\x1b[4" .. background .. "m")
io.flush() io.flush()
@ -219,7 +219,7 @@ function textgpu.start()
gpu.setBackground(0x000000) gpu.setBackground(0x000000)
modules.component.api.register(nil, "gpu", gpu) 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() deadhooks[#deadhooks + 1] = function()
io.write("\x1b[?25h") --Enable cursor on quit io.write("\x1b[?25h") --Enable cursor on quit