mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 20:49:23 +02:00
+ test code for regexpr use in find dialog
This commit is contained in:
parent
6f56bc2312
commit
189e270fe9
@ -97,6 +97,7 @@
|
|||||||
{$define Undo}
|
{$define Undo}
|
||||||
{$ifdef DEBUG}
|
{$ifdef DEBUG}
|
||||||
{$define DebugUndo}
|
{$define DebugUndo}
|
||||||
|
{$define TEST_REGEXP}
|
||||||
{ Use this to incorporate a call to
|
{ Use this to incorporate a call to
|
||||||
external compiler.
|
external compiler.
|
||||||
Parsing of compiler output is done,
|
Parsing of compiler output is done,
|
||||||
|
@ -140,6 +140,10 @@ const
|
|||||||
ffFromCursor = $0000;
|
ffFromCursor = $0000;
|
||||||
ffEntireScope = $0020;
|
ffEntireScope = $0020;
|
||||||
|
|
||||||
|
{$ifdef TEST_REGEXP}
|
||||||
|
ffUseRegExp = $0040;
|
||||||
|
{$endif TEST_REGEXP}
|
||||||
|
|
||||||
coTextColor = 0;
|
coTextColor = 0;
|
||||||
coWhiteSpaceColor = 1;
|
coWhiteSpaceColor = 1;
|
||||||
coCommentColor = 2;
|
coCommentColor = 2;
|
||||||
@ -747,6 +751,9 @@ uses
|
|||||||
{$ifdef WinClipSupported}
|
{$ifdef WinClipSupported}
|
||||||
Strings,WinClip,
|
Strings,WinClip,
|
||||||
{$endif WinClipSupported}
|
{$endif WinClipSupported}
|
||||||
|
{$ifdef TEST_REGEXP}
|
||||||
|
regexpr,
|
||||||
|
{$endif TEST_REGEXP}
|
||||||
WConsts,WViews,WCEdit;
|
WConsts,WViews,WCEdit;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -5922,6 +5929,13 @@ var S: string;
|
|||||||
Count: sw_integer;
|
Count: sw_integer;
|
||||||
Found,CanExit: boolean;
|
Found,CanExit: boolean;
|
||||||
SForward,DoReplace,DoReplaceAll: boolean;
|
SForward,DoReplace,DoReplaceAll: boolean;
|
||||||
|
{$ifdef TEST_REGEXP}
|
||||||
|
UseRegExp : boolean;
|
||||||
|
RegExpEngine : TRegExprEngine;
|
||||||
|
RegExpFlags : tregexprflags;
|
||||||
|
regexpindex,regexplen : longint;
|
||||||
|
findstrpchar : pchar;
|
||||||
|
{$endif TEST_REGEXP}
|
||||||
LeftOK,RightOK: boolean;
|
LeftOK,RightOK: boolean;
|
||||||
FoundCount: sw_integer;
|
FoundCount: sw_integer;
|
||||||
A,B: TPoint;
|
A,B: TPoint;
|
||||||
@ -5984,6 +5998,20 @@ begin
|
|||||||
DoReplace:=(FindFlags and ffDoReplace)<>0;
|
DoReplace:=(FindFlags and ffDoReplace)<>0;
|
||||||
Confirm:=(FindFlags and ffPromptOnReplace)<>0;
|
Confirm:=(FindFlags and ffPromptOnReplace)<>0;
|
||||||
DoReplaceAll:=(FindFlags and ffReplaceAll)<>0;
|
DoReplaceAll:=(FindFlags and ffReplaceAll)<>0;
|
||||||
|
{$ifdef TEST_REGEXP}
|
||||||
|
UseRegExp:=(FindFlags and ffUseRegExp)<>0;
|
||||||
|
if UseRegExp then
|
||||||
|
begin
|
||||||
|
if FindFlags and ffCaseSensitive<>0 then
|
||||||
|
RegExpFlags:=[ref_caseinsensitive]
|
||||||
|
else
|
||||||
|
RegExpFlags:=[];
|
||||||
|
getmem(findstrpchar,length(findstr)+1);
|
||||||
|
strpcopy(findstrpchar,findstr);
|
||||||
|
RegExpEngine:=GenerateRegExprEngine(findstrpchar,RegExpFlags);
|
||||||
|
strdispose(findstrpchar);
|
||||||
|
end;
|
||||||
|
{$endif TEST_REGEXP}
|
||||||
Count:=GetLineCount;
|
Count:=GetLineCount;
|
||||||
FoundCount:=0;
|
FoundCount:=0;
|
||||||
{ Empty file ? }
|
{ Empty file ? }
|
||||||
@ -6053,14 +6081,32 @@ begin
|
|||||||
repeat
|
repeat
|
||||||
CurDY:=DY;
|
CurDY:=DY;
|
||||||
S:=GetDisplayText(Y);
|
S:=GetDisplayText(Y);
|
||||||
P:=ContainsText(FindStr,S,X+1);
|
{$ifdef TEST_REGEXP}
|
||||||
Found:=P<>0;
|
if UseRegExp then
|
||||||
|
begin
|
||||||
|
getmem(findstrpchar,length(Copy(S,X+1,high(S)))+1);
|
||||||
|
strpcopy(findstrpchar,Copy(S,X+1,high(S)));
|
||||||
|
Found:=RegExprPos(RegExpEngine,findstrpchar,regexpindex,regexplen);
|
||||||
|
strdispose(findstrpchar);
|
||||||
|
P:=regexpindex;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
{$endif TEST_REGEXP}
|
||||||
|
begin
|
||||||
|
P:=ContainsText(FindStr,S,X+1);
|
||||||
|
Found:=P<>0;
|
||||||
|
end;
|
||||||
if Found then
|
if Found then
|
||||||
begin
|
begin
|
||||||
A.X:=P-1;
|
A.X:=P-1;
|
||||||
A.Y:=Y;
|
A.Y:=Y;
|
||||||
B.Y:=Y;
|
B.Y:=Y;
|
||||||
B.X:=A.X+length(FindStr);
|
{$ifdef TEST_REGEXP}
|
||||||
|
if UseRegExp then
|
||||||
|
B.X:=A.X+regexplen
|
||||||
|
else
|
||||||
|
{$endif TEST_REGEXP}
|
||||||
|
B.X:=A.X+length(FindStr);
|
||||||
end;
|
end;
|
||||||
Found:=Found and InArea(A.X,A.Y);
|
Found:=Found and InArea(A.X,A.Y);
|
||||||
|
|
||||||
@ -6179,6 +6225,9 @@ begin
|
|||||||
EditorDialog(edSearchFailed,nil);
|
EditorDialog(edSearchFailed,nil);
|
||||||
if FindStr<>'' then
|
if FindStr<>'' then
|
||||||
PopInfo;
|
PopInfo;
|
||||||
|
{$ifdef TEST_REGEXP}
|
||||||
|
DestroyRegExprEngine(RegExpEngine);
|
||||||
|
{$endif TEST_REGEXP}
|
||||||
if (FindFlags and ffmScope)=ffSelectedText then
|
if (FindFlags and ffmScope)=ffSelectedText then
|
||||||
{ restore selection PM }
|
{ restore selection PM }
|
||||||
begin
|
begin
|
||||||
@ -6943,7 +6992,10 @@ end;
|
|||||||
END.
|
END.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.5 2001-09-12 09:31:42 pierre
|
Revision 1.6 2001-09-13 16:11:34 pierre
|
||||||
|
+ test code for regexpr use in find dialog
|
||||||
|
|
||||||
|
Revision 1.5 2001/09/12 09:31:42 pierre
|
||||||
* fix bug 1579
|
* fix bug 1579
|
||||||
|
|
||||||
Revision 1.4 2001/09/04 22:58:58 pierre
|
Revision 1.4 2001/09/04 22:58:58 pierre
|
||||||
|
Loading…
Reference in New Issue
Block a user