mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 04:38:13 +02:00
SynEdit: moved wheel to mouse actions
git-svn-id: trunk@33972 -
This commit is contained in:
parent
7ab9c2029b
commit
fe880f6f54
@ -365,9 +365,8 @@ type
|
||||
{$ENDIF}
|
||||
procedure WMKillFocus(var Msg: TWMKillFocus); message WM_KILLFOCUS;
|
||||
procedure WMExit(var Message: TLMExit); message LM_EXIT;
|
||||
{$IFNDEF SYN_LAZARUS}
|
||||
procedure WMMouseWheel(var Msg: TMessage); message WM_MOUSEWHEEL;
|
||||
{$ENDIF}
|
||||
procedure WMMouseWheel(var Message: TLMMouseEvent); message LM_MOUSEWHEEL;
|
||||
//procedure WMMouseWheel(var Msg: TMessage); message WM_MOUSEWHEEL;
|
||||
procedure WMSetFocus(var Msg: TLMSetFocus); message WM_SETFOCUS;
|
||||
procedure WMVScroll(var Msg: {$IFDEF SYN_LAZARUS}TLMScroll{$ELSE}TWMScroll{$ENDIF}); message WM_VSCROLL;
|
||||
private
|
||||
@ -441,14 +440,12 @@ type
|
||||
fMouseDownX: integer;
|
||||
fMouseDownY: integer;
|
||||
fBookMarkOpt: TSynBookMarkOpt;
|
||||
{$ifndef SYN_LAZARUS}
|
||||
fMouseWheelAccumulator: integer;
|
||||
{$endif}
|
||||
FMouseWheelAccumulator: integer;
|
||||
fHideSelection: boolean;
|
||||
fOverwriteCaret: TSynEditCaretType;
|
||||
fInsertCaret: TSynEditCaretType;
|
||||
FKeyStrokes, FLastKeyStrokes: TSynEditKeyStrokes;
|
||||
FMouseActions, FMouseSelActions: TSynEditMouseInternalActions;
|
||||
FMouseActions, FMouseSelActions, FMouseTextActions: TSynEditMouseInternalActions;
|
||||
FMouseActionSearchHandlerList: TSynEditMouseActionSearchList;
|
||||
FMouseActionExecHandlerList: TSynEditMouseActionExecList;
|
||||
FMarkList: TSynEditMarkList;
|
||||
@ -499,6 +496,7 @@ type
|
||||
function GetModified: Boolean;
|
||||
function GetMouseActions: TSynEditMouseActions;
|
||||
function GetMouseSelActions: TSynEditMouseActions;
|
||||
function GetMouseTextActions: TSynEditMouseActions;
|
||||
function GetPaintLockOwner: TSynEditBase;
|
||||
function GetPlugin(Index: Integer): TSynEditPlugin;
|
||||
function GetTextBetweenPoints(aStartPoint, aEndPoint: TPoint): String;
|
||||
@ -507,6 +505,7 @@ type
|
||||
procedure SetFoldState(const AValue: String);
|
||||
procedure SetMouseActions(const AValue: TSynEditMouseActions);
|
||||
procedure SetMouseSelActions(const AValue: TSynEditMouseActions);
|
||||
procedure SetMouseTextActions(AValue: TSynEditMouseActions);
|
||||
procedure SetPaintLockOwner(const AValue: TSynEditBase);
|
||||
procedure SetShareOptions(const AValue: TSynEditorShareOptions);
|
||||
procedure SetTextBetweenPoints(aStartPoint, aEndPoint: TPoint; const AValue: String);
|
||||
@ -652,7 +651,7 @@ type
|
||||
procedure ScrollTimerHandler(Sender: TObject);
|
||||
procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); override;
|
||||
|
||||
procedure FindAndHandleMouseAction(AButton: TMouseButton; AShift: TShiftState;
|
||||
procedure FindAndHandleMouseAction(AButton: TSynMouseButton; AShift: TShiftState;
|
||||
X, Y: Integer; ACCount:TSynMAClickCount;
|
||||
ADir: TSynMAClickDir);
|
||||
function DoHandleMouseAction(AnActionList: TSynEditMouseActions;
|
||||
@ -952,6 +951,8 @@ type
|
||||
read FKeystrokes write SetKeystrokes;
|
||||
property MouseActions: TSynEditMouseActions
|
||||
read GetMouseActions write SetMouseActions;
|
||||
property MouseTextActions: TSynEditMouseActions
|
||||
read GetMouseTextActions write SetMouseTextActions;
|
||||
property MouseSelActions: TSynEditMouseActions // Mouseactions, if mouse is over selection => fallback to normal
|
||||
read GetMouseSelActions write SetMouseSelActions;
|
||||
property MaxUndo: Integer read GetMaxUndo write SetMaxUndo default 1024;
|
||||
@ -1206,6 +1207,13 @@ type
|
||||
function PerformUndo(Caller: TObject): Boolean; override;
|
||||
end;
|
||||
|
||||
{ TSynEditMouseGlobalActions }
|
||||
|
||||
TSynEditMouseGlobalActions = class(TSynEditMouseInternalActions)
|
||||
protected
|
||||
procedure InitForOptions(AnOptions: TSynEditorMouseOptions); override;
|
||||
end;
|
||||
|
||||
{ TSynEditMouseTextActions }
|
||||
|
||||
TSynEditMouseTextActions = class(TSynEditMouseInternalActions)
|
||||
@ -1350,6 +1358,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TSynEditMouseGlobalActions }
|
||||
|
||||
procedure TSynEditMouseGlobalActions.InitForOptions(AnOptions: TSynEditorMouseOptions);
|
||||
begin
|
||||
AddCommand(emcWheelScrollDown, False, mbWheelDown, ccAny, cdDown, [], []);
|
||||
AddCommand(emcWheelScrollUp, False, mbWheelUp, ccAny, cdDown, [], []);
|
||||
end;
|
||||
|
||||
{ TSynEditMouseTextActions }
|
||||
|
||||
procedure TSynEditMouseTextActions.InitForOptions(AnOptions: TSynEditorMouseOptions);
|
||||
@ -1491,6 +1507,11 @@ begin
|
||||
Result := FMouseSelActions.UserActions;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetMouseTextActions: TSynEditMouseActions;
|
||||
begin
|
||||
Result := FMouseTextActions.UserActions;
|
||||
end;
|
||||
|
||||
function TCustomSynEdit.GetPaintLockOwner: TSynEditBase;
|
||||
begin
|
||||
Result := TSynEditStringList(FLines).PaintLockOwner;
|
||||
@ -1822,8 +1843,9 @@ begin
|
||||
SetDefaultKeystrokes;
|
||||
end;
|
||||
|
||||
FMouseActions := TSynEditMouseTextActions.Create(Self);
|
||||
FMouseSelActions := TSynEditMouseSelActions.Create(Self);
|
||||
FMouseActions := TSynEditMouseGlobalActions.Create(Self);
|
||||
FMouseSelActions := TSynEditMouseSelActions.Create(Self);
|
||||
FMouseTextActions := TSynEditMouseTextActions.Create(Self);
|
||||
FMouseActionSearchHandlerList := TSynEditMouseActionSearchList.Create;
|
||||
FMouseActionExecHandlerList := TSynEditMouseActionExecList.Create;
|
||||
|
||||
@ -2062,6 +2084,7 @@ begin
|
||||
FreeAndNil(FMouseActionExecHandlerList);
|
||||
FreeAndNil(FMouseActions);
|
||||
FreeAndNil(FMouseSelActions);
|
||||
FreeAndNil(FMouseTextActions);
|
||||
FreeAndNil(FLeftGutter);
|
||||
FreeAndNil(FRightGutter);
|
||||
FreeAndNil(FPaintLineColor);
|
||||
@ -2584,6 +2607,9 @@ var
|
||||
Handled: Boolean;
|
||||
AnAction: TSynEditMouseAction;
|
||||
ClipHelper: TSynClipboardStream;
|
||||
i: integer;
|
||||
const
|
||||
WHEEL_PAGESCROLL = MAXDWORD;
|
||||
begin
|
||||
AnAction := nil;
|
||||
Result := False;
|
||||
@ -2709,7 +2735,7 @@ begin
|
||||
if assigned(fMarkupCtrlMouse) and fMarkupCtrlMouse.IsMouseOverLink and
|
||||
assigned(FOnClickLink)
|
||||
then
|
||||
FOnClickLink(Self, AnInfo.Button, AnInfo.Shift, AnInfo.MouseX, AnInfo.MouseY)
|
||||
FOnClickLink(Self, SynMouseButtonBackMap[AnInfo.Button], AnInfo.Shift, AnInfo.MouseX, AnInfo.MouseY)
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
@ -2730,6 +2756,20 @@ begin
|
||||
MoveCaret;
|
||||
CommandProcessor(AnAction.Option, #0, nil);
|
||||
end;
|
||||
emcWheelScrollDown:
|
||||
begin
|
||||
i := Mouse.WheelScrollLines;
|
||||
if (i = WHEEL_PAGESCROLL) or (i > fLinesInWindow) then
|
||||
i := fLinesInWindow;
|
||||
TopView := TopView - i;
|
||||
end;
|
||||
emcWheelScrollUp:
|
||||
begin
|
||||
i := Mouse.WheelScrollLines;
|
||||
if (i = WHEEL_PAGESCROLL) or (i > fLinesInWindow) then
|
||||
i := fLinesInWindow;
|
||||
TopView := TopView + i;
|
||||
end;
|
||||
else
|
||||
Result := False; // ACommand was not handled => Fallback to parent Context
|
||||
end;
|
||||
@ -2739,7 +2779,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.FindAndHandleMouseAction(AButton: TMouseButton;
|
||||
procedure TCustomSynEdit.FindAndHandleMouseAction(AButton: TSynMouseButton;
|
||||
AShift: TShiftState; X, Y: Integer; ACCount:TSynMAClickCount;
|
||||
ADir: TSynMAClickDir);
|
||||
var
|
||||
@ -2763,24 +2803,32 @@ begin
|
||||
{$IFDEF FPC}@{$ENDIF}DoHandleMouseAction)
|
||||
then
|
||||
exit;
|
||||
// mouse event occured in Gutter ?
|
||||
|
||||
if FLeftGutter.Visible and (X < FLeftGutter.Width) then begin
|
||||
FLeftGutter.MaybeHandleMouseAction(Info, {$IFDEF FPC}@{$ENDIF}DoHandleMouseAction);
|
||||
exit;
|
||||
// No fallback to text actions
|
||||
end;
|
||||
if FRightGutter.Visible and (X > ClientWidth - FRightGutter.Width) then begin
|
||||
FRightGutter.MaybeHandleMouseAction(Info, {$IFDEF FPC}@{$ENDIF}DoHandleMouseAction);
|
||||
exit;
|
||||
// No fallback to text actions
|
||||
end;
|
||||
// mouse event occured in selected block ?
|
||||
if SelAvail and (X >= TextLeftPixelOffset) and
|
||||
//(x < ClientWidth - TextRightPixelOffset - ScrollBarWidth) and
|
||||
IsPointInSelection(FInternalCaret.LineBytePos)
|
||||
then
|
||||
if DoHandleMouseAction(FMouseSelActions.GetActionsForOptions(FMouseOptions), Info) then
|
||||
// mouse event occured in Gutter ?
|
||||
if FLeftGutter.MaybeHandleMouseAction(Info, {$IFDEF FPC}@{$ENDIF}DoHandleMouseAction) then
|
||||
exit;
|
||||
end
|
||||
else
|
||||
if FRightGutter.Visible and (X > ClientWidth - FRightGutter.Width) then begin
|
||||
// mouse event occured in Gutter ?
|
||||
if FRightGutter.MaybeHandleMouseAction(Info, {$IFDEF FPC}@{$ENDIF}DoHandleMouseAction) then
|
||||
exit;
|
||||
end
|
||||
else
|
||||
begin
|
||||
// mouse event occured in selected block ?
|
||||
if SelAvail and (X >= TextLeftPixelOffset) and
|
||||
//(x < ClientWidth - TextRightPixelOffset - ScrollBarWidth) and
|
||||
IsPointInSelection(FInternalCaret.LineBytePos)
|
||||
then
|
||||
if DoHandleMouseAction(FMouseSelActions.GetActionsForOptions(FMouseOptions), Info) then
|
||||
exit;
|
||||
// mouse event occured in text?
|
||||
if DoHandleMouseAction(FMouseTextActions.GetActionsForOptions(FMouseOptions), Info) then
|
||||
exit;
|
||||
end;
|
||||
|
||||
DoHandleMouseAction(FMouseActions.GetActionsForOptions(FMouseOptions), Info);
|
||||
finally
|
||||
if Info.IgnoreUpClick then
|
||||
@ -2838,7 +2886,7 @@ begin
|
||||
Include(fStateFlags, sfRightGutterClick);
|
||||
FRightGutter.MouseDown(Button, Shift, X, Y);
|
||||
end;
|
||||
FindAndHandleMouseAction(Button, Shift, X, Y, CType, cdDown);
|
||||
FindAndHandleMouseAction(SynMouseButtonMap[Button], Shift, X, Y, CType, cdDown);
|
||||
finally
|
||||
DecPaintLock;
|
||||
end;
|
||||
@ -3095,7 +3143,7 @@ begin
|
||||
FRightGutter.MouseUp(Button, Shift, X, Y);
|
||||
Exclude(fStateFlags, sfRightGutterClick);
|
||||
end;
|
||||
FindAndHandleMouseAction(Button, Shift, X, Y, CType, cdUp);
|
||||
FindAndHandleMouseAction(SynMouseButtonMap[Button], Shift, X, Y, CType, cdUp);
|
||||
finally
|
||||
DecPaintLock;
|
||||
end;
|
||||
@ -5397,6 +5445,11 @@ begin
|
||||
FMouseSelActions.UserActions := AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetMouseTextActions(AValue: TSynEditMouseActions);
|
||||
begin
|
||||
FMouseTextActions.UserActions := AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetPaintLockOwner(const AValue: TSynEditBase);
|
||||
begin
|
||||
TSynEditStringList(FLines).PaintLockOwner := AValue;
|
||||
@ -6134,6 +6187,9 @@ begin
|
||||
FMouseActions.ResetUserActions;
|
||||
FMouseSelActions.Options := FMouseOptions;
|
||||
FMouseSelActions.ResetUserActions;
|
||||
FMouseTextActions.Options := FMouseOptions;
|
||||
FMouseTextActions.ResetUserActions;
|
||||
|
||||
FLeftGutter.ResetMouseActions;
|
||||
FRightGutter.ResetMouseActions;
|
||||
end;
|
||||
@ -7125,44 +7181,45 @@ begin
|
||||
fRedoList.Unlock;
|
||||
end;
|
||||
|
||||
{$IFNDEF SYN_LAZARUS}
|
||||
|
||||
procedure TCustomSynEdit.WMMouseWheel(var Msg: TMessage);
|
||||
procedure TCustomSynEdit.WMMouseWheel(var Message: TLMMouseEvent);
|
||||
var
|
||||
nDelta: integer;
|
||||
nWheelClicks: integer;
|
||||
{$IFNDEF SYN_COMPILER_4_UP}
|
||||
lState: TShiftState;
|
||||
const
|
||||
LinesToScroll = 3;
|
||||
WHEEL_DELTA = 120;
|
||||
WHEEL_PAGESCROLL = MAXDWORD;
|
||||
{$ENDIF}
|
||||
begin
|
||||
if csDesigning in ComponentState then
|
||||
exit;
|
||||
if ((sfHorizScrollbarVisible in fStateFlags) and (Message.Y > ClientHeight)) or
|
||||
((sfVertScrollbarVisible in fStateFlags) and (Message.X > ClientWidth))
|
||||
then begin
|
||||
inherited;
|
||||
exit;
|
||||
end;
|
||||
|
||||
if GetKeyState(VK_CONTROL) >= 0 then
|
||||
{$IFDEF SYN_COMPILER_4_UP}
|
||||
nDelta := Mouse.WheelScrollLines
|
||||
{$ELSE}
|
||||
nDelta := LinesToScroll
|
||||
{$ENDIF}
|
||||
else begin
|
||||
nDelta := fLinesInWindow;
|
||||
if (eoHalfPageScroll in fOptions) then nDelta :=nDelta div 2;
|
||||
nDelta := Max(1, nDelta);
|
||||
lState := Message.State - [ssCaps, ssNum, ssScroll]; // Remove unreliable states, see http://bugs.freepascal.org/view.php?id=20065
|
||||
Inc(FMouseWheelAccumulator, Message.WheelDelta);
|
||||
|
||||
FMouseClickDoPopUp := False;
|
||||
IncPaintLock;
|
||||
try
|
||||
while FMouseWheelAccumulator > WHEEL_DELTA do begin
|
||||
dec(FMouseWheelAccumulator, WHEEL_DELTA);
|
||||
FindAndHandleMouseAction(mbWheelDown, lState, Message.X, Message.Y, ccSingle, cdDown);
|
||||
end;
|
||||
|
||||
while FMouseWheelAccumulator < WHEEL_DELTA do begin
|
||||
inc(FMouseWheelAccumulator, WHEEL_DELTA);
|
||||
FindAndHandleMouseAction(mbWheelUp, lState, Message.X, Message.Y, ccSingle, cdDown);
|
||||
end;
|
||||
finally
|
||||
DecPaintLock;
|
||||
end;
|
||||
|
||||
Inc(fMouseWheelAccumulator, SmallInt(Msg.wParamHi));
|
||||
nWheelClicks := fMouseWheelAccumulator div WHEEL_DELTA;
|
||||
fMouseWheelAccumulator := fMouseWheelAccumulator mod WHEEL_DELTA;
|
||||
if (nDelta = integer(WHEEL_PAGESCROLL)) or (nDelta > LinesInWindow) then
|
||||
nDelta := LinesInWindow;
|
||||
TopView := TopView - (nDelta * nWheelClicks);
|
||||
Update;
|
||||
end;
|
||||
if FMouseClickDoPopUp and (PopupMenu <> nil) then begin
|
||||
PopupMenu.PopupComponent:=self;
|
||||
PopupMenu.PopUp;
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
Message.Result := 1 // handled, skip further handling by interface
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetWantTabs(const Value: boolean);
|
||||
begin
|
||||
|
@ -52,13 +52,25 @@ type
|
||||
|
||||
TSynEditorMouseCommand = type word;
|
||||
TSynEditorMouseCommandOpt = type word;
|
||||
TSynMouseButton = (mbLeft, mbRight, mbMiddle, mbExtra1, mbExtra2, mbWheelUp, mbWheelDown);
|
||||
TSynMAClickCount = (ccSingle, ccDouble, ccTriple, ccQuad, ccAny);
|
||||
TSynMAClickDir = (cdUp, cdDown);
|
||||
ESynMouseCmdError = class(Exception);
|
||||
|
||||
const
|
||||
SynMouseButtonMap: Array [TMouseButton] of TSynMouseButton =
|
||||
(mbLeft, mbRight, mbMiddle, mbExtra1, mbExtra2);
|
||||
|
||||
SynMouseButtonBackMap: Array [TSynMouseButton] of TMouseButton =
|
||||
(Controls.mbLeft, Controls.mbRight, Controls.mbMiddle,
|
||||
Controls.mbExtra1, Controls.mbExtra2,
|
||||
Controls.mbLeft, Controls.mbLeft);
|
||||
|
||||
type
|
||||
|
||||
TSynEditMouseActionInfo = record
|
||||
NewCaret: TSynEditCaret;
|
||||
Button: TMouseButton;
|
||||
Button: TSynMouseButton;
|
||||
Shift: TShiftState;
|
||||
MouseX, MouseY: Integer;
|
||||
CCount: TSynMAClickCount;
|
||||
@ -75,13 +87,13 @@ type
|
||||
FOption: TSynEditorMouseCommandOpt;
|
||||
FPriority: TSynEditorMouseCommandOpt;
|
||||
FShift, FShiftMask: TShiftState;
|
||||
FButton: TMouseButton;
|
||||
FButton: TSynMouseButton;
|
||||
FClickCount: TSynMAClickCount;
|
||||
FCommand: TSynEditorMouseCommand;
|
||||
FMoveCaret: Boolean;
|
||||
procedure SetButton(const AValue: TMouseButton);
|
||||
procedure SetButton(const AValue: TSynMouseButton);
|
||||
procedure SetClickCount(const AValue: TSynMAClickCount);
|
||||
procedure SetClickDir(const AValue: TSynMAClickDir);
|
||||
procedure SetClickDir(AValue: TSynMAClickDir);
|
||||
procedure SetCommand(const AValue: TSynEditorMouseCommand);
|
||||
procedure SetMoveCaret(const AValue: Boolean);
|
||||
procedure SetOption(const AValue: TSynEditorMouseCommandOpt);
|
||||
@ -94,7 +106,7 @@ type
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
procedure Clear;
|
||||
function IsMatchingShiftState(AShift: TShiftState): Boolean;
|
||||
function IsMatchingClick(ABtn: TMouseButton; ACCount: TSynMAClickCount;
|
||||
function IsMatchingClick(ABtn: TSynMouseButton; ACCount: TSynMAClickCount;
|
||||
ACDir: TSynMAClickDir): Boolean;
|
||||
function IsFallback: Boolean;
|
||||
function Conflicts(Other: TSynEditMouseAction): Boolean;
|
||||
@ -102,7 +114,7 @@ type
|
||||
published
|
||||
property Shift: TShiftState read FShift write SetShift default [];
|
||||
property ShiftMask: TShiftState read FShiftMask write SetShiftMask default [];
|
||||
property Button: TMouseButton read FButton write SetButton default mbLeft;
|
||||
property Button: TSynMouseButton read FButton write SetButton default mbLeft;
|
||||
property ClickCount: TSynMAClickCount read FClickCount write SetClickCount default ccSingle;
|
||||
property ClickDir: TSynMAClickDir read FClickDir write SetClickDir default cdUp;
|
||||
property Command: TSynEditorMouseCommand read FCommand write SetCommand;
|
||||
@ -137,7 +149,7 @@ type
|
||||
IgnoreCmd: Boolean = False): Integer;
|
||||
procedure AddCommand(const ACmd: TSynEditorMouseCommand;
|
||||
const AMoveCaret: Boolean;
|
||||
const AButton: TMouseButton; const AClickCount: TSynMAClickCount;
|
||||
const AButton: TSynMouseButton; const AClickCount: TSynMAClickCount;
|
||||
const ADir: TSynMAClickDir; const AShift, AShiftMask: TShiftState;
|
||||
const AOpt: TSynEditorMouseCommandOpt = 0;
|
||||
const APrior: Integer = 0);
|
||||
@ -221,7 +233,10 @@ const
|
||||
|
||||
emcSynEditCommand = TSynEditorMouseCommand(17); // Key-Commands
|
||||
|
||||
emcMax = 17;
|
||||
emcWheelScrollDown = TSynEditorMouseCommand(18);
|
||||
emcWheelScrollUp = TSynEditorMouseCommand(19);
|
||||
|
||||
emcMax = 19;
|
||||
|
||||
emcPluginFirst = 20000;
|
||||
|
||||
@ -265,7 +280,7 @@ const
|
||||
implementation
|
||||
|
||||
const
|
||||
SynMouseCommandNames: array [0..15] of TIdentMapEntry = (
|
||||
SynMouseCommandNames: array [0..17] of TIdentMapEntry = (
|
||||
(Value: emcNone; Name: 'emcNone'),
|
||||
(Value: emcStartSelections; Name: 'emcStartSelections'),
|
||||
(Value: emcStartColumnSelections; Name: 'emcStartColumnSelections'),
|
||||
@ -287,7 +302,11 @@ const
|
||||
(Value: emcCodeFoldExpand; Name: 'emcCodeFoldExpand'),
|
||||
(Value: emcCodeFoldContextMenu; Name: 'emcCodeFoldContextMenu'),
|
||||
|
||||
(Value: emcSynEditCommand; Name: 'emcSynEditCommand')
|
||||
(Value: emcSynEditCommand; Name: 'emcSynEditCommand'),
|
||||
|
||||
(Value: emcWheelScrollDown; Name: 'emcWheelScrollDown'),
|
||||
(Value: emcWheelScrollUp; Name: 'emcWheelScrollUp')
|
||||
|
||||
);
|
||||
|
||||
function AllocatePluginMouseRange(Count: Integer): integer;
|
||||
@ -321,6 +340,9 @@ begin
|
||||
|
||||
emcSynEditCommand: Result := SYNS_emcSynEditCommand;
|
||||
|
||||
emcWheelScrollDown: Result := SYNS_emcWheelScrollDown;
|
||||
emcWheelScrollUp: Result := SYNS_emcWheelScrollUp;
|
||||
|
||||
else Result := ''
|
||||
end;
|
||||
end;
|
||||
@ -419,12 +441,15 @@ end;
|
||||
|
||||
{ TSynEditMouseAction }
|
||||
|
||||
procedure TSynEditMouseAction.SetButton(const AValue: TMouseButton);
|
||||
procedure TSynEditMouseAction.SetButton(const AValue: TSynMouseButton);
|
||||
begin
|
||||
if FButton = AValue then exit;
|
||||
FButton := AValue;
|
||||
if Collection <> nil then
|
||||
TSynEditMouseActions(Collection).AssertNoConflict(self);
|
||||
|
||||
if FButton in [mbWheelUp, mbWheelDown] then
|
||||
ClickDir := cdDown;
|
||||
end;
|
||||
|
||||
procedure TSynEditMouseAction.SetClickCount(const AValue: TSynMAClickCount);
|
||||
@ -435,8 +460,10 @@ begin
|
||||
TSynEditMouseActions(Collection).AssertNoConflict(self);
|
||||
end;
|
||||
|
||||
procedure TSynEditMouseAction.SetClickDir(const AValue: TSynMAClickDir);
|
||||
procedure TSynEditMouseAction.SetClickDir(AValue: TSynMAClickDir);
|
||||
begin
|
||||
if FButton in [mbWheelUp, mbWheelDown] then
|
||||
AValue := cdDown;
|
||||
if FClickDir = AValue then exit;
|
||||
FClickDir := AValue;
|
||||
if Collection <> nil then
|
||||
@ -533,7 +560,7 @@ begin
|
||||
Result := AShift * FShiftMask = FShift;
|
||||
end;
|
||||
|
||||
function TSynEditMouseAction.IsMatchingClick(ABtn: TMouseButton; ACCount: TSynMAClickCount;
|
||||
function TSynEditMouseAction.IsMatchingClick(ABtn: TSynMouseButton; ACCount: TSynMAClickCount;
|
||||
ACDir: TSynMAClickDir): Boolean;
|
||||
begin
|
||||
Result := (Button = ABtn)
|
||||
@ -717,7 +744,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TSynEditMouseActions.AddCommand(const ACmd: TSynEditorMouseCommand;
|
||||
const AMoveCaret: Boolean; const AButton: TMouseButton;
|
||||
const AMoveCaret: Boolean; const AButton: TSynMouseButton;
|
||||
const AClickCount: TSynMAClickCount; const ADir: TSynMAClickDir;
|
||||
const AShift, AShiftMask: TShiftState; const AOpt: TSynEditorMouseCommandOpt = 0;
|
||||
const APrior: Integer = 0);
|
||||
|
@ -404,6 +404,8 @@ resourcestring
|
||||
SYNS_emcCodeFoldExpand_opt = 'Nodes,One,All';
|
||||
SYNS_emcCodeFoldContextMenu = 'Fold Menu';
|
||||
SYNS_emcSynEditCommand = 'IDE Command';
|
||||
SYNS_emcWheelScrollDown = 'Wheel scroll down';
|
||||
SYNS_emcWheelScrollUp = 'Wheel scroll up';
|
||||
SYNS_emcContextMenuCaretMove_opt = '"Move caret, when selection exists", Never, "Click outside", Always';
|
||||
|
||||
implementation
|
||||
|
@ -693,7 +693,7 @@ type
|
||||
FUserSchemes: TQuickStringlist;
|
||||
private
|
||||
FCustomSavedActions: Boolean;
|
||||
FMainActions, FSelActions: TSynEditMouseActions;
|
||||
FMainActions, FSelActions, FTextActions: TSynEditMouseActions;
|
||||
FName: String;
|
||||
FGutterActions: TSynEditMouseActions;
|
||||
FGutterActionsFold, FGutterActionsFoldExp, FGutterActionsFoldCol: TSynEditMouseActions;
|
||||
@ -735,6 +735,7 @@ type
|
||||
|
||||
property MainActions: TSynEditMouseActions read FMainActions;
|
||||
property SelActions: TSynEditMouseActions read FSelActions;
|
||||
property TextActions: TSynEditMouseActions read FTextActions;
|
||||
property GutterActions: TSynEditMouseActions read FGutterActions;
|
||||
property GutterActionsFold: TSynEditMouseActions read FGutterActionsFold;
|
||||
property GutterActionsFoldExp: TSynEditMouseActions read FGutterActionsFoldExp;
|
||||
@ -2273,6 +2274,7 @@ begin
|
||||
Reset;
|
||||
FMainActions := TSynEditMouseActions.Create(nil);
|
||||
FSelActions := TSynEditMouseActions.Create(nil);
|
||||
FTextActions := TSynEditMouseActions.Create(nil);
|
||||
FGutterActions := TSynEditMouseActions.Create(nil);
|
||||
FGutterActionsFold := TSynEditMouseActions.Create(nil);
|
||||
FGutterActionsFoldExp := TSynEditMouseActions.Create(nil);
|
||||
@ -2286,6 +2288,7 @@ begin
|
||||
ClearUserSchemes;
|
||||
FUserSchemes.Free;
|
||||
FMainActions.Free;
|
||||
FTextActions.Free;
|
||||
FSelActions.Free;
|
||||
FGutterActions.Free;
|
||||
FGutterActionsFold.Free;
|
||||
@ -2370,8 +2373,9 @@ procedure TEditorMouseOptions.ResetTextToDefault;
|
||||
begin
|
||||
FMainActions.Clear;
|
||||
FSelActions.Clear;
|
||||
FTextActions.Clear;
|
||||
|
||||
with FMainActions do begin
|
||||
with FTextActions do begin
|
||||
if FAltColumnMode then begin
|
||||
AddCommand(emcStartSelections, True, mbLeft, ccSingle, cdDown, [], [ssShift, ssAlt], emcoSelectionStart);
|
||||
AddCommand(emcStartSelections, True, mbLeft, ccSingle, cdDown, [ssShift], [ssShift, ssAlt], emcoSelectionContinue);
|
||||
@ -2415,12 +2419,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
with FMainActions do begin
|
||||
AddCommand(emcWheelScrollDown, False, mbWheelDown, ccAny, cdDown, [], []);
|
||||
AddCommand(emcWheelScrollUp, False, mbWheelUp, ccAny, cdDown, [], []);
|
||||
end;
|
||||
|
||||
if FTextDrag then
|
||||
with FSelActions do begin
|
||||
AddCommand(emcStartDragMove, False, mbLeft, ccSingle, cdDown, [], []);
|
||||
end;
|
||||
|
||||
with FMainActions do begin
|
||||
with FTextActions do begin
|
||||
AddCommand(emcSynEditCommand, False, mbExtra1, ccAny, cdDown, [], [], ecJumpBack);
|
||||
AddCommand(emcSynEditCommand, False, mbExtra2, ccAny, cdDown, [], [], ecJumpForward);
|
||||
end;
|
||||
@ -2439,6 +2448,7 @@ procedure TEditorMouseOptions.AssignActions(Src: TEditorMouseOptions);
|
||||
begin
|
||||
FMainActions.Assign (Src.MainActions);
|
||||
FSelActions.Assign (Src.SelActions);
|
||||
FTextActions.Assign (Src.TextActions);
|
||||
FGutterActions.Assign (Src.GutterActions);
|
||||
FGutterActionsFold.Assign (Src.GutterActionsFold);
|
||||
FGutterActionsFoldExp.Assign(Src.GutterActionsFoldExp);
|
||||
@ -2495,6 +2505,7 @@ begin
|
||||
Result :=
|
||||
Temp.MainActions.Equals(self.MainActions) and
|
||||
Temp.SelActions.Equals (self.SelActions) and
|
||||
Temp.TextActions.Equals (self.TextActions) and
|
||||
Temp.GutterActions.Equals (self.GutterActions) and
|
||||
Temp.GutterActionsFold.Equals (self.GutterActionsFold) and
|
||||
Temp.GutterActionsFoldCol.Equals(self.GutterActionsFoldCol) and
|
||||
@ -4065,6 +4076,7 @@ begin
|
||||
ASynEdit.MouseOptions := [emUseMouseActions];
|
||||
ASynEdit.MouseActions.Assign(FUserMouseSettings.MainActions);
|
||||
ASynEdit.MouseSelActions.Assign(FUserMouseSettings.SelActions);
|
||||
ASynEdit.MouseTextActions.Assign(FUserMouseSettings.TextActions);
|
||||
ASynEdit.Gutter.MouseActions.Assign(FUserMouseSettings.GutterActions);
|
||||
if ASynEdit.Gutter.CodeFoldPart <> nil then begin
|
||||
ASynEdit.Gutter.CodeFoldPart.MouseActions.Assign(FUserMouseSettings.GutterActionsFold);
|
||||
|
@ -40,7 +40,7 @@ inherited EditorMouseOptionsAdvFrame: TEditorMouseOptionsAdvFrame
|
||||
Align = alLeft
|
||||
AutoExpand = True
|
||||
Constraints.MinWidth = 50
|
||||
DefaultItemHeight = 17
|
||||
DefaultItemHeight = 18
|
||||
ReadOnly = True
|
||||
ShowButtons = False
|
||||
ShowRoot = False
|
||||
@ -81,24 +81,24 @@ inherited EditorMouseOptionsAdvFrame: TEditorMouseOptionsAdvFrame
|
||||
object ToolButton3: TToolButton
|
||||
Left = 122
|
||||
Top = 0
|
||||
Width = 4
|
||||
Width = 5
|
||||
Caption = 'ToolButton3'
|
||||
Style = tbsDivider
|
||||
end
|
||||
object UpdateButton: TToolButton
|
||||
Left = 126
|
||||
Left = 127
|
||||
Top = 0
|
||||
Caption = 'UpdateButton'
|
||||
OnClick = UpdateButtonClick
|
||||
end
|
||||
object AddNewButton: TToolButton
|
||||
Left = 208
|
||||
Left = 209
|
||||
Top = 0
|
||||
Caption = 'AddNewButton'
|
||||
OnClick = AddNewButtonClick
|
||||
end
|
||||
object DelButton: TToolButton
|
||||
Left = 298
|
||||
Left = 299
|
||||
Top = 0
|
||||
Caption = 'DelButton'
|
||||
OnClick = DelButtonClick
|
||||
@ -115,17 +115,17 @@ inherited EditorMouseOptionsAdvFrame: TEditorMouseOptionsAdvFrame
|
||||
TabOrder = 4
|
||||
object Panel1: TPanel
|
||||
Left = 1
|
||||
Height = 20
|
||||
Height = 21
|
||||
Top = 1
|
||||
Width = 608
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
ClientHeight = 20
|
||||
ClientHeight = 21
|
||||
ClientWidth = 608
|
||||
TabOrder = 0
|
||||
object OtherActionLabel: TLabel
|
||||
Left = 1
|
||||
Height = 18
|
||||
Height = 19
|
||||
Top = 1
|
||||
Width = 94
|
||||
Align = alLeft
|
||||
@ -152,8 +152,8 @@ inherited EditorMouseOptionsAdvFrame: TEditorMouseOptionsAdvFrame
|
||||
end
|
||||
object OtherActionGrid: TStringGrid
|
||||
Left = 1
|
||||
Height = 104
|
||||
Top = 21
|
||||
Height = 103
|
||||
Top = 22
|
||||
Width = 608
|
||||
Align = alClient
|
||||
AutoEdit = False
|
||||
|
@ -84,7 +84,8 @@ type
|
||||
FTempMouseSettings: TEditorMouseOptions;
|
||||
FKeyMap: TKeyCommandRelationList;
|
||||
|
||||
FMainNode, FSelNode: TTreeNode;
|
||||
FGlobalNode: TTreeNode;
|
||||
FTextNode, FSelNode: TTreeNode;
|
||||
FGutterNode: TTreeNode;
|
||||
FGutterFoldNode, FGutterFoldExpNode, FGutterFoldColNode: TTreeNode;
|
||||
FGutterLinesNode: TTreeNode;
|
||||
@ -574,8 +575,8 @@ begin
|
||||
FTempMouseSettings.ImportFromXml(xml, 'Lazarus/MouseSchemes/Scheme' + n+ '/');
|
||||
end;
|
||||
xml.Free;
|
||||
ContextTree.Selected := FMainNode;
|
||||
ContextTreeChange(nil, FMainNode);
|
||||
ContextTree.Selected := FTextNode;
|
||||
ContextTreeChange(nil, FTextNode);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -600,13 +601,17 @@ procedure TEditorMouseOptionsAdvFrame.Setup(ADialog: TAbstractOptionsEditorDialo
|
||||
begin
|
||||
FTempMouseSettings := EditorOpts.TempMouseSettings;
|
||||
ContextTree.Items.Clear;
|
||||
FMainNode := ContextTree.Items.Add(nil, dlgMouseOptNodeMain);
|
||||
FMainNode.Data := FTempMouseSettings.MainActions;
|
||||
FGlobalNode := ContextTree.Items.Add(nil, dlgMouseOptNodeAll);
|
||||
FGlobalNode.Data := FTempMouseSettings.MainActions;
|
||||
|
||||
// Text
|
||||
FTextNode := ContextTree.Items.AddChild(FGlobalNode, dlgMouseOptNodeMain);
|
||||
FTextNode.Data := FTempMouseSettings.TextActions;
|
||||
// Selection
|
||||
FSelNode := ContextTree.Items.AddChild(FMainNode, dlgMouseOptNodeSelect);
|
||||
FSelNode := ContextTree.Items.AddChild(FTextNode, dlgMouseOptNodeSelect);
|
||||
FSelNode.Data := FTempMouseSettings.SelActions;
|
||||
// Gutter
|
||||
FGutterNode := ContextTree.Items.AddChild(nil, dlgMouseOptNodeGutter);
|
||||
FGutterNode := ContextTree.Items.AddChild(FGlobalNode, dlgMouseOptNodeGutter);
|
||||
FGutterNode.Data := FTempMouseSettings.GutterActions;
|
||||
// Gutter Fold
|
||||
FGutterFoldNode := ContextTree.Items.AddChild(FGutterNode, dlgMouseOptNodeGutterFold);
|
||||
@ -717,8 +722,8 @@ begin
|
||||
begin
|
||||
FKeyMap := KeyMap;
|
||||
end;
|
||||
ContextTree.Selected := FMainNode;
|
||||
ContextTreeChange(ContextTree, FMainNode);
|
||||
ContextTree.Selected := FGlobalNode;
|
||||
ContextTreeChange(ContextTree, FGlobalNode);
|
||||
end;
|
||||
|
||||
procedure TEditorMouseOptionsAdvFrame.WriteSettings(
|
||||
@ -729,9 +734,9 @@ end;
|
||||
|
||||
procedure TEditorMouseOptionsAdvFrame.RefreshSettings;
|
||||
begin
|
||||
if (FMainNode = nil) or (FKeyMap = nil) then exit;
|
||||
ContextTree.Selected := FMainNode;
|
||||
ContextTreeChange(ContextTree, FMainNode);
|
||||
if (FGlobalNode = nil) or (FKeyMap = nil) then exit;
|
||||
ContextTree.Selected := FGlobalNode;
|
||||
ContextTreeChange(ContextTree, FGlobalNode);
|
||||
end;
|
||||
|
||||
class function TEditorMouseOptionsAdvFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
|
||||
|
@ -1338,6 +1338,7 @@ resourcestring
|
||||
|
||||
dlgMouseOptions = 'Mouse';
|
||||
dlgMouseOptionsAdv = 'Advanced';
|
||||
dlgMouseOptNodeAll = 'All';
|
||||
dlgMouseOptNodeMain = 'Text';
|
||||
dlgMouseOptNodeSelect = 'Selection';
|
||||
dlgMouseOptNodeGutter = 'Gutter';
|
||||
@ -1362,6 +1363,8 @@ resourcestring
|
||||
dlgMouseOptBtnRight = 'Right';
|
||||
dlgMouseOptBtnExtra1 = 'Extra 1';
|
||||
dlgMouseOptBtnExtra2 = 'Extra 2';
|
||||
dlgMouseOptBtnWheelUp = 'Wheel up';
|
||||
dlgMouseOptBtnWheelDown = 'Wheel down';
|
||||
dlgMouseOptBtnDown = 'Down';
|
||||
dlgMouseOptBtnUp = 'Up';
|
||||
dlgMouseOptBtn1 = 'Single';
|
||||
|
@ -11,7 +11,7 @@ object MouseaActionDialog: TMouseaActionDialog
|
||||
ClientWidth = 362
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '0.9.31'
|
||||
object BtnLabel: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = ButtonBox
|
||||
@ -190,6 +190,7 @@ object MouseaActionDialog: TMouseaActionDialog
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 12
|
||||
ItemHeight = 15
|
||||
OnChange = ButtonBoxChange
|
||||
Style = csDropDownList
|
||||
TabOrder = 3
|
||||
end
|
||||
@ -232,6 +233,14 @@ object MouseaActionDialog: TMouseaActionDialog
|
||||
Top = 225
|
||||
Width = 350
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 10
|
||||
ShowButtons = [pbOK, pbCancel]
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ uses
|
||||
SynEditMouseCmds, LazarusIDEStrConsts, KeyMapping, IDECommands;
|
||||
|
||||
var
|
||||
ButtonName: Array [TMouseButton] of String;
|
||||
ButtonName: Array [TSynMouseButton] of String;
|
||||
ClickName: Array [TSynMAClickCount] of String;
|
||||
ButtonDirName: Array [TSynMAClickDir] of String;
|
||||
|
||||
@ -37,6 +37,7 @@ type
|
||||
PriorSpin: TSpinEdit;
|
||||
procedure ActionBoxChange(Sender: TObject);
|
||||
procedure BtnDefaultClick(Sender: TObject);
|
||||
procedure ButtonBoxChange(Sender: TObject);
|
||||
procedure CapturePanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
@ -57,9 +58,9 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
const
|
||||
BtnToIndex: array [mbLeft..mbExtra2] of Integer = (0, 1, 2, 3, 4);
|
||||
BtnToIndex: array [TSynMouseButton] of Integer = (0, 1, 2, 3, 4, 5, 6);
|
||||
ClickToIndex: array [ccSingle..ccAny] of Integer = (0, 1, 2, 3, 4);
|
||||
IndexToBtn: array [0..4] of TMouseButton = (mbLeft, mbRight, mbMiddle, mbExtra1, mbExtra2);
|
||||
IndexToBtn: array [0..6] of TSynMouseButton = (mbLeft, mbRight, mbMiddle, mbExtra1, mbExtra2, mbWheelUp, mbWheelDown);
|
||||
IndexToClick: array [0..4] of TSynMAClickCount = (ccSingle, ccDouble, ccTriple, ccQuad, ccAny);
|
||||
|
||||
function KeyMapIndexOfCommand(AKeyMap: TKeyCommandRelationList; ACmd: Word): Integer;
|
||||
@ -78,7 +79,7 @@ procedure TMouseaActionDialog.FormCreate(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
CName: String;
|
||||
mb: TMouseButton;
|
||||
mb: TSynMouseButton;
|
||||
cc: TSynMAClickCount;
|
||||
begin
|
||||
ButtonName[mbLeft]:=dlgMouseOptBtnLeft;
|
||||
@ -86,6 +87,8 @@ begin
|
||||
ButtonName[mbMiddle]:=dlgMouseOptBtnMiddle;
|
||||
ButtonName[mbExtra1]:=dlgMouseOptBtnExtra1;
|
||||
ButtonName[mbExtra2]:=dlgMouseOptBtnExtra2;
|
||||
ButtonName[mbWheelUp]:=dlgMouseOptBtnWheelUp;
|
||||
ButtonName[mbWheelDown]:=dlgMouseOptBtnWheelDown;
|
||||
|
||||
ClickName[ccSingle]:=dlgMouseOptBtn1;
|
||||
ClickName[ccDouble]:=dlgMouseOptBtn2;
|
||||
@ -107,7 +110,7 @@ begin
|
||||
ActionBox.Items.AddObject(CName, TObject(ptrint(i)));
|
||||
end;
|
||||
ButtonBox.Clear;
|
||||
for mb := low(TMouseButton) to high(TMouseButton) do
|
||||
for mb := low(TSynMouseButton) to high(TSynMouseButton) do
|
||||
ButtonBox.Items.add(ButtonName[mb]);
|
||||
ClickBox.Clear;
|
||||
for cc:= low(TSynMAClickCount) to high(TSynMAClickCount) do
|
||||
@ -143,6 +146,11 @@ begin
|
||||
CtrlCheck.State := cbGrayed;
|
||||
end;
|
||||
|
||||
procedure TMouseaActionDialog.ButtonBoxChange(Sender: TObject);
|
||||
begin
|
||||
DirCheck.Enabled := not(IndexToBtn[ButtonBox.ItemIndex] in [mbWheelUp, mbWheelDown]);
|
||||
end;
|
||||
|
||||
procedure TMouseaActionDialog.ActionBoxChange(Sender: TObject);
|
||||
var
|
||||
ACmd: TSynEditorMouseCommand;
|
||||
@ -180,7 +188,7 @@ end;
|
||||
procedure TMouseaActionDialog.CapturePanelMouseDown(Sender: TObject;
|
||||
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
ButtonBox.ItemIndex := BtnToIndex[Button];
|
||||
ButtonBox.ItemIndex := BtnToIndex[SynMouseButtonMap[Button]];
|
||||
ClickBox.ItemIndex := 0;
|
||||
if ssDouble in Shift then ClickBox.ItemIndex := 1;
|
||||
if ssTriple in Shift then ClickBox.ItemIndex := 2;
|
||||
@ -206,6 +214,7 @@ begin
|
||||
PriorSpin.Value := MAct.Priority;
|
||||
|
||||
ActionBoxChange(nil);
|
||||
ButtonBoxChange(nil);
|
||||
if OptBox.Enabled then begin
|
||||
if MAct.Command = emcSynEditCommand then
|
||||
OptBox.ItemIndex := OptBox.Items.IndexOfObject(TObject(Pointer(PtrUInt(MAct.Option))))
|
||||
|
Loading…
Reference in New Issue
Block a user