Re: [code] [textadept] Are you a keyboard junkie?

From: Mitchell <>
Date: Tue, 9 Apr 2013 13:39:07 -0400 (Eastern Daylight Time)

Hi Pete,

On Mon, 8 Apr 2013, Peter Kazmier wrote:

> [snip]
> I'd really like to make an I.COMMAND_ENTRY argument that can be used
> with I.wrap so that I can prompt the user for input from the command
> entry line instead of the heavy weight gtdialog input box (my I.PROMPT).
> I need help with a simple function that returns whatever was input in
> the command entry box. I can't wrap my head around the current examples
> of where you use command entry as the flow of control leaves the
> function that invokes it. So in my case, I would need a function that
> I.wrap can execute (I.COMMAND_ENTRY[2]) and get a simple return with a
> value. But I can't seem to wrap my head around how to do this because
> the flow of control leaves the function that sends the user to the
> command entry. Do you have any ideas or suggestions?

Technically in curses, calling `gui.command_entry.focus()` is blocking, so
when `focus()` returns, `gui.command_entry.entry_text` holds the text
entered in. There are a couple ways you can do what you want to do, but
this provides better encapsulation I think:

   -- This will only work in curses since
   -- `gui.command_entry.focus()` is blocking.
   function gui.command_entry.get_command()
     local command = ''
     local idx = events.connect(events.COMMAND_ENTRY_COMMAND,
                                  command = cmd
                                  return false
                                end, 1)
     events.disconnect(events.COMMAND_ENTRY_COMMAND, idx)
     return command

Otherwise, you can set a variable before calling `focus()`, then in a new
COMMAND_ENTRY_COMMAND handler at index 1, check for that flag, returning
`false` if it's on so the command is not propagated further (much like
incremental find). Then after calling `focus()`, read from

I hope that helps,

You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Tue 09 Apr 2013 - 13:39:07 EDT

This archive was generated by hypermail 2.2.0 : Wed 10 Apr 2013 - 06:49:42 EDT