<div dir="ltr"><div><div>Thanks René<br><br></div>You gave me the crucial clue but, for the record, it's (for example)<br><br>TM_SELECTED_TEXT="some text"<br>TM_SELECTION="14:6-14:15"<br><br></div>and it's the second one I was missing.<br></div><div class="gmail_extra"><br clear="all"><div><br>07952130635<br>skype: rdrake98<br><a href="https://dl.dropboxusercontent.com/u/51971271/drake/index.html" target="_blank">blog</a> - <a href="https://twitter.com/rdrake98" target="_blank">twitter</a><br></div>
<br><div class="gmail_quote">On 12 October 2014 08:00, René Schwaiger <span dir="ltr"><<a href="mailto:sanssecours@f-m.fm" target="_blank">sanssecours@f-m.fm</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Richard Drake wrote<br>
<span class="">> That part works, thanks.<br>
><br>
> What seems to have changed from TM1 is that when $TM_SELECTED_TEXT is set<br>
> all of<br>
><br>
> $TM_LINE_NUMBER<br>
> $TM_LINE_INDEX<br>
> $TM_CURRENT_WORD<br>
> $TM_CURRENT_LINE<br>
><br>
> are blank. The first two at least I need. Is this a bug?<br>
<br>
</span>Hi Richard,<br>
<br>
I think the way TextMate exports the current selection has changed.<br>
`TM_SELECTED_TEXT` is now always set, even if there is no selection. It<br>
contains the current line number and column number.  If there is a selection<br>
it contains both the start and end position in the form:<br>
`start_line:start_column-end_line:end_column`. You can also see the content<br>
of this variable at the very left in the status bar after the text “Line: ”.<br>
<br>
`TM_LINE_NUMBER` and `TM_LINE_INDEX` in TextMate 1 seem to be the line<br>
number and column number of the “end” of the selection. We can get these<br>
values in TextMate 2 by using `TM_SELECTED_TEXT`. We apply the following<br>
steps:<br>
<br>
1. Split on `-` then get the last part of the resulting list<br>
2. Split on `:` and check how many items the resulting list contains<br>
2.1. If it contains one item then this item is the line number<br>
(`TM_LINE_NUMBER`).<br>
     The column number (`TM_LINE_INDEX`) is 0.<br>
2.2. If it contains two items, then the first one is the line number and the<br>
second one is the column number.<br>
<br>
Kind regards,<br>
  René<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://textmate.1073791.n5.nabble.com/Changing-the-selection-in-a-script-command-tp28328p28335.html" target="_blank">http://textmate.1073791.n5.nabble.com/Changing-the-selection-in-a-script-command-tp28328p28335.html</a><br>
Sent from the textmate users mailing list archive at Nabble.com.<br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
textmate mailing list<br>
<a href="mailto:textmate@lists.macromates.com">textmate@lists.macromates.com</a><br>
<a href="http://lists.macromates.com/listinfo/textmate" target="_blank">http://lists.macromates.com/listinfo/textmate</a></div></div></blockquote></div><br></div>