[NEW_FEATURE] (Author: Andreas Jonsson) Add "close all tab to left" and "close all tab to right" features.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1097 f5eea248-9336-0410-98b8-ebc06183d4e3remotes/trunk
parent
e172c69700
commit
082253c37f
|
@ -279,6 +279,9 @@
|
||||||
<Item CMID="13" name="移除檔案唯讀屬性"/>
|
<Item CMID="13" name="移除檔案唯讀屬性"/>
|
||||||
<Item CMID="14" name="將此檔案移至新啟動的 Notepad++"/>
|
<Item CMID="14" name="將此檔案移至新啟動的 Notepad++"/>
|
||||||
<Item CMID="15" name="開啟此檔案到新啟動的 Notepad++"/>
|
<Item CMID="15" name="開啟此檔案到新啟動的 Notepad++"/>
|
||||||
|
<Item CMID="16" name="重新載入"/>
|
||||||
|
<Item CMID="17" name="關閉左邊所有檔案"/>
|
||||||
|
<Item CMID="18" name="關閉右邊所有檔案"/>
|
||||||
</TabBar>
|
</TabBar>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
|
|
|
@ -278,6 +278,8 @@
|
||||||
<Item CMID="14" name="Move to New Instance"/>
|
<Item CMID="14" name="Move to New Instance"/>
|
||||||
<Item CMID="15" name="Open in New Instance"/>
|
<Item CMID="15" name="Open in New Instance"/>
|
||||||
<Item CMID="16" name="Reload"/>
|
<Item CMID="16" name="Reload"/>
|
||||||
|
<Item CMID="17" name="Close All to the Left"/>
|
||||||
|
<Item CMID="18" name="Close All to the Right"/>
|
||||||
</TabBar>
|
</TabBar>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
|
|
|
@ -278,6 +278,8 @@
|
||||||
<Item CMID="14" name="Move to New Instance"/>
|
<Item CMID="14" name="Move to New Instance"/>
|
||||||
<Item CMID="15" name="Open in New Instance"/>
|
<Item CMID="15" name="Open in New Instance"/>
|
||||||
<Item CMID="16" name="Reload"/>
|
<Item CMID="16" name="Reload"/>
|
||||||
|
<Item CMID="17" name="Close All to the Left"/>
|
||||||
|
<Item CMID="18" name="Close All to the Right"/>
|
||||||
</TabBar>
|
</TabBar>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,8 @@
|
||||||
<Item CMID="14" name="Déplacer vers une nouvelle fenêtre"/>
|
<Item CMID="14" name="Déplacer vers une nouvelle fenêtre"/>
|
||||||
<Item CMID="15" name="Ouvrir dans une nouvelle fenêtre"/>
|
<Item CMID="15" name="Ouvrir dans une nouvelle fenêtre"/>
|
||||||
<Item CMID="16" name="Recharger"/>
|
<Item CMID="16" name="Recharger"/>
|
||||||
|
<Item CMID="17" name="Fermer les onglets sur la gauche"/>
|
||||||
|
<Item CMID="18" name="Fermer les onglets sur la droite"/>
|
||||||
</TabBar>
|
</TabBar>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Dialog>
|
<Dialog>
|
||||||
|
|
|
@ -125,6 +125,7 @@
|
||||||
#endif //SIZE_DLG_H
|
#endif //SIZE_DLG_H
|
||||||
|
|
||||||
#include "localization.h"
|
#include "localization.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#define MENU 0x01
|
#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 fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from
|
||||||
bool fileCloseAll();
|
bool fileCloseAll();
|
||||||
bool fileCloseAllButCurrent();
|
bool fileCloseAllButCurrent();
|
||||||
|
bool fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes);
|
||||||
|
bool fileCloseAllToLeft();
|
||||||
|
bool fileCloseAllToRight();
|
||||||
bool fileSave(BufferID id = BUFFER_INVALID);
|
bool fileSave(BufferID id = BUFFER_INVALID);
|
||||||
bool fileSaveAll();
|
bool fileSaveAll();
|
||||||
bool fileSaveAs(BufferID id = BUFFER_INVALID, bool isSaveCopy = false);
|
bool fileSaveAs(BufferID id = BUFFER_INVALID, bool isSaveCopy = false);
|
||||||
|
|
|
@ -209,7 +209,12 @@ BEGIN
|
||||||
MENUITEM "Rename...", IDM_FILE_RENAME
|
MENUITEM "Rename...", IDM_FILE_RENAME
|
||||||
MENUITEM "&Close", IDM_FILE_CLOSE
|
MENUITEM "&Close", IDM_FILE_CLOSE
|
||||||
MENUITEM "Clos&e All", IDM_FILE_CLOSEALL
|
MENUITEM "Clos&e All", IDM_FILE_CLOSEALL
|
||||||
|
POPUP "Close More"
|
||||||
|
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 Right", IDM_FILE_CLOSEALL_TORIGHT
|
||||||
|
END
|
||||||
MENUITEM "Move to Recycle Bin", IDM_FILE_DELETE
|
MENUITEM "Move to Recycle Bin", IDM_FILE_DELETE
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Load Session...", IDM_FILE_LOADSESSION
|
MENUITEM "Load Session...", IDM_FILE_LOADSESSION
|
||||||
|
|
|
@ -112,6 +112,16 @@ void Notepad_plus::command(int id)
|
||||||
checkDocState();
|
checkDocState();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDM_FILE_CLOSEALL_TOLEFT :
|
||||||
|
fileCloseAllToLeft();
|
||||||
|
checkDocState();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_FILE_CLOSEALL_TORIGHT :
|
||||||
|
fileCloseAllToRight();
|
||||||
|
checkDocState();
|
||||||
|
break;
|
||||||
|
|
||||||
case IDM_FILE_SAVE :
|
case IDM_FILE_SAVE :
|
||||||
fileSave();
|
fileSave();
|
||||||
break;
|
break;
|
||||||
|
@ -2491,6 +2501,8 @@ void Notepad_plus::command(int id)
|
||||||
case IDM_FILE_CLOSE :
|
case IDM_FILE_CLOSE :
|
||||||
case IDM_FILE_CLOSEALL :
|
case IDM_FILE_CLOSEALL :
|
||||||
case IDM_FILE_CLOSEALL_BUT_CURRENT :
|
case IDM_FILE_CLOSEALL_BUT_CURRENT :
|
||||||
|
case IDM_FILE_CLOSEALL_TOLEFT :
|
||||||
|
case IDM_FILE_CLOSEALL_TORIGHT :
|
||||||
case IDM_FILE_SAVE :
|
case IDM_FILE_SAVE :
|
||||||
case IDM_FILE_SAVEALL :
|
case IDM_FILE_SAVEALL :
|
||||||
case IDM_FILE_RELOAD:
|
case IDM_FILE_RELOAD:
|
||||||
|
|
|
@ -638,6 +638,77 @@ bool Notepad_plus::fileCloseAll()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Notepad_plus::fileCloseAllGiven(const std::vector<int> &krvecBufferIndexes)
|
||||||
|
{
|
||||||
|
// First check if we need to save any file.
|
||||||
|
|
||||||
|
std::vector<int>::const_iterator itIndexesEnd = krvecBufferIndexes.end();
|
||||||
|
|
||||||
|
for(std::vector<int>::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<int>::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<int> 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<int> vecIndexesToClose;
|
||||||
|
for(int i = _pDocTab->nbItem() - 1; i > kiActive; i--) {
|
||||||
|
vecIndexesToClose.push_back(i);
|
||||||
|
}
|
||||||
|
return fileCloseAllGiven(vecIndexesToClose);
|
||||||
|
}
|
||||||
|
|
||||||
bool Notepad_plus::fileCloseAllButCurrent()
|
bool Notepad_plus::fileCloseAllButCurrent()
|
||||||
{
|
{
|
||||||
BufferID current = _pEditView->getCurrentBufferID();
|
BufferID current = _pEditView->getCurrentBufferID();
|
||||||
|
|
|
@ -332,6 +332,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||||
vector<MenuItemUnit> itemUnitArray;
|
vector<MenuItemUnit> itemUnitArray;
|
||||||
itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSE, TEXT("Close")));
|
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_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_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")));
|
||||||
|
|
|
@ -70,6 +70,8 @@ WinMenuKeyDefinition winKeyDefs[] = {
|
||||||
{VK_W, IDM_FILE_CLOSE, true, false, false, NULL},
|
{VK_W, IDM_FILE_CLOSE, true, false, false, NULL},
|
||||||
{VK_NULL, IDM_FILE_CLOSEALL, false, 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_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_DELETE, false, false, false, NULL},
|
||||||
{VK_NULL, IDM_FILE_RENAME, false, false, false, NULL},
|
{VK_NULL, IDM_FILE_RENAME, false, false, false, NULL},
|
||||||
{VK_NULL, IDM_FILE_LOADSESSION, false, false, false, NULL},
|
{VK_NULL, IDM_FILE_LOADSESSION, false, false, false, NULL},
|
||||||
|
|
|
@ -367,22 +367,23 @@ void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & plugin
|
||||||
int tabContextMenuItemPos[] = {
|
int tabContextMenuItemPos[] = {
|
||||||
0, // 0 : Close
|
0, // 0 : Close
|
||||||
1, // 1 : Close ALL BUT This
|
1, // 1 : Close ALL BUT This
|
||||||
2, // 2 : Save
|
4, // 2 : Save
|
||||||
3, // 3 : Save As
|
5, // 3 : Save As
|
||||||
7, // 4 : Print
|
9, // 4 : Print
|
||||||
16,// 5 : Move to Other View
|
18,// 5 : Move to Other View
|
||||||
17,// 6 : Clone to Other View
|
19,// 6 : Clone to Other View
|
||||||
12,// 7 : Full File Path to Clipboard
|
14,// 7 : Full File Path to Clipboard
|
||||||
13,// 8 : Filename to Clipboard
|
15,// 8 : Filename to Clipboard
|
||||||
14,// 9 : Current Dir. Path to Clipboard
|
16,// 9 : Current Dir. Path to Clipboard
|
||||||
4, // 10: Rename
|
6, // 10: Rename
|
||||||
5, // 11: Delete
|
7, // 11: Delete
|
||||||
9, // 12: Read-Only
|
11, // 12: Read-Only
|
||||||
10,// 13: Clear Read-Only Flag
|
12,// 13: Clear Read-Only Flag
|
||||||
18,// 14: Move to New Instance
|
20,// 14: Move to New Instance
|
||||||
19,// 15: Open to New Instance
|
21,// 15: Open to New Instance
|
||||||
6, // 16: Reload
|
8, // 16: Reload
|
||||||
|
2, // 17 : Close ALL to the Left
|
||||||
|
3, // 18 : Close ALL to the Right
|
||||||
-1 //-------End
|
-1 //-------End
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
#define IDM_FILE_CLOSE (IDM_FILE + 3)
|
#define IDM_FILE_CLOSE (IDM_FILE + 3)
|
||||||
#define IDM_FILE_CLOSEALL (IDM_FILE + 4)
|
#define IDM_FILE_CLOSEALL (IDM_FILE + 4)
|
||||||
#define IDM_FILE_CLOSEALL_BUT_CURRENT (IDM_FILE + 5)
|
#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_SAVE (IDM_FILE + 6)
|
||||||
#define IDM_FILE_SAVEALL (IDM_FILE + 7)
|
#define IDM_FILE_SAVEALL (IDM_FILE + 7)
|
||||||
#define IDM_FILE_SAVEAS (IDM_FILE + 8)
|
#define IDM_FILE_SAVEAS (IDM_FILE + 8)
|
||||||
|
|
Loading…
Reference in New Issue