openwrt: add LuCI 0.9 branch to the package repository with Flukso patches applied
This commit is contained in:
parent
adbb953b1c
commit
dec84822d5
4877 changed files with 652078 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 60
|
||||
/!svn/ver/4830/luci/branches/luci-0.9/contrib/luacurses/test
|
||||
END
|
||||
getyx.lua
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 70
|
||||
/!svn/ver/4830/luci/branches/luci-0.9/contrib/luacurses/test/getyx.lua
|
||||
END
|
||||
hello.lua
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 70
|
||||
/!svn/ver/4830/luci/branches/luci-0.9/contrib/luacurses/test/hello.lua
|
||||
END
|
||||
filter.lua
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 71
|
||||
/!svn/ver/4830/luci/branches/luci-0.9/contrib/luacurses/test/filter.lua
|
||||
END
|
||||
getnstr.lua
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 72
|
||||
/!svn/ver/4830/luci/branches/luci-0.9/contrib/luacurses/test/getnstr.lua
|
||||
END
|
||||
mouse.lua
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 70
|
||||
/!svn/ver/4830/luci/branches/luci-0.9/contrib/luacurses/test/mouse.lua
|
||||
END
|
||||
rain.lua
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 69
|
||||
/!svn/ver/4830/luci/branches/luci-0.9/contrib/luacurses/test/rain.lua
|
||||
END
|
||||
pair.lua
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 69
|
||||
/!svn/ver/4830/luci/branches/luci-0.9/contrib/luacurses/test/pair.lua
|
||||
END
|
||||
266
mote/v1/openwrt/package/luci/contrib/luacurses/test/.svn/entries
Normal file
266
mote/v1/openwrt/package/luci/contrib/luacurses/test/.svn/entries
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
10
|
||||
|
||||
dir
|
||||
6253
|
||||
http://svn.luci.subsignal.org/luci/branches/luci-0.9/contrib/luacurses/test
|
||||
http://svn.luci.subsignal.org
|
||||
|
||||
|
||||
|
||||
2008-08-31T11:16:52.902738Z
|
||||
3027
|
||||
Cyrus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ab181a69-ba2e-0410-a84d-ff88ab4c47bc
|
||||
|
||||
getyx.lua
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-19T09:58:18.548068Z
|
||||
bda0a8e7b299a67a476cfe916e44c81c
|
||||
2008-08-31T11:16:52.902738Z
|
||||
3027
|
||||
Cyrus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
259
|
||||
|
||||
hello.lua
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-19T09:58:18.548068Z
|
||||
ce2bc731f6dbceaffa90f442cccc72ed
|
||||
2008-08-31T11:16:52.902738Z
|
||||
3027
|
||||
Cyrus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
453
|
||||
|
||||
filter.lua
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-19T09:58:18.552068Z
|
||||
099ebd2ddcd0c18377f717305d71b04e
|
||||
2008-08-31T11:16:52.902738Z
|
||||
3027
|
||||
Cyrus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
981
|
||||
|
||||
getnstr.lua
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-19T09:58:18.552068Z
|
||||
09affd3e30d6d3cdfe22f0bc838aef32
|
||||
2008-08-31T11:16:52.902738Z
|
||||
3027
|
||||
Cyrus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
165
|
||||
|
||||
mouse.lua
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-19T09:58:18.552068Z
|
||||
c322fd9b3879bdf08c90133f4f42207a
|
||||
2008-08-31T11:16:52.902738Z
|
||||
3027
|
||||
Cyrus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1328
|
||||
|
||||
rain.lua
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-19T09:58:18.552068Z
|
||||
26972f0fd22c69440034a9f91496adf2
|
||||
2008-08-31T11:16:52.902738Z
|
||||
3027
|
||||
Cyrus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2041
|
||||
|
||||
pair.lua
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-19T09:58:18.552068Z
|
||||
f5229a43832bbb1a464c02c34d8d54dc
|
||||
2008-08-31T11:16:52.902738Z
|
||||
3027
|
||||
Cyrus
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
366
|
||||
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
function read_cmd()
|
||||
curses.attron(curses.A_BOLD);
|
||||
curses.addstr("Command: ");
|
||||
curses.attron(underline);
|
||||
local s = "";
|
||||
while (true) do
|
||||
local c = string.char(curses.getch());
|
||||
if (c == '\n') then break; end
|
||||
s = s .. c;
|
||||
end
|
||||
curses.attroff(underline);
|
||||
curses.attroff(curses.A_BOLD);
|
||||
curses.addch("\n");
|
||||
|
||||
return s;
|
||||
end
|
||||
|
||||
|
||||
curses.filter();
|
||||
curses.initscr();
|
||||
curses.cbreak();
|
||||
curses.keypad(curses.stdscr(), TRUE);
|
||||
|
||||
if (curses.has_colors()) then
|
||||
curses.start_color();
|
||||
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK);
|
||||
underline = curses.COLOR_PAIR(1);
|
||||
else
|
||||
underline = curses.A_UNDERLINE;
|
||||
end
|
||||
|
||||
while (true) do
|
||||
local s = read_cmd();
|
||||
if (s == "exit") then break; end
|
||||
curses.reset_shell_mode();
|
||||
io.write("\n");
|
||||
io.flush(io.stdout);
|
||||
os.execute(s);
|
||||
curses.reset_prog_mode();
|
||||
curses.touchwin(curses.stdscr());
|
||||
curses.erase();
|
||||
curses.refresh();
|
||||
end
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
|
||||
curses.keypad(curses.stdscr(), true);
|
||||
s = curses.mvgetnstr(10, 10, 10);
|
||||
curses.addstr(s);
|
||||
curses.getch();
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
while (true) do
|
||||
local s = curses.getnstr(1000);
|
||||
curses.addstr(s);
|
||||
curses.addstr(":" .. table.concat({curses.getyx(curses.stdscr())}, ' ') .. "\n");
|
||||
if (s == "exit") then break; end
|
||||
end
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
function show_message(message)
|
||||
local width = string.len(message) + 6;
|
||||
win = curses.newwin(5, width, (curses.LINES() - 5) / 2, (curses.COLS() - width) / 2);
|
||||
win:box('|', '-');
|
||||
win:mvaddstr(2, 3, message);
|
||||
win:getch();
|
||||
win:delwin();
|
||||
end
|
||||
|
||||
curses.initscr();
|
||||
curses.cbreak();
|
||||
curses.mvaddstr((curses.LINES() - 5) / 2, (curses.COLS() - 10) / 2, "Hit any key");
|
||||
curses.getch();
|
||||
show_message("Hello, World!")
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
function show_message(m)
|
||||
local width = string.len(m) + 6;
|
||||
local win = curses.newwin(5, width, (lines - 5) / 2, (cols - width) / 2);
|
||||
win:keypad(true);
|
||||
win:attron(curses.COLOR_PAIR(curses.COLOR_RED));
|
||||
win:box('|', '-', '+');
|
||||
win:mvaddstr(2, 3, m);
|
||||
win:refresh();
|
||||
win:getch();
|
||||
win:delwin();
|
||||
end
|
||||
|
||||
curses.initscr();
|
||||
curses.start_color();
|
||||
curses.init_pair(curses.COLOR_BLUE, curses.COLOR_BLUE, curses.COLOR_WHITE);
|
||||
curses.init_pair(curses.COLOR_RED, curses.COLOR_RED, curses.COLOR_WHITE);
|
||||
curses.cbreak();
|
||||
curses.noecho();
|
||||
curses.keypad(curses.stdscr(), true);
|
||||
|
||||
lines = curses.LINES();
|
||||
cols = curses.COLS();
|
||||
|
||||
mmasks =
|
||||
{
|
||||
curses.BUTTON1_CLICKED,
|
||||
curses.BUTTON2_CLICKED,
|
||||
curses.BUTTON3_CLICKED,
|
||||
curses.BUTTON4_CLICKED
|
||||
};
|
||||
|
||||
table.foreachi(mmasks, function(_i, _m) curses.addmousemask(_m) end);
|
||||
curses.attron(curses.COLOR_PAIR(curses.COLOR_BLUE));
|
||||
curses.attron(curses.A_BOLD);
|
||||
curses.mvaddstr((lines - 5) / 2, (cols - 10) / 2, "click");
|
||||
|
||||
curses.refresh();
|
||||
while(true) do
|
||||
local c = curses.getch();
|
||||
if (c == curses.KEY_MOUSE) then
|
||||
local r, id, x, y, z, bstate = curses.getmouse();
|
||||
if (r) then
|
||||
show_message("id = " .. id .. ", x = " .. x .. ", y = " .. y .. ", z = " .. z .. ", bstate = " ..
|
||||
string.format("0x%x", bstate));
|
||||
end
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
|
||||
curses.start_color();
|
||||
curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_YELLOW);
|
||||
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_RED);
|
||||
|
||||
for i = 1, 2 do
|
||||
local r, f, b = curses.pair_content(i);
|
||||
curses.attrset(curses.COLOR_PAIR(i));
|
||||
curses.addstr(f .. ", " .. b .. "\n");
|
||||
end
|
||||
|
||||
curses.getch();
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
curses.nl();
|
||||
curses.noecho();
|
||||
|
||||
|
||||
if (curses.has_colors()) then
|
||||
curses.start_color();
|
||||
curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK);
|
||||
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK);
|
||||
end
|
||||
|
||||
curses.curs_set(0);
|
||||
curses.timeout(0);
|
||||
|
||||
math.randomseed(os.time());
|
||||
|
||||
lines = curses.LINES();
|
||||
cols = curses.COLS();
|
||||
|
||||
xpos = {};
|
||||
ypos = {};
|
||||
r = lines - 4;
|
||||
c = cols - 4;
|
||||
for i = 0, 4 do
|
||||
xpos[i] = c * math.random() + 2;
|
||||
ypos[i] = r * math.random() + 2;
|
||||
end
|
||||
|
||||
function dec(i, max)
|
||||
if (curses.has_colors()) then
|
||||
local z = 3 * math.random();
|
||||
local c = curses.COLOR_PAIR(z);
|
||||
curses.attrset(c);
|
||||
if (math.floor(z) > 0) then
|
||||
curses.attron(curses.A_BOLD);
|
||||
end
|
||||
end
|
||||
|
||||
if (i > 0) then return i - 1;
|
||||
else return max;
|
||||
end
|
||||
end
|
||||
|
||||
i = 0;
|
||||
while(true) do
|
||||
x = c * math.random() + 2;
|
||||
y = r * math.random() + 2;
|
||||
|
||||
curses.mvaddstr(y, x, ".");
|
||||
|
||||
curses.mvaddstr(ypos[i], xpos[i], "o");
|
||||
|
||||
i = dec(i, 4);
|
||||
curses.mvaddstr(ypos[i], xpos[i], "O");
|
||||
|
||||
i = dec(i, 4);
|
||||
curses.mvaddstr(ypos[i] - 1, xpos[i], "-");
|
||||
curses.mvaddstr(ypos[i], xpos[i] - 1, "|.|");
|
||||
curses.mvaddstr(ypos[i] + 1, xpos[i], "-");
|
||||
|
||||
i = dec(i, 4);
|
||||
curses.mvaddstr(ypos[i] - 2, xpos[i], "-");
|
||||
curses.mvaddstr(ypos[i] - 1, xpos[i] - 1, "/ \\");
|
||||
curses.mvaddstr(ypos[i], xpos[i] - 2, "| O |");
|
||||
curses.mvaddstr(ypos[i] + 1, xpos[i] - 1, "\\ /");
|
||||
curses.mvaddstr(ypos[i] + 2, xpos[i], "-");
|
||||
|
||||
i = dec(i, 4);
|
||||
curses.mvaddstr(ypos[i] - 2, xpos[i], " ");
|
||||
curses.mvaddstr(ypos[i] - 1, xpos[i] - 1, " ");
|
||||
curses.mvaddstr(ypos[i], xpos[i] - 2, " ");
|
||||
curses.mvaddstr(ypos[i] + 1, xpos[i] - 1, " ");
|
||||
curses.mvaddstr(ypos[i] + 2, xpos[i], " ");
|
||||
|
||||
|
||||
xpos[i] = x;
|
||||
ypos[i] = y;
|
||||
|
||||
local ch = curses.getch();
|
||||
if (ch == string.byte('q', 1)) or (ch == string.byte('Q', 1)) then break; end
|
||||
curses.refresh();
|
||||
curses.napms(50);
|
||||
end
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
function read_cmd()
|
||||
curses.attron(curses.A_BOLD);
|
||||
curses.addstr("Command: ");
|
||||
curses.attron(underline);
|
||||
local s = "";
|
||||
while (true) do
|
||||
local c = string.char(curses.getch());
|
||||
if (c == '\n') then break; end
|
||||
s = s .. c;
|
||||
end
|
||||
curses.attroff(underline);
|
||||
curses.attroff(curses.A_BOLD);
|
||||
curses.addch("\n");
|
||||
|
||||
return s;
|
||||
end
|
||||
|
||||
|
||||
curses.filter();
|
||||
curses.initscr();
|
||||
curses.cbreak();
|
||||
curses.keypad(curses.stdscr(), TRUE);
|
||||
|
||||
if (curses.has_colors()) then
|
||||
curses.start_color();
|
||||
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK);
|
||||
underline = curses.COLOR_PAIR(1);
|
||||
else
|
||||
underline = curses.A_UNDERLINE;
|
||||
end
|
||||
|
||||
while (true) do
|
||||
local s = read_cmd();
|
||||
if (s == "exit") then break; end
|
||||
curses.reset_shell_mode();
|
||||
io.write("\n");
|
||||
io.flush(io.stdout);
|
||||
os.execute(s);
|
||||
curses.reset_prog_mode();
|
||||
curses.touchwin(curses.stdscr());
|
||||
curses.erase();
|
||||
curses.refresh();
|
||||
end
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
|
||||
curses.keypad(curses.stdscr(), true);
|
||||
s = curses.mvgetnstr(10, 10, 10);
|
||||
curses.addstr(s);
|
||||
curses.getch();
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
while (true) do
|
||||
local s = curses.getnstr(1000);
|
||||
curses.addstr(s);
|
||||
curses.addstr(":" .. table.concat({curses.getyx(curses.stdscr())}, ' ') .. "\n");
|
||||
if (s == "exit") then break; end
|
||||
end
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
function show_message(message)
|
||||
local width = string.len(message) + 6;
|
||||
win = curses.newwin(5, width, (curses.LINES() - 5) / 2, (curses.COLS() - width) / 2);
|
||||
win:box('|', '-');
|
||||
win:mvaddstr(2, 3, message);
|
||||
win:getch();
|
||||
win:delwin();
|
||||
end
|
||||
|
||||
curses.initscr();
|
||||
curses.cbreak();
|
||||
curses.mvaddstr((curses.LINES() - 5) / 2, (curses.COLS() - 10) / 2, "Hit any key");
|
||||
curses.getch();
|
||||
show_message("Hello, World!")
|
||||
|
||||
curses.endwin();
|
||||
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
function show_message(m)
|
||||
local width = string.len(m) + 6;
|
||||
local win = curses.newwin(5, width, (lines - 5) / 2, (cols - width) / 2);
|
||||
win:keypad(true);
|
||||
win:attron(curses.COLOR_PAIR(curses.COLOR_RED));
|
||||
win:box('|', '-', '+');
|
||||
win:mvaddstr(2, 3, m);
|
||||
win:refresh();
|
||||
win:getch();
|
||||
win:delwin();
|
||||
end
|
||||
|
||||
curses.initscr();
|
||||
curses.start_color();
|
||||
curses.init_pair(curses.COLOR_BLUE, curses.COLOR_BLUE, curses.COLOR_WHITE);
|
||||
curses.init_pair(curses.COLOR_RED, curses.COLOR_RED, curses.COLOR_WHITE);
|
||||
curses.cbreak();
|
||||
curses.noecho();
|
||||
curses.keypad(curses.stdscr(), true);
|
||||
|
||||
lines = curses.LINES();
|
||||
cols = curses.COLS();
|
||||
|
||||
mmasks =
|
||||
{
|
||||
curses.BUTTON1_CLICKED,
|
||||
curses.BUTTON2_CLICKED,
|
||||
curses.BUTTON3_CLICKED,
|
||||
curses.BUTTON4_CLICKED
|
||||
};
|
||||
|
||||
table.foreachi(mmasks, function(_i, _m) curses.addmousemask(_m) end);
|
||||
curses.attron(curses.COLOR_PAIR(curses.COLOR_BLUE));
|
||||
curses.attron(curses.A_BOLD);
|
||||
curses.mvaddstr((lines - 5) / 2, (cols - 10) / 2, "click");
|
||||
|
||||
curses.refresh();
|
||||
while(true) do
|
||||
local c = curses.getch();
|
||||
if (c == curses.KEY_MOUSE) then
|
||||
local r, id, x, y, z, bstate = curses.getmouse();
|
||||
if (r) then
|
||||
show_message("id = " .. id .. ", x = " .. x .. ", y = " .. y .. ", z = " .. z .. ", bstate = " ..
|
||||
string.format("0x%x", bstate));
|
||||
end
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
curses.endwin();
|
||||
|
||||
18
mote/v1/openwrt/package/luci/contrib/luacurses/test/pair.lua
Normal file
18
mote/v1/openwrt/package/luci/contrib/luacurses/test/pair.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
|
||||
curses.start_color();
|
||||
curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_YELLOW);
|
||||
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_RED);
|
||||
|
||||
for i = 1, 2 do
|
||||
local r, f, b = curses.pair_content(i);
|
||||
curses.attrset(curses.COLOR_PAIR(i));
|
||||
curses.addstr(f .. ", " .. b .. "\n");
|
||||
end
|
||||
|
||||
curses.getch();
|
||||
curses.endwin();
|
||||
|
||||
89
mote/v1/openwrt/package/luci/contrib/luacurses/test/rain.lua
Normal file
89
mote/v1/openwrt/package/luci/contrib/luacurses/test/rain.lua
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
curses.nl();
|
||||
curses.noecho();
|
||||
|
||||
|
||||
if (curses.has_colors()) then
|
||||
curses.start_color();
|
||||
curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK);
|
||||
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK);
|
||||
end
|
||||
|
||||
curses.curs_set(0);
|
||||
curses.timeout(0);
|
||||
|
||||
math.randomseed(os.time());
|
||||
|
||||
lines = curses.LINES();
|
||||
cols = curses.COLS();
|
||||
|
||||
xpos = {};
|
||||
ypos = {};
|
||||
r = lines - 4;
|
||||
c = cols - 4;
|
||||
for i = 0, 4 do
|
||||
xpos[i] = c * math.random() + 2;
|
||||
ypos[i] = r * math.random() + 2;
|
||||
end
|
||||
|
||||
function dec(i, max)
|
||||
if (curses.has_colors()) then
|
||||
local z = 3 * math.random();
|
||||
local c = curses.COLOR_PAIR(z);
|
||||
curses.attrset(c);
|
||||
if (math.floor(z) > 0) then
|
||||
curses.attron(curses.A_BOLD);
|
||||
end
|
||||
end
|
||||
|
||||
if (i > 0) then return i - 1;
|
||||
else return max;
|
||||
end
|
||||
end
|
||||
|
||||
i = 0;
|
||||
while(true) do
|
||||
x = c * math.random() + 2;
|
||||
y = r * math.random() + 2;
|
||||
|
||||
curses.mvaddstr(y, x, ".");
|
||||
|
||||
curses.mvaddstr(ypos[i], xpos[i], "o");
|
||||
|
||||
i = dec(i, 4);
|
||||
curses.mvaddstr(ypos[i], xpos[i], "O");
|
||||
|
||||
i = dec(i, 4);
|
||||
curses.mvaddstr(ypos[i] - 1, xpos[i], "-");
|
||||
curses.mvaddstr(ypos[i], xpos[i] - 1, "|.|");
|
||||
curses.mvaddstr(ypos[i] + 1, xpos[i], "-");
|
||||
|
||||
i = dec(i, 4);
|
||||
curses.mvaddstr(ypos[i] - 2, xpos[i], "-");
|
||||
curses.mvaddstr(ypos[i] - 1, xpos[i] - 1, "/ \\");
|
||||
curses.mvaddstr(ypos[i], xpos[i] - 2, "| O |");
|
||||
curses.mvaddstr(ypos[i] + 1, xpos[i] - 1, "\\ /");
|
||||
curses.mvaddstr(ypos[i] + 2, xpos[i], "-");
|
||||
|
||||
i = dec(i, 4);
|
||||
curses.mvaddstr(ypos[i] - 2, xpos[i], " ");
|
||||
curses.mvaddstr(ypos[i] - 1, xpos[i] - 1, " ");
|
||||
curses.mvaddstr(ypos[i], xpos[i] - 2, " ");
|
||||
curses.mvaddstr(ypos[i] + 1, xpos[i] - 1, " ");
|
||||
curses.mvaddstr(ypos[i] + 2, xpos[i], " ");
|
||||
|
||||
|
||||
xpos[i] = x;
|
||||
ypos[i] = y;
|
||||
|
||||
local ch = curses.getch();
|
||||
if (ch == string.byte('q', 1)) or (ch == string.byte('Q', 1)) then break; end
|
||||
curses.refresh();
|
||||
curses.napms(50);
|
||||
end
|
||||
|
||||
curses.endwin();
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue