File: scratchpad.lua

package info (click to toggle)
ipe 7.2.30-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,844 kB
  • sloc: cpp: 42,635; makefile: 664; sh: 44; xml: 17; ansic: 14; python: 7
file content (40 lines) | stat: -rw-r--r-- 1,137 bytes parent folder | download
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
#!/usr/bin/env ipescript 
-- -*- lua -*-
----------------------------------------------------------------------
-- Create a copy of an Ipe presentation for presentation inside Ipe
----------------------------------------------------------------------
--
-- Running this script as "ipescript scratchpad <input> <output>" will
-- create <output> as a copy of the Ipe document <input>,
-- but adding a new layer "scratchpad" to all pages of the input,
-- making this layer the active layer of every view,
-- and locking all input layers.
--
----------------------------------------------------------------------

if #argv ~= 2 then
  io.stderr:write("Usage: ipescript scratchpad <input> <output>\n")
  return
end

local inname = argv[1]
local outname = argv[2]

local doc = assert(ipe.Document(inname))

for pno = 1,#doc do
  print("Page: ", pno)
  local p = doc[pno]
  p:addLayer("scratchpad")
  for vno = 1,p:countViews() do
    p:setActive(vno, "scratchpad")
    p:setVisible(vno, "scratchpad", true)
  end
  for i, l in ipairs(p:layers()) do
    if l ~= "scratchpad" then
      p:setLocked(l, true)
    end
  end
end

doc:save(outname)