From a24f6b27c2b503f617f0cf73a2e2e7f4c322650e Mon Sep 17 00:00:00 2001 From: pierre Date: Mon, 16 Dec 2002 15:16:15 +0000 Subject: [PATCH] * try to fix the moving of breakpoints --- ide/fpviews.pas | 177 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 172 insertions(+), 5 deletions(-) diff --git a/ide/fpviews.pas b/ide/fpviews.pas index 2168a8eb6e..e3b19a9ee2 100644 --- a/ide/fpviews.pas +++ b/ide/fpviews.pas @@ -131,10 +131,11 @@ type TSourceEditor = object(TFileEditor) constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar; AIndicator: PIndicator;const AFileName: string); - public CompileStamp : longint; - public CodeCompleteTip: PFPToolTip; + private + ShouldHandleBreakpoints : boolean; + public { Syntax highlight } function IsReservedWord(const S: string): boolean; virtual; function IsAsmReservedWord(const S: string): boolean; virtual; @@ -163,6 +164,10 @@ type procedure PushInfo(Const st : string);virtual; procedure PopInfo;virtual; procedure DeleteLine(I: sw_integer); virtual; + procedure BackSpace; virtual; + procedure DelChar; virtual; + procedure DelSelect; virtual; + function InsertNewLine : Sw_integer;virtual; function InsertLine(LineNo: sw_integer; const S: string): PCustomLine; virtual; procedure AddLine(const S: string); virtual; end; @@ -1459,13 +1464,172 @@ end; procedure TSourceEditor.DeleteLine(I: sw_integer); begin inherited DeleteLine(I); - BreakpointsCollection^.AdaptBreakpoints(@Self,I,-1); + If ShouldHandleBreakpoints then + BreakpointsCollection^.AdaptBreakpoints(@Self,I,-1); end; +procedure TSourceEditor.BackSpace; +var + MoveBreakpointToPreviousLine,WasEnabled : boolean; + PBStart,PBEnd : PBreakpoint; + I : longint; +begin + MoveBreakpointToPreviousLine:=(CurPos.X=0) and (CurPos.Y>0); + If MoveBreakpointToPreviousLine then + begin + ShouldHandleBreakpoints:=false; + I:=CurPos.Y+1; + PBEnd:=BreakpointsCollection^.FindBreakpointAt(@Self,I); + PBStart:=BreakpointsCollection^.FindBreakpointAt(@Self,I-1); + end; + inherited Backspace; + if MoveBreakpointToPreviousLine then + begin + ShouldHandleBreakpoints:=true; + if assigned(PBEnd) then + begin + if assigned(PBStart) then + begin + if PBEnd^.state=bs_enabled then + PBStart^.state:=bs_enabled; + BreakpointsCollection^.Free(PBEnd); + end + else + begin + WasEnabled:=PBEnd^.state=bs_enabled; + if WasEnabled then + begin + PBEnd^.state:=bs_disabled; + PBEnd^.UpdateSource; + end; + PBEnd^.line:=I-1; + if WasEnabled then + begin + PBEnd^.state:=bs_enabled; + PBEnd^.UpdateSource; + end; + end; + end; + BreakpointsCollection^.AdaptBreakpoints(@Self,I,-1); + end; +end; + +function TSourceEditor.InsertNewLine : Sw_integer; +var + MoveBreakpointToNextLine : boolean; + I : longint; +begin + ShouldHandleBreakpoints:=false; + MoveBreakpointToNextLine:=Cursor.xlength(S)) or (S='')) and (CurPos.Y0; + PBEnd:=BreakpointsCollection^.FindBreakpointAt(@Self,SelEnd.Y); + PBStart:=BreakpointsCollection^.FindBreakpointAt(@Self,SelEnd.Y); + + I:=SelStart.Y; + inherited DelSelect; + if MoveBreakpointToFirstLine and assigned(PBEnd) then + begin + If assigned(PBStart) then + begin + if PBEnd^.state=bs_enabled then + PBStart^.state:=bs_enabled; + BreakpointsCollection^.Free(PBEnd); + end + else + begin + WasEnabled:=PBEnd^.state=bs_enabled; + if WasEnabled then + begin + PBEnd^.state:=bs_disabled; + PBEnd^.UpdateSource; + end; + PBEnd^.line:=I; + if WasEnabled then + begin + PBEnd^.state:=bs_enabled; + PBEnd^.UpdateSource; + end; + end; + end; + BreakpointsCollection^.AdaptBreakpoints(@Self,I,-J); + ShouldHandleBreakpoints:=true; +end; + + function TSourceEditor.InsertLine(LineNo: sw_integer; const S: string): PCustomLine; begin InsertLine := inherited InsertLine(LineNo,S); - BreakpointsCollection^.AdaptBreakpoints(@Self,LineNo,1); + If ShouldHandleBreakpoints then + BreakpointsCollection^.AdaptBreakpoints(@Self,LineNo,1); end; procedure TSourceEditor.AddLine(const S: string); @@ -4395,7 +4559,10 @@ end; END. { $Log$ - Revision 1.38 2002-12-12 00:09:08 pierre + Revision 1.39 2002-12-16 15:16:15 pierre + * try to fix the moving of breakpoints + + Revision 1.38 2002/12/12 00:09:08 pierre * move line breakpoints if lines added or deleted in editor window Revision 1.37 2002/11/30 01:56:52 pierre