mirror of https://gitlab.com/basile.b/dexed.git
added custom hint window class
This commit is contained in:
parent
15c51f1fef
commit
9f72412e85
|
@ -7,12 +7,20 @@ interface
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, SynEdit, ce_d2syn, ce_txtsyn ,SynEditHighlighter, controls,
|
Classes, SysUtils, SynEdit, ce_d2syn, ce_txtsyn ,SynEditHighlighter, controls,
|
||||||
lcltype, LazSynEditText, SynEditKeyCmds, SynHighlighterLFM, SynEditMouseCmds,
|
lcltype, LazSynEditText, SynEditKeyCmds, SynHighlighterLFM, SynEditMouseCmds,
|
||||||
SynEditFoldedView, crc, ce_common, ce_observer, ce_writableComponent;
|
SynEditFoldedView, crc, ce_common, ce_observer, ce_writableComponent, Forms;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
TCESynMemo = class;
|
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)
|
TCEFoldCache = class(TCollectionItem)
|
||||||
private
|
private
|
||||||
fCollapsed: boolean;
|
fCollapsed: boolean;
|
||||||
|
@ -123,6 +131,20 @@ implementation
|
||||||
uses
|
uses
|
||||||
graphics, ce_interfaces, ce_staticmacro, ce_dcd, SynEditHighlighterFoldBase;
|
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 -------------------------------------------------------}
|
{$REGION TCESynMemoCache -------------------------------------------------------}
|
||||||
constructor TCESynMemoCache.create(aComponent: TComponent);
|
constructor TCESynMemoCache.create(aComponent: TComponent);
|
||||||
begin
|
begin
|
||||||
|
@ -153,6 +175,7 @@ begin
|
||||||
fSourceFilename := fMemo.fileName;
|
fSourceFilename := fMemo.fileName;
|
||||||
fSelectionEnd := fMemo.SelEnd;
|
fSelectionEnd := fMemo.SelEnd;
|
||||||
fFontSize := fMemo.Font.Size;
|
fFontSize := fMemo.Font.Size;
|
||||||
|
TCEEditorHintWindow.FontSize := fMemo.Font.Size;
|
||||||
//
|
//
|
||||||
// TODO-cEditor Cache: >nested< folding persistence
|
// TODO-cEditor Cache: >nested< folding persistence
|
||||||
// cf. other ways: http://forum.lazarus.freepascal.org/index.php?topic=26748.msg164722#msg164722
|
// 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
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
identifierToD2Syn;
|
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_ADD: if Font.Size < 50 then Font.Size := Font.Size + 1;
|
||||||
VK_SUBTRACT: if Font.Size > 3 then Font.Size := Font.Size - 1;
|
VK_SUBTRACT: if Font.Size > 3 then Font.Size := Font.Size - 1;
|
||||||
VK_DECIMAL: Font.Size := fStoredFontSize;
|
VK_DECIMAL: Font.Size := fStoredFontSize;
|
||||||
end;
|
end;
|
||||||
|
TCEEditorHintWindow.FontSize := Font.Size;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCESynMemo.KeyUp(var Key: Word; Shift: TShiftState);
|
procedure TCESynMemo.KeyUp(var Key: Word; Shift: TShiftState);
|
||||||
|
@ -552,6 +577,8 @@ initialization
|
||||||
LfmSyn.KeyAttri.Style := [fsBold];
|
LfmSyn.KeyAttri.Style := [fsBold];
|
||||||
LfmSyn.NumberAttri.Foreground := clMaroon;
|
LfmSyn.NumberAttri.Foreground := clMaroon;
|
||||||
LfmSyn.StringAttri.Foreground := clBlue;
|
LfmSyn.StringAttri.Foreground := clBlue;
|
||||||
|
//
|
||||||
|
TCEEditorHintWindow.FontSize := 10;
|
||||||
finalization
|
finalization
|
||||||
D2Syn.Free;
|
D2Syn.Free;
|
||||||
LfmSyn.Free;
|
LfmSyn.Free;
|
||||||
|
|
Loading…
Reference in New Issue