• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 14390735465

10 Apr 2025 09:30PM UTC coverage: 34.559% (-31.7%) from 66.23%
14390735465

push

github

alerque
Merge tag 'v0.15.12' into develop

4 of 4 new or added lines in 3 files covered. (100.0%)

4064 existing lines in 73 files now uncovered.

6918 of 20018 relevant lines covered (34.56%)

2597.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/outputters/text.lua
1
local base = require("outputters.base")
×
2

3
local cursorX = 0
×
4
local cursorY = 0
×
5

6
local outfile
7
local started = false
×
8

9
local outputter = pl.class(base)
×
10
outputter._name = "text"
×
11
outputter.extension = "txt"
×
12

13
-- The outputter init can't actually initialize output (as logical as it might
14
-- have seemed) because that requires a page size which we don't know yet.
15
-- function outputter:_init () end
16

17
function outputter:_ensureInit ()
×
18
   if not started then
×
19
      started = true
×
20
      local fname = self:getOutputFilename()
×
UNCOV
21
      outfile = fname == "-" and io.stdout or io.open(fname, "w+")
×
22
   end
23
end
24

25
function outputter:_writeline (...)
×
26
   self:_ensureInit()
×
27
   local args = pl.utils.pack(...)
×
28
   for i = 1, #args do
×
UNCOV
29
      outfile:write(args[i])
×
30
   end
31
end
32

33
function outputter:newPage ()
×
34
   self:_ensureInit()
×
UNCOV
35
   outfile:write(" ")
×
36
end
37

38
function outputter.abort ()
×
39
   if started then
×
40
      outfile:close()
×
UNCOV
41
      started = false
×
42
   end
43
end
44
function outputter:finish ()
×
UNCOV
45
   self:_ensureInit()
×
UNCOV
46
   self:runHooks("prefinish")
×
47
   outfile:close()
×
48
   started = false
×
49
end
50

51
function outputter:getCursor ()
×
52
   return cursorX, cursorY
×
53
end
54

55
function outputter:setCursor (x, y, relative)
×
56
   self:_ensureInit()
×
57
   local bs = SILE.types.measurement("0.8bs"):tonumber()
×
58
   local spc = SILE.types.measurement("0.8spc"):tonumber()
×
UNCOV
59
   local offset = relative and { x = cursorX, y = cursorY } or { x = 0, y = 0 }
×
60
   local newx, newy = offset.x + x, offset.y - y
×
UNCOV
61
   if started then
×
62
      if newx < cursorX then
×
63
         outfile:write("\n")
×
64
      elseif newy > cursorY then
×
UNCOV
65
         if newy - cursorY > bs then
×
66
            outfile:write("\n")
×
67
         else
UNCOV
68
            outfile:write("\u{202b}")
×
69
         end
70
      elseif newx > cursorX then
×
71
         if newx:tonumber() - cursorX:tonumber() > spc then
×
UNCOV
72
            outfile:write(" ")
×
73
         else
74
            outfile:write("\u{202b}")
×
75
         end
76
      end
77
   end
78
   cursorY = newy
×
UNCOV
79
   cursorX = newx
×
80
end
81

82
function outputter:drawHbox (value, width)
×
83
   self:_ensureInit()
×
UNCOV
84
   width = SU.cast("number", width)
×
UNCOV
85
   if not value.text then
×
UNCOV
86
      return
×
87
   end
88
   self:_writeline(value.text)
×
89
   if width > 0 then
×
UNCOV
90
      cursorX = cursorX + width
×
91
   end
92
end
93

UNCOV
94
function outputter:drawRaw (literal)
×
UNCOV
95
   self:_ensureInit()
×
UNCOV
96
   outfile:write(literal)
×
97
end
98

UNCOV
99
return outputter
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc