implemented handling keys in IDE windows

git-svn-id: trunk@5526 -
This commit is contained in:
mattias 2004-05-29 17:20:06 +00:00
parent d79589f135
commit c1f1aa5d22
12 changed files with 207 additions and 46 deletions

View File

@ -2,6 +2,7 @@ object CodeExplorerView: TCodeExplorerView
Caption = 'CodeExplorerView' Caption = 'CodeExplorerView'
ClientHeight = 505 ClientHeight = 505
ClientWidth = 206 ClientWidth = 206
KeyPreview = True
OnClose = CodeExplorerViewCLOSE OnClose = CodeExplorerViewCLOSE
OnCreate = CodeExplorerViewCREATE OnCreate = CodeExplorerViewCREATE
OnResize = CodeExplorerViewRESIZE OnResize = CodeExplorerViewRESIZE
@ -13,7 +14,6 @@ object CodeExplorerView: TCodeExplorerView
Width = 206 Width = 206
object RefreshButton: TButton object RefreshButton: TButton
Caption = 'Refresh' Caption = 'Refresh'
TabStop = True
TabOrder = 0 TabOrder = 0
OnClick = RefreshButtonCLICK OnClick = RefreshButtonCLICK
Height = 25 Height = 25
@ -22,14 +22,13 @@ object CodeExplorerView: TCodeExplorerView
object OptionsButton: TButton object OptionsButton: TButton
Enabled = False Enabled = False
Caption = 'Options' Caption = 'Options'
TabStop = True
TabOrder = 1 TabOrder = 1
Left = 110 Left = 110
Height = 25 Height = 25
Width = 96 Width = 96
end end
object CodeTreeview: TTreeView object CodeTreeview: TTreeView
Align = ALBOTTOM Align = alBottom
DefaultItemHeight = 17 DefaultItemHeight = 17
DragCursor = 65524 DragCursor = 65524
HideSelection = False HideSelection = False
@ -40,7 +39,7 @@ object CodeExplorerView: TCodeExplorerView
TabOrder = 2 TabOrder = 2
OnDblClick = CodeTreeviewDBLCLICK OnDblClick = CodeTreeviewDBLCLICK
OnDeletion = CodeTreeviewDELETION OnDeletion = CodeTreeviewDELETION
Options = [TVOAUTOITEMHEIGHT, TVOKEEPCOLLAPSEDNODES, TVORIGHTCLICKSELECT, TVOSHOWBUTTONS, TVOSHOWLINES, TVOSHOWROOT, TVOTOOLTIPS] Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
Height = 480 Height = 480
Top = 25 Top = 25
Width = 206 Width = 206

View File

@ -2,24 +2,24 @@
LazarusResources.Add('TCodeExplorerView','FORMDATA',[ LazarusResources.Add('TCodeExplorerView','FORMDATA',[
'TPF0'#17'TCodeExplorerView'#16'CodeExplorerView'#7'Caption'#6#16'CodeExplore' 'TPF0'#17'TCodeExplorerView'#16'CodeExplorerView'#7'Caption'#6#16'CodeExplore'
+'rView'#12'ClientHeight'#3#249#1#11'ClientWidth'#3#206#0#7'OnClose'#7#21'Cod' +'rView'#12'ClientHeight'#3#249#1#11'ClientWidth'#3#206#0#10'KeyPreview'#9#7
+'eExplorerViewCLOSE'#8'OnCreate'#7#22'CodeExplorerViewCREATE'#8'OnResize'#7 +'OnClose'#7#21'CodeExplorerViewCLOSE'#8'OnCreate'#7#22'CodeExplorerViewCREAT'
+#22'CodeExplorerViewRESIZE'#18'HorzScrollBar.Page'#3#207#0#18'VertScrollBar.' +'E'#8'OnResize'#7#22'CodeExplorerViewRESIZE'#18'HorzScrollBar.Page'#3#207#0
+'Page'#3#250#1#4'Left'#3'z'#1#6'Height'#3#249#1#3'Top'#3#175#0#5'Width'#3#206 +#18'VertScrollBar.Page'#3#250#1#4'Left'#3'z'#1#6'Height'#3#249#1#3'Top'#3#175
+#0#0#7'TButton'#13'RefreshButton'#7'Caption'#6#7'Refresh'#7'TabStop'#9#8'Tab' +#0#5'Width'#3#206#0#0#7'TButton'#13'RefreshButton'#7'Caption'#6#7'Refresh'#8
+'Order'#2#0#7'OnClick'#7#18'RefreshButtonCLICK'#6'Height'#2#25#5'Width'#2'`' +'TabOrder'#2#0#7'OnClick'#7#18'RefreshButtonCLICK'#6'Height'#2#25#5'Width'#2
+#0#0#7'TButton'#13'OptionsButton'#7'Enabled'#8#7'Caption'#6#7'Options'#7'Tab' +'`'#0#0#7'TButton'#13'OptionsButton'#7'Enabled'#8#7'Caption'#6#7'Options'#8
+'Stop'#9#8'TabOrder'#2#1#4'Left'#2'n'#6'Height'#2#25#5'Width'#2'`'#0#0#9'TTr' +'TabOrder'#2#1#4'Left'#2'n'#6'Height'#2#25#5'Width'#2'`'#0#0#9'TTreeView'#12
+'eeView'#12'CodeTreeview'#5'Align'#7#8'ALBOTTOM'#17'DefaultItemHeight'#2#17 +'CodeTreeview'#5'Align'#7#8'alBottom'#17'DefaultItemHeight'#2#17#10'DragCurs'
+#10'DragCursor'#4#244#255#0#0#13'HideSelection'#8#6'Images'#7#10'Imagelist1' +'or'#4#244#255#0#0#13'HideSelection'#8#6'Images'#7#10'Imagelist1'#11'ParentC'
+#11'ParentCtl3D'#8#9'PopupMenu'#7#13'TreePopupmenu'#16'RightClickSelect'#9#8 +'tl3D'#8#9'PopupMenu'#7#13'TreePopupmenu'#16'RightClickSelect'#9#8'TabOrder'
+'TabOrder'#2#2#10'OnDblClick'#7#20'CodeTreeviewDBLCLICK'#10'OnDeletion'#7#20 +#2#2#10'OnDblClick'#7#20'CodeTreeviewDBLCLICK'#10'OnDeletion'#7#20'CodeTreev'
+'CodeTreeviewDELETION'#7'Options'#11#17'TVOAUTOITEMHEIGHT'#21'TVOKEEPCOLLAPS' +'iewDELETION'#7'Options'#11#17'tvoAutoItemHeight'#21'tvoKeepCollapsedNodes'
+'EDNODES'#19'TVORIGHTCLICKSELECT'#14'TVOSHOWBUTTONS'#12'TVOSHOWLINES'#11'TVO' +#19'tvoRightClickSelect'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'
+'SHOWROOT'#11'TVOTOOLTIPS'#0#6'Height'#3#224#1#3'Top'#2#25#5'Width'#3#206#0#0 +#11'tvoToolTips'#0#6'Height'#3#224#1#3'Top'#2#25#5'Width'#3#206#0#0#0#10'TIm'
+#0#10'TImageList'#10'Imagelist1'#4'left'#2'@'#3'top'#2' '#0#0#10'TPopupMenu' +'ageList'#10'Imagelist1'#4'left'#2'@'#3'top'#2' '#0#0#10'TPopupMenu'#13'Tree'
+#13'TreePopupmenu'#4'left'#2'@'#3'top'#2'H'#0#9'TMenuItem'#14'JumpToMenuitem' +'Popupmenu'#4'left'#2'@'#3'top'#2'H'#0#9'TMenuItem'#14'JumpToMenuitem'#7'Cap'
+#7'Caption'#6#14'Jump to source'#7'OnClick'#7#19'JumpToMenuitemCLICK'#0#0#9 +'tion'#6#14'Jump to source'#7'OnClick'#7#19'JumpToMenuitemCLICK'#0#0#9'TMenu'
+'TMenuItem'#15'RefreshMenuitem'#7'Caption'#6#7'Refresh'#7'OnClick'#7#20'Refr' +'Item'#15'RefreshMenuitem'#7'Caption'#6#7'Refresh'#7'OnClick'#7#20'RefreshMe'
+'eshMenuitemCLICK'#0#0#0#0 +'nuitemCLICK'#0#0#0#0
]); ]);

View File

@ -35,6 +35,7 @@ uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons, Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
ComCtrls, ComCtrls,
CodeToolManager, CodeAtom, CodeCache, CodeTree, PascalParserTool, CodeToolManager, CodeAtom, CodeCache, CodeTree, PascalParserTool,
IDECommands,
EnvironmentOpts, IDEOptionDefs, LazarusIDEStrConsts, InputHistory, IDEProcs, EnvironmentOpts, IDEOptionDefs, LazarusIDEStrConsts, InputHistory, IDEProcs,
Menus; Menus;
@ -95,6 +96,8 @@ type
function GetNodeImage(CodeNode: TCodeTreeNode): integer; function GetNodeImage(CodeNode: TCodeTreeNode): integer;
procedure CreateNodes(ACodeTool: TCodeTool; CodeNode: TCodeTreeNode; procedure CreateNodes(ACodeTool: TCodeTool; CodeNode: TCodeTreeNode;
ParentViewNode, InFrontViewNode: TTreeNode; CreateSiblings: boolean); ParentViewNode, InFrontViewNode: TTreeNode; CreateSiblings: boolean);
protected
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
public public
procedure BeginUpdate; procedure BeginUpdate;
procedure EndUpdate; procedure EndUpdate;
@ -367,6 +370,12 @@ begin
end; end;
end; end;
procedure TCodeExplorerView.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited KeyUp(Key, Shift);
ExecuteIDECommand(Self,Key,Shift,caMenuOnly);
end;
procedure TCodeExplorerView.BeginUpdate; procedure TCodeExplorerView.BeginUpdate;
begin begin
inc(FUpdateCount); inc(FUpdateCount);

View File

@ -240,11 +240,6 @@ const
ecCustomToolLast = ecUserFirst + 2999; ecCustomToolLast = ecUserFirst + 2999;
const
caAll = [caSourceEditor, caDesigner];
caSrcEditOnly = [caSourceEditor];
caDesignOnly = [caDesigner];
type type
TKeyMapScheme = ( TKeyMapScheme = (
kmsLazarus, kmsLazarus,
@ -1800,7 +1795,7 @@ begin
// create default keymapping // create default keymapping
// moving // moving
C:=Categories[AddCategory('CursorMoving',srkmCatCursorMoving,caSrcEditOnly)]; C:=Categories[AddCategory('CursorMoving',srkmCatCursorMoving,caSrcEdit)];
AddDefault(C,'Move cursor word left',ecWordLeft); AddDefault(C,'Move cursor word left',ecWordLeft);
AddDefault(C,'Move cursor word right',ecWordRight); AddDefault(C,'Move cursor word right',ecWordRight);
AddDefault(C,'Move cursor to line start',ecLineStart); AddDefault(C,'Move cursor to line start',ecLineStart);
@ -1819,7 +1814,7 @@ begin
AddDefault(C,'Scroll right one char',ecScrollRight); AddDefault(C,'Scroll right one char',ecScrollRight);
// selection // selection
C:=Categories[AddCategory('Selection',srkmCatSelection,caSrcEditOnly)]; C:=Categories[AddCategory('Selection',srkmCatSelection,caSrcEdit)];
AddDefault(C,'Copy selection to clipboard',ecCopy); AddDefault(C,'Copy selection to clipboard',ecCopy);
AddDefault(C,'Cut selection to clipboard',ecCut); AddDefault(C,'Cut selection to clipboard',ecCut);
AddDefault(C,'Paste clipboard to current position',ecPaste); AddDefault(C,'Paste clipboard to current position',ecPaste);
@ -1849,7 +1844,7 @@ begin
AddDefault(C,'Break Lines in selection',ecSelectionBreakLines); AddDefault(C,'Break Lines in selection',ecSelectionBreakLines);
// editing // editing
C:=Categories[AddCategory('editing commands',srkmCatEditing,caSrcEditOnly)]; C:=Categories[AddCategory('editing commands',srkmCatEditing,caSrcEdit)];
AddDefault(C,'Indent block',ecBlockIndent); AddDefault(C,'Indent block',ecBlockIndent);
AddDefault(C,'Unindent block',ecBlockUnindent); AddDefault(C,'Unindent block',ecBlockUnindent);
AddDefault(C,'Delete last char',ecDeleteLastChar); AddDefault(C,'Delete last char',ecDeleteLastChar);
@ -1883,7 +1878,7 @@ begin
AddDefault(C,'Redo',ecRedo); AddDefault(C,'Redo',ecRedo);
// search & replace // search & replace
C:=Categories[AddCategory('SearchReplace',srkmCatSearchReplace,caSrcEditOnly)]; C:=Categories[AddCategory('SearchReplace',srkmCatSearchReplace,caAll)];
AddDefault(C,'Go to matching bracket',ecMatchBracket); AddDefault(C,'Go to matching bracket',ecMatchBracket);
AddDefault(C,'Find text',ecFind); AddDefault(C,'Find text',ecFind);
AddDefault(C,'Find next',ecFindNext); AddDefault(C,'Find next',ecFindNext);
@ -1901,7 +1896,7 @@ begin
AddDefault(C,'Open file at cursor',ecOpenFileAtCursor); AddDefault(C,'Open file at cursor',ecOpenFileAtCursor);
// marker // marker
C:=Categories[AddCategory('Marker',srkmCatMarker,caSrcEditOnly)]; C:=Categories[AddCategory('Marker',srkmCatMarker,caSrcEdit)];
AddDefault(C,'Go to marker 0',ecGotoMarker0); AddDefault(C,'Go to marker 0',ecGotoMarker0);
AddDefault(C,'Go to marker 1',ecGotoMarker1); AddDefault(C,'Go to marker 1',ecGotoMarker1);
AddDefault(C,'Go to marker 2',ecGotoMarker2); AddDefault(C,'Go to marker 2',ecGotoMarker2);
@ -1924,7 +1919,7 @@ begin
AddDefault(C,'Set marker 9',ecSetMarker9); AddDefault(C,'Set marker 9',ecSetMarker9);
// codetools // codetools
C:=Categories[AddCategory('CodeTools',srkmCatCodeTools,caSrcEditOnly)]; C:=Categories[AddCategory('CodeTools',srkmCatCodeTools,caSrcEdit)];
AddDefault(C,'Code template completion',ecAutoCompletion); AddDefault(C,'Code template completion',ecAutoCompletion);
AddDefault(C,'Word completion',ecWordCompletion); AddDefault(C,'Word completion',ecWordCompletion);
AddDefault(C,'Complete code',ecCompleteCode); AddDefault(C,'Complete code',ecCompleteCode);
@ -2055,7 +2050,7 @@ begin
AddDefault(C,'About Lazarus',ecAboutLazarus); AddDefault(C,'About Lazarus',ecAboutLazarus);
// designer // designer
C:=Categories[AddCategory('Designer',lisKeyCatDesigner,caDesignOnly)]; C:=Categories[AddCategory('Designer',lisKeyCatDesigner,caDesign)];
AddDefault(C,'Copy selected Components to clipboard',ecCopyComponents); AddDefault(C,'Copy selected Components to clipboard',ecCopyComponents);
AddDefault(C,'Cut selected Components to clipboard',ecCutComponents); AddDefault(C,'Cut selected Components to clipboard',ecCutComponents);
AddDefault(C,'Paste Components from clipboard',ecPasteComponents); AddDefault(C,'Paste Components from clipboard',ecPasteComponents);

View File

@ -50,6 +50,8 @@ uses
Dialogs, Dialogs,
// codetools // codetools
Laz_XMLCfg, CodeToolsStructs, CodeToolManager, CodeCache, DefineTemplates, Laz_XMLCfg, CodeToolsStructs, CodeToolManager, CodeCache, DefineTemplates,
// IDE interface
AllIDEIntf, ObjectInspector, PropEdits, IDECommands,
// synedit // synedit
SynEditKeyCmds, SynEditKeyCmds,
// compile // compile
@ -60,7 +62,7 @@ uses
// designer // designer
ComponentPalette, ComponentReg, ComponentPalette, ComponentReg,
Designer, FormEditor, CustomFormEditor, Designer, FormEditor, CustomFormEditor,
ObjectInspector, PropEdits, ControlSelection, AllIDEIntf, ControlSelection,
{$DEFINE UseNewMenuEditor} {$DEFINE UseNewMenuEditor}
{$IFDEF UseNewMenuEditor} {$IFDEF UseNewMenuEditor}
MenuEditorForm, MenuEditorForm,
@ -240,6 +242,8 @@ type
// Global IDE events // Global IDE events
procedure OnProcessIDECommand(Sender: TObject; Command: word; procedure OnProcessIDECommand(Sender: TObject; Command: word;
var Handled: boolean); var Handled: boolean);
procedure OnExecuteIDECommand(Sender: TObject;
var Key: word; Shift: TShiftState; Areas: TCommandAreas);
// Environment options dialog events // Environment options dialog events
procedure OnLoadEnvironmentSettings(Sender: TObject; procedure OnLoadEnvironmentSettings(Sender: TObject;
@ -283,6 +287,8 @@ type
// ObjectInspector + PropertyEditorHook events // ObjectInspector + PropertyEditorHook events
procedure OIOnSelectPersistents(Sender: TObject); procedure OIOnSelectPersistents(Sender: TObject);
procedure OIOnShowOptions(Sender: TObject); procedure OIOnShowOptions(Sender: TObject);
procedure OIRemainingKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure OnPropHookGetMethods(TypeData:PTypeData; Proc:TGetStringProc); procedure OnPropHookGetMethods(TypeData:PTypeData; Proc:TGetStringProc);
function OnPropHookMethodExists(const AMethodName:ShortString; function OnPropHookMethodExists(const AMethodName:ShortString;
TypeData: PTypeData; TypeData: PTypeData;
@ -319,6 +325,7 @@ type
procedure OnDesignerRenameComponent(ADesigner: TDesigner; procedure OnDesignerRenameComponent(ADesigner: TDesigner;
AComponent: TComponent; const NewName: string); AComponent: TComponent; const NewName: string);
// control selection
procedure OnControlSelectionChanged(Sender: TObject); procedure OnControlSelectionChanged(Sender: TObject);
procedure OnControlSelectionPropsChanged(Sender: TObject); procedure OnControlSelectionPropsChanged(Sender: TObject);
procedure OnControlSelectionFormChanged(Sender: TObject; OldForm, procedure OnControlSelectionFormChanged(Sender: TObject; OldForm,
@ -423,6 +430,7 @@ type
procedure SetupSourceNotebook; procedure SetupSourceNotebook;
procedure SetupTransferMacros; procedure SetupTransferMacros;
procedure SetupControlSelection; procedure SetupControlSelection;
procedure SetupIDEInterface;
procedure SetupStartProject; procedure SetupStartProject;
procedure ReOpenIDEWindows; procedure ReOpenIDEWindows;
@ -566,8 +574,12 @@ type
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
procedure GetDesignerUnit(ADesigner: TDesigner; procedure GetDesignerUnit(ADesigner: TDesigner;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
procedure GetObjectInspectorUnit(
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
procedure GetUnitWithForm(AForm: TCustomForm; procedure GetUnitWithForm(AForm: TCustomForm;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
procedure GetUnitWithPersistent(APersistent: TPersistent;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
function GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo): TSourceEditor; function GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo): TSourceEditor;
procedure UpdateDefaultPascalFileExtensions; procedure UpdateDefaultPascalFileExtensions;
function CreateSrcEditPageName(const AnUnitName, AFilename: string; function CreateSrcEditPageName(const AnUnitName, AFilename: string;
@ -890,6 +902,7 @@ begin
SetupSourceNotebook; SetupSourceNotebook;
SetupTransferMacros; SetupTransferMacros;
SetupControlSelection; SetupControlSelection;
SetupIDEInterface;
// Main IDE bar created and setup completed -> Show it // Main IDE bar created and setup completed -> Show it
Show; Show;
@ -933,6 +946,7 @@ begin
Application.RemoveOnUserInputHandler(@OnApplicationUserInput); Application.RemoveOnUserInputHandler(@OnApplicationUserInput);
Application.RemoveOnIdleHandler(@OnApplicationIdle); Application.RemoveOnIdleHandler(@OnApplicationIdle);
Screen.RemoveHandlerRemoveForm(@OnScreenRemoveForm); Screen.RemoveHandlerRemoveForm(@OnScreenRemoveForm);
IDECommands.OnExecuteIDECommand:=nil;
// free project, if it is still there // free project, if it is still there
FreeThenNil(Project1); FreeThenNil(Project1);
@ -988,6 +1002,12 @@ begin
DoShowEnvGeneralOptions(eodpObjectInspector); DoShowEnvGeneralOptions(eodpObjectInspector);
end; end;
procedure TMainIDE.OIRemainingKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
OnExecuteIDECommand(Sender,Key,Shift,caDesign);
end;
procedure TMainIDE.OnPropHookGetMethods(TypeData:PTypeData; procedure TMainIDE.OnPropHookGetMethods(TypeData:PTypeData;
Proc:TGetStringProc); Proc:TGetStringProc);
var ActiveSrcEdit: TSourceEditor; var ActiveSrcEdit: TSourceEditor;
@ -1198,6 +1218,7 @@ begin
ObjectInspector1 := TObjectInspector.Create(Self); ObjectInspector1 := TObjectInspector.Create(Self);
ObjectInspector1.OnSelectPersistentsInOI:=@OIOnSelectPersistents; ObjectInspector1.OnSelectPersistentsInOI:=@OIOnSelectPersistents;
ObjectInspector1.OnShowOptions:=@OIOnShowOptions; ObjectInspector1.OnShowOptions:=@OIOnShowOptions;
ObjectInspector1.OnRemainingKeyUp:=@OIRemainingKeyUp;
GlobalDesignHook:=TPropertyEditorHook.Create; GlobalDesignHook:=TPropertyEditorHook.Create;
GlobalDesignHook.GetPrivateDirectory:=AppendPathDelim(GetPrimaryConfigPath); GlobalDesignHook.GetPrivateDirectory:=AppendPathDelim(GetPrimaryConfigPath);
@ -1209,6 +1230,7 @@ begin
GlobalDesignHook.AddHandlerBeforeAddComponent(@OnPropHookBeforeAddComponent); GlobalDesignHook.AddHandlerBeforeAddComponent(@OnPropHookBeforeAddComponent);
GlobalDesignHook.AddHandlerComponentRenamed(@OnPropHookComponentRenamed); GlobalDesignHook.AddHandlerComponentRenamed(@OnPropHookComponentRenamed);
GlobalDesignHook.AddHandlerComponentAdded(@OnPropHookComponentAdded); GlobalDesignHook.AddHandlerComponentAdded(@OnPropHookComponentAdded);
ObjectInspector1.PropertyEditorHook:=GlobalDesignHook; ObjectInspector1.PropertyEditorHook:=GlobalDesignHook;
EnvironmentOptions.IDEWindowLayoutList.Apply(ObjectInspector1, EnvironmentOptions.IDEWindowLayoutList.Apply(ObjectInspector1,
DefaultObjectInspectorName); DefaultObjectInspectorName);
@ -1349,6 +1371,11 @@ begin
TheControlSelection.OnSelectionFormChanged:=@OnControlSelectionFormChanged; TheControlSelection.OnSelectionFormChanged:=@OnControlSelectionFormChanged;
end; end;
procedure TMainIDE.SetupIDEInterface;
begin
IDECommands.OnExecuteIDECommand:=@OnExecuteIDECommand;
end;
procedure TMainIDE.SetupStartProject; procedure TMainIDE.SetupStartProject;
var var
LastParam: String; LastParam: String;
@ -1881,10 +1908,14 @@ begin
case Command of case Command of
ecSave: ecSave:
if Sender is TDesigner then begin if (Sender is TDesigner) then begin
GetDesignerUnit(TDesigner(Sender),ASrcEdit,AnUnitInfo); GetDesignerUnit(TDesigner(Sender),ASrcEdit,AnUnitInfo);
if (AnUnitInfo<>nil) and (AnUnitInfo.EditorIndex>=0) then if (AnUnitInfo<>nil) and (AnUnitInfo.EditorIndex>=0) then
DoSaveEditorFile(AnUnitInfo.EditorIndex,[sfCheckAmbigiousFiles]); DoSaveEditorFile(AnUnitInfo.EditorIndex,[sfCheckAmbigiousFiles]);
end else if (Sender is TObjectInspector) then begin
GetObjectInspectorUnit(ASrcEdit,AnUnitInfo);
if (AnUnitInfo<>nil) and (AnUnitInfo.EditorIndex>=0) then
DoSaveEditorFile(AnUnitInfo.EditorIndex,[sfCheckAmbigiousFiles]);
end else if Sender is TSourceNotebook then end else if Sender is TSourceNotebook then
mnuSaveClicked(Self); mnuSaveClicked(Self);
@ -1996,6 +2027,21 @@ begin
end; end;
end; end;
procedure TMainIDE.OnExecuteIDECommand(Sender: TObject; var Key: word;
Shift: TShiftState; Areas: TCommandAreas);
var
CommandRelation: TKeyCommandRelation;
Handled: Boolean;
begin
writeln('TMainIDE.OnExecuteIDECommand A ',Key);
CommandRelation:=EditorOpts.KeyMap.Find(Key,Shift,Areas);
if (CommandRelation=nil) or (CommandRelation.Command=ecNone) then exit;
Handled:=false;
writeln('TMainIDE.OnExecuteIDECommand B ',CommandRelation.Command,' ',ecSave);
OnProcessIDECommand(Sender,CommandRelation.Command,Handled);
if Handled then Key:=VK_UNKNOWN;
end;
procedure TMainIDE.OnSrcNoteBookCtrlMouseUp(Sender: TObject; procedure TMainIDE.OnSrcNoteBookCtrlMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftstate; X, Y: Integer); Button: TMouseButton; Shift: TShiftstate; X, Y: Integer);
var var
@ -6715,6 +6761,18 @@ begin
end; end;
end; end;
procedure TMainIDE.GetObjectInspectorUnit(
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
begin
ActiveSourceEditor:=nil;
ActiveUnitInfo:=nil;
if (ObjectInspector1=nil) or (ObjectInspector1.PropertyEditorHook=nil)
or (ObjectInspector1.PropertyEditorHook.LookupRoot=nil)
then exit;
GetUnitWithPersistent(ObjectInspector1.PropertyEditorHook.LookupRoot,
ActiveSourceEditor,ActiveUnitInfo);
end;
procedure TMainIDE.GetUnitWithForm(AForm: TCustomForm; procedure TMainIDE.GetUnitWithForm(AForm: TCustomForm;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo); var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
var var
@ -6726,9 +6784,20 @@ begin
AComponent:=TDesigner(AForm.Designer).LookupRoot; AComponent:=TDesigner(AForm.Designer).LookupRoot;
if AComponent=nil then if AComponent=nil then
RaiseException('TMainIDE.GetUnitWithForm AComponent=nil'); RaiseException('TMainIDE.GetUnitWithForm AComponent=nil');
GetUnitWithPersistent(AComponent,ActiveSourceEditor,ActiveUnitInfo);
end else begin
ActiveSourceEditor:=nil;
ActiveUnitInfo:=nil;
end;
end;
procedure TMainIDE.GetUnitWithPersistent(APersistent: TPersistent;
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
begin
if APersistent<>nil then begin
ActiveUnitInfo:=Project1.FirstUnitWithComponent; ActiveUnitInfo:=Project1.FirstUnitWithComponent;
while ActiveUnitInfo<>nil do begin while ActiveUnitInfo<>nil do begin
if ActiveUnitInfo.Component=AComponent then begin if ActiveUnitInfo.Component=APersistent then begin
ActiveSourceEditor:=SourceNoteBook.FindSourceEditorWithPageIndex( ActiveSourceEditor:=SourceNoteBook.FindSourceEditorWithPageIndex(
ActiveUnitInfo.EditorIndex); ActiveUnitInfo.EditorIndex);
exit; exit;
@ -10345,6 +10414,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.727 2004/05/29 17:20:05 mattias
implemented handling keys in IDE windows
Revision 1.726 2004/05/29 14:52:18 mattias Revision 1.726 2004/05/29 14:52:18 mattias
implemented go to next/previous error implemented go to next/previous error

View File

@ -253,6 +253,8 @@ type
itmJumpForward: TMenuItem; itmJumpForward: TMenuItem;
itmAddJumpPoint: TMenuItem; itmAddJumpPoint: TMenuItem;
itmJumpHistory: TMenuItem; itmJumpHistory: TMenuItem;
itmJumpToNextError: TMenuItem;
itmJumpToPrevError: TMenuItem;
itmFindBlockOtherEnd: TMenuItem; itmFindBlockOtherEnd: TMenuItem;
itmFindBlockStart: TMenuItem; itmFindBlockStart: TMenuItem;
itmFindDeclaration: TMenuItem; itmFindDeclaration: TMenuItem;
@ -725,6 +727,8 @@ begin
CreateMenuItem(mnuSearch,itmJumpForward,'itmJumpForward',lisMenuJumpForward); CreateMenuItem(mnuSearch,itmJumpForward,'itmJumpForward',lisMenuJumpForward);
CreateMenuItem(mnuSearch,itmAddJumpPoint,'itmAddJumpPoint',lisMenuAddJumpPointToHistory); CreateMenuItem(mnuSearch,itmAddJumpPoint,'itmAddJumpPoint',lisMenuAddJumpPointToHistory);
CreateMenuItem(mnuSearch,itmJumpHistory,'itmJumpHistory',lisMenuViewJumpHistory); CreateMenuItem(mnuSearch,itmJumpHistory,'itmJumpHistory',lisMenuViewJumpHistory);
CreateMenuItem(mnuSearch,itmJumpHistory,'itmJumpToNextError',lisMenuJumpToNextError);
CreateMenuItem(mnuSearch,itmJumpHistory,'itmJumpToPrevError',lisMenuJumpToPrevError);
mnuSearch.Add(CreateMenuSeparator); mnuSearch.Add(CreateMenuSeparator);
@ -944,6 +948,8 @@ begin
itmJumpForward.ShortCut:=CommandToShortCut(ecJumpForward); itmJumpForward.ShortCut:=CommandToShortCut(ecJumpForward);
itmAddJumpPoint.ShortCut:=CommandToShortCut(ecAddJumpPoint); itmAddJumpPoint.ShortCut:=CommandToShortCut(ecAddJumpPoint);
itmJumpHistory.ShortCut:=CommandToShortCut(ecViewJumpHistory); itmJumpHistory.ShortCut:=CommandToShortCut(ecViewJumpHistory);
itmJumpToNextError.ShortCut:=CommandToShortCut(ecJumpToNextError);
itmJumpToPrevError.ShortCut:=CommandToShortCut(ecJumpToPrevError);
itmFindBlockOtherEnd.ShortCut:=CommandToShortCut(ecFindBlockOtherEnd); itmFindBlockOtherEnd.ShortCut:=CommandToShortCut(ecFindBlockOtherEnd);
itmFindBlockStart.ShortCut:=CommandToShortCut(ecFindBlockStart); itmFindBlockStart.ShortCut:=CommandToShortCut(ecFindBlockStart);
itmFindDeclaration.ShortCut:=CommandToShortCut(ecFindDeclaration); itmFindDeclaration.ShortCut:=CommandToShortCut(ecFindDeclaration);

View File

@ -38,7 +38,7 @@ interface
uses uses
Classes, SysUtils, Controls, StdCtrls, Forms, LResources, IDEProcs, Classes, SysUtils, Controls, StdCtrls, Forms, LResources, IDEProcs,
IDEOptionDefs, EnvironmentOpts, LazarusIDEStrConsts; IDEOptionDefs, IDECommands, EnvironmentOpts, LazarusIDEStrConsts;
type type
{ TMessageLine } { TMessageLine }
@ -68,6 +68,8 @@ type
MessageView: TListBox; MessageView: TListBox;
procedure MessageViewDblClicked(Sender: TObject); procedure MessageViewDblClicked(Sender: TObject);
Procedure MessageViewClicked(sender : TObject); Procedure MessageViewClicked(sender : TObject);
procedure MessagesViewKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private private
FItems: TList; // list of TMessageLine FItems: TList; // list of TMessageLine
FVisibleItems: TList; // list of TMessageLine (visible Items of FItems) FVisibleItems: TList; // list of TMessageLine (visible Items of FItems)
@ -149,6 +151,8 @@ Begin
ItemByEnum(nmiwMessagesViewName); ItemByEnum(nmiwMessagesViewName);
ALayout.Form:=TForm(Self); ALayout.Form:=TForm(Self);
ALayout.Apply; ALayout.Apply;
KeyPreview:=true;
OnKeyDown:=@MessagesViewKeyDown;
end; end;
destructor TMessagesView.Destroy; destructor TMessagesView.Destroy;
@ -388,6 +392,12 @@ begin
end; end;
end; end;
procedure TMessagesView.MessagesViewKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
ExecuteIDECommand(Self,Key,Shift);
end;
function TMessagesView.GetDirectory: string; function TMessagesView.GetDirectory: string;
var var
i: Integer; i: Integer;

View File

@ -40,6 +40,7 @@ interface
uses uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Buttons, ComCtrls, Classes, SysUtils, LCLProc, LResources, Forms, Controls, Buttons, ComCtrls,
StdCtrls, Menus, Dialogs, Graphics, FileCtrl, StdCtrls, Menus, Dialogs, Graphics, FileCtrl,
IDECommands,
LazarusIDEStrConsts, IDEProcs, IDEOptionDefs, EnvironmentOpts, LazarusIDEStrConsts, IDEProcs, IDEOptionDefs, EnvironmentOpts,
Project, AddToProjectDlg, PackageSystem, PackageDefs; Project, AddToProjectDlg, PackageSystem, PackageDefs;
@ -104,6 +105,8 @@ type
function GetImageIndexOfFile(AFile: TUnitInfo): integer; function GetImageIndexOfFile(AFile: TUnitInfo): integer;
procedure OnProjectBeginUpdate(Sender: TObject); procedure OnProjectBeginUpdate(Sender: TObject);
procedure OnProjectEndUpdate(Sender: TObject; ProjectChanged: boolean); procedure OnProjectEndUpdate(Sender: TObject; ProjectChanged: boolean);
protected
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -602,6 +605,12 @@ begin
EndUpdate; EndUpdate;
end; end;
procedure TProjectInspectorForm.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited KeyDown(Key, Shift);
ExecuteIDECommand(Self,Key,Shift,caMenuOnly);
end;
function TProjectInspectorForm.GetSelectedFile: TUnitInfo; function TProjectInspectorForm.GetSelectedFile: TUnitInfo;
var var
CurNode: TTreeNode; CurNode: TTreeNode;
@ -679,6 +688,7 @@ begin
inherited Create(TheOwner); inherited Create(TheOwner);
Name:=NonModalIDEWindowNames[nmiwProjectInspector]; Name:=NonModalIDEWindowNames[nmiwProjectInspector];
Caption:=lisMenuProjectInspector; Caption:=lisMenuProjectInspector;
KeyPreview:=true;
ALayout:=EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(Name); ALayout:=EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(Name);
ALayout.Form:=TForm(Self); ALayout.Form:=TForm(Self);
@ -688,6 +698,7 @@ begin
OnResize:=@ProjectInspectorFormResize; OnResize:=@ProjectInspectorFormResize;
OnResize(Self); OnResize(Self);
OnShow:=@ProjectInspectorFormShow; OnShow:=@ProjectInspectorFormShow;
KeyPreview:=true;
end; end;
destructor TProjectInspectorForm.Destroy; destructor TProjectInspectorForm.Destroy;

View File

@ -47,6 +47,7 @@ uses
Classes, SysUtils, Controls, Forms, Dialogs, Buttons, ComCtrls, StdCtrls, Classes, SysUtils, Controls, Forms, Dialogs, Buttons, ComCtrls, StdCtrls,
Graphics, LCLType, FileCtrl, LResources, Graphics, LCLType, FileCtrl, LResources,
CodeToolManager, CodeCache, CodeToolManager, CodeCache,
IDECommands,
EnvironmentOpts, IDEOptionDefs, LazarusIDEStrConsts, InputHistory; EnvironmentOpts, IDEOptionDefs, LazarusIDEStrConsts, InputHistory;
type type
@ -198,6 +199,8 @@ type
procedure RebuildTree; procedure RebuildTree;
procedure SetRootFilename(const AValue: string); procedure SetRootFilename(const AValue: string);
procedure SetRootShortFilename(const AValue: string); procedure SetRootShortFilename(const AValue: string);
protected
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -413,6 +416,12 @@ begin
FRootNode.ShortFilename:=AValue; FRootNode.ShortFilename:=AValue;
end; end;
procedure TUnitDependenciesView.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited KeyUp(Key, Shift);
ExecuteIDECommand(Self,Key,Shift,caMenuOnly);
end;
function TUnitDependenciesView.RootValid: boolean; function TUnitDependenciesView.RootValid: boolean;
begin begin
Result:=FRootValid; Result:=FRootValid;
@ -439,6 +448,7 @@ begin
Name:=NonModalIDEWindowNames[nmiwUnitDependenciesName]; Name:=NonModalIDEWindowNames[nmiwUnitDependenciesName];
Caption := dlgUnitDepCaption; Caption := dlgUnitDepCaption;
EnvironmentOptions.IDEWindowLayoutList.Apply(Self,Name); EnvironmentOptions.IDEWindowLayoutList.Apply(Self,Name);
KeyPreview:=true;
SrcTypeImageList:=TImageList.Create(Self); SrcTypeImageList:=TImageList.Create(Self);
with SrcTypeImageList do with SrcTypeImageList do

View File

@ -38,9 +38,16 @@ uses
Classes, SysUtils, LCLType; Classes, SysUtils, LCLType;
type type
TCommandArea = (caSourceEditor, caDesigner); TCommandArea = (caMenu, caSourceEditor, caDesigner);
TCommandAreas = set of TCommandArea; TCommandAreas = set of TCommandArea;
const
caAll = [caMenu, caSourceEditor, caDesigner];
caMenuOnly = [caMenu];
caSrcEdit = [caMenu,caSourceEditor];
caDesign = [caMenu,caDesigner];
type
TIDEShortCut = record TIDEShortCut = record
Key1: word; Key1: word;
Shift1: TShiftState; Shift1: TShiftState;
@ -100,6 +107,20 @@ function IDEShortCut(Key1: word; Shift1: TShiftState;
Key2: word; Shift2: TShiftState): TIDEShortCut; Key2: word; Shift2: TShiftState): TIDEShortCut;
type
TExecuteIDECommand = procedure(Sender: TObject;
var Key: word; Shift: TShiftState;
Areas: TCommandAreas) of object;
var
// will be set by the IDE
OnExecuteIDECommand: TExecuteIDECommand;
procedure ExecuteIDECommand(Sender: TObject; var Key: word; Shift: TShiftState;
Areas: TCommandAreas);
procedure ExecuteIDECommand(Sender: TObject; var Key: word; Shift: TShiftState);
implementation implementation
@ -112,6 +133,18 @@ begin
Result.Shift2:=Shift2; Result.Shift2:=Shift2;
end; end;
procedure ExecuteIDECommand(Sender: TObject; var Key: word; Shift: TShiftState;
Areas: TCommandAreas);
begin
if (OnExecuteIDECommand<>nil) and (Key<>VK_UNKNOWN) then
OnExecuteIDECommand(Sender,Key,Shift,Areas);
end;
procedure ExecuteIDECommand(Sender: TObject; var Key: word; Shift: TShiftState);
begin
OnExecuteIDECommand(Sender,Key,Shift,caMenuOnly);
end;
{ TIDECommandCategory } { TIDECommandCategory }
procedure TIDECommandCategory.Delete(Index: Integer); procedure TIDECommandCategory.Delete(Index: Integer);

View File

@ -358,6 +358,7 @@ type
procedure OnMainPopupMenuPopup(Sender: TObject); procedure OnMainPopupMenuPopup(Sender: TObject);
procedure HookRefreshPropertyValues; procedure HookRefreshPropertyValues;
private private
FOnRemainingKeyUp: TKeyEvent;
FSelection: TPersistentSelectionList; FSelection: TPersistentSelectionList;
FComponentTreeHeight: integer; FComponentTreeHeight: integer;
FDefaultItemHeight: integer; FDefaultItemHeight: integer;
@ -414,6 +415,7 @@ type
read FPropertyEditorHook write SetPropertyEditorHook; read FPropertyEditorHook write SetPropertyEditorHook;
property OnModified: TNotifyEvent read FOnModified write FOnModified; property OnModified: TNotifyEvent read FOnModified write FOnModified;
property OnShowOptions: TNotifyEvent read FOnShowOptions write SetOnShowOptions; property OnShowOptions: TNotifyEvent read FOnShowOptions write SetOnShowOptions;
property OnRemainingKeyUp: TKeyEvent read FOnRemainingKeyUp write FOnRemainingKeyUp;
property ShowComponentTree: boolean read FShowComponentTree write SetShowComponentTree; property ShowComponentTree: boolean read FShowComponentTree write SetShowComponentTree;
property ComponentTreeHeight: integer read FComponentTreeHeight write SetComponentTreeHeight; property ComponentTreeHeight: integer read FComponentTreeHeight write SetComponentTreeHeight;
property UsePairSplitter: boolean read FUsePairSplitter write SetUsePairSplitter; property UsePairSplitter: boolean read FUsePairSplitter write SetUsePairSplitter;
@ -2261,16 +2263,18 @@ constructor TObjectInspector.Create(AnOwner: TComponent);
begin begin
inherited Create(AnOwner); inherited Create(AnOwner);
Caption := oisObjectInspector;
FPropertyEditorHook:=nil; FPropertyEditorHook:=nil;
FSelection:=TPersistentSelectionList.Create; FSelection:=TPersistentSelectionList.Create;
FUpdatingAvailComboBox:=false; FUpdatingAvailComboBox:=false;
Name := DefaultObjectInspectorName;
FDefaultItemHeight := 22; FDefaultItemHeight := 22;
FComponentTreeHeight:=100; FComponentTreeHeight:=100;
FShowComponentTree:=true; FShowComponentTree:=true;
FUsePairSplitter:=TPairSplitter.IsSupportedByInterface; FUsePairSplitter:=TPairSplitter.IsSupportedByInterface;
Caption := oisObjectInspector;
Name := DefaultObjectInspectorName;
KeyPreview:=true;
// StatusBar // StatusBar
StatusBar:=TStatusBar.Create(Self); StatusBar:=TStatusBar.Create(Self);
with StatusBar do begin with StatusBar do begin
@ -2844,6 +2848,8 @@ begin
if Key=VK_UNKNOWN then exit; if Key=VK_UNKNOWN then exit;
end; end;
inherited KeyDown(Key, Shift); inherited KeyDown(Key, Shift);
if (Key<>VK_UNKNOWN) and Assigned(OnRemainingKeyUp) then
OnRemainingKeyUp(Self,Key,Shift);
end; end;
procedure TObjectInspector.OnShowHintPopupMenuItemClick(Sender : TObject); procedure TObjectInspector.OnShowHintPopupMenuItemClick(Sender : TObject);

View File

@ -40,6 +40,7 @@ interface
uses uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Buttons, ComCtrls, Classes, SysUtils, LCLProc, LResources, Forms, Controls, Buttons, ComCtrls,
StdCtrls, Menus, Dialogs, Graphics, FileCtrl, AVL_Tree, StdCtrls, Menus, Dialogs, Graphics, FileCtrl, AVL_Tree,
IDECommands,
LazConf, LazarusIDEStrConsts, IDEProcs, IDEOptionDefs, EnvironmentOpts, LazConf, LazarusIDEStrConsts, IDEProcs, IDEOptionDefs, EnvironmentOpts,
Project, PackageDefs, PackageSystem, PackageEditor; Project, PackageDefs, PackageSystem, PackageEditor;
@ -86,6 +87,8 @@ type
procedure GetCurrentIsUsedBy(var Dependency: TPkgDependency); procedure GetCurrentIsUsedBy(var Dependency: TPkgDependency);
function SearchParentNodeWithText(ANode: TTreeNode; function SearchParentNodeWithText(ANode: TTreeNode;
const NodeText: string): TTreeNode; const NodeText: string): TTreeNode;
protected
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -444,6 +447,12 @@ begin
end; end;
end; end;
procedure TPkgGraphExplorer.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited KeyUp(Key, Shift);
ExecuteIDECommand(Self,Key,Shift,caMenuOnly);
end;
constructor TPkgGraphExplorer.Create(TheOwner: TComponent); constructor TPkgGraphExplorer.Create(TheOwner: TComponent);
var var
ALayout: TIDEWindowLayout; ALayout: TIDEWindowLayout;
@ -453,6 +462,7 @@ begin
fSortedPackages:=TAVLTree.Create(@CompareLazPackageID); fSortedPackages:=TAVLTree.Create(@CompareLazPackageID);
Name:=NonModalIDEWindowNames[nmiwPkgGraphExplorer]; Name:=NonModalIDEWindowNames[nmiwPkgGraphExplorer];
Caption:=lisMenuPackageGraph; Caption:=lisMenuPackageGraph;
KeyPreview:=true;
ALayout:=EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(Name); ALayout:=EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(Name);
ALayout.Form:=TForm(Self); ALayout.Form:=TForm(Self);