QuickSearch eXtended

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: sheep, Hacker, Stefan2, white

Post Reply
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo » 2009-05-30, 12:05 UTC

Maybe there could be a check box in the regular search that would enable this. That way you could disable it for regex.
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license

User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 » 2009-05-30, 12:26 UTC

Samuel wrote:I would like it and it seems like no big deal.

Im working on RegEx right now. But I think I need support from Mr. Ghisler for that. Currently when you would filter out all files with another letter, this letter is not written to the filter.

This gives problems using regex.
You cant write for example: "\d" because no file would match "". So you have to paste this string to Quicksearch.
It would be best if Christian sent all files every time, but if he doesn't, you can work around it by checking whether reg exp is correct. I believe that counting parentheses and checking for '\' at the end is enough.

User avatar
nsp
Power Member
Power Member
Posts: 1219
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp » 2009-05-30, 14:29 UTC

Samuel wrote:Anyone knows a good Regex lib for C++?
I know some C regex that can be compiled with wchar :
If you want very simple stuff, you can use T-Rex see here ! i C++ wrapper is available.

Thomas Lackner's port (from Tcl 8.5a3) of Henry Spencer library here ! you can include it or compile a separate dll.

for full c++

For big stuff you can use PCRE (google search) or Boost regex++....

With regex, 2 options are very useful to have :
A) Ignorecase/ case sensitive !
B) greedy/ non greedy match
Last edited by nsp on 2009-05-30, 15:00 UTC, edited 1 time in total.

j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j » 2009-05-30, 14:36 UTC

I can also recommend

http://www.codeproject.com/KB/library/deelx.aspx

which is easy to integrate and pure C++.
#84251

User avatar
Lefteous
Power Member
Power Member
Posts: 9457
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous » 2009-05-30, 15:07 UTC

I guess the best solution would be if TC could share it's library. This would make plugin amd extension development easier and also lead to a common regex syntax in TC.

2Samuel
Great work!
currently the Unicode string is converted to normal string, because I know normal strings better.
There is no need to fear Unicode strings :-)
The back and forth converting is more troublesome.

User avatar
Samuel
Power Member
Power Member
Posts: 1871
Joined: 2003-08-29, 15:44 UTC
Location: Brandenburg, Germany
Contact:

Post by *Samuel » 2009-05-30, 23:08 UTC

I first tried boost, an now I am using the very tiny deelx. Thx for the recommendations.

Source is available in first post. Regex is hard. Till now I didnt get it to work. I dont know whats the reason. If I use it from outside the dll, it just works fine. but in it it just gives trouble.

Here is the code:

Code: Select all

BOOL __stdcall MatchFileW(WCHAR* QSFilter,WCHAR* FileName)
{
// convert WCHAR* to wString
 wstring wsQSFilter(QSFilter);
 wstring wsFileName(FileName);

// convert to lowercase:
 transform(wsQSFilter.begin(),wsQSFilter.end(),wsQSFilter.begin(),tolower);
 transform(wsFileName.begin(),wsFileName.end(),wsFileName.begin(),tolower);

// remove asterisks "*" before and after the filter:
 if(wsQSFilter.substr(0,1)                    ==L"*") wsQSFilter.erase(0,1);
 if(wsQSFilter.substr(wsQSFilter.length()-1,1)==L"*") wsQSFilter.erase(wsQSFilter.length()-1,1);


// should a RegEx search be used?
 if(wsQSFilter.substr(0,1)==L"?"){
  wsQSFilter.erase(0,1);                                             // remove ? and add ".*" before and after search text
  wsQSFilter=L".*"+wsQSFilter+L".*";

// search with RegEx
  static CRegexpT <wchar_t> regexp(wsQSFilter.c_str(),wsQSFilter.length(),IGNORECASE);
  MatchResult result=regexp.Match(wsFileName.c_str());

  if(result.IsMatched()) return 1;
  else return 0;
 }

...
Can anyone find an error?

j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j » 2009-05-31, 02:04 UTC

The [face=courier]static[/face] in front of [face=courier]CRegexpT[/face] does not look like a good idea to me. Remove it and you should be fine...

User avatar
Samuel
Power Member
Power Member
Posts: 1871
Joined: 2003-08-29, 15:44 UTC
Location: Brandenburg, Germany
Contact:

Post by *Samuel » 2009-05-31, 08:06 UTC

Thanks Mr. J. Your my hero. That did it. (copied it from a function.)

And an inconvenience by TC. You have to enable both checkboxes from Configuration -> Quick Search -> exact name match to use RegEx. Otherwise asterisks are added before dots. (not just at the start and end of an expression.)

2ghisler (Author):
Could you please give the two options separately to the function. Please make it possible to have the unchanged string in the function without workarounds.

New tcmatch version with RegEx in first post.

2m^2: didnt you write something about strings some seconds ago?

User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 » 2009-05-31, 08:19 UTC

Samuel wrote:2m^2: didnt you write something about strings some seconds ago?
I did. But I got up just before this and missed important part of your code. My post made no sense here, so I deleted it.

User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo » 2009-05-31, 09:39 UTC

Can someone post a good example of using RegEx with this? I have not dealt with RegEx before.
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license

j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j » 2009-05-31, 10:23 UTC

Some examples:
[face=courier]\d\d[/face] => Files that contain two consecutive digits.
[face=courier]^w.*d$[/face] => Files that start with "w" and end with "d".
[face=courier][^x]y[/face] => files that contain an "y" but not "xy".

Use Google to find some more :-)

Just tried the plug-in and I saw a small problem:
You can not type [face=courier]^[[/face] to start an expression in a box bracket. I guess because it tries to match files with [face=courier][[/face] (or because it's an invalid expression) and does not let me continue to type. It would be good to filter a [face=courier][[/face] if it is the last character and does not have a \ before it, so you could still end an expression with [face=courier]\[[/face].

User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo » 2009-05-31, 10:31 UTC

Those only work in the regular search, right?
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license

j
Member
Member
Posts: 124
Joined: 2009-04-13, 19:49 UTC

Post by *j » 2009-05-31, 10:34 UTC

You have to start your search with a [face=courier]?[/face] in order to use regular expressions with Samuels plug-in. So [face=courier]?\d\d[/face] for example.

User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo » 2009-05-31, 10:38 UTC

Thank you for that. I was expecting to get nailed on that one. ;)

I take it that is a known thing?
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license

User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 » 2009-05-31, 11:11 UTC

I have several comments:
-Ini would be really useful. To enable reg exps by default, without '?'
-Sources. Can you change paths to relative ones?
-Bug: In reg exp mode, it doesn't accept space to make multiple searches. Example: "?h " in the main TC directory.

And a Ghisler's thing: inability to use arrows is REALLY annoying. I'm used to first write both parentheses, move cursor left and add content. I hate the current behaviour, I'd much much more welcome forcing me to dismiss the quick search dialog to be able to move the cursor horizontally than what is now. :roll:

Post Reply