luci-0.8: drop lpeg and luacurses, unused
This commit is contained in:
parent
16572ca099
commit
280e9f296c
15 changed files with 0 additions and 4104 deletions
1
contrib/lpeg/.gitignore
vendored
1
contrib/lpeg/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
lpeg-*
|
|
@ -1,33 +0,0 @@
|
|||
include ../../build/config.mk
|
||||
include ../../build/gccconfig.mk
|
||||
|
||||
LPEG_VERSION = 0.8.1
|
||||
LPEG_SITE = http://www.inf.puc-rio.br/~roberto/lpeg
|
||||
LPEG_DIR = lpeg-$(LPEG_VERSION)
|
||||
LPEG_FILE = $(LPEG_DIR).tar.gz
|
||||
LPEG_URL = $(LPEG_SITE)/$(LPEG_FILE)
|
||||
|
||||
all: compile
|
||||
|
||||
include ../../build/module.mk
|
||||
|
||||
$(LPEG_FILE):
|
||||
wget -O $@ $(LPEG_URL) || rm -f $@
|
||||
|
||||
$(LPEG_DIR)/.prepared: $(LPEG_FILE)
|
||||
rm -rf $(LPEG_DIR)
|
||||
tar xvfz $(LPEG_FILE)
|
||||
touch $@
|
||||
|
||||
compile: $(LPEG_DIR)/.prepared
|
||||
$(MAKE) -C $(LPEG_DIR) CC=$(CC) COPT="$(CFLAGS) $(LUA_CFLAGS) -fpic"
|
||||
mkdir -p dist$(LUA_LIBRARYDIR)
|
||||
cp $(LPEG_DIR)/{lpeg.so,re.lua} dist$(LUA_LIBRARYDIR)
|
||||
|
||||
luasource:
|
||||
luastrip:
|
||||
luacompile:
|
||||
compile-all: compile
|
||||
|
||||
clean:
|
||||
rm -rf $(LPEG_DIR) $(LPEG_FILE)
|
|
@ -1,10 +0,0 @@
|
|||
include ../../build/module.mk
|
||||
include ../../build/config.mk
|
||||
include ../../build/gccconfig.mk
|
||||
|
||||
compile: dist$(LUA_LIBRARYDIR)/curses.so
|
||||
|
||||
dist$(LUA_LIBRARYDIR)/curses.so:
|
||||
mkdir -p dist$(LUA_LIBRARYDIR)
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(SHLIB_FLAGS) -pedantic \
|
||||
-Wall $(FPIC) $(LUA_CFLAGS) -o dist$(LUA_LIBRARYDIR)/curses.so src/curses.c src/luacurses.c
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -1,137 +0,0 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
#include <curses.h>
|
||||
#include "luacurses.h"
|
||||
|
||||
SCREEN* luacurses_toscreen(lua_State* L, int index)
|
||||
{
|
||||
SCREEN** pscreen = (SCREEN**) luaL_checkudata(L, index, MKLUALIB_META_CURSES_SCREEN);
|
||||
if (!pscreen) luaL_argerror(L, index, "bad screen");
|
||||
if (!*pscreen) luaL_error(L, "attempt to use invalid screen");
|
||||
return *pscreen;
|
||||
}
|
||||
|
||||
SCREEN** luacurses_newscreen(lua_State* L)
|
||||
{
|
||||
SCREEN** pscreen = (SCREEN**) lua_newuserdata(L, sizeof(SCREEN*));
|
||||
*pscreen = 0;
|
||||
luaL_getmetatable(L, MKLUALIB_META_CURSES_SCREEN);
|
||||
lua_setmetatable(L, -2);
|
||||
return pscreen;
|
||||
}
|
||||
|
||||
void luacurses_regscreen(lua_State* L, const char* name, SCREEN* userdata)
|
||||
{
|
||||
lua_pushstring(L, name);
|
||||
SCREEN** pscreen = luacurses_newscreen(L);
|
||||
*pscreen = userdata;
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
WINDOW* luacurses_towindow(lua_State* L, int index)
|
||||
{
|
||||
WINDOW** pwindow = (WINDOW**) luaL_checkudata(L, index, MKLUALIB_META_CURSES_WINDOW);
|
||||
if (!pwindow) luaL_argerror(L, index, "bad window");
|
||||
if (!*pwindow) luaL_error(L, "attempt to use invalid window");
|
||||
return *pwindow;
|
||||
}
|
||||
|
||||
WINDOW** luacurses_newwindow(lua_State* L)
|
||||
{
|
||||
WINDOW** pwindow = (WINDOW**) lua_newuserdata(L, sizeof(WINDOW*));
|
||||
*pwindow = 0;
|
||||
luaL_getmetatable(L, MKLUALIB_META_CURSES_WINDOW);
|
||||
lua_setmetatable(L, -2);
|
||||
return pwindow;
|
||||
}
|
||||
|
||||
void luacurses_regwindow(lua_State* L, const char* name, WINDOW* userdata)
|
||||
{
|
||||
lua_pushstring(L, name);
|
||||
WINDOW** pwindow = luacurses_newwindow(L);
|
||||
*pwindow = userdata;
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
FILE* tofile(lua_State* L, int index)
|
||||
{
|
||||
FILE** pf = (FILE**) luaL_checkudata(L, index, MKLUALIB_META_CURSES_FILE);
|
||||
if (!pf) luaL_argerror(L, index, "bad file");
|
||||
if (!*pf) luaL_error(L, "attempt to use invalid file");
|
||||
return *pf;
|
||||
}
|
||||
|
||||
FILE** newfile(lua_State* L)
|
||||
{
|
||||
FILE** pf = (FILE**) lua_newuserdata(L, sizeof(FILE*));
|
||||
*pf = 0;
|
||||
luaL_getmetatable(L, MKLUALIB_META_CURSES_FILE);
|
||||
lua_setmetatable(L, -2);
|
||||
return pf;
|
||||
}
|
||||
|
||||
void luacurses_regfile(lua_State* L, const char* name, FILE* f)
|
||||
{
|
||||
lua_pushstring(L, name);
|
||||
FILE** pf = newfile(L);
|
||||
*pf = f;
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
|
||||
char* luacurses_wgetnstr(WINDOW* w, int n)
|
||||
{
|
||||
char* s = (char*) malloc(n + 1);
|
||||
wgetnstr(w, s, n);
|
||||
return s;
|
||||
}
|
||||
|
||||
char* luacurses_window_tostring(WINDOW* w)
|
||||
{
|
||||
char* buf = (char*) malloc(64);
|
||||
sprintf(buf, "window %p", w);
|
||||
return buf;
|
||||
}
|
||||
|
||||
char* luacurses_screen_tostring(SCREEN* s)
|
||||
{
|
||||
char* buf = (char*) malloc(64);
|
||||
sprintf(buf, "screen %p", s);
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool luacurses_getmouse(short* id, int* x, int* y, int* z, mmask_t* bstate)
|
||||
{
|
||||
MEVENT e;
|
||||
int res = getmouse(&e);
|
||||
|
||||
*id = e.id;
|
||||
*x = e.x;
|
||||
*y = e.y;
|
||||
*z = e.z;
|
||||
*bstate = e.bstate;
|
||||
return (res == OK);
|
||||
}
|
||||
|
||||
bool luacurses_ungetmouse (short id, int x, int y, int z, mmask_t bstate)
|
||||
{
|
||||
MEVENT e;
|
||||
e.id = id;
|
||||
e.x = x;
|
||||
e.y = y;
|
||||
e.z = z;
|
||||
e.bstate = bstate;
|
||||
return (ungetmouse(&e) == OK);
|
||||
}
|
||||
|
||||
mmask_t luacurses_addmousemask(mmask_t m)
|
||||
{
|
||||
mmask_t old;
|
||||
mousemask(m, &old);
|
||||
return mousemask(old | m, 0);
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
|
||||
#include <curses.h>
|
||||
|
||||
#define MKLUALIB_META_CURSES_SCREEN "SCREEN*"
|
||||
|
||||
SCREEN* luacurses_toscreen(lua_State* L, int index);
|
||||
SCREEN** luacurses_newscreen(lua_State* L);
|
||||
void luacurses_regscreen(lua_State* L, const char* name, SCREEN* userdata);
|
||||
|
||||
#define MKLUALIB_META_CURSES_WINDOW "WINDOW*"
|
||||
|
||||
WINDOW* luacurses_towindow(lua_State* L, int index);
|
||||
WINDOW** luacurses_newwindow(lua_State* L);
|
||||
void luacurses_regwindow(lua_State* L, const char* name, WINDOW* userdata);
|
||||
|
||||
#define MKLUALIB_META_CURSES_FILE "FILE*"
|
||||
|
||||
FILE* tofile(lua_State* L, int index);
|
||||
FILE** newfile(lua_State* L);
|
||||
void luacurses_regfile(lua_State* L, const char* name, FILE* f);
|
||||
|
||||
char* luacurses_wgetnstr(WINDOW* w, int n);
|
||||
char* luacurses_wgetstr(WINDOW* w);
|
||||
|
||||
#define luacurses_mvwgetnstr(w, y, x, n) (wmove(w, y, x) == ERR ? 0 : luacurses_wgetnstr(w, n))
|
||||
#define luacurses_getnstr(n) luacurses_wgetnstr(stdscr, n)
|
||||
#define luacurses_mvgetnstr(y, x, n) luacurses_mvwgetnstr(stdscr, y, x, n)
|
||||
|
||||
char* luacurses_window_tostring(WINDOW* w);
|
||||
char* luacurses_screen_tostring(SCREEN* s);
|
||||
|
||||
#define luacurses_window_free(w) {delwin(w); w = 0;}
|
||||
#define luacurses_screen_free(s) {delscreen(s); s = 0;}
|
||||
|
||||
bool luacurses_getmouse(short* id, int* x, int* y, int* z, mmask_t* bstate);
|
||||
bool luacurses_ungetmouse (short id, int x, int y, int z, mmask_t bstate);
|
||||
mmask_t luacurses_addmousemask(mmask_t m);
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
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();
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
require("curses");
|
||||
|
||||
curses.initscr();
|
||||
|
||||
curses.keypad(curses.stdscr(), true);
|
||||
s = curses.mvgetnstr(10, 10, 10);
|
||||
curses.addstr(s);
|
||||
curses.getch();
|
||||
|
||||
curses.endwin();
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
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();
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
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();
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
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();
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
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();
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
|
||||
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…
Reference in a new issue