[TxMt] Re: Suggestions for implementing incremental-search like functionality
Allan Odgaard
mailinglist at textmate.org
Fri Mar 14 00:59:29 UTC 2014
On 13 Mar 2014, at 19:47, Chriztian Steinmeier wrote:
> […] An alternative way would be to just open a $DIALOG, asking for
> the XPath expression and then do the processing - but I can't see a
> $DIALOG command that lets me do that (read input)...
Using the ruby UI wrapper (for DIALOG), such command could take the
following form:
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
-wKU
require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes"
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui"
query = TextMate::UI.request_string(:prompt => "XPath Query:")
TextMate.exit_discard if query.to_s.empty?
# output HTML based on stdin and query…
You can mix this with the suggestion by Hans-Jörg, i.e. let the
generated HTML include a text field prepopulated with the query string,
allowing the user to change the query.
If so, you may want to allow an initial empty query string, for that,
change ‘query.to_s.empty?’ → ‘query.nil?’ in the above. This
will still allow the user to abort the command (and never see the HTML
output window) via the Cancel button (or ⌘,) but if they just press
return, the window will appear.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20140314/586b39c3/attachment.html>
More information about the textmate
mailing list