add editor commands PreviousChangedArea & NextChangedArea

This commit is contained in:
Basile Burg 2016-06-26 21:35:09 +02:00
parent 0f385033a7
commit a5992c7a8e
6 changed files with 141 additions and 5 deletions

BIN
icons/other/case.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -13,7 +13,7 @@
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
<Resources Count="83">
<Resources Count="84">
<Resource_0 FileName="../icons/window/layout_add.png" Type="RCDATA" ResourceName="LAYOUT_ADD"/>
<Resource_1 FileName="../icons/window/layout.png" Type="RCDATA" ResourceName="LAYOUT"/>
<Resource_2 FileName="../icons/window/application_go.png" Type="RCDATA" ResourceName="APPLICATION_GO"/>
@ -97,6 +97,7 @@
<Resource_80 FileName="../icons/arrow/arrow_redo.png" Type="RCDATA" ResourceName="ARROW_REDO"/>
<Resource_81 FileName="../icons/arrow/arrow_pen.png" Type="RCDATA" ResourceName="ARROW_PEN"/>
<Resource_82 FileName="../icons/arrow/arrow_down.png" Type="RCDATA" ResourceName="ARROW_DOWN"/>
<Resource_83 FileName="../icons/other/case.png" Type="RCDATA" ResourceName="CASE"/>
</Resources>
</General>
<i18n>

View File

@ -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

View File

@ -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;

View File

@ -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');
//

View File

@ -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 --------------------------------------------------------}