The Return of the File Browser
- Details
- Written by Alexander Riedel
- Last Updated: 23 August 2019
- Created: 03 July 2019
- Hits: 6511
Back in the lost ages of pre-internet dawn, PrimalScript sported a File Manager panel which enabled users to quickly open, rename and copy files on their hard drive without having to switch to another application. Over the years this particular panel became less and less important as screen sizes increased, multi-monitor support became prevalent and Admins spent much more time in Windows File Explorer anyway.
Users started to complain that the panel inhabited too much screen space and that it also impacted startup speed – which was true since it did need to read your hard disk. The two-pane folder-file layout was basically akin to launching a full-fledged Windows Explorer instance.
As an experiment, we simply disabled the panel for a service build – lo and behold nobody noticed, or at least nobody complained. To be fair, one person complained many, many years later, questioning our judgement about removing this highly valuable feature.
So imagine our surprise when we started receiving emails about this "other editor" having this "most helpful" File Explorer panel and "why in the name of all that's holy would we not have something as useful as this in our products"?
We could have just shrugged, re-enabled the code, and the whole File Explorer panel would have been back – but of course that would have been lazy. We also did not want to simply copy what the old panel did and leave it at that – so we reviewed what our users wanted and created a brand new panel:
As you might expect from something called "File Browser" – it lists the files in your selected folder. It has many standard features that you would expect:
- A field to show you exactly where you are
- A button to navigate to other locations
- A history feature to enable you to switch between commonly used locations
- The ability to create a new folder
- The ability to create a new file. If you name the new file with a known extension, the associated template is pulled in automatically.
- A search box to scan for specific files and the associated buttons to go back and forth on the results.
- Double clicking on a file as expected will open that file in PrimalScript.
- Last but not least – a refresh button, and a collapse all nodes button.
The context menu for files has a few more standard functions you know from other parts of PrimalScript.
Most important here is the ability to run scripts directly without having to load them into the editor first.
The eagle-eyed among you have by now probably spotted the node indicators in front of some code files and wondered of what those might be. Let's expand some:
PrimalScript will parse the files in your selected folder in the background and list any contained classes, methods and functions within those files. This applies to all file types PrimalScript knows, not just PowerShell files.
So, what can you do with those? Let's try this:
You can quite simply double click on a function and PrimalScript will open the file and take you to the function's location. Right clicking and selecting "Open function location" does the some thing.
Once you right click you also see the "Copy function code to clipboard" menu item. Try it.
(Click on the image to see the higher resolution video)
It will copy the function directly from the file and put it in the Windows clipboard. You are now free to paste that code in your script wherever you like.
Of course you can also drag and drop the code directly to your script without the Windows clipboard detour.
(Click on the image to see the higher resolution video)
PrimalScript will not interfere if you drag and drop between languages, so if you want to drag and drop C# in your PowerShell script to convert it there, go ahead.
Last but not least, sometimes you just need the full path name of a file. Dragging and dropping the file will drop the full path.
(Click on the image to see the higher resolution video)
If it is a PowerShell file you are dropping, it is enclosed in quotes and dot sourced.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.