PowerShellFar - PowerShell host for Far Manager (English)

Here you can discuss about your favorite plug-in.
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

PowerShellFar - PowerShell host for Far Manager (English)

Post by NightRoman »

English speaking PowerShell users are welcome to use and discuss the PowerShellFar plugin
http://code.google.com/p/farnet/
User avatar
senpost
Posts: 53
Joined: Fri 27 Mar, 2009 03:54

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by senpost »

I am moving this http://forum.farmanager.com/viewtopic.php?f=41&t=5995 post from plug-in forum to here,

This is what I have in my mind for my new plugin "drill down search" in Far,

Goal of this plugin is to improve search experience in FAR, Things I dont like in current "FAR search" , and things I want to do in this new plugin.

1. No regular expression, With FarNet/PowerShellFar I can leverage .NETs RegEx engine.
2. While its searching I cannot do any other activity. I want to have result panel displays files that matches search and I should be able to view/edit files while search is going on the background.
Let me try to explain this by an example,

1. Select a folder/folders to search in active panel
2. Get all *.log files from selected folder(s) and list the files in a panel lets call it result panel for now. From result panel, I should be able to do all normal file operations like search, view, browse, edit, delete, rename etc...
3. From the result panel, Search files that has todays date. Clear result panel and place matching files in result panel.
4. From the result panel, filter files that have log entries from 4.00 pm to 10.00 pm
5. This is our final set of files, copy the filenames to clipboard

In powershell I would do this by placing the result for each step in a temp variable and drill down further. With PowerShellFar, I would like to add some GUI so my search can be more visual.

Please let me know how can I get started.

Thanks in advance.
"To us all towns are one, all men our kin"
Kanniyan Poongundran, Tamil Poet, 500 BC
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by NightRoman »

1. No regular expression, With FarNet/PowerShellFar I can leverage .NETs RegEx engine.
2. While its searching I cannot do any other activity. I want to have result panel displays files that matches search and I should be able to view/edit files while search is going on the background.
Take a look at the Search-Regex-.ps1 script in PowerShellFar. It searches for regular expressions (or substrings, if the pattern starts with *), shows results in the panel and does not block the main UI thread during search.

To get selected items in a panel use Get-FarPath cmdlet in PowerShellFar or take a look at its code if you want to do this in a C# module.

To copy text to the clipboard use $Far.CopyToClipboard method (in PSF) or Far.Net.CopyToClipboard (in C#).

As for the other details... it is your module, please write it yourself :) Everything from your list is possible and easy, but it is still some work to do and some stuff to learn. If you have particular technical questions, ask them one at a time.
User avatar
senpost
Posts: 53
Joined: Fri 27 Mar, 2009 03:54

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by senpost »

Thanks for the reply. I started looking into Search-Regex- script. I am tweaking and as well as learning.

How do you debug these scripts? What kind of dev setup you have?

Thanks
"To us all towns are one, all men our kin"
Kanniyan Poongundran, Tamil Poet, 500 BC
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by NightRoman »

How do you debug these scripts? What kind of dev setup you have?
No special dev setup is needed.

PSF host implements the standard PowerShell debugger. The typical debugging scenario is:
* Open a script in the editor
* Set a breakpoint (F11 \ PSF \ Debugger \ Line breakpoint) (or set a breakpoint yourself by Set-PSBreakpoint)
* Invoke the script as usual from the command line (use prefix >:) or just hit F5 in the editor
* When breakpoint is hit the debugger dialog opens
* F1, read help (or you may read the PowerShellFar.hlf help before).

Debugging may look unusual at first but it definitely works fine and helps to find problems. Suggestions are welcome but I am not planning to make the debugger much more advanced.
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by NightRoman »

senpost
Just in case. Do you use the Colorer plugin? If not then I would recommend to use it, it's a must have tool for a developer. And PSF includes the PowerShell syntax highlighting scheme PowerShellFar.hrc for PowerShell scripts. Use it, indeed.
User avatar
senpost
Posts: 53
Joined: Fri 27 Mar, 2009 03:54

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by senpost »

I tried it actually, Copied prototype segment from powershell.hrc to proto.hrc and Copied <hrd> element from RomanConsole.hrd to catelog-console.xml. Its not working. I must be doing something wrong. I havent spent time reading instructions on installing PS scheme for colorer.
"To us all towns are one, all men our kin"
Kanniyan Poongundran, Tamil Poet, 500 BC
User avatar
senpost
Posts: 53
Joined: Fri 27 Mar, 2009 03:54

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by senpost »

I saw your reply here http://stackoverflow.com/questions/4106 ... 45#4108245
Can I use VS 2010 to debug bench scripts? I have tried coping .config file but didnt work.
"To us all towns are one, all men our kin"
Kanniyan Poongundran, Tamil Poet, 500 BC
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by NightRoman »

senpost wrote:I tried it actually, Copied prototype segment from powershell.hrc to proto.hrc and Copied <hrd> element from RomanConsole.hrd to catelog-console.xml. Its not working. I must be doing something wrong. I havent spent time reading instructions on installing PS scheme for colorer.
You are doing something wrong, more likely. Can you show what exactly you copied?
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by NightRoman »

senpost wrote:I saw your reply here http://stackoverflow.com/questions/4106 ... 45#4108245
Can I use VS 2010 to debug bench scripts? I have tried coping .config file but didnt work.
No. Visual Studio basically has nothing to do with PS scripts, including debugging (unfortunately). My answer at StackOverflow is about debugging PS cmdlets with VS 2010. Cmdlets are just special classes in .NET dlls, that's it, it's about debugging .NET code (related to PS or not), not PS scripts.
User avatar
senpost
Posts: 53
Joined: Fri 27 Mar, 2009 03:54

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by senpost »

If the path contains space for example "c:\program files" PowerShellFar tab expansion is not working, Any thoughts?
"To us all towns are one, all men our kin"
Kanniyan Poongundran, Tamil Poet, 500 BC
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by NightRoman »

Yes, paths with spaces are not handled well by tab expansion. This limitation is known. So far I am not planning to fix it: a) it seems to be inconvenient not too often; b) making parsing more complex might be not quite reasonable. IMHO, indeed.

Tab expansion is implemented by the TabExpansion.ps1 script. You can try to improve it.

P.S. I'll think of it. But, you see, not many users complain, you are the first for several years.
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by NightRoman »

Not for excuse but for better understanding, a few words about some ambiguities. Tab expansion just thinks you are about to expand "Files" in your example, i.e. the last token in the incomplete command. Is it stupid? Maybe. But bot too much. There might be use cases when this behaviour is actually smart and does exactly what we want, i.e. "Files" actually exists and we are about to expand exactly it, not "Program Files".
User avatar
HaRT
Moderator
Posts: 9530
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 109 times
Been thanked: 229 times

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by HaRT »

NightRoman wrote:There might be use cases when this behaviour is actually smart and does exactly what we want, i.e. "Files" actually exists and we are about to expand exactly it, not "Program Files".
A solution might be to behave like the YAC plugin does, namely to honour the quotes:
C:\Program Files‹Tab› would try to complete “Files”
"C:\Program Files‹Tab› would try to complete “C:\Program Files” (please note the double quote in the beginning).
Фар есть инструмент, а не нянька. © 2009 DrKnS
User avatar
NightRoman
Posts: 5945
Joined: Fri 18 Aug, 2006 13:52
Location: Cambridge, UK
Has thanked: 14 times
Been thanked: 15 times
Contact:

Re: PowerShellFar - PowerShell host for Far Manager (English

Post by NightRoman »

Yes, in theory that would be ideal. I investigated this. Unfortunately (or fortunately), the PowerShell tab expansion is much more complicated that YAC and adding this feature without breaking the others leads to expensive extra parsing. Expected performance degradation and increased complexity due to this is not worth the benefits: the improved use case is rare, at the same time other cases should suffer all the time.
Post Reply

Return to “General Plug-In Discussions”