Quellcode durchsuchen

* more changes to speed syntax highlighting up

pierre vor 23 Jahren
Ursprung
Commit
f14ab4c96f
2 geänderte Dateien mit 76 neuen und 49 gelöschten Zeilen
  1. 52 34
      ide/fpviews.pas
  2. 24 15
      ide/weditor.pas

+ 52 - 34
ide/fpviews.pas

@@ -139,7 +139,7 @@ type
       function  IsReservedWord(const S: string): boolean; virtual;
       function  IsAsmReservedWord(const S: string): boolean; virtual;
       function  GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
-      function  GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string; virtual;
+      function  GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer;var Symbol: string): boolean; virtual;
       { CodeTemplates }
       function    TranslateCodeTemplate(var Shortcut: string; ALines: PUnsortedStringCollection): boolean; virtual;
       function    SelectCodeTemplate(var ShortCut: string): boolean; virtual;
@@ -420,7 +420,7 @@ type
                     PScrollBar; AIndicator: PIndicator);
       function    IsReservedWord(const S: string): boolean; virtual;
       function    GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
-      function    GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string; virtual;
+      function    GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer;var Symbol: string): boolean; virtual;
       function    GetPalette: PPalette; virtual;
     end;
 
@@ -430,7 +430,7 @@ type
                     PScrollBar; AIndicator: PIndicator);
       function    IsReservedWord(const S: string): boolean; virtual;
       function    GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
-      function    GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string; virtual;
+      function    GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer;var Symbol: string): boolean; virtual;
     end;
 
 function  SearchFreeWindowNo: integer;
@@ -1130,43 +1130,49 @@ begin
     ssAsmSuffix       : Count:=1;
     ssDirectivePrefix : Count:=1;
     ssDirectiveSuffix : Count:=1;
+  else
+    Count:=0;
   end;
   GetSpecSymbolCount:=Count;
 end;
 
-function TSourceEditor.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string;
+function TSourceEditor.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer;var Symbol: string): boolean;
 begin
+  GetSpecSymbol:=true;
   case SpecClass of
     ssCommentPrefix :
       case Index of
-        0 : GetSpecSymbol:='{';
-        1 : GetSpecSymbol:='(*';
-        2 : GetSpecSymbol:='//';
+        0 : Symbol:='{';
+        1 : Symbol:='(*';
+        2 : Symbol:='//';
       end;
     ssCommentSingleLinePrefix :
       case Index of
-        0 : GetSpecSymbol:='//';
+        0 : Symbol:='//';
       end;
     ssCommentSuffix :
       case Index of
-        0 : GetSpecSymbol:='}';
-        1 : GetSpecSymbol:='*)';
+        0 : Symbol:='}';
+        1 : Symbol:='*)';
       end;
     ssStringPrefix :
-      GetSpecSymbol:='''';
+      Symbol:='''';
     ssStringSuffix :
-      GetSpecSymbol:='''';
-    { must ne uppercased to avoid calling UpCaseStr in MatchesAnyAsmSymbol PM }
+      Symbol:='''';
+    { must be uppercased to avoid calling UpCaseStr in MatchesAnyAsmSymbol PM }
     ssAsmPrefix :
-      GetSpecSymbol:='ASM';
+      Symbol:='ASM';
     ssAsmSuffix :
-      GetSpecSymbol:='END';
+      Symbol:='END';
     ssDirectivePrefix :
-      GetSpecSymbol:='{$';
+      Symbol:='{$';
     ssDirectiveSuffix :
-      GetSpecSymbol:='}';
+      Symbol:='}';
     else
-      GetSpecSymbol:='';
+      begin
+        Symbol:='';
+        GetSpecSymbol:=false;
+      end;
   end;
 end;
 
@@ -4221,10 +4227,11 @@ begin
   GetSpecSymbolCount:=0;
 end;
 
-function TFPMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string;
+function TFPMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer;var Symbol: string): boolean;
 begin
   Abstract;
-  GetSpecSymbol:='';
+  GetSpecSymbol:=false;
+  Symbol:='';
 end;
 
 function TFPMemo.IsReservedWord(const S: string): boolean;
@@ -4251,40 +4258,48 @@ begin
     ssAsmSuffix       : Count:=1;
     ssDirectivePrefix : Count:=1;
     ssDirectiveSuffix : Count:=1;
+  else
+    Count:=0;
   end;
   GetSpecSymbolCount:=Count;
 end;
 
-function TFPCodeMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string;
+function TFPCodeMemo.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer;var Symbol: string): boolean;
 begin
+  GetSpecSymbol:=true;
   case SpecClass of
     ssCommentPrefix :
       case Index of
-        0 : GetSpecSymbol:='{';
-        1 : GetSpecSymbol:='(*';
-        2 : GetSpecSymbol:='//';
+        0 : Symbol:='{';
+        1 : Symbol:='(*';
+        2 : Symbol:='//';
       end;
     ssCommentSingleLinePrefix :
       case Index of
-        0 : GetSpecSymbol:='//';
+        0 : Symbol:='//';
       end;
     ssCommentSuffix :
       case Index of
-        0 : GetSpecSymbol:='}';
-        1 : GetSpecSymbol:='*)';
+        0 : Symbol:='}';
+        1 : Symbol:='*)';
       end;
     ssStringPrefix :
-      GetSpecSymbol:='''';
+      Symbol:='''';
     ssStringSuffix :
-      GetSpecSymbol:='''';
+      Symbol:='''';
     ssAsmPrefix :
-      GetSpecSymbol:='ASM';
+      Symbol:='ASM';
     ssAsmSuffix :
-      GetSpecSymbol:='END';
+      Symbol:='END';
     ssDirectivePrefix :
-      GetSpecSymbol:='{$';
+      Symbol:='{$';
     ssDirectiveSuffix :
-      GetSpecSymbol:='}';
+      Symbol:='}';
+  else
+    begin
+      GetSpecSymbol:=false;
+      Symbol:='';
+    end;
   end;
 end;
 
@@ -4354,7 +4369,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.30  2002-09-11 10:05:10  pierre
+  Revision 1.31  2002-09-11 11:23:48  pierre
+   * more changes to speed syntax highlighting up
+
+  Revision 1.30  2002/09/11 10:05:10  pierre
    * try to speed up syntax highlighting
 
   Revision 1.29  2002/09/07 15:40:46  peter

+ 24 - 15
ide/weditor.pas

@@ -562,7 +562,7 @@ type
     public
      { Syntax highlight support }
    {a}function    GetSpecSymbolCount(SpecClass: TSpecSymbolClass): integer; virtual;
-   {a}function    GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string; virtual;
+   {a}function    GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer;var Symbol: string): boolean; virtual;
    {a}function    IsReservedWord(const S: string): boolean; virtual;
    {a}function    IsAsmReservedWord(const S: string): boolean; virtual;
     public
@@ -749,13 +749,16 @@ const
      ReplaceStr         : String[FindStrSize] = '';
      FindReplaceEditor  : PCustomCodeEditor = nil;
      FindFlags          : word = ffPromptOnReplace;
-     WhiteSpaceChars    : set of char = [#0,#32,#255];
-     TabChars           : set of char = [#9];
-     HashChars          : set of char = ['#'];
-     AlphaChars         : set of char = ['A'..'Z','a'..'z','_'];
-     NumberChars        : set of char = ['0'..'9'];
-     HexNumberChars     : set of char = ['0'..'9','A'..'F','a'..'f'];
-     RealNumberChars    : set of char = ['E','e','.'{,'+','-'}];
+{$ifndef NO_UNTYPEDSET}
+  {$define USE_UNTYPEDSET}
+{$endif ndef NO_UNTYPEDSET}
+     WhiteSpaceChars    {$ifdef USE_UNTYPEDSET}: set of char {$endif} = [#0,#32,#255];
+     TabChars           {$ifdef USE_UNTYPEDSET}: set of char {$endif} = [#9];
+     HashChars          {$ifdef USE_UNTYPEDSET}: set of char {$endif} = ['#'];
+     AlphaChars         {$ifdef USE_UNTYPEDSET}: set of char {$endif} = ['A'..'Z','a'..'z','_'];
+     NumberChars        {$ifdef USE_UNTYPEDSET}: set of char {$endif} = ['0'..'9'];
+     HexNumberChars     {$ifdef USE_UNTYPEDSET}: set of char {$endif} = ['0'..'9','A'..'F','a'..'f'];
+     RealNumberChars    {$ifdef USE_UNTYPEDSET}: set of char {$endif} = ['E','e','.'{,'+','-'}];
 
 procedure RegisterWEditor;
 
@@ -2099,7 +2102,7 @@ var
     for I:=1 to Editor^.GetSpecSymbolCount(SClass) do
     begin
       SymbolIndex:=I;
-      S:=Editor^.GetSpecSymbol(SClass,I-1);
+      Editor^.GetSpecSymbol(SClass,I-1,S);
       if (length(SymbolConcat)<length(S)) or
          ((PartialMatch=pmNone) and (length(S)<>length(SymbolConcat)))
           then
@@ -2133,7 +2136,7 @@ var
     for I:=1 to Editor^.GetSpecSymbolCount(SClass) do
     begin
       SymbolIndex:=I;
-      S:=Editor^.GetSpecSymbol(SClass,I-1);
+      Editor^.GetSpecSymbol(SClass,I-1,S);
       if (length(S)<>length(What)) then
         Match:=false
       else
@@ -2163,7 +2166,7 @@ var
   begin
     IsCommentPrefix:=MatchesAnySpecSymbol(ssCommentPrefix,pmLeft);
   end;
-
+                              {** **}
   function IsSingleLineCommentPrefix: boolean;
   begin
     IsSingleLineCommentPrefix:=MatchesAnySpecSymbol(ssCommentSingleLinePrefix,pmLeft);
@@ -2295,6 +2298,7 @@ var
   procedure ProcessChar(C: char);
   var CC: TCharClass;
       EX: Sw_integer;
+      EndComment: string;
   begin
     CC:=GetCharClass(C);
     if ClassStart=X then
@@ -2358,7 +2362,8 @@ var
                   { Remove (* from SymbolConcat to avoid problem with (*) PM }
                   { fixes part of bug 1617 }
                   { but removed proper directive prefix detection ... }
-                  if MatchingSymbol[length(MatchingSymbol)]=Editor^.GetSpecSymbol(ssCommentSuffix,SymbolIndex)[1] then
+                  Editor^.GetSpecSymbol(ssCommentSuffix,SymbolIndex,EndComment);
+                  if MatchingSymbol[length(MatchingSymbol)]=EndComment[1] then
                     Delete(SymbolConcat,1,length(MatchingSymbol));
                 end
               else if InComment and IsCommentSuffix then
@@ -3095,10 +3100,11 @@ begin
   GetSpecSymbolCount:=0;
 end;
 
-function TCustomCodeEditor.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer): string;
+function TCustomCodeEditor.GetSpecSymbol(SpecClass: TSpecSymbolClass; Index: integer;var Symbol: string):boolean;
 begin
   Abstract;
-  GetSpecSymbol:='';
+  Symbol:='';
+  GetSpecSymbol:=false;
 end;
 
 function TCustomCodeEditor.IsReservedWord(const S: string): boolean;
@@ -7159,7 +7165,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.33  2002-09-11 10:05:10  pierre
+  Revision 1.34  2002-09-11 11:23:48  pierre
+   * more changes to speed syntax highlighting up
+
+  Revision 1.33  2002/09/11 10:05:10  pierre
    * try to speed up syntax highlighting
 
   Revision 1.32  2002/09/11 08:39:44  pierre