/components/synedit/syneditmousecmds.pp

http://github.com/graemeg/lazarus · Puppet · 1101 lines · 976 code · 125 blank · 0 comment · 83 complexity · 124b89d15b41c580c057cc6c9a35f3d4 MD5 · raw file

  1. { Mouse Command Configuration for SynEdit
  2. Copyright (C) 2009 Martn Friebe
  3. The contents of this file are subject to the Mozilla Public License
  4. Version 1.1 (the "License"); you may not use this file except in compliance
  5. with the License. You may obtain a copy of the License at
  6. http://www.mozilla.org/MPL/
  7. Software distributed under the License is distributed on an "AS IS" basis,
  8. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  9. the specific language governing rights and limitations under the License.
  10. Alternatively, the contents of this file may be used under the terms of the
  11. GNU General Public License Version 2 or later (the "GPL"), in which case
  12. the provisions of the GPL are applicable instead of those above.
  13. If you wish to allow use of your version of this file only under the terms
  14. of the GPL and not to allow others to use your version of this file
  15. under the MPL, indicate your decision by deleting the provisions above and
  16. replace them with the notice and other provisions required by the GPL.
  17. If you do not delete the provisions above, a recipient may use your version
  18. of this file under either the MPL or the GPL.
  19. A copy of the GNU General Public License is available on the World Wide Web
  20. at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
  21. to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  22. MA 02111-1307, USA.
  23. }
  24. unit SynEditMouseCmds;
  25. {$I synedit.inc}
  26. interface
  27. uses
  28. LazSynEditMouseCmdsTypes, Classes, Controls, SysUtils, SynEditStrConst, SynEditPointClasses,
  29. SynEditKeyCmds, Dialogs, LCLProc, Menus;
  30. type
  31. TSynEditorMouseOption = (
  32. emUseMouseActions, // Enable mouse actions
  33. emAltSetsColumnMode, // Allows to activate "column" selection mode, if <Alt> key is pressed and text is being selected with mouse
  34. emDragDropEditing, // Allows to drag-and-drop text blocks within the control
  35. emRightMouseMovesCursor, // When clicking with the right mouse button, for a popup menu, move the caret to clicked position
  36. emDoubleClickSelectsLine, // Selects entire line with double-click, otherwise double-click selects only current word
  37. emShowCtrlMouseLinks, // Pressing <Ctrl> key (SYNEDIT_LINK_MODIFIER) will highlight the word under mouse cursor
  38. emCtrlWheelZoom // Allows to zoom editor by <Ctrl+MouseWheel> commands
  39. );
  40. TSynEditorMouseOptions = set of TSynEditorMouseOption;
  41. TSynEditorMouseCommand = type word;
  42. TSynEditorMouseCommandOpt = type word;
  43. TSynMouseButton = LazSynEditMouseCmdsTypes.TSynMouseButton;
  44. TSynMAClickCount = (ccSingle, ccDouble, ccTriple, ccQuad, ccAny);
  45. TSynMAClickDir = (cdUp, cdDown);
  46. TSynMAUpRestriction = ( // Restrict cdUp
  47. crLastDownPos, // check if the lasth MouseDown had same Pos (as in would have triggered the same command)
  48. crLastDownPosSameLine, // check if the last dow
  49. crLastDownPosSearchAll, // allow to find downclick at lower priority or parent list
  50. crLastDownButton, crLastDownShift, // check if the lasth MouseDown had same Button / Shift
  51. crAllowFallback // If action is restricted, continue search for up action in (fallback, or parent list)
  52. );
  53. TSynMAUpRestrictions = set of TSynMAUpRestriction;
  54. ESynMouseCmdError = class(Exception);
  55. const
  56. crRestrictAll = [crLastDownPos, crLastDownPosSameLine, crLastDownButton, crLastDownShift];
  57. mbXLeft = LazSynEditMouseCmdsTypes.mbLeft;
  58. mbXRight = LazSynEditMouseCmdsTypes.mbRight;
  59. mbXMiddle = LazSynEditMouseCmdsTypes.mbMiddle;
  60. mbXExtra1 = LazSynEditMouseCmdsTypes.mbExtra1;
  61. mbXExtra2 = LazSynEditMouseCmdsTypes.mbExtra2;
  62. mbXWheelUp = LazSynEditMouseCmdsTypes.mbWheelUp;
  63. mbXWheelDown = LazSynEditMouseCmdsTypes.mbWheelDown;
  64. SynMouseButtonMap: Array [TMouseButton] of TSynMouseButton =
  65. (mbXLeft, mbXRight, mbXMiddle, mbXExtra1, mbXExtra2);
  66. SynMouseButtonBackMap: Array [TSynMouseButton] of TMouseButton =
  67. (Controls.mbLeft, Controls.mbRight, Controls.mbMiddle,
  68. Controls.mbExtra1, Controls.mbExtra2,
  69. Controls.mbLeft, Controls.mbLeft);
  70. type
  71. // Mouse actions to be handled *after* paintlock
  72. TSynEditMouseActionResult = record
  73. DoPopUpEvent: Boolean; // Trigger OnContextPopUp, only valid if PopUpMenu is set
  74. PopUpEventX, PopUpEventY: Integer;
  75. PopUpMenu: TPopupMenu; // PopupMenu to Display (must be outside PaintLock)
  76. end;
  77. TSynEditMouseActionInfo = record
  78. NewCaret: TSynEditCaret;
  79. Button: TSynMouseButton;
  80. Shift: TShiftState;
  81. MouseX, MouseY, WheelDelta: Integer;
  82. CCount: TSynMAClickCount;
  83. Dir: TSynMAClickDir;
  84. CaretDone: Boolean; // Return Value
  85. IgnoreUpClick: Boolean;
  86. ActionResult: TSynEditMouseActionResult;
  87. end;
  88. { TSynEditMouseAction }
  89. TSynEditMouseAction = class(TCollectionItem)
  90. private
  91. FButtonUpRestrictions: TSynMAUpRestrictions;
  92. FClickDir: TSynMAClickDir;
  93. FIgnoreUpClick: Boolean;
  94. FOption: TSynEditorMouseCommandOpt;
  95. FOption2: Integer;
  96. FPriority: TSynEditorMouseCommandOpt;
  97. FShift, FShiftMask: TShiftState;
  98. FButton: TSynMouseButton;
  99. FClickCount: TSynMAClickCount;
  100. FCommand: TSynEditorMouseCommand;
  101. FMoveCaret: Boolean;
  102. procedure SetButton(const AValue: TSynMouseButton);
  103. procedure SetButtonUpRestrictions(AValue: TSynMAUpRestrictions);
  104. procedure SetClickCount(const AValue: TSynMAClickCount);
  105. procedure SetClickDir(AValue: TSynMAClickDir);
  106. procedure SetCommand(const AValue: TSynEditorMouseCommand);
  107. procedure SetIgnoreUpClick(AValue: Boolean);
  108. procedure SetMoveCaret(const AValue: Boolean);
  109. procedure SetOption(const AValue: TSynEditorMouseCommandOpt);
  110. procedure SetOption2(AValue: Integer);
  111. procedure SetPriority(const AValue: TSynEditorMouseCommandOpt);
  112. procedure SetShift(const AValue: TShiftState);
  113. procedure SetShiftMask(const AValue: TShiftState);
  114. protected
  115. function GetDisplayName: string; override;
  116. public
  117. procedure Assign(Source: TPersistent); override;
  118. procedure Clear;
  119. function IsMatchingShiftState(AShift: TShiftState): Boolean;
  120. function IsMatchingClick(ABtn: TSynMouseButton; ACCount: TSynMAClickCount;
  121. ACDir: TSynMAClickDir): Boolean;
  122. function IsFallback: Boolean;
  123. function Conflicts(Other: TSynEditMouseAction): Boolean;
  124. function Equals(Other: TSynEditMouseAction; IgnoreCmd: Boolean = False): Boolean; reintroduce;
  125. published
  126. property Shift: TShiftState read FShift write SetShift default [];
  127. property ShiftMask: TShiftState read FShiftMask write SetShiftMask default [];
  128. property Button: TSynMouseButton read FButton write SetButton default mbXLeft;
  129. property ClickCount: TSynMAClickCount read FClickCount write SetClickCount default ccSingle;
  130. property ClickDir: TSynMAClickDir read FClickDir write SetClickDir default cdUp;
  131. property ButtonUpRestrictions: TSynMAUpRestrictions
  132. read FButtonUpRestrictions write SetButtonUpRestrictions default [];
  133. property Command: TSynEditorMouseCommand read FCommand write SetCommand;
  134. property MoveCaret: Boolean read FMoveCaret write SetMoveCaret default False;
  135. property IgnoreUpClick: Boolean read FIgnoreUpClick write SetIgnoreUpClick default False; // only for mouse down
  136. property Option: TSynEditorMouseCommandOpt read FOption write SetOption default 0;
  137. property Option2: Integer read FOption2 write SetOption2 default 0;
  138. // Priority: 0 = highest / MaxInt = lowest
  139. property Priority: TSynEditorMouseCommandOpt read FPriority write SetPriority default 0;
  140. end;
  141. { TSynEditMouseActions }
  142. TSynEditMouseActions = class(TCollection)
  143. private
  144. FOwner: TPersistent;
  145. FAssertLock: Integer;
  146. function GetItem(Index: Integer): TSynEditMouseAction;
  147. procedure SetItem(Index: Integer; const AValue: TSynEditMouseAction);
  148. protected
  149. function GetOwner: TPersistent; override;
  150. procedure Update(Item: TCollectionItem); override;
  151. public
  152. constructor Create(AOwner: TPersistent);
  153. function Add: TSynEditMouseAction;
  154. procedure Assign(Source: TPersistent); override;
  155. procedure AssertNoConflict(MAction: TSynEditMouseAction);
  156. function Equals(Other: TSynEditMouseActions): Boolean; reintroduce;
  157. function FindCommand(AnInfo: TSynEditMouseActionInfo;
  158. APrevious: TSynEditMouseAction = nil): TSynEditMouseAction;
  159. procedure ResetDefaults; virtual;
  160. procedure IncAssertLock;
  161. procedure DecAssertLock;
  162. function IndexOf(MAction: TSynEditMouseAction;
  163. IgnoreCmd: Boolean = False): Integer;
  164. procedure AddCommand(const ACmd: TSynEditorMouseCommand;
  165. const AMoveCaret: Boolean;
  166. const AButton: TSynMouseButton; const AClickCount: TSynMAClickCount;
  167. const ADir: TSynMAClickDir; const AShift, AShiftMask: TShiftState;
  168. const AOpt: TSynEditorMouseCommandOpt = 0;
  169. const APrior: Integer = 0;
  170. const AOpt2: integer = 0;
  171. const AIgnoreUpClick: Boolean = False); overload;
  172. procedure AddCommand(const ACmd: TSynEditorMouseCommand;
  173. const AMoveCaret: Boolean;
  174. const AButton: TSynMouseButton; const AClickCount: TSynMAClickCount;
  175. const ADir: TSynMAClickDir; const AnUpRestrict: TSynMAUpRestrictions;
  176. const AShift, AShiftMask: TShiftState;
  177. const AOpt: TSynEditorMouseCommandOpt = 0;
  178. const APrior: Integer = 0;
  179. const AOpt2: integer = 0;
  180. const AIgnoreUpClick: Boolean = False); overload;
  181. public
  182. property Items[Index: Integer]: TSynEditMouseAction read GetItem
  183. write SetItem; default;
  184. end;
  185. { TSynEditMouseInternalActions }
  186. TSynEditMouseInternalActions = class(TSynEditMouseActions)
  187. private
  188. FOptions, FInternOptions: TSynEditorMouseOptions;
  189. FUserActions: TSynEditMouseActions;
  190. procedure SetOptions(AValue: TSynEditorMouseOptions);
  191. procedure SetUserActions(AValue: TSynEditMouseActions);
  192. protected
  193. procedure InitForOptions(AnOptions: TSynEditorMouseOptions); virtual;
  194. public
  195. constructor Create(AOwner: TPersistent);
  196. destructor Destroy; override;
  197. procedure ResetDefaults; override;
  198. procedure ResetUserActions;
  199. function GetActionsForOptions(AnOptions: TSynEditorMouseOptions): TSynEditMouseActions;
  200. property Options: TSynEditorMouseOptions read FOptions write SetOptions;
  201. property UserActions: TSynEditMouseActions read FUserActions write SetUserActions;
  202. end;
  203. TSynEditMouseActionHandler = function(AnActionList: TSynEditMouseActions;
  204. var AnInfo: TSynEditMouseActionInfo): Boolean of object;
  205. // Called by SynEdit
  206. // Should Call "HandleActionProc" for each ActionList it want's to check
  207. TSynEditMouseActionSearchProc = function(var AnInfo: TSynEditMouseActionInfo;
  208. HandleActionProc: TSynEditMouseActionHandler): Boolean of object;
  209. // Called by "HandleActionProc", if an Action was found in the list
  210. TSynEditMouseActionExecProc = function(AnAction: TSynEditMouseAction;
  211. var AnInfo: TSynEditMouseActionInfo): Boolean of object;
  212. { TSynEditMouseActionSearchList }
  213. TSynEditMouseActionSearchList = Class(TMethodList)
  214. public
  215. function CallSearchHandlers(var AnInfo: TSynEditMouseActionInfo;
  216. HandleActionProc: TSynEditMouseActionHandler): Boolean;
  217. end;
  218. { TSynEditMouseActionExecList }
  219. TSynEditMouseActionExecList = Class(TMethodList)
  220. public
  221. function CallExecHandlers(AnAction: TSynEditMouseAction;
  222. var AnInfo: TSynEditMouseActionInfo): Boolean;
  223. end;
  224. const
  225. // EditorMouseCommands
  226. emcNone = TSynEditorMouseCommand(0);
  227. emcStartSelections = TSynEditorMouseCommand(1); // Start BlockSelection (Default Left Mouse Btn)
  228. emcStartColumnSelections = TSynEditorMouseCommand(3); // Column BlockSelection (Default Alt - Left Mouse Btn)
  229. emcStartLineSelections = TSynEditorMouseCommand(4); // Line BlockSelection (Default Alt - Left Mouse Btn)
  230. emcStartLineSelectionsNoneEmpty = TSynEditorMouseCommand(5); // Line BlockSelection (Default Alt - Left Mouse Btn)
  231. emcSelectWord = TSynEditorMouseCommand(6);
  232. emcSelectLine = TSynEditorMouseCommand(7);
  233. emcSelectPara = TSynEditorMouseCommand(8);
  234. emcStartDragMove = TSynEditorMouseCommand(9);
  235. emcPasteSelection = TSynEditorMouseCommand(10);
  236. emcMouseLink = TSynEditorMouseCommand(11);
  237. emcContextMenu = TSynEditorMouseCommand(12);
  238. emcOnMainGutterClick = TSynEditorMouseCommand(13); // OnGutterClick
  239. emcCodeFoldCollaps = TSynEditorMouseCommand(14);
  240. emcCodeFoldExpand = TSynEditorMouseCommand(15);
  241. emcCodeFoldContextMenu = TSynEditorMouseCommand(16);
  242. emcSynEditCommand = TSynEditorMouseCommand(17); // Key-Commands
  243. emcWheelScrollDown = TSynEditorMouseCommand(18);
  244. emcWheelScrollUp = TSynEditorMouseCommand(19);
  245. emcWheelVertScrollDown = TSynEditorMouseCommand(20);
  246. emcWheelVertScrollUp = TSynEditorMouseCommand(21);
  247. emcWheelHorizScrollDown = TSynEditorMouseCommand(22);
  248. emcWheelHorizScrollUp = TSynEditorMouseCommand(23);
  249. emcWheelZoomOut = TSynEditorMouseCommand(24);
  250. emcWheelZoomIn = TSynEditorMouseCommand(25);
  251. emcWheelZoomNorm = TSynEditorMouseCommand(26);
  252. emcStartSelectTokens = TSynEditorMouseCommand(27); // Start BlockSelection, word/token wise
  253. emcStartSelectWords = TSynEditorMouseCommand(28); // Start BlockSelection, wordwise
  254. emcStartSelectLines = TSynEditorMouseCommand(29); // Start BlockSelection, linewise (but not line mode)
  255. emcOverViewGutterGotoMark = TSynEditorMouseCommand(30);
  256. emcOverViewGutterScrollTo = TSynEditorMouseCommand(31);
  257. emcMax = 31;
  258. emcPluginFirstSyncro = 19000;
  259. emcPluginFirstMultiCaret = 19010;
  260. emcPluginFirst = 20000;
  261. // Options
  262. emcoSelectionStart = TSynEditorMouseCommandOpt(0);
  263. emcoSelectionContinue = TSynEditorMouseCommandOpt(1);
  264. emcoSelectLineSmart = TSynEditorMouseCommandOpt(0);
  265. emcoSelectLineFull = TSynEditorMouseCommandOpt(1);
  266. emcoMouseLinkShow = TSynEditorMouseCommandOpt(0);
  267. emcoMouseLinkHide = TSynEditorMouseCommandOpt(1);
  268. emcoNotDragedSetCaretOnUp = TSynEditorMouseCommandOpt(0);
  269. emcoNotDragedNoCaretOnUp = TSynEditorMouseCommandOpt(1);
  270. emcoCodeFoldCollapsOne = TSynEditorMouseCommandOpt(0);
  271. emcoCodeFoldCollapsAll = TSynEditorMouseCommandOpt(1);
  272. emcoCodeFoldCollapsAtCaret = TSynEditorMouseCommandOpt(2);
  273. emcoCodeFoldCollapsPreCaret = TSynEditorMouseCommandOpt(3);
  274. emcoCodeFoldExpandOne = TSynEditorMouseCommandOpt(0);
  275. emcoCodeFoldExpandAll = TSynEditorMouseCommandOpt(1);
  276. // menu, and caret move
  277. emcoSelectionCaretMoveNever = TSynEditorMouseCommandOpt(0);
  278. emcoSelectionCaretMoveOutside = TSynEditorMouseCommandOpt(1); // click is outside selected area
  279. emcoSelectionCaretMoveAlways = TSynEditorMouseCommandOpt(2);
  280. emcoWheelScrollSystem = TSynEditorMouseCommandOpt(0); // Opt2 > 0 ==> percentage
  281. emcoWheelScrollLines = TSynEditorMouseCommandOpt(1); // Opt2 > 0 ==> amount of lines
  282. emcoWheelScrollPages = TSynEditorMouseCommandOpt(2); // Opt2 > 0 ==> percentage
  283. emcoWheelScrollPagesLessOne = TSynEditorMouseCommandOpt(3); // Opt2 > 0 ==> percentage
  284. type
  285. TMouseCmdNameAndOptProcs = function(emc: TSynEditorMouseCommand): String;
  286. // Plugins don't know of other plugins, so they need to map the codes
  287. // Plugins all start at ecPluginFirst (overlapping)
  288. // If ask by SynEdit they add an offset
  289. // Return the next offset
  290. function AllocatePluginMouseRange(Count: Integer; OffsetOnly: Boolean = False): integer;
  291. function MouseCommandName(emc: TSynEditorMouseCommand): String;
  292. function MouseCommandConfigName(emc: TSynEditorMouseCommand): String;
  293. function SynMouseCmdToIdent(SynMouseCmd: Longint; var Ident: String): Boolean;
  294. function IdentToSynMouseCmd(const Ident: string; var SynMouseCmd: Longint): Boolean;
  295. procedure GetEditorMouseCommandValues(Proc: TGetStrProc);
  296. procedure RegisterMouseCmdIdentProcs(IdentToIntFn: TIdentToInt; IntToIdentFn: TIntToIdent);
  297. procedure RegisterExtraGetEditorMouseCommandValues(AProc: TGetEditorCommandValuesProc);
  298. procedure RegisterMouseCmdNameAndOptProcs(ANamesProc: TMouseCmdNameAndOptProcs; AOptProc: TMouseCmdNameAndOptProcs = nil);
  299. const
  300. SYNEDIT_LINK_MODIFIER = {$IFDEF LCLcarbon}ssMeta{$ELSE}ssCtrl{$ENDIF};
  301. implementation
  302. const
  303. SynMouseCommandNames: array [0..30] of TIdentMapEntry = (
  304. (Value: emcNone; Name: 'emcNone'),
  305. (Value: emcStartSelections; Name: 'emcStartSelections'),
  306. (Value: emcStartColumnSelections; Name: 'emcStartColumnSelections'),
  307. (Value: emcStartLineSelections; Name: 'emcStartLineSelections'),
  308. (Value: emcStartLineSelectionsNoneEmpty; Name: 'emcStartLineSelectionsNoneEmpty'),
  309. (Value: emcSelectWord; Name: 'emcSelectWord'),
  310. (Value: emcSelectLine; Name: 'emcSelectLine'),
  311. (Value: emcSelectPara; Name: 'emcSelectPara'),
  312. (Value: emcStartDragMove; Name: 'emcStartDragMove'),
  313. (Value: emcPasteSelection; Name: 'emcPasteSelection'),
  314. (Value: emcMouseLink; Name: 'emcMouseLink'),
  315. (Value: emcContextMenu; Name: 'emcContextMenu'),
  316. (Value: emcOnMainGutterClick; Name: 'emcOnMainGutterClick'),
  317. (Value: emcCodeFoldCollaps; Name: 'emcCodeFoldCollaps'),
  318. (Value: emcCodeFoldExpand; Name: 'emcCodeFoldExpand'),
  319. (Value: emcCodeFoldContextMenu; Name: 'emcCodeFoldContextMenu'),
  320. (Value: emcSynEditCommand; Name: 'emcSynEditCommand'),
  321. (Value: emcWheelScrollDown; Name: 'emcWheelScrollDown'),
  322. (Value: emcWheelScrollUp; Name: 'emcWheelScrollUp'),
  323. (Value: emcWheelVertScrollDown; Name: 'emcWheelVertScrollDown'),
  324. (Value: emcWheelVertScrollUp; Name: 'emcWheelVertScrollUp'),
  325. (Value: emcWheelHorizScrollDown; Name: 'emcWheelHorizScrollDown'),
  326. (Value: emcWheelHorizScrollUp; Name: 'emcWheelHorizScrollUp'),
  327. (Value: emcWheelZoomOut; Name: 'emcWheelZoomOut'),
  328. (Value: emcWheelZoomIn; Name: 'emcWheelZoomIn'),
  329. (Value: emcWheelZoomNorm; Name: 'emcWheelZoomNorm'),
  330. (Value: emcStartSelectTokens; Name: 'emcStartSelectTokens'),
  331. (Value: emcStartSelectWords; Name: 'emcStartSelectWords'),
  332. (Value: emcStartSelectLines; Name: 'emcStartSelectLines'),
  333. (Value: emcOverViewGutterGotoMark;Name: 'emcOverViewGutterGotoMark'),
  334. (Value: emcOverViewGutterScrollTo;Name: 'emcOverViewGutterScrollTo')
  335. );
  336. var
  337. ExtraIdentToIntFn: Array of TIdentToInt = nil;
  338. ExtraIntToIdentFn: Array of TIntToIdent = nil;
  339. ExtraGetEditorCommandValues: Array of TGetEditorCommandValuesProc = nil;
  340. ExtraMouseCmdNameFn: Array of TMouseCmdNameAndOptProcs = nil;
  341. ExtraMouseCmdOptFn: Array of TMouseCmdNameAndOptProcs = nil;
  342. function AllocatePluginMouseRange(Count: Integer; OffsetOnly: Boolean = False): integer;
  343. const
  344. CurOffset : integer = 0;
  345. begin
  346. Result := CurOffset;
  347. inc(CurOffset, Count);
  348. if not OffsetOnly then
  349. inc(Result, emcPluginFirst);
  350. end;
  351. function MouseCommandName(emc: TSynEditorMouseCommand): String;
  352. var
  353. i: Integer;
  354. begin
  355. case emc of
  356. emcNone: Result := SYNS_emcNone;
  357. emcStartSelections: Result := SYNS_emcStartSelection;
  358. emcStartColumnSelections: Result := SYNS_emcStartColumnSelections;
  359. emcStartLineSelections: Result := SYNS_emcStartLineSelections;
  360. emcStartLineSelectionsNoneEmpty: Result := SYNS_emcStartLineSelectionsNoneEmpty;
  361. emcSelectWord: Result := SYNS_emcSelectWord;
  362. emcSelectLine: Result := SYNS_emcSelectLine;
  363. emcSelectPara: Result := SYNS_emcSelectPara;
  364. emcStartDragMove: Result := SYNS_emcStartDragMove;
  365. emcPasteSelection: Result := SYNS_emcPasteSelection;
  366. emcMouseLink: Result := SYNS_emcMouseLink;
  367. emcContextMenu: Result := SYNS_emcContextMenu;
  368. emcOnMainGutterClick: Result := SYNS_emcBreakPointToggle;
  369. emcCodeFoldCollaps: Result := SYNS_emcCodeFoldCollaps;
  370. emcCodeFoldExpand: Result := SYNS_emcCodeFoldExpand;
  371. emcCodeFoldContextMenu: Result := SYNS_emcCodeFoldContextMenu;
  372. emcSynEditCommand: Result := SYNS_emcSynEditCommand;
  373. emcWheelScrollDown: Result := SYNS_emcWheelScrollDown;
  374. emcWheelScrollUp: Result := SYNS_emcWheelScrollUp;
  375. emcWheelHorizScrollDown: Result := SYNS_emcWheelHorizScrollDown;
  376. emcWheelHorizScrollUp: Result := SYNS_emcWheelHorizScrollUp;
  377. emcWheelVertScrollDown: Result := SYNS_emcWheelVertScrollDown;
  378. emcWheelVertScrollUp: Result := SYNS_emcWheelVertScrollUp;
  379. emcWheelZoomOut: Result := SYNS_emcWheelZoomOut;
  380. emcWheelZoomIn: Result := SYNS_emcWheelZoomIn;
  381. emcWheelZoomNorm: Result := SYNS_emcWheelZoomNorm;
  382. emcStartSelectTokens: Result := SYNS_emcStartSelectTokens;
  383. emcStartSelectWords: Result := SYNS_emcStartSelectWords;
  384. emcStartSelectLines: Result := SYNS_emcStartSelectLines;
  385. emcOverViewGutterGotoMark: Result := SYNS_emcOverViewGutterGotoMark;
  386. emcOverViewGutterScrollTo: Result := SYNS_emcOverViewGutterScrollTo;
  387. else begin
  388. Result := '';
  389. i := 0;
  390. while (i < length(ExtraMouseCmdNameFn)) and (Result = '') do begin
  391. Result := ExtraMouseCmdNameFn[i](emc);
  392. inc(i);
  393. end;
  394. end;
  395. end;
  396. end;
  397. function MouseCommandConfigName(emc: TSynEditorMouseCommand): String;
  398. var
  399. i: Integer;
  400. begin
  401. case emc of
  402. emcStartSelections,
  403. emcStartColumnSelections,
  404. emcStartLineSelections,
  405. emcStartLineSelectionsNoneEmpty: Result := SYNS_emcSelection_opt;
  406. emcSelectLine: Result := SYNS_emcSelectLine_opt;
  407. emcMouseLink: Result := SYNS_emcMouseLink_opt;
  408. emcStartDragMove: Result := SYNS_emcStartDragMove_opt;
  409. emcCodeFoldCollaps: Result := SYNS_emcCodeFoldCollaps_opt;
  410. emcCodeFoldExpand: Result := SYNS_emcCodeFoldExpand_opt;
  411. emcContextMenu: Result := SYNS_emcContextMenuCaretMove_opt;
  412. emcWheelScrollDown..emcWheelVertScrollUp:
  413. Result := SYNS_emcWheelScroll_opt;
  414. else begin
  415. Result := '';
  416. i := 0;
  417. while (i < length(ExtraMouseCmdOptFn)) and (Result = '') do begin
  418. Result := ExtraMouseCmdOptFn[i](emc);
  419. inc(i);
  420. end;
  421. end;
  422. end;
  423. end;
  424. function SynMouseCmdToIdent(SynMouseCmd: Longint; var Ident: String): Boolean;
  425. var
  426. i: Integer;
  427. begin
  428. Ident := '';
  429. Result := IntToIdent(SynMouseCmd, Ident, SynMouseCommandNames);
  430. i := 0;
  431. while (i < length(ExtraIntToIdentFn)) and (not Result) do begin
  432. Result := ExtraIntToIdentFn[i](SynMouseCmd, Ident);
  433. inc(i);
  434. end;
  435. end;
  436. function IdentToSynMouseCmd(const Ident: string; var SynMouseCmd: Longint): Boolean;
  437. var
  438. i: Integer;
  439. begin
  440. SynMouseCmd := 0;
  441. Result := IdentToInt(Ident, SynMouseCmd, SynMouseCommandNames);
  442. i := 0;
  443. while (i < length(ExtraIdentToIntFn)) and (not Result) do begin
  444. Result := ExtraIdentToIntFn[i](Ident, SynMouseCmd);
  445. inc(i);
  446. end;
  447. end;
  448. procedure GetEditorMouseCommandValues(Proc: TGetStrProc);
  449. var
  450. i: Integer;
  451. begin
  452. for i := Low(SynMouseCommandNames) to High(SynMouseCommandNames) do
  453. Proc(SynMouseCommandNames[I].Name);
  454. i := 0;
  455. while (i < length(ExtraGetEditorCommandValues)) do begin
  456. ExtraGetEditorCommandValues[i](Proc);
  457. inc(i);
  458. end;
  459. end;
  460. procedure RegisterMouseCmdIdentProcs(IdentToIntFn: TIdentToInt; IntToIdentFn: TIntToIdent);
  461. var
  462. i: Integer;
  463. begin
  464. i := length(ExtraIdentToIntFn);
  465. SetLength(ExtraIdentToIntFn, i + 1);
  466. ExtraIdentToIntFn[i] := IdentToIntFn;
  467. i := length(ExtraIntToIdentFn);
  468. SetLength(ExtraIntToIdentFn, i + 1);
  469. ExtraIntToIdentFn[i] := IntToIdentFn;
  470. end;
  471. procedure RegisterExtraGetEditorMouseCommandValues(AProc: TGetEditorCommandValuesProc);
  472. var
  473. i: Integer;
  474. begin
  475. i := length(ExtraGetEditorCommandValues);
  476. SetLength(ExtraGetEditorCommandValues, i + 1);
  477. ExtraGetEditorCommandValues[i] := AProc;
  478. end;
  479. procedure RegisterMouseCmdNameAndOptProcs(ANamesProc: TMouseCmdNameAndOptProcs;
  480. AOptProc: TMouseCmdNameAndOptProcs);
  481. var
  482. i: Integer;
  483. begin
  484. i := length(ExtraMouseCmdNameFn);
  485. SetLength(ExtraMouseCmdNameFn, i + 1);
  486. ExtraMouseCmdNameFn[i] := ANamesProc;
  487. if AOptProc = nil then
  488. exit;
  489. i := length(ExtraMouseCmdOptFn);
  490. SetLength(ExtraMouseCmdOptFn, i + 1);
  491. ExtraMouseCmdOptFn[i] := AOptProc;
  492. end;
  493. { TSynEditMouseInternalActions }
  494. procedure TSynEditMouseInternalActions.SetOptions(AValue: TSynEditorMouseOptions);
  495. begin
  496. FOptions := AValue;
  497. if emUseMouseActions in FOptions then exit;
  498. AValue := AValue - [emUseMouseActions];
  499. if (FInternOptions = AValue) and (Count > 0) then exit;
  500. FInternOptions := AValue;
  501. InitForOptions(FInternOptions);
  502. end;
  503. procedure TSynEditMouseInternalActions.SetUserActions(AValue: TSynEditMouseActions);
  504. begin
  505. if AValue =nil then
  506. FUserActions.Clear
  507. else
  508. FUserActions.Assign(AValue);
  509. end;
  510. procedure TSynEditMouseInternalActions.InitForOptions(AnOptions: TSynEditorMouseOptions);
  511. begin
  512. Clear;
  513. end;
  514. constructor TSynEditMouseInternalActions.Create(AOwner: TPersistent);
  515. begin
  516. FOptions := [];
  517. FUserActions := TSynEditMouseActions.Create(AOwner);
  518. inherited Create(AOwner);
  519. end;
  520. destructor TSynEditMouseInternalActions.Destroy;
  521. begin
  522. FreeAndNil(FUserActions);
  523. inherited Destroy;
  524. end;
  525. procedure TSynEditMouseInternalActions.ResetDefaults;
  526. begin
  527. InitForOptions(FOptions);
  528. end;
  529. procedure TSynEditMouseInternalActions.ResetUserActions;
  530. begin
  531. if emUseMouseActions in FOptions then begin
  532. if (FInternOptions <> FOptions - [emUseMouseActions]) or (Count = 0) then begin
  533. FInternOptions := FOptions - [emUseMouseActions];
  534. InitForOptions(FInternOptions);
  535. end;
  536. FUserActions.Assign(Self);
  537. end
  538. else begin
  539. FUserActions.Clear;
  540. end;
  541. end;
  542. function TSynEditMouseInternalActions.GetActionsForOptions(AnOptions: TSynEditorMouseOptions): TSynEditMouseActions;
  543. begin
  544. Options := AnOptions;
  545. if emUseMouseActions in FOptions then
  546. Result := FUserActions
  547. else
  548. Result := Self;
  549. end;
  550. { TSynEditMouseAction }
  551. procedure TSynEditMouseAction.SetButton(const AValue: TSynMouseButton);
  552. begin
  553. if FButton = AValue then exit;
  554. FButton := AValue;
  555. if Collection <> nil then
  556. TSynEditMouseActions(Collection).AssertNoConflict(self);
  557. if FButton in [mbXWheelUp, mbXWheelDown] then
  558. ClickDir := cdDown;
  559. end;
  560. procedure TSynEditMouseAction.SetButtonUpRestrictions(AValue: TSynMAUpRestrictions);
  561. begin
  562. if FButtonUpRestrictions = AValue then Exit;
  563. FButtonUpRestrictions := AValue;
  564. if Collection <> nil then
  565. TSynEditMouseActions(Collection).AssertNoConflict(self);
  566. end;
  567. procedure TSynEditMouseAction.SetClickCount(const AValue: TSynMAClickCount);
  568. begin
  569. if FClickCount = AValue then exit;
  570. FClickCount := AValue;
  571. if Collection <> nil then
  572. TSynEditMouseActions(Collection).AssertNoConflict(self);
  573. end;
  574. procedure TSynEditMouseAction.SetClickDir(AValue: TSynMAClickDir);
  575. begin
  576. if FButton in [mbXWheelUp, mbXWheelDown] then
  577. AValue := cdDown;
  578. if FClickDir = AValue then exit;
  579. FClickDir := AValue;
  580. if Collection <> nil then
  581. TSynEditMouseActions(Collection).AssertNoConflict(self);
  582. end;
  583. procedure TSynEditMouseAction.SetCommand(const AValue: TSynEditorMouseCommand);
  584. begin
  585. if FCommand = AValue then exit;
  586. FCommand := AValue;
  587. if Collection <> nil then
  588. TSynEditMouseActions(Collection).AssertNoConflict(self);
  589. end;
  590. procedure TSynEditMouseAction.SetIgnoreUpClick(AValue: Boolean);
  591. begin
  592. if FIgnoreUpClick = AValue then Exit;
  593. FIgnoreUpClick := AValue;
  594. if Collection <> nil then
  595. TSynEditMouseActions(Collection).AssertNoConflict(self);
  596. end;
  597. procedure TSynEditMouseAction.SetMoveCaret(const AValue: Boolean);
  598. begin
  599. if FMoveCaret = AValue then exit;
  600. FMoveCaret := AValue;
  601. if Collection <> nil then
  602. TSynEditMouseActions(Collection).AssertNoConflict(self);
  603. end;
  604. procedure TSynEditMouseAction.SetOption(const AValue: TSynEditorMouseCommandOpt);
  605. begin
  606. if FOption = AValue then exit;
  607. FOption := AValue;
  608. if Collection <> nil then
  609. TSynEditMouseActions(Collection).AssertNoConflict(self);
  610. end;
  611. procedure TSynEditMouseAction.SetOption2(AValue: Integer);
  612. begin
  613. if FOption2 = AValue then Exit;
  614. FOption2 := AValue;
  615. if Collection <> nil then
  616. TSynEditMouseActions(Collection).AssertNoConflict(self);
  617. end;
  618. procedure TSynEditMouseAction.SetPriority(const AValue: TSynEditorMouseCommandOpt);
  619. begin
  620. if FPriority = AValue then exit;
  621. FPriority := AValue;
  622. if Collection <> nil then
  623. TSynEditMouseActions(Collection).AssertNoConflict(self);
  624. end;
  625. procedure TSynEditMouseAction.SetShift(const AValue: TShiftState);
  626. begin
  627. if FShift = AValue then exit;
  628. FShift := AValue;
  629. if Collection <> nil then
  630. TSynEditMouseActions(Collection).AssertNoConflict(self);
  631. end;
  632. procedure TSynEditMouseAction.SetShiftMask(const AValue: TShiftState);
  633. begin
  634. if FShiftMask = AValue then exit;
  635. FShiftMask := AValue;
  636. if Collection <> nil then
  637. TSynEditMouseActions(Collection).AssertNoConflict(self);
  638. end;
  639. function TSynEditMouseAction.GetDisplayName: string;
  640. begin
  641. Result := MouseCommandName(FCommand);
  642. end;
  643. procedure TSynEditMouseAction.Assign(Source: TPersistent);
  644. begin
  645. if Source is TSynEditMouseAction then
  646. begin
  647. FCommand := TSynEditMouseAction(Source).Command;
  648. FClickCount := TSynEditMouseAction(Source).ClickCount;
  649. FClickDir := TSynEditMouseAction(Source).ClickDir;
  650. FButtonUpRestrictions := TSynEditMouseAction(Source).ButtonUpRestrictions;
  651. FButton := TSynEditMouseAction(Source).Button;
  652. FShift := TSynEditMouseAction(Source).Shift;
  653. FShiftMask := TSynEditMouseAction(Source).ShiftMask;
  654. FMoveCaret := TSynEditMouseAction(Source).MoveCaret;
  655. FIgnoreUpClick := TSynEditMouseAction(Source).IgnoreUpClick;
  656. FOption := TSynEditMouseAction(Source).FOption;
  657. FOption2 := TSynEditMouseAction(Source).FOption2;
  658. FPriority := TSynEditMouseAction(Source).Priority;
  659. end else
  660. inherited Assign(Source);
  661. if Collection <> nil then
  662. TSynEditMouseActions(Collection).AssertNoConflict(self);
  663. end;
  664. procedure TSynEditMouseAction.Clear;
  665. begin
  666. FCommand := 0;
  667. FClickCount := ccSingle;
  668. FClickDir := cdUp;
  669. FButton := mbXLeft;
  670. FShift := [];
  671. FShiftMask := [];
  672. FMoveCaret := False;
  673. FOption := 0;
  674. FPriority := 0;
  675. FIgnoreUpClick := False;
  676. end;
  677. function TSynEditMouseAction.IsMatchingShiftState(AShift: TShiftState): Boolean;
  678. begin
  679. Result := AShift * FShiftMask = FShift;
  680. end;
  681. function TSynEditMouseAction.IsMatchingClick(ABtn: TSynMouseButton; ACCount: TSynMAClickCount;
  682. ACDir: TSynMAClickDir): Boolean;
  683. begin
  684. Result := (Button = ABtn)
  685. and ((ClickCount = ACCount) or (ClickCount = ccAny))
  686. and (ClickDir = ACDir)
  687. end;
  688. function TSynEditMouseAction.IsFallback: Boolean;
  689. begin
  690. Result := FShiftMask = [];
  691. end;
  692. function TSynEditMouseAction.Conflicts(Other: TSynEditMouseAction): Boolean;
  693. begin
  694. If (Other = nil) or (Other = self) then exit(False);
  695. Result := (Other.Button = self.Button)
  696. and ((Other.ClickCount = self.ClickCount)
  697. or (self.ClickCount = ccAny) or (Other.ClickCount = ccAny))
  698. and (Other.ClickDir = self.ClickDir)
  699. and (Other.Shift * self.ShiftMask = self.Shift * Other.ShiftMask)
  700. and ((Other.Command <> self.Command) or // Only conflicts, if Command differs
  701. (Other.MoveCaret <> self.MoveCaret) or
  702. (Other.IgnoreUpClick <> self.IgnoreUpClick) or
  703. (Other.Option <> self.Option) or
  704. (Other.Option2 <> self.Option2) )
  705. and not(Other.IsFallback xor self.IsFallback)
  706. and (Other.Priority = self.Priority);
  707. end;
  708. function TSynEditMouseAction.Equals(Other: TSynEditMouseAction;
  709. IgnoreCmd: Boolean = False): Boolean;
  710. begin
  711. Result := (Other.Button = self.Button)
  712. and (Other.ClickCount = self.ClickCount)
  713. and (Other.ClickDir = self.ClickDir)
  714. and (Other.ButtonUpRestrictions = self.ButtonUpRestrictions)
  715. and (Other.Shift = self.Shift)
  716. and (Other.ShiftMask = self.ShiftMask)
  717. and (Other.Priority = self.Priority)
  718. and ((Other.Command = self.Command) or IgnoreCmd)
  719. and ((Other.Option = self.Option) or IgnoreCmd)
  720. and ((Other.Option2 = self.Option2) or IgnoreCmd)
  721. and ((Other.MoveCaret = self.MoveCaret) or IgnoreCmd)
  722. and ((Other.IgnoreUpClick = self.IgnoreUpClick) or IgnoreCmd);
  723. end;
  724. { TSynEditMouseActions }
  725. function TSynEditMouseActions.GetItem(Index: Integer): TSynEditMouseAction;
  726. begin
  727. Result := TSynEditMouseAction(inherited GetItem(Index));
  728. end;
  729. procedure TSynEditMouseActions.SetItem(Index: Integer; const AValue: TSynEditMouseAction);
  730. begin
  731. inherited SetItem(Index, AValue);
  732. end;
  733. function TSynEditMouseActions.GetOwner: TPersistent;
  734. begin
  735. Result := FOwner;
  736. end;
  737. procedure TSynEditMouseActions.Update(Item: TCollectionItem);
  738. var
  739. i: Integer;
  740. Err : ESynMouseCmdError;
  741. begin
  742. inherited Update(Item);
  743. i := Count - 1;
  744. Err := nil;
  745. while i > 0 do begin
  746. try
  747. AssertNoConflict(Items[i]);
  748. except
  749. on E : ESynMouseCmdError do begin
  750. Delete(i);
  751. if assigned(Owner) and (csDesigning in TComponent(Owner).ComponentState)
  752. then
  753. MessageDlg(SYNS_EDuplicateShortCut, E.Message + LineEnding + Items[i].DisplayName,
  754. mtWarning, [mbOK], '')
  755. else
  756. Err := E;
  757. //if not(assigned(Owner) and (csLoading in TComponent(Owner).ComponentState))
  758. //then
  759. // raise E;
  760. end;
  761. end;
  762. dec(i);
  763. end;
  764. if assigned(Err) then
  765. raise Err;
  766. end;
  767. constructor TSynEditMouseActions.Create(AOwner: TPersistent);
  768. begin
  769. inherited Create(TSynEditMouseAction);
  770. FOwner := AOwner;
  771. FAssertLock := 0;
  772. end;
  773. function TSynEditMouseActions.Add: TSynEditMouseAction;
  774. begin
  775. Result := TSynEditMouseAction(inherited Add);
  776. end;
  777. procedure TSynEditMouseActions.Assign(Source: TPersistent);
  778. var
  779. i: Integer;
  780. begin
  781. if Source is TSynEditMouseActions then
  782. begin
  783. Clear;
  784. BeginUpdate;
  785. for i := 0 to TSynEditMouseActions(Source).Count-1 do
  786. Add.Assign(TSynEditMouseActions(Source)[i]);
  787. EndUpdate;
  788. end
  789. else
  790. inherited Assign(Source);
  791. end;
  792. procedure TSynEditMouseActions.AssertNoConflict(MAction: TSynEditMouseAction);
  793. var
  794. i: Integer;
  795. begin
  796. if (FAssertLock > 0) or (UpdateCount > 0) then exit;
  797. for i := 0 to Count-1 do begin
  798. if Items[i].Conflicts(MAction) then
  799. raise ESynMouseCmdError.Create(SYNS_EDuplicateShortCut);
  800. end;
  801. end;
  802. function TSynEditMouseActions.Equals(Other: TSynEditMouseActions): Boolean;
  803. var
  804. i: Integer;
  805. begin
  806. Result := False;
  807. if Count <> Other.Count then exit;
  808. for i := 0 to Count - 1 do
  809. if Other.IndexOf(Items[i]) < 0 then
  810. exit;
  811. Result := True;
  812. end;
  813. function TSynEditMouseActions.FindCommand(AnInfo: TSynEditMouseActionInfo;
  814. APrevious: TSynEditMouseAction = nil): TSynEditMouseAction;
  815. var
  816. i, MinPriority: Integer;
  817. act, found, fback: TSynEditMouseAction;
  818. begin
  819. MinPriority := 0;
  820. if assigned(APrevious) then
  821. MinPriority := APrevious.Priority + 1;
  822. fback := nil;
  823. found := nil;
  824. for i := 0 to Count-1 do begin
  825. act := Items[i];
  826. if act.Priority < MinPriority then
  827. continue;
  828. if act.IsMatchingClick(AnInfo.Button, AnInfo.CCount, AnInfo.Dir) and
  829. act.IsMatchingShiftState(AnInfo.Shift)
  830. then begin
  831. if act.IsFallback then begin
  832. if (fback = nil) or (act.Priority < fback.Priority) then
  833. fback := act;
  834. end
  835. else begin
  836. if (found = nil) or (act.Priority < found.Priority) then
  837. found := act;
  838. end;
  839. end;
  840. end;
  841. if found <> nil then begin
  842. if (fback <> nil) and (fback.Priority < found.Priority) then
  843. Result := fback
  844. else
  845. Result := found;
  846. end
  847. else if fback <> nil then
  848. Result := fback
  849. else
  850. Result := nil;
  851. end;
  852. procedure TSynEditMouseActions.AddCommand(const ACmd: TSynEditorMouseCommand;
  853. const AMoveCaret: Boolean; const AButton: TSynMouseButton;
  854. const AClickCount: TSynMAClickCount; const ADir: TSynMAClickDir;
  855. const AShift, AShiftMask: TShiftState; const AOpt: TSynEditorMouseCommandOpt = 0;
  856. const APrior: Integer = 0; const AOpt2: integer = 0; const AIgnoreUpClick: Boolean = False);
  857. begin
  858. AddCommand(ACmd, AMoveCaret, AButton, AClickCount, ADir, [], AShift, AShiftMask, AOpt, APrior,
  859. AOpt2, AIgnoreUpClick);
  860. end;
  861. procedure TSynEditMouseActions.AddCommand(const ACmd: TSynEditorMouseCommand;
  862. const AMoveCaret: Boolean; const AButton: TSynMouseButton;
  863. const AClickCount: TSynMAClickCount; const ADir: TSynMAClickDir;
  864. const AnUpRestrict: TSynMAUpRestrictions; const AShift, AShiftMask: TShiftState;
  865. const AOpt: TSynEditorMouseCommandOpt; const APrior: Integer; const AOpt2: integer;
  866. const AIgnoreUpClick: Boolean);
  867. var
  868. new: TSynEditMouseAction;
  869. begin
  870. inc(FAssertLock);
  871. try
  872. new := Add;
  873. with new do begin
  874. Command := ACmd;
  875. MoveCaret := AMoveCaret;
  876. Button := AButton;
  877. ClickCount := AClickCount;
  878. ClickDir := ADir;
  879. ButtonUpRestrictions := AnUpRestrict;
  880. Shift := AShift;
  881. ShiftMask := AShiftMask;
  882. Option := AOpt;
  883. Priority := APrior;
  884. Option2 := AOpt2;
  885. IgnoreUpClick := AIgnoreUpClick;
  886. end;
  887. finally
  888. dec(FAssertLock);
  889. end;
  890. try
  891. AssertNoConflict(new);
  892. except
  893. Delete(Count-1);
  894. raise;
  895. end;
  896. end;
  897. procedure TSynEditMouseActions.ResetDefaults;
  898. begin
  899. Clear;
  900. end;
  901. procedure TSynEditMouseActions.IncAssertLock;
  902. begin
  903. inc(FAssertLock);
  904. end;
  905. procedure TSynEditMouseActions.DecAssertLock;
  906. begin
  907. dec(FAssertLock);
  908. end;
  909. function TSynEditMouseActions.IndexOf(MAction: TSynEditMouseAction;
  910. IgnoreCmd: Boolean = False): Integer;
  911. begin
  912. Result := Count - 1;
  913. while Result >= 0 do begin
  914. if Items[Result].Equals(MAction, IgnoreCmd) then exit;
  915. Dec(Result);
  916. end;
  917. end;
  918. { TSynEditMouseActionSearchList }
  919. function TSynEditMouseActionSearchList.CallSearchHandlers(var AnInfo: TSynEditMouseActionInfo;
  920. HandleActionProc: TSynEditMouseActionHandler): Boolean;
  921. var
  922. i: LongInt;
  923. begin
  924. i:=Count;
  925. Result := False;
  926. while NextDownIndex(i) and (not Result) do
  927. Result := TSynEditMouseActionSearchProc(Items[i])(AnInfo, HandleActionProc);
  928. end;
  929. { TSynEditMouseActionExecList }
  930. function TSynEditMouseActionExecList.CallExecHandlers(AnAction: TSynEditMouseAction;
  931. var AnInfo: TSynEditMouseActionInfo): Boolean;
  932. var
  933. i: LongInt;
  934. begin
  935. i:=Count;
  936. Result := False;
  937. while NextDownIndex(i) and (not Result) do
  938. Result := TSynEditMouseActionExecProc(Items[i])(AnAction, AnInfo);
  939. end;
  940. initialization
  941. RegisterIntegerConsts(TypeInfo(TSynEditorMouseCommand), @IdentToSynMouseCmd, @SynMouseCmdToIdent);
  942. finalization
  943. ExtraIdentToIntFn := nil;
  944. ExtraIntToIdentFn := nil;
  945. ExtraGetEditorCommandValues := nil;
  946. ExtraMouseCmdNameFn := nil;
  947. ExtraMouseCmdOptFn := nil;
  948. end.