ADD: Support of multiply file mask (for example - *.txt;*.ini)

This commit is contained in:
Alexander Koblov 2007-12-21 20:06:50 +00:00
commit c5f8a9285e
6 changed files with 88 additions and 167 deletions

View file

@ -27,6 +27,8 @@ object frmConfigToolBar: TfrmConfigToolBar
ParentColor = False
end
object lblCommand: TLabel
AnchorSideTop.Control = cbCommand
AnchorSideTop.Side = asrCenter
Left = 4
Height = 14
Top = 98
@ -40,33 +42,39 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = -5
Height = 2
Top = 83
Top = 87
Width = 590
AutoSize = False
BorderSpacing.Top = 8
BorderSpacing.Top = 12
Color = clWindowFrame
ParentColor = False
Transparent = False
end
object lblParameters: TLabel
AnchorSideTop.Control = kedtParams
AnchorSideTop.Side = asrCenter
Left = 4
Height = 14
Top = 120
Top = 125
Width = 60
Caption = '&Parameters:'
FocusControl = kedtParams
ParentColor = False
end
object lblStartPath: TLabel
AnchorSideTop.Control = kedtStartPath
AnchorSideTop.Side = asrCenter
Left = 4
Height = 14
Top = 147
Top = 148
Width = 54
Caption = '&Start path:'
FocusControl = kedtStartPath
ParentColor = False
end
object lblIconFile: TLabel
AnchorSideTop.Control = kedtIconFileName
AnchorSideTop.Side = asrCenter
Left = 4
Height = 14
Top = 171
@ -76,18 +84,22 @@ object frmConfigToolBar: TfrmConfigToolBar
ParentColor = False
end
object lblIcon: TLabel
AnchorSideTop.Control = sbIconExample
AnchorSideTop.Side = asrCenter
Left = 4
Height = 14
Top = 197
Top = 207
Width = 26
Caption = 'Ic&on:'
ParentColor = False
WordWrap = True
end
object lblToolTip: TLabel
AnchorSideTop.Control = kedtToolTip
AnchorSideTop.Side = asrCenter
Left = 4
Height = 14
Top = 238
Top = 242
Width = 37
Caption = '&Tooltip:'
FocusControl = kedtToolTip
@ -98,7 +110,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = 120
Height = 38
Top = 194
Top = 195
Width = 38
BorderSpacing.Top = 6
Color = clBtnFace
@ -107,6 +119,8 @@ object frmConfigToolBar: TfrmConfigToolBar
object btnOpenBarFile: TButton
AnchorSideLeft.Control = stToolBarFileName
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = stToolBarFileName
AnchorSideTop.Side = asrCenter
Left = 425
Height = 21
Top = 2
@ -120,8 +134,8 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Control = btnAddButton
AnchorSideTop.Side = asrBottom
Left = 4
Height = 23
Top = 52
Height = 28
Top = 57
Width = 77
BorderSpacing.Top = 6
BorderSpacing.InnerBorder = 4
@ -133,7 +147,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Control = lblButtonBar
AnchorSideTop.Side = asrBottom
Left = 4
Height = 23
Height = 28
Top = 23
Width = 77
BorderSpacing.Top = 6
@ -147,7 +161,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = 120
Height = 21
Top = 91
Top = 95
Width = 298
AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending]
BorderSpacing.Top = 6
@ -160,10 +174,13 @@ object frmConfigToolBar: TfrmConfigToolBar
TabOrder = 4
end
object btnOpenFile: TButton
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = cbCommand
AnchorSideTop.Side = asrCenter
Left = 419
Height = 21
Top = 91
Width = 24
Top = 95
Width = 26
BorderSpacing.InnerBorder = 4
Caption = '>>'
OnClick = btnOpenFileClick
@ -174,8 +191,8 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Control = lblLabel
AnchorSideTop.Side = asrBottom
Left = 455
Height = 23
Top = 91
Height = 28
Top = 95
Width = 109
BorderSpacing.Top = 6
BorderSpacing.Bottom = 21
@ -188,7 +205,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = 120
Height = 21
Top = 118
Top = 122
Width = 298
BorderSpacing.Top = 6
Font.Height = -11
@ -201,7 +218,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = 120
Height = 21
Top = 140
Top = 145
Width = 298
BorderSpacing.Top = 6
Font.Height = -11
@ -214,7 +231,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = 120
Height = 21
Top = 167
Top = 168
Width = 298
BorderSpacing.Top = 6
Font.Height = -11
@ -225,9 +242,11 @@ object frmConfigToolBar: TfrmConfigToolBar
object btnOpenIconFile: TButton
AnchorSideLeft.Control = kedtIconFileName
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = kedtIconFileName
AnchorSideTop.Side = asrCenter
Left = 418
Height = 21
Top = 167
Top = 168
Width = 26
BorderSpacing.InnerBorder = 4
Caption = '>>'
@ -239,7 +258,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = 120
Height = 21
Top = 238
Top = 239
Width = 298
BorderSpacing.Top = 6
Font.Height = -11
@ -286,15 +305,18 @@ object frmConfigToolBar: TfrmConfigToolBar
end
object gbGroupBox: TGroupBox
Left = 455
Height = 82
Height = 84
Width = 121
Caption = 'Appearance'
ClientHeight = 64
ClientHeight = 66
ClientWidth = 117
TabOrder = 3
object lblSize: TLabel
AnchorSideTop.Control = kedtBarSize
AnchorSideTop.Side = asrCenter
Left = 6
Height = 14
Top = 3
Width = 55
AutoSize = False
Caption = 'S&ize:'
@ -314,7 +336,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 22
Top = 25
Width = 71
BorderSpacing.Top = 8
Caption = 'F&lat icons'
@ -328,7 +350,7 @@ object frmConfigToolBar: TfrmConfigToolBar
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 45
Top = 48
Width = 79
BorderSpacing.Top = 4
Caption = 'S&mall icons'
@ -366,7 +388,6 @@ object frmConfigToolBar: TfrmConfigToolBar
BorderStyle = sbsSunken
end
object OpenDialog: TOpenDialog
Title = 'Îòêðûòü ñóùåñòâóþùèé ôàéë'
FilterIndex = 0
left = 496
top = 120

View file

@ -1,12 +1,23 @@
{
Double Commander
----------------------------
Configuration Toolbar
Double Commander
-------------------------------------------------------------------------
Configuration Toolbar
Licence : GNU GPL v 2.0
Author : Alexander Koblov (Alexx2000@mail.ru)
Copyright (C) 2006-2007 Koblov Alexander (Alexx2000@mail.ru)
contributors:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit fConfigToolBar;

View file

@ -1,15 +1,14 @@
{
Double Commander
----------------------------
Licence : GNU GPL v 2.0
Author : Alexander Koblov (Alexx2000@mail.ru)
Double Commander
----------------------------
Licence : GNU GPL v 2.0
Author : Alexander Koblov (Alexx2000@mail.ru)
Several useful functions
Several useful functions
contributors:
Radek Cervinka <radek.cervinka@centrum.cz>
Part of this code based on code from http://www.delphirus.com.ru
contributors:
Radek Cervinka <radek.cervinka@centrum.cz>
}
@ -29,12 +28,10 @@ function GetDirs (DirName : String; var Dirs : TStringList) : Longint;
function GetAbsoluteFileName(sPath, sRelativeFileName : String) : String;
function ExtractOnlyFileName(const FileName: string): string;
procedure Split(const sFileNameWithParams : String; var sFileName, sParams : String);
Function cnvFormatFileSize(iSize:Int64):String;
Function MinimizeFilePath(const PathToMince: String; Canvas: TCanvas;
function cnvFormatFileSize(iSize:Int64):String;
function MinimizeFilePath(const PathToMince: String; Canvas: TCanvas;
MaxLen: Integer): String;
function CharPos(C: Char; const S: string; StartPos: Integer = 1): Integer; overload;
function G_ValidateWildText(const S, Mask: string; bCaseSens : Boolean = False; MaskChar: Char = '?';
WildCard: Char = '*'): Boolean;
function CharPos(C: Char; const S: string; StartPos: Integer = 1): Integer;
procedure DivFileName(const sFileName:String; var n,e:String);
implementation
@ -170,7 +167,7 @@ begin
sParams := Copy(sFileNameWithParams, iSpacePos + 1, iLength - iSpacePos);
end;
Function cnvFormatFileSize(iSize:Int64):String;
function cnvFormatFileSize(iSize:Int64):String;
var
d:double;
begin
@ -198,9 +195,13 @@ begin
end;
end;
{
This function based on code from http://www.delphirus.com.ru
}
{=========================================================}
Function MinimizeFilePath(const PathToMince: String; Canvas: TCanvas;
function MinimizeFilePath(const PathToMince: String; Canvas: TCanvas;
MaxLen: Integer): String;
{=========================================================}
// "C:\Program Files\Delphi\DDropTargetDemo\main.pas"
@ -293,7 +294,7 @@ begin
end;
function CharPos(C: Char; const S: string; StartPos: Integer = 1): Integer; overload;
function CharPos(C: Char; const S: string; StartPos: Integer = 1): Integer;
var
sNewStr : String;
begin
@ -308,117 +309,5 @@ else
Result := Pos(C, S);
end;
{
This function based on G_ValidateWildText from AcedUtils
http://acedutils.narod.ru/AcedUtils.zip
}
function G_ValidateWildText(const S, Mask: string; bCaseSens : Boolean = False; MaskChar: Char = '?';
WildCard: Char = '*'): Boolean;
label
99;
var
L, X, X0, Q: Integer;
P, P1, B: PChar;
C: Char;
sUpperS,
sUpperMask : String;
begin
if not bCaseSens then
begin
sUpperS := UpperCase(S);
sUpperMask := UpperCase(Mask);
end
else
begin
sUpperS := S;
sUpperMask := Mask;
end;
X := Pos(WildCard, sUpperMask);
Result := False;
if X = 0 then
begin
L := Length(sUpperMask);
if (L > 0) and (L = Length(sUpperS)) then
begin
P := Pointer(sUpperS);
B := Pointer(sUpperMask);
repeat
C := B^;
if (C <> MaskChar) and (C <> P^) then
Exit;
Dec(L);
Inc(B);
Inc(P);
until L = 0;
Result := True;
end;
Exit;
end;
L := Length(sUpperS);
P := Pointer(sUpperS);
B := Pointer(sUpperMask);
Q := X - 1;
if L < Q then
Exit;
while Q > 0 do
begin
C := B^;
if (C <> MaskChar) and (C <> P^) then
Exit;
Dec(Q);
Inc(B);
Inc(P);
end;
Dec(L, X - 1);
repeat
X0 := X;
P1 := P;
while sUpperMask[X0] = WildCard do
Inc(X0);
X := CharPos(WildCard, sUpperMask, X0);
if X = 0 then
Break;
99:
P := P1;
B := @sUpperMask[X0];
Q := X - X0;
if L < Q then
Exit;
while Q > 0 do
begin
C := B^;
if (C <> MaskChar) and (C <> P^) then
begin
Inc(P1);
Dec(L);
goto 99;
end;
Dec(Q);
Inc(B);
Inc(P);
end;
Dec(L, X - X0);
until False;
X := Length(sUpperMask);
if L >= X - X0 + 1 then
begin
P := Pointer(sUpperS);
Inc(P, Length(sUpperS) - 1);
while X >= X0 do
begin
C := sUpperMask[X];
if (C <> MaskChar) and (C <> P^) then
Exit;
Dec(X);
Dec(P);
end;
Result := True;
end;
end;
end.

View file

@ -101,7 +101,7 @@ type
implementation
uses
SysUtils, uFileOp, uGlobs, uVFSutil,
SysUtils, Masks, uFileOp, uGlobs, uVFSutil,
uShowMsg, Controls, uLng, uShowForm, uVFSmodule, uDCUtils,
uOSUtils;
@ -575,7 +575,7 @@ begin
begin
frp:=fFileList.GetItem(i);
if (frp^.sName='..') then Continue;
if G_ValidateWildText(frp^.sName, sMask) then
if MatchesMaskList(frp^.sName, sMask) then
frp^.bSelected := bSelect;
end;
end;

View file

@ -117,7 +117,7 @@ TFindThread = class(TThread)
implementation
uses
Dialogs, uLng, uFindMmap, uFindEx, uGlobs;
Dialogs, Masks, uLng, uFindMmap, uFindEx, uGlobs;
{ TFindThread }
@ -309,7 +309,7 @@ begin
{$IFDEF WIN32}
(* This is hack *)
//WriteLN('File = ', sr.Name);
if not G_ValidateWildText(sr.Name, FFileMask) then
if not MatchesMaskList(sr.Name, FFileMask) then
begin
Result := False;
Exit;

View file

@ -122,7 +122,7 @@ Type
function IsBlocked : Boolean;
implementation
uses Forms, SysUtils, uFileOp, uOSUtils, LCLProc, uFileProcs, uDCUtils, uLng, Controls;
uses Forms, SysUtils, Masks, uFileOp, uOSUtils, LCLProc, uFileProcs, uDCUtils, uLng, Controls;
var
WCXModule : TWCXModule; // used in ProcessDataProc
@ -609,7 +609,7 @@ procedure TWCXModule.CopySelectedWithSubFolders(var flist:TFileList);
if (FFileMask <> '*.*') and (FFileMask <> '*') and
not FPS_ISDIR(PHeaderData(FArcFileList.Items[I])^.FileAttr) and
not(G_ValidateWildText(CurrFileName, FFileMask)) then
not(MatchesMaskList(CurrFileName, FFileMask)) then
Continue;
// DebugLN('In folder = ' + CurrFileName);
@ -655,7 +655,7 @@ begin
if fri.sName[1] = PathDelim then
Delete(fri.sName, 1, 1);
if (FFileMask <> '*.*') and (FFileMask <> '*') and not(G_ValidateWildText(fri.sName, FFileMask) or FPS_ISDIR(fri.iMode)) then
if (FFileMask <> '*.*') and (FFileMask <> '*') and not(MatchesMaskList(fri.sName, FFileMask) or FPS_ISDIR(fri.iMode)) then
Continue;