Page 1 of 3

Folder Pane Preview

Posted: 26 Sep 2017 22:23
by bdeshi
This lets you select a folder in the first pane, and preview its contents on the second pane.
FPP_demo.gif
(Born out of this discussion)
Once started it keeps running in the background to continuously sync the preview pane to the current folder selection. Run it again to toggle off.
  • FEATURES
  • Dedicated Icon!Image
  • auto-updating preview.
  • Customizable preview tab.
  • You should get a "readme" followed by the config on the first run.
  • The preview always opens on the second (right/bottom) pane.
  • =========
    INSTALL
    =========
  • Loading the script by itself shows a menu with preview and config choices. But of course you can also start preview and config directly.
  • Outside of CTB and UDC (eg, from catalog, other scripts, address bar, regular load, etc), you can call the script very easily:
    • Show menu

      Code: Select all

      ::load 'folder-pane-preview.xys';
    • Toggle Preview

      Code: Select all

      ::global $FPP_Do_Preview = 1; load 'folder-pane-preview.xys';
    • Open Config

      Code: Select all

      ::global $FPP_Do_Config = 1; load 'folder-pane-preview.xys';
  • However, due to the script's fighting with certain technical limitations of the scripting engine, associating with CTB and UDC may be a little involved.
  • UDC/CTB Integration Scripts:
    • Use these for CTB Left/Right-click scripts and UDC Run Scripts.
    • Show menu

      Code: Select all

      $s='folder-pane-preview.xys'; run """%ComSpec%"" /c """"<xy>"" /script=""::load '$s';"" /flg=2 /hwnd=<hwnd>""""",,0,0;
      [/size]
    • Toggle Preview

      Code: Select all

      $s='folder-pane-preview.xys'; $f='$FPP_Do_Preview'; run """%ComSpec%"" /c """"<xy>"" /script=""::global $f=1;load '$s';"" /flg=2 /hwnd=<hwnd>""""",,0,0;
      [/size]
    • "Open Config"

      Code: Select all

      $s='folder-pane-preview.xys'; $f='$FPP_Do_Config'; run """%ComSpec%"" /c """"<xy>"" /script=""::global $f=1;load '$s';"" /flg=2 /hwnd=<hwnd>""""",,0,0;
      [/size]
    • Now you can create a CTB using these as left-click and right-click scripts.
      Here's an example where, Click = preview, SHIFT+Click = config.

      Code: Select all

      $s='folder-pane-preview.xys'; $f='$FPP_Do_'.(get('shift')==1?'Config':'Preview'); run """<xy>"" /script=""::global $f=1;load '$s';"" /flg=2 /hwnd=<hwnd>";
      (In all of these scripts $s should point to the location of folder-pane-preview.xys.)
  • Stopping the preview
    Once started, the script stays running in the background. There are many ways to stop.
    • Simply run the preview again. This works as a toggle.
    • Switch panes. Depending on config, the preview pane may stay, but the script will stop.
    • Disable Dual Panes.
    • Switch tabs may also work, depending on config.
    • Press Esc.
    • The script also stops whenever XY executes an end 1,,0; statement.
  • And a final note, since the script may get called often while already running, you might get warnings regarding recursive script execution. To turn this off (it is quite safe) set `ScriptRecursionWarningOff=1` in XYplorer configuration file.
(Thanks to klownboy for lots of testing and suggestions.)

Hope you find this useful. Let me know about any bugs or improvements.

Re: Folder Pane Preview

Posted: 27 Sep 2017 14:03
by klownboy
Hi Sammay, very impressive script. Great job in figuring out how to get a true toggle working. :appl:

One issue I noticed in working with this new version 1.2 is that the use of /flg=2 /hwnd=<hwnd> also brings an hourglass cursor for a number of seconds after use. We discovered on some others scripts of few years ago that if you ran it through the command line with cmd /c you eliminate the annoying hourglass. Have you noticed it? It doesn't stop anything from happening; it's just a bit annoying. I believe the issue may have been brought to Don's attention but he's got bigger fish to fry and it still exist.

Try using the following as the normal left click command of a CTB. It seems to be just as fast and you don't get the hourglass.

Code: Select all

$s='D:\Tools\XYplorer\Scripts\folder-pane-preview.xys'; $f='$FPP_Do_Preview'; run "cmd /c <xy> /script=""::global $f=1;load '$s';"" /flg=2 /hwnd=<hwnd>", , 0,0;
You need , , 0,0; to eliminate the wait and hide the command box. An old example of its use is here viewtopic.php?f=7&t=10272&start=90#p135193

As much as I like your script, I'm still hoping Don will incorporate this idea. :)

Thanks again,
Ken

Re: Folder Pane Preview

Posted: 27 Sep 2017 15:07
by bdeshi
Did not know that. Nice tip! I added a bazillion more quotes, to handle spaced paths. (Changed the post body only. Don't think it warrants updating the script.)

Re: Folder Pane Preview

Posted: 27 Sep 2017 18:28
by klownboy
Hi again Sammay. Would it make sense to have the capability for a user to have the means to load a specific layout on the start of the preview? I ask because I typically use one pane, but when I go into dual pane mode I usually have horizontal panes. For this script and viewing the preview pane, it makes more sense to do it with a vertical panes sized the way it want it - similar to what you show in the gif. That I can easily do with a layout change. Or, actually I could probably just get away with invoking CID #801 to toggle horizontal vs. vertical panes. I did put #801; in the left click commands of a CTB and it worked fine though I may try a loadlayout to tighten up the pane. It does revert back to my normal horizontal pane when done...which is good.

I have not been able to get "shift " working (to get to configuration screen in a UDC script) on version 1.2 or version previous to that. I assume it must work for you. Unless something is interfering. I use get shift in other scripts with no issues but mostly menus.

Re: Folder Pane Preview

Posted: 27 Sep 2017 18:51
by bdeshi
"load layout" - Sure. (In fact, I believe it will be a nice effect if the preview pane's width automatically extends, and shrinks back afterwards.)
However, at the outset I'm not very keen to automatically toggle between vertical and horizontal splits. (A conditional #801 in the calling script can do nicely for now.)

"get('shift')" - Works fine for me. You see in the UDC script this is completely independent of the FPP script proper. (Perhaps hold SHIFT longer?)

btw, there's a msgbox if you start preview from the 2nd pane. Do you think it might be distracting?

Re: Folder Pane Preview

Posted: 27 Sep 2017 22:06
by klownboy
I've saved a new layout and load it via the CTB "On left click" command box...

Code: Select all

$s='folder-pane-preview.xys'; $f='$FPP_Do_Preview'; run """%ComSpec%"" /c """"<xy>"" /script=""::global $f=1;loadlayout('Dual Vertical Panes');load '$s';"" /flg=2 /hwnd=<hwnd>""""",,0,0;
Since the layouts include the horizontal vs vertical pane setting, it works great.

Edit: Duh! :oops: Sorry, no I hadn't tested getting out of the preview. The above doesn't work coming out of preview which make sense obviously since it's calling the same layout again. Using CID #801 worked fine 'for me' since I'm returning to a horizontal panes, but I'll have to figure something else for layout so it's not invoked when coming out of preview. Sammay, can I use one of your existing variables to check if it's already in preview, so I don't 'loadlayout' coming out of preview?

I've noticed the message coming up a few times when starting in the 2nd Pane. Personally I could do without the message box. I think if it was mentioned in the write-up information it should be fine enough.

I'm not sure why the shift doesn't work for the UDC. I've tried a few different keys and none work. Which key do you have it assigned to?

Re: Folder Pane Preview

Posted: 28 Sep 2017 04:14
by pleiades
this is like the miller column :tup: can it do subfolders?

Re: Folder Pane Preview

Posted: 28 Sep 2017 05:57
by bdeshi
pleiades wrote:this is like the miller column :tup: can it do subfolders?
How do you mean? You can preview subfolders of the current path in 1st pane. Of course you can navigate up/down in this pane to preview subfolders in other levels.
klownboy wrote:Sammay, can I use one of your existing variables to check if it's already in preview, so I don't 'loadlayout' coming out of preview?
Sure, why not? The global variables with $FPP_ prefix will not be renamed in later versions, so you can use these.
I am going to add another input box[es] in the config to enter the effective layout for preview, and the script will switch back to last layout on exit.

About the UDC SHIFT: I was clicking the UDC menu item by mouse, with SHIFT pressed. If you have a shortcut assigned, and add SHIFT to it, then the shortcut itself gets changed and the UDC doesn't get triggered. Is this the case? (Maybe the example UDC script in my post is better suited for something else, like catalog.)

Re: Folder Pane Preview

Posted: 28 Sep 2017 11:51
by klownboy
Hey Sammay, concerning the layout and vertical panes, I ended up using your Perm variable $P_FOLDERPANEPREVIEW_RUNNING in the CTB calling script which seemed to make sense since it only there when the preview is ON.

Code: Select all

$s='D:\Tools\XYplorer\Scripts\folder-pane-preview.xys'; $f='$FPP_Do_Preview'; run """%ComSpec%"" /c """"<xy>"" /script=""::global $f=1;if !($P_FOLDERPANEPREVIEW_RUNNING) {loadlayout('Dual Vertical Panes')};load '$s';"" /flg=2 /hwnd=<hwnd>""""",,0,0;
However since your existing script itself remembers dual pane status, it ends up reverting back to my vertical pane and not what I had originally before hitting the CTB, which is single pane with a horizontal panes set. So coming out of preview is a problem and whatever I do in the calling script will be fighting against the script itself. I could put additional commands in the calling script to take care of it, but I'd probably end up with some pane flickering due to unnecessary pane changes. It sounds like you're taking care of it with an update you mentioned.

Concerning the UDC, yes, I was assigning a keyboard shortcut. I never even tried it from the UDC menu and yes it does work from there. Honestly I don't really care about other means of getting access to the Configuration menu. Having access to it from the UDC menu or from a CTB right click is more than sufficient. Thanks again.

Re: Folder Pane Preview

Posted: 28 Sep 2017 14:36
by bdeshi
klownboy wrote:It sounds like you're taking care of it with an update you mentioned.
Yup. Although I've found some could-be-bugs of setlayout() in my notes. We'll see how it turns out.

Re: Folder Pane Preview

Posted: 28 Sep 2017 17:32
by CompSystems
idea, if the current panel does not contain subfolders then the right panel does not display anything

Re: Folder Pane Preview

Posted: 28 Sep 2017 17:54
by bdeshi
you can't have a tab without a location.

Re: Folder Pane Preview

Posted: 28 Sep 2017 17:56
by klownboy
Hi Sammay, for this update are you planning on using SC setlayout as opposed to SC loadlayout? Loadlayout would be nice for users that have them, but I can see why you might have to use setlayout to accommodate those that do not have them or use them and to make it scriptable. I can live with either though.

Re: Folder Pane Preview

Posted: 28 Sep 2017 18:16
by bdeshi
I decided against loadlayout.
fpp-layouter.png
Preview H/W can be either a pixel or a percentage. In the same input box you can define both height and width separately for either split modes. When pane split is vertical, pane width will be shown and edited, and so on for horizontal. If this is too difficult, I'll just add separate inputs for H and W and make only one editable based on picked split mode. Of course, I'm also planning for an option to revert to last state.

Re: Folder Pane Preview

Posted: 30 Sep 2017 06:44
by pleiades
Hi SammaySarkar, I have an idea, if the current folder has a subfolder inside it then it will show it on another tab?

Example if the current folder has a subfolder and the subfolder has a sub-subfolder

Current Folder
---> Subfolder
--- Sub-Subfolder

If you click the current folder, it will open 2 preview tabs. If it has another sub-sub-subfolder, it will open 3 preview tabs, Something like that but maybe limit it to 5 or 10 because it will crash or something.