if use() is passed a file, uses that. If it's passed nil as the buffer, it uses stdin

This commit is contained in:
Geoff Leyland 2014-06-19 16:13:38 +12:00
parent 8db3740230
commit 3b28558461

View File

@ -411,9 +411,17 @@ buffer_mt.__index = buffer_mt
local function use(buffer, parameters)
parameters = parameters or {}
parameters.filename = parameters.filename or "<unknown>"
parameters.column_map = parameters.columns and
column_map:new(parameters.columns)
if not buffer then
buffer = file_buffer:new(io.stdin)
elseif io.type(buffer) == "file" then
buffer = file_buffer:new(buffer)
end
local f = { buffer = buffer, parameters = parameters }
return setmetatable(f, buffer_mt)
end