From 26afcec76912f88cc25bbeb70a6cc8850d999516 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 14 Jan 2020 13:27:28 +0300 Subject: [PATCH] fix(backends): Implement cursor tracking to roughly simulate glues --- core/text-output.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/core/text-output.lua b/core/text-output.lua index 789cf2b8e..d300074e4 100644 --- a/core/text-output.lua +++ b/core/text-output.lua @@ -3,15 +3,12 @@ if (not SILE.outputters) then SILE.outputters = {} end local outfile local cursorX = 0 local cursorY = 0 -local hboxCount = 0 +local started = false local writeline = function (...) local args = table.pack(...) - if hboxCount >= 1 then outfile:write(" ") end for i=1, #args do outfile:write(args[i]) - if i < #args then outfile:write(" ") end - hboxCount = hboxCount + 1 end end @@ -28,16 +25,24 @@ SILE.outputters.text = { setColor = function() end, pushColor = function () end, popColor = function () end, - outputHbox = function (value) - writeline(value.text) + outputHbox = function (value, width) + width = SU.cast("number", width) + if width > 0 then + writeline(value.text) + started = true + cursorX = cursorX + width + end end, setFont = function () end, drawImage = function () end, imageSize = function () end, moveTo = function (x, y) - if y > cursorY or x <= cursorX then - outfile:write("\n") - hboxCount = 0 + if started then + if y > cursorY or x < cursorX then + outfile:write("\n") + elseif x > cursorX then + outfile:write(" ") + end end cursorY = y cursorX = x