+ fix: TAB indentation handling according to predecessors (NP2)

This commit is contained in:
Rainer Kottenhoff 2018-01-26 09:17:05 +01:00
parent 04d232efb7
commit 324b638abc
3 changed files with 47 additions and 25 deletions

View File

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

View File

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

View File

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