On 12 Oct 2014, at 9:25, Richard Drake wrote:
Thanks René
You gave me the crucial clue but, for the record, it's (for example)
TM_SELECTED_TEXT="some text"
TM_SELECTION="14:6-14:15"
and it's the second one I was missing.
For the records, TM_SELECTION follows the selection string syntax documented here: http://manual.textmate.org/references.html#selection-string
For example with multiple selections or columnar selections, you will see & and x in the string, and with “freehanded” placement of caret (e.g. option click past end of line) you will see + (which can also occur for column selections).
I think a regexp like this can be used for a simple parser:
/^(\d+)(?::(\d+))?(?:\+\d+)?(-|x)(\d+)(?::(\d+))?(?:\+\d+)?(?:&.*)?$/
$1 = from line
$2 = from column
$3 = - or x indicating regular or columnar selection
$4 = to line
$5 = to column
I didn’t capture the “past EOL offsets”.
_______________________________________________
textmate mailing list
textmate@lists.macromates.com
http://lists.macromates.com/listinfo/textmate