mirror of https://gitlab.com/basile.b/dexed.git
editor, center the Y view when active line is changed programatically
This commit is contained in:
parent
53fe7317b8
commit
a1b3955cc2
|
@ -7,6 +7,7 @@
|
|||
the <key>CTRL</key> + <key>SPACE</key> shortcut or the <key>.</key> key.
|
||||
- GDB Commander, added the _useCustomCommandsHistory_ option. If checked the history is used to auto-complete the field at the bottom.
|
||||
This is the previous default but it's now deactivated for a better experience with the GDB completions.
|
||||
- Editor, always center the view on current line after actions that have for effect to change the line number (find next, message click, goto line, goto next changed area, etc.)
|
||||
|
||||
## Bugs fixed
|
||||
|
||||
|
|
|
@ -819,7 +819,7 @@ begin
|
|||
fDoc.CaretY := i + 1;
|
||||
fDoc.CaretX := srcpos - sum + len;
|
||||
fDoc.SelectWord;
|
||||
fDoc.EnsureCursorPosVisible;
|
||||
fDoc.centerCursor();
|
||||
break;
|
||||
end;
|
||||
sum += linelen;
|
||||
|
|
|
@ -1151,7 +1151,8 @@ begin
|
|||
exit;
|
||||
fDoc.setFocus;
|
||||
fDoc.CaretXY := pos;
|
||||
fDoc.SelectLine;
|
||||
fDoc.centerCursor();
|
||||
fDoc.SelectLine();
|
||||
end;
|
||||
|
||||
function TMessagesWidget.itemShouldBeVisible(item: TTreeNode;
|
||||
|
|
|
@ -601,6 +601,7 @@ begin
|
|||
fHasRestarted := false;
|
||||
chkFromCur.Checked := true;
|
||||
fDoc.setFocus;
|
||||
fDoc.centerCursor();
|
||||
end;
|
||||
updateImperative;
|
||||
end;
|
||||
|
@ -632,7 +633,10 @@ begin
|
|||
fDoc.CaretX := fDoc.CaretX + fToFind.length;
|
||||
end;
|
||||
if fDoc.SearchReplace(fToFind, fReplaceWth, getOptions + [ssoReplace]) <> 0 then
|
||||
begin
|
||||
fHasSearched := true;
|
||||
fDoc.centerCursor();
|
||||
end;
|
||||
fDoc.OnReplaceText := nil;
|
||||
updateImperative;
|
||||
end;
|
||||
|
|
|
@ -10,7 +10,7 @@ uses
|
|||
SynHighlighterLFM, SynEditHighlighter, SynEditMouseCmds, SynEditFoldedView,
|
||||
SynEditMarks, SynEditTypes, SynHighlighterJScript, SynBeautifier, dialogs,
|
||||
md5, Spin, LCLIntf, LazFileUtils, LMessages, SynHighlighterCpp, math,
|
||||
SynGutterBase, LCLVersion,
|
||||
SynGutterBase, LCLVersion, SynEditMiscProcs,
|
||||
//SynEditMarkupFoldColoring,
|
||||
Clipbrd, fpjson, jsonparser, LazUTF8, Buttons, StdCtrls,
|
||||
u_common, u_writableComponent, u_d2syn, u_txtsyn, u_dialogs, u_sxsyn,
|
||||
|
@ -380,6 +380,7 @@ type
|
|||
function implementMain: THasMain;
|
||||
procedure replaceUndoableContent(const value: string);
|
||||
procedure setDscannerOptions(dsEnabled: boolean; dsDelay: integer);
|
||||
procedure centerCursor();
|
||||
//
|
||||
property IdentifierMatchOptions: TIdentifierMatchOptions read fMatchOpts write setMatchOpts;
|
||||
property Identifier: string read fIdentifier;
|
||||
|
@ -943,20 +944,26 @@ end;
|
|||
procedure TSynMemoPositions.back;
|
||||
begin
|
||||
Inc(fPos);
|
||||
{$HINTS OFF}
|
||||
if fPos < fList.Count then
|
||||
fMemo.CaretY := PtrInt(fList.Items[fPos])
|
||||
{$HINTS ON}
|
||||
begin
|
||||
{$HINTS OFF}
|
||||
fMemo.CaretY := PtrInt(fList.Items[fPos]);
|
||||
{$HINTS ON}
|
||||
TDexedMemo(fMemo).centerCursor();
|
||||
end
|
||||
else Dec(fPos);
|
||||
end;
|
||||
|
||||
procedure TSynMemoPositions.next;
|
||||
begin
|
||||
Dec(fPos);
|
||||
{$HINTS OFF}
|
||||
if fPos > -1 then
|
||||
fMemo.CaretY := PtrInt(fList.Items[fPos])
|
||||
{$HINTS ON}
|
||||
begin
|
||||
{$HINTS OFF}
|
||||
fMemo.CaretY := PtrInt(fList.Items[fPos]);
|
||||
{$HINTS ON}
|
||||
TDexedMemo(fMemo).centerCursor();
|
||||
end
|
||||
else Inc(fPos);
|
||||
end;
|
||||
|
||||
|
@ -2109,6 +2116,18 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TDexedMemo.centerCursor();
|
||||
var
|
||||
Y, LinesInWin, CurTopLine, NewTopLine: Integer;
|
||||
begin
|
||||
LinesInWin := LinesInWindow;
|
||||
CurTopLine := TopView;
|
||||
Y := ToPos(TextView.TextToViewIndex(ToIdx(CaretY)));
|
||||
NewTopLine := Max(1, Y - (LinesInWin div 2));
|
||||
if NewTopLine < 1 then NewTopLine := 1;
|
||||
TopView := NewTopLine;
|
||||
end;
|
||||
|
||||
procedure TDexedMemo.ShowPhobosDoc;
|
||||
var
|
||||
str: string;
|
||||
|
@ -2263,7 +2282,7 @@ begin
|
|||
else if i > lines.Count then
|
||||
i := lines.Count;
|
||||
CaretY:= i;
|
||||
EnsureCursorPosVisible;
|
||||
centerCursor();
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -2333,6 +2352,7 @@ begin
|
|||
p.X:= 1;
|
||||
p.Y:= i + 1 - d;
|
||||
ExecuteCommand(ecGotoXY, #0, @p);
|
||||
centerCursor;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -2368,7 +2388,10 @@ begin
|
|||
end;
|
||||
end;
|
||||
if assigned(tk) then
|
||||
begin
|
||||
ExecuteCommand(ecGotoXY, #0, @tk^.position);
|
||||
centerCursor;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDexedMemo.goToWarning(next: boolean);
|
||||
|
@ -2389,7 +2412,7 @@ begin
|
|||
if j <> -1 then
|
||||
begin
|
||||
CaretY:= fDscannerResults.item[j]^.line;
|
||||
EnsureCursorPosVisible;
|
||||
centerCursor;
|
||||
end;
|
||||
end
|
||||
else
|
||||
|
@ -2403,7 +2426,7 @@ begin
|
|||
if (j <> -1) and (j < fDscannerResults.count) then
|
||||
begin
|
||||
CaretY:= fDscannerResults.item[j]^.line;
|
||||
EnsureCursorPosVisible;
|
||||
centerCursor;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -3482,7 +3505,7 @@ begin
|
|||
e := Point(length(Lines[lines.Count-1])+1,lines.Count);
|
||||
TextBetweenPoints[b,e] := value;
|
||||
CaretXY := p;
|
||||
EnsureCursorPosVisible;
|
||||
centerCursor;
|
||||
fModified := true;
|
||||
end;
|
||||
|
||||
|
@ -3826,7 +3849,7 @@ begin
|
|||
pt := Mouse.CursorPos;
|
||||
pt.x:= pt.x - 40;
|
||||
CaretY := fScrollMemo.fMemo.CaretY;
|
||||
EnsureCursorPosVisible;
|
||||
centerCursor;
|
||||
fScrollMemo.Visible:=false;
|
||||
mouse.CursorPos := pt;
|
||||
fPositions.store;
|
||||
|
@ -4009,7 +4032,7 @@ begin
|
|||
else
|
||||
addBreakPoint(line);
|
||||
CaretY := Line;
|
||||
EnsureCursorPosVisible;
|
||||
centerCursor;
|
||||
end;
|
||||
|
||||
procedure TDexedMemo.addGutterIcon(line: integer; value: TGutterIcon);
|
||||
|
@ -4111,7 +4134,7 @@ begin
|
|||
// newly opened source has not 3 cols yet
|
||||
fMultiGutterMarks.columnCount := 3;
|
||||
caretY := line;
|
||||
EnsureCursorPosVisible;
|
||||
centerCursor;
|
||||
removeDebugTimeMarks;
|
||||
removeDscannerWarnings;
|
||||
case reason of
|
||||
|
|
Loading…
Reference in New Issue