Added close unchanged tabs command

Close #5185, close #5007
This commit is contained in:
Jon Bockhorst 2019-01-01 03:18:35 -06:00 committed by Don HO
parent ab4c2edde6
commit b75ccd29e2
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
8 changed files with 47 additions and 19 deletions

View File

@ -189,6 +189,7 @@ public:
bool fileCloseAllGiven(const std::vector<int>& krvecBufferIndexes); bool fileCloseAllGiven(const std::vector<int>& krvecBufferIndexes);
bool fileCloseAllToLeft(); bool fileCloseAllToLeft();
bool fileCloseAllToRight(); bool fileCloseAllToRight();
bool fileCloseAllUnchanged();
bool fileSave(BufferID id = BUFFER_INVALID); bool fileSave(BufferID id = BUFFER_INVALID);
bool fileSaveAll(); bool fileSaveAll();
bool fileSaveSpecific(const generic_string& fileNameToSave); bool fileSaveSpecific(const generic_string& fileNameToSave);

View File

@ -249,6 +249,7 @@ BEGIN
MENUITEM "Close All but Active Document", IDM_FILE_CLOSEALL_BUT_CURRENT 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 Left", IDM_FILE_CLOSEALL_TOLEFT
MENUITEM "Close All to the Right", IDM_FILE_CLOSEALL_TORIGHT MENUITEM "Close All to the Right", IDM_FILE_CLOSEALL_TORIGHT
MENUITEM "Close All Unchanged", IDM_FILE_CLOSEALL_UNCHANGED
END END
MENUITEM "Move to Recycle Bin", IDM_FILE_DELETE MENUITEM "Move to Recycle Bin", IDM_FILE_DELETE
MENUITEM SEPARATOR MENUITEM SEPARATOR

View File

@ -215,6 +215,11 @@ void Notepad_plus::command(int id)
checkDocState(); checkDocState();
break; break;
case IDM_FILE_CLOSEALL_UNCHANGED:
fileCloseAllUnchanged();
checkDocState();
break;
case IDM_FILE_SAVE : case IDM_FILE_SAVE :
fileSave(); fileSave();
break; break;
@ -3356,6 +3361,7 @@ void Notepad_plus::command(int id)
case IDM_FILE_CLOSEALL_BUT_CURRENT : case IDM_FILE_CLOSEALL_BUT_CURRENT :
case IDM_FILE_CLOSEALL_TOLEFT : case IDM_FILE_CLOSEALL_TOLEFT :
case IDM_FILE_CLOSEALL_TORIGHT : case IDM_FILE_CLOSEALL_TORIGHT :
case IDM_FILE_CLOSEALL_UNCHANGED:
case IDM_FILE_SAVE : case IDM_FILE_SAVE :
case IDM_FILE_SAVEALL : case IDM_FILE_SAVEALL :
case IDM_FILE_RELOAD: case IDM_FILE_RELOAD:

View File

@ -1106,6 +1106,22 @@ bool Notepad_plus::fileCloseAllToRight()
return fileCloseAllGiven(vecIndexesToClose); return fileCloseAllGiven(vecIndexesToClose);
} }
bool Notepad_plus::fileCloseAllUnchanged()
{
std::vector<int> vecIndexesToClose;
for (int i = int(_pDocTab->nbItem()) - 1; i >= 0; i--) {
BufferID id = _mainDocTab.getBufferByIndex(i);
Buffer* buf = MainFileManager->getBufferByID(id);
if ((buf->isUntitled() && buf->docLength() == 0) || !buf->isDirty())
{
vecIndexesToClose.push_back(i);
}
}
return fileCloseAllGiven(vecIndexesToClose);
}
bool Notepad_plus::fileCloseAllButCurrent() bool Notepad_plus::fileCloseAllButCurrent()
{ {
BufferID current = _pEditView->getCurrentBufferID(); BufferID current = _pEditView->getCurrentBufferID();

View File

@ -522,6 +522,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_BUT_CURRENT, TEXT("Close All BUT This"))); 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_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_CLOSEALL_TORIGHT, TEXT("Close All to the Right")));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSEALL_UNCHANGED, TEXT("Close All Unchanged")));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_SAVE, TEXT("Save"))); 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_SAVEAS, TEXT("Save As...")));
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_RENAME, TEXT("Rename"))); itemUnitArray.push_back(MenuItemUnit(IDM_FILE_RENAME, TEXT("Rename")));

View File

@ -94,6 +94,7 @@ static const WinMenuKeyDefinition winKeyDefs[] =
{ VK_NULL, IDM_FILE_CLOSEALL_BUT_CURRENT, false, false, false, nullptr }, { VK_NULL, IDM_FILE_CLOSEALL_BUT_CURRENT, false, false, false, nullptr },
{ VK_NULL, IDM_FILE_CLOSEALL_TOLEFT, false, false, false, nullptr }, { VK_NULL, IDM_FILE_CLOSEALL_TOLEFT, false, false, false, nullptr },
{ VK_NULL, IDM_FILE_CLOSEALL_TORIGHT, false, false, false, nullptr }, { VK_NULL, IDM_FILE_CLOSEALL_TORIGHT, false, false, false, nullptr },
{ VK_NULL, IDM_FILE_CLOSEALL_UNCHANGED, false, false, false, nullptr },
{ VK_NULL, IDM_FILE_DELETE, false, false, false, nullptr }, { VK_NULL, IDM_FILE_DELETE, false, false, false, nullptr },
{ VK_NULL, IDM_FILE_LOADSESSION, false, false, false, nullptr }, { VK_NULL, IDM_FILE_LOADSESSION, false, false, false, nullptr },
{ VK_NULL, IDM_FILE_SAVESESSION, false, false, false, nullptr }, { VK_NULL, IDM_FILE_SAVESESSION, false, false, false, nullptr },

View File

@ -372,26 +372,27 @@ static const int tabContextMenuItemPos[] =
// | | // | |
0, // 0 : Close 0, // 0 : Close
1, // 1 : Close ALL BUT This 1, // 1 : Close ALL BUT This
4, // 2 : Save 5, // 2 : Save
5, // 3 : Save As 6, // 3 : Save As
9, // 4 : Print 10, // 4 : Print
23, // 5 : Move to Other View 24, // 5 : Move to Other View
24, // 6 : Clone to Other View 25, // 6 : Clone to Other View
19, // 7 : Full File Path to Clipboard 20, // 7 : Full File Path to Clipboard
20, // 8 : Filename to Clipboard 21, // 8 : Filename to Clipboard
21, // 9 : Current Dir. Path to Clipboard 22, // 9 : Current Dir. Path to Clipboard
6, // 10: Rename 7, // 10: Rename
7, // 11: Move to Recycle Bin 8, // 11: Move to Recycle Bin
16, // 12: Read-Only 17, // 12: Read-Only
17, // 13: Clear Read-Only Flag 18, // 13: Clear Read-Only Flag
25, // 14: Move to New Instance 26, // 14: Move to New Instance
26, // 15: Open to New Instance 27, // 15: Open to New Instance
8, // 16: Reload 9, // 16: Reload
2, // 17: Close ALL to the Left 2, // 17: Close ALL to the Left
3, // 18: Close ALL to the Right 3, // 18: Close ALL to the Right
11, // 19: Open Containing Folder in Explorer 12, // 19: Open Containing Folder in Explorer
12, // 20: Open Containing Folder in cmd 13, // 20: Open Containing Folder in cmd
14, // 21: Open in Default Viewer 15, // 21: Open in Default Viewer
4, // 22: Close ALL Unchanged
-1 //-------End -1 //-------End
}; };

View File

@ -57,10 +57,11 @@
#define IDM_FILE_RESTORELASTCLOSEDFILE (IDM_FILE + 21) #define IDM_FILE_RESTORELASTCLOSEDFILE (IDM_FILE + 21)
#define IDM_FILE_OPENFOLDERASWORSPACE (IDM_FILE + 22) #define IDM_FILE_OPENFOLDERASWORSPACE (IDM_FILE + 22)
#define IDM_FILE_OPEN_DEFAULT_VIEWER (IDM_FILE + 23) #define IDM_FILE_OPEN_DEFAULT_VIEWER (IDM_FILE + 23)
#define IDM_FILE_CLOSEALL_UNCHANGED (IDM_FILE + 24)
// IMPORTANT: If list above is modified, you have to change the following values: // IMPORTANT: If list above is modified, you have to change the following values:
// To be updated if new menu item(s) is (are) added in menu "File" // To be updated if new menu item(s) is (are) added in menu "File"
#define IDM_FILEMENU_LASTONE IDM_FILE_OPEN_DEFAULT_VIEWER #define IDM_FILEMENU_LASTONE IDM_FILE_CLOSEALL_UNCHANGED
// 0 based position of command "Exit" including the bars in the file menu // 0 based position of command "Exit" including the bars in the file menu
// and without counting "Recent files history" items // and without counting "Recent files history" items