[TxMt] Snippet Question: Insert given values of parameters with pull-down menu
Hans-Jörg Bibiko
bibiko at eva.mpg.de
Fri Apr 27 22:54:52 UTC 2007
Hi,
I have to write much XSL stuff. I use among others the snippet
collection of Andreas Schöller (BTW thanks for that).
He was so kind to add information about the valid values of parameters.
example:
Snippet ou =>
<xsl:output
name=""
encoding="utf-8|ASCII|US-ASCII|iso-8859-1|utf8|KOI8R|cp1251"
indent="no|yes"
use-character-maps="mapping1 mapping2"
method="text|html|xml|xhtml"
/>
As usual I can use TAB to jump to each ${n:} token.
Now my question:
Would it be possible to convert e.g. the token 'text|html|xml|xhtml'
into a pull-down menu?
I tried it this way:
After pressing TAB TM highlights 'text|html|xml|xhtml'; I invoke a
command:
`echo -en "$TM_SELECTED_TEXT" | ruby -e '
require File.join(ENV["TM_SUPPORT_PATH"], "lib/dialog.rb")
words = STDIN.read().split("|")
print words[(Dialog.menu words)]
'`
and I can choose what I want. After that, of course, I cannot use TAB
to navigate through the snippet any more, unfortunately.
I also tried a snippet like:
<xsl:output method="${1:`echo -en "text|html|xml|xhtml" | ruby -e '
require File.join(ENV["TM_SUPPORT_PATH"], "lib/dialog.rb")
words = STDIN.read().split("|")
print words[(Dialog.menu words)]
'`}" encoding="${2:`echo -en "utf-8|ASCII|US-ASCII|iso-8859-1|utf8|
KOI8R|cp1251" | ruby -e '
require File.join(ENV["TM_SUPPORT_PATH"], "lib/dialog.rb")
words = STDIN.read().split("|")
print words[(Dialog.menu words)]
'`}"/>
In principal this works and the TAB behaviour isn't disturb but I
have no visual feedback what I'm typing while the menus popping up
and the TAB mechanism starts at token 1 which I already entered.
Would it cost much effort to implement such a behaviour? Meaning if I
press TAB and within the new selection occurs a given delimiter (here
| ) or tag or what ever that the snippet parser will show this
selection as pull-down menu automatically without distroying the TAB
mechanism.
And, would it make sense as a global snippet feature?
Regards,
Hans
More information about the textmate
mailing list