浏览代码

+ more regexp, options now in Find/Replace dialogs

pierre 24 年之前
父节点
当前提交
f1dd7fd8db
共有 3 个文件被更改,包括 58 次插入12 次删除
  1. 6 1
      ide/wcedit.pas
  2. 6 1
      ide/wconstse.inc
  3. 46 10
      ide/weditor.pas

+ 6 - 1
ide/wcedit.pas

@@ -1132,6 +1132,8 @@ begin
      inc(i);
      inc(rx);
      if s[i]=#9 then
+
+
       inc(rx,TabSize-(rx mod tabsize));
    end;
   GetDisplayTextPos:=rx;
@@ -1990,7 +1992,10 @@ end;
 END.
 {
  $Log$
- Revision 1.3  2001-09-14 16:33:06  pierre
+ Revision 1.4  2001-09-14 23:47:08  pierre
+  + more regexp, options now in Find/Replace dialogs
+
+ Revision 1.3  2001/09/14 16:33:06  pierre
   * several small changes
 
  Revision 1.2  2001/08/05 02:01:48  peter

+ 6 - 1
ide/wconstse.inc

@@ -27,6 +27,7 @@
     label_find_texttofind = '~T~ext to find';
     label_find_casesensitive = '~C~ase sensitive';
     label_find_wholewordsonly = '~W~hole words only';
+    label_find_useregexp = '~U~se regular expr.';
     label_find_direction = 'Direction';
     label_find_forward = 'Forwar~d~';
     label_find_backward = '~B~ackward';
@@ -42,6 +43,7 @@
     label_replace_newtext = '    ~N~ew text';
     label_replace_options = label_find_options;
     label_replace_casesensitive = label_find_casesensitive;
+    label_replace_useregexp = label_find_useregexp;
     label_replace_wholewordsonly = label_find_wholewordsonly;
     label_replace_promptonreplace = '~P~rompt on replace';
     label_replace_direction = label_find_direction;
@@ -113,7 +115,10 @@
 
 {
   $Log$
-  Revision 1.1  2001-08-04 11:30:25  peter
+  Revision 1.2  2001-09-14 23:47:09  pierre
+   + more regexp, options now in Find/Replace dialogs
+
+  Revision 1.1  2001/08/04 11:30:25  peter
     * ide works now with both compiler versions
 
   Revision 1.1.2.3  2001/03/06 22:04:53  pierre

+ 46 - 10
ide/weditor.pas

@@ -141,7 +141,11 @@ const
       ffEntireScope      = $0020;
 
 {$ifdef TEST_REGEXP}
-      ffUseRegExp        = $0040;
+      ffUseRegExp        = $0100;
+      ffmUseRegExpFind   = $0004;
+      ffsUseRegExpFind   = 8 - 2;
+      ffmUseRegExpReplace = $0008;
+      ffsUseRegExpReplace = 8 - 3;
 {$endif TEST_REGEXP}
 
       coTextColor         = 0;
@@ -5866,7 +5870,12 @@ begin
     Find := FindStr;
     if GetCurrentWord<>'' then
       Find:=GetCurrentWord;
+{$ifdef TEST_REGEXP}
+    Options := (FindFlags and ffmOptions) shr ffsOptions or
+               (FindFlags and ffUseRegExp) shr ffsUseRegExpFind;
+{$else not TEST_REGEXP}
     Options := (FindFlags and ffmOptions) shr ffsOptions;
+{$endif TEST_REGEXP}
     Direction := (FindFlags and ffmDirection) shr ffsDirection;
     Scope := (FindFlags and ffmScope) shr ffsScope;
     Origin := (FindFlags and ffmOrigin) shr ffsOrigin;
@@ -5874,7 +5883,10 @@ begin
     if EditorDialog(edFind, @FindRec) <> cmCancel then
     begin
       FindStr := Find;
-      FindFlags := (Options shl ffsOptions) or (Direction shl ffsDirection) or
+      FindFlags := ((Options and ffmOptions) shl ffsOptions) or (Direction shl ffsDirection) or
+{$ifdef TEST_REGEXP}
+         ((Options and ffmUseRegExpFind) shl ffsUseRegExpFind) or
+{$endif TEST_REGEXP}
          (Scope shl ffsScope) or (Origin shl ffsOrigin);
       FindFlags := FindFlags and not ffDoReplace;
       if DoConf then
@@ -5900,7 +5912,12 @@ begin
     if GetCurrentWord<>'' then
       Find:=GetCurrentWord;
     Replace := ReplaceStr;
+{$ifdef TEST_REGEXP}
+    Options := (FindFlags and ffmOptions) shr ffsOptions or
+               (FindFlags and ffUseRegExp) shr ffsUseRegExpReplace;
+{$else not TEST_REGEXP}
     Options := (FindFlags and ffmOptions) shr ffsOptions;
+{$endif TEST_REGEXP}
     Direction := (FindFlags and ffmDirection) shr ffsDirection;
     Scope := (FindFlags and ffmScope) shr ffsScope;
     Origin := (FindFlags and ffmOrigin) shr ffsOrigin;
@@ -5910,6 +5927,9 @@ begin
       FindStr := Find;
       ReplaceStr := Replace;
       FindFlags := (Options shl ffsOptions) or (Direction shl ffsDirection) or
+{$ifdef TEST_REGEXP}
+         ((Options and ffmUseRegExpReplace) shl ffsUseRegExpReplace) or
+{$endif TEST_REGEXP}
          (Scope shl ffsScope) or (Origin shl ffsOrigin);
       FindFlags := FindFlags or ffDoReplace;
       if Re = cmYes then
@@ -6086,9 +6106,13 @@ begin
        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);
+         { If start of line is required do check other positions PM }
+         if (FindStr[1]='^') and (X<>0) then
+           Found:=false
+         else
+           Found:=RegExprPos(RegExpEngine,findstrpchar,regexpindex,regexplen);
          strdispose(findstrpchar);
-         P:=regexpindex;
+         P:=regexpindex+X+1;
        end
     else
 {$endif TEST_REGEXP}
@@ -6226,7 +6250,8 @@ begin
   if FindStr<>'' then
     PopInfo;
 {$ifdef TEST_REGEXP}
-  DestroyRegExprEngine(RegExpEngine);
+  if UseRegExp then
+    DestroyRegExprEngine(RegExpEngine);
 {$endif TEST_REGEXP}
   if (FindFlags and ffmScope)=ffSelectedText then
     { restore selection PM }
@@ -6671,11 +6696,15 @@ begin
     Insert(Control);
 
     R1.Copy(R); Inc(R1.A.Y,2); R1.B.Y:=R1.A.Y+1; R1.B.X:=R1.A.X+(R1.B.X-R1.A.X) div 2-1;
-    R2.Copy(R1); R2.Move(0,1); R2.B.Y:=R2.A.Y+2;
+    R2.Copy(R1); R2.Move(0,1);
+    R2.B.Y:=R2.A.Y+{$ifdef TEST_REGEXP}3{$else}2{$endif};
     New(CB1, Init(R2,
       NewSItem(label_find_casesensitive,
       NewSItem(label_find_wholewordsonly,
-      nil))));
+{$ifdef TEST_REGEXP}
+      NewSItem(label_find_useregexp,
+{$endif TEST_REGEXP}
+      nil)))){$ifdef TEST_REGEXP}){$endif TEST_REGEXP};
     Insert(CB1);
     Insert(New(PLabel, Init(R1, label_find_options, CB1)));
 
@@ -6751,12 +6780,16 @@ begin
     Insert(Control);
 
     R1.Copy(R); Inc(R1.A.Y,4); R1.B.Y:=R1.A.Y+1; R1.B.X:=R1.A.X+(R1.B.X-R1.A.X) div 2-1;
-    R2.Copy(R1); R2.Move(0,1); R2.B.Y:=R2.A.Y+3;
+    R2.Copy(R1); R2.Move(0,1);
+    R2.B.Y:=R2.A.Y+{$ifdef TEST_REGEXP}4{$else}3{$endif};
     New(CB1, Init(R2,
       NewSItem(label_replace_casesensitive,
       NewSItem(label_replace_wholewordsonly,
       NewSItem(label_replace_promptonreplace,
-      nil)))));
+{$ifdef TEST_REGEXP}
+      NewSItem(label_find_useregexp,
+{$endif TEST_REGEXP}
+      nil))))){$ifdef TEST_REGEXP}){$endif TEST_REGEXP};
     Insert(CB1);
     Insert(New(PLabel, Init(R1, label_replace_options, CB1)));
 
@@ -6992,7 +7025,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.6  2001-09-13 16:11:34  pierre
+  Revision 1.7  2001-09-14 23:47:09  pierre
+   + more regexp, options now in Find/Replace dialogs
+
+  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