Re: [textadept] [code] View to be splitted

From: Gabriel Dubatti <gdubatti.att.gmail.com>
Date: Tue, 11 Sep 2018 10:45:44 -0300

Hi Lukas,

El 11/09/2018 a las 09:53, Procházka Lukáš Ing. escribió:
> Hello,
>
> I would like to create a new view to show some lines of interest
> ("Code Explorer") from all open files.
>
> Being inspired by ta-tweaks and its 'project' module, which provides
> project view, search-in-project view and so, I have a (newbie) question:
>
> TA defines _VIEWS variable.
>
> How do I determine which view to split in the way that one of its
> child will keep its usage (it will show a file content) and the second
> will be used for the "Code Explorer"?
>
> - ta-tweaks 'project' module uses several views, and I deduce that
> number of actual views being shown used by 'project' module may vary.
>
> - Some other views correspond to a file that has been opened.
>
> - There may be views associated with 'untitled' - non existing - files.
>
> - There are views like 'Command Entry', 'Message Buffer'...
>
> I may traverse all _VIEWS members but I don't know how to determine
> which is to be split (it seems that 'ta_view' object has no 'parent'
> or 'childs' members to get parental view or views created by
> splitting, and there is no 'title' member to get title which appears
> in the TA top tab bar, or whether it is 'Command entry' view, 'Message
> Buffer' view...).
>
> Moreover, I'm afraid that e.g. splitting _VIEWS[1] (or any other) may
> break functionality of 'project' module, or it may break the way how
> size of each view is saved between sessions.
>
> So - how to determine view to be split without breaking functionality
> of other modules?
>
> Best regards,
>
> Lukas
>
Keeping the illusion of an IDE in TA can be a little tricky because view
management in TA is more suited for manual use (IMHO).

What I end doing, is assigning a fixed function to each view and instead
of closing them, I change it's size to 0, to hide them.

In project/init.lua I defined in which view every part is shown and the
default split orientation and size. If I want to go to a view, I check
all the previous views exist, and if not, I use the table to create them.

--preferred view number for each view type
Proj.prefview = {
   [Proj.PRJV_DEFAULT] = 0,  -- default view (no active project)
   [Proj.PRJV_PROJECT] = 1,  -- project in view #1
   [Proj.PRJV_FILES]   = 2,  -- project files in view #2
   [Proj.PRJV_SEARCH]  = 3,  -- search results in view #3
   [Proj.PRJV_FILES_2] = 4,  -- files #2 (right side of vertical split)
in view #4
}

--split control { adjust previous view size [%], vertical/horizontal
split, view to split }
Proj.prefsplit = {
   [1] = { 0.20, true,  1 },  -- project files in view #2  (view #1 size
= 20%, VERTICAL)
   [2] = { 0.75, false, 2 },  -- search results in view #3 (view #2 size
= 75%, HORIZONTAL)
   [3] = { 0.50, true,  2 },  -- files #2 in view #4       (view #2 size
= 50%, VERTICAL)
}

You can define where you want your view in this way and add the logic to
hide it when not needed.

Cheers,

Gabriel

-- 
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 11 Sep 2018 - 09:45:44 EDT

This archive was generated by hypermail 2.2.0 : Wed 12 Sep 2018 - 06:41:22 EDT