[textadept] Snippets and event.handlers

From: Robert <ro....at.web.de>
Date: Mon, 9 May 2011 20:17:33 +0200

Hi,

since I never seem to be able to remember the _exact_ event names I
wanted to have a snippet
for connecting to an event:

function event_names()
  local buffer = buffer
  local handlers = _G.events.handlers
  local event_names = {}
  for k, _ in pairs(handlers) do
    event_names[#event_names + 1] = k
  end
  table.sort(event_names)
  event_name = gui.filteredlist('Events', 'Events', event_names)
  if event_name then return event_name else return '' end
end

snippets.ev = "events.connect('%1<event_names()>', %0)"

This would require events.handlers to be a public table. [1]

I also found an issue when there is no explicit %0 at the end of a
snippet. More details at [2]

Robert

[1] http://code.google.com/p/textadept/issues/detail?id=148
[2] http://code.google.com/p/textadept/issues/detail?id=147
Received on Mon 09 May 2011 - 14:17:33 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:06:37 EST