From 9f72412e85a7fb35e1b7d6619020fbec702e3322 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 7 Feb 2015 06:37:39 +0100 Subject: [PATCH 1/3] added custom hint window class --- src/ce_synmemo.pas | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index 3c916f10..d25784ec 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -7,12 +7,20 @@ interface uses Classes, SysUtils, SynEdit, ce_d2syn, ce_txtsyn ,SynEditHighlighter, controls, lcltype, LazSynEditText, SynEditKeyCmds, SynHighlighterLFM, SynEditMouseCmds, - SynEditFoldedView, crc, ce_common, ce_observer, ce_writableComponent; + SynEditFoldedView, crc, ce_common, ce_observer, ce_writableComponent, Forms; type TCESynMemo = class; + TCEEditorHintWindow = class(THintWindow) + public + class var FontSize: Integer; + constructor Create(AOwner: TComponent); override; + function CalcHintRect(MaxWidth: Integer; const AHint: String; + AData: Pointer): TRect; override; + end; + TCEFoldCache = class(TCollectionItem) private fCollapsed: boolean; @@ -123,6 +131,20 @@ implementation uses graphics, ce_interfaces, ce_staticmacro, ce_dcd, SynEditHighlighterFoldBase; + + +constructor TCEEditorHintWindow.Create(AOwner: TComponent); +begin + inherited; + Canvas.Font.Size:= FontSize; +end; + +function TCEEditorHintWindow.CalcHintRect(MaxWidth: Integer; const AHint: String; AData: Pointer): TRect; +begin + Canvas.Font.Size:= FontSize; + result := inherited CalcHintRect(MaxWidth, AHint, AData); +end; + {$REGION TCESynMemoCache -------------------------------------------------------} constructor TCESynMemoCache.create(aComponent: TComponent); begin @@ -153,6 +175,7 @@ begin fSourceFilename := fMemo.fileName; fSelectionEnd := fMemo.SelEnd; fFontSize := fMemo.Font.Size; + TCEEditorHintWindow.FontSize := fMemo.Font.Size; // // TODO-cEditor Cache: >nested< folding persistence // cf. other ways: http://forum.lazarus.freepascal.org/index.php?topic=26748.msg164722#msg164722 @@ -486,12 +509,14 @@ procedure TCESynMemo.KeyDown(var Key: Word; Shift: TShiftState); begin inherited; identifierToD2Syn; + if not (Shift = [ssCtrl]) then exit; // - if (Shift = [ssCtrl]) then case Key of + case Key of VK_ADD: if Font.Size < 50 then Font.Size := Font.Size + 1; VK_SUBTRACT: if Font.Size > 3 then Font.Size := Font.Size - 1; VK_DECIMAL: Font.Size := fStoredFontSize; end; + TCEEditorHintWindow.FontSize := Font.Size; end; procedure TCESynMemo.KeyUp(var Key: Word; Shift: TShiftState); @@ -552,6 +577,8 @@ initialization LfmSyn.KeyAttri.Style := [fsBold]; LfmSyn.NumberAttri.Foreground := clMaroon; LfmSyn.StringAttri.Foreground := clBlue; + // + TCEEditorHintWindow.FontSize := 10; finalization D2Syn.Free; LfmSyn.Free; From eaece5e6703466fabff5db817c94842983d90001 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 7 Feb 2015 06:38:16 +0100 Subject: [PATCH 2/3] activated ddoc hints from DCD --- src/ce_main.pas | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/ce_main.pas b/src/ce_main.pas index 3316b68c..44d43483 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -853,12 +853,27 @@ end; procedure TCEMainForm.ApplicationProperties1ShowHint(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo); begin - CanShow := true; - //if fDoc <> nil then if fDoc.Focused then - //begin - // DcdWrapper.getDdocFromCursor(HintStr); - // CanShow := HintStr <> ''; - //end; + // TODO-crefactor: move this to TCESynMemo or TCEEditorWidget. + // TODO-cbugfix: first DDoc hint, window rect is wrong. + if fDoc <> nil then if fDoc.Focused then + begin + TCEEditorHintWindow.FontSize := fDoc.Font.Size; + HintInfo.HintWindowClass := TCEEditorHintWindow; + HintInfo.HideTimeout := 120000; + // note: non-default color allows non-themed draw() which allows custom font-size to be handled. + HintInfo.HintColor := clInfoBk + $01010100; + // + DcdWrapper.getDdocFromCursor(HintStr); + if (length(HintStr) > 0) then + if Hintstr[1] = #13 then + Hintstr := Hintstr[2..length(Hintstr)]; + if (length(HintStr) > 0) then + if Hintstr[1] = #10 then + Hintstr := Hintstr[2..length(Hintstr)]; + end else + HintInfo.HideTimeout := 2500; + // + CanShow := HintStr <> ''; end; {$ENDREGION} From f6ef7aa4bf6b321539fa1c018055c272e3a1d58a Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 7 Feb 2015 06:38:41 +0100 Subject: [PATCH 3/3] typo --- src/ce_editor.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ce_editor.pas b/src/ce_editor.pas index a1f8caa3..70e0587a 100644 --- a/src/ce_editor.pas +++ b/src/ce_editor.pas @@ -99,7 +99,7 @@ begin // completion.OnPaintItem := @completionItemPaint; fSyncEdit := TSynPluginSyncroEdit.Create(self); - //TODO-ccLCL&LAZ-specific: activate this after next Laz release + //TODO-cLCL&LAZ-specific: activate this after next Laz release //fSyncEdit.CaseSensitive:=true; bmp := TBitmap.Create; try