mirror of https://gitlab.com/basile.b/dexed.git
added support for MouseLinks: <Ctrl>+Move, <Ctrl>+<mbLeft>, invoke dcd find symbol loc
This commit is contained in:
parent
19c2afe9d9
commit
eb7f061480
|
@ -39,6 +39,7 @@ type
|
||||||
procedure memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure memoMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure memoMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
procedure memoChange(Sender: TObject);
|
procedure memoChange(Sender: TObject);
|
||||||
|
procedure memoCtrlClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
procedure memoMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
procedure memoMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
||||||
function getEditor(index: NativeInt): TCESynMemo;
|
function getEditor(index: NativeInt): TCESynMemo;
|
||||||
function getEditorCount: NativeInt;
|
function getEditorCount: NativeInt;
|
||||||
|
@ -194,6 +195,7 @@ begin
|
||||||
memo.OnKeyPress := @memoKeyPress;
|
memo.OnKeyPress := @memoKeyPress;
|
||||||
memo.OnMouseDown := @memoMouseDown;
|
memo.OnMouseDown := @memoMouseDown;
|
||||||
memo.OnMouseMove := @memoMouseMove;
|
memo.OnMouseMove := @memoMouseMove;
|
||||||
|
memo.OnClickLink := @memoCtrlClick;
|
||||||
//
|
//
|
||||||
pageControl.ActivePage := sheet;
|
pageControl.ActivePage := sheet;
|
||||||
end;
|
end;
|
||||||
|
@ -241,6 +243,11 @@ procedure TCEEditorWidget.memoChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEEditorWidget.memoCtrlClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
getSymbolLoc;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEEditorWidget.getSymbolLoc;
|
procedure TCEEditorWidget.getSymbolLoc;
|
||||||
var
|
var
|
||||||
str: TMemoryStream;
|
str: TMemoryStream;
|
||||||
|
@ -263,7 +270,10 @@ begin
|
||||||
if fname <> ftempname then if fileExists(fname) then
|
if fname <> ftempname then if fileExists(fname) then
|
||||||
CEMainForm.openFile(fname);
|
CEMainForm.openFile(fname);
|
||||||
if srcpos <> -1 then
|
if srcpos <> -1 then
|
||||||
fDoc.SelStart := srcpos; // fDoc probably not be updated
|
begin
|
||||||
|
fDoc.SelStart := srcpos;
|
||||||
|
fDoc.SelectWord;
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
str.Free;
|
str.Free;
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -5,9 +5,9 @@ unit ce_synmemo;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, SynEdit, SynMemo, ce_d2syn, ce_txtsyn ,SynEditHighlighter,
|
Classes, SysUtils, SynEdit, ce_d2syn, ce_txtsyn ,SynEditHighlighter,
|
||||||
controls, lcltype, LazSynEditText, SynEditKeyCmds, SynHighlighterLFM, SynEditMouseCmds,
|
controls, lcltype, LazSynEditText, SynEditKeyCmds, SynHighlighterLFM, SynEditMouseCmds,
|
||||||
ce_common, ce_observer;
|
ce_common, ce_observer, ce_dcd;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -16,16 +16,16 @@ type
|
||||||
fPos: Integer;
|
fPos: Integer;
|
||||||
fMax: Integer;
|
fMax: Integer;
|
||||||
fList: TFPList;
|
fList: TFPList;
|
||||||
fMemo: TSynMemo;
|
fMemo: TCustomSynEdit;
|
||||||
public
|
public
|
||||||
constructor create(aMemo: TSynMemo);
|
constructor create(aMemo: TCustomSynEdit);
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
procedure store;
|
procedure store;
|
||||||
procedure back;
|
procedure back;
|
||||||
procedure next;
|
procedure next;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCESynMemo = class(TSynMemo)
|
TCESynMemo = class(TSynEdit)
|
||||||
private
|
private
|
||||||
fFilename: string;
|
fFilename: string;
|
||||||
fModified: boolean;
|
fModified: boolean;
|
||||||
|
@ -78,7 +78,7 @@ uses
|
||||||
graphics, ce_interfaces;
|
graphics, ce_interfaces;
|
||||||
|
|
||||||
{$REGION TCESynMemoPositions ---------------------------------------------------}
|
{$REGION TCESynMemoPositions ---------------------------------------------------}
|
||||||
constructor TCESynMemoPositions.create(aMemo: TSynMemo);
|
constructor TCESynMemoPositions.create(aMemo: TCustomSynEdit);
|
||||||
begin
|
begin
|
||||||
fList := TFPList.Create;
|
fList := TFPList.Create;
|
||||||
fMax := 20;
|
fMax := 20;
|
||||||
|
@ -95,32 +95,38 @@ end;
|
||||||
procedure TCESynMemoPositions.back;
|
procedure TCESynMemoPositions.back;
|
||||||
begin
|
begin
|
||||||
Inc(fPos);
|
Inc(fPos);
|
||||||
{$WARNINGS OFF}
|
{$HINTS OFF}
|
||||||
if fPos < fList.Count then
|
if fPos < fList.Count then
|
||||||
fMemo.CaretY := NativeInt(fList.Items[fPos])
|
fMemo.CaretY := NativeInt(fList.Items[fPos])
|
||||||
{$WARNINGS ON}
|
{$HINTS ON}
|
||||||
else Dec(fPos);
|
else Dec(fPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCESynMemoPositions.next;
|
procedure TCESynMemoPositions.next;
|
||||||
begin
|
begin
|
||||||
Dec(fPos);
|
Dec(fPos);
|
||||||
{$WARNINGS OFF}
|
{$HINTS OFF}
|
||||||
if fPos > -1 then
|
if fPos > -1 then
|
||||||
fMemo.CaretY := NativeInt(fList.Items[fPos])
|
fMemo.CaretY := NativeInt(fList.Items[fPos])
|
||||||
{$WARNINGS ON}
|
{$HINTS ON}
|
||||||
else Inc(fPos);
|
else Inc(fPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCESynMemoPositions.store;
|
procedure TCESynMemoPositions.store;
|
||||||
|
var
|
||||||
|
delta: NativeInt;
|
||||||
|
const
|
||||||
|
thresh = 6;
|
||||||
begin
|
begin
|
||||||
fPos := 0;
|
fPos := 0;
|
||||||
{$WARNINGS OFF}
|
{$HINTS OFF}{$WARNINGS OFF}
|
||||||
if fList.Count > 0 then
|
if fList.Count > 0 then
|
||||||
if NativeInt(fList.Items[fPos]) = fMemo.CaretY then
|
begin
|
||||||
exit;
|
delta := fMemo.CaretY - NativeInt(fList.Items[fPos]);
|
||||||
|
if (delta > -thresh) and (delta < thresh) then exit;
|
||||||
|
end;
|
||||||
fList.Insert(0, Pointer(NativeInt(fMemo.CaretY)));
|
fList.Insert(0, Pointer(NativeInt(fMemo.CaretY)));
|
||||||
{$WARNINGS ON}
|
{$HINTS ON}{$WARNINGS ON}
|
||||||
while fList.Count > fMax do
|
while fList.Count > fMax do
|
||||||
fList.Delete(fList.Count-1);
|
fList.Delete(fList.Count-1);
|
||||||
end;
|
end;
|
||||||
|
@ -144,7 +150,7 @@ begin
|
||||||
fStoredFontSize := Font.Size;
|
fStoredFontSize := Font.Size;
|
||||||
|
|
||||||
MouseOptions := MouseOptions +
|
MouseOptions := MouseOptions +
|
||||||
[emAltSetsColumnMode, emDragDropEditing, emCtrlWheelZoom];
|
[emAltSetsColumnMode, emDragDropEditing, emCtrlWheelZoom, emShowCtrlMouseLinks];
|
||||||
Gutter.LineNumberPart.ShowOnlyLineNumbersMultiplesOf := 5;
|
Gutter.LineNumberPart.ShowOnlyLineNumbersMultiplesOf := 5;
|
||||||
Gutter.LineNumberPart.MarkupInfo.Foreground := clGray;
|
Gutter.LineNumberPart.MarkupInfo.Foreground := clGray;
|
||||||
Gutter.SeparatorPart.LineOffset := 1;
|
Gutter.SeparatorPart.LineOffset := 1;
|
||||||
|
@ -152,6 +158,13 @@ begin
|
||||||
Gutter.SeparatorPart.MarkupInfo.Foreground := clGray;
|
Gutter.SeparatorPart.MarkupInfo.Foreground := clGray;
|
||||||
Gutter.CodeFoldPart.MarkupInfo.Foreground := clGray;
|
Gutter.CodeFoldPart.MarkupInfo.Foreground := clGray;
|
||||||
//
|
//
|
||||||
|
MouseLinkColor.Style:= [fsUnderline];
|
||||||
|
with MouseActions.Add do begin
|
||||||
|
Command := emcMouseLink;
|
||||||
|
shift := [ssCtrl];
|
||||||
|
ShiftMask := [ssCtrl];
|
||||||
|
end;
|
||||||
|
//
|
||||||
Highlighter := D2Syn;
|
Highlighter := D2Syn;
|
||||||
D2Syn.FoldKinds := [fkBrackets, fkComments1, fkComments2, fkStrings];
|
D2Syn.FoldKinds := [fkBrackets, fkComments1, fkComments2, fkStrings];
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue