# Lua bindings for Ipe

These are the Lua methods provided by the Ipe program itself. They are only available to Lua code running inside Ipe.

## Application user interface

The application user interface object provides the GUI for the Ipe program.

    -- model is a Lua table containing methods that will be called
    -- by the ui when events occur
    ui = AppUi(model)

    ui:close()         -- close window

    ui:setActionState(name, t) -- set whether action is checked
    t = ui:actionState(name)   -- is action checked?

    ui:explain(text)     -- show message in status bar for a few seconds
    ui:setWindowTitle(caption)

    -- set contents of attribute selectors from style sheet
    ui:setupSymbolicNames(styleSheet)

    -- set attribute values displayed in user interface
    -- 'attributes' table see below
    ui:setAttributes(styleSheet, attributes)

    -- set layer list from page
    ui:setLayers(page, view)

    ui:setActionState(action_name, true_or_false)
    state = ui:actionState(action_name)

The following methods work on the canvas inside the UI:

    ui:setPage(page, view, styleSheet)  -- set page shown on canvas
    ui:setSnap(snap)                    -- for 'snap' table see below
    ui:setFontPool(p)       -- an opaque object obtained from an ipe.Document

    -- 'pan' is a vector indicating the user coordinates at canvas center
    v = ui:pan()
    ui:setPan(v)

    zoom = ui:zoom()        -- a number
    ui:setZoom(zoom)

    v = ui:pos()            -- current mouse position, after snapping
    v = ui:unsnappedPos()   -- current mouse position, before snapping
    v = ui:simpleSnapPos()  -- same, but ignoring angular snap
    v = ui:globalPos()      -- mouse position on screen

    v = ui:canvasSize()     -- size of canvas in pixels

    ui:setPretty(t)         -- true or false
    ui:setFifiVisible(t)    -- true or false

    ui:update()             -- update canvas and tool
    ui:update(false)        -- update tool only
    ui:finishTool()

    ui:panTool()
    ui:selectTool()
    ui:transformTool()
    ui:shapeTool()