socsvn commit: r270160 - in soc2014/pedrosouza/lua_loader/head/sys: boot/lua lua/src
pedrosouza at FreeBSD.org
pedrosouza at FreeBSD.org
Sat Jun 28 00:30:43 UTC 2014
Author: pedrosouza
Date: Sat Jun 28 00:30:41 2014
New Revision: 270160
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=270160
Log:
Fix print and string.char function, added menu box
Modified:
soc2014/pedrosouza/lua_loader/head/sys/boot/lua/lutils.c
soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua
soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua
soc2014/pedrosouza/lua_loader/head/sys/lua/src/lbaselib.c
Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/lutils.c
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/lutils.c Fri Jun 27 23:15:31 2014 (r270159)
+++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/lutils.c Sat Jun 28 00:30:41 2014 (r270160)
@@ -97,8 +97,9 @@
buf[n] = 0;
while (n-- > 0)
{
- buf[n] = ((int)lua_tonumber(L, n)) & 0xFF;
+ buf[n] = ((int)lua_tonumber(L, n+1)) & 0xFF;
}
+
lua_pushstring(L, buf);
return 1;
}
Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Fri Jun 27 23:15:31 2014 (r270159)
+++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/menu.lua Sat Jun 28 00:30:41 2014 (r270160)
@@ -7,7 +7,7 @@
screen.setcursor(x, y);
print("Boot Menu");
for k, v in pairs(opts) do
- screen.setcursor(x + v.index, y);
+ screen.setcursor(x, y + v.index);
local name = v.name;
if (name == nil) then
@@ -21,9 +21,11 @@
if (opts == nil) then
opts = menu.options;
end
- screen.clear();
+
while true do
- menu.draw(0, 0, opts);
+ screen.clear();
+ menu.draw(6, 11, opts);
+ menu.drawbox(4, 10, 40, 10);
local ch = string.char(io.getchar());
if (opts[ch] ~= nil) then
local ret = opts[ch].func();
@@ -35,6 +37,30 @@
end
end
+function menu.drawbox(x, y, w, h)
+ local hl = string.char(0xCD);
+ local vl = string.char(0xBA);
+
+ local tl = string.char(0xC9);
+ local bl = string.char(0xC8);
+ local tr = string.char(0xBB);
+ local br = string.char(0xBC);
+
+ screen.setcursor(x, y); print(tl);
+ screen.setcursor(x, y+h); print(bl);
+ screen.setcursor(x+w, y); print(tr);
+ screen.setcursor(x+w, y+h); print(br);
+
+ screen.setcursor(x+1, y);
+ for i = 0, w-2 do print(hl); end
+ screen.setcursor(x+1, y+h);
+ for i = 0, w-2 do print(hl); end
+
+
+ for i = 1, h-1 do screen.setcursor(x, y+i); print(vl); end
+ for i = 1, h-1 do screen.setcursor(x+w, y+i); print(vl); end
+end
+
menu.options = {
["1"] = {index = 1, name = "Boot Multi user", func = function () core.setSingleUser(false); loader.perform("boot"); end},
["2"] = {index = 2, name = "Boot Single user", func = function () core.setSingleUser(true); loader.perform("boot"); end},
Modified: soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Fri Jun 27 23:15:31 2014 (r270159)
+++ soc2014/pedrosouza/lua_loader/head/sys/boot/lua/screen.lua Sat Jun 28 00:30:41 2014 (r270160)
@@ -5,7 +5,7 @@
end
function screen.setcursor(x, y)
- print("\027["..x..";"..y.."H");
+ print("\027["..y..";"..x.."H");
end
function screen.setforeground(c)
Modified: soc2014/pedrosouza/lua_loader/head/sys/lua/src/lbaselib.c
==============================================================================
--- soc2014/pedrosouza/lua_loader/head/sys/lua/src/lbaselib.c Fri Jun 27 23:15:31 2014 (r270159)
+++ soc2014/pedrosouza/lua_loader/head/sys/lua/src/lbaselib.c Sat Jun 28 00:30:41 2014 (r270160)
@@ -39,7 +39,10 @@
luai_writestring(s, l);
lua_pop(L, 1); /* pop result */
}
+// Do not print "\n"
+#ifndef BOOT_LUA
luai_writeline();
+#endif
return 0;
}
More information about the svn-soc-all
mailing list