Hi,
short question:
Is it possible for a command (Input: “Selection” - fallback to “Line” ; Output: HTML window) to replace the "Input selection" via Javascript's TextMate.system()?
TextMate.system("$DIALOG x-insert --text 'foo'", null) works but only for a selection and not for the fallback situation.
Has anyone an idea?
Thanks, Hans
On 27 Sep 2014, at 18:41, Hans-Jörg Bibiko wrote:
Is it possible for a command (Input: “Selection” - fallback to “Line” ; Output: HTML window) to replace the "Input selection" via Javascript's TextMate.system()?
TextMate.system("$DIALOG x-insert --text 'foo'", null) works but only for a selection and not for the fallback situation.
Has anyone an idea?
Untested, but you could run this if TM_SELECTED_TEXT is unset:
TextMate.system('"$TM_MATE" -l"$TM_LINE_NUMBER-$((TM_LINE_NUMBER+1))"', null)
Then it will select the current line and x-insert should thus replace it.
By default "$TM_MATE" works on current document found via the TM_DOCUMENT_UUID environment variable.
On 28 Sep 2014, at 10:44, Allan Odgaard mailinglist@textmate.org wrote:
On 27 Sep 2014, at 18:41, Hans-Jörg Bibiko wrote:
Is it possible for a command (Input: “Selection” - fallback to “Line” ; Output: HTML window) to replace the "Input selection" via Javascript's TextMate.system()?
TextMate.system("$DIALOG x-insert --text 'foo'", null) works but only for a selection and not for the fallback situation.
Has anyone an idea?
Untested, but you could run this if TM_SELECTED_TEXT is unset:
TextMate.system('"$TM_MATE" -l"$TM_LINE_NUMBER-$((TM_LINE_NUMBER+1))"', null)
Haha - holy ..., it works like a charm :) Allan, thanks a lot, you saved my day!
I've already played with "mate" but I didn't come up with the obvious one. If this works then I thought that this should also work:
TextMate.system('"$TM_MATE" -l"$TM_LINE_NUMBER:1-$TM_LINE_NUMBER:1000000"', null)
and yes :) - due to that this scripting language I'm working on does not allow long lines.
So my line of code is now:
TextMate.system('[[ -z $TM_SELECTED_TEXT ]] && "$TM_MATE" -l"$TM_LINE_NUMBER:1-$TM_LINE_NUMBER:1000000"', null);
Kind regards, Hans
On 28 Sep 2014, at 11:19, Hans-Jörg Bibiko bibiko@eva.mpg.de wrote:
TextMate.system('[[ -z $TM_SELECTED_TEXT ]] && "$TM_MATE" -l"$TM_LINE_NUMBER:1-$TM_LINE_NUMBER:1000000"', null);
Hmm, but this leads to another issue: How to get the actual _current_ line number since TM_QUERY or TM_LINE_NUMBER rely on the bash starting environment?
And while the HTML output window is open the user can change the caret.
Yet another idea?
Best, Hans