mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+chg: try to preserve caret position and visible line positions after recoding
This commit is contained in:
parent
eabdaef50e
commit
79109a77e4
@ -524,11 +524,13 @@ bool EditConvertText(HWND hwnd, cpi_enc_t encSource, cpi_enc_t encDest)
|
||||
if (pchText) {
|
||||
WideCharToMultiByteEx(Encoding_SciCP, 0, pwchText, -1, pchText, cbText, NULL, NULL);
|
||||
FreeMem(pwchText);
|
||||
DocLn const vis1stLine = SciCall_GetFirstVisibleLine();
|
||||
DocPos const curPos = SciCall_GetCurrentPos();
|
||||
EditSetNewText(hwnd, pchText, (cbText - 1), true, false);
|
||||
Encoding_Current(encDest);
|
||||
SciCall_GotoPos(curPos);
|
||||
SciCall_SetFirstVisibleLine(vis1stLine);
|
||||
FreeMem(pchText);
|
||||
Sci_GotoPosTop(curPos);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
@ -6746,6 +6746,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
|
||||
case CMD_ESCAPE: {
|
||||
|
||||
DocLn const vis1stLine = SciCall_GetFirstVisibleLine();
|
||||
DocPos const iCurPos = SciCall_GetCurrentPos();
|
||||
|
||||
int skipLevel = Settings2.ExitOnESCSkipLevel;
|
||||
@ -6764,6 +6766,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
SciCall_ClearSelections();
|
||||
//~EndUndoTransAction();
|
||||
SciCall_GotoPos(iCurPos);
|
||||
SciCall_SetFirstVisibleLine(vis1stLine);
|
||||
s_bInMultiEditMode = false;
|
||||
--skipLevel;
|
||||
}
|
||||
@ -8440,6 +8443,7 @@ static void _HandleAutoCloseTags()
|
||||
/// int const lexerID = SciCall_GetLexer();
|
||||
/// if (lexerID == SCLEX_HTML || lexerID == SCLEX_XML)
|
||||
DocPos const maxSearchBackward = 8192;
|
||||
DocLn const vis1stLine = SciCall_GetFirstVisibleLine();
|
||||
DocPos const iCurPos = SciCall_GetCurrentPos();
|
||||
DocPos const iHelper = iCurPos - maxSearchBackward;
|
||||
DocPos const iStartPos = max_p(0, iHelper);
|
||||
@ -8479,6 +8483,7 @@ static void _HandleAutoCloseTags()
|
||||
if ((cchIns > 3) && !isNonClosingTag) {
|
||||
EditReplaceSelection(replaceBuf, false);
|
||||
SciCall_GotoPos(iCurPos);
|
||||
SciCall_SetFirstVisibleLine(vis1stLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -805,8 +805,6 @@ DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool);
|
||||
//~#define Sci_GetDocEndPosition() SciCall_GetTextLength()
|
||||
#define Sci_GetDocEndPosition() SciCall_PositionAfter(SciCall_GetTextLength() - 1)
|
||||
|
||||
#define Sci_GotoPosTop(position) { SciCall_GotoPos(Sci_GetDocEndPosition()); SciCall_GotoPos(curPos); }
|
||||
|
||||
#define Sci_ClampAlpha(alpha) clampi((alpha), SC_ALPHA_TRANSPARENT, SC_ALPHA_OPAQUE) //~SC_ALPHA_NOALPHA
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user