mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 04:29:25 +02:00
MG: custom external tools are now shown in the menu
git-svn-id: trunk@1846 -
This commit is contained in:
parent
9edfb60be4
commit
d5f0ff7d47
@ -168,7 +168,7 @@ ResourceString
|
||||
lisMenuCompilerOptions = 'Compiler Options...';
|
||||
lisMenuRunParameters = 'Run Parameters ...';
|
||||
|
||||
lisMenuSettings = 'Settings ...';
|
||||
lisMenuSettings = 'Configure custom tools ...';
|
||||
lisMenuQuickSyntaxCheck = 'Quick syntax check';
|
||||
lisMenuGuessUnclosedBlock = 'Guess unclosed block';
|
||||
lisMenuGuessMisplacedIFDEF = 'Guess misplaced IFDEF/ENDIF';
|
||||
|
108
ide/main.pp
108
ide/main.pp
@ -50,10 +50,11 @@ uses
|
||||
PropEdits, ControlSelection, UnitEditor, CompilerOptions, EditorOptions,
|
||||
EnvironmentOpts, TransferMacros, SynEditKeyCmds, KeyMapping, ProjectOpts,
|
||||
IDEProcs, Process, UnitInfoDlg, Debugger, DBGOutputForm, GDBMIDebugger,
|
||||
RunParamsOpts, ExtToolDialog, MacroPromptDlg, LMessages, ProjectDefs,
|
||||
Watchesdlg, BreakPointsdlg, ColumnDlg, OutputFilter, BuildLazDialog,
|
||||
MiscOptions, EditDefineTree, CodeToolsOptions, TypInfo, IDEOptionDefs,
|
||||
CodeToolsDefines, LocalsDlg, DebuggerDlg, InputHistory, DiskDiffsDialog,
|
||||
RunParamsOpts, ExtToolDialog, ExtToolEditDlg, MacroPromptDlg, LMessages,
|
||||
ProjectDefs, Watchesdlg, BreakPointsdlg, ColumnDlg, OutputFilter,
|
||||
BuildLazDialog, MiscOptions, EditDefineTree, CodeToolsOptions, TypInfo,
|
||||
IDEOptionDefs, CodeToolsDefines, LocalsDlg, DebuggerDlg, InputHistory,
|
||||
DiskDiffsDialog,
|
||||
// main ide
|
||||
BaseDebugManager, DebugManager, MainBar;
|
||||
|
||||
@ -143,6 +144,7 @@ type
|
||||
procedure mnuToolConvertDFMtoLFMClicked(Sender : TObject);
|
||||
procedure mnuToolBuildLazarusClicked(Sender : TObject);
|
||||
procedure mnuToolConfigBuildLazClicked(Sender : TObject);
|
||||
procedure mnuCustomExtToolClick(Sender : TObject);
|
||||
|
||||
// environment menu
|
||||
procedure mnuEnvGeneralOptionsClicked(Sender : TObject);
|
||||
@ -248,6 +250,8 @@ type
|
||||
FRunProcess: TProcess; // temp solution, will be replaced by dummydebugger
|
||||
TheCompiler: TCompiler;
|
||||
TheOutputFilter: TOutputFilter;
|
||||
|
||||
CustomExtToolMenuSeparator: TMenuItem;
|
||||
|
||||
procedure SetDefaultsForForm(aForm : TCustomForm);
|
||||
|
||||
@ -287,7 +291,7 @@ type
|
||||
procedure SetupControlSelection;
|
||||
procedure SetupStartProject;
|
||||
|
||||
// method for 'new unit'
|
||||
// methods for 'new unit'
|
||||
function CreateNewCodeBuffer(NewUnitType:TNewUnitType;
|
||||
NewFilename: string; var NewCodeBuffer: TCodeBuffer;
|
||||
var NewUnitName: string): TModalResult;
|
||||
@ -365,6 +369,7 @@ type
|
||||
|
||||
// tools
|
||||
function DoConvertDFMtoLFM: TModalResult;
|
||||
procedure UpdateCustomToolsInMenu;
|
||||
|
||||
// external tools
|
||||
function DoRunExternalTool(Index: integer): TModalResult;
|
||||
@ -1310,6 +1315,8 @@ begin
|
||||
itmToolConvertDFMtoLFM.OnClick := @mnuToolConvertDFMtoLFMClicked;
|
||||
itmToolBuildLazarus.OnClick := @mnuToolBuildLazarusClicked;
|
||||
itmToolConfigureBuildLazarus.OnClick := @mnuToolConfigBuildLazClicked;
|
||||
CustomExtToolMenuSeparator:=nil;
|
||||
UpdateCustomToolsInMenu;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.SetupEnvironmentMenu;
|
||||
@ -1947,9 +1954,7 @@ begin
|
||||
EnvironmentOptions.ExternalTools.SaveShortCuts(EditorOpts.KeyMap);
|
||||
EditorOpts.Save;
|
||||
SourceNotebook.ReloadEditorOptions;
|
||||
|
||||
// ToDo: update menu
|
||||
|
||||
UpdateCustomToolsInMenu;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1984,6 +1989,21 @@ begin
|
||||
MiscellaneousOptions.Save;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
procedure TMainIDE.mnuCustomExtToolClick(Sender: TObject);
|
||||
|
||||
Handler for clicking on a menuitem for a custom external tool.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TMainIDE.mnuCustomExtToolClick(Sender: TObject);
|
||||
var
|
||||
Index: integer;
|
||||
begin
|
||||
if CustomExtToolMenuSeparator=nil then exit;
|
||||
Index:=TMenuItem(Sender).MenuIndex-CustomExtToolMenuSeparator.MenuIndex-1;
|
||||
if (Index<0) or (Index>=EnvironmentOptions.ExternalTools.Count) then exit;
|
||||
DoRunExternalTool(Index);
|
||||
end;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
procedure TMainIDE.SaveDesktopSettings(
|
||||
@ -4673,6 +4693,75 @@ begin
|
||||
DoCheckFilesOnDisk;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
procedure TMainIDE.UpdateCustomToolsInMenu;
|
||||
|
||||
Creates a TMenuItem for each custom external tool.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TMainIDE.UpdateCustomToolsInMenu;
|
||||
var
|
||||
ToolCount: integer;
|
||||
|
||||
procedure CreateToolMenuItems;
|
||||
var
|
||||
CurMenuItem: TMenuItem;
|
||||
LastIndex, FirstIndex, ExistingCount: integer;
|
||||
begin
|
||||
// add separator
|
||||
if (ToolCount>0) and (CustomExtToolMenuSeparator=nil) then begin
|
||||
CustomExtToolMenuSeparator:=CreateMenuSeparator;
|
||||
mnuTools.Add(CustomExtToolMenuSeparator);
|
||||
end;
|
||||
// add enough menuitems
|
||||
if CustomExtToolMenuSeparator=nil then exit;
|
||||
FirstIndex:=CustomExtToolMenuSeparator.MenuIndex+1;
|
||||
LastIndex:=FirstIndex;
|
||||
while (LastIndex<mnuTools.Count) and (mnuTools[LastIndex].Caption<>'-') do
|
||||
inc(LastIndex);
|
||||
ExistingCount:=LastIndex-FirstIndex;
|
||||
while ExistingCount<ToolCount do begin
|
||||
CurMenuItem := TMenuItem.Create(Self);
|
||||
CurMenuItem.Name:='itmToolCustomExt'+IntToStr(ExistingCount);
|
||||
CurMenuItem.Caption:=CurMenuItem.Name;
|
||||
mnuTools.Insert(LastIndex,CurMenuItem);
|
||||
inc(LastIndex);
|
||||
inc(ExistingCount);
|
||||
end;
|
||||
// delete unneeded menuitems
|
||||
while ExistingCount>ToolCount do begin
|
||||
mnuTools[LastIndex].Free;
|
||||
dec(LastIndex);
|
||||
dec(ExistingCount);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SetToolMenuItems;
|
||||
var
|
||||
CurMenuItem: TMenuItem;
|
||||
i, Index: integer;
|
||||
ExtTool: TExternalToolOptions;
|
||||
begin
|
||||
if CustomExtToolMenuSeparator=nil then exit;
|
||||
i:=CustomExtToolMenuSeparator.MenuIndex+1;
|
||||
Index:=0;
|
||||
while (i<mnuTools.Count) do begin
|
||||
CurMenuItem:=mnuTools[i];
|
||||
if CurMenuItem.Caption='-' then break;
|
||||
ExtTool:=EnvironmentOptions.ExternalTools[Index];
|
||||
CurMenuItem.Caption:=ExtTool.Title;
|
||||
CurMenuItem.ShortCut:=ShortCut(ExtTool.Key,ExtTool.Shift);
|
||||
CurMenuItem.OnClick:=@mnuCustomExtToolClick;
|
||||
inc(i);
|
||||
inc(Index);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
ToolCount:=EnvironmentOptions.ExternalTools.Count;
|
||||
CreateToolMenuItems;
|
||||
SetToolMenuItems;
|
||||
end;
|
||||
|
||||
function TMainIDE.DoCheckSyntax: TModalResult;
|
||||
var
|
||||
ActiveUnitInfo:TUnitInfo;
|
||||
@ -6502,6 +6591,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.342 2002/08/16 20:13:07 lazarus
|
||||
MG: custom external tools are now shown in the menu
|
||||
|
||||
Revision 1.341 2002/08/16 19:00:54 lazarus
|
||||
MG: added Un-/Comment Selection
|
||||
|
||||
|
@ -494,6 +494,8 @@ begin
|
||||
itmFindBlockStart.Caption := lisMenuFindCodeBlockStart;
|
||||
mnuSearch.add(itmFindBlockStart);
|
||||
|
||||
mnuSearch.Add(CreateMenuSeparator);
|
||||
|
||||
itmFindDeclaration := TMenuItem.Create(Self);
|
||||
itmFindDeclaration.Name:='itmFindDeclaration';
|
||||
itmFindDeclaration.Caption := lisMenuFindDeclarationAtCursor;
|
||||
@ -705,6 +707,8 @@ begin
|
||||
itmToolConfigure.Caption := lisMenuSettings;
|
||||
mnuTools.Add(itmToolConfigure);
|
||||
|
||||
mnuTools.Add(CreateMenuSeparator);
|
||||
|
||||
itmToolSyntaxCheck := TMenuItem.Create(Self);
|
||||
itmToolSyntaxCheck.Name:='itmToolSyntaxCheck';
|
||||
itmToolSyntaxCheck.Caption := lisMenuQuickSyntaxCheck;
|
||||
@ -720,11 +724,15 @@ begin
|
||||
itmToolGuessMisplacedIFDEF.Caption := lisMenuGuessMisplacedIFDEF;
|
||||
mnuTools.Add(itmToolGuessMisplacedIFDEF);
|
||||
|
||||
mnuTools.Add(CreateMenuSeparator);
|
||||
|
||||
itmToolConvertDFMtoLFM := TMenuItem.Create(Self);
|
||||
itmToolConvertDFMtoLFM.Name:='itmToolConvertDFMtoLFM';
|
||||
itmToolConvertDFMtoLFM.Caption := lisMenuConvertDFMtoLFM;
|
||||
mnuTools.Add(itmToolConvertDFMtoLFM);
|
||||
|
||||
mnuTools.Add(CreateMenuSeparator);
|
||||
|
||||
itmToolBuildLazarus := TMenuItem.Create(Self);
|
||||
itmToolBuildLazarus.Name:='itmToolBuildLazarus';
|
||||
itmToolBuildLazarus.Caption := lisMenuBuildLazarus;
|
||||
|
@ -743,9 +743,9 @@ const
|
||||
//==============================================
|
||||
// Background Modes
|
||||
//==============================================
|
||||
TRANSPARENT = 1;
|
||||
OPAQUE = 2;
|
||||
BKMODE_LAST = 2;
|
||||
TRANSPARENT = 1;
|
||||
OPAQUE = 2;
|
||||
BKMODE_LAST = 2;
|
||||
|
||||
//==============================================
|
||||
// Font constants
|
||||
@ -1408,12 +1408,43 @@ const
|
||||
'primary selection', 'secondary selection', 'clipboard'
|
||||
);
|
||||
|
||||
|
||||
|
||||
function MapIrregularVirtualKey(vk: word): word;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
function MapIrregularVirtualKey(vk: word): word;
|
||||
begin
|
||||
if vk<VK_IRREGULAR then begin
|
||||
Result:=vk;
|
||||
exit;
|
||||
end;
|
||||
case vk-VK_IRREGULAR of
|
||||
|
||||
ord('0')..ord('9'):
|
||||
Result:=vk-VK_IRREGULAR-ord('0')+VK_0;
|
||||
|
||||
ord('A')..ord('Z'):
|
||||
Result:=vk-VK_IRREGULAR-ord('A')+VK_A;
|
||||
|
||||
ord('a')..ord('z'):
|
||||
Result:=vk-VK_IRREGULAR-ord('a')+VK_A;
|
||||
|
||||
else
|
||||
Result:=vk;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.10 2002/08/16 20:13:09 lazarus
|
||||
MG: custom external tools are now shown in the menu
|
||||
|
||||
Revision 1.9 2002/08/15 15:46:48 lazarus
|
||||
MG: added changes from Andrew (Clipping)
|
||||
|
||||
|
13
lcl/menus.pp
13
lcl/menus.pp
@ -292,7 +292,7 @@ function ShortCutToText(ShortCut: TShortCut): string;
|
||||
implementation
|
||||
|
||||
uses
|
||||
Interfaces, LCLLinux;
|
||||
Interfaces, LCLLinux, LCLType;
|
||||
|
||||
{ Menu command managment }
|
||||
|
||||
@ -431,10 +431,12 @@ end;
|
||||
|
||||
Function ShortCut(const Key: Word; const Shift : TShiftState) : TShortCut;
|
||||
Begin
|
||||
Result := 0;
|
||||
if WordRec(Key).Hi <> 0 then exit;
|
||||
Result := MapIrregularVirtualKey(Key);
|
||||
if WordRec(Result).Hi <> 0 then begin
|
||||
Result:=0;
|
||||
exit;
|
||||
end;
|
||||
|
||||
Result := Key;
|
||||
if ssShift in Shift then Inc(Result,scShift);
|
||||
if ssCtrl in Shift then Inc(Result,scCtrl);
|
||||
if ssAlt in Shift then Inc(Result,scAlt);
|
||||
@ -455,6 +457,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.24 2002/08/16 20:13:09 lazarus
|
||||
MG: custom external tools are now shown in the menu
|
||||
|
||||
Revision 1.23 2002/08/15 13:37:57 lazarus
|
||||
MG: started menuitem icon, checked, radio and groupindex
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user