by robert » Fri Apr 13, 2012 1:13 pm
I'll admit that the requirement for typing "</" to insert the close tag was a personal preference; I don't really like closing tags auto-inserted when I type the closing ">" of the opening tag. If this were an option (perhaps choose between the way things are now, auto-inserting closing tags, and no closing tag assistance at all), would this alleviate most of your problems?
As for completions where the caret is placed somewhere in the middle of the inserted text, that would definitely be a good addition to the library. The closest thing today is parameterized completions, which doesn't fit your needs since it assumes it's for C-style method parameters (a list of stuff between single-char delimiters, such as parens). No answer for this just yet.
There is no implicit auto-completion support either, but for the specific example you asked about, I believe you could override your TokenMaker's getInsertBreak() method to return an action that checked whether the token at offset (caret-1) was a start tag's closing bracket and the token at offset (caret) was a closing tag's open bracket (if that makes sense). In that case, do your special formatting, otherwise just do a standard replaceSelection("\n"). In fact, I could see this as a feature request for the built-in XML and MXML TokenMakers.
<OT>
This library has made me appreciate the structure of EditorKits in the Swing text package. Things like that custom newline action would be in a much more logical place there, but have gotten a little messy in RSTA due to my desire to separate simple syntax highlighting/editing from code completion, syntax checking, etc.
</OT>
I'll admit that the requirement for typing "</" to insert the close tag was a personal preference; I don't really like closing tags auto-inserted when I type the closing ">" of the opening tag. If this were an option (perhaps choose between the way things are now, auto-inserting closing tags, and no closing tag assistance at all), would this alleviate most of your problems?
As for completions where the caret is placed somewhere in the middle of the inserted text, that would definitely be a good addition to the library. The closest thing today is parameterized completions, which doesn't fit your needs since it assumes it's for C-style method parameters (a list of stuff between single-char delimiters, such as parens). No answer for this just yet.
There is no implicit auto-completion support either, but for the specific example you asked about, I believe you could override your TokenMaker's getInsertBreak() method to return an action that checked whether the token at offset (caret-1) was a start tag's closing bracket and the token at offset (caret) was a closing tag's open bracket (if that makes sense). In that case, do your special formatting, otherwise just do a standard replaceSelection("\n"). In fact, I could see this as a feature request for the built-in XML and MXML TokenMakers.
<OT>
This library has made me appreciate the structure of EditorKits in the Swing text package. Things like that custom newline action would be in a much more logical place there, but have gotten a little messy in RSTA due to my desire to separate simple syntax highlighting/editing from code completion, syntax checking, etc.
</OT>