Re: [code] [textadept] Event just a file to be opened

From: Mitchell <m.att.foicica.com>
Date: Tue, 30 Jul 2019 15:43:38 -0400 (EDT)

Hi Lukas,

On Tue, 30 Jul 2019, Procházka Lukáš Ing. wrote:

> Hello,
>
> suppose that TA has two views, (1) of a file buffer and (2) be a [Message
> Box].
>
> Suppose that [Message Box] view has focus.
>
> That a third app launches TA to open a second file.
>
> Here, TA uses the current view, i.e. that of [Message Box], to show the
> second file (buffer) content.
>
> But I'm looking for a way to tell TA to switch to the view (1) just before a
> second file is being opened, so [Message Box] view keeps unchanged whilst the
> "file" view is used to show the file to be opened.
>
> How to process this?
>
> My idea is to handle an event, like 'events.FILE_TO_BE_OPENED', which would
> change the current view in advance.
>
> Is there a such way?

If this only happens when an external application calls upon Textadept to open the file, then you may be able to hook into the undocumented 'cmd_line' event:

   events.connect('cmd_line', function()
     if buffer._type == _L['[Message Buffer]'] and #_VIEWS > 1 then
       -- go to another view
     end
   end, 1)

Note the second argument to `events.connect()` is needed in order to be processed before Textadept's default event, which would open files passed to Textadept.

I have not tested this idea though.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 30 Jul 2019 - 15:43:38 EDT

This archive was generated by hypermail 2.2.0 : Wed 31 Jul 2019 - 06:49:13 EDT