Minor refactoring & rename varibles

This commit is contained in:
Don Ho 2025-02-13 15:12:45 +01:00
parent 5dfc9709c9
commit 0b98007883
4 changed files with 13 additions and 12 deletions

View File

@ -2192,12 +2192,12 @@ void Notepad_plus::command(int id)
case IDM_VIEW_UNFOLD_CURRENT: case IDM_VIEW_UNFOLD_CURRENT:
{ {
bool isToggleEnabled = NppParameters::getInstance().getNppGUI()._enableFoldCmdToggable; bool isToggleEnabled = NppParameters::getInstance().getNppGUI()._enableFoldCmdToggable;
bool mode = id == IDM_VIEW_FOLD_CURRENT ? fold_collapse : fold_uncollapse; bool mode = id == IDM_VIEW_FOLD_CURRENT ? fold_collapse : fold_expand;
if (isToggleEnabled) if (isToggleEnabled)
{ {
bool isFolded = _pEditView->isCurrentLineFolded(); bool isFolded = _pEditView->isCurrentLineFolded();
mode = isFolded ? fold_uncollapse : fold_collapse; mode = isFolded ? fold_expand : fold_collapse;
} }
_pEditView->foldCurrentPos(mode); _pEditView->foldCurrentPos(mode);
@ -2208,7 +2208,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_UNFOLDALL: case IDM_VIEW_UNFOLDALL:
{ {
_isFolding = true; // So we can ignore events while folding is taking place _isFolding = true; // So we can ignore events while folding is taking place
bool doCollapse = (id==IDM_VIEW_FOLDALL)?fold_collapse:fold_uncollapse; bool doCollapse = (id == IDM_VIEW_FOLDALL) ? fold_collapse : fold_expand;
_pEditView->foldAll(doCollapse); _pEditView->foldAll(doCollapse);
if (_pDocMap) if (_pDocMap)
{ {
@ -2240,7 +2240,7 @@ void Notepad_plus::command(int id)
case IDM_VIEW_UNFOLD_7: case IDM_VIEW_UNFOLD_7:
case IDM_VIEW_UNFOLD_8: case IDM_VIEW_UNFOLD_8:
_isFolding = true; // So we can ignore events while folding is taking place _isFolding = true; // So we can ignore events while folding is taking place
_pEditView->collapse(id - IDM_VIEW_UNFOLD - 1, fold_uncollapse); _pEditView->collapse(id - IDM_VIEW_UNFOLD - 1, fold_expand);
_isFolding = false; _isFolding = false;
break; break;

View File

@ -5726,7 +5726,7 @@ intptr_t CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam
case NPPM_INTERNAL_SCINTILLAFINDERUNCOLLAPSE : case NPPM_INTERNAL_SCINTILLAFINDERUNCOLLAPSE :
{ {
_scintView.foldAll(fold_uncollapse); _scintView.foldAll(fold_expand);
return TRUE; return TRUE;
} }

View File

@ -546,14 +546,15 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
MultiCaretInfo(int len, size_t n) : _len2remove(len), _selIndex(n) {}; MultiCaretInfo(int len, size_t n) : _len2remove(len), _selIndex(n) {};
}; };
SHORT ctrl = GetKeyState(VK_CONTROL);
SHORT alt = GetKeyState(VK_MENU);
SHORT shift = GetKeyState(VK_SHIFT);
bool isColumnSelection = (execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN); bool isColumnSelection = (execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN);
bool column2MultSelect = (NppParameters::getInstance()).getSVP()._columnSel2MultiEdit; bool column2MultSelect = (NppParameters::getInstance()).getSVP()._columnSel2MultiEdit;
if (wParam == VK_DELETE) if (wParam == VK_DELETE)
{ {
SHORT ctrl = GetKeyState(VK_CONTROL);
SHORT alt = GetKeyState(VK_MENU);
SHORT shift = GetKeyState(VK_SHIFT);
if (!(shift & 0x8000) && !(ctrl & 0x8000) && !(alt & 0x8000)) // DEL & Multi-edit if (!(shift & 0x8000) && !(ctrl & 0x8000) && !(alt & 0x8000)) // DEL & Multi-edit
{ {
size_t nbSelections = execute(SCI_GETSELECTIONS); size_t nbSelections = execute(SCI_GETSELECTIONS);
@ -574,8 +575,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
{ {
size_t docLen = getCurrentDocLen(); size_t docLen = getCurrentDocLen();
char eolStr[3]; char eolStr[3] = { '\0' };
Sci_TextRangeFull tr; Sci_TextRangeFull tr {};
tr.chrg.cpMin = posStart; tr.chrg.cpMin = posStart;
tr.chrg.cpMax = posEnd + 2; tr.chrg.cpMax = posEnd + 2;
if (tr.chrg.cpMax > static_cast<Sci_Position>(docLen)) if (tr.chrg.cpMax > static_cast<Sci_Position>(docLen))
@ -2464,7 +2465,7 @@ void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask)
if (mask & BufferChangeLanguage) if (mask & BufferChangeLanguage)
{ {
defineDocType(buffer->getLangType()); defineDocType(buffer->getLangType());
foldAll(fold_uncollapse); foldAll(fold_expand);
} }
if (mask & BufferChangeLexing) if (mask & BufferChangeLexing)

View File

@ -89,7 +89,7 @@ const int CP_GREEK = 1253;
#define LIST_7 128 #define LIST_7 128
#define LIST_8 256 #define LIST_8 256
const bool fold_uncollapse = true; const bool fold_expand = true;
const bool fold_collapse = false; const bool fold_collapse = false;
#define MAX_FOLD_COLLAPSE_LEVEL 8 #define MAX_FOLD_COLLAPSE_LEVEL 8