-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This modules was previously part of alnbox: https://github.com/starius/alnbox
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- This file is part of lua-rote, Lua binding to ROTE | ||
-- Terminal Emulation library | ||
-- Copyright (C) 2015 Boris Nagaev | ||
-- See the LICENSE file for terms of use. | ||
|
||
describe("rote.cursesConsts", function() | ||
it("gets values of curses constants", function() | ||
local cursesConsts = require 'rote.cursesConsts' | ||
assert.truthy(cursesConsts.KEY_UP) | ||
assert.truthy(cursesConsts.KEY_DOWN) | ||
assert.truthy(cursesConsts.KEY_LEFT) | ||
assert.truthy(cursesConsts.KEY_RIGHT) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-- lua-rote, Lua binding to ROTE, Terminal Emulation library | ||
-- Copyright (C) 2015 Boris Nagaev | ||
-- See the LICENSE file for terms of use. | ||
|
||
-- ROTE is a simple C library for VT102 terminal emulation. | ||
-- See http://rote.sourceforge.net/ | ||
|
||
-- returns table of curses numeric consts | ||
-- module posix.curses requires starting curses, | ||
-- otherwise these consts are not initialized. | ||
-- Starting curses if often not desirable. | ||
-- This module spawns child process, which | ||
-- prints values of consts. | ||
|
||
local rote = require 'rote' | ||
local wait = assert(require "posix.sys.wait") | ||
|
||
local function printConsts() | ||
local curses = require 'posix.curses' | ||
local stdscr = curses.initscr() | ||
curses.endwin() | ||
local out_fname = assert(arg[1]) | ||
local out = io.open(out_fname, 'w') | ||
out:write('return {') | ||
for name, value in pairs(curses) do | ||
if type(value) == "number" then | ||
local t = "[%q] = %i," | ||
out:write(t:format(name, value)) | ||
end | ||
end | ||
out:write('}') | ||
out:close() | ||
end | ||
|
||
local fname = os.tmpname() | ||
local f = io.open(fname, 'w') | ||
f:write(string.dump(printConsts)) | ||
f:close() | ||
|
||
local fname2 = os.tmpname() | ||
|
||
local lluacov = os.getenv('LOAD_LUACOV') or '' | ||
|
||
local cmd = 'lua %s %s %s' | ||
cmd = cmd:format(lluacov, fname, fname2) | ||
|
||
local rt = rote.RoteTerm(24, 80) | ||
local pid = rt:forkPty(cmd) | ||
wait.wait(pid) | ||
rt:forsakeChild() | ||
|
||
local consts = dofile(fname2) | ||
|
||
os.remove(fname) | ||
os.remove(fname2) | ||
|
||
return consts |