diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd480e5d..a77f6db4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,9 @@
## Enhancements
- Editor, added the _Redo All_ action.
+- Editor, added the _ecScrollCenteredDown_ and _ecScrollCenteredUp_ actions. Only available using shortcuts and
+ binded by default to UP/DOWN+CTRL+ALT, they allow to maintain the caret at the center
+ of the text view while scrolling.
## Bugs fixed
diff --git a/src/u_synmemo.pas b/src/u_synmemo.pas
index 97f18bfb..3f6a3be6 100644
--- a/src/u_synmemo.pas
+++ b/src/u_synmemo.pas
@@ -382,6 +382,7 @@ type
procedure setDscannerOptions(dsEnabled: boolean; dsDelay: integer);
procedure centerCursor();
procedure redoAll();
+ procedure scrollCentered(down: boolean);
//
property IdentifierMatchOptions: TIdentifierMatchOptions read fMatchOpts write setMatchOpts;
property Identifier: string read fIdentifier;
@@ -483,6 +484,8 @@ const
ecSelLeftWordEdge = ecUserFirst + 32;
ecSelRightWordEdge = ecUserFirst + 33;
ecRedoAll = ecUserFirst + 34;
+ ecScrollCenteredUp = ecUserFirst + 35;
+ ecScrollCenteredDown = ecUserFirst + 36;
var
D2Syn: TSynD2Syn; // used as model to set the options when no editor exists.
TxtSyn: TSynTxtSyn; // used as model to set the options when no editor exists.
@@ -1484,6 +1487,8 @@ begin
AddKey(ecSmartWordLeft, 0, [], 0, []);
AddKey(ecSmartWordRight, 0, [], 0, []);
AddKey(ecRedoAll, 0, [], 0, []);
+ AddKey(ecScrollCenteredDown, VK_DOWN, [ssCtrl, ssAlt], 0, []);
+ AddKey(ecScrollCenteredUp, VK_UP, [ssCtrl, ssAlt], 0, []);
end;
end;
@@ -1524,6 +1529,8 @@ begin
'ecSelLeftWordEdge': begin Int := ecSelLeftWordEdge; exit(true); end;
'ecSelRightWordEdge': begin Int := ecSelRightWordEdge; exit(true); end;
'ecRedoAll': begin Int := ecRedoAll; exit(true); end;
+ 'ecScrollCenteredUp': begin Int := ecScrollCenteredUp; exit(true); end;
+ 'ecScrollCenteredDown': begin Int := ecScrollCenteredDown; exit(true); end;
else exit(false);
end;
end;
@@ -1565,6 +1572,8 @@ begin
ecSelLeftWordEdge: begin Ident := 'ecSelLeftWordEdge'; exit(true); end;
ecSelRightWordEdge: begin Ident := 'ecSelRightWordEdge'; exit(true); end;
ecRedoAll: begin Ident := 'ecRedoAll'; exit(true); end;
+ ecScrollCenteredUp: begin Ident := 'ecScrollCenteredUp'; exit(true); end;
+ ecScrollCenteredDown: begin Ident := 'ecScrollCenteredDown'; exit(true); end;
else exit(false);
end;
end;
@@ -1699,6 +1708,10 @@ begin
gotoWordEdge(true);
ecRedoAll:
redoAll();
+ ecScrollCenteredUp:
+ scrollCentered(false);
+ ecScrollCenteredDown:
+ scrollCentered(true);
end;
if fOverrideColMode and not SelAvail then
begin
@@ -2135,6 +2148,20 @@ begin
TopView := NewTopLine;
end;
+procedure TDexedMemo.scrollCentered(down: boolean);
+begin
+ centerCursor();
+ if down then
+ begin
+ ExecuteCommand(ecScrollDown, #0, nil);
+ CaretY := CaretY - 1;
+ end else
+ begin
+ ExecuteCommand(ecScrollUp, #0, nil);
+ CaretY := CaretY + 1;
+ end;
+end;
+
procedure TDexedMemo.ShowPhobosDoc;
var
str: string;