mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 18:36:10 +02:00
implemented breakpoints hints for source editor
git-svn-id: trunk@4232 -
This commit is contained in:
parent
12839a8385
commit
80d74a8fe7
@ -108,10 +108,45 @@ type
|
||||
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
|
||||
property BreakPoints: TIDEBreakPoints read FBreakPoints write SetBreakPoints;
|
||||
end;
|
||||
|
||||
function GetBreakPointStateDescription(ABreakpoint: TBaseBreakpoint): string;
|
||||
function GetBreakPointActionsDescription(ABreakpoint: TBaseBreakpoint): string;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
function GetBreakPointStateDescription(ABreakpoint: TBaseBreakpoint): string;
|
||||
const
|
||||
// enabled valid
|
||||
DEBUG_STATE: array[Boolean, TValidState] of String = (
|
||||
{vsUnknown, vsValid, vsInvalid}
|
||||
{Disabled} ('? (Off)','Disabled','Invalid (Off)'),
|
||||
{Endabled} ('? (On)', 'Enabled', 'Invalid (On)'));
|
||||
begin
|
||||
Result:=DEBUG_STATE[ABreakpoint.Enabled,ABreakpoint.Valid];
|
||||
end;
|
||||
|
||||
function GetBreakPointActionsDescription(ABreakpoint: TBaseBreakpoint): string;
|
||||
const
|
||||
DEBUG_ACTION: array[TIDEBreakPointAction] of string =
|
||||
('Break', 'Enable Group', 'Disable Group');
|
||||
|
||||
var
|
||||
CurBreakPoint: TIDEBreakPoint;
|
||||
Action: TIDEBreakPointAction;
|
||||
begin
|
||||
Result := '';
|
||||
if ABreakpoint is TIDEBreakPoint then begin
|
||||
CurBreakPoint:=TIDEBreakPoint(ABreakpoint);
|
||||
for Action := Low(Action) to High(Action) do
|
||||
if Action in CurBreakpoint.Actions
|
||||
then begin
|
||||
if Result <> '' then Result := Result + ', ';
|
||||
Result := Result + DEBUG_ACTION[Action]
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBreakPointsDlg.BreakPointAdd(const ASender: TIDEBreakPoints;
|
||||
const ABreakpoint: TIDEBreakPoint);
|
||||
var
|
||||
@ -408,18 +443,7 @@ end;
|
||||
|
||||
procedure TBreakPointsDlg.UpdateItem(const AnItem: TListItem;
|
||||
const ABreakpoint: TIDEBreakPoint);
|
||||
const
|
||||
DEBUG_ACTION: array[TIDEBreakPointAction] of string =
|
||||
('Break', 'Enable Group', 'Disable Group');
|
||||
|
||||
// enabled valid
|
||||
DEBUG_STATE: array[Boolean, TValidState] of String = (
|
||||
{vsUnknown, vsValid, vsInvalid}
|
||||
{Disabled} ('? (Off)','Disabled','Invalid (Off)'),
|
||||
{Endabled} ('? (On)', 'Enabled', 'Invalid (On)'));
|
||||
var
|
||||
Action: TIDEBreakPointAction;
|
||||
S: String;
|
||||
Filename: String;
|
||||
begin
|
||||
// Filename/Address
|
||||
@ -430,7 +454,7 @@ begin
|
||||
// Group
|
||||
|
||||
// state
|
||||
AnItem.Caption := DEBUG_STATE[ABreakpoint.Enabled, ABreakpoint.Valid];
|
||||
AnItem.Caption := GetBreakPointStateDescription(ABreakpoint);
|
||||
|
||||
// filename
|
||||
Filename:=ABreakpoint.Source;
|
||||
@ -447,14 +471,7 @@ begin
|
||||
AnItem.SubItems[2] := ABreakpoint.Expression;
|
||||
|
||||
// actions
|
||||
S := '';
|
||||
for Action := Low(Action) to High(Action) do
|
||||
if Action in ABreakpoint.Actions
|
||||
then begin
|
||||
if S <> '' then s := S + ', ';
|
||||
S := S + DEBUG_ACTION[Action]
|
||||
end;
|
||||
AnItem.SubItems[3] := S;
|
||||
AnItem.SubItems[3] := GetBreakPointActionsDescription(ABreakpoint);
|
||||
|
||||
// hitcount
|
||||
AnItem.SubItems[4] := IntToStr(ABreakpoint.HitCount);
|
||||
@ -489,6 +506,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.20 2003/06/04 13:34:58 mattias
|
||||
implemented breakpoints hints for source editor
|
||||
|
||||
Revision 1.19 2003/06/03 11:20:12 mattias
|
||||
implemented enable/disable/delete breakpoints in same source
|
||||
|
||||
|
@ -171,6 +171,7 @@ type
|
||||
procedure SetSourceMark(const AValue: TSourceMark);
|
||||
procedure OnSourceMarkPositionChanged(Sender: TObject);
|
||||
procedure OnSourceMarkBeforeFree(Sender: TObject);
|
||||
procedure OnSourceMarkGetHint(SenderMark: TSourceMark; var Hint: string);
|
||||
protected
|
||||
procedure AssignTo(Dest: TPersistent); override;
|
||||
procedure DoChanged; override;
|
||||
@ -249,6 +250,7 @@ begin
|
||||
FSourceMark.IsBreakPoint:=true;
|
||||
FSourceMark.Line:=Line;
|
||||
FSourceMark.Visible:=true;
|
||||
FSourceMark.AddGetHintHandler(@OnSourceMarkGetHint);
|
||||
UpdateSourceMark;
|
||||
end;
|
||||
end;
|
||||
@ -263,6 +265,15 @@ begin
|
||||
SourceMark:=nil;
|
||||
end;
|
||||
|
||||
procedure TManagedBreakPoint.OnSourceMarkGetHint(SenderMark: TSourceMark;
|
||||
var Hint: string);
|
||||
begin
|
||||
Hint:=GetBreakPointStateDescription(Self)+EndOfLine
|
||||
+'Hitcount: '+IntToStr(Hitcount)+EndOfLine
|
||||
+'Action: '+GetBreakPointActionsDescription(Self)+EndOfLine
|
||||
+'Condition: '+Expression;
|
||||
end;
|
||||
|
||||
procedure TManagedBreakPoint.AssignTo(Dest: TPersistent);
|
||||
begin
|
||||
inherited AssignTo(Dest);
|
||||
@ -1364,6 +1375,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.46 2003/06/04 13:34:58 mattias
|
||||
implemented breakpoints hints for source editor
|
||||
|
||||
Revision 1.45 2003/06/04 12:44:55 mattias
|
||||
implemented setting breakpoint while compiling
|
||||
|
||||
|
@ -161,6 +161,7 @@ type
|
||||
fUndoAfterSave:boolean;
|
||||
fUseSyntaxHighlight:boolean;
|
||||
FCopyWordAtCursorOnCopyNone: boolean;
|
||||
FShowGutterHints: boolean;
|
||||
fBlockIndent:integer;
|
||||
fUndoLimit:integer;
|
||||
fTabWidth:integer;
|
||||
@ -192,7 +193,6 @@ type
|
||||
fAutoDelayInMSec:integer;
|
||||
fCodeTemplateFileName:Ansistring;
|
||||
fCTemplIndentToTokenStart: boolean;
|
||||
procedure SetCopyWordAtCursorOnCopyNone(const AValue: boolean);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -235,7 +235,8 @@ type
|
||||
property UseSyntaxHighlight:boolean
|
||||
read fUseSyntaxHighlight write fUseSyntaxHighlight default true;
|
||||
property CopyWordAtCursorOnCopyNone: boolean read FCopyWordAtCursorOnCopyNone
|
||||
write SetCopyWordAtCursorOnCopyNone;
|
||||
write FCopyWordAtCursorOnCopyNone;
|
||||
property ShowGutterHints: boolean read FShowGutterHints write FShowGutterHints;
|
||||
property BlockIndent:integer read fBlockIndent write fBlockIndent default 2;
|
||||
property UndoLimit:integer read fUndoLimit write fUndoLimit default 32767;
|
||||
property TabWidth:integer read fTabWidth write fTabWidth default 8;
|
||||
@ -333,6 +334,7 @@ type
|
||||
FindTextAtCursorCheckBox:TCheckBox;
|
||||
UseSyntaxHighlightCheckBox:TCheckBox;
|
||||
CopyWordAtCursorOnCopyNoneCheckBox:TCheckBox;
|
||||
ShowGutterHintsCheckBox:TCheckBox;
|
||||
MouseLinksCheckBox: TCheckBox;
|
||||
BlockIndentComboBox:TComboBox;
|
||||
BlockIndentLabel:TLabel;
|
||||
@ -1041,12 +1043,6 @@ end;
|
||||
|
||||
{ TEditorOptions }
|
||||
|
||||
procedure TEditorOptions.SetCopyWordAtCursorOnCopyNone(const AValue: boolean);
|
||||
begin
|
||||
if FCopyWordAtCursorOnCopyNone=AValue then exit;
|
||||
FCopyWordAtCursorOnCopyNone:=AValue;
|
||||
end;
|
||||
|
||||
constructor TEditorOptions.Create;
|
||||
var ConfFileName: string;
|
||||
fs:TFileStream;
|
||||
@ -1073,6 +1069,7 @@ begin
|
||||
fCtrlMouseLinks:=true;
|
||||
fShowTabCloseButtons:=true;
|
||||
FCopyWordAtCursorOnCopyNone:=true;
|
||||
FShowGutterHints:=true;
|
||||
fBlockIndent:=2;
|
||||
fUndoLimit:=32767;
|
||||
fTabWidth:=8;
|
||||
@ -1162,6 +1159,8 @@ begin
|
||||
XMLConfig.GetValue('EditorOptions/General/Editor/ShowTabCloseButtons',true);
|
||||
FCopyWordAtCursorOnCopyNone:=
|
||||
XMLConfig.GetValue('EditorOptions/General/Editor/CopyWordAtCursorOnCopyNone',true);
|
||||
FShowGutterHints:=
|
||||
XMLConfig.GetValue('EditorOptions/General/Editor/ShowGutterHints',true);
|
||||
fUndoAfterSave:=
|
||||
XMLConfig.GetValue('EditorOptions/General/Editor/UndoAfterSave',true);
|
||||
fFindTextAtCursor:=
|
||||
@ -1282,6 +1281,9 @@ begin
|
||||
XMLConfig.SetDeleteValue(
|
||||
'EditorOptions/General/Editor/CopyWordAtCursorOnCopyNone',
|
||||
FCopyWordAtCursorOnCopyNone,true);
|
||||
XMLConfig.SetDeleteValue(
|
||||
'EditorOptions/General/Editor/ShowGutterHints',
|
||||
FShowGutterHints,true);
|
||||
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/UndoAfterSave'
|
||||
,fUndoAfterSave,true);
|
||||
XMLConfig.SetDeleteValue('EditorOptions/General/Editor/FindTextAtCursor'
|
||||
@ -3204,7 +3206,7 @@ begin
|
||||
Top:=5;
|
||||
Left:=5;
|
||||
Width:=MaxX-10;
|
||||
Height:=24*11; // 24 pixels per line
|
||||
Height:=24*12; // 24 pixels per line
|
||||
Caption:=lismenueditoroptions;
|
||||
end;
|
||||
|
||||
@ -3354,6 +3356,18 @@ begin
|
||||
Checked:=EditorOpts.CtrlMouseLinks;
|
||||
end;
|
||||
|
||||
ShowGutterHintsCheckBox:=TCheckBox.Create(Self);
|
||||
with ShowGutterHintsCheckBox do begin
|
||||
Name:='ShowGutterHintsCheckBox';
|
||||
Parent:=EditorOptionsGroupBox;
|
||||
Top:=MouseLinksCheckBox.Top+MouseLinksCheckBox.Height+5;
|
||||
Left:=MouseLinksCheckBox.Left;
|
||||
Width:=ChkBoxW;
|
||||
Height:=AltSetsColumnModeCheckBox.Height;
|
||||
Caption:=dlgShowGutterHints;
|
||||
Checked:=EditorOpts.ShowGutterHints;
|
||||
end;
|
||||
|
||||
// right side
|
||||
ScrollPastEoLCheckBox:=TCheckBox.Create(Self);
|
||||
with ScrollPastEoLCheckBox do begin
|
||||
@ -3598,7 +3612,7 @@ begin
|
||||
Top:=5;
|
||||
Left:=5;
|
||||
Width:=MaxX-10;
|
||||
Height:=24*11; // 24 pixels per option
|
||||
Height:=21*12+31; // 21 pixels per option
|
||||
end;
|
||||
|
||||
// many, many checkboxes ...
|
||||
@ -3680,6 +3694,13 @@ begin
|
||||
Height:=AltSetsColumnModeCheckBox.Height;
|
||||
end;
|
||||
|
||||
with ShowGutterHintsCheckBox do begin
|
||||
Top:=MouseLinksCheckBox.Top+MouseLinksCheckBox.Height+5;
|
||||
Left:=AltSetsColumnModeCheckBox.Left;
|
||||
Width:=ChkBoxW;
|
||||
Height:=AltSetsColumnModeCheckBox.Height;
|
||||
end;
|
||||
|
||||
// right side
|
||||
|
||||
with ScrollPastEoLCheckBox do begin
|
||||
@ -3774,20 +3795,8 @@ begin
|
||||
Width:=BlockIndentComboBox.Left-2-Left;
|
||||
end;
|
||||
|
||||
with UndoLimitComboBox do begin
|
||||
Top:=BlockIndentComboBox.Top+BlockIndentComboBox.Height+5;
|
||||
Left:=BlockIndentComboBox.Left;
|
||||
Width:=70;
|
||||
end;
|
||||
|
||||
with UndoLimitLabel do begin
|
||||
Top:=UndoLimitComboBox.Top+2;
|
||||
Left:=EditorOptionsGroupBox.Left+2;
|
||||
Width:=UndoLimitComboBox.Left-Left-2;
|
||||
end;
|
||||
|
||||
with TabWidthsComboBox do begin
|
||||
Top:=UndoLimitComboBox.Top+UndoLimitComboBox.Height+5;
|
||||
Top:=BlockIndentComboBox.Top+BlockIndentComboBox.Height+5;
|
||||
Left:=BlockIndentComboBox.Left;
|
||||
Width:=70;
|
||||
end;
|
||||
@ -3797,6 +3806,18 @@ begin
|
||||
Left:=EditorOptionsGroupBox.Left+2;
|
||||
Width:=TabWidthsComboBox.Left-Left-2;
|
||||
end;
|
||||
|
||||
with UndoLimitComboBox do begin
|
||||
Top:=BlockIndentComboBox.Top;
|
||||
Left:=BlockIndentComboBox.Left+BlockIndentComboBox.Width+50+70;
|
||||
Width:=70;
|
||||
end;
|
||||
|
||||
with UndoLimitLabel do begin
|
||||
Top:=UndoLimitComboBox.Top+2;
|
||||
Left:=UndoLimitComboBox.Left-70+2;
|
||||
Width:=UndoLimitComboBox.Left-Left-2;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEditorOptionsForm.SetupDisplayPage;
|
||||
@ -5245,6 +5266,7 @@ begin
|
||||
EditorOpts.UndoAfterSave:=UndoAfterSaveCheckBox.Checked;
|
||||
EditorOpts.CopyWordAtCursorOnCopyNone:=
|
||||
CopyWordAtCursorOnCopyNoneCheckBox.Checked;
|
||||
EditorOpts.ShowGutterHints:=ShowGutterHintsCheckBox.Checked;
|
||||
EditorOpts.FindTextAtCursor:=FindTextAtCursorCheckBox.Checked;
|
||||
EditorOpts.UseSyntaxHighlight:=UseSyntaxHighlightCheckBox.Checked;
|
||||
EditorOpts.CtrlMouseLinks:=MouseLinksCheckBox.Checked;
|
||||
|
@ -651,6 +651,7 @@ resourcestring
|
||||
dlgCloseButtonsNotebook = 'Show Close Buttons in notebook';
|
||||
dlgShowScrollHint = 'Show Scroll Hint';
|
||||
dlgMouseLinks = 'Mouse links';
|
||||
dlgShowGutterHints = 'Show Gutter Hints';
|
||||
dlgSmartTabs = 'Smart Tabs';
|
||||
dlgTabsToSpaces = 'Tabs To Spaces';
|
||||
dlgTrimTrailingSpaces = 'Trim Trailing Spaces';
|
||||
|
@ -43,15 +43,19 @@ uses
|
||||
|
||||
type
|
||||
TSourceMarks = class;
|
||||
|
||||
|
||||
TSourceMark = class;
|
||||
|
||||
{ TSourceMark }
|
||||
|
||||
TGetSourceMarkHintEvent =
|
||||
procedure(SenderMark: TSourceMark; var Hint: string) of object;
|
||||
|
||||
TSourceMarkHandler = (
|
||||
smhPositionChanged,
|
||||
smhBeforeFree
|
||||
smhBeforeFree,
|
||||
smhGetHint
|
||||
);
|
||||
|
||||
|
||||
TSourceMark = class(TSynEditMark)
|
||||
private
|
||||
FData: TObject;
|
||||
@ -86,6 +90,7 @@ type
|
||||
function CompareEditorAndLine(ASynEdit: TCustomSynEdit;
|
||||
ALine: integer): integer;
|
||||
function GetFilename: string;
|
||||
function GetHint: string; virtual;
|
||||
public
|
||||
// handlers
|
||||
procedure RemoveAllHandlersForObject(HandlerObject: TObject);
|
||||
@ -93,6 +98,8 @@ type
|
||||
procedure RemovePositionChangedHandler(OnPositionChanged: TNotifyEvent);
|
||||
procedure AddBeforeFreeHandler(OnBeforeFree: TNotifyEvent);
|
||||
procedure RemoveBeforeFreeHandler(OnBeforeFree: TNotifyEvent);
|
||||
procedure AddGetHintHandler(OnGetHint: TGetSourceMarkHintEvent);
|
||||
procedure RemoveGetHintHandler(OnGetHint: TGetSourceMarkHintEvent);
|
||||
public
|
||||
// properties
|
||||
property Data: TObject read FData write SetData;
|
||||
@ -363,6 +370,16 @@ begin
|
||||
Result:=FSourceMarks.GetFilename(Self);
|
||||
end;
|
||||
|
||||
function TSourceMark.GetHint: string;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:='';
|
||||
i:=FHandlers[smhGetHint].Count;
|
||||
while FHandlers[smhGetHint].NextDownIndex(i) do
|
||||
TGetSourceMarkHintEvent(FHandlers[smhGetHint][i])(Self,Result);
|
||||
end;
|
||||
|
||||
procedure TSourceMark.RemoveAllHandlersForObject(HandlerObject: TObject);
|
||||
var
|
||||
HandlerType: TSourceMarkHandler;
|
||||
@ -394,6 +411,16 @@ begin
|
||||
FHandlers[smhBeforeFree].Remove(TMethod(OnBeforeFree));
|
||||
end;
|
||||
|
||||
procedure TSourceMark.AddGetHintHandler(OnGetHint: TGetSourceMarkHintEvent);
|
||||
begin
|
||||
AddHandler(smhGetHint,TMethod(OnGetHint));
|
||||
end;
|
||||
|
||||
procedure TSourceMark.RemoveGetHintHandler(OnGetHint: TGetSourceMarkHintEvent);
|
||||
begin
|
||||
FHandlers[smhGetHint].Remove(TMethod(OnGetHint));
|
||||
end;
|
||||
|
||||
{ TSourceMarks }
|
||||
|
||||
function TSourceMarks.GetItems(Index: integer): TSourceMark;
|
||||
|
Loading…
Reference in New Issue
Block a user