Browse Source

Gabors changes

pierre 25 years ago
parent
commit
f9eba82854
1 changed files with 145 additions and 53 deletions
  1. 145 53
      ide/text/weditor.pas

+ 145 - 53
ide/text/weditor.pas

@@ -26,6 +26,9 @@ uses
 { try to only do syntax on part of file until current position
 { try to only do syntax on part of file until current position
   does work correctly now ? at least I hope so PM }
   does work correctly now ? at least I hope so PM }
 {$define TEST_PARTIAL_SYNTAX}
 {$define TEST_PARTIAL_SYNTAX}
+{ Please "change" this to a field in TCodeEditor and check for this it a normal
+  "if"-construct in UpdateAttrs(). WEditor contains a _generic_ editor object
+  and should stay as flexible as possible. - Gabor }
 
 
 const
 const
       cmFileNameChanged      = 51234;
       cmFileNameChanged      = 51234;
@@ -271,6 +274,7 @@ type
       CompleteState: TCompleteState;
       CompleteState: TCompleteState;
       CodeCompleteFrag: PString;
       CodeCompleteFrag: PString;
       CodeCompleteWord: PString;
       CodeCompleteWord: PString;
+      AlwaysShowScrollBars: boolean;
       constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
       constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
           PScrollBar; AIndicator: PIndicator; AbufSize:Sw_Word);
           PScrollBar; AIndicator: PIndicator; AbufSize:Sw_Word);
       procedure   SetFlags(AFlags: longint); virtual;
       procedure   SetFlags(AFlags: longint); virtual;
@@ -332,6 +336,9 @@ type
       procedure   SetErrorMessage(const S: string); virtual;
       procedure   SetErrorMessage(const S: string); virtual;
       procedure   AdjustSelection(DeltaX, DeltaY: sw_integer);
       procedure   AdjustSelection(DeltaX, DeltaY: sw_integer);
       procedure   AdjustSelectionPos(CurPosX, CurPosY: sw_integer; DeltaX, DeltaY: sw_integer);
       procedure   AdjustSelectionPos(CurPosX, CurPosY: sw_integer; DeltaX, DeltaY: sw_integer);
+      function    IsFlagSet(AFlag: longint): boolean;
+      procedure   GetContent(ALines: PUnsortedStringCollection); virtual;
+      procedure   SetContent(ALines: PUnsortedStringCollection); virtual;
       procedure   Lock;
       procedure   Lock;
       procedure   UnLock;
       procedure   UnLock;
     private
     private
@@ -350,6 +357,7 @@ type
       IndicatorDrawCalled  : boolean;
       IndicatorDrawCalled  : boolean;
       CurEvent    : PEvent;
       CurEvent    : PEvent;
       function    Overwrite: boolean;
       function    Overwrite: boolean;
+      function    IsModal: boolean;
       function    GetLine(I: sw_integer): PLine;
       function    GetLine(I: sw_integer): PLine;
       procedure   CheckSels;
       procedure   CheckSels;
       procedure   CodeCompleteCheck;
       procedure   CodeCompleteCheck;
@@ -1228,8 +1236,8 @@ begin
   Flags:=AFlags;
   Flags:=AFlags;
   if ((OldFlags xor Flags) and efCodeComplete)<>0 then
   if ((OldFlags xor Flags) and efCodeComplete)<>0 then
     ClearCodeCompleteWord;
     ClearCodeCompleteWord;
-  SetInsertMode((Flags and efInsertMode)<>0);
-  if (Flags and efSyntaxHighlight)<>0 then
+  SetInsertMode(IsFlagSet(efInsertMode));
+  if IsFlagSet(efSyntaxHighlight) then
     UpdateAttrs(0,attrAll) else
     UpdateAttrs(0,attrAll) else
   for I:=0 to GetLineCount-1 do
   for I:=0 to GetLineCount-1 do
     SetLineFormat(I,'');
     SetLineFormat(I,'');
@@ -1251,6 +1259,39 @@ begin
   DrawView;
   DrawView;
 end;
 end;
 
 
+procedure TCodeEditor.GetContent(ALines: PUnsortedStringCollection);
+procedure AddIt(P: PLine); {$ifndef FPC}far;{$endif}
+begin
+  if Assigned(P) and Assigned(P^.Text) then
+    ALines^.Insert(NewStr(GetStr(P^.Text)));
+end;
+begin
+  if Assigned(Lines) then
+    Lines^.ForEach(@AddIt);
+end;
+
+procedure TCodeEditor.SetContent(ALines: PUnsortedStringCollection);
+procedure AddIt(P: PString); {$ifndef FPC}far;{$endif}
+begin
+  AddLine(GetStr(P));
+end;
+begin
+  Lock;
+  TextStart; HideSelect; DeleteAllLines;
+  if Assigned(ALines) then
+    ALines^.ForEach(@AddIt);
+  LimitsChanged;
+  if IsFlagSet(efSyntaxHighlight) then
+    UpdateAttrsRange(0,Min(Delta.Y+Size.Y,GetLineCount-1),
+      attrAll
+{$ifndef TEST_PARTIAL_SYNTAX}
+      +attrForceFull
+{$endif TEST_PARTIAL_SYNTAX}
+      );
+  TextStart;
+  UnLock;
+end;
+
 procedure TCodeEditor.Lock;
 procedure TCodeEditor.Lock;
 begin
 begin
   Inc(LockFlag);
   Inc(LockFlag);
@@ -1326,6 +1367,11 @@ begin
     end;
     end;
 end;
 end;
 
 
+function TCodeEditor.IsFlagSet(AFlag: longint): boolean;
+begin
+  IsFlagSet:=(Flags and AFlag)=AFlag;
+end;
+
 procedure TCodeEditor.AdjustSelection(DeltaX, DeltaY: sw_integer);
 procedure TCodeEditor.AdjustSelection(DeltaX, DeltaY: sw_integer);
 begin
 begin
   AdjustSelectionPos(CurPos.X,CurPos.Y,DeltaX,DeltaY);
   AdjustSelectionPos(CurPos.X,CurPos.Y,DeltaX,DeltaY);
@@ -1359,6 +1405,15 @@ begin
   DrawView;
   DrawView;
 end;
 end;
 
 
+function TCodeEditor.IsModal: boolean;
+var IsM: boolean;
+begin
+  IsM:=GetState(sfModal);
+  if Assigned(Owner) then
+    IsM:=IsM or Owner^.GetState(sfModal);
+  IsModal:=IsM;
+end;
+
 procedure TCodeEditor.UpdateIndicator;
 procedure TCodeEditor.UpdateIndicator;
 begin
 begin
   if Indicator<>nil then
   if Indicator<>nil then
@@ -1368,9 +1423,9 @@ begin
 {$ifdef debug}
 {$ifdef debug}
     Indicator^.StoreUndo:=StoreUndo;
     Indicator^.StoreUndo:=StoreUndo;
 {$ifdef TEST_PARTIAL_SYNTAX}
 {$ifdef TEST_PARTIAL_SYNTAX}
-    Indicator^.SyntaxComplete:=SyntaxComplete and ((Flags and efSyntaxHighlight)<>0);
+    Indicator^.SyntaxComplete:=SyntaxComplete and IsFlagSet(efSyntaxHighlight);
 {$endif TEST_PARTIAL_SYNTAX}
 {$endif TEST_PARTIAL_SYNTAX}
-    Indicator^.UseTabs:=((Flags and efUseTabCharacters)<>0);
+    Indicator^.UseTabs:=IsFlagSet(efUseTabCharacters);
 {$endif debug}
 {$endif debug}
     if lockflag>0 then
     if lockflag>0 then
       IndicatorDrawCalled:=true
       IndicatorDrawCalled:=true
@@ -1505,19 +1560,24 @@ begin
                  Message(@Self,evCommand,cmNewLine,nil);
                  Message(@Self,evCommand,cmNewLine,nil);
              kbEsc :
              kbEsc :
                if CompleteState=csOffering then
                if CompleteState=csOffering then
-                 CodeCompleteCancel;
+                 CodeCompleteCancel else
+                if IsModal then
+                  DontClear:=true;
            else
            else
             case Event.CharCode of
             case Event.CharCode of
              #9,#32..#255 :
              #9,#32..#255 :
-               begin
-                 NoSelect:=true;
-                 AddChar(Event.CharCode);
-                 NoSelect:=false;
-                 if (CompleteState<>csDenied) or (Event.CharCode=#32) then
-                   CCAction:=ccCheck
-                 else
-                   CCAction:=ccClear;
-               end;
+               if (Event.CharCode=#9) and IsModal then
+                 DontClear:=true
+               else
+                 begin
+                   NoSelect:=true;
+                   AddChar(Event.CharCode);
+                   NoSelect:=false;
+                   if (CompleteState<>csDenied) or (Event.CharCode=#32) then
+                     CCAction:=ccCheck
+                   else
+                     CCAction:=ccClear;
+                 end;
             else
             else
               DontClear:=true;
               DontClear:=true;
             end; { case Event.CharCode .. }
             end; { case Event.CharCode .. }
@@ -1795,7 +1855,7 @@ begin
      end;
      end;
     GetDisplayTextFormat(AY,LineText,Format);
     GetDisplayTextFormat(AY,LineText,Format);
 
 
-{    if (Flags and efSyntaxHighlight)<>0 then MaxX:=length(LineText)+1
+{    if FlagSet(efSyntaxHighlight) then MaxX:=length(LineText)+1
        else }MaxX:=Size.X+Delta.X;
        else }MaxX:=Size.X+Delta.X;
     for X:=1 to Min(MaxX,255) do
     for X:=1 to Min(MaxX,255) do
     begin
     begin
@@ -1813,7 +1873,7 @@ begin
       end else
       end else
       { no highlight }
       { no highlight }
       begin
       begin
-   if (Flags and efVerticalBlocks<>0) then
+   if IsFlagSet(efVerticalBlocks) then
       begin
       begin
         if (SelStart.X<=AX) and (AX<=SelEnd.X) and
         if (SelStart.X<=AX) and (AX<=SelEnd.X) and
       (SelStart.Y<=AY) and (AY<=SelEnd.Y) then
       (SelStart.Y<=AY) and (AY<=SelEnd.Y) then
@@ -1829,13 +1889,13 @@ begin
          this give BoundsCheckError with -Cr quite often PM }
          this give BoundsCheckError with -Cr quite often PM }
        Color:=ColorTab[ord(Format[X]) mod (coLastColor + 1)] else Color:=ColorTab[coTextColor];
        Color:=ColorTab[ord(Format[X]) mod (coLastColor + 1)] else Color:=ColorTab[coTextColor];
 
 
-    if ( ((Flags and efHighlightRow)   <>0) and
-       (PX.Y=CurPos.Y) ) and (HighlightRow=-1) then
+    if IsFlagSet(efHighlightRow) and
+       (PX.Y=CurPos.Y) and (HighlightRow=-1) then
       begin
       begin
         Color:=CombineColors(Color,HighlightRowColor);
         Color:=CombineColors(Color,HighlightRowColor);
         FreeFormat[X]:=false;
         FreeFormat[X]:=false;
       end;
       end;
-    if ( ((Flags and efHighlightColumn)<>0) and (PX.X=CurPos.X) ) then
+    if IsFlagSet(efHighlightColumn) and (PX.X=CurPos.X) then
       begin
       begin
         Color:=CombineColors(Color,HighlightColColor);
         Color:=CombineColors(Color,HighlightColColor);
         FreeFormat[X]:=false;
         FreeFormat[X]:=false;
@@ -1876,7 +1936,7 @@ end;
 
 
 function TCodeEditor.Overwrite: boolean;
 function TCodeEditor.Overwrite: boolean;
 begin
 begin
-  Overwrite:=(Flags and efInsertMode)=0;
+  Overwrite:=not IsFlagSet(efInsertMode);
 end;
 end;
 
 
 function TCodeEditor.GetLineCount: sw_integer;
 function TCodeEditor.GetLineCount: sw_integer;
@@ -2025,9 +2085,10 @@ begin
   { I disagree here
   { I disagree here
     I don't want the editor to change the position of the tabs
     I don't want the editor to change the position of the tabs
     in my makefiles !! PM
     in my makefiles !! PM
-  if ((Flags and efUseTabCharacters)<>0) and (TabSize>0) then
+  if FlagSet(efUseTabCharacters) and (TabSize>0) then
    SetLineText(I,CompressUsingTabs(S,TabSize))
    SetLineText(I,CompressUsingTabs(S,TabSize))
   else                  }
   else                  }
+  { ... then you better make this optional - Gabor }
    SetLineText(I,S);
    SetLineText(I,S);
 end;
 end;
 
 
@@ -2163,7 +2224,7 @@ var S, PreS: string;
 begin
 begin
   S:=GetLineText(CurPos.Y);
   S:=GetLineText(CurPos.Y);
   if CurPos.Y>0 then
   if CurPos.Y>0 then
-    PreS:=RTrim(GetLineText(CurPos.Y-1),(Flags and efUseTabCharacters)=0)
+    PreS:=RTrim(GetLineText(CurPos.Y-1),not IsFlagSet(efUseTabCharacters))
   else
   else
     PreS:='';
     PreS:='';
   if CurPos.X>=length(PreS) then
   if CurPos.X>=length(PreS) then
@@ -2336,7 +2397,7 @@ end;
 
 
 procedure TCodeEditor.LineDown;
 procedure TCodeEditor.LineDown;
 begin
 begin
-  if CurPos.Y<GetLineCount-1 then
+  if (CurPos.Y<GetLineCount-1) then
      SetCurPtr(CurPos.X,CurPos.Y+1);
      SetCurPtr(CurPos.X,CurPos.Y+1);
 end;
 end;
 
 
@@ -2456,7 +2517,7 @@ begin
     begin
     begin
       S:=GetDisplayText(CurPos.Y);
       S:=GetDisplayText(CurPos.Y);
       SelBack:=length(S)-SelEnd.X;
       SelBack:=length(S)-SelEnd.X;
-      SetDisplayText(CurPos.Y,RTrim(S,(Flags and efUseTabCharacters)=0));
+      SetDisplayText(CurPos.Y,RTrim(S,not IsFlagSet(efUseTabCharacters)));
     end;
     end;
     SetDisplayText(CurPos.Y,copy(S,1,CurPos.X-1+1));
     SetDisplayText(CurPos.Y,copy(S,1,CurPos.X-1+1));
     CalcIndent(CurPos.Y);
     CalcIndent(CurPos.Y);
@@ -2537,7 +2598,7 @@ begin
    begin
    begin
      S:=GetDisplayText(CurPos.Y);
      S:=GetDisplayText(CurPos.Y);
      CP:=CurPos.X-1;
      CP:=CurPos.X-1;
-     if (Flags and efBackspaceUnindents)<>0 then
+     if IsFlagSet(efBackspaceUnindents) then
       if Trim(copy(S,1,CP+1))='' then
       if Trim(copy(S,1,CP+1))='' then
       begin
       begin
         Y:=CurPos.Y;
         Y:=CurPos.Y;
@@ -3027,6 +3088,7 @@ var OSS,OSE: TPoint;
     Line,ShortCut: string;
     Line,ShortCut: string;
     X,Y,I,LineIndent: sw_integer;
     X,Y,I,LineIndent: sw_integer;
     CodeLines: PUnsortedStringCollection;
     CodeLines: PUnsortedStringCollection;
+    CanJump: boolean;
 begin
 begin
   {
   {
     The usage of editing primitives in this routine make it pretty slow, but
     The usage of editing primitives in this routine make it pretty slow, but
@@ -3057,20 +3119,34 @@ begin
         DelChar;
         DelChar;
       for Y:=0 to CodeLines^.Count-1 do
       for Y:=0 to CodeLines^.Count-1 do
       begin
       begin
+        CanJump:=false;
         if Y>0 then
         if Y>0 then
-          for X:=1 to LineIndent do  { indent template lines to align }
-            AddChar(' ');            { them to the first line         }
+          begin
+             CanJump:=Trim(GetLineText(CurPos.Y))='';
+             if CanJump=false then
+               begin
+                 for X:=1 to LineIndent do  { indent template lines to align }
+                   AddChar(' ');            { them to the first line         }
+               end
+             else
+              SetCurPtr(CurPos.X+LineIndent,CurPos.Y);
+          end;
         Line:=CodeLines^.At(Y)^;
         Line:=CodeLines^.At(Y)^;
         for X:=1 to length(Line) do
         for X:=1 to length(Line) do
           AddChar(Line[X]);
           AddChar(Line[X]);
         if Y<CodeLines^.Count-1 then
         if Y<CodeLines^.Count-1 then
           begin
           begin
             InsertLine;               { line break }
             InsertLine;               { line break }
-            while CurPos.X>0 do       { unindent }
-            begin
-              SetCurPtr(CurPos.X-1,CurPos.Y);
-              DelChar;
-            end;
+            if CanJump=false then
+              begin
+                while CurPos.X>0 do       { unindent }
+                begin
+                  SetCurPtr(CurPos.X-1,CurPos.Y);
+                  DelChar;
+                end;
+              end
+            else
+              SetCurPtr(0,CurPos.Y);
           end;
           end;
       end;
       end;
     end;
     end;
@@ -3095,12 +3171,12 @@ begin
   SP:=CurPos;
   SP:=CurPos;
   HoldUndo:=StoreUndo;
   HoldUndo:=StoreUndo;
   StoreUndo:=false;
   StoreUndo:=false;
-  if (C<>TAB) or ((Flags and efUseTabCharacters)<>0) then
+  if (C<>TAB) or IsFlagSet(efUseTabCharacters) then
     SC:=C
     SC:=C
   else
   else
     begin
     begin
       LocTabSize:=TabSize - (CurPos.X mod TabSize);
       LocTabSize:=TabSize - (CurPos.X mod TabSize);
-      if (CurPos.Y<=1) or ((Flags and efAutoIndent)=0) then
+      if (CurPos.Y<=1) or not IsFlagSet(efAutoIndent) then
         SC:=CharStr(' ',LocTabSize)
         SC:=CharStr(' ',LocTabSize)
       else
       else
         begin
         begin
@@ -3146,7 +3222,7 @@ begin
   Addaction(eaInsertText,SP,CurPos,C);
   Addaction(eaInsertText,SP,CurPos,C);
   StoreUndo:=false;
   StoreUndo:=false;
 {$endif Undo}
 {$endif Undo}
-  if ((Flags and efAutoBrackets)<>0) then
+  if IsFlagSet(efAutoBrackets) then
     begin
     begin
       BI:=Pos(C,OpenBrackets);
       BI:=Pos(C,OpenBrackets);
       if (BI>0) then
       if (BI>0) then
@@ -3945,7 +4021,7 @@ begin
      else begin SetSelection(CurPos,OldPos); Extended:=true; end;
      else begin SetSelection(CurPos,OldPos); Extended:=true; end;
     DrawView;
     DrawView;
   end else
   end else
-   if (Flags and efPersistentBlocks)=0 then
+   if not IsFlagSet(efPersistentBlocks) then
       begin HideSelect; DrawView; end;
       begin HideSelect; DrawView; end;
 {  if PointOfs(SelStart)=PointOfs(SelEnd) then
 {  if PointOfs(SelStart)=PointOfs(SelEnd) then
      SetSelection(CurPos,CurPos);}
      SetSelection(CurPos,CurPos);}
@@ -3955,7 +4031,7 @@ begin
      ((Highlight.A.X<>HighLight.B.X) or (Highlight.A.Y<>HighLight.B.Y)) then
      ((Highlight.A.X<>HighLight.B.X) or (Highlight.A.Y<>HighLight.B.Y)) then
      HideHighlight;
      HideHighlight;
   if (OldPos.Y<>CurPos.Y) and (0<=OldPos.Y) and (OldPos.Y<GetLineCount) then
   if (OldPos.Y<>CurPos.Y) and (0<=OldPos.Y) and (OldPos.Y<GetLineCount) then
-     SetLineText(OldPos.Y,RTrim(GetLineText(OldPos.Y),(Flags and efUseTabCharacters)=0));
+     SetLineText(OldPos.Y,RTrim(GetLineText(OldPos.Y),not IsFlagSet(efUseTabCharacters)));
   if ((CurPos.X<>OldPos.X) or (CurPos.Y<>OldPos.Y)) and (GetErrorMessage<>'') then
   if ((CurPos.X<>OldPos.X) or (CurPos.Y<>OldPos.Y)) and (GetErrorMessage<>'') then
     SetErrorMessage('');
     SetErrorMessage('');
   if ((CurPos.X<>OldPos.X) or (CurPos.Y<>OldPos.Y)) and (HighlightRow<>-1) then
   if ((CurPos.X<>OldPos.X) or (CurPos.Y<>OldPos.Y)) and (HighlightRow<>-1) then
@@ -4007,7 +4083,7 @@ var Line: string;
     CurWord,NewWord: string;
     CurWord,NewWord: string;
 begin
 begin
   SetCodeCompleteFrag('');
   SetCodeCompleteFrag('');
-  if ((Flags and efCodeComplete)=0) or (IsReadOnly=true) then Exit;
+  if (not IsFlagSet(efCodeComplete)) or (IsReadOnly=true) then Exit;
 
 
   Lock;
   Lock;
 
 
@@ -4289,7 +4365,7 @@ var
 var CurLine: Sw_integer;
 var CurLine: Sw_integer;
     Line,NextLine,PrevLine,OldLine: PLine;
     Line,NextLine,PrevLine,OldLine: PLine;
 begin
 begin
-  if ((Flags and efSyntaxHighlight)=0) or (FromLine>=GetLineCount) then
+  if (not IsFlagSet(efSyntaxHighlight)) or (FromLine>=GetLineCount) then
   begin
   begin
     SetLineFormat(FromLine,'');
     SetLineFormat(FromLine,'');
     UpdateAttrs:=GetLineCount;
     UpdateAttrs:=GetLineCount;
@@ -4303,7 +4379,7 @@ begin
     Exit;
     Exit;
   end;
   end;
 {$ifdef TEST_PARTIAL_SYNTAX}
 {$ifdef TEST_PARTIAL_SYNTAX}
-  If ((Flags and efSyntaxHighlight)<>0) and (LastSyntaxedLine<FromLine)
+  If IsFlagSet(efSyntaxHighlight) and (LastSyntaxedLine<FromLine)
      and (FromLine<GetLineCount) then
      and (FromLine<GetLineCount) then
     CurLine:=LastSyntaxedLine
     CurLine:=LastSyntaxedLine
   else
   else
@@ -4452,7 +4528,7 @@ var OK: boolean;
     VerticalBlock: boolean;
     VerticalBlock: boolean;
     SEnd: TPoint;
     SEnd: TPoint;
 begin
 begin
-  if (Editor^.Flags and efVerticalBlocks)<>0 then
+  if Editor^.IsFlagSet(efVerticalBlocks) then
     begin
     begin
       NotImplemented;
       NotImplemented;
       Exit;
       Exit;
@@ -4468,7 +4544,7 @@ begin
   begin
   begin
     StartPos:=CurPos; DestPos:=CurPos;
     StartPos:=CurPos; DestPos:=CurPos;
     EPos:=CurPos;
     EPos:=CurPos;
-    VerticalBlock:=(Editor^.Flags and efVerticalBlocks)<>0;
+    VerticalBlock:=Editor^.IsFlagSet(efVerticalBlocks);
     LineDelta:=0; LineCount:=(Editor^.SelEnd.Y-Editor^.SelStart.Y)+1;
     LineDelta:=0; LineCount:=(Editor^.SelEnd.Y-Editor^.SelStart.Y)+1;
     OK:=GetLineCount<MaxLineCount;
     OK:=GetLineCount<MaxLineCount;
     OrigS:=GetDisplayText(DestPos.Y);
     OrigS:=GetDisplayText(DestPos.Y);
@@ -4742,8 +4818,20 @@ begin
 end;
 end;
 
 
 procedure TCodeEditor.SetState(AState: Word; Enable: Boolean);
 procedure TCodeEditor.SetState(AState: Word; Enable: Boolean);
+  procedure ShowSBar(SBar: PScrollBar);
+  begin
+    if Assigned(SBar) and (SBar^.GetState(sfVisible)=false) then
+        SBar^.Show;
+  end;
 begin
 begin
   inherited SetState(AState,Enable);
   inherited SetState(AState,Enable);
+
+  if AlwaysShowScrollBars then
+   begin
+     ShowSBar(HScrollBar);
+     ShowSBar(VScrollBar);
+   end;
+
   if (AState and (sfActive+sfSelected+sfFocused))<>0 then
   if (AState and (sfActive+sfSelected+sfFocused))<>0 then
     begin
     begin
       SelectionChanged;
       SelectionChanged;
@@ -4775,7 +4863,7 @@ begin
   S.Read(Flags,SizeOf(Flags));
   S.Read(Flags,SizeOf(Flags));
   S.Read(TabSize,SizeOf(TabSize));
   S.Read(TabSize,SizeOf(TabSize));
 
 
-  if (Flags and efStoreContent)<>0 then
+  if IsFlagSet(efStoreContent) then
     begin
     begin
       S.Read(TSize,SizeOf(TSize));
       S.Read(TSize,SizeOf(TSize));
       New(TS, Init(@S,S.GetPos,TSize));
       New(TS, Init(@S,S.GetPos,TSize));
@@ -4813,7 +4901,7 @@ begin
   S.Write(Flags,SizeOf(Flags));
   S.Write(Flags,SizeOf(Flags));
   S.Write(TabSize,SizeOf(TabSize));
   S.Write(TabSize,SizeOf(TabSize));
 
 
-  if (Flags and efStoreContent)<>0 then
+  if IsFlagSet(efStoreContent) then
     begin
     begin
       { NS.Init;
       { NS.Init;
       SaveToStream(@NS);
       SaveToStream(@NS);
@@ -4821,6 +4909,7 @@ begin
       NS.Done;
       NS.Done;
         This is waste of time PM
         This is waste of time PM
         use Seek instead !! }
         use Seek instead !! }
+      { yep. and this won't work for serial streams. - Gabor }
       TSize:=0;
       TSize:=0;
       TSizePos:=S.GetPos;
       TSizePos:=S.GetPos;
       S.Write(TSize,SizeOf(TSize));
       S.Write(TSize,SizeOf(TSize));
@@ -4865,7 +4954,7 @@ begin
   LimitsChanged;
   LimitsChanged;
   if not AllLinesComplete then
   if not AllLinesComplete then
     SetModified(true);
     SetModified(true);
-  if (Flags and efSyntaxHighlight)<>0 then
+  if IsFlagSet(efSyntaxHighlight) then
     UpdateAttrsRange(0,Min(Delta.Y+Size.Y,GetLineCount-1),
     UpdateAttrsRange(0,Min(Delta.Y+Size.Y,GetLineCount-1),
       attrAll
       attrAll
 {$ifndef TEST_PARTIAL_SYNTAX}
 {$ifndef TEST_PARTIAL_SYNTAX}
@@ -4916,10 +5005,10 @@ begin
         if Line=StartP.Y then S:=copy(S,LinePosToCharIdx(Line,StartP.X),255);
         if Line=StartP.Y then S:=copy(S,LinePosToCharIdx(Line,StartP.X),255);
       end;
       end;
     { Remove all traling spaces PM }
     { Remove all traling spaces PM }
-    if (Flags and efKeepTrailingSpaces)=0 then
+    if not IsFlagSet(efKeepTrailingSpaces) then
       While (Length(S)>0) and (S[Length(S)]=' ') do
       While (Length(S)>0) and (S[Length(S)]=' ') do
        Dec(S[0]);
        Dec(S[0]);
-    { if (Flags and efUseTabCharacters)<>0 then
+    { if FlagSet(efUseTabCharacters) then
       S:=CompressUsingTabs(S,TabSize);
       S:=CompressUsingTabs(S,TabSize);
       }
       }
     Stream^.Write(S[1],length(S));
     Stream^.Write(S[1],length(S));
@@ -5033,7 +5122,7 @@ begin
         end;
         end;
     end;
     end;
 {$I-}
 {$I-}
-  if (Flags and efBackupFiles)<>0 then
+  if IsFlagSet(efBackupFiles) then
   begin
   begin
      BAKName:=DirAndNameOf(FileName)+'.bak';
      BAKName:=DirAndNameOf(FileName)+'.bak';
      Assign(f,BAKName);
      Assign(f,BAKName);
@@ -5109,7 +5198,7 @@ begin
    cmFileNameChanged :
    cmFileNameChanged :
      if (Event.InfoPtr=nil) or (Event.InfoPtr=@Self) then
      if (Event.InfoPtr=nil) or (Event.InfoPtr=@Self) then
      begin
      begin
-       B:=(Flags and efSyntaxHighlight)<>0;
+       B:=IsFlagSet(efSyntaxHighlight);
        SH:=UseSyntaxHighlight(@Self);
        SH:=UseSyntaxHighlight(@Self);
        if SH<>B then
        if SH<>B then
          if SH then
          if SH then
@@ -5504,12 +5593,12 @@ end;
 
 
 function DefUseSyntaxHighlight(Editor: PFileEditor): boolean;
 function DefUseSyntaxHighlight(Editor: PFileEditor): boolean;
 begin
 begin
-  DefUseSyntaxHighlight:=(Editor^.Flags and efSyntaxHighlight)<>0;
+  DefUseSyntaxHighlight:=Editor^.IsFlagSet(efSyntaxHighlight);
 end;
 end;
 
 
 function DefUseTabsPattern(Editor: PFileEditor): boolean;
 function DefUseTabsPattern(Editor: PFileEditor): boolean;
 begin
 begin
-  DefUseTabsPattern:=(Editor^.Flags and efUseTabCharacters)<>0;
+  DefUseTabsPattern:=Editor^.IsFlagSet(efUseTabCharacters);
 end;
 end;
 
 
 procedure RegisterCodeEditors;
 procedure RegisterCodeEditors;
@@ -5524,7 +5613,10 @@ end;
 END.
 END.
 {
 {
   $Log$
   $Log$
-  Revision 1.79  2000-02-05 14:50:59  florian
+  Revision 1.80  2000-02-07 12:11:15  pierre
+   Gabors changes
+
+  Revision 1.79  2000/02/05 14:50:59  florian
     * applied fix from Gabor regarding the limited line length of the clipboard
     * applied fix from Gabor regarding the limited line length of the clipboard
 
 
   Revision 1.78  2000/01/28 22:20:04  pierre
   Revision 1.78  2000/01/28 22:20:04  pierre
@@ -5880,4 +5972,4 @@ END.
     + options are now written/read
     + options are now written/read
     + find and replace routines
     + find and replace routines
 
 
-}
+}