Session Manager [v7.90]  —  Bookmark your environments: locations and/or display (save/restore tabsets and layout)

Discuss and share scripts and script files...
Malarki
Posts: 208
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: Session Manager [v7.50]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by Malarki »

The change from "caption" to "label" fixed it. All good now. Thanks!

FluxTorpedoe
Posts: 904
Joined: 05 Oct 2011 13:15

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by FluxTorpedoe »

 
#####################
###  Session Manager v7.80  ###
#####################



Hi everyone,

Here’s a new update with a few additions, a few specific fixes/requests, and a (probable overall) slight speed boost…
…While Session Manager has crossed the 5000 lines barrier! :twisted:

So I’d like to take the opportunity of this (humble) milestone to thank Don for XYplorer,
as well as every user and forum member for their contribution.

:D


Most notable (full list and more details available below in changelog):
++ For newcomers — Easy install: Automatic creation of toolbar button on first run
———————————————————————————
New append actions (and related tools)
+++ New entry: Actions > Append Current Tabs to Another Session (appended tabs will be in the background and have a blue text)
      This will remember the tabs of (only) the visible pane(s), load the chosen session,
      then append the tabs to the matching pane(s) of the session, only if pane also visible and no duplicate tabs
+++ New entry: Actions > Append Active Tab to Another Session (appended tab will be in the foreground and have a blue text)
      This will remember the active tab, load the chosen session,
      then append the tab (duplicate or not) to the active pane
      New default mouse modifier: Ctrl+Click on a session name (see below to assign modifier)
+ New entry: Actions > Remove Text Color of All Visible Tabs
+ 2 new mouse modifiers available when clicking on session
      Access in: Actions > Edit Mouse Modifiers (Used When Clicking on a Session Name)...
———————————————————————————
• 5 (~8) New commands for external access (Catalog, CKS, UDC...):
+ Save as new session
+ Delete specific session
+ Append another session to current tabs (select session from list / or specific)
+ Append current tabs to another session (from list / or specific)
+ Append active tab to another session (from list / or specific)
———————————————————————————
+ Script can now be used properly without a toolbar button {seemingly benigne but quite important code change}
! Fixed Session Manager not displaying its menu (since v7.50) when run via Catalog or XYplorer User>Run/Load

Have a nice day! 8)
   Flux

———————————————————————————

• DOWNLOADS: (Previous versions available in Changelog)

› Script:
SessionManager.xys
(246.79 KiB) Downloaded 370 times
 
› Script in UTF-16 LE: (Special version for foreign languages who encounter "invalid character" issues)
SessionManager-UTF16.zip
(61.04 KiB) Downloaded 281 times
 
› Languages:
   Don’t forget to come back here to check when language files are updated.
   Installation: Just copy the (extracted) language file (eg. SessionManager.it) in the same folder as the script itself (SessionManager.xys).
   Note: All the following files work with Session Manager latest version (untranslated strings will just be displayed in English).
 — Čeština by Hogatyv6.50+
 — Dansk by Regmosv6.50+
 — Italiano by Flora_RMCv6.90+
 — Deutsche by Dean36v6.60+
 — Português (Brasil) by SkyFrontierv5.2+
 — Français by pseudozv4.b1+
 — 中文 by Haodeav6.80+

———————————————————————————

• REQUIREMENTS:
 — XYplorer >= 19.90.0112 — Highly Recommended: XYplorer version >= 24.30.0121

• INSTALLATION » for first-time users:
 — Please refer to first post

• UPDATE » for all users:
 — Overwrite your existing "SessionManager.xys" file with latest version
 — Note: On first run, an XYplorer and Session Manager maintenance check might be done and display a confirmation message, you can safely press OK. (Or run it later via "Options > Maintenance Check...")

• UPDATE » for non-english users:
 — Also download one of the language files and extract it into the same folder as SessionManager.xys (language detection is automatic)

———————————————————————————

• CHANGELOG:
++ Easy install: Automatic creation of toolbar button on first run
++ Loading and quick switching between sessions (eg Ctrl+Click on button) should be slightly faster overall
———————————————————————————
New append actions (and related tools)
+++ New entry: Append Current Tabs to Another Session (appended tabs will be in the background and have a blue text)
      This will remember the tabs of (only) the visible pane(s), load the chosen session,
      then append the tabs to the matching pane(s) of the session, only if pane also visible and no duplicate tabs
      - Run via: Actions > Append Current Tabs to Another Session...
      - or Modifier+Click on a session name in Session Manager main menu (see below to assign modifier)
      Note: Appended tabs will only load paths (without custom column order or size)
+ New mouse modifier available when clicking on session: Append current tabs to clicked session
      Access in: Actions > Edit Mouse Modifiers (Used When Clicking on a Session Name)...
+++ New entry: Append Active Tab to Another Session (appended tab will be in the foreground and have a blue text)
      This will remember the active tab, load the chosen session,
      then append the tab (duplicate or not) to the active pane
      - Run via: Actions > Append Active Tab to Another Session...
      - or Modifier+Click {new Default Ctrl+Click} on a session name in Session Manager main menu (see below to assign modifier)
+ New mouse modifier available when clicking on session: Append active tab to clicked session
      Access in: Actions > Edit Mouse Modifiers (Used When Clicking on a Session Name)...
* Renamed previous entry: "Append Tabs of a Session" to "Append Another Session to Current Tabs"
* Append Another Session: Workaround to keep relative paths "?:\..." still relative (ie unresolved)
      Note: tab("new") seems to automatically resolve relative paths (eg. ?:\Folder > D:\Folder)
+ New entry: Actions > Remove Text Color of All Visible Tabs
      Just a quick way to remove the blue tab name text produced by the Append actions
* Append...: Current session not listed anymore as a session to append from
* More safety checks for append actions (incl. to prevent recursiveness, eg via Shift+Click on active session to append it to itself)
———————————————————————————
• 5 (~8) New commands for external access (Catalog, CKS, UDC...):
+ Save as new session
      global $DYN_inpSess = "Session Name"; load "SessionManager.xys", "_Save";
+ Delete specific session
      global $DYN_inpSess = "Session Name"; load "SessionManager.xys", "_Delete";
+ Append another session to current tabs (select session from list)
      load "SessionManager.xys", "_AppendFromAnotherSession";
            or with specific session
      global $DYN_inpSess = "Session Name"; load "SessionManager.xys", "_AppendFromAnotherSession";
+ Append current tabs to another session (from list)
      load "SessionManager.xys", "_AppendToAnotherSession";
            or with specific session
      global $DYN_inpSess = "Session Name"; load "SessionManager.xys", "_AppendToAnotherSession";
+ Append active tab to another session (from list)
      global $DYN_appendActiveTab = 1; load "SessionManager.xys", "_AppendToAnotherSession";
            or with specific session
      global $DYN_inpSess = "Session Name"; global $DYN_appendActiveTab = 1; load "SessionManager.xys", "_AppendToAnotherSession";
———————————————————————————
+ Script can now be used properly without a toolbar button {seemingly benigne but quite important code change}
* Changed default mouse modifiers on session: Ctrl: Append active tab to clicked session, Ctrl+Shift: Load only session content
* Adjusted display of both "Edit mouse modifiers" menus, based on font size (so columns remain aligned)
* Updated cheat sheet and clarified and reordered commands. Details in: Options > Help: Cheat Sheet
* Menu entries Actions > "Switch between...", and "Append..." now greyed out if only one session exists
! Fixed Session Manager not displaying its menu (since v7.50) when run via Catalog or XYplorer User>Run/Load


• CHANGELOG – all versions:
Don’t hesitate to browse the exhaustive changelog (with download links to previous versions) here: • Session Manager Changelog •

———————————————————————————

• TRANSLATORS:
 — New contributions are more than welcome!
 — please head to the dedicated post on the ML forum for the changelog and latest english language file
Last edited by FluxTorpedoe on 17 Sep 2024 12:38, edited 1 time in total.

Malarki
Posts: 208
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by Malarki »

Thanks again; I use this all the time.

Malarki
Posts: 208
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by Malarki »

... Except that the problem I mentioned on 23 June with v7.50 has somehow reappeared; of changing my XY toolbar CTB. v7.50 did that until I made the "Label" tweak you had recommended, which (as I recall) fixed both the non-appearance of the session list and the renaming of my CTB.

I run SM from a CTB that just launches the XY function of "Load Script File" via "#10;". Note that this is not the same as "Load Script File..." #753. SM is one of a half-dozen scripts I can choose from the resulting list that drops down. This version 7.80 of SM, when run, replaces that CTB icon with one which has icon text "< Tabsets >" and internal name "Session Manager [Ctrl: Switch - Alt: Reset - Shift: QuickSave - C+A: LayoutReset - A+S: LoadFavorite]".

This "Tabsets" CTB still has the assignment of #10 and opens my list of scripts but SM shouldn't do this.

Thanks!

FluxTorpedoe
Posts: 904
Joined: 05 Oct 2011 13:15

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by FluxTorpedoe »

Hi’
Malarki wrote: 18 Sep 2024 02:24 I run SM from a CTB that just launches the XY function of "Load Script File" via "#10;".
   Dang! I rewrote several parts of the code so that Session Manager could work without a toolbar button…
   But I didn’t realize / think of the case where it could still be run via a button, but not its own! :ninja:

   I figured a way which seems clean, try this.
   Line 3828, replace:

Code: Select all

if (isset($SM_CTBINDEX) && ($SM_CTBINDEX < 0) && (get("Trigger", "ctbindex") != -1)) {
   with

Code: Select all

if (!self("caption", -2) && isset($SM_CTBINDEX) && ($SM_CTBINDEX < 0) && (get("Trigger", "ctbindex") != -1)) {
   This should trigger the (new) dialog which detects that the button is missing, and asks if you want to fix this.
   (So, obviously, you press No ;) )

Malarki
Posts: 208
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by Malarki »

The replacement line does fix the toolbar button issue, on first use (only) popping the dialog you mention.

However, the script then errors out as shown in the attached screen shot. The programming is so far beyond me that I can't even guess what to change...

Thanks for the efforts on this.
Attachments
CAP_ 39168.jpg
CAP_ 39168.jpg (135.1 KiB) Viewed 8236 times

FluxTorpedoe
Posts: 904
Joined: 05 Oct 2011 13:15

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by FluxTorpedoe »

I don’t understand this, it looks like the script has been modified, eg the separator lines

Code: Select all

•••""".
should end with 3 double quotes, not with an

Code: Select all

••E"".
Maybe when you edited the script something went wrong…
Could you re-download the original and try again?

Malarki
Posts: 208
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by Malarki »

This is a surprise. I use Notepad++ almost stock though I have set it to save all files as UTF-8. I made the Session Manager line change with that editor. Now I see that NPP is changing hex codes at line ends eg. replacing 970D with 8145. Since these don't display the difference isn't visible.

I can't think why it hasn't been a problem before, but it is what caused the script to crash. I'll have to troubleshoot NPP separately.


So I made the Session Manager line change using Windows Notepad, and the script now executes. However, it first thing pops a note saying that it will add a toolbar button at the end of the bar. I don't want that so I did not press "Ok" but instead killed the window; but it added a button anyway with a name apparently derived from an open XY tab.

I'd like to be able to tell SM, on its first run, to forget about toolbar alterations.

Thanks!

Malarki
Posts: 208
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by Malarki »

Regarding the strange line breaks created in Notepad++... That editor has a lot of support for different encodings (code pages?) and languages; most of which is beyond me. I think that as a result, when left in UTF-8 encoding, it is over-interpreting some special characters in Session Manager.

The prime example I find is the separator line in SM created with hex '97' characters, followed by a hex 0D line feed. NPP seems to take the '970D' combination as a Japanese character and replaces the pair with '8145' which displays on US Windows as a backwards E. Saving the file from NPP locks in this damage (chiefly of the line feed being lost). This doesn't happen with lines ending in 0A 0D (CR-LF). It also doesn't happen if I enforce ANSI encoding in NPP, but then so many non-English characters become unreadable.

Below is a screenshot of the original SM script on the left, and as loaded into NPP and saved out, on the right, in a hex editor.

Just explaining this for info as I doubt the effects you need are easily achievable with regular ANSI characters.
sm script saved from npp noted.jpg
sm script saved from npp noted.jpg (671.5 KiB) Viewed 8193 times

FluxTorpedoe
Posts: 904
Joined: 05 Oct 2011 13:15

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by FluxTorpedoe »

I hesitated to mention the encoding in my reply, didn’t want to delve too deep, but there it goes:
The settings file "SessionManager.ini" is automatically encoded in UTF-8 (with BOM) to ensure maximum compatibility, but the script itself, "SessionManager.xys", is encoded in ANSI (Latin 1), for maximum compatibility too (else, there’s the other version available in UTF16LE with BOM).

What’s a bit weird is that it should be detected by Notepad++ (granted, I have a few misreadings sometimes in Akelpad too).

——————————————————
Malarki wrote: 18 Sep 2024 21:14So I made the Session Manager line change using Windows Notepad, and the script now executes. However, it first thing pops a note saying that it will add a toolbar button at the end of the bar. I don't want that so I did not press "Ok" but instead killed the window; but it added a button anyway with a name
Well, the dialog says "No valid Session Manager toolbar button found ---> Do you want to fix this now?",
So do not close it / kill the window (it will assume there’s a problem)!
Just press "No" (ie "I know there’s no button, I don’t want to fix this"), this way it won’t create a button —and it will remember your choice.

In your case, since a Session Manager button was already created, erase all its content and remove it from the toolbar, then run Session Manager and press "No" when it asks you the previous question —or run the Help > Maintenance Check... to force it to ask you the question again.

Tell me how things go. :)

autocart
Posts: 1356
Joined: 26 Sep 2013 15:22

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by autocart »

Just FYI:
Here (middle/western Europe), if I open your SessionManager.xys script in Notepad++ as downloaded, it auto-detects the encoding as Character Sets -> Japanese -> Shift-JIS.
Trying to change it to ANSI, UTF-8, UTF-8-BOM, UTF-16 BE BOM, or UTF-16 LE BOM seems to have no effect. Notepad++ keeps thinking that it is Shift-JIS and keeps displaying it as such.

Only when I change to, e.g. Character Sets -> Western European -> Windows-1252 and then do a save, it *seems* fine (untested in XY as of yet). Without the save, something still seems off when I type new characters on the keyboard.

UPDATE:
When I close and reopen, it is back to Shift-JIS. I need to add an extra step after changing char set and saving: Convert to UTF-8. Now, it seems fine. Emphasis still on *seems*. I'll keep observing.

UPDATE 2:
It seems to run ok, but the SessionManager layout tools menu does display strange characters instead of bullets (in the menu separators / headings).
My current solution (still in testing phase) is to first change to Winodws-1252 and convert to UTF-8, then make any edits that I want to make, then save and change it back to ANSI, then save again. And then run it in XY.
Last edited by autocart on 19 Sep 2024 17:54, edited 1 time in total.

Malarki
Posts: 208
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by Malarki »

Regarding the Session Manager v7.80 startup dialog -

In a "fresh::" XY instance, running v7.80 exactly as downloaded (not in and out of an editor), I get the pop-up shown below. I also get this with my customized XY where SM is chosen from a list via #10 Load Script File CTB. This is after deleting any previous .ini files.

Whether I choose OK or kill the window, this creates a new CTB with short visible name "tabsets".
xy fresh session mgr message.jpg
xy fresh session mgr message.jpg (92.66 KiB) Viewed 8144 times

FluxTorpedoe
Posts: 904
Joined: 05 Oct 2011 13:15

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by FluxTorpedoe »

@autocart & @malarki Thanks for the detailed feedback!

⮞ Regarding the encoding
I gathered some editors and made some tests, and indeed v7.80 displays a strange behavior. I confirm the detection as Shift-JIS in Notepad++, and 850 OEM in Akelpad. But in Editpad and EmEditor it’s correctly detected as 1252 / ANSI!
I figured out the problem which lies in the changelog at the beginning of the file, and comes from the separator lines ——— with em signs (I use them so often, didn’t realize they’re not "basic" after all).
FYI Session Manager v7.00 had this too and causes the same wrong detection in Notepad++ (but not in Akelpad!).

• Quick fix —only for those who need/want to edit SessionManager.xys v7.80 in Notepad++
Open the script in the regular Notepad.exe, remove the 3 ——— lines at the beginning, and save the file (renaming the extension as xys).

———————————————————————————

⮞ Regarding the button @malarki
Session Manager creates a toolbar button on first run (when there’s no INI), so that’s expected —but this unattended install should only happen once.
So in your case, keep your original INI file.
1 – If there’s already a Session Manager button, erase all its content and remove it from the toolbar.
2 – Run Session Manager via your custom button with #10
3a - If SM opens the dialog like in your last screenshot with only "OK", press OK (let it create the button) and restart from step 1
3b – The dialog should be "No valid Session Manager toolbar button found ---> Do you want to fix this now?", press "No"
⭢ no button will be created and your choice should be remembered

As mentioned before, if you change your mind or other settings in XYplorer, you can still force the script to recheck this status via Help > Maintenance Check..., which will ask you the question (in 3b) again.

Note on second thought: Permanent variables must be allowed, maybe check if you had disabled this setting in XYplorer.
Configuration > General > Refresh, Icons, History > Scripting: Remember permanent variables

Malarki
Posts: 208
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by Malarki »

Confirmed that removing the three separator lines near the beginning of the script eliminates the chance for Notepad++ to misinterpret them and silently change them.

As a side note, because of other characters used the script must be kept in ANSI, not converted to UTF-8. Fortunately, even if set to UTF-8 encoding for new files, NPP won't convert an existing ANSI file to UTF-8 unless told to do so on a per-file basis (it seems).

I also have Session Mgr running OK now after following your installation steps - basically letting it create a CTB then deleting that. Just FYI that on the first run, besides creating a new CTB it also changes the icon on the CTB for my #10 action.

So now it works just like it usta!

Thanks for all your attention to this and of course for this so-impressive and useful script.

FluxTorpedoe
Posts: 904
Joined: 05 Oct 2011 13:15

Re: Session Manager [v7.80]  —  Bookmark your environments: locations and/or display (tabsets and layout)

Post by FluxTorpedoe »

Glad to know it’s working for you now!
So in the next version, I’ll add the change~fix for "Session Manager launched from a button but not its own".
And (even if you shouldn’t need it anymore), i’ll slightly change the button creation on first run: if the script is launched "by an advanced user" (eg from another button), the YES/NO dialog will popup, instead of creating the button by default.

Well, I’ll wait for other things to add or change before posting it.

Have a nice day 8)
Flux

Post Reply