Skip to content

Commit

Permalink
fix(backends): Implement cursor tracking to roughly simulate glues
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jan 14, 2020
1 parent 4f24d4a commit 26afcec
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions core/text-output.lua
Expand Up @@ -3,15 +3,12 @@ if (not SILE.outputters) then SILE.outputters = {} end
local outfile local outfile
local cursorX = 0 local cursorX = 0
local cursorY = 0 local cursorY = 0
local hboxCount = 0 local started = false


local writeline = function (...) local writeline = function (...)
local args = table.pack(...) local args = table.pack(...)
if hboxCount >= 1 then outfile:write(" ") end
for i=1, #args do for i=1, #args do
outfile:write(args[i]) outfile:write(args[i])
if i < #args then outfile:write(" ") end
hboxCount = hboxCount + 1
end end
end end


Expand All @@ -28,16 +25,24 @@ SILE.outputters.text = {
setColor = function() end, setColor = function() end,
pushColor = function () end, pushColor = function () end,
popColor = function () end, popColor = function () end,
outputHbox = function (value) outputHbox = function (value, width)
writeline(value.text) width = SU.cast("number", width)
if width > 0 then
writeline(value.text)
started = true
cursorX = cursorX + width
end
end, end,
setFont = function () end, setFont = function () end,
drawImage = function () end, drawImage = function () end,
imageSize = function () end, imageSize = function () end,
moveTo = function (x, y) moveTo = function (x, y)
if y > cursorY or x <= cursorX then if started then
outfile:write("\n") if y > cursorY or x < cursorX then
hboxCount = 0 outfile:write("\n")
elseif x > cursorX then
outfile:write(" ")
end
end end
cursorY = y cursorY = y
cursorX = x cursorX = x
Expand Down

0 comments on commit 26afcec

Please sign in to comment.