commit
cb81180eac
6 changed files with 222 additions and 20 deletions
@ -1,11 +1,19 @@ |
||||
-- This is an example Xournal++ Plugin - copy this to get started |
||||
|
||||
print("Hello from Lua Plugin\n"); |
||||
var_dump = require "var_dump" |
||||
|
||||
-- Register all Toolbar actions and intialize all UI stuff |
||||
-- Register all Toolbar actions and intialize all UI stuff |
||||
function initUi() |
||||
print("Plugin initUi called\n"); |
||||
end |
||||
print("Hello from Example: Plugin initUi called\n"); |
||||
|
||||
ref = app.registerUi({["menu"] = "Test123", ["callback"] = "exampleCallback"}); |
||||
print("Menu reference:"); |
||||
var_dump(ref); |
||||
|
||||
app.msgbox("Test123", "yes,no") |
||||
print("Example plugin registered\n"); |
||||
end |
||||
|
||||
-- Callback if the menu item is executed |
||||
function exampleCallback() |
||||
app.msgbox("Test123", "yes,no"); |
||||
end |
||||
|
||||
@ -0,0 +1,33 @@ |
||||
-- Source: https://gist.github.com/lunixbochs/5b0bb27861a396ab7a86#file-var_dump-lua-L1 |
||||
|
||||
local function string(o) |
||||
return '"' .. tostring(o) .. '"' |
||||
end |
||||
|
||||
local function recurse(o, indent) |
||||
if indent == nil then indent = '' end |
||||
local indent2 = indent .. ' ' |
||||
if type(o) == 'table' then |
||||
local s = indent .. '{' .. '\n' |
||||
local first = true |
||||
for k,v in pairs(o) do |
||||
if first == false then s = s .. ', \n' end |
||||
if type(k) ~= 'number' then k = string(k) end |
||||
s = s .. indent2 .. '[' .. k .. '] = ' .. recurse(v, indent2) |
||||
first = false |
||||
end |
||||
return s .. '\n' .. indent .. '}' |
||||
else |
||||
return string(o) |
||||
end |
||||
end |
||||
|
||||
local function var_dump(...) |
||||
local args = {...} |
||||
if #args > 1 then |
||||
var_dump(args) |
||||
else |
||||
print(recurse(args[1])) |
||||
end |
||||
end |
||||
return var_dump |
||||
Loading…
Reference in new issue