File: visrc.lua

package info (click to toggle)
vis 0.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,388 kB
  • sloc: ansic: 22,372; sh: 950; makefile: 356; python: 47
file content (28 lines) | stat: -rw-r--r-- 670 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package.path = '../../lua/?.lua;'..package.path
dofile("../../lua/vis.lua")

-- redirect output to stdout, stderr is used by the vis UI
io.stderr = io.stdout

-- make sure we gracefully terminate, cleanup terminal state etc.
os.exit = function(status)
	vis:exit(status)
end

vis.events.subscribe(vis.events.WIN_OPEN, function(win)
	-- test.in file passed to vis
	local in_file = win.file.name
	if in_file then
		-- use the corresponding test.lua file
		lua_file = string.gsub(in_file, '%.in$', '.lua')
		local ok, msg = pcall(dofile, lua_file)
		if not ok then
			if type(msg) == 'string' then
				print(msg)
			end
			vis:exit(1)
			return
		end
	end
	vis:exit(0)
end)