diff --git a/PowerEditor/installer/nativeLang/chinese.xml b/PowerEditor/installer/nativeLang/chinese.xml index 503017e2..a0c0a86b 100644 --- a/PowerEditor/installer/nativeLang/chinese.xml +++ b/PowerEditor/installer/nativeLang/chinese.xml @@ -279,6 +279,9 @@ + + + diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 99ef70fe..6159f2de 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -278,6 +278,8 @@ + + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index fb261ddd..88754064 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -278,6 +278,8 @@ + + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index eea72dfd..5c87c4ee 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -287,6 +287,8 @@ + + diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index cc14d1a2..01683b87 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -125,6 +125,7 @@ #endif //SIZE_DLG_H #include "localization.h" +#include #define MENU 0x01 @@ -236,6 +237,9 @@ public: bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from bool fileCloseAll(); bool fileCloseAllButCurrent(); + bool fileCloseAllGiven(const std::vector &krvecBufferIndexes); + bool fileCloseAllToLeft(); + bool fileCloseAllToRight(); bool fileSave(BufferID id = BUFFER_INVALID); bool fileSaveAll(); bool fileSaveAs(BufferID id = BUFFER_INVALID, bool isSaveCopy = false); diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index f3879b9b..383a2efb 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -209,7 +209,12 @@ BEGIN MENUITEM "Rename...", IDM_FILE_RENAME MENUITEM "&Close", IDM_FILE_CLOSE MENUITEM "Clos&e All", IDM_FILE_CLOSEALL - MENUITEM "Close All but Active Document", IDM_FILE_CLOSEALL_BUT_CURRENT + POPUP "Close More" + BEGIN + MENUITEM "Close All but Active Document", IDM_FILE_CLOSEALL_BUT_CURRENT + MENUITEM "Close All to the Left", IDM_FILE_CLOSEALL_TOLEFT + MENUITEM "Close All to the Right", IDM_FILE_CLOSEALL_TORIGHT + END MENUITEM "Move to Recycle Bin", IDM_FILE_DELETE MENUITEM SEPARATOR MENUITEM "Load Session...", IDM_FILE_LOADSESSION diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 9ee57ca3..ed455ffc 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -112,6 +112,16 @@ void Notepad_plus::command(int id) checkDocState(); break; + case IDM_FILE_CLOSEALL_TOLEFT : + fileCloseAllToLeft(); + checkDocState(); + break; + + case IDM_FILE_CLOSEALL_TORIGHT : + fileCloseAllToRight(); + checkDocState(); + break; + case IDM_FILE_SAVE : fileSave(); break; @@ -2491,6 +2501,8 @@ void Notepad_plus::command(int id) case IDM_FILE_CLOSE : case IDM_FILE_CLOSEALL : case IDM_FILE_CLOSEALL_BUT_CURRENT : + case IDM_FILE_CLOSEALL_TOLEFT : + case IDM_FILE_CLOSEALL_TORIGHT : case IDM_FILE_SAVE : case IDM_FILE_SAVEALL : case IDM_FILE_RELOAD: diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 1b1ab2bc..8a0a0672 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -638,6 +638,77 @@ bool Notepad_plus::fileCloseAll() return true; } +bool Notepad_plus::fileCloseAllGiven(const std::vector &krvecBufferIndexes) +{ + // First check if we need to save any file. + + std::vector::const_iterator itIndexesEnd = krvecBufferIndexes.end(); + + for(std::vector::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex) { + BufferID id = _pDocTab->getBufferByIndex(*itIndex); + Buffer * buf = MainFileManager->getBufferByID(id); + if (buf->isUntitled() && buf->docLength() == 0) + { + // Do nothing. + } + else if (buf->isDirty()) + { + if(_activeView == MAIN_VIEW) + { + activateBuffer(id, MAIN_VIEW); + if(!activateBuffer(id, SUB_VIEW)) + switchEditViewTo(MAIN_VIEW); + } + else + { + activateBuffer(id, SUB_VIEW); + switchEditViewTo(SUB_VIEW); + } + + int res = doSaveOrNot(buf->getFullPathName()); + if (res == IDYES) + { + if (!fileSave(id)) + return false; // Abort entire procedure. + } + else if (res == IDCANCEL) + { + return false; + } + } + } + + // Now we close. + for(std::vector::const_iterator itIndex = krvecBufferIndexes.begin(); itIndex != itIndexesEnd; ++itIndex) { + doClose(_pDocTab->getBufferByIndex(*itIndex), currentView()); + } + + return true; +} + +bool Notepad_plus::fileCloseAllToLeft() +{ + // Indexes must go from high to low to deal with the fact that when one index is closed, any remaining + // indexes (smaller than the one just closed) will point to the wrong tab. + std::vector vecIndexesToClose; + for(int i = _pDocTab->getCurrentTabIndex() - 1; i >= 0; i--) { + vecIndexesToClose.push_back(i); + } + return fileCloseAllGiven(vecIndexesToClose); +} + +bool Notepad_plus::fileCloseAllToRight() +{ + // Indexes must go from high to low to deal with the fact that when one index is closed, any remaining + // indexes (smaller than the one just closed) will point to the wrong tab. + const int kiActive = _pDocTab->getCurrentTabIndex(); + std::vector vecIndexesToClose; + for(int i = _pDocTab->nbItem() - 1; i > kiActive; i--) { + vecIndexesToClose.push_back(i); + } + return fileCloseAllGiven(vecIndexesToClose); +} + bool Notepad_plus::fileCloseAllButCurrent() { BufferID current = _pEditView->getCurrentBufferID(); diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 13388ea2..fe13c850 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -332,6 +332,8 @@ BOOL Notepad_plus::notify(SCNotification *notification) vector itemUnitArray; itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSE, TEXT("Close"))); itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_BUT_CURRENT, TEXT("Close All BUT This"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_TOLEFT, TEXT("Close All to the Left"))); + itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_TORIGHT, TEXT("Close All to the Right"))); itemUnitArray.push_back(MenuItemUnit(IDM_FILE_SAVE, TEXT("Save"))); itemUnitArray.push_back(MenuItemUnit(IDM_FILE_SAVEAS, TEXT("Save As..."))); itemUnitArray.push_back(MenuItemUnit(IDM_FILE_RENAME, TEXT("Rename"))); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 830c108b..96f3e79a 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -70,6 +70,8 @@ WinMenuKeyDefinition winKeyDefs[] = { {VK_W, IDM_FILE_CLOSE, true, false, false, NULL}, {VK_NULL, IDM_FILE_CLOSEALL, false, false, false, NULL}, {VK_NULL, IDM_FILE_CLOSEALL_BUT_CURRENT, false, false, false, NULL}, + {VK_NULL, IDM_FILE_CLOSEALL_TOLEFT, false, false, false, NULL}, + {VK_NULL, IDM_FILE_CLOSEALL_TORIGHT, false, false, false, NULL}, {VK_NULL, IDM_FILE_DELETE, false, false, false, NULL}, {VK_NULL, IDM_FILE_RENAME, false, false, false, NULL}, {VK_NULL, IDM_FILE_LOADSESSION, false, false, false, NULL}, diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 363161f6..57ebda50 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -367,22 +367,23 @@ void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & plugin int tabContextMenuItemPos[] = { 0, // 0 : Close 1, // 1 : Close ALL BUT This -2, // 2 : Save -3, // 3 : Save As -7, // 4 : Print -16,// 5 : Move to Other View -17,// 6 : Clone to Other View -12,// 7 : Full File Path to Clipboard -13,// 8 : Filename to Clipboard -14,// 9 : Current Dir. Path to Clipboard -4, // 10: Rename -5, // 11: Delete -9, // 12: Read-Only -10,// 13: Clear Read-Only Flag -18,// 14: Move to New Instance -19,// 15: Open to New Instance -6, // 16: Reload - +4, // 2 : Save +5, // 3 : Save As +9, // 4 : Print +18,// 5 : Move to Other View +19,// 6 : Clone to Other View +14,// 7 : Full File Path to Clipboard +15,// 8 : Filename to Clipboard +16,// 9 : Current Dir. Path to Clipboard +6, // 10: Rename +7, // 11: Delete +11, // 12: Read-Only +12,// 13: Clear Read-Only Flag +20,// 14: Move to New Instance +21,// 15: Open to New Instance +8, // 16: Reload +2, // 17 : Close ALL to the Left +3, // 18 : Close ALL to the Right -1 //-------End }; diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 3bd9afb8..31013275 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -37,6 +37,8 @@ #define IDM_FILE_CLOSE (IDM_FILE + 3) #define IDM_FILE_CLOSEALL (IDM_FILE + 4) #define IDM_FILE_CLOSEALL_BUT_CURRENT (IDM_FILE + 5) + #define IDM_FILE_CLOSEALL_TOLEFT (IDM_FILE + 18) + #define IDM_FILE_CLOSEALL_TORIGHT (IDM_FILE + 19) #define IDM_FILE_SAVE (IDM_FILE + 6) #define IDM_FILE_SAVEALL (IDM_FILE + 7) #define IDM_FILE_SAVEAS (IDM_FILE + 8)