diff --git a/docs/lazdoc.css b/docs/lazdoc.css index 70e8ec76cd..180ce908ec 100644 --- a/docs/lazdoc.css +++ b/docs/lazdoc.css @@ -22,6 +22,12 @@ div.title { color: #005A9C; } +div.focushint { + text-align: right; + font-size: 10px; + color: #005A9C; +} + tt, span.keyword, pre { font-family: Courier, monospace } diff --git a/ide/codehelp.pas b/ide/codehelp.pas index 879f1765cc..93eb3edc77 100644 --- a/ide/codehelp.pas +++ b/ide/codehelp.pas @@ -40,6 +40,7 @@ interface uses Classes, SysUtils, LCLProc, Forms, Controls, FileUtil, Dialogs, AvgLvlTree, + LCLType, // codetools CodeAtom, CodeTree, CodeToolManager, FindDeclarationTool, BasicCodeTools, KeywordFuncLists, PascalParserTool, CodeCache, CacheCodeTools, FileProcs, @@ -51,11 +52,11 @@ uses // synedit SynHighlighterPas, // IDEIntf - IDEMsgIntf, MacroIntf, PackageIntf, LazHelpIntf, ProjectIntf, IDEDialogs, - IDEHelpIntf, LazIDEIntf, + IDECommands, IDEMsgIntf, MacroIntf, PackageIntf, LazHelpIntf, ProjectIntf, + IDEDialogs, IDEHelpIntf, LazIDEIntf, // IDE - LazarusIDEStrConsts, CompilerOptions, IDEProcs, PackageDefs, EnvironmentOpts, - TransferMacros, PackageSystem, DialogProcs; + EditorOptions, LazarusIDEStrConsts, CompilerOptions, IDEProcs, PackageDefs, + EnvironmentOpts, TransferMacros, PackageSystem, DialogProcs, KeyMapping; const IDEProjectName = 'Lazarus'; @@ -215,7 +216,8 @@ type TCodeHelpHintOption = ( chhoSmallStep, // do the next step. Use this to run on idle. chhoDeclarationHeader, // add a header with source position and type of identifier - chhoNoComments // do not add the pasdoc comments + chhoNoComments, // do not add the pasdoc comments + chhoShowFocusHint // show the shortcut ecFocusHint ); TCodeHelpHintOptions = set of TCodeHelpHintOption; @@ -2240,6 +2242,7 @@ var n: Integer; LastOwner: TObject; s: String; + Cmd: TKeyCommandRelation; procedure AddLinkToOwner(CurOwner: TObject); var @@ -2302,7 +2305,7 @@ begin // add fpdoc entry FPDocFilename:=GetFPDocFilenameForSource(CTTool.MainFilename, false,CacheWasUsed,AnOwner); - //DebugLn(['TCodeHelpManager.GetHTMLHint2 FPDocFilename=',FPDocFilename,' ElementName="',ElementName,'"']); + //DebugLn(['TCodeHelpManager.GetHTMLHint FPDocFilename=',FPDocFilename,' ElementName="',ElementName,'"']); if (not CacheWasUsed) and (not Complete) then exit(chprParsing); if n=1 then @@ -2315,7 +2318,7 @@ begin ElementNode:=FPDocFile.GetElementWithName(ElementName); if ElementNode<>nil then begin - //debugln(['TCodeHelpManager.GetHTMLHint2 fpdoc element found "',ElementName,'"']); + //debugln(['TCodeHelpManager.GetHTMLHint fpdoc element found "',ElementName,'"']); AddLinkToOwner(AnOwner); s:=AppendLineEnding(GetFPDocNodeAsHTML(FPDocFile,ElementNode.FindNode(FPDocItemNames[fpdiShort]))); @@ -2343,7 +2346,7 @@ begin or ((CTNode.Desc in [ctnProcedure,ctnProcedureHead]) and (CTTool.ProcNodeHasSpecifier(CTNode,psOVERRIDE))) then begin - debugln(['TCodeHelpManager.GetHTMLHint2 searching for inherited of ',CTNode.DescAsString,' ',dbgs(XYPos)]); + debugln(['TCodeHelpManager.GetHTMLHint searching for inherited of ',CTNode.DescAsString,' ',dbgs(XYPos)]); OldXYPos:=XYPos; OldCTTool:=CTTool; OldCTNode:=CTNode; @@ -2351,18 +2354,19 @@ begin CTTool,CTNode,XYPos,aTopLine)) or (CTNode=OldCTNode) then begin - debugln(['TCodeHelpManager.GetHTMLHint2 inherited not found: ',dbgs(OldXYPos)]); + debugln(['TCodeHelpManager.GetHTMLHint inherited not found: ',dbgs(OldXYPos)]); break; end; end else begin - debugln(['TCodeHelpManager.GetHTMLHint2 not searching inherited for ',CTNode.DescAsString]); + debugln(['TCodeHelpManager.GetHTMLHint not searching inherited for ',CTNode.DescAsString]); break; end; end; + except on E: Exception do begin - debugln(['TCodeHelpManager.GetHTMLHint2 Exception: ',E.Message]); + debugln(['TCodeHelpManager.GetHTMLHint Exception: ',E.Message]); //DumpExceptionBackTrace; end; end; @@ -2370,10 +2374,17 @@ begin finally ElementNames.Free; FreeListOfPCodeXYPosition(ListOfPCodeXYPosition); + if chhoShowFocusHint in Options then begin + Cmd:=EditorOpts.KeyMap.FindByCommand(ecFocusHint); + if (Cmd<>nil) and (not IDEShortCutEmpty(Cmd.ShortcutA)) then begin + HTMLHint:=HTMLHint+'
Press ' + +KeyAndShiftStateToEditorKeyString(Cmd.ShortcutA)+' for focus
'+LineEnding; + end; + end; HTMLHint:=''+LineEnding +''+LineEnding+HTMLHint+''+LineEnding; end; - debugln(['TCodeHelpManager.GetHTMLHint2 ',HTMLHint]); + debugln(['TCodeHelpManager.GetHTMLHint ',HTMLHint]); Result:=chprSuccess; end; diff --git a/ide/idehelpmanager.pas b/ide/idehelpmanager.pas index 0c200dcb75..7cd286c068 100644 --- a/ide/idehelpmanager.pas +++ b/ide/idehelpmanager.pas @@ -190,8 +190,9 @@ type const BaseURL: string; var TheHint: string; out HintWinRect: TRect): boolean; override; function GetHintForSourcePosition(const ExpandedFilename: string; - const CodePos: TPoint; - out BaseURL, HTMLHint: string): TShowHelpResult; override; + const CodePos: TPoint; + out BaseURL, HTMLHint: string; + Flags: TIDEHelpManagerCreateHintFlags = []): TShowHelpResult; override; function ConvertSourcePosToPascalHelpContext(const CaretPos: TPoint; const Filename: string): TPascalHelpContextList; override; @@ -1492,20 +1493,24 @@ begin Result:=true; end; -function TIDEHelpManager.GetHintForSourcePosition(const ExpandedFilename: string; - const CodePos: TPoint; out BaseURL, HTMLHint: string): TShowHelpResult; +function TIDEHelpManager.GetHintForSourcePosition( + const ExpandedFilename: string; const CodePos: TPoint; out BaseURL, + HTMLHint: string; Flags: TIDEHelpManagerCreateHintFlags): TShowHelpResult; var Code: TCodeBuffer; CacheWasUsed: boolean; + HintFlags: TCodeHelpHintOptions; begin BaseURL:=''; HTMLHint:=''; Code:=CodeToolBoss.LoadFile(ExpandedFilename,true,false); if (Code=nil) or Code.LineColIsSpace(CodePos.Y,CodePos.X) then exit(shrHelpNotFound); + HintFlags:=[chhoDeclarationHeader]; + if ihmchAddFocusHint in Flags then + Include(HintFlags,chhoShowFocusHint); if CodeHelpBoss.GetHTMLHint(Code,CodePos.X,CodePos.Y, - [chhoDeclarationHeader], - BaseURL,HTMLHint,CacheWasUsed)=chprSuccess + HintFlags,BaseURL,HTMLHint,CacheWasUsed)=chprSuccess then exit(shrSuccess); Result:=shrHelpNotFound; diff --git a/ide/keymapping.pp b/ide/keymapping.pp index 3ff57ecd04..58d2cf13cb 100644 --- a/ide/keymapping.pp +++ b/ide/keymapping.pp @@ -607,6 +607,7 @@ begin ecContextHelp: SetResult(VK_F1,[],VK_UNKNOWN,[]); ecEditContextHelp: SetResult(VK_F1,[ssShift,ssCtrl],VK_UNKNOWN,[]); ecReportingBug: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); + ecFocusHint: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); // designer ecDesignerCopy : SetResult(VK_C,[ssCtrl],VK_Insert,[ssCtrl]); @@ -1049,6 +1050,7 @@ begin ecContextHelp: SetResult(VK_F1,[ssCtrl],VK_UNKNOWN,[]); ecEditContextHelp: SetResult(VK_F1,[ssCtrl,ssShift],VK_UNKNOWN,[]); ecReportingBug: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); + ecFocusHint: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); // designer ecDesignerCopy : SetResult(VK_C,[ssCtrl],VK_UNKNOWN,[],VK_Insert,[ssCtrl],VK_UNKNOWN,[]); @@ -1680,6 +1682,7 @@ begin ecContextHelp: SetResult(VK_HELP,[],VK_UNKNOWN,[]); ecEditContextHelp: SetResult(VK_HELP,[ssShift,ssCtrl],VK_HELP,[ssCtrl]); ecReportingBug: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); + ecFocusHint: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]); // designer ecDesignerCopy : SetResult(VK_C,[ssMeta],VK_UNKNOWN,[]); @@ -2227,6 +2230,7 @@ begin ecContextHelp : Result:= lisMenuContextHelp; ecEditContextHelp : Result:= lisMenuEditContextHelp; ecReportingBug : Result:= srkmecReportingBug; + ecFocusHint : Result:= lisFocusHint; // desginer ecDesignerCopy : Result:= lisDsgCopyComponents; @@ -2887,6 +2891,7 @@ begin AddDefault(C, 'Context sensitive help', lisKMContextSensitiveHelp, ecContextHelp); AddDefault(C, 'Edit context sensitive help', lisKMEditContextSensitiveHelp, ecEditContextHelp); AddDefault(C, 'Reporting a bug', srkmecReportingBug, ecReportingBug); + AddDefault(C, 'Focus hint', lisFocusHint, ecFocusHint); // designer - without menu items in the IDE bar (at least not directly) C:=Categories[AddCategory('Designer',lisKeyCatDesigner,IDECmdScopeDesignerOnly)]; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index a596b03206..be3d48a96d 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -2706,6 +2706,7 @@ resourcestring // help menu srkmecunknown = 'unknown editor command'; srkmecReportingBug = 'Reporting a bug'; + lisFocusHint = 'Focus hint'; // Category srkmCatCursorMoving = 'Cursor moving commands'; diff --git a/ide/main.pp b/ide/main.pp index 1b43a7510a..6c57100ca3 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -16139,7 +16139,8 @@ begin if EditorOpts.AutoToolTipSymbTools then begin {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.OnSrcNotebookShowHintForSource A');{$ENDIF} TIDEHelpManager(HelpBoss).GetHintForSourcePosition(ActiveUnitInfo.Filename, - CaretPos,BaseURL,SmartHintStr); + CaretPos,BaseURL,SmartHintStr, + [{$IFDEF EnableFocusHint}ihmchAddFocusHint{$ENDIF}]); {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.OnSrcNotebookShowHintForSource B');{$ENDIF} end; case ToolStatus of diff --git a/ideintf/idecommands.pas b/ideintf/idecommands.pas index 1275d364cf..51316053e7 100644 --- a/ideintf/idecommands.pas +++ b/ideintf/idecommands.pas @@ -310,6 +310,7 @@ const ecContextHelp = ecFirstLazarus + 903; ecEditContextHelp = ecFirstLazarus + 904; ecReportingBug = ecFirstLazarus + 905; + ecFocusHint = ecFirstLazarus + 906; // designer ecDesignerCopy = ecFirstLazarus + 1000; diff --git a/ideintf/idehelpintf.pas b/ideintf/idehelpintf.pas index a829ba5fe9..01c6afff59 100644 --- a/ideintf/idehelpintf.pas +++ b/ideintf/idehelpintf.pas @@ -49,6 +49,11 @@ type property ModifierStr: string read FModifierStr write FModifierStr; end; + TIDEHelpManagerCreateHintFlag = ( + ihmchAddFocusHint + ); + TIDEHelpManagerCreateHintFlags = set of TIDEHelpManagerCreateHintFlag; + { TBaseHelpManager } TBaseHelpManager = class(TComponent) @@ -65,7 +70,8 @@ type procedure ShowHelpForIDEControl(Sender: TControl); virtual; abstract; function GetHintForSourcePosition(const ExpandedFilename: string; const CodePos: TPoint; - out BaseURL, HTMLHint: string): TShowHelpResult; virtual; abstract; + out BaseURL, HTMLHint: string; + Flags: TIDEHelpManagerCreateHintFlags = []): TShowHelpResult; virtual; abstract; function CreateHint(aHintWindow: THintWindow; ScreenPos: TPoint; const BaseURL: string; var TheHint: string; out HintWinRect: TRect): boolean; virtual; abstract; diff --git a/packager/pkgmanager.pas b/packager/pkgmanager.pas index 79dab8f92e..00ff7d291e 100644 --- a/packager/pkgmanager.pas +++ b/packager/pkgmanager.pas @@ -306,7 +306,7 @@ type function CheckInstallPackageList(PkgIDList: TObjectList; Flags: TPkgInstallInIDEFlags = []): boolean; override; function InstallPackages(PkgIdList: TObjectList; - Flags: TPkgInstallInIDEFlags = []): TModalResult; override; + Flags: TPkgInstallInIDEFlags = []): TModalResult; override; procedure DoTranslatePackage(APackage: TLazPackage); function DoOpenPackageSource(APackage: TLazPackage): TModalResult; function DoCompileAutoInstallPackages(Flags: TPkgCompileFlags;