From a5992c7a8e665eaa403b1cb11ca532303b1d01fa Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 26 Jun 2016 21:35:09 +0200 Subject: [PATCH] add editor commands PreviousChangedArea & NextChangedArea --- icons/other/case.png | Bin 0 -> 1604 bytes lazproj/coedit.lpi | 3 +- src/ce_editor.lfm | 34 ++++++++++++++++++++-- src/ce_editor.pas | 42 +++++++++++++++++++++++++++- src/ce_messages.pas | 2 ++ src/ce_synmemo.pas | 65 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 icons/other/case.png diff --git a/icons/other/case.png b/icons/other/case.png new file mode 100644 index 0000000000000000000000000000000000000000..4b3f39ec2521442db29ab7538ed1fc2185f7610d GIT binary patch literal 1604 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xa^B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh*)icxGNo zet9uiy|1s8XI^nhVqS8pr;Du;&;-5A%oHmpQxj85Hy1ZU0|QG#Lsw%<6AL$2b2m#< z3s+NDb8|D8UYGpj(%jU%5}4i;xL#La?BLJ~N(#9JK$~4si!#enQ{0O3a}~f|w#vlq z78ji6LG`BKbc>5CPQCg-$LND17Ac}(Lcr7mV#1RxkONQnsd>QEUIa|mTelv$&%nU6 z!_&nvq~cadP_&0gqKMspd-1Jza?99Hik{?d{SqK@Hd>6cRq&}Qm&-;KtrvaA6)`NcUO=dzo8e6LZnU~5H6PPyBJc8@1Fzm|V|FaAAa`d)Fvs^5i6qqH;Y zCF7MF4)#7QkT|qZfTj88heV68!zr03#8MPQ;;V({?+95cSRVX)wS`(lbW`r_bf;BZ zohw;16kFHv1)Arm=}w*0t(5;*#ic1kD!%YNV|vc~O^$|>PiAU#xilDV>&+^){C=`@ z@%BW=7PIU<8c)R@a%jJEK-}t<$YF*WK&>+q0!qFXvS?74`UFj|T zQ6p3+8DH4&?Yve*wbs{ShVSyrCtIyZociwd=H}8smD~L7-8Y`7GH&WG`>xf+B)dJ& z#rLwzyty+Q4|ymqn0@L^NR1xnTAAsrQp}AExnIxi{?7Dt_I8Q=b>|NrYhrpZM?R*{ zb;r8b3pEtGejk;4@UW!Lpu@>$?(F&VHMF&vuNO9U%cMlc`SZ!y?O30>nUCkoaW?k& z>l`;?;vEE9R>?%RU7RQ(730&o)w$AhqkV7ZNzb)EUA(o^a+X!!F4NGQ$~)&x_av4w zHRIcNzk0lOy0AZWW}xlVCXYZCozqr5jAwm&c`w|)yf(Gk>7+}I#q{aZ*>~Cf{a5q4 zbw{GaKBK;3leu13r%jt4B>!sjw|?3Dj$nmCp_3{FYc@`Lqq1z-yfgYbKUQtgx!hCx z>ksR%-}9PPJZ~2o)%NeM+7NTkTgA=(n9Za2QC&Z~48m$}{_N-qO_yD$6x0#$?NdJk ZGegnx5LMQatG1wW-P6_2Wt~$(69D`wViN!W literal 0 HcmV?d00001 diff --git a/lazproj/coedit.lpi b/lazproj/coedit.lpi index ae1a21a0..47c740d1 100644 --- a/lazproj/coedit.lpi +++ b/lazproj/coedit.lpi @@ -13,7 +13,7 @@ - + @@ -97,6 +97,7 @@ + diff --git a/src/ce_editor.lfm b/src/ce_editor.lfm index c92e7841..7038176d 100644 --- a/src/ce_editor.lfm +++ b/src/ce_editor.lfm @@ -12,14 +12,14 @@ inherited CEEditorWidget: TCEEditorWidget ClientHeight = 434 ClientWidth = 465 inherited Content: TPanel - Height = 434 + Height = 398 Width = 465 - ClientHeight = 434 + ClientHeight = 398 ClientWidth = 465 object editorStatus: TStatusBar[0] Left = 0 Height = 20 - Top = 412 + Top = 376 Width = 465 AutoSize = False BorderSpacing.Bottom = 2 @@ -45,6 +45,9 @@ inherited CEEditorWidget: TCEEditorWidget UseSystemFont = False end end + inherited toolbar: TCEToolBar + Width = 457 + end end inherited contextMenu: TPopupMenu left = 24 @@ -86,6 +89,9 @@ inherited CEEditorWidget: TCEEditorWidget Caption = 'Redo' OnClick = mnuedRedoClick end + object MenuItem11: TMenuItem + Caption = '-' + end object mnuedPrev: TMenuItem Caption = 'Previous location' OnClick = mnuedPrevClick @@ -94,6 +100,28 @@ inherited CEEditorWidget: TCEEditorWidget Caption = 'Next location' OnClick = mnuedNextClick end + object MenuItem10: TMenuItem + Caption = '-' + end + object mnuedPrevCarea: TMenuItem + Caption = 'Previous changed area' + OnClick = mnuedPrevCareaClick + end + object mnuedNextCarea: TMenuItem + Caption = 'Next changed area' + OnClick = mnuedNextCareaClick + end + object MenuItem9: TMenuItem + Caption = '-' + end + object mnuedUpcase: TMenuItem + Caption = 'Upper case selection' + OnClick = mnuedUpcaseClick + end + object mnuedLowcase: TMenuItem + Caption = 'Lower case selection' + OnClick = mnuedLowcaseClick + end object MenuItem7: TMenuItem Caption = '-' end diff --git a/src/ce_editor.pas b/src/ce_editor.pas index ecde1887..6a0cbee4 100644 --- a/src/ce_editor.pas +++ b/src/ce_editor.pas @@ -9,7 +9,7 @@ uses ComCtrls, SynEditHighlighter, ExtCtrls, Menus, SynMacroRecorder, dialogs, SynPluginSyncroEdit, SynEdit, SynHighlighterMulti, ce_dialogs, ce_widget, ce_interfaces, ce_synmemo, ce_dlang, ce_common, ce_dcd, ce_observer, - ce_sharedres, ce_controls, ce_writableComponent; + ce_sharedres, ce_controls, ce_writableComponent, ce_dsgncontrols; type @@ -53,11 +53,18 @@ type TCEEditorWidget = class(TCEWidget, ICEMultiDocObserver, ICEMultiDocHandler, ICEProjectObserver) MenuItem1: TMenuItem; + MenuItem10: TMenuItem; + MenuItem11: TMenuItem; + mnuedNextCarea: TMenuItem; + mnuedPrevCarea: TMenuItem; + mnuedLowcase: TMenuItem; + mnuedUpcase: TMenuItem; MenuItem2: TMenuItem; MenuItem3: TMenuItem; MenuItem5: TMenuItem; MenuItem6: TMenuItem; MenuItem8: TMenuItem; + MenuItem9: TMenuItem; mnuedRename: TMenuItem; mnuedInvAllNone: TMenuItem; mnuedComm: TMenuItem; @@ -76,6 +83,10 @@ type macRecorder: TSynMacroRecorder; editorStatus: TStatusBar; mnuEditor: TPopupMenu; + procedure mnuedNextCareaClick(Sender: TObject); + procedure mnuedPrevCareaClick(Sender: TObject); + procedure mnuedLowcaseClick(Sender: TObject); + procedure mnuedUpcaseClick(Sender: TObject); procedure MenuItem5Click(Sender: TObject); procedure MenuItem6Click(Sender: TObject); procedure MenuItem8Click(Sender: TObject); @@ -299,6 +310,10 @@ begin AssignPng(mnuedNext.Bitmap, 'GO_NEXT'); AssignPng(mnuedPrev.Bitmap, 'GO_PREVIOUS'); AssignPng(mnuedRename.Bitmap, 'PENCIL'); + AssignPng(mnuedUpcase.Bitmap, 'CASE'); + AssignPng(mnuedLowcase.Bitmap, 'CASE'); + AssignPng(mnuedNextCarea.Bitmap, 'GO_NEXT'); + AssignPng(mnuedPrevCarea.Bitmap, 'GO_PREVIOUS'); // EntitiesConnector.addObserver(self); EntitiesConnector.addSingleService(self); @@ -814,6 +829,31 @@ begin end; end; +procedure TCEEditorWidget.mnuedUpcaseClick(Sender: TObject); +begin + //TODO-ceditor: case-related commands are not implemented in synedit + if fDoc.isNotNil then + fDoc.ExecuteCommand(ecLowerCaseBlock, #0, nil); +end; + +procedure TCEEditorWidget.mnuedLowcaseClick(Sender: TObject); +begin + if fDoc.isNotNil then + fDoc.ExecuteCommand(ecUpperCaseBlock, #0, nil); +end; + +procedure TCEEditorWidget.mnuedNextCareaClick(Sender: TObject); +begin + if fDoc.isNotNil then + fDoc.nextChangedArea; +end; + +procedure TCEEditorWidget.mnuedPrevCareaClick(Sender: TObject); +begin + if fDoc.isNotNil then + fDoc.previousChangedArea; +end; + procedure TCEEditorWidget.MenuItem8Click(Sender: TObject); var str: TStringList; diff --git a/src/ce_messages.pas b/src/ce_messages.pas index 13854809..753ac3e8 100644 --- a/src/ce_messages.pas +++ b/src/ce_messages.pas @@ -313,6 +313,8 @@ begin fBtns[amcMisc]:= btnSelMisc; fBtns[amcProj]:= btnSelProj; // + // reminder: a tollbar button can be used here because it would have the + // same size as the buttons used to select a category. btnClearCat.OnClick := @actClearCurCatExecute; AssignPng(btnClearCat, 'CLEAN'); // diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index 018f67c4..6b36f46f 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -175,6 +175,7 @@ type procedure showCallTips(const tips: string); function lexCanCloseBrace: boolean; procedure handleStatusChanged(Sender: TObject; Changes: TSynStatusChanges); + procedure gotoToChangedArea(next: boolean); protected procedure DoEnter; override; procedure DoExit; override; @@ -211,6 +212,8 @@ type procedure showDDocs; procedure hideDDocs; procedure ShowPhobosDoc; + procedure nextChangedArea; + procedure previousChangedArea; procedure copy; // function breakPointsCount: integer; @@ -263,6 +266,8 @@ const ecRenameIdentifier = ecUserFirst + 12; ecCommentIdentifier = ecUserFirst + 13; ecShowPhobosDoc = ecUserFirst + 14; + ecPreviousChangedArea = ecUserFirst + 15; + ecNextChangedArea = ecUserFirst + 16; var D2Syn: TSynD2Syn; // used as model to set the options when no editor exists. @@ -753,6 +758,8 @@ begin AddKey(ecRenameIdentifier, VK_F2, [], 0, []); AddKey(ecCommentIdentifier, 0, [], 0, []); AddKey(ecShowPhobosDoc, VK_F1, [], 0, []); + AddKey(ecPreviousChangedArea, VK_UP, [ssAlt], 0, []); + AddKey(ecNextChangedArea, VK_DOWN, [ssAlt], 0, []); end; end; @@ -773,6 +780,8 @@ begin 'ecRenameIdentifier': begin Int := ecRenameIdentifier; exit(true); end; 'ecCommentIdentifier': begin Int := ecCommentIdentifier; exit(true); end; 'ecShowPhobosDoc': begin Int := ecShowPhobosDoc; exit(true); end; + 'ecNextChangedArea': begin Int := ecNextChangedArea; exit(true); end; + 'ecPreviousChangedArea':begin Int := ecPreviousChangedArea; exit(true); end; else exit(false); end; end; @@ -794,6 +803,8 @@ begin ecRenameIdentifier: begin Ident := 'ecRenameIdentifier'; exit(true); end; ecCommentIdentifier: begin Ident := 'ecCommentIdentifier'; exit(true); end; ecShowPhobosDoc: begin Ident := 'ecShowPhobosDoc'; exit(true); end; + ecNextChangedArea: begin Ident := 'ecNextChangedArea'; exit(true); end; + ecPreviousChangedArea:begin Ident := 'ecPreviousChangedArea'; exit(true); end; else exit(false); end; end; @@ -843,6 +854,10 @@ begin commentIdentifier; ecShowPhobosDoc: ShowPhobosDoc; + ecNextChangedArea: + gotoToChangedArea(true); + ecPreviousChangedArea: + gotoToChangedArea(false); end; if fOverrideColMode and not SelAvail then begin @@ -1223,6 +1238,56 @@ begin {$ENDIF} end; +procedure TCESynMemo.nextChangedArea; +begin + gotoToChangedArea(true); +end; + +procedure TCESynMemo.previousChangedArea; +begin + gotoToChangedArea(false); +end; + +procedure TCESynMemo.gotoToChangedArea(next: boolean); +var + i: integer; + s: TSynLineState; + d: integer; + b: integer = 0; + p: TPoint; +begin + i := CaretY - 1; + s := GetLineState(i); + case next of + true: begin d := 1; b := lines.count-1; end; + false:d := -1; + end; + if i = b then + exit; + // exit the current area if it's modified + while s <> slsNone do + begin + s := GetLineState(i); + if i = b then + exit; + i += d; + end; + // find next modified area + while s = slsNone do + begin + s := GetLineState(i); + if i = b then + break; + i += d; + end; + // goto area beg/end + if (s <> slsNone) and (i <> CaretY + 1) then + begin + p.X:= 1; + p.Y:= i + 1 - d; + ExecuteCommand(ecGotoXY, #0, @p); + end; +end; {$ENDREGION} {$REGION DDoc & CallTip --------------------------------------------------------}