Skip to content

Commit 8549010

Browse files
committed
Version 0.0.2
1 parent 95606c5 commit 8549010

File tree

4 files changed

+63
-82
lines changed

4 files changed

+63
-82
lines changed

rockspecs/nocurses-0.0.1-1.rockspec

Lines changed: 0 additions & 33 deletions
This file was deleted.

rockspecs/nocurses-scm-0.rockspec renamed to rockspecs/nocurses-0.0.2-1.rockspec

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
package = "nocurses"
2-
version = "scm-0"
2+
version = "0.0.2-1"
3+
local pkgVersion = version:gsub("^(.*)%-.-$", "%1")
4+
local url, dir
5+
if pkgVersion == "scm" then
6+
url = "https://github.com/osch/lua-nocurses/archive/master.zip"
7+
dir = "lua-nocurses-master"
8+
else
9+
url = "https://github.com/osch/lua-nocurses/archive/v"..pkgVersion..".zip"
10+
dir = "lua-nocurses-"..pkgVersion
11+
end
312
source = {
4-
url = "https://github.com/osch/lua-nocurses/archive/master.zip",
5-
dir = "lua-nocurses-master",
13+
url = url,
14+
dir = dir,
615
}
716
description = {
817
summary = "A terminal screen manipulation library",
@@ -26,8 +35,8 @@ build = {
2635
"src/main.c",
2736
"src/nocurses_compat.c",
2837
},
29-
defines = { "NOCURSES_VERSION="..version:gsub("^(.*)-.-$", "%1") },
38+
defines = { "NOCURSES_VERSION="..pkgVersion },
3039
},
3140
["nocurses.getkey"] = "src/nocurses/getkey.lua",
3241
}
33-
}
42+
}

rockspecs/setversion.lua

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/lua
2+
3+
os.setlocale("C")
4+
5+
local pkgName = "nocurses"
6+
7+
local format = string.format
8+
local lfs = require("lfs")
9+
10+
local version = ...
11+
assert(version, "missing argument version")
12+
local fullVersion
13+
if version == "scm" then
14+
fullVersion = "scm-0"
15+
else
16+
assert(version:match("^%d+%.%d+%.%d+$"), format("invalid version %q", version))
17+
fullVersion = version.."-1"
18+
end
19+
20+
for fileName in lfs.dir(".") do
21+
local p1, v, p2 = fileName:match("^("..pkgName.."%-)(.*)(%.rockspec)$")
22+
if p1 then
23+
local newName = p1..fullVersion..p2
24+
print(format("%-30s -> %s", fileName, newName))
25+
local out = {}
26+
local matched = false
27+
local inFile = io.open(fileName, "r")
28+
for line in inFile:lines() do
29+
local l1, l2 = line:match("^(%s*version%s*%=%s*\")[^\"]*(\"%s*)$")
30+
if l1 then
31+
assert(not matched)
32+
matched = true
33+
out[#out+1] = l1..fullVersion..l2
34+
else
35+
out[#out+1] = line
36+
end
37+
end
38+
out[#out+1] = ""
39+
inFile:close()
40+
assert(matched)
41+
local newFile, err = io.open(newName, "w")
42+
assert(newFile, err)
43+
newFile:write(table.concat(out, "\n"))
44+
newFile:close()
45+
if fileName ~= newName then
46+
os.remove(fileName)
47+
end
48+
end
49+
end

src/main.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -672,44 +672,6 @@ static const luaL_Reg ModuleFunctions[] =
672672

673673
/* ============================================================================================ */
674674

675-
typedef struct {
676-
const char* name;
677-
const char* bytes;
678-
} InputSequence;
679-
680-
static const InputSequence inputSequences[] =
681-
{
682-
{ "Up", "\033[A" },
683-
{ "Down", "\033[B" },
684-
{ "Right", "\033[C" },
685-
{ "Left", "\033[D" },
686-
{ "Home", "\033[H" },
687-
{ "End", "\033[F" },
688-
{ "Page_Up", "\033[5~" },
689-
{ "Page_Down", "\033[6~" },
690-
{ "Backspace", "\177" },
691-
{ "Backspace", "\010" },
692-
{ "Tab", "\011" },
693-
{ "Delete", "\033[3~" },
694-
{ "Insert", "\033[2~" },
695-
{ "Escape", "\033" },
696-
{ "Enter", "\n" },
697-
{ "F1", "\033OP" },
698-
{ "F2", "\033OQ" },
699-
{ "F3", "\033OR" },
700-
{ "F4", "\033OS" },
701-
{ "F5", "\033[15~" },
702-
{ "F6", "\033[17~" },
703-
{ "F7", "\033[18~" },
704-
{ "F8", "\033[19~" },
705-
{ "F9", "\033[20~" },
706-
{ "F10", "\033[21~" },
707-
{ "F11", "\033[23~" },
708-
{ "F12", "\033[24~" },
709-
{ NULL, NULL }
710-
};
711-
712-
/* ============================================================================================ */
713675

714676
DLL_PUBLIC int luaopen_nocurses(lua_State* L)
715677
{
@@ -752,12 +714,6 @@ DLL_PUBLIC int luaopen_nocurses(lua_State* L)
752714
} else {
753715
luaL_setfuncs(L, ModuleFunctions, 0);
754716
}
755-
lua_newtable(L); /* --> module, key */
756-
for (const InputSequence* seq = inputSequences; seq->name; ++seq) {
757-
lua_pushstring(L, seq->name); /* --> module, key, bytes */
758-
lua_setfield(L, -2, seq->bytes); /* --> module, key */
759-
} /* --> module, key */
760-
lua_setfield(L, -2, "keyt"); /* --> module */
761717
lua_pop(L, 1);
762718

763719
lua_pushliteral(L, NOCURSES_VERSION_STRING);

0 commit comments

Comments
 (0)