Author Topic: File tab collection  (Read 1636 times)

dunkers

  • Senior Community Member
  • Posts: 778
  • Hero Points: 36
File tab collection
« on: August 20, 2023, 02:32:16 PM »
Surely someone else must've asked for this before, but a search hasn't turned up anything...

I start editing in a project and open a file or two. As time goes on I open more files, and before long the list of open files is wider than the Slickedit window - instead of just clicking one of those tabs (in the file tab toolbar) I resort to popping open the projects toolbar to select a file! So eventually I will remove tabs I've not opened for some time, and then curse when it turns out to be the file I want next.

So, my request is for file tab collections. What I envision is some popup dialog which will let you save the currently open files and tabs under some user-defined name (note: this is the list of files and tabs, not saving the contents of the files). At some point the user can pop up the dialog and select a previously saved set of files/tabs which will replace the ones currently open/showing for the project.

Perhaps an additional option in workspace properties might do it too or instead.

Graeme

  • Senior Community Member
  • Posts: 2816
  • Hero Points: 347
Re: File tab collection
« Reply #1 on: August 21, 2023, 09:06:29 AM »
macros save_named_files and load_named_files might do what you want
https://community.slickedit.com/index.php/topic,17865.msg69981.html#msg69981

also, when you need to close some files, probably you already know, but if you set file tab sort order to "most recently viewed", you can close files that you haven't viewed for a while.  Another thing is that at the right hand end of the file tabs there is a drop-down list that shows you all the files you have open in that window.
« Last Edit: August 21, 2023, 09:39:44 AM by Graeme »

dunkers

  • Senior Community Member
  • Posts: 778
  • Hero Points: 36
Re: File tab collection
« Reply #2 on: August 21, 2023, 12:39:39 PM »
Ah! save-named-files (which you told me about before, but which I wasn't looking for then) seems to do exactly the right job. Thanks!

I know about the drop down on the right, but it's not that useful (except where you have so many files open you can't see them all on the tab bar). You can't, for instance, multi-select to close. So initially I thought I just wanted a better and quicker way to reduce the number - F3 in the tab bar works, but it just reduces the number and doesn't discriminate which files are being closed (unless you take your time over it). But then I realised I wanted a specific set so it's opening stuff as well as closing. Perhaps having a defined set depending on which part of the project I'm working on, and the xxx-named-files macros do that.

dunkers

  • Senior Community Member
  • Posts: 778
  • Hero Points: 36
Re: File tab collection
« Reply #3 on: August 20, 2024, 06:43:20 PM »
Me again :)

save-named-files turns out not to be appropriate - it saves/loads to/from some global config, where I really want it to be per project. Obviously, loading tabs from a different project which have the same filenames can lead to serious mistakes, although I suppose there might be some use for it.

So, no problem: just find the macro and copy it to modify. Except I can't find it anywhere. Seems to be in the blob for which no source is provided.

Is that correct, or am I just no looking in the right place?

Graeme

  • Senior Community Member
  • Posts: 2816
  • Hero Points: 347
Re: File tab collection
« Reply #4 on: August 20, 2024, 08:36:48 PM »
Hi
The source code is at restore.e line 2100

on the slick command line, type
fp save-named-files
and it should find it

The command allows you to specify a name for the set of files - you could prefix the name with the name of the project perhaps.
The save_named_files command looks like this
_command void save_named_files(_str sectionName="") name_info(',') {
   save_named_state(sectionName,true,false,VSCFGPROFILE_NAMED_FILES);
}
VSCFGPROFILE_NAMED_FILES is the string "named_files"

This ends up in user.cfg.xml as this
   <misc.named_files n="misc.named_files" version="1">
      <p n="gp1">
         <monitor_configs>


So theoretically you can change the string to the name of your project or workspace or something and it might do what you want, and same with load_named_files.
Another possibility is to copy the code for save_named_state and experiment.  Unfortunately I don't know anything about the xmlcfg stuff or profiles.  I suspect that you can supply a filename in the call to _xmlcfg_create and it will write to that file instead of user.cfg.xml.  The VSCFGPACKAGE_MISC thing is the string "misc"  - which I guess results in the "misc.named_files" bit you can see above
_plugin_get_profile seems to be in the core code and you don't get a choice of where it goes looking for the profile, so if you specify your own filename in the call to xmlcfg_create, it will never find the profile  - but maybe that doesn't matter, I do not know.

Code: [Select]
   profile_handle:=_plugin_get_profile(VSCFGPACKAGE_MISC,profile_name);
   if (profile_handle<0) {
      profile_handle=_xmlcfg_create('',VSENCODING_UTF8);
      int profile_node=_xmlcfg_add(profile_handle,0,VSXMLCFG_PROFILE,VSXMLCFG_NODE_ELEMENT_START,VSXMLCFG_ADD_AS_CHILD);
      _xmlcfg_set_attribute(profile_handle,profile_node,VSXMLCFG_PROFILE_NAME,_plugin_append_profile_name(VSCFGPACKAGE_MISC,profile_name));
   }

   handle:=_xmlcfg_create('',VSENCODING_UTF8);

Graeme

  • Senior Community Member
  • Posts: 2816
  • Hero Points: 347
Re: File tab collection
« Reply #5 on: August 20, 2024, 08:39:46 PM »
also meant to say, the "Files" toolwindow allows you to select and close multiple files at the same time.

dunkers

  • Senior Community Member
  • Posts: 778
  • Hero Points: 36
Re: File tab collection
« Reply #6 on: August 20, 2024, 09:23:10 PM »
Many thanks, Graham. Again! Don't know why I couldn't find that, except perhaps I was looking for save-named-files, although I'm sure I tried both variants.

I will try copying to a custom file (so updates don't erase it) and experiment.