Added a watch dialog.

Shane

git-svn-id: trunk@488 -
This commit is contained in:
lazarus 2001-12-07 20:12:15 +00:00
parent 7f0e94c70e
commit 8747750b3d
9 changed files with 451 additions and 57 deletions

1
.gitattributes vendored
View File

@ -143,6 +143,7 @@ ide/viewforms1.lrs svneol=native#text/pascal
ide/viewunit_dlg.lfm svneol=native#text/plain
ide/viewunit_dlg.pp svneol=native#text/pascal
ide/viewunits1.lrs svneol=native#text/pascal
ide/watchesdlg.pp svneol=native#text/pascal
ide/wordcompletion.pp svneol=native#text/pascal
images/bookmark.lrs svneol=native#text/pascal
images/btn_downarrow.ico -text svneol=unset#image/x-icon

View File

@ -39,7 +39,8 @@ uses
Main,
MsgView,
FindReplaceDialog,
FindInFilesDlg;
FindInFilesDlg,
WatchesDlg;
begin
Application.Initialize;
@ -57,6 +58,7 @@ begin
CheckHeap('TMainIDE created');
{$ENDIF}
Application.CreateForm(TMessagesView, MessagesView);
Application.CreateForm(TWatchesDlg, Watches_Dlg);
Application.CreateForm(TLazFindReplaceDialog, FindReplaceDlg);
Application.CreateForm(TLazFindInFilesDialog, FindInFilesDialog);
SplashForm.StartTimer;
@ -69,6 +71,10 @@ end.
{
$Log$
Revision 1.25 2001/12/07 20:12:13 lazarus
Added a watch dialog.
Shane
Revision 1.24 2001/11/06 16:42:23 lazarus
MG: added facade for find in files

View File

@ -40,7 +40,7 @@ uses
PropEdits, ControlSelection, UnitEditor, CompilerOptions, EditorOptions,
EnvironmentOpts, TransferMacros, KeyMapping, ProjectOpts, IDEProcs, Process,
UnitInfoDlg, Debugger, RunParamsOpts, ExtToolDialog, MacroPromptDlg,
LMessages, ProjectDefs;
LMessages, ProjectDefs,Watchesdlg;
const
Version_String = '0.8.1 alpha';
@ -121,6 +121,7 @@ type
itmViewForms : TMenuItem;
itmViewFile : TMenuItem;
itmViewMessage : TMenuItem;
itmViewwatches : TMenuItem;
itmProjectNew: TMenuItem;
itmProjectOpen: TMenuItem;
@ -176,6 +177,7 @@ type
Procedure mnuViewFormsClicked(Sender : TObject);
procedure mnuViewCodeExplorerClick(Sender : TObject);
procedure mnuViewMessagesClick(Sender : TObject);
procedure mnuViewWatchesClick(Sender : TObject);
procedure MessageViewDblClick(Sender : TObject);
procedure mnuToggleFormUnitClicked(Sender : TObject);
@ -231,6 +233,7 @@ type
procedure OnSrcNoteBookShowUnitInfo(Sender: TObject);
Procedure OnSrcNotebookToggleFormUnit(Sender : TObject);
Procedure OnSrcNotebookViewJumpHistory(Sender : TObject);
Procedure OnSrcNotebookAddWatchesAtCursor(Sender : TObject);
// ObjectInspector events
procedure OIOnAddAvailableComponent(AComponent:TComponent;
@ -635,7 +638,7 @@ begin
SourceNotebook.OnShowUnitInfo := @OnSrcNoteBookShowUnitInfo;
SourceNotebook.OnToggleFormUnitClicked := @OnSrcNotebookToggleFormUnit;
SourceNotebook.OnViewJumpHistory := @OnSrcNotebookViewJumpHistory;
SourceNotebook.OnAddWatchAtCursor := @OnSrcNotebookAddWatchesAtCursor;
// search menus
itmSearchFind.OnClick := @SourceNotebook.FindClicked;
itmSearchFindNext.OnClick := @SourceNotebook.FindNextClicked;
@ -1182,6 +1185,11 @@ begin
itmViewMessage.OnClick := @mnuViewMessagesClick;
mnuView.Add(itmViewMessage);
itmViewWatches := TMenuItem.Create(Self);
itmViewWatches.Name:='itmViewWatches';
itmViewWatches.Caption := 'Watches';
itmViewWatches.OnClick := @mnuViewWatchesClick;
mnuView.Add(itmViewWatches);
//--------------
// Project
//--------------
@ -5050,6 +5058,22 @@ begin
FHintSender := Sender;
end;
Procedure TMainIDE.OnSrcNotebookAddWatchesAtCursor(Sender : TObject);
var
SE : TSourceEditor;
begin
Writeln('in MAIN.pp ADD WATCHES');
//get the sourceEditor.
Se := TSourceNotebook(sender).GetActiveSE;
if not Assigned(se) then Exit;
end;
procedure TMainIDE.mnuViewWatchesClick(Sender : TObject);
begin
Watches_dlg.Show;
end;
//-----------------------------------------------------------------------------
initialization
@ -5064,6 +5088,10 @@ end.
{ =============================================================================
$Log$
Revision 1.165 2001/12/07 20:12:13 lazarus
Added a watch dialog.
Shane
Revision 1.164 2001/12/05 18:19:10 lazarus
MG: added calendar to allunits and removed unused vars

View File

@ -102,7 +102,7 @@ type
Shift: TShiftState; X,Y: Integer);
Procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
Function FindFile(const Value: String) : String;
Function GetWordFromCaret(CaretPos : TPoint) : String;
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
Function GetSource : TStrings;
Procedure SetSource(Value : TStrings);
@ -175,7 +175,9 @@ type
//used to get the word at the mouse cursor
Function GetWordAtPosition(Position : TPoint) : String;
Function GetWordAtCurrentCaret: String;
//used to get the x,y of the caret if the caret was where the mouse is
//used in
//GetWordAtPosition
@ -254,6 +256,7 @@ type
FOnToggleFormUnitClicked : TNotifyEvent;
FOnUserCommandProcessed: TOnProcessUserCommand;
FOnViewJumpHistory: TNotifyEvent;
FOnAddWatchAtCursor: TNotifyEvent;
// PopupMenu
Procedure BuildPopupMenu;
@ -263,6 +266,7 @@ type
Procedure ReadOnlyClicked(Sender : TObject);
Procedure ShowUnitInfo(Sender : TObject);
Procedure ToggleBreakpointClicked(Sender : TObject);
Procedure AddWatchAtCursor(Sender : TObject);
Procedure ToggleLineNumbersClicked(Sender : TObject);
Procedure OpenAtCursorClicked(Sender : TObject);
Procedure BookmarkGoTo(Value: Integer);
@ -292,7 +296,7 @@ type
Procedure NextEditor;
Procedure PrevEditor;
Procedure ProcessParentCommand(Sender: TObject;
Procedure ProcessParentCommand(Sender: TObject;
var Command: TSynEditorCommand; var AChar: char; Data: pointer);
Procedure ParentCommandProcessed(Sender: TObject;
var Command: TSynEditorCommand; var AChar: char; Data: pointer);
@ -398,6 +402,8 @@ type
read FOnUserCommandProcessed write FOnUserCommandProcessed;
property OnViewJumpHistory: TNotifyEvent
read FOnViewJumpHistory write FOnViewJumpHistory;
property OnAddWatchAtCursor: TNotifyEvent
read FOnAddWatchAtCursor write FOnAddWatchAtCursor;
end;
{Goto dialog}
@ -1429,57 +1435,11 @@ end;
Function TSourceEditor.GetWordAtPosition(Position : TPoint) : String;
var
//TopLine : Integer;
//LineHeight : Integer;
LineNum : Integer;
XLine : Integer;
EditorLine: string;
Texts : String;
CaretPos : TPoint;
begin
Result := '';
Caretpos := GetCaretPosfromCursorPos(Position);
LineNum := CaretPos.Y-1;
XLine := CaretPos.X;
EditorLine := FEditor.Lines[LineNum];
// Writeln('XLine and LineNum = ',XLine,',',LineNum);
if Length(trim(EditorLine)) = 0 then Exit;
if XLine > Length(EditorLine) then Exit;
//walk backwards to a space or non-standard character.
while (
(upcase(EditorLine[XLine]) in (['A'..'Z'])) or
(upcase(EditorLine[XLine]) in (['0'..'9']))
) and
(XLine>1) do
dec(xLine);
if ( (XLine > 1) and (XLine < Length(EditorLine))) then Inc(xLine);
Texts := Copy(EditorLine,XLine,length(EditorLine)); //chop off the beginning
XLine := 1;
while (
(upcase(Texts[XLine]) in (['A'..'Z'])) or
(upcase(Texts[XLine]) in (['0'..'9']))
) and
(XLine< Length(Texts)) do
inc(xLine);
if (XLine < Length(Texts) ) and (XLine >1) then dec(xLine);
if not(
(upcase(Texts[XLine]) in (['A'..'Z'])) or
(upcase(Texts[XLine]) in (['0'..'9']))
) then
dec(xLine);
Texts := Copy(Texts,1,XLine);
Result := Texts;
Result := GetWordFromCaret(CaretPos);
end;
Procedure TSourceEditor.EditorMouseDown(Sender : TObject; Button : TMouseButton;
@ -1520,6 +1480,63 @@ begin
Result.Y := LineNum;
end;
Function TSourceEditor.GetWordAtCurrentCaret: String;
var
CaretPos : TPoint;
begin
Result := '';
CaretPos.Y := CurrentCursorYLine;
CaretPos.X := CurrentCursorXLine;
Result := GetWordFromCaret(CaretPos);
end;
Function TSourceEditor.GetWordFromCaret(CaretPos : TPoint) : String;
var
XLine,YLine : Integer;
EditorLine,Texts : String;
begin
YLine := CaretPos.Y;
XLine := CaretPos.X;
EditorLine := FEditor.Lines[YLine-1];
if Length(trim(EditorLine)) = 0 then Exit;
if XLine > Length(EditorLine) then Exit;
//walk backwards to a space or non-standard character.
while (
(upcase(EditorLine[XLine]) in (['A'..'Z'])) or
(upcase(EditorLine[XLine]) in (['0'..'9']))
) and
(XLine>1) do
dec(xLine);
if ( (XLine > 1) and (XLine < Length(EditorLine))) then Inc(xLine);
Texts := Copy(EditorLine,XLine,length(EditorLine)); //chop off the beginning
XLine := 1;
while (
(upcase(Texts[XLine]) in (['A'..'Z'])) or
(upcase(Texts[XLine]) in (['0'..'9']))
) and
(XLine< Length(Texts)) do
inc(xLine);
if (XLine < Length(Texts) ) and (XLine >1) then dec(xLine);
if not(
(upcase(Texts[XLine]) in (['A'..'Z'])) or
(upcase(Texts[XLine]) in (['0'..'9']))
) then
dec(xLine);
Texts := Copy(Texts,1,XLine);
Result := Texts;
end;
{------------------------------------------------------------------------}
{ TSourceNotebook }
@ -2204,6 +2221,13 @@ Begin
SubMenuItem.OnClick := @ToggleBreakpointClicked;
MenuItem.Add(SubMenuItem);
SubMenuItem := TMenuItem.Create(Self);
SubMenuItem.Name := 'AddWatchAtCursorMenuItem';
SubMenuItem.Caption := '&Add Watch At Cursor';
SubMenuItem.OnClick := @AddWatchAtCursor;
MenuItem.Add(SubMenuItem);
SubMenuItem := TMenuItem.Create(Self);
SubMenuItem.Name := 'RunToCursorMenuItem';
SubMenuItem.Caption := '&Run to Cursor';
@ -3109,6 +3133,12 @@ begin
FHintTimer.Enabled := False;
end;
Procedure TSourceNotebook.AddWatchAtCursor(Sender : TObject);
begin
if Assigned(OnAddWatchAtCursor) then
OnAddWatchAtCursor(Self);
end;
{ GOTO DIALOG}

296
ide/watchesdlg.pp Normal file
View File

@ -0,0 +1,296 @@
unit watchesdlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, LResources, StdCtrls,Buttons,Extctrls;
type
TWatchesdlg = class(TForm)
Listbox1: TLISTBOX;
private
{ private declarations }
protected
Procedure Listbox1KeyPress(Sender : TObject; var Key: Char);
Procedure Listbox1KeyDown(Sender: TObject; var Key: Word; Shift:TShiftState);
public
{ public declarations }
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
end;
TInsertWatch = class(TForm)
lblExpression : TLabel;
lblRepCount : TLabel;
lblDigits : TLabel;
cbEnabled : TCHeckbox;
cbAllowFunc : TCheckbox;
Style : TRadioGroup;
btnOK : TButton;
btnCancel : TButton;
btnHelp : TButton;
edtExpression: TEdit;
edtRepCount : TEdit;
edtDigits : TEdit;
private
public
constructor Create(AOWner : TCOmponent); override;
destructor Destroy; override;
end;
var
Watches_Dlg : TWatchesDlg;
InsertWatch : TInsertWatch;
implementation
constructor TWatchesdlg.Create(AOwner : TComponent);
Begin
inherited;
Listbox1 := TListbox.Create(self);
with Listbox1 do
Begin
Parent := self;
Align := alClient;
Visible := True;
Name := 'ListBox1';
OnKeyPress := @Listbox1KeyPress;
OnKeyDown := @Listbox1KeyDown;
end;
Caption := 'Watches';
Name := 'WatchesDlg';
Width := 250;
Height := 100;
//TListBox currently does NOT fire keypress, keyDown, KeyUp events. This is a fix for now.
OnKeyDown := @ListBox1KeyDown;
Position := poScreenCenter;
InsertWatch := TInsertWatch.Create(nil);
End;
destructor TWatchesDlg.Destroy;
Begin
InsertWatch.Free;
inherited;
end;
Procedure TWatchesDlg.Listbox1KeyPress(Sender : TObject; var Key : Char);
Begin
Writeln('Key is ',Key);
end;
Procedure TWatchesDlg.Listbox1KeyDown(Sender : TObject; var Key : Word; Shift : TShiftState);
var
Count : Integer;
Begin
Writeln('Key is ',Key);
case Key of
45 : begin //insert
if InsertWatch.ShowMOdal = mrOK then
Begin
//just for now...
if InsertWatch.edtExpression.Text <> '' then
ListBox1.Items.Add(InsertWatch.edtExpression.Text);
end;
end;
46 : begin //delete
if Listbox1.SelCount > 0 then
Begin
Count := 0;
while Count <= Listbox1.Items.Count-1 do
if Listbox1.Selected[Count] then
Listbox1.Items.Delete(Count)
else
Inc(Count);
end;
end;
end; //case
end;
{ TInsertWatch }
constructor TInsertWatch.Create(AOwner : TComponent);
Begin
inherited;
Width := 420;
Height := 200;
Position := poScreenCenter;
Caption := 'Watch Properties';
lblExpression := TLabel.Create(self);
with lblExpression do
Begin
Parent := self;
Caption := 'Expression:';
Name := 'lblExpression';
Left := 15;
Top := 20;
Visible := TRue;
end;
edtExpression := TEdit.Create(self);
with edtExpression do
Begin
Parent := Self;
Name := 'edtExpression';
Left := lblExpression.Left+lblExpression.Width+25;
top := lblExpression.top-3;
Width := self.width-left-15;
Visible := TRue;
Text := '';
end;
lblRepCount := TLabel.Create(self);
with lblRepCount do
Begin
Parent := self;
Caption := 'Repeat Count:';
Name := 'lblRepCount';
Left := 15;
Top := 45;
Width := 80;
Visible := TRue;
end;
edtRepCount := TEdit.Create(self);
with edtRepCount do
Begin
Parent := Self;
Text := '0';
NAme := 'edtRepCount';
Left := lblExpression.Left+lblExpression.Width+25;
Top := lblRepCount.Top -3;
Width := 60;
Visible := TRue;
end;
lblDigits := TLAbel.Create(self);
with lblDigits do
Begin
Parent := self;
Caption := 'Digits:';
Name := 'lblDigits';
Left := edtRepCount.left+edtRepCount.Width+10;
Width := 40;
Top := lblRepCount.Top;
Visible := TRue;
end;
edtDigits := TEdit.Create(self);
with edtDigits do
Begin
Parent := self;
Text := '0';
Name := 'edtDigits';
Left := lblDigits.Left+lblDigits.Width+10;
Top := lblRepCount.Top;
Width := self.width-left-15;
Visible := TRue;
end;
cbEnabled := TCheckbox.Create(self);
with cbEnabled do
Begin
Parent := self;
Left := 15;
Top := lblDigits.Top+20;
Name := 'cbEnabled';
Text := 'Enabled';
Width := 60;
Checked := True;
Visible := TRue;
end;
cbAllowFunc := TCheckBox.Create(self);
with cbAllowFunc do
Begin
Parent := self;
Left := edtRepCount.Left;
Text := 'Allow Function Calls';
Name := 'cbAllowFunc';
Checked := False;
Top := cbEnabled.Top;
Visible := TRue;
end;
Style := TRadioGroup.Create(self);
with Style do
Begin
Parent := self;
Name := 'Style';
Left := 15;
Top := cbEnabled.Top + 25;
Width := self.width-left-15;
Columns := 3;
Items.Add('Character');
Items.Add('String');
Items.Add('Decimal');
Items.Add('Hexadecimal');
Items.Add('Floating Point');
Items.Add('Pointer');
Items.Add('Record/Structure');
Items.Add('Default');
Items.Add('Memory Dump');
ItemIndex := 7; //default
Height := self.height-top-40;
Visible := True;
end;
btnOK := TButton.Create(self);
with btnOK do
Begin
Parent := self;
caption := 'OK';
Left := (self.width div 2) -25;
Top := Self.Height-30;
ModalResult := mrOK;
Visible := TRue;
end;
btnCancel := TButton.Create(self);
with btncancel do
Begin
Parent := self;
caption := 'Cancel';
Left := (self.width div 2) -25+Width+5;
Top := Self.Height-30;
ModalResult := mrCancel;
Visible := TRue;
end;
btnHelp := TButton.Create(self);
with btnHelp do
Begin
Parent := self;
caption := 'Help';
Left := (self.width div 2) -25+(2*width)+10;
Top := Self.Height-30;
// ModalResult := mrHelp;
Enabled := FAlse;
Visible := TRue;
end;
end;
destructor TInsertWatch.destroy;
begin
inherited;
end;
end.

View File

@ -804,6 +804,7 @@ var
F: TCustomForm;
ShiftState: TShiftState;
begin
Writeln('name is ',self.name);
Result := True;
F := GetParentForm(Self);
if (F <> nil)
@ -838,8 +839,7 @@ begin
and (F <> Self)
and (F.KeyPreview)
and (TWinControl(F).DoKeyPress(Message)) then Exit;
if not (csNoStdEvents in ControlStyle)
if not (csNoStdEvents in ControlStyle)
then with Message do
begin
C := Char(CharCode);
@ -1933,6 +1933,10 @@ end;
{ =============================================================================
$Log$
Revision 1.43 2001/12/07 20:12:15 lazarus
Added a watch dialog.
Shane
Revision 1.42 2001/11/10 10:48:00 lazarus
MG: fixed set formicon on invisible forms

View File

@ -1499,6 +1499,10 @@ end;
{ =============================================================================
$Log$
Revision 1.51 2001/12/07 20:12:15 lazarus
Added a watch dialog.
Shane
Revision 1.50 2001/12/05 18:23:47 lazarus
Added events to Calendar
Shane

View File

@ -1632,7 +1632,15 @@ begin
if (sender is TCustomForm) then Begin
ConnectSignal(PgtkObject(TCustomForm(sender).handle), 'key-press-event', @GTKKeyUpDown, GDK_KEY_PRESS_MASK);
ConnectSignal(PgtkObject(TCustomForm(sender).handle), 'key-release-event', @GTKKeyUpDown, GDK_KEY_RELEASE_MASK);
end;
end
else
if (sender is TCustomListBox) then
Begin
Writeln('------------------------------------------------------------------');
ConnectSignal(PgtkObject(GetCoreChildWidget(PgtkWidget(TCustomListBox(sender).handle))), 'key-press-event', @GTKKeyUpDown, GDK_KEY_PRESS_MASK);
ConnectSignal(PgtkObject(GetCoreChildWidget(PgtkWidget(TCustomListBox(sender).handle))), 'key-release-event', @GTKKeyUpDown, GDK_KEY_RELEASE_MASK);
Writeln('------------------------------------------------------------------');
end;
ConnectSignal(gFixed, 'key-press-event', @GTKKeyUpDown, GDK_KEY_PRESS_MASK);
ConnectSignal(gFixed, 'key-release-event', @GTKKeyUpDown, GDK_KEY_RELEASE_MASK);
end;
@ -2015,7 +2023,7 @@ begin
gtk_container_set_focus_vadjustment(PGtkContainer(TempWidget),
gtk_scrolled_window_get_vadjustment(PGtkScrolledWindow(p)));
gtk_container_set_focus_hadjustment(PGtkContainer(TempWidget),
gtk_scrolled_window_get_hadjustment(PGtkScrolledWindow(p)));
gtk_scrolled_window_get_hadjustment(PGtkScrolledWindow(p)));
gtk_widget_show(TempWidget);
//--------------------------
@ -3463,6 +3471,10 @@ end;
{ =============================================================================
$Log$
Revision 1.82 2001/12/07 20:12:15 lazarus
Added a watch dialog.
Shane
Revision 1.81 2001/12/06 13:39:36 lazarus
Added TArrow component
Shane

View File

@ -234,6 +234,15 @@ type
property MultiSelect;
property OnClick;
property OnDblClick;
property OnEnter;
property OnExit;
property OnKeyPress;
property OnKeyDown;
property OnKeyUp;
property OnMouseMove;
property OnMouseDown;
property OnMouseUp;
property OnResize;
property Sorted;
property Style;
property Visible;
@ -572,6 +581,10 @@ end.
{ =============================================================================
$Log$
Revision 1.17 2001/12/07 20:12:15 lazarus
Added a watch dialog.
Shane
Revision 1.16 2001/10/19 14:27:43 lazarus
MG: fixed customradiogroup OnClick + ItemIndex