From a45f4354e3358847c9e92e84ddc2a69ea0a17a77 Mon Sep 17 00:00:00 2001 From: pierre Date: Fri, 25 Jan 2002 14:15:35 +0000 Subject: [PATCH] * fix bug #1774 --- ide/wcedit.pas | 76 +++++++++++++++++++++++++++++++++++-------------- ide/weditor.pas | 10 +++++-- 2 files changed, 63 insertions(+), 23 deletions(-) diff --git a/ide/wcedit.pas b/ide/wcedit.pas index 4c9c5b3c49..465b5fa6df 100644 --- a/ide/wcedit.pas +++ b/ide/wcedit.pas @@ -692,7 +692,10 @@ begin ((AAction=eaMoveCursor) or (AAction=eaInsertText) 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 begin pa^.EndPos:=AEndPos; @@ -1367,8 +1370,11 @@ begin SetCurPtr(EndPos.X,EndPos.Y); SetMinMax(EndPos.Y); Had_efNoIndent:=(GetFlags and efNoIndent)<>0; + WasInserting:=GetInsertMode; + SetInsertMode(true); SetFlags(GetFlags or efNoIndent); InsertNewLine; + SetInsertMode(WasInserting); if not Had_efNoIndent then SetFlags(GetFlags and not efNoIndent); {DelEnd; wrong for eaCut at least } @@ -1421,9 +1427,23 @@ var Temp,Idx,Last,Count : Longint; WasInserting,Is_grouped,Had_efNoIndent : boolean; Line : String; + MaxY,MinY : sw_integer; + procedure SetMinMax(y : sw_integer); + begin + if MinY=-1 then + MinY:=Y; + if YMaxY then + MaxY:=Y; + end; begin Core^.SetStoreUndo(False); Lock; + MinY:=-1; + MaxY:=-1; if Core^.RedoList^.count <> 0 then begin Last:=Core^.RedoList^.count-1; @@ -1451,42 +1471,49 @@ begin begin SetCurPtr(startpos.x,startpos.y); InsertText(GetStr(Text)); + SetMinMax(StartPos.Y); end; eaDeleteText : begin SetCurPtr(EndPos.X,EndPos.Y); for Temp := 1 to length(GetStr(Text)) do 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; - 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 : begin SetCurPtr(StartPos.X,StartPos.Y); Had_efNoIndent:=(GetFlags and efNoIndent)<>0; SetFlags(GetFlags or efNoIndent); + WasInserting:=GetInsertMode; + SetInsertMode(false); InsertNewLine; + SetInsertMode(WasInserting); SetCurPtr(StartPos.X,StartPos.Y); InsertText(GetStr(Text)); if not Had_efNoIndent then SetFlags(GetFlags and not efNoIndent); SetCurPtr(EndPos.X,EndPos.Y); + SetMinMax(StartPos.Y); end; eaDeleteLine : begin @@ -1498,6 +1525,8 @@ begin copy(GetDisplayText(EndPos.Y),1,EndPos.X),EndPos.X) +GetStr(Text)); SetCurPtr(EndPos.X,EndPos.Y); + SetMinMax(StartPos.Y); + SetMinMax(EndPos.Y); end; eaSelectionChanged : begin @@ -1530,8 +1559,10 @@ begin if Core^.RedoList^.count=0 then SetCmdState(RedoCmd,false); SetCmdState(UndoCmd,true); - DrawView; Message(Application,evBroadcast,cmCommandSetChanged,nil); + if MinY<>-1 then + UpdateAttrsRange(MinY,MaxY,attrAll); + DrawView; end; Core^.SetStoreUndo(True); Unlock; @@ -2006,7 +2037,10 @@ end; END. { $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 Revision 1.5 2001/09/27 22:32:24 pierre diff --git a/ide/weditor.pas b/ide/weditor.pas index 521f1dff86..9fb940aebb 100644 --- a/ide/weditor.pas +++ b/ide/weditor.pas @@ -4750,7 +4750,10 @@ begin EI^.Fold^.Collapse(false); end; SetStoreUndo(HoldUndo); - Addaction(eaInsertLine,SCP,CurPos,IndentStr); + if not overwrite then + Addaction(eaInsertLine,SCP,CurPos,IndentStr) + else + AddAction(eaMoveCursor,SCP,CurPos,''); SetStoreUndo(false); AdjustSelection(CurPos.X-SCP.X,CurPos.Y-SCP.Y); end else @@ -7093,7 +7096,10 @@ end; END. { $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 Revision 1.15 2001/10/02 22:43:22 pierre