1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
return {
description = "Replaces the textutils pagers with something akin to less",
dependencies = {
"bin/help.lua"
},
settings = {
{
name = "mbs.pager.enabled",
description = "Whether the alternative pager is enabled.",
default = true,
},
{
name = "mbs.pager.mode",
description = "The mode for the alternative pager.",
default = "default",
}
},
enabled = function() return settings.get("mbs.pager.enabled") end,
setup = function(path)
shell.setAlias("help", "/" .. fs.combine(path, "bin/help.lua"))
shell.setCompletionFunction(fs.combine(path, "bin/help.lua"), function(shell, index, text, previous)
if index == 1 then return help.completeTopic(text) end
end)
local native_pprint, native_ptabulate = textutils.pagedPrint, textutils.pagedTabulate
textutils.pagedPrint = function(text, free_lines)
local mode = settings.get("mbs.pager.mode")
if mode == "none" then
return io.write(text .. "\n")
else
return native_pprint(text, free_lines)
end
end
textutils.pagedTabulate = function(...)
local mode = settings.get("mbs.pager.mode")
if mode == "none" then
return textutils.tabulate(...)
else
return native_ptabulate(...)
end
end
end
}
|