mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+ fix: TAB indentation handling according to predecessors (NP2)
This commit is contained in:
parent
04d232efb7
commit
324b638abc
@ -3307,11 +3307,11 @@ void EditCompressSpaces(HWND hwnd)
|
||||
|
||||
const int iNewLen = StringCchLenA(pszOut, LocalSize(pszOut));
|
||||
|
||||
if (iCurPos > iAnchorPos) {
|
||||
EditSelectEx(hwnd, iAnchorPos, iAnchorPos + iNewLen);
|
||||
if (iCurPos < iAnchorPos) {
|
||||
EditSelectEx(hwnd, iCurPos + iNewLen, iCurPos);
|
||||
}
|
||||
else if (iCurPos < iAnchorPos) {
|
||||
EditSelectEx(hwnd, iCurPos, iCurPos + iNewLen);
|
||||
else if (iCurPos > iAnchorPos) {
|
||||
EditSelectEx(hwnd, iAnchorPos, iAnchorPos + iNewLen);
|
||||
}
|
||||
else { // empty selection
|
||||
int iNewPos = iCurPos;
|
||||
|
||||
@ -3324,18 +3324,53 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDM_EDIT_INDENT:
|
||||
{
|
||||
int token = BeginUndoAction();
|
||||
SendMessage(g_hwndEdit,SCI_TAB,0,0);
|
||||
EndUndoAction(token);
|
||||
int token = SciCall_IsSelectionEmpty() ? -1 : BeginUndoAction();
|
||||
|
||||
if (bTabIndents && !SciCall_IsSelectionEmpty()) {
|
||||
const int iLineSelStart = SciCall_LineFromPosition(SciCall_GetSelectionStart());
|
||||
const int iLineSelEnd = SciCall_LineFromPosition(SciCall_GetSelectionEnd());
|
||||
if (iLineSelStart == iLineSelEnd) {
|
||||
SendMessage(g_hwndEdit, SCI_VCHOME, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage(g_hwndEdit, SCI_TAB, 0, 0);
|
||||
|
||||
if (token >= 0) { EndUndoAction(token); }
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IDM_EDIT_UNINDENT:
|
||||
{
|
||||
int token = BeginUndoAction();
|
||||
SendMessage(g_hwndEdit,SCI_BACKTAB,0,0);
|
||||
EndUndoAction(token);
|
||||
int token = SciCall_IsSelectionEmpty() ? -1 : BeginUndoAction();
|
||||
|
||||
if (bTabIndents && !SciCall_IsSelectionEmpty()) {
|
||||
const int iLineSelStart = SciCall_LineFromPosition(SciCall_GetSelectionStart());
|
||||
const int iLineSelEnd = SciCall_LineFromPosition(SciCall_GetSelectionEnd());
|
||||
if (iLineSelStart == iLineSelEnd) {
|
||||
SendMessage(g_hwndEdit, SCI_VCHOME, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage(g_hwndEdit, SCI_BACKTAB, 0, 0);
|
||||
|
||||
if (token >= 0) { EndUndoAction(token); }
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CMD_CTRLTAB:
|
||||
{
|
||||
int token = SciCall_IsSelectionEmpty() ? -1 : BeginUndoAction();
|
||||
|
||||
SendMessage(g_hwndEdit, SCI_SETTABINDENTS, FALSE, 0);
|
||||
SendMessage(g_hwndEdit, SCI_SETUSETABS, TRUE, 0);
|
||||
SendMessage(g_hwndEdit, SCI_TAB, 0, 0);
|
||||
SendMessage(g_hwndEdit, SCI_SETUSETABS, !bTabsAsSpaces, 0);
|
||||
SendMessage(g_hwndEdit, SCI_SETTABINDENTS, bTabIndents, 0);
|
||||
|
||||
if (token >= 0) { EndUndoAction(token); }
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4865,19 +4900,6 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
|
||||
|
||||
case CMD_CTRLTAB:
|
||||
{
|
||||
int token = SciCall_IsSelectionEmpty() ? -1 : BeginUndoAction();
|
||||
SendMessage(g_hwndEdit,SCI_SETTABINDENTS,FALSE,0);
|
||||
SendMessage(g_hwndEdit,SCI_SETUSETABS,TRUE,0);
|
||||
SendMessage(g_hwndEdit,SCI_TAB,0,0);
|
||||
SendMessage(g_hwndEdit,SCI_SETUSETABS,!bTabsAsSpaces,0);
|
||||
SendMessage(g_hwndEdit,SCI_SETTABINDENTS,bTabIndents,0);
|
||||
if (token >= 0) EndUndoAction(token);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CMD_RECODEDEFAULT:
|
||||
{
|
||||
WCHAR tchCurFile2[MAX_PATH] = { L'\0' };
|
||||
|
||||
@ -181,8 +181,8 @@ BEGIN
|
||||
END
|
||||
POPUP "&Block"
|
||||
BEGIN
|
||||
MENUITEM "&Indent\tTab", IDM_EDIT_INDENT
|
||||
MENUITEM "&Unindent\tShift+Tab", IDM_EDIT_UNINDENT
|
||||
MENUITEM "&Indent\tTab", IDM_EDIT_INDENT
|
||||
MENUITEM "&Unindent\tShift+Tab", IDM_EDIT_UNINDENT
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "&Enclose Selection"
|
||||
BEGIN
|
||||
|
||||
Loading…
Reference in New Issue
Block a user