pierre 23 years ago
parent
commit
a45f4354e3
2 changed files with 63 additions and 23 deletions
  1. 55 21
      ide/wcedit.pas
  2. 8 2
      ide/weditor.pas

+ 55 - 21
ide/wcedit.pas

@@ -692,7 +692,10 @@ begin
          ((AAction=eaMoveCursor) or
          ((AAction=eaMoveCursor) or
           (AAction=eaInsertText) or
           (AAction=eaInsertText) or
           (AAction=eaOverwriteText) or
           (AAction=eaOverwriteText) or
-          (AAction=eaDeleteText))
+          (AAction=eaDeleteText)) and
+         { do not group if a new grouped_action started }
+          (not assigned(UndoList^.CurrentGroupedAction) or
+           (UndoList^.CurrentGroupedAction^.ActionCount>0))
          then
          then
         begin
         begin
           pa^.EndPos:=AEndPos;
           pa^.EndPos:=AEndPos;
@@ -1367,8 +1370,11 @@ begin
                 SetCurPtr(EndPos.X,EndPos.Y);
                 SetCurPtr(EndPos.X,EndPos.Y);
                 SetMinMax(EndPos.Y);
                 SetMinMax(EndPos.Y);
                 Had_efNoIndent:=(GetFlags and efNoIndent)<>0;
                 Had_efNoIndent:=(GetFlags and efNoIndent)<>0;
+                WasInserting:=GetInsertMode;
+                SetInsertMode(true);
                 SetFlags(GetFlags or efNoIndent);
                 SetFlags(GetFlags or efNoIndent);
                 InsertNewLine;
                 InsertNewLine;
+                SetInsertMode(WasInserting);
                 if not Had_efNoIndent then
                 if not Had_efNoIndent then
                   SetFlags(GetFlags and not efNoIndent);
                   SetFlags(GetFlags and not efNoIndent);
                 {DelEnd; wrong for eaCut at least }
                 {DelEnd; wrong for eaCut at least }
@@ -1421,9 +1427,23 @@ var
   Temp,Idx,Last,Count : Longint;
   Temp,Idx,Last,Count : Longint;
   WasInserting,Is_grouped,Had_efNoIndent : boolean;
   WasInserting,Is_grouped,Had_efNoIndent : boolean;
   Line : String;
   Line : String;
+  MaxY,MinY : sw_integer;
+  procedure SetMinMax(y : sw_integer);
+    begin
+      if MinY=-1 then
+        MinY:=Y;
+      if Y<MinY then
+        MinY:=Y;
+      if MaxY=-1 then
+        MaxY:=Y;
+      if Y>MaxY then
+        MaxY:=Y;
+    end;
 begin
 begin
   Core^.SetStoreUndo(False);
   Core^.SetStoreUndo(False);
   Lock;
   Lock;
+  MinY:=-1;
+  MaxY:=-1;
   if Core^.RedoList^.count <> 0 then
   if Core^.RedoList^.count <> 0 then
    begin
    begin
     Last:=Core^.RedoList^.count-1;
     Last:=Core^.RedoList^.count-1;
@@ -1451,42 +1471,49 @@ begin
           begin
           begin
             SetCurPtr(startpos.x,startpos.y);
             SetCurPtr(startpos.x,startpos.y);
             InsertText(GetStr(Text));
             InsertText(GetStr(Text));
+            SetMinMax(StartPos.Y);
           end;
           end;
         eaDeleteText :
         eaDeleteText :
           begin
           begin
             SetCurPtr(EndPos.X,EndPos.Y);
             SetCurPtr(EndPos.X,EndPos.Y);
             for Temp := 1 to length(GetStr(Text)) do
             for Temp := 1 to length(GetStr(Text)) do
               DelChar;
               DelChar;
+            SetMinMax(EndPos.Y);
+          end;
+        eaOverwriteText :
+          begin
+            SetCurPtr(StartPos.X,StartPos.Y);
+            Line:=GetDisplayText(StartPos.Y);
+            WasInserting:=GetInsertMode;
+            SetInsertMode(false);
+            if assigned(text) then
+              for Temp := 1 to length(Text^) do
+                begin
+                  AddChar(Text^[Temp]);
+                  if StartPos.X+Temp>Length(Line) then
+                    Text^[Temp]:=' '
+                  else
+                    Text^[Temp]:=Line[StartPos.X+Temp];
+                end;
+            SetInsertMode(WasInserting);
+            SetCurPtr(EndPos.X,EndPos.Y);
+            SetMinMax(StartPos.Y);
           end;
           end;
-            eaOverwriteText :
-              begin
-                SetCurPtr(StartPos.X,StartPos.Y);
-                Line:=GetDisplayText(StartPos.Y);
-                WasInserting:=GetInsertMode;
-                SetInsertMode(false);
-                if assigned(text) then
-                  for Temp := 1 to length(Text^) do
-                    begin
-                      AddChar(Text^[Temp]);
-                      if StartPos.X+Temp>Length(Line) then
-                        Text^[Temp]:=' '
-                      else
-                        Text^[Temp]:=Line[StartPos.X+Temp];
-                    end;
-                SetInsertMode(WasInserting);
-                SetCurPtr(EndPos.X,EndPos.Y);
-              end;
         eaInsertLine :
         eaInsertLine :
           begin
           begin
             SetCurPtr(StartPos.X,StartPos.Y);
             SetCurPtr(StartPos.X,StartPos.Y);
             Had_efNoIndent:=(GetFlags and efNoIndent)<>0;
             Had_efNoIndent:=(GetFlags and efNoIndent)<>0;
             SetFlags(GetFlags or efNoIndent);
             SetFlags(GetFlags or efNoIndent);
+            WasInserting:=GetInsertMode;
+            SetInsertMode(false);
             InsertNewLine;
             InsertNewLine;
+            SetInsertMode(WasInserting);
             SetCurPtr(StartPos.X,StartPos.Y);
             SetCurPtr(StartPos.X,StartPos.Y);
             InsertText(GetStr(Text));
             InsertText(GetStr(Text));
             if not Had_efNoIndent then
             if not Had_efNoIndent then
               SetFlags(GetFlags and not efNoIndent);
               SetFlags(GetFlags and not efNoIndent);
             SetCurPtr(EndPos.X,EndPos.Y);
             SetCurPtr(EndPos.X,EndPos.Y);
+            SetMinMax(StartPos.Y);
           end;
           end;
         eaDeleteLine :
         eaDeleteLine :
           begin
           begin
@@ -1498,6 +1525,8 @@ begin
               copy(GetDisplayText(EndPos.Y),1,EndPos.X),EndPos.X)
               copy(GetDisplayText(EndPos.Y),1,EndPos.X),EndPos.X)
               +GetStr(Text));
               +GetStr(Text));
             SetCurPtr(EndPos.X,EndPos.Y);
             SetCurPtr(EndPos.X,EndPos.Y);
+            SetMinMax(StartPos.Y);
+            SetMinMax(EndPos.Y);
           end;
           end;
         eaSelectionChanged :
         eaSelectionChanged :
           begin
           begin
@@ -1530,8 +1559,10 @@ begin
       if Core^.RedoList^.count=0 then
       if Core^.RedoList^.count=0 then
         SetCmdState(RedoCmd,false);
         SetCmdState(RedoCmd,false);
       SetCmdState(UndoCmd,true);
       SetCmdState(UndoCmd,true);
-      DrawView;
       Message(Application,evBroadcast,cmCommandSetChanged,nil);
       Message(Application,evBroadcast,cmCommandSetChanged,nil);
+      if MinY<>-1 then
+        UpdateAttrsRange(MinY,MaxY,attrAll);
+      DrawView;
     end;
     end;
   Core^.SetStoreUndo(True);
   Core^.SetStoreUndo(True);
   Unlock;
   Unlock;
@@ -2006,7 +2037,10 @@ end;
 END.
 END.
 {
 {
  $Log$
  $Log$
- Revision 1.6  2001-10-10 23:34:54  pierre
+ Revision 1.7  2002-01-25 14:15:35  pierre
+  * fix bug 1774
+
+ Revision 1.6  2001/10/10 23:34:54  pierre
   * fix bug 1632
   * fix bug 1632
 
 
  Revision 1.5  2001/09/27 22:32:24  pierre
  Revision 1.5  2001/09/27 22:32:24  pierre

+ 8 - 2
ide/weditor.pas

@@ -4750,7 +4750,10 @@ begin
           EI^.Fold^.Collapse(false);
           EI^.Fold^.Collapse(false);
     end;
     end;
      SetStoreUndo(HoldUndo);
      SetStoreUndo(HoldUndo);
-     Addaction(eaInsertLine,SCP,CurPos,IndentStr);
+     if not overwrite then
+       Addaction(eaInsertLine,SCP,CurPos,IndentStr)
+     else
+       AddAction(eaMoveCursor,SCP,CurPos,'');
      SetStoreUndo(false);
      SetStoreUndo(false);
     AdjustSelection(CurPos.X-SCP.X,CurPos.Y-SCP.Y);
     AdjustSelection(CurPos.X-SCP.X,CurPos.Y-SCP.Y);
   end else
   end else
@@ -7093,7 +7096,10 @@ end;
 END.
 END.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2001-11-07 00:18:00  pierre
+  Revision 1.17  2002-01-25 14:15:35  pierre
+   * fix bug 1774
+
+  Revision 1.16  2001/11/07 00:18:00  pierre
    * avoid problem to compile ide with debug for linux
    * avoid problem to compile ide with debug for linux
 
 
   Revision 1.15  2001/10/02 22:43:22  pierre
   Revision 1.15  2001/10/02 22:43:22  pierre