[code] [Textadept] command_entry events

From: samg <samg.att.fastmail.com>
Date: Sun, 26 Jan 2020 17:58:34 -0800

Hello,

Does the command entry buffer not emit the CHAR_ADDED event? Or is my
code below flawed? If there's no event, is there another way to get the input?
The only way I can think of other than events is to rebind every character and
 number in mode_keys. I'm running Textadept 10.8 on Linux.

Thanks,
Sam

-- Example
function run()
  local function on_entry(c)
    ui.print('here!')
  end
  
  -- define keys
  mode_keys = {
    ['esc'] = function()
      events.disconnect(events.CHAR_ADDED, on_entry)
      ui.command_entry.focus()
    end,
    ['\n'] = function()
      events.disconnect(events.CHAR_ADDED, on_entry)
      ui.command_entry.focus()
    end
  }
  setmetatable(mode_keys, ui.command_entry.editing_keys)

  -- add event handler
  events.connect(events.CHAR_ADDED, on_entry)

  -- open command entry
  ui.command_entry.focus()
  ui.command_entry.height = ui.command_entry:text_height(0)
  keys._command_entry, keys.MODE = mode_keys, '_command_entry'
end

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sun 26 Jan 2020 - 20:58:34 EST

This archive was generated by hypermail 2.2.0 : Mon 27 Jan 2020 - 06:51:01 EST