Author Topic: Feature request  (Read 895 times)

Graeme

  • Senior Community Member
  • Posts: 2359
  • Hero Points: 310
Feature request
« on: September 09, 2018, 12:06:56 pm »
My hack in xxutils.e https://community.slickedit.com/index.php/topic,11186.msg57320.html#msg57320  for saving and restoring tool-window layout no longer works in  slick V23.

I've asked a few times I think, for save_named_state and load_named_state to be documented, since they seem to work.  It's strange to leave them in the code but not say what they do.  What I would now like is a version of save_window_config that doesn't save buffers so I can use it to save restore tool-window layout without affecting buffers.  I might be able to hack my own version but it's pretty frustrating to have to fix a bunch of things each time a new version of slickedit appears.  e.g. every time proctree.e changes, I have to add the following function to get single click in the defs toolbar back.

Code: [Select]
_proc_tree.lbutton_up()
{
   if (_IsKeyDown(CTRL)) {
      return 0;
   }

   // If there is a pending on-change, kill the timer
   if (gProcTreeFocusTimerId != -1) {
      _kill_timer(gProcTreeFocusTimerId);
      gProcTreeFocusTimerId=-1;
   }
   int index=_TreeCurIndex();
   call_event(CHANGE_LEAF_ENTER,index,p_window_id,ON_CHANGE,'w');
}


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4896
  • Hero Points: 399
Re: Feature request
« Reply #1 on: September 11, 2018, 04:40:53 am »
The auto-restore features, as I'm sure you noticed, are pretty complicated. For beta 5, I've added save_named_layout and load_named_layout commands. Had to tweak some APIs but it wasn't too bad. At least this should be able to be supported. These commands work exactly like yours.

If you want your commands to work in v23, just call these new ones. If you also want your commands to work with older versions, get the current version with _version() and call compareSEVersions() so your code knows which path to take.

Graeme

  • Senior Community Member
  • Posts: 2359
  • Hero Points: 310
Re: Feature request
« Reply #2 on: September 11, 2018, 11:34:08 am »
That's great.  Thanks a lot.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4896
  • Hero Points: 399
Re: Feature request
« Reply #3 on: September 11, 2018, 02:01:06 pm »
Here are some more changes I've made. There are 3 sets of commands:

save_named_state/load_named_state. Writes to state.ini and restores everything (files,tool windows, toolbars).

save_named_files/load_named_files. Writes to windowstate.slk and restores files only. This file really should have been named windowstate.ini but it's too late to change it now.

save_named_layout/load_named_layout. Writes to layoutstate.ini and restores tool windows and tool bars.

These are better names for what these sets of commands do but anyone using saved_named_state/load_named_state will need to use save_named_files/load_named_files instead.

Graeme

  • Senior Community Member
  • Posts: 2359
  • Hero Points: 310
Re: Feature request
« Reply #4 on: September 12, 2018, 11:56:32 am »
ok, thanks.

Graeme

  • Senior Community Member
  • Posts: 2359
  • Hero Points: 310
Re: Feature request
« Reply #5 on: October 05, 2018, 09:56:28 am »
Hi Clark
I think there's an issue with the callback function.  It uses windowstate.slk as the filename every time - but now there are three different filenames.  I had a go at fixing it but it doesn't seem to work.  I'm out of time right now - I'll have another look tomorrow.


Code: [Select]
static _str _load_named_state_callback(int reason, var result, _str key)
{
   _nocheck _control _sellist;
   _nocheck _control _sellistok;
   if (key == 4) {
      item := _sellist._lbget_text();
      status := _ini_delete_section(load_named_state_callback_filename,item);
      if ( !status ) {
         _sellist._lbdelete_item();
      }
   }
   return "";
}

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4896
  • Hero Points: 399
Re: Feature request
« Reply #6 on: October 05, 2018, 02:38:23 pm »
Good catch!

Fixed for beta 6 (unless it's called RC1).

Graeme

  • Senior Community Member
  • Posts: 2359
  • Hero Points: 310
Re: Feature request
« Reply #7 on: October 05, 2018, 09:55:25 pm »
Hi Clark
I found I had to change "key == 4" to "key == 3" to get the callback delete to work.  You might have already noticed that.
I've also added some code to handle windowstate.slk becoming windowstate.ini so all three files have an "ini" extension.  When I did a file compare my diff tool failed - I think because it treated the ini file as a plain text file - but when I forced binary compare it still failed - not sure why.  Anyway that made me think it's perhaps debateable whether the extension should be ini instead of slk  - but I personally don't care so I've assumed ini is best.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4896
  • Hero Points: 399
Re: Feature request
« Reply #8 on: October 05, 2018, 10:20:42 pm »
The changes I made were pretty similar. I don't want to change the filenames for backward compatibility. Also, this requires changing some tables (one in Slick-C and one in C++ code) to special case these files being loading as Utf-8.

Graeme

  • Senior Community Member
  • Posts: 2359
  • Hero Points: 310
Re: Feature request
« Reply #9 on: October 06, 2018, 09:52:07 pm »
ok, this is completely unimportant but just in case I confused you  - I was trying to suggest a way of allowing previously existing windowstate.slk to be used going forward by simply copying it to windowstate.ini if windowstate.ini doesn't exist.  That way everybody uses the three ini files going forward and windowstate.slk is left as a relic.  If you understood me the first time just forget I said this.
I really appreciate you adding this.  I hope it gets some use.