Example buffer_actions.lua
require 'textadept'
_M.textui = require 'textui'
local style = _M.textui.style
style.action_style = { back = '#6e6e6e', fore = '#00FFFF' }
local function on_refresh(buffer)
buffer:add_text('Function command: ')
buffer:add_text('Show modifiers', style.action_style, function(buffer, shift, ctl, alt, meta)
local modifiers = ''
if shift then modifiers = modifiers .. ' shift' end
if ctl then modifiers = modifiers .. ' control' end
if alt then modifiers = modifiers .. ' alt' end
if meta then modifiers = modifiers .. ' meta' end
gui.statusbar_text = "Selected with modifiers: " .. modifiers
end)
buffer:add_text('\nTable command: ')
buffer:add_text('Snapopen user home', style.action_style,
{ _M.textadept.snapopen.open, _USERHOME })
buffer:add_text('\n\nExplicit hotspot: ')
local start_pos = buffer.current_pos
buffer:add_text('Click here somewhere\nto select a theme', style.action_style)
buffer:add_hotspot(start_pos, buffer.current_pos, gui.select_theme)
end
local function on_keypress(buffer, key, code, shift, ctl, alt, meta)
if key and string.match(key, '^[a-z]$') then
gui.statusbar_text = key
return true
end
end
local function create_action_buffer()
local buffer = _M.textui.buffer.new('Action buffer')
buffer.on_refresh = on_refresh
buffer.on_keypress = on_keypress
buffer.keys.cc = _M.textadept.menu.select_command
buffer:show()
end
keys['f6'] = create_action_buffer