26 lines
458 B
Lua
26 lines
458 B
Lua
return function(con)
|
|
|
|
function con.forLine(l, fn, oy)
|
|
local x, y = 0, 0
|
|
for j, l in utf8.codes(con.out[l]) do
|
|
l = utf8.char(l)
|
|
if fn then fn(l, x, y + oy) end
|
|
if l == '\t' then x = x + 8 - (x % 8)
|
|
elseif l == '\v' then y = y + 1
|
|
elseif l == '\r' then x = 0
|
|
else x = x + 1
|
|
end
|
|
end
|
|
return y
|
|
end
|
|
|
|
function con.forText(fn)
|
|
local y = 0
|
|
for i = 1, #con.out do
|
|
y = y + 1 + con.forLine(i, fn, y)
|
|
end
|
|
return y
|
|
end
|
|
|
|
end
|