-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinsertion_helper.lua
More file actions
21 lines (19 loc) · 845 Bytes
/
insertion_helper.lua
File metadata and controls
21 lines (19 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local sep = package.config:sub(1, 1) -- path separator depends on OS
local sourcePath = debug.getinfo(1).source:match("@?(.*" .. sep .. ")")
local stroke_io = require "stroke_io"
local _M = {}
-- Function to insert strokes for a shape (need to extract the shape name from the dictionary)
function _M.insert_stroke(shape_name)
local filepath = sourcePath .. "Shapes" .. sep .. shape_name .. ".lua"
local strokes = stroke_io.read_strokes_from_file(filepath)
if strokes and #strokes > 0 then
local refs = app.addStrokes({ strokes = strokes , allowUndoRedoAction = "grouped" })
if app.addToSelection then
app.addToSelection(refs)
else
print("Cannot add shape to selection because of missing API, consider upgrading Xournal++")
end
app.refreshPage()
end
end
return _M