summaryrefslogtreecommitdiff
path: root/vis/visrc.lua
blob: 909aa00228ff8d3c597a4e4197fe7dff4332c619 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
vis.events = {}
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$', '')
		local file = assert(io.popen(string.format("cpp -P '%s.keys'", name), 'r'))
		local keys = file:read('*all')
		keys = string.gsub(keys, '<Space>', ' ')
		keys = string.gsub(keys, '\n', '')
		file:close()
		vis:feedkeys(keys..'<Escape>')
		vis:command(string.format("w! '%s.out'", name))
	end
	vis:command('q!')
end