mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 09:36:10 +02:00
IDE+object inspector: shwoing code help hints for properties
git-svn-id: trunk@17478 -
This commit is contained in:
parent
7c665e0d4c
commit
04b8a93513
@ -74,6 +74,7 @@ function FindDeclarationOfOIProperty(AnInspector: TObjectInspectorDlg;
|
|||||||
Row: TOIPropertyGridRow; out Code: TCodeBuffer; out Caret: TPoint;
|
Row: TOIPropertyGridRow; out Code: TCodeBuffer; out Caret: TPoint;
|
||||||
out NewTopLine: integer): Boolean;
|
out NewTopLine: integer): Boolean;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
function CreateDefaultOIFavouriteProperties: TOIFavouriteProperties;
|
function CreateDefaultOIFavouriteProperties: TOIFavouriteProperties;
|
||||||
|
@ -163,6 +163,9 @@ type
|
|||||||
var ErrMsg: string): TShowHelpResult; override;
|
var ErrMsg: string): TShowHelpResult; override;
|
||||||
procedure ShowHelpForMessage(Line: integer); override;
|
procedure ShowHelpForMessage(Line: integer); override;
|
||||||
procedure ShowHelpForObjectInspector(Sender: TObject); override;
|
procedure ShowHelpForObjectInspector(Sender: TObject); override;
|
||||||
|
function CreateHint(aHintWindow: THintWindow; ScreenPos: TPoint;
|
||||||
|
const BaseURL: string; var TheHint: string;
|
||||||
|
out HintWinRect: TRect): boolean; override;
|
||||||
function GetHintForSourcePosition(const ExpandedFilename: string;
|
function GetHintForSourcePosition(const ExpandedFilename: string;
|
||||||
const CodePos: TPoint;
|
const CodePos: TPoint;
|
||||||
out BaseURL, HTMLHint: string): TShowHelpResult;
|
out BaseURL, HTMLHint: string): TShowHelpResult;
|
||||||
@ -1245,6 +1248,50 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TIDEHelpManager.CreateHint(aHintWindow: THintWindow; ScreenPos: TPoint;
|
||||||
|
const BaseURL: string; var TheHint: string; out HintWinRect: TRect): boolean;
|
||||||
|
var
|
||||||
|
IsHTML: Boolean;
|
||||||
|
Provider: TAbstractIDEHTMLProvider;
|
||||||
|
HTMLControl: TControl;
|
||||||
|
ms: TMemoryStream;
|
||||||
|
NewWidth, NewHeight: integer;
|
||||||
|
begin
|
||||||
|
IsHTML:=SysUtils.CompareText(copy(TheHint,1,6),'<HTML>')=0;
|
||||||
|
|
||||||
|
if aHintWindow.ControlCount>0 then begin
|
||||||
|
aHintWindow.Controls[0].Free;
|
||||||
|
end;
|
||||||
|
if IsHTML then begin
|
||||||
|
Provider:=nil;
|
||||||
|
HTMLControl:=CreateIDEHTMLControl(aHintWindow,Provider);
|
||||||
|
Provider.BaseURL:=BaseURL;
|
||||||
|
HTMLControl.Parent:=aHintWindow;
|
||||||
|
HTMLControl.Align:=alClient;
|
||||||
|
ms:=TMemoryStream.Create;
|
||||||
|
try
|
||||||
|
if TheHint<>'' then
|
||||||
|
ms.Write(TheHint[1],length(TheHint));
|
||||||
|
ms.Position:=0;
|
||||||
|
Provider.ControlIntf.SetHTMLContent(ms);
|
||||||
|
finally
|
||||||
|
ms.Free;
|
||||||
|
end;
|
||||||
|
Provider.ControlIntf.GetPreferredControlSize(NewWidth,NewHeight);
|
||||||
|
if NewWidth<=0 then
|
||||||
|
NewWidth:=500;
|
||||||
|
if NewHeight<=0 then
|
||||||
|
NewHeight:=200;
|
||||||
|
HintWinRect := Rect(0,0,NewWidth,NewHeight);
|
||||||
|
TheHint:='';
|
||||||
|
end else begin
|
||||||
|
HintWinRect := aHintWindow.CalcHintRect(Screen.Width, TheHint, nil);
|
||||||
|
end;
|
||||||
|
OffsetRect(HintWinRect, ScreenPos.X, ScreenPos.Y+30);
|
||||||
|
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
function TIDEHelpManager.GetHintForSourcePosition(const ExpandedFilename: string;
|
function TIDEHelpManager.GetHintForSourcePosition(const ExpandedFilename: string;
|
||||||
const CodePos: TPoint; out BaseURL, HTMLHint: string): TShowHelpResult;
|
const CodePos: TPoint; out BaseURL, HTMLHint: string): TShowHelpResult;
|
||||||
var
|
var
|
||||||
|
283
ide/main.pp
283
ide/main.pp
@ -75,7 +75,7 @@ uses
|
|||||||
// lcl
|
// lcl
|
||||||
LCLProc, LCLMemManager, LCLType, LCLIntf, LConvEncoding, LMessages,
|
LCLProc, LCLMemManager, LCLType, LCLIntf, LConvEncoding, LMessages,
|
||||||
LResources, StdCtrls, Forms, Buttons, Menus, FileUtil, Controls, GraphType,
|
LResources, StdCtrls, Forms, Buttons, Menus, FileUtil, Controls, GraphType,
|
||||||
Graphics, ExtCtrls, Dialogs, InterfaceBase, LDockCtrl,
|
HelpIntfs, Graphics, ExtCtrls, Dialogs, InterfaceBase, LDockCtrl,
|
||||||
// codetools
|
// codetools
|
||||||
LinkScanner, BasicCodeTools, AVL_Tree, Laz_XMLCfg,
|
LinkScanner, BasicCodeTools, AVL_Tree, Laz_XMLCfg,
|
||||||
CodeToolsStructs, CodeToolManager, CodeCache, DefineTemplates,
|
CodeToolsStructs, CodeToolManager, CodeCache, DefineTemplates,
|
||||||
@ -83,8 +83,8 @@ uses
|
|||||||
SynEditKeyCmds,
|
SynEditKeyCmds,
|
||||||
// IDE interface
|
// IDE interface
|
||||||
AllIDEIntf, BaseIDEIntf, ObjectInspector, PropEdits, MacroIntf, IDECommands,
|
AllIDEIntf, BaseIDEIntf, ObjectInspector, PropEdits, MacroIntf, IDECommands,
|
||||||
SrcEditorIntf, NewItemIntf, IDEExternToolIntf, IDEMsgIntf, PackageIntf,
|
SrcEditorIntf, NewItemIntf, IDEExternToolIntf, IDEMsgIntf,
|
||||||
ProjectIntf, MenuIntf, LazIDEIntf, IDEDialogs,
|
PackageIntf, ProjectIntf, MenuIntf, LazIDEIntf, IDEDialogs,
|
||||||
// protocol
|
// protocol
|
||||||
IDEProtocol,
|
IDEProtocol,
|
||||||
// compile
|
// compile
|
||||||
@ -115,7 +115,7 @@ uses
|
|||||||
// rest of the ide
|
// rest of the ide
|
||||||
Splash, IDEDefs, LazarusIDEStrConsts, LazConf, MsgView, SearchResultView,
|
Splash, IDEDefs, LazarusIDEStrConsts, LazConf, MsgView, SearchResultView,
|
||||||
CodeTemplatesDlg, CodeBrowser,
|
CodeTemplatesDlg, CodeBrowser,
|
||||||
PublishModule, EnvironmentOpts, TransferMacros, KeyMapping,
|
PublishModule, EnvironmentOpts, TransferMacros, KeyMapping,
|
||||||
IDETranslations, IDEProcs, ExtToolDialog, ExtToolEditDlg, OutputFilter, JumpHistoryView,
|
IDETranslations, IDEProcs, ExtToolDialog, ExtToolEditDlg, OutputFilter, JumpHistoryView,
|
||||||
BuildLazDialog, MiscOptions, InputHistory, UnitDependencies, ClipBoardHistory,
|
BuildLazDialog, MiscOptions, InputHistory, UnitDependencies, ClipBoardHistory,
|
||||||
ProcessList, InitialSetupDlgs, NewDialog, MakeResStrDlg, ToDoList,
|
ProcessList, InitialSetupDlgs, NewDialog, MakeResStrDlg, ToDoList,
|
||||||
@ -126,7 +126,7 @@ uses
|
|||||||
// main ide
|
// main ide
|
||||||
MainBar, MainIntf, MainBase,
|
MainBar, MainIntf, MainBase,
|
||||||
// options frames
|
// options frames
|
||||||
IDEOptionsIntf, IDEOptionsDlg,
|
IDEOptionsIntf, IDEOptionsDlg,
|
||||||
options_files, options_desktop, options_window, options_formed, options_oi,
|
options_files, options_desktop, options_window, options_formed, options_oi,
|
||||||
options_backup, options_naming, options_fpdoc,
|
options_backup, options_naming, options_fpdoc,
|
||||||
options_editor_general, options_editor_display, options_editor_keymapping,
|
options_editor_general, options_editor_display, options_editor_keymapping,
|
||||||
@ -144,7 +144,7 @@ type
|
|||||||
);
|
);
|
||||||
|
|
||||||
{ TMainIDE }
|
{ TMainIDE }
|
||||||
|
|
||||||
TMainIDE = class(TMainIDEBase)
|
TMainIDE = class(TMainIDEBase)
|
||||||
// event handlers
|
// event handlers
|
||||||
procedure MainIDEFormClose(Sender: TObject; var CloseAction: TCloseAction);
|
procedure MainIDEFormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||||
@ -390,8 +390,11 @@ type
|
|||||||
procedure OIOnAddToFavourites(Sender: TObject);
|
procedure OIOnAddToFavourites(Sender: TObject);
|
||||||
procedure OIOnRemoveFromFavourites(Sender: TObject);
|
procedure OIOnRemoveFromFavourites(Sender: TObject);
|
||||||
procedure OIOnFindDeclarationOfProperty(Sender: TObject);
|
procedure OIOnFindDeclarationOfProperty(Sender: TObject);
|
||||||
procedure OIOnUpdateRestricted(Sender: TObject);
|
|
||||||
procedure OIOnSelectionChange(Sender: TObject);
|
procedure OIOnSelectionChange(Sender: TObject);
|
||||||
|
function OIOnPropertyHint(Sender: TObject; PointedRow: TOIPropertyGridRow;
|
||||||
|
ScreenPos: TPoint; aHintWindow: THintWindow;
|
||||||
|
out HintWinRect: TRect; out AHint: string): boolean;
|
||||||
|
procedure OIOnUpdateRestricted(Sender: TObject);
|
||||||
function OnPropHookGetMethodName(const Method: TMethod;
|
function OnPropHookGetMethodName(const Method: TMethod;
|
||||||
PropOwner: TObject): String;
|
PropOwner: TObject): String;
|
||||||
procedure OnPropHookGetMethods(TypeData: PTypeData; Proc:TGetStringProc);
|
procedure OnPropHookGetMethods(TypeData: PTypeData; Proc:TGetStringProc);
|
||||||
@ -522,7 +525,7 @@ type
|
|||||||
FRemoteControlFileValid: boolean;
|
FRemoteControlFileValid: boolean;
|
||||||
|
|
||||||
FRebuildingCompilerGraphCodeToolsDefinesNeeded: boolean;
|
FRebuildingCompilerGraphCodeToolsDefinesNeeded: boolean;
|
||||||
|
|
||||||
FRenamingComponents: TFPList; // list of TComponents currently renaming
|
FRenamingComponents: TFPList; // list of TComponents currently renaming
|
||||||
FOIHelpProvider: TAbstractIDEHTMLProvider;
|
FOIHelpProvider: TAbstractIDEHTMLProvider;
|
||||||
|
|
||||||
@ -748,7 +751,7 @@ type
|
|||||||
function DoTestCompilerSettings(
|
function DoTestCompilerSettings(
|
||||||
TheCompilerOptions: TCompilerOptions): TModalResult;
|
TheCompilerOptions: TCompilerOptions): TModalResult;
|
||||||
function QuitIDE: boolean;
|
function QuitIDE: boolean;
|
||||||
|
|
||||||
// edit menu
|
// edit menu
|
||||||
procedure DoCommand(EditorCommand: integer); override;
|
procedure DoCommand(EditorCommand: integer); override;
|
||||||
procedure DoSourceEditorCommand(EditorCommand: integer);
|
procedure DoSourceEditorCommand(EditorCommand: integer);
|
||||||
@ -1032,7 +1035,7 @@ begin
|
|||||||
Application.Terminate;
|
Application.Terminate;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SetParamOptions(SkipAutoLoadingLastProject, StartedByStartLazarus, EnableRemoteControl, ShowSplashScreen);
|
SetParamOptions(SkipAutoLoadingLastProject, StartedByStartLazarus, EnableRemoteControl, ShowSplashScreen);
|
||||||
|
|
||||||
DebugLn('TMainIDE.ParseCmdLineOptions:');
|
DebugLn('TMainIDE.ParseCmdLineOptions:');
|
||||||
@ -1196,7 +1199,7 @@ begin
|
|||||||
Application.AddOnDropFilesHandler(@OnApplicationDropFiles);
|
Application.AddOnDropFilesHandler(@OnApplicationDropFiles);
|
||||||
Screen.AddHandlerRemoveForm(@OnScreenRemoveForm);
|
Screen.AddHandlerRemoveForm(@OnScreenRemoveForm);
|
||||||
SetupHints;
|
SetupHints;
|
||||||
|
|
||||||
// Now load a project
|
// Now load a project
|
||||||
SetupStartProject;
|
SetupStartProject;
|
||||||
|
|
||||||
@ -1265,7 +1268,7 @@ begin
|
|||||||
FreeThenNil(EditorOpts);
|
FreeThenNil(EditorOpts);
|
||||||
FreeThenNil(EnvironmentOptions);
|
FreeThenNil(EnvironmentOptions);
|
||||||
FreeThenNil(IDECommandScopes);
|
FreeThenNil(IDECommandScopes);
|
||||||
|
|
||||||
// free control selection
|
// free control selection
|
||||||
if TheControlSelection<>nil then
|
if TheControlSelection<>nil then
|
||||||
FreeThenNil(TheControlSelection);
|
FreeThenNil(TheControlSelection);
|
||||||
@ -1324,8 +1327,8 @@ begin
|
|||||||
else
|
else
|
||||||
if C.InheritsFrom(TFrame) then C := TFrame;
|
if C.InheritsFrom(TFrame) then C := TFrame;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
if ObjectInspector1.GetActivePropertyRow = nil then
|
if ObjectInspector1.GetActivePropertyRow = nil then
|
||||||
begin
|
begin
|
||||||
if C <> nil then
|
if C <> nil then
|
||||||
@ -1380,6 +1383,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.OIOnSelectionChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
// handled by property hook
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMainIDE.OIOnPropertyHint(Sender: TObject;
|
||||||
|
PointedRow: TOIPropertyGridRow; ScreenPos: TPoint; aHintWindow: THintWindow;
|
||||||
|
out HintWinRect: TRect; out AHint: string): boolean;
|
||||||
|
var
|
||||||
|
Code: TCodeBuffer;
|
||||||
|
Caret: TPoint;
|
||||||
|
NewTopLine: integer;
|
||||||
|
BaseURL: string;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
AHint:='';
|
||||||
|
HintWinRect:=Rect(0,0,0,0);
|
||||||
|
if not BeginCodeTools then exit;
|
||||||
|
if FindDeclarationOfOIProperty(ObjectInspector1,PointedRow,Code,Caret,NewTopLine)
|
||||||
|
then begin
|
||||||
|
if TIDEHelpManager(HelpBoss).GetHintForSourcePosition(Code.Filename,
|
||||||
|
Caret,BaseURL,aHint)=shrSuccess
|
||||||
|
then begin
|
||||||
|
Result:=HelpBoss.CreateHint(aHintWindow,ScreenPos,BaseURL,aHint,HintWinRect);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OIOnUpdateRestricted(Sender: TObject);
|
procedure TMainIDE.OIOnUpdateRestricted(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if Sender = nil then Sender := ObjectInspector1;
|
if Sender = nil then Sender := ObjectInspector1;
|
||||||
@ -1389,49 +1420,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OIOnSelectionChange(Sender: TObject);
|
|
||||||
var
|
|
||||||
OI: TObjectInspectorDlg absolute Sender;
|
|
||||||
Row: TOIPropertyGridRow;
|
|
||||||
Code: TCodeBuffer;
|
|
||||||
Caret: TPoint;
|
|
||||||
NewTopLine: integer;
|
|
||||||
BaseURL, HTMLHint: String;
|
|
||||||
CacheWasUsed: Boolean;
|
|
||||||
Stream: TStringStream;
|
|
||||||
begin
|
|
||||||
if (Sender is TObjectInspectorDlg) then
|
|
||||||
begin
|
|
||||||
if OI.ShowInfoBox then
|
|
||||||
begin
|
|
||||||
Row := OI.GetActivePropertyRow;
|
|
||||||
Stream := nil;
|
|
||||||
if (Row <> nil) and FindDeclarationOfOIProperty(OI, Row, Code, Caret, NewTopLine) then
|
|
||||||
begin
|
|
||||||
if CodeHelpBoss.GetHTMLHint(Code, Caret.X, Caret.Y, True, BaseURL, HTMLHint, CacheWasUsed) = chprSuccess then
|
|
||||||
begin
|
|
||||||
FOIHelpProvider.BaseURL := BaseURL;
|
|
||||||
Stream := TStringStream.Create(HTMLHint);
|
|
||||||
try
|
|
||||||
FOIHelpProvider.ControlIntf.SetHTMLContent(Stream);
|
|
||||||
finally
|
|
||||||
Stream.Free;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if Stream = nil then
|
|
||||||
begin
|
|
||||||
Stream := TStringStream.Create('');
|
|
||||||
try
|
|
||||||
FOIHelpProvider.ControlIntf.SetHTMLContent(Stream);
|
|
||||||
finally
|
|
||||||
Stream.Free;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TMainIDE.OnPropHookGetMethodName(const Method: TMethod;
|
function TMainIDE.OnPropHookGetMethodName(const Method: TMethod;
|
||||||
PropOwner: TObject): String;
|
PropOwner: TObject): String;
|
||||||
var
|
var
|
||||||
@ -1694,6 +1682,7 @@ begin
|
|||||||
ObjectInspector1.OnShowOptions:=@OIOnShowOptions;
|
ObjectInspector1.OnShowOptions:=@OIOnShowOptions;
|
||||||
ObjectInspector1.OnViewRestricted:=@OIOnViewRestricted;
|
ObjectInspector1.OnViewRestricted:=@OIOnViewRestricted;
|
||||||
ObjectInspector1.OnSelectionChange:=@OIOnSelectionChange;
|
ObjectInspector1.OnSelectionChange:=@OIOnSelectionChange;
|
||||||
|
ObjectInspector1.OnPropertyHint:=@OIOnPropertyHint;
|
||||||
ObjectInspector1.OnDestroy:=@OIOnDestroy;
|
ObjectInspector1.OnDestroy:=@OIOnDestroy;
|
||||||
HelpControl := CreateIDEHTMLControl(ObjectInspector1, FOIHelpProvider);
|
HelpControl := CreateIDEHTMLControl(ObjectInspector1, FOIHelpProvider);
|
||||||
HelpControl.Parent := ObjectInspector1.InfoPanel;
|
HelpControl.Parent := ObjectInspector1.InfoPanel;
|
||||||
@ -1788,7 +1777,7 @@ begin
|
|||||||
MainIDEBar.itmFindBlockOtherEnd.OnClick:=@mnuSearchFindBlockOtherEnd;
|
MainIDEBar.itmFindBlockOtherEnd.OnClick:=@mnuSearchFindBlockOtherEnd;
|
||||||
MainIDEBar.itmFindDeclaration.OnClick:=@mnuSearchFindDeclaration;
|
MainIDEBar.itmFindDeclaration.OnClick:=@mnuSearchFindDeclaration;
|
||||||
MainIDEBar.itmOpenFileAtCursor.OnClick:=@mnuOpenFileAtCursorClicked;
|
MainIDEBar.itmOpenFileAtCursor.OnClick:=@mnuOpenFileAtCursorClicked;
|
||||||
|
|
||||||
SourceNotebook.InitMacros(GlobalMacroList);
|
SourceNotebook.InitMacros(GlobalMacroList);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2293,7 +2282,7 @@ end;
|
|||||||
procedure TMainIDE.SetupEnvironmentMenu;
|
procedure TMainIDE.SetupEnvironmentMenu;
|
||||||
begin
|
begin
|
||||||
inherited SetupEnvironmentMenu;
|
inherited SetupEnvironmentMenu;
|
||||||
with MainIDEBar do
|
with MainIDEBar do
|
||||||
begin
|
begin
|
||||||
itmEnvGeneralOptions.OnClick := @mnuEnvGeneralOptionsClicked;
|
itmEnvGeneralOptions.OnClick := @mnuEnvGeneralOptionsClicked;
|
||||||
itmEnvCodeTemplates.OnClick := @mnuEnvCodeTemplatesClicked;
|
itmEnvCodeTemplates.OnClick := @mnuEnvCodeTemplatesClicked;
|
||||||
@ -2354,7 +2343,7 @@ end;
|
|||||||
procedure TMainIDE.SetDesigning(AComponent: TComponent; Value: Boolean);
|
procedure TMainIDE.SetDesigning(AComponent: TComponent; Value: Boolean);
|
||||||
begin
|
begin
|
||||||
SetComponentDesignMode(AComponent, Value);
|
SetComponentDesignMode(AComponent, Value);
|
||||||
if Value then
|
if Value then
|
||||||
WidgetSet.SetDesigning(AComponent);
|
WidgetSet.SetDesigning(AComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2761,7 +2750,7 @@ begin
|
|||||||
|
|
||||||
ecViewComponents:
|
ecViewComponents:
|
||||||
DoShowComponentList;
|
DoShowComponentList;
|
||||||
|
|
||||||
ecToggleFPDocEditor:
|
ecToggleFPDocEditor:
|
||||||
DoShowFPDocEditor;
|
DoShowFPDocEditor;
|
||||||
|
|
||||||
@ -2821,16 +2810,16 @@ begin
|
|||||||
|
|
||||||
ecRemoveBreakPoint:
|
ecRemoveBreakPoint:
|
||||||
SourceNotebook.DeleteBreakpointClicked(Self);
|
SourceNotebook.DeleteBreakpointClicked(Self);
|
||||||
|
|
||||||
ecProcedureList:
|
ecProcedureList:
|
||||||
mnuSearchProcedureList(self);
|
mnuSearchProcedureList(self);
|
||||||
|
|
||||||
ecInsertGUID:
|
ecInsertGUID:
|
||||||
mnuEditInsertGUID(self);
|
mnuEditInsertGUID(self);
|
||||||
|
|
||||||
ecInsertTodo:
|
ecInsertTodo:
|
||||||
mnuEditInsertTodo(self);
|
mnuEditInsertTodo(self);
|
||||||
|
|
||||||
else
|
else
|
||||||
Handled:=false;
|
Handled:=false;
|
||||||
// let the bosses handle it
|
// let the bosses handle it
|
||||||
@ -3413,7 +3402,7 @@ begin
|
|||||||
|
|
||||||
// close
|
// close
|
||||||
DoCloseProject;
|
DoCloseProject;
|
||||||
|
|
||||||
// ask what to do next
|
// ask what to do next
|
||||||
while (Project1=nil) do begin
|
while (Project1=nil) do begin
|
||||||
case ShowProjectWizardDlg of
|
case ShowProjectWizardDlg of
|
||||||
@ -3503,13 +3492,13 @@ begin
|
|||||||
if POOutDir<>'' then
|
if POOutDir<>'' then
|
||||||
POFilename:=TrimFilename(AppendPathDelim(POOutDir)+ExtractFileName(POFilename));
|
POFilename:=TrimFilename(AppendPathDelim(POOutDir)+ExtractFileName(POFilename));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
POFileAgeValid:=false;
|
POFileAgeValid:=false;
|
||||||
if FileExistsCached(POFilename) then begin
|
if FileExistsCached(POFilename) then begin
|
||||||
POFileAge:=FileAgeUTF8(POFilename);
|
POFileAge:=FileAgeUTF8(POFilename);
|
||||||
POFileAgeValid:=true;
|
POFileAgeValid:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//DebugLn(['TMainIDE.UpdateProjectPOFile Updating POFilename="',POFilename,'"']);
|
//DebugLn(['TMainIDE.UpdateProjectPOFile Updating POFilename="',POFilename,'"']);
|
||||||
|
|
||||||
Files := TStringList.Create;
|
Files := TStringList.Create;
|
||||||
@ -3526,7 +3515,7 @@ begin
|
|||||||
Files.Add(LRTFilename);
|
Files.Add(LRTFilename);
|
||||||
// check .rst file
|
// check .rst file
|
||||||
RSTFilename:=ExtractFileName(ChangeFileExt(CurFilename,'.rst'));
|
RSTFilename:=ExtractFileName(ChangeFileExt(CurFilename,'.rst'));
|
||||||
|
|
||||||
// the compiler puts the .rst in the unit output directory
|
// the compiler puts the .rst in the unit output directory
|
||||||
UnitOutputDir:=AProject.GetOutputDirectory;
|
UnitOutputDir:=AProject.GetOutputDirectory;
|
||||||
if UnitOutputDir='' then
|
if UnitOutputDir='' then
|
||||||
@ -3542,7 +3531,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
|
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
UpdatePoFile(Files, POFilename);
|
UpdatePoFile(Files, POFilename);
|
||||||
Result := mrOk;
|
Result := mrOk;
|
||||||
@ -3553,7 +3542,7 @@ begin
|
|||||||
E.Message]), mtError, [mbOk]);
|
E.Message]), mtError, [mbOk]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
Files.Destroy;
|
Files.Destroy;
|
||||||
end;
|
end;
|
||||||
@ -4021,7 +4010,7 @@ begin
|
|||||||
// load settings from CodetoolsOption to IDEOptionsDialog
|
// load settings from CodetoolsOption to IDEOptionsDialog
|
||||||
ReadSettings(CodeToolsOpts);
|
ReadSettings(CodeToolsOpts);
|
||||||
end;
|
end;
|
||||||
if IDEOptionsDialog.ShowModal = mrOk then
|
if IDEOptionsDialog.ShowModal = mrOk then
|
||||||
begin
|
begin
|
||||||
// invalidate cached substituted macros
|
// invalidate cached substituted macros
|
||||||
IncreaseCompilerParseStamp;
|
IncreaseCompilerParseStamp;
|
||||||
@ -4037,7 +4026,7 @@ begin
|
|||||||
UpdateDefaultPascalFileExtensions;
|
UpdateDefaultPascalFileExtensions;
|
||||||
|
|
||||||
//DebugLn(['TMainIDE.DoShowEnvGeneralOptions OldLanguage=',OldLanguage,' EnvironmentOptions.LanguageID=',EnvironmentOptions.LanguageID]);
|
//DebugLn(['TMainIDE.DoShowEnvGeneralOptions OldLanguage=',OldLanguage,' EnvironmentOptions.LanguageID=',EnvironmentOptions.LanguageID]);
|
||||||
if OldLanguage<>EnvironmentOptions.LanguageID then
|
if OldLanguage<>EnvironmentOptions.LanguageID then
|
||||||
begin
|
begin
|
||||||
TranslateResourceStrings(EnvironmentOptions.LazarusDirectory,
|
TranslateResourceStrings(EnvironmentOptions.LazarusDirectory,
|
||||||
EnvironmentOptions.LanguageID);
|
EnvironmentOptions.LanguageID);
|
||||||
@ -4216,9 +4205,9 @@ begin
|
|||||||
NewUnitInfo.ComponentName:=NewComponent.Name;
|
NewUnitInfo.ComponentName:=NewComponent.Name;
|
||||||
NewUnitInfo.ComponentResourceName:=NewUnitInfo.ComponentName;
|
NewUnitInfo.ComponentResourceName:=NewUnitInfo.ComponentName;
|
||||||
if UseCreateFormStatements and
|
if UseCreateFormStatements and
|
||||||
NewUnitInfo.IsPartOfProject and
|
NewUnitInfo.IsPartOfProject and
|
||||||
Project1.AutoCreateForms and
|
Project1.AutoCreateForms and
|
||||||
(pfMainUnitHasCreateFormStatements in Project1.Flags) then
|
(pfMainUnitHasCreateFormStatements in Project1.Flags) then
|
||||||
begin
|
begin
|
||||||
Project1.AddCreateFormToProjectFile(NewComponent.ClassName,
|
Project1.AddCreateFormToProjectFile(NewComponent.ClassName,
|
||||||
NewComponent.Name);
|
NewComponent.Name);
|
||||||
@ -4295,7 +4284,7 @@ begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||||
if not FileExistsInIDE(LFMFilename,[]) then begin
|
if not FileExistsInIDE(LFMFilename,[]) then begin
|
||||||
DebugLn(['TMainIDE.DoOpenComponent file not found ',LFMFilename]);
|
DebugLn(['TMainIDE.DoOpenComponent file not found ',LFMFilename]);
|
||||||
@ -4329,7 +4318,7 @@ begin
|
|||||||
debugln('TMainIDE.DoOpenComponent DoLoadLFM failed ',LFMFilename);
|
debugln('TMainIDE.DoOpenComponent DoLoadLFM failed ',LFMFilename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Component:=AnUnitInfo.Component;
|
Component:=AnUnitInfo.Component;
|
||||||
if Component<>nil then
|
if Component<>nil then
|
||||||
Result:=mrOk
|
Result:=mrOk
|
||||||
@ -5381,7 +5370,7 @@ begin
|
|||||||
ReferencesLocked:=true;
|
ReferencesLocked:=true;
|
||||||
Project1.LockUnitComponentDependencies;
|
Project1.LockUnitComponentDependencies;
|
||||||
Project1.UpdateUnitComponentDependencies;
|
Project1.UpdateUnitComponentDependencies;
|
||||||
|
|
||||||
// close old designer form
|
// close old designer form
|
||||||
Result:=CloseUnitComponent(AnUnitInfo,CloseFlags);
|
Result:=CloseUnitComponent(AnUnitInfo,CloseFlags);
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
@ -5413,7 +5402,7 @@ begin
|
|||||||
|
|
||||||
if AnUnitInfo.Component=nil then begin
|
if AnUnitInfo.Component=nil then begin
|
||||||
// load/create new instance
|
// load/create new instance
|
||||||
|
|
||||||
// find the classname of the LFM, and check for inherited form
|
// find the classname of the LFM, and check for inherited form
|
||||||
QuickCheckLFMBuffer(AnUnitInfo.Source,LFMBuf,LFMType,LFMComponentName,
|
QuickCheckLFMBuffer(AnUnitInfo.Source,LFMBuf,LFMType,LFMComponentName,
|
||||||
NewClassName,LCLVersion,MissingClasses);
|
NewClassName,LCLVersion,MissingClasses);
|
||||||
@ -5474,7 +5463,7 @@ begin
|
|||||||
LRSObjectTextToBinary(TxtLFMStream,BinStream);
|
LRSObjectTextToBinary(TxtLFMStream,BinStream);
|
||||||
AnUnitInfo.ComponentLastBinStreamSize:=BinStream.Size;
|
AnUnitInfo.ComponentLastBinStreamSize:=BinStream.Size;
|
||||||
BinStream.Position:=0;
|
BinStream.Position:=0;
|
||||||
|
|
||||||
{$IFDEF VerboseIDELFMConversion}
|
{$IFDEF VerboseIDELFMConversion}
|
||||||
DebugLn(['TMainIDE.DoLoadLFM Binary START =======================================']);
|
DebugLn(['TMainIDE.DoLoadLFM Binary START =======================================']);
|
||||||
debugln(dbgMemStream(BinStream,BinStream.Size));
|
debugln(dbgMemStream(BinStream,BinStream.Size));
|
||||||
@ -5649,7 +5638,7 @@ var
|
|||||||
Result:=RefUnitInfo.Filename;
|
Result:=RefUnitInfo.Filename;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// search in the used units of the .lpr files
|
// search in the used units of the .lpr files
|
||||||
if (Project1.MainUnitInfo<>nil)
|
if (Project1.MainUnitInfo<>nil)
|
||||||
and (Project1.MainUnitInfo.Source<>nil)
|
and (Project1.MainUnitInfo.Source<>nil)
|
||||||
@ -5688,10 +5677,10 @@ var
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:='';
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LoadDependencyHidden(const RefRootName: string): TModalResult;
|
function LoadDependencyHidden(const RefRootName: string): TModalResult;
|
||||||
var
|
var
|
||||||
LFMFilename: String;
|
LFMFilename: String;
|
||||||
@ -5701,7 +5690,7 @@ var
|
|||||||
RefUnitInfo: TUnitInfo;
|
RefUnitInfo: TUnitInfo;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
|
|
||||||
// load lfm
|
// load lfm
|
||||||
UnitFilename:=FindUnitFilename(RefRootName);
|
UnitFilename:=FindUnitFilename(RefRootName);
|
||||||
if UnitFilename='' then begin
|
if UnitFilename='' then begin
|
||||||
@ -5714,7 +5703,7 @@ var
|
|||||||
debugln('TMainIDE.DoFixupComponentReferences Failed loading ',LFMFilename);
|
debugln('TMainIDE.DoFixupComponentReferences Failed loading ',LFMFilename);
|
||||||
exit(mrCancel);
|
exit(mrCancel);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
RefUnitInfo:=Project1.UnitInfoWithFilename(UnitFilename);
|
RefUnitInfo:=Project1.UnitInfoWithFilename(UnitFilename);
|
||||||
// create unit info
|
// create unit info
|
||||||
if RefUnitInfo=nil then begin
|
if RefUnitInfo=nil then begin
|
||||||
@ -5732,7 +5721,7 @@ var
|
|||||||
end;
|
end;
|
||||||
RefUnitInfo.Source := UnitCode;
|
RefUnitInfo.Source := UnitCode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if RefUnitInfo.Component<>nil then begin
|
if RefUnitInfo.Component<>nil then begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
exit;
|
exit;
|
||||||
@ -5742,7 +5731,7 @@ var
|
|||||||
Result:=DoLoadLFM(RefUnitInfo,LFMCode,
|
Result:=DoLoadLFM(RefUnitInfo,LFMCode,
|
||||||
OpenFlags+[ofLoadHiddenResource],[]);
|
OpenFlags+[ofLoadHiddenResource],[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
CurRoot: TComponent;
|
CurRoot: TComponent;
|
||||||
ReferenceRootNames: TStringList;
|
ReferenceRootNames: TStringList;
|
||||||
@ -5770,7 +5759,7 @@ begin
|
|||||||
// load the referenced component
|
// load the referenced component
|
||||||
Result:=LoadDependencyHidden(RefRootName);
|
Result:=LoadDependencyHidden(RefRootName);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
GlobalFixupReferences;
|
GlobalFixupReferences;
|
||||||
ReferenceInstanceNames.Clear;
|
ReferenceInstanceNames.Clear;
|
||||||
GetFixupInstanceNames(CurRoot,RefRootName,ReferenceInstanceNames);
|
GetFixupInstanceNames(CurRoot,RefRootName,ReferenceInstanceNames);
|
||||||
@ -5778,7 +5767,7 @@ begin
|
|||||||
|
|
||||||
// forget the rest of the dangling references
|
// forget the rest of the dangling references
|
||||||
RemoveFixupReferences(CurRoot,RefRootName);
|
RemoveFixupReferences(CurRoot,RefRootName);
|
||||||
|
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
// ToDo: give a nice error message and give user the choice between
|
// ToDo: give a nice error message and give user the choice between
|
||||||
// a) ignore and loose the references
|
// a) ignore and loose the references
|
||||||
@ -5883,7 +5872,7 @@ var
|
|||||||
TheModalResult:=mrCancel;
|
TheModalResult:=mrCancel;
|
||||||
LFMCode:=nil;
|
LFMCode:=nil;
|
||||||
ClassFound:=false;
|
ClassFound:=false;
|
||||||
|
|
||||||
AncestorClassName:='';
|
AncestorClassName:='';
|
||||||
if not CodeToolBoss.FindFormAncestor(UnitCode,AComponentClassName,
|
if not CodeToolBoss.FindFormAncestor(UnitCode,AComponentClassName,
|
||||||
AncestorClassName,true) then
|
AncestorClassName,true) then
|
||||||
@ -5929,7 +5918,7 @@ var
|
|||||||
LFMCode.Source:=
|
LFMCode.Source:=
|
||||||
'inherited '+AComponentName+': '+AComponentClassName+LineEnding
|
'inherited '+AComponentName+': '+AComponentClassName+LineEnding
|
||||||
+'end';
|
+'end';
|
||||||
|
|
||||||
Result:=true;
|
Result:=true;
|
||||||
TheModalResult:=mrOk;
|
TheModalResult:=mrOk;
|
||||||
end;
|
end;
|
||||||
@ -5949,7 +5938,7 @@ var
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
TheModalResult:=mrCancel;
|
TheModalResult:=mrCancel;
|
||||||
if not FilenameIsPascalUnit(UnitFilename) then exit;
|
if not FilenameIsPascalUnit(UnitFilename) then exit;
|
||||||
|
|
||||||
CurUnitInfo:=Project1.UnitInfoWithFilename(UnitFilename);
|
CurUnitInfo:=Project1.UnitInfoWithFilename(UnitFilename);
|
||||||
if (CurUnitInfo<>nil) and (CurUnitInfo.Component<>nil) then
|
if (CurUnitInfo<>nil) and (CurUnitInfo.Component<>nil) then
|
||||||
begin
|
begin
|
||||||
@ -5967,7 +5956,7 @@ var
|
|||||||
end;
|
end;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not TryWithoutLFM then begin
|
if not TryWithoutLFM then begin
|
||||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||||
if FileExistsUTF8(LFMFilename) then begin
|
if FileExistsUTF8(LFMFilename) then begin
|
||||||
@ -5981,7 +5970,7 @@ var
|
|||||||
ReadLFMHeader(LFMCode.Source,LFMClassName,LFMType);
|
ReadLFMHeader(LFMCode.Source,LFMClassName,LFMType);
|
||||||
if LFMType='' then ;
|
if LFMType='' then ;
|
||||||
if SysUtils.CompareText(LFMClassName,AComponentClassName)<>0 then exit;
|
if SysUtils.CompareText(LFMClassName,AComponentClassName)<>0 then exit;
|
||||||
|
|
||||||
// .lfm found
|
// .lfm found
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end else if not TryWithoutLFM then begin
|
end else if not TryWithoutLFM then begin
|
||||||
@ -5997,18 +5986,18 @@ var
|
|||||||
debugln('TMainIDE.DoLoadComponentDependencyHidden Failed loading ',UnitFilename);
|
debugln('TMainIDE.DoLoadComponentDependencyHidden Failed loading ',UnitFilename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if TryWithoutLFM then begin
|
if TryWithoutLFM then begin
|
||||||
if not FindClassInUnit(UnitCode,TheModalResult,LFMCode,Result) then exit;
|
if not FindClassInUnit(UnitCode,TheModalResult,LFMCode,Result) then exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// create unit info
|
// create unit info
|
||||||
if CurUnitInfo=nil then begin
|
if CurUnitInfo=nil then begin
|
||||||
CurUnitInfo:=TUnitInfo.Create(UnitCode);
|
CurUnitInfo:=TUnitInfo.Create(UnitCode);
|
||||||
CurUnitInfo.ReadUnitNameFromSource(true);
|
CurUnitInfo.ReadUnitNameFromSource(true);
|
||||||
Project1.AddFile(CurUnitInfo,false);
|
Project1.AddFile(CurUnitInfo,false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// load resource hidden
|
// load resource hidden
|
||||||
TheModalResult:=DoLoadLFM(CurUnitInfo,LFMCode,
|
TheModalResult:=DoLoadLFM(CurUnitInfo,LFMCode,
|
||||||
Flags+[ofLoadHiddenResource],[]);
|
Flags+[ofLoadHiddenResource],[]);
|
||||||
@ -6023,7 +6012,7 @@ var
|
|||||||
TheModalResult:=mrCancel;
|
TheModalResult:=mrCancel;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TryRegisteredClasses(out TheModalResult: TModalResult): boolean;
|
function TryRegisteredClasses(out TheModalResult: TModalResult): boolean;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
@ -6045,7 +6034,7 @@ begin
|
|||||||
CTErrorCode:=nil;
|
CTErrorCode:=nil;
|
||||||
CTErrorLine:=0;
|
CTErrorLine:=0;
|
||||||
CTErrorCol:=0;
|
CTErrorCol:=0;
|
||||||
|
|
||||||
if (AComponentClassName='') or (not IsValidIdent(AComponentClassName)) then
|
if (AComponentClassName='') or (not IsValidIdent(AComponentClassName)) then
|
||||||
begin
|
begin
|
||||||
DebugLn(['TMainIDE.DoLoadComponentDependencyHidden invalid component class name "',AComponentClassName,'"']);
|
DebugLn(['TMainIDE.DoLoadComponentDependencyHidden invalid component class name "',AComponentClassName,'"']);
|
||||||
@ -6074,7 +6063,7 @@ begin
|
|||||||
|
|
||||||
// then try registered global classes
|
// then try registered global classes
|
||||||
if TryRegisteredClasses(Result) then exit;
|
if TryRegisteredClasses(Result) then exit;
|
||||||
|
|
||||||
// finally search in used units
|
// finally search in used units
|
||||||
UsedUnitFilenames:=nil;
|
UsedUnitFilenames:=nil;
|
||||||
try
|
try
|
||||||
@ -6281,7 +6270,7 @@ var
|
|||||||
until false;
|
until false;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
UserAsked:=false;
|
UserAsked:=false;
|
||||||
Project1.LockUnitComponentDependencies;
|
Project1.LockUnitComponentDependencies;
|
||||||
@ -6291,7 +6280,7 @@ begin
|
|||||||
// It is important that first the hard, non cyclic dependencies
|
// It is important that first the hard, non cyclic dependencies
|
||||||
// are freed in the correct order.
|
// are freed in the correct order.
|
||||||
// After that the soft, cyclic dependencies can be freed in any order.
|
// After that the soft, cyclic dependencies can be freed in any order.
|
||||||
|
|
||||||
// first close all descendants recursively
|
// first close all descendants recursively
|
||||||
// This must happen in the right order (descendants before ancestor)
|
// This must happen in the right order (descendants before ancestor)
|
||||||
if not CloseNext(Result,[ucdtAncestor]) then exit;
|
if not CloseNext(Result,[ucdtAncestor]) then exit;
|
||||||
@ -6620,7 +6609,7 @@ begin
|
|||||||
if Result=mrCancel then exit;
|
if Result=mrCancel then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TitleWasDefault := Project1.TitleIsDefault(true);
|
TitleWasDefault := Project1.TitleIsDefault(true);
|
||||||
|
|
||||||
// set new project filename
|
// set new project filename
|
||||||
@ -6632,7 +6621,7 @@ begin
|
|||||||
if (Project1.MainUnitID >= 0) then
|
if (Project1.MainUnitID >= 0) then
|
||||||
begin
|
begin
|
||||||
GetMainUnit(MainUnitInfo, MainUnitSrcEdit, true);
|
GetMainUnit(MainUnitInfo, MainUnitSrcEdit, true);
|
||||||
|
|
||||||
if not Project1.Resources.RenameDirectives(MainUnitInfo.Filename,NewProgramFilename)
|
if not Project1.Resources.RenameDirectives(MainUnitInfo.Filename,NewProgramFilename)
|
||||||
then begin
|
then begin
|
||||||
DebugLn(['TMainIDE.DoShowSaveProjectAsDialog failed renaming directives Old="',MainUnitInfo.Filename,'" New="',NewProgramFilename,'"']);
|
DebugLn(['TMainIDE.DoShowSaveProjectAsDialog failed renaming directives Old="',MainUnitInfo.Filename,'" New="',NewProgramFilename,'"']);
|
||||||
@ -6642,7 +6631,7 @@ begin
|
|||||||
// Save old source code, to prevent overwriting it,
|
// Save old source code, to prevent overwriting it,
|
||||||
// if the file name didn't actually change.
|
// if the file name didn't actually change.
|
||||||
OldSource := MainUnitInfo.Source.Source;
|
OldSource := MainUnitInfo.Source.Source;
|
||||||
|
|
||||||
// switch MainUnitInfo.Source to new code
|
// switch MainUnitInfo.Source to new code
|
||||||
NewBuf := CodeToolBoss.CreateFile(NewProgramFilename);
|
NewBuf := CodeToolBoss.CreateFile(NewProgramFilename);
|
||||||
if NewBuf=nil then begin
|
if NewBuf=nil then begin
|
||||||
@ -6686,7 +6675,7 @@ begin
|
|||||||
Project1.CompilerOptions.DebugPath:=
|
Project1.CompilerOptions.DebugPath:=
|
||||||
RebaseSearchPath(Project1.CompilerOptions.DebugPath,OldProjectPath,
|
RebaseSearchPath(Project1.CompilerOptions.DebugPath,OldProjectPath,
|
||||||
Project1.ProjectDirectory,true);
|
Project1.ProjectDirectory,true);
|
||||||
|
|
||||||
// change title
|
// change title
|
||||||
if TitleWasDefault then begin
|
if TitleWasDefault then begin
|
||||||
Project1.Title:=Project1.GetDefaultTitle;
|
Project1.Title:=Project1.GetDefaultTitle;
|
||||||
@ -6804,7 +6793,7 @@ begin
|
|||||||
Project1.InsertEditorIndex(SourceNotebook.Notebook.PageIndex);
|
Project1.InsertEditorIndex(SourceNotebook.Notebook.PageIndex);
|
||||||
AnUnitInfo.EditorIndex:=SourceNotebook.FindPageWithEditor(NewSrcEdit);
|
AnUnitInfo.EditorIndex:=SourceNotebook.FindPageWithEditor(NewSrcEdit);
|
||||||
//debugln(['TMainIDE.DoOpenFileInSourceEditor ',AnUnitInfo.Filename,' ',AnUnitInfo.EditorIndex]);
|
//debugln(['TMainIDE.DoOpenFileInSourceEditor ',AnUnitInfo.Filename,' ',AnUnitInfo.EditorIndex]);
|
||||||
|
|
||||||
// restore source editor settings
|
// restore source editor settings
|
||||||
DoRestoreBookMarks(AnUnitInfo,NewSrcEdit);
|
DoRestoreBookMarks(AnUnitInfo,NewSrcEdit);
|
||||||
DebugBoss.DoRestoreDebuggerMarks(AnUnitInfo);
|
DebugBoss.DoRestoreDebuggerMarks(AnUnitInfo);
|
||||||
@ -6922,7 +6911,7 @@ begin
|
|||||||
|
|
||||||
// syntax highlighter type
|
// syntax highlighter type
|
||||||
NewUnitInfo.SyntaxHighlighter:=FilenameToLazSyntaxHighlighter(NewFilename);
|
NewUnitInfo.SyntaxHighlighter:=FilenameToLazSyntaxHighlighter(NewFilename);
|
||||||
|
|
||||||
// required packages
|
// required packages
|
||||||
if NewUnitInfo.IsPartOfProject and (NewFileDescriptor.RequiredPackages<>'')
|
if NewUnitInfo.IsPartOfProject and (NewFileDescriptor.RequiredPackages<>'')
|
||||||
then begin
|
then begin
|
||||||
@ -7050,7 +7039,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo);
|
GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo);
|
||||||
if ActiveUnitInfo=nil then exit;
|
if ActiveUnitInfo=nil then exit;
|
||||||
|
|
||||||
// check if the unit is currently reverting
|
// check if the unit is currently reverting
|
||||||
if ActiveUnitInfo.IsReverting then begin
|
if ActiveUnitInfo.IsReverting then begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
@ -7447,7 +7436,7 @@ begin
|
|||||||
Project1.Modified:=true;
|
Project1.Modified:=true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Reverting:=false;
|
Reverting:=false;
|
||||||
if ofRevert in Flags then begin
|
if ofRevert in Flags then begin
|
||||||
Reverting:=true;
|
Reverting:=true;
|
||||||
@ -8341,15 +8330,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// save main source
|
// save main source
|
||||||
if (MainUnitInfo<>nil) and (not (sfDoNotSaveVirtualFiles in flags)) then
|
if (MainUnitInfo<>nil) and (not (sfDoNotSaveVirtualFiles in flags)) then
|
||||||
begin
|
begin
|
||||||
if not (sfSaveToTestDir in Flags) then
|
if not (sfSaveToTestDir in Flags) then
|
||||||
DestFilename := MainUnitInfo.Filename
|
DestFilename := MainUnitInfo.Filename
|
||||||
else
|
else
|
||||||
DestFilename := MainBuildBoss.GetTestUnitFilename(MainUnitInfo);
|
DestFilename := MainBuildBoss.GetTestUnitFilename(MainUnitInfo);
|
||||||
|
|
||||||
// if we are saving a project to a temporary folder then we also need to save resources
|
// if we are saving a project to a temporary folder then we also need to save resources
|
||||||
// or compilation will be broken
|
// or compilation will be broken
|
||||||
if sfSaveToTestDir in Flags then
|
if sfSaveToTestDir in Flags then
|
||||||
if not Project1.Resources.Regenerate(DestFileName, False, True) then
|
if not Project1.Resources.Regenerate(DestFileName, False, True) then
|
||||||
DebugLn('TMainIDE.DoSaveProject Project1.Resources.Regenerate failed');
|
DebugLn('TMainIDE.DoSaveProject Project1.Resources.Regenerate failed');
|
||||||
@ -8360,20 +8349,20 @@ begin
|
|||||||
Result:=DoSaveEditorFile(MainUnitInfo.EditorIndex,
|
Result:=DoSaveEditorFile(MainUnitInfo.EditorIndex,
|
||||||
[sfProjectSaving]+[sfSaveToTestDir,sfCheckAmbiguousFiles]*Flags);
|
[sfProjectSaving]+[sfSaveToTestDir,sfCheckAmbiguousFiles]*Flags);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
// not loaded in source editor (hidden)
|
// not loaded in source editor (hidden)
|
||||||
if not (sfSaveToTestDir in Flags) and not MainUnitInfo.NeedsSaveToDisk then
|
if not (sfSaveToTestDir in Flags) and not MainUnitInfo.NeedsSaveToDisk then
|
||||||
SkipSavingMainSource := true;
|
SkipSavingMainSource := true;
|
||||||
if (not SkipSavingMainSource) and (MainUnitInfo.Source<>nil) then
|
if (not SkipSavingMainSource) and (MainUnitInfo.Source<>nil) then
|
||||||
begin
|
begin
|
||||||
Result:=SaveCodeBufferToFile(MainUnitInfo.Source, DestFilename);
|
Result:=SaveCodeBufferToFile(MainUnitInfo.Source, DestFilename);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// clear modified flags
|
// clear modified flags
|
||||||
if not (sfSaveToTestDir in Flags) then
|
if not (sfSaveToTestDir in Flags) then
|
||||||
begin
|
begin
|
||||||
if (Result=mrOk) then begin
|
if (Result=mrOk) then begin
|
||||||
if MainUnitInfo<>nil then MainUnitInfo.ClearModifieds;
|
if MainUnitInfo<>nil then MainUnitInfo.ClearModifieds;
|
||||||
@ -8411,7 +8400,7 @@ begin
|
|||||||
|
|
||||||
// update all lrs files
|
// update all lrs files
|
||||||
MainBuildBoss.UpdateProjectAutomaticFiles;
|
MainBuildBoss.UpdateProjectAutomaticFiles;
|
||||||
|
|
||||||
// everything went well => clear all modified flags
|
// everything went well => clear all modified flags
|
||||||
Project1.ClearModifieds(true);
|
Project1.ClearModifieds(true);
|
||||||
|
|
||||||
@ -8506,7 +8495,7 @@ begin
|
|||||||
Result:=MessageDlg(ACaption, AText, mtError, [mbAbort], 0);
|
Result:=MessageDlg(ACaption, AText, mtError, [mbAbort], 0);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check symbolic link
|
// check symbolic link
|
||||||
Result:=ChooseSymlink(AFilename);
|
Result:=ChooseSymlink(AFilename);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
@ -8781,7 +8770,7 @@ begin
|
|||||||
|
|
||||||
// add and load default required packages
|
// add and load default required packages
|
||||||
PkgBoss.AddDefaultDependencies(Project1);
|
PkgBoss.AddDefaultDependencies(Project1);
|
||||||
|
|
||||||
Result:=DoCompleteLoadingProjectInfo;
|
Result:=DoCompleteLoadingProjectInfo;
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
finally
|
finally
|
||||||
@ -9461,7 +9450,7 @@ begin
|
|||||||
|
|
||||||
// Setup debugger
|
// Setup debugger
|
||||||
if not DebugBoss.InitDebugger then Exit;
|
if not DebugBoss.InitDebugger then Exit;
|
||||||
|
|
||||||
Result := mrOK;
|
Result := mrOK;
|
||||||
ToolStatus := itDebugger;
|
ToolStatus := itDebugger;
|
||||||
end;
|
end;
|
||||||
@ -9545,11 +9534,11 @@ procedure TMainIDE.DoRestart;
|
|||||||
GetCommandLineParameters(Params, False);
|
GetCommandLineParameters(Params, False);
|
||||||
|
|
||||||
DebugLn('CommandLine 1 : %s', [CmdLine]);
|
DebugLn('CommandLine 1 : %s', [CmdLine]);
|
||||||
|
|
||||||
if (pos(PrimaryConfPathOptLong, CmdLine) = 0) and
|
if (pos(PrimaryConfPathOptLong, CmdLine) = 0) and
|
||||||
(pos(PrimaryConfPathOptShort, CmdLine) = 0) then
|
(pos(PrimaryConfPathOptShort, CmdLine) = 0) then
|
||||||
CmdLine := CmdLine + ' "' + PrimaryConfPathOptLong + GetPrimaryConfigPath+'"';
|
CmdLine := CmdLine + ' "' + PrimaryConfPathOptLong + GetPrimaryConfigPath+'"';
|
||||||
|
|
||||||
DebugLn('CommandLine 2 : %s', [CmdLine]);
|
DebugLn('CommandLine 2 : %s', [CmdLine]);
|
||||||
StartLazProcess.CommandLine := CmdLine;
|
StartLazProcess.CommandLine := CmdLine;
|
||||||
StartLazProcess.Execute;
|
StartLazProcess.Execute;
|
||||||
@ -9587,7 +9576,7 @@ procedure TMainIDE.DoExecuteRemoteControl;
|
|||||||
if (Files=nil) or (Files.Count=0) then exit;
|
if (Files=nil) or (Files.Count=0) then exit;
|
||||||
ProjectLoaded:=Project1<>nil;
|
ProjectLoaded:=Project1<>nil;
|
||||||
DebugLn(['TMainIDE.DoExecuteRemoteControl.OpenFiles ProjectLoaded=',ProjectLoaded]);
|
DebugLn(['TMainIDE.DoExecuteRemoteControl.OpenFiles ProjectLoaded=',ProjectLoaded]);
|
||||||
|
|
||||||
// open project
|
// open project
|
||||||
if (Files<>nil) and (Files.Count>0) then begin
|
if (Files<>nil) and (Files.Count>0) then begin
|
||||||
AProjectFilename:=Files[0];
|
AProjectFilename:=Files[0];
|
||||||
@ -9731,7 +9720,7 @@ begin
|
|||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=DoSaveAll([sfDoNotSaveVirtualFiles]);
|
Result:=DoSaveAll([sfDoNotSaveVirtualFiles]);
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
DebugLn('TMainIDE.DoBuildLazarus: failed because saving failed');
|
DebugLn('TMainIDE.DoBuildLazarus: failed because saving failed');
|
||||||
@ -10045,7 +10034,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//DebugLn(['TMainIDE.DoConfigBuildFile ',ActiveUnitInfo.Filename,' ',DirectiveList.DelimitedText]);
|
//DebugLn(['TMainIDE.DoConfigBuildFile ',ActiveUnitInfo.Filename,' ',DirectiveList.DelimitedText]);
|
||||||
|
|
||||||
// save IDE directives
|
// save IDE directives
|
||||||
if FilenameIsPascalSource(ActiveUnitInfo.Filename) then begin
|
if FilenameIsPascalSource(ActiveUnitInfo.Filename) then begin
|
||||||
// parse source for IDE directives (i.e. % comments)
|
// parse source for IDE directives (i.e. % comments)
|
||||||
@ -10524,7 +10513,7 @@ begin
|
|||||||
Result:=ShowDiskDiffsDialog(AnUnitList,APackageList);
|
Result:=ShowDiskDiffsDialog(AnUnitList,APackageList);
|
||||||
if Result in [mrYesToAll] then
|
if Result in [mrYesToAll] then
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
|
|
||||||
// reload units
|
// reload units
|
||||||
if AnUnitList<>nil then begin
|
if AnUnitList<>nil then begin
|
||||||
for i:=0 to AnUnitList.Count-1 do begin
|
for i:=0 to AnUnitList.Count-1 do begin
|
||||||
@ -10546,11 +10535,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// reload packages
|
// reload packages
|
||||||
Result:=PkgBoss.RevertPackages(APackageList);
|
Result:=PkgBoss.RevertPackages(APackageList);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
|
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
finally
|
finally
|
||||||
FCheckingFilesOnDisk:=false;
|
FCheckingFilesOnDisk:=false;
|
||||||
@ -10926,7 +10915,7 @@ var MaxMessages: integer;
|
|||||||
NewFilename: String;
|
NewFilename: String;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
|
||||||
MaxMessages:=MessagesView.VisibleItemCount;
|
MaxMessages:=MessagesView.VisibleItemCount;
|
||||||
if Index>=MaxMessages then exit;
|
if Index>=MaxMessages then exit;
|
||||||
if (Index<0) then begin
|
if (Index<0) then begin
|
||||||
@ -11172,7 +11161,7 @@ begin
|
|||||||
and (MessagesView.Parent = nil) then
|
and (MessagesView.Parent = nil) then
|
||||||
SourceNotebook.Height := Max(50,Min(SourceNotebook.Height,
|
SourceNotebook.Height := Max(50,Min(SourceNotebook.Height,
|
||||||
MessagesView.Top-SourceNotebook.Top));
|
MessagesView.Top-SourceNotebook.Top));
|
||||||
if PutOnTop then
|
if PutOnTop then
|
||||||
begin
|
begin
|
||||||
if MessagesView.Parent = nil then
|
if MessagesView.Parent = nil then
|
||||||
MessagesView.ShowOnTop;
|
MessagesView.ShowOnTop;
|
||||||
@ -11551,7 +11540,7 @@ begin
|
|||||||
// mark references modified
|
// mark references modified
|
||||||
if APersistent is TComponent then
|
if APersistent is TComponent then
|
||||||
MarkUnitsModifiedUsingSubComponent(TComponent(APersistent));
|
MarkUnitsModifiedUsingSubComponent(TComponent(APersistent));
|
||||||
|
|
||||||
// remember cursor position
|
// remember cursor position
|
||||||
SourceNotebook.AddJumpPointClicked(Self);
|
SourceNotebook.AddJumpPointClicked(Self);
|
||||||
|
|
||||||
@ -12131,10 +12120,10 @@ begin
|
|||||||
DumpStack;
|
DumpStack;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then
|
if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then
|
||||||
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
|
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
|
||||||
|
|
||||||
if AddJumpPoint and (ActiveUnitInfo <> nil) and (ActiveSrcEdit <> nil)
|
if AddJumpPoint and (ActiveUnitInfo <> nil) and (ActiveSrcEdit <> nil)
|
||||||
then begin
|
then begin
|
||||||
if (NewSource<>ActiveUnitInfo.Source)
|
if (NewSource<>ActiveUnitInfo.Source)
|
||||||
@ -12142,7 +12131,7 @@ begin
|
|||||||
or (ActiveSrcEdit.EditorComponent.CaretY<>NewY) then
|
or (ActiveSrcEdit.EditorComponent.CaretY<>NewY) then
|
||||||
SourceNotebook.AddJumpPointClicked(Self);
|
SourceNotebook.AddJumpPointClicked(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (ActiveUnitInfo = nil) or (NewSource<>ActiveUnitInfo.Source)
|
if (ActiveUnitInfo = nil) or (NewSource<>ActiveUnitInfo.Source)
|
||||||
then begin
|
then begin
|
||||||
// jump to other file -> open it
|
// jump to other file -> open it
|
||||||
@ -13170,7 +13159,7 @@ var
|
|||||||
raise EComponentError.Create(s);
|
raise EComponentError.Create(s);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure RenameInheritedComponents(RenamedUnit: TUnitInfo;
|
procedure RenameInheritedComponents(RenamedUnit: TUnitInfo;
|
||||||
Simulate: boolean);
|
Simulate: boolean);
|
||||||
var
|
var
|
||||||
@ -13193,7 +13182,7 @@ var
|
|||||||
OldClassName,AComponent.ClassName,false);
|
OldClassName,AComponent.ClassName,false);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// rename inherited component
|
// rename inherited component
|
||||||
InheritedComponent:=
|
InheritedComponent:=
|
||||||
DependingUnit.Component.FindComponent(AComponent.Name);
|
DependingUnit.Component.FindComponent(AComponent.Name);
|
||||||
@ -13237,7 +13226,7 @@ var
|
|||||||
UsedByDependency:=UsedByDependency.NextUsedByDependency;
|
UsedByDependency:=UsedByDependency.NextUsedByDependency;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure RenameMethods;
|
procedure RenameMethods;
|
||||||
var
|
var
|
||||||
PropList: PPropList;
|
PropList: PPropList;
|
||||||
@ -13683,14 +13672,14 @@ begin
|
|||||||
FormEditor1.PaintAllDesignerItems;
|
FormEditor1.PaintAllDesignerItems;
|
||||||
GetCurrentUnit(SrcEdit,AnUnitInfo);
|
GetCurrentUnit(SrcEdit,AnUnitInfo);
|
||||||
UpdateSaveMenuItemsAndButtons(true);
|
UpdateSaveMenuItemsAndButtons(true);
|
||||||
if Screen.ActiveForm<>nil then
|
if Screen.ActiveForm<>nil then
|
||||||
begin
|
begin
|
||||||
AnIDesigner:=Screen.ActiveForm.Designer;
|
AnIDesigner:=Screen.ActiveForm.Designer;
|
||||||
if AnIDesigner is TDesigner then
|
if AnIDesigner is TDesigner then
|
||||||
begin
|
begin
|
||||||
MainIDEBar.itmViewToggleFormUnit.Enabled := true;
|
MainIDEBar.itmViewToggleFormUnit.Enabled := true;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
MainIDEBar.itmViewToggleFormUnit.Enabled := (AnUnitInfo<>nil)
|
MainIDEBar.itmViewToggleFormUnit.Enabled := (AnUnitInfo<>nil)
|
||||||
and AnUnitInfo.HasResources;
|
and AnUnitInfo.HasResources;
|
||||||
@ -13700,7 +13689,7 @@ begin
|
|||||||
|
|
||||||
if FCheckFilesOnDiskNeeded then
|
if FCheckFilesOnDiskNeeded then
|
||||||
DoCheckFilesOnDisk(true);
|
DoCheckFilesOnDisk(true);
|
||||||
|
|
||||||
if (FRemoteControlTimer=nil) and EnableRemoteControl then
|
if (FRemoteControlTimer=nil) and EnableRemoteControl then
|
||||||
SetupRemoteControl;
|
SetupRemoteControl;
|
||||||
end;
|
end;
|
||||||
@ -13750,7 +13739,7 @@ begin
|
|||||||
|
|
||||||
if DoOpenEditorFile(AFilename, -1, OpenFlags) = mrAbort then Break;
|
if DoOpenEditorFile(AFilename, -1, OpenFlags) = mrAbort then Break;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SetRecentFilesMenu;
|
SetRecentFilesMenu;
|
||||||
SaveEnvironment;
|
SaveEnvironment;
|
||||||
end;
|
end;
|
||||||
@ -14073,7 +14062,7 @@ begin
|
|||||||
debugln('[TMainIDE.OnPropHookCreateMethod] ************ ',AMethodName);
|
debugln('[TMainIDE.OnPropHookCreateMethod] ************ ',AMethodName);
|
||||||
DebugLn(['[TMainIDE.OnPropHookCreateMethod] Persistent=',dbgsName(APersistent),' Unit=',GetClassUnitName(APersistent.ClassType),' Path=',APropertyPath]);
|
DebugLn(['[TMainIDE.OnPropHookCreateMethod] Persistent=',dbgsName(APersistent),' Unit=',GetClassUnitName(APersistent.ClassType),' Path=',APropertyPath]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
OverrideMethodName:='';
|
OverrideMethodName:='';
|
||||||
if APersistent is TComponent then begin
|
if APersistent is TComponent then begin
|
||||||
AComponent:=TComponent(APersistent);
|
AComponent:=TComponent(APersistent);
|
||||||
@ -14155,7 +14144,7 @@ begin
|
|||||||
debugln('');
|
debugln('');
|
||||||
debugln('[TMainIDE.OnPropHookShowMethod] ************ "',AMethodName,'" ',ActiveUnitInfo.Filename);
|
debugln('[TMainIDE.OnPropHookShowMethod] ************ "',AMethodName,'" ',ActiveUnitInfo.Filename);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
AClassName:=ActiveUnitInfo.Component.ClassName;
|
AClassName:=ActiveUnitInfo.Component.ClassName;
|
||||||
CurMethodName:=AMethodName;
|
CurMethodName:=AMethodName;
|
||||||
|
|
||||||
|
@ -5089,51 +5089,16 @@ procedure TSourceNotebook.ActivateHint(const ScreenPos: TPoint;
|
|||||||
const BaseURL, TheHint: string);
|
const BaseURL, TheHint: string);
|
||||||
var
|
var
|
||||||
HintWinRect: TRect;
|
HintWinRect: TRect;
|
||||||
IsHTML: Boolean;
|
AHint: String;
|
||||||
Provider: TAbstractIDEHTMLProvider;
|
|
||||||
HTMLControl: TControl;
|
|
||||||
ms: TMemoryStream;
|
|
||||||
NewWidth, NewHeight: integer;
|
|
||||||
begin
|
begin
|
||||||
if csDestroying in ComponentState then exit;
|
if csDestroying in ComponentState then exit;
|
||||||
if FHintWindow<>nil then
|
if FHintWindow<>nil then
|
||||||
FHintWindow.Visible:=false;
|
FHintWindow.Visible:=false;
|
||||||
if FHintWindow=nil then
|
if FHintWindow=nil then
|
||||||
FHintWindow:=THintWindow.Create(Self);
|
FHintWindow:=THintWindow.Create(Self);
|
||||||
IsHTML:=SysUtils.CompareText(copy(TheHint,1,6),'<HTML>')=0;
|
AHint:=TheHint;
|
||||||
//DebugLn(['TSourceNotebook.ActivateHint IsHTML=',IsHTML,' TheHint=',TheHint]);
|
if LazarusHelp.CreateHint(FHintWindow,ScreenPos,BaseURL,AHint,HintWinRect) then
|
||||||
if FHintWindow.ControlCount>0 then begin
|
FHintWindow.ActivateHint(HintWinRect,aHint);
|
||||||
//DebugLn(['TSourceNotebook.ActivateHint ',dbgsName(FHintWindow.Controls[0])]);
|
|
||||||
FHintWindow.Controls[0].Free;
|
|
||||||
end;
|
|
||||||
if IsHTML then begin
|
|
||||||
Provider:=nil;
|
|
||||||
HTMLControl:=CreateIDEHTMLControl(FHintWindow,Provider);
|
|
||||||
Provider.BaseURL:=BaseURL;
|
|
||||||
HTMLControl.Parent:=FHintWindow;
|
|
||||||
HTMLControl.Align:=alClient;
|
|
||||||
ms:=TMemoryStream.Create;
|
|
||||||
try
|
|
||||||
if TheHint<>'' then
|
|
||||||
ms.Write(TheHint[1],length(TheHint));
|
|
||||||
ms.Position:=0;
|
|
||||||
Provider.ControlIntf.SetHTMLContent(ms);
|
|
||||||
finally
|
|
||||||
ms.Free;
|
|
||||||
end;
|
|
||||||
Provider.ControlIntf.GetPreferredControlSize(NewWidth,NewHeight);
|
|
||||||
if NewWidth<=0 then
|
|
||||||
NewWidth:=500;
|
|
||||||
if NewHeight<=0 then
|
|
||||||
NewHeight:=200;
|
|
||||||
HintWinRect := Rect(0,0,NewWidth,NewHeight);
|
|
||||||
OffsetRect(HintWinRect, ScreenPos.X, ScreenPos.Y+30);
|
|
||||||
FHintWindow.ActivateHint(HintWinRect,'');
|
|
||||||
end else begin
|
|
||||||
HintWinRect := FHintWindow.CalcHintRect(Screen.Width, TheHint, nil);
|
|
||||||
OffsetRect(HintWinRect, ScreenPos.X, ScreenPos.Y+30);
|
|
||||||
FHintWindow.ActivateHint(HintWinRect,TheHint);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceNotebook.HideHint;
|
procedure TSourceNotebook.HideHint;
|
||||||
|
@ -23,7 +23,8 @@ unit IDEHelpIntf;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, Controls, HelpIntfs, LazHelpIntf, TextTools;
|
Classes, SysUtils, LCLProc, Forms, Controls, HelpIntfs, LazHelpIntf,
|
||||||
|
TextTools;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ THelpDBIRegExprMessage
|
{ THelpDBIRegExprMessage
|
||||||
@ -61,6 +62,9 @@ type
|
|||||||
var ErrMsg: string): TShowHelpResult; virtual; abstract;
|
var ErrMsg: string): TShowHelpResult; virtual; abstract;
|
||||||
procedure ShowHelpForMessage(Line: integer); virtual; abstract;
|
procedure ShowHelpForMessage(Line: integer); virtual; abstract;
|
||||||
procedure ShowHelpForObjectInspector(Sender: TObject); virtual; abstract;
|
procedure ShowHelpForObjectInspector(Sender: TObject); virtual; abstract;
|
||||||
|
function CreateHint(aHintWindow: THintWindow; ScreenPos: TPoint;
|
||||||
|
const BaseURL: string; var TheHint: string;
|
||||||
|
out HintWinRect: TRect): boolean; virtual; abstract;
|
||||||
|
|
||||||
function ConvertSourcePosToPascalHelpContext(const CaretPos: TPoint;
|
function ConvertSourcePosToPascalHelpContext(const CaretPos: TPoint;
|
||||||
const Filename: string): TPascalHelpContextList; virtual; abstract;
|
const Filename: string): TPascalHelpContextList; virtual; abstract;
|
||||||
|
@ -35,8 +35,13 @@ unit ObjectInspector;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
InterfaceBase, Forms, SysUtils, Buttons, Types, Classes, Graphics, GraphType,
|
// IMPORTANT: the object inspector is a tool and can be used in other programs
|
||||||
StdCtrls, LCLType, LCLIntf, LCLProc, Controls, ComCtrls, ExtCtrls, TypInfo,
|
// too. Don't put Lazarus IDE specific things here.
|
||||||
|
// FCL
|
||||||
|
SysUtils, Types, Classes, TypInfo,
|
||||||
|
// LCL
|
||||||
|
InterfaceBase, Forms, Buttons, Graphics, GraphType,
|
||||||
|
StdCtrls, LCLType, LCLIntf, LCLProc, Controls, ComCtrls, ExtCtrls,
|
||||||
LMessages, LResources, LazConfigStorage, Menus, Dialogs, Themes,
|
LMessages, LResources, LazConfigStorage, Menus, Dialogs, Themes,
|
||||||
ObjInspStrConsts,
|
ObjInspStrConsts,
|
||||||
PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor,
|
PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor,
|
||||||
@ -323,6 +328,11 @@ type
|
|||||||
oiqeShowValue
|
oiqeShowValue
|
||||||
);
|
);
|
||||||
|
|
||||||
|
TOIPropertyHint = function(Sender: TObject; PointedRow: TOIPropertyGridRow;
|
||||||
|
ScreenPos: TPoint; aHintWindow: THintWindow;
|
||||||
|
out HintWinRect: TRect; out AHint: string
|
||||||
|
): boolean of object;
|
||||||
|
|
||||||
TOICustomPropertyGrid = class(TCustomControl)
|
TOICustomPropertyGrid = class(TCustomControl)
|
||||||
private
|
private
|
||||||
FBackgroundColor: TColor;
|
FBackgroundColor: TColor;
|
||||||
@ -332,6 +342,7 @@ type
|
|||||||
FHighlightColor: TColor;
|
FHighlightColor: TColor;
|
||||||
FLayout: TOILayout;
|
FLayout: TOILayout;
|
||||||
FOnOIKeyDown: TKeyEvent;
|
FOnOIKeyDown: TKeyEvent;
|
||||||
|
FOnPropertyHint: TOIPropertyHint;
|
||||||
FOnSelectionChange: TNotifyEvent;
|
FOnSelectionChange: TNotifyEvent;
|
||||||
FReferencesColor: TColor;
|
FReferencesColor: TColor;
|
||||||
FRowSpacing: integer;
|
FRowSpacing: integer;
|
||||||
@ -537,6 +548,7 @@ type
|
|||||||
property OnModified: TNotifyEvent read FOnModified write FOnModified;
|
property OnModified: TNotifyEvent read FOnModified write FOnModified;
|
||||||
property OnOIKeyDown: TKeyEvent read FOnOIKeyDown write FOnOIKeyDown;
|
property OnOIKeyDown: TKeyEvent read FOnOIKeyDown write FOnOIKeyDown;
|
||||||
property OnSelectionChange: TNotifyEvent read FOnSelectionChange write FOnSelectionChange;
|
property OnSelectionChange: TNotifyEvent read FOnSelectionChange write FOnSelectionChange;
|
||||||
|
property OnPropertyHint: TOIPropertyHint read FOnPropertyHint write FOnPropertyHint;
|
||||||
property PrefferedSplitterX: integer read FPreferredSplitterX
|
property PrefferedSplitterX: integer read FPreferredSplitterX
|
||||||
write FPreferredSplitterX default 100;
|
write FPreferredSplitterX default 100;
|
||||||
property PropertyEditorHook: TPropertyEditorHook read FPropertyEditorHook
|
property PropertyEditorHook: TPropertyEditorHook read FPropertyEditorHook
|
||||||
@ -690,6 +702,7 @@ type
|
|||||||
FAutoShow: Boolean;
|
FAutoShow: Boolean;
|
||||||
FFavourites: TOIFavouriteProperties;
|
FFavourites: TOIFavouriteProperties;
|
||||||
FInfoBoxHeight: integer;
|
FInfoBoxHeight: integer;
|
||||||
|
FOnPropertyHint: TOIPropertyHint;
|
||||||
FOnSelectionChange: TNotifyEvent;
|
FOnSelectionChange: TNotifyEvent;
|
||||||
FRestricted: TOIRestrictedProperties;
|
FRestricted: TOIRestrictedProperties;
|
||||||
FOnAddToFavourites: TNotifyEvent;
|
FOnAddToFavourites: TNotifyEvent;
|
||||||
@ -737,6 +750,9 @@ type
|
|||||||
procedure HookLookupRootChange;
|
procedure HookLookupRootChange;
|
||||||
procedure OnGridModified(Sender: TObject);
|
procedure OnGridModified(Sender: TObject);
|
||||||
procedure OnGridSelectionChange(Sender: TObject);
|
procedure OnGridSelectionChange(Sender: TObject);
|
||||||
|
function OnGridPropertyHint(Sender: TObject; PointedRow: TOIPropertyGridRow;
|
||||||
|
ScreenPos: TPoint; aHintWindow: THintWindow;
|
||||||
|
out HintWinRect: TRect; out AHint: string): boolean;
|
||||||
procedure SetAvailComboBoxText;
|
procedure SetAvailComboBoxText;
|
||||||
procedure HookGetSelection(const ASelection: TPersistentSelectionList);
|
procedure HookGetSelection(const ASelection: TPersistentSelectionList);
|
||||||
procedure HookSetSelection(const ASelection: TPersistentSelectionList);
|
procedure HookSetSelection(const ASelection: TPersistentSelectionList);
|
||||||
@ -772,6 +788,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 OnSelectionChange: TNotifyEvent read FOnSelectionChange write FOnSelectionChange;
|
property OnSelectionChange: TNotifyEvent read FOnSelectionChange write FOnSelectionChange;
|
||||||
|
property OnPropertyHint: TOIPropertyHint read FOnPropertyHint write FOnPropertyHint;
|
||||||
property OnShowOptions: TNotifyEvent read FOnShowOptions
|
property OnShowOptions: TNotifyEvent read FOnShowOptions
|
||||||
write SetOnShowOptions;
|
write SetOnShowOptions;
|
||||||
property OnRemainingKeyUp: TKeyEvent read FOnRemainingKeyUp
|
property OnRemainingKeyUp: TKeyEvent read FOnRemainingKeyUp
|
||||||
@ -1950,7 +1967,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=pehNone;
|
Result:=pehNone;
|
||||||
if (RowIndex<0) or (RowIndex>=RowCount) then exit;
|
if (RowIndex<0) or (RowIndex>=RowCount) then exit;
|
||||||
if SplitterX>=X then begin
|
if SplitterX<=X then begin
|
||||||
if (FCurrentButton<>nil)
|
if (FCurrentButton<>nil)
|
||||||
and (FCurrentButton.Left<=X) then
|
and (FCurrentButton.Left<=X) then
|
||||||
Result:=pehEditButton
|
Result:=pehEditButton
|
||||||
@ -2981,10 +2998,18 @@ begin
|
|||||||
Begin
|
Begin
|
||||||
if Assigned(PointedRow.Editor) then begin
|
if Assigned(PointedRow.Editor) then begin
|
||||||
HintType := GetHintTypeAt(Index,Position.X);
|
HintType := GetHintTypeAt(Index,Position.X);
|
||||||
|
if (HintType = pehName) and Assigned(OnPropertyHint) then begin
|
||||||
|
if OnPropertyHint(Self,PointedRow,Position,FHintWindow,Rect,AHint) then
|
||||||
|
begin
|
||||||
|
FHintWindow.ActivateHint(Rect,AHint);
|
||||||
|
end;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
AHint := PointedRow.Editor.GetHint(HintType,Position.X,Position.Y);
|
AHint := PointedRow.Editor.GetHint(HintType,Position.X,Position.Y);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if AHint = '' then Exit;
|
if AHint = '' then Exit;
|
||||||
Rect := FHintWindow.CalcHintRect(0,AHint,nil); //no maxwidth
|
Rect := FHintWindow.CalcHintRect(0,AHint,nil); //no maxwidth
|
||||||
Position := Mouse.CursorPos;
|
Position := Mouse.CursorPos;
|
||||||
@ -4321,6 +4346,15 @@ begin
|
|||||||
if Assigned(FOnSelectionChange) then OnSelectionChange(Self);
|
if Assigned(FOnSelectionChange) then OnSelectionChange(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TObjectInspectorDlg.OnGridPropertyHint(Sender: TObject;
|
||||||
|
PointedRow: TOIPropertyGridRow; ScreenPos: TPoint; aHintWindow: THintWindow;
|
||||||
|
out HintWinRect: TRect; out AHint: string): boolean;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if Assigned(FOnPropertyHint) then
|
||||||
|
Result:=FOnPropertyHint(Sender,PointedRow,ScreenPos,aHintWindow,HintWinRect,AHint);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TObjectInspectorDlg.SetAvailComboBoxText;
|
procedure TObjectInspectorDlg.SetAvailComboBoxText;
|
||||||
begin
|
begin
|
||||||
case FSelection.Count of
|
case FSelection.Count of
|
||||||
@ -4623,6 +4657,7 @@ begin
|
|||||||
PopupMenu:=MainPopupMenu;
|
PopupMenu:=MainPopupMenu;
|
||||||
OnModified:=@OnGridModified;
|
OnModified:=@OnGridModified;
|
||||||
OnSelectionChange:=@OnGridSelectionChange;
|
OnSelectionChange:=@OnGridSelectionChange;
|
||||||
|
OnPropertyHint:=@OnGridPropertyHint;
|
||||||
OnOIKeyDown:=@OnGridKeyDown;
|
OnOIKeyDown:=@OnGridKeyDown;
|
||||||
OnKeyUp:=@OnGridKeyUp;
|
OnKeyUp:=@OnGridKeyUp;
|
||||||
OnDblClick:=@OnGridDblClick;
|
OnDblClick:=@OnGridDblClick;
|
||||||
@ -4640,6 +4675,7 @@ begin
|
|||||||
PopupMenu:=MainPopupMenu;
|
PopupMenu:=MainPopupMenu;
|
||||||
OnModified:=@OnGridModified;
|
OnModified:=@OnGridModified;
|
||||||
OnSelectionChange:=@OnGridSelectionChange;
|
OnSelectionChange:=@OnGridSelectionChange;
|
||||||
|
OnPropertyHint:=@OnGridPropertyHint;
|
||||||
OnOIKeyDown:=@OnGridKeyDown;
|
OnOIKeyDown:=@OnGridKeyDown;
|
||||||
OnKeyUp:=@OnGridKeyUp;
|
OnKeyUp:=@OnGridKeyUp;
|
||||||
OnDblClick:=@OnGridDblClick;
|
OnDblClick:=@OnGridDblClick;
|
||||||
@ -4661,6 +4697,7 @@ begin
|
|||||||
PopupMenu:=MainPopupMenu;
|
PopupMenu:=MainPopupMenu;
|
||||||
OnModified:=@OnGridModified;
|
OnModified:=@OnGridModified;
|
||||||
OnSelectionChange:=@OnGridSelectionChange;
|
OnSelectionChange:=@OnGridSelectionChange;
|
||||||
|
OnPropertyHint:=@OnGridPropertyHint;
|
||||||
OnOIKeyDown:=@OnGridKeyDown;
|
OnOIKeyDown:=@OnGridKeyDown;
|
||||||
OnKeyUp:=@OnGridKeyUp;
|
OnKeyUp:=@OnGridKeyUp;
|
||||||
OnDblClick:=@OnGridDblClick;
|
OnDblClick:=@OnGridDblClick;
|
||||||
@ -4682,6 +4719,7 @@ begin
|
|||||||
PopupMenu:=MainPopupMenu;
|
PopupMenu:=MainPopupMenu;
|
||||||
OnModified:=@OnGridModified;
|
OnModified:=@OnGridModified;
|
||||||
OnSelectionChange:=@OnGridSelectionChange;
|
OnSelectionChange:=@OnGridSelectionChange;
|
||||||
|
OnPropertyHint:=@OnGridPropertyHint;
|
||||||
OnOIKeyDown:=@OnGridKeyDown;
|
OnOIKeyDown:=@OnGridKeyDown;
|
||||||
OnKeyUp:=@OnGridKeyUp;
|
OnKeyUp:=@OnGridKeyUp;
|
||||||
OnDblClick:=@OnGridDblClick;
|
OnDblClick:=@OnGridDblClick;
|
||||||
|
Loading…
Reference in New Issue
Block a user