[TxMt] Re: Changing the selection in a script/command

Richard Drake rdrake98 at gmail.com
Sun Oct 12 07:25:39 UTC 2014


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.


07952130635
skype: rdrake98
blog <https://dl.dropboxusercontent.com/u/51971271/drake/index.html> -
twitter <https://twitter.com/rdrake98>

On 12 October 2014 08:00, René Schwaiger <sanssecours at f-m.fm> wrote:

> Richard Drake wrote
> > That part works, thanks.
> >
> > What seems to have changed from TM1 is that when $TM_SELECTED_TEXT is set
> > all of
> >
> > $TM_LINE_NUMBER
> > $TM_LINE_INDEX
> > $TM_CURRENT_WORD
> > $TM_CURRENT_LINE
> >
> > are blank. The first two at least I need. Is this a bug?
>
> Hi Richard,
>
> I think the way TextMate exports the current selection has changed.
> `TM_SELECTED_TEXT` is now always set, even if there is no selection. It
> contains the current line number and column number.  If there is a
> selection
> it contains both the start and end position in the form:
> `start_line:start_column-end_line:end_column`. You can also see the content
> of this variable at the very left in the status bar after the text “Line:
> ”.
>
> `TM_LINE_NUMBER` and `TM_LINE_INDEX` in TextMate 1 seem to be the line
> number and column number of the “end” of the selection. We can get these
> values in TextMate 2 by using `TM_SELECTED_TEXT`. We apply the following
> steps:
>
> 1. Split on `-` then get the last part of the resulting list
> 2. Split on `:` and check how many items the resulting list contains
> 2.1. If it contains one item then this item is the line number
> (`TM_LINE_NUMBER`).
>      The column number (`TM_LINE_INDEX`) is 0.
> 2.2. If it contains two items, then the first one is the line number and
> the
> second one is the column number.
>
> Kind regards,
>   René
>
>
>
> --
> View this message in context:
> http://textmate.1073791.n5.nabble.com/Changing-the-selection-in-a-script-command-tp28328p28335.html
> Sent from the textmate users mailing list archive at Nabble.com.
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20141012/5ec12e73/attachment-0001.html>


More information about the textmate mailing list