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
|
local args, state = ...
-- Set up views table
local views = scroll.state_get_value(state, "views")
if views == nil then
scroll.state_set_value(state, "views", {})
views = scroll.state_get_value(state, "views")
end
local function find_view(view)
for _, v in ipairs(views) do
if v["object"] == view then
return v
end
end
return nil
end
if args[1] == 'toggle' then
local focused_view = scroll.focused_view()
local view = find_view(focused_view)
if view == nil then
view = {
object = focused_view,
maximized = false,
wf = 0,
hf = 0
}
table.insert(views, view)
end
view["maximized"] = not view["maximized"]
if view["maximized"] then
local container = scroll.view_get_container(focused_view)
view["wf"] = scroll.container_get_width_fraction(container)
view["hf"] = scroll.container_get_height_fraction(container)
scroll.command(nil, "set_size h 1.0")
scroll.command(nil, "set_size v 1.0")
else
scroll.command(nil, "set_size h " .. view["wf"])
scroll.command(nil, "set_size v " .. view["hf"])
end
end
|