diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2024-05-21 19:53:22 -0600 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2024-05-21 19:53:22 -0600 |
| commit | b7074021b7bfb0932b889b9560dd22df31cef818 (patch) | |
| tree | 0295b18de8fb8ea5289cbda95675687ae06025ff /test/vis/visrc.lua | |
| parent | b7f8018a00be930e3f2b864949aec1f91291309c (diff) | |
| parent | efafa3c178268a4149fc3e432bc1174a013c16de (diff) | |
Merge vis-tests into test directory
Going forward all tests should be submitted here directly.
Diffstat (limited to 'test/vis/visrc.lua')
| -rw-r--r-- | test/vis/visrc.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/vis/visrc.lua b/test/vis/visrc.lua new file mode 100644 index 0000000..da34920 --- /dev/null +++ b/test/vis/visrc.lua @@ -0,0 +1,27 @@ +package.path = '../../lua/?.lua;'..package.path +dofile("../../lua/vis.lua") + +local function run_if_exists(luafile) + local f = io.open(luafile, "r") + if f ~= nil then + f:close() + dofile(luafile) + end +end + +vis.events.subscribe(vis.events.WIN_OPEN, function(win) + -- test.in file passed to vis + local name = win.file.name + if name then + -- use the corresponding test.lua file + name = string.gsub(name, '%.in$', '') + run_if_exists(string.format("%s.lua", name)) + local file = io.open(string.format("%s.keys", name)) + local keys = file:read('*all') + keys = string.gsub(keys, '%s*\n', '') + keys = string.gsub(keys, '<Space>', ' ') + file:close() + vis:feedkeys(keys..'<Escape>') + vis:command(string.format("w! '%s.out'", name)) + end +end) |
