[ENHANCE] Make extension column optional in vertical file switcher.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1170 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
4c6ea9795e
commit
6e9b5a64b1
|
@ -391,6 +391,10 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
|||
// INT NPPM_GETCURRENTVIEW(0, 0)
|
||||
// Return: current edit view of Notepad++. Only 2 possible values: 0 = Main, 1 = Secondary
|
||||
|
||||
#define NPPM_DOCSWITCHERDISABLECOLUMN (NPPMSG + 89)
|
||||
// VOID NPPM_DOCSWITCHERDISABLECOLUMN(0, BOOL disableOrNot)
|
||||
// Disable or enable extension column of doc switcher
|
||||
|
||||
#define RUNCOMMAND_USER (WM_USER + 3000)
|
||||
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
|
||||
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)
|
||||
|
|
|
@ -1854,6 +1854,20 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||
return langDesc.length();
|
||||
}
|
||||
|
||||
case NPPM_DOCSWITCHERDISABLECOLUMN:
|
||||
{
|
||||
BOOL isOff = lParam;
|
||||
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
|
||||
nppGUI._fileSwitcherWithoutExtColumn = isOff == TRUE;
|
||||
|
||||
if (_pFileSwitcherPanel)
|
||||
{
|
||||
_pFileSwitcherPanel->reload();
|
||||
}
|
||||
// else nothing to do
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case NPPM_SHOWDOCSWITCHER:
|
||||
{
|
||||
BOOL toShow = lParam;
|
||||
|
|
|
@ -4129,6 +4129,14 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
|||
val = 0;
|
||||
_nppGUI._multiInstSetting = (MultiInstSetting)val;
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("MISC")))
|
||||
{
|
||||
const TCHAR * optName = element->Attribute(TEXT("fileSwitcherWithoutExtColumn"));
|
||||
if (optName && !lstrcmp(optName, TEXT("yes")))
|
||||
{
|
||||
_nppGUI._fileSwitcherWithoutExtColumn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4477,6 +4485,7 @@ bool NppParameters::writeGUIParams()
|
|||
bool stylerThemeExist = false;
|
||||
bool delimiterSelectionExist = false;
|
||||
bool multiInstExist = false;
|
||||
bool miscExist = false;
|
||||
|
||||
TiXmlNode *dockingParamNode = NULL;
|
||||
|
||||
|
@ -4847,6 +4856,13 @@ bool NppParameters::writeGUIParams()
|
|||
childNode->InsertEndChild(hist_element);
|
||||
}
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("MISC")))
|
||||
{
|
||||
miscExist = true;
|
||||
|
||||
const TCHAR * pStr = _nppGUI._fileSwitcherWithoutExtColumn?TEXT("yes"):TEXT("no");
|
||||
element->SetAttribute(TEXT("fileSwitcherWithoutExtColumn"), pStr);
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("sessionExt")))
|
||||
{
|
||||
sessionExtExist = true;
|
||||
|
@ -5144,7 +5160,13 @@ bool NppParameters::writeGUIParams()
|
|||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("multiInst"));
|
||||
GUIConfigElement->SetAttribute(TEXT("setting"), _nppGUI._multiInstSetting);
|
||||
}
|
||||
|
||||
if (!miscExist)
|
||||
{
|
||||
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
||||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("MISC"));
|
||||
|
||||
GUIConfigElement->SetAttribute(TEXT("fileSwitcherWithoutExtColumn"), _nppGUI._fileSwitcherWithoutExtColumn?TEXT("yes"):TEXT("no"));
|
||||
}
|
||||
insertDockingParamNode(GUIRoot);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -310,7 +310,6 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
|||
bool showStatus = nppGUI._statusBarShow;
|
||||
bool showMenu = nppGUI._menuBarShow;
|
||||
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_HIDE, BM_SETCHECK, showTool?BST_UNCHECKED:BST_CHECKED, 0);
|
||||
int ID2Check = 0;
|
||||
switch (tbStatus)
|
||||
|
@ -394,6 +393,12 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
|||
::SendMessage(::GetParent(_hParent), NPPM_SHOWDOCSWITCHER, 0, isChecked?TRUE:FALSE);
|
||||
}
|
||||
return TRUE;
|
||||
case IDC_CHECK_DOCSWITCH_NOEXTCOLUMN :
|
||||
{
|
||||
bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_DOCSWITCH_NOEXTCOLUMN, BM_GETCHECK, 0, 0));
|
||||
::SendMessage(::GetParent(_hParent), NPPM_DOCSWITCHERDISABLECOLUMN, 0, isChecked?TRUE:FALSE);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case IDC_CHECK_TAB_HIDE :
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "VerticalFileSwitcher.h"
|
||||
#include "menuCmdID.h"
|
||||
#include "Parameters.h"
|
||||
#include "localization.h"
|
||||
//#include "localization.h"
|
||||
|
||||
int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
||||
{
|
||||
|
@ -61,17 +61,6 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||
case WM_INITDIALOG :
|
||||
{
|
||||
_fileListView.init(_hInst, _hSelf, _hImaLst);
|
||||
NppParameters *nppParams = NppParameters::getInstance();
|
||||
NativeLangSpeaker *pNativeSpeaker = nppParams->getNativeLangSpeaker();
|
||||
generic_string nameStr = pNativeSpeaker->getAttrNameStr(TEXT("Name"), FS_ROOTNODE, FS_CLMNNAME);
|
||||
_fileListView.insertColumn(nameStr.c_str(), 150, 0);
|
||||
|
||||
bool isExtColumn = nppParams->getNppGUI()._fileSwitcherWithoutExtColumn;
|
||||
if (isExtColumn)
|
||||
{
|
||||
generic_string extStr = pNativeSpeaker->getAttrNameStr(TEXT("Ext."), FS_ROOTNODE, FS_CLMNEXT);
|
||||
_fileListView.insertColumn(extStr.c_str(), 50, 1);
|
||||
}
|
||||
_fileListView.initList();
|
||||
_fileListView.display();
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@
|
|||
#include "VerticalFileSwitcherListView.h"
|
||||
|
||||
#define FS_PROJECTPANELTITLE TEXT("Doc Switcher")
|
||||
#define FS_ROOTNODE "DocSwitcher"
|
||||
#define FS_CLMNNAME "ColumnName"
|
||||
#define FS_CLMNEXT "ColumnExt"
|
||||
|
||||
class VerticalFileSwitcher : public DockingDlgInterface {
|
||||
public:
|
||||
|
@ -92,6 +89,12 @@ public:
|
|||
return _fileListView.getSelectedFiles(reverse);
|
||||
};
|
||||
|
||||
void reload(){
|
||||
_fileListView.deleteColumn(1);
|
||||
_fileListView.deleteColumn(0);
|
||||
_fileListView.reload();
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
|
|
@ -29,6 +29,11 @@
|
|||
#include "precompiledHeaders.h"
|
||||
#include "VerticalFileSwitcherListView.h"
|
||||
#include "Buffer.h"
|
||||
#include "localization.h"
|
||||
|
||||
#define FS_ROOTNODE "DocSwitcher"
|
||||
#define FS_CLMNNAME "ColumnName"
|
||||
#define FS_CLMNEXT "ColumnExt"
|
||||
|
||||
void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst)
|
||||
{
|
||||
|
@ -94,7 +99,21 @@ LRESULT VerticalFileSwitcherListView::runProc(HWND hwnd, UINT Message, WPARAM wP
|
|||
void VerticalFileSwitcherListView::initList()
|
||||
{
|
||||
TaskListInfo taskListInfo;
|
||||
::SendMessage(::GetParent(_hParent), WM_GETTASKLISTINFO, (WPARAM)&taskListInfo, TRUE);
|
||||
static HWND nppHwnd = ::GetParent(_hParent);
|
||||
::SendMessage(nppHwnd, WM_GETTASKLISTINFO, (WPARAM)&taskListInfo, TRUE);
|
||||
|
||||
NppParameters *nppParams = NppParameters::getInstance();
|
||||
NativeLangSpeaker *pNativeSpeaker = nppParams->getNativeLangSpeaker();
|
||||
generic_string nameStr = pNativeSpeaker->getAttrNameStr(TEXT("Name"), FS_ROOTNODE, FS_CLMNNAME);
|
||||
insertColumn(nameStr.c_str(), 150, 0);
|
||||
|
||||
bool isExtColumn = !nppParams->getNppGUI()._fileSwitcherWithoutExtColumn;
|
||||
if (isExtColumn)
|
||||
{
|
||||
generic_string extStr = pNativeSpeaker->getAttrNameStr(TEXT("Ext."), FS_ROOTNODE, FS_CLMNEXT);
|
||||
insertColumn(extStr.c_str(), 50, 1);
|
||||
}
|
||||
|
||||
for (size_t i = 0, len = taskListInfo._tlfsLst.size(); i < len ; ++i)
|
||||
{
|
||||
TaskLstFnStatus & fileNameStatus = taskListInfo._tlfsLst[i];
|
||||
|
@ -103,7 +122,7 @@ void VerticalFileSwitcherListView::initList()
|
|||
|
||||
TCHAR fn[MAX_PATH];
|
||||
lstrcpy(fn, ::PathFindFileName(fileNameStatus._fn.c_str()));
|
||||
bool isExtColumn = (NppParameters::getInstance())->getNppGUI()._fileSwitcherWithoutExtColumn;
|
||||
|
||||
if (isExtColumn)
|
||||
{
|
||||
::PathRemoveExtension(fn);
|
||||
|
@ -124,6 +143,12 @@ void VerticalFileSwitcherListView::initList()
|
|||
}
|
||||
}
|
||||
|
||||
void VerticalFileSwitcherListView::reload()
|
||||
{
|
||||
removeAll();
|
||||
initList();
|
||||
}
|
||||
|
||||
int VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view) const
|
||||
{
|
||||
int nbItem = ListView_GetItemCount(_hSelf);
|
||||
|
@ -156,7 +181,7 @@ void VerticalFileSwitcherListView::setItemIconStatus(int bufferID)
|
|||
|
||||
TCHAR fn[MAX_PATH];
|
||||
lstrcpy(fn, ::PathFindFileName(buf->getFileName()));
|
||||
bool isExtColumn = (NppParameters::getInstance())->getNppGUI()._fileSwitcherWithoutExtColumn;
|
||||
bool isExtColumn = !(NppParameters::getInstance())->getNppGUI()._fileSwitcherWithoutExtColumn;
|
||||
if (isExtColumn)
|
||||
{
|
||||
::PathRemoveExtension(fn);
|
||||
|
@ -236,7 +261,7 @@ int VerticalFileSwitcherListView::add(int bufferID, int iView)
|
|||
|
||||
TCHAR fn[MAX_PATH];
|
||||
lstrcpy(fn, ::PathFindFileName(fileName));
|
||||
bool isExtColumn = (NppParameters::getInstance())->getNppGUI()._fileSwitcherWithoutExtColumn;
|
||||
bool isExtColumn = !(NppParameters::getInstance())->getNppGUI()._fileSwitcherWithoutExtColumn;
|
||||
if (isExtColumn)
|
||||
{
|
||||
::PathRemoveExtension(fn);
|
||||
|
@ -272,6 +297,16 @@ void VerticalFileSwitcherListView::remove(int index)
|
|||
ListView_DeleteItem(_hSelf, index);
|
||||
}
|
||||
|
||||
void VerticalFileSwitcherListView::removeAll()
|
||||
{
|
||||
int nbItem = ListView_GetItemCount(_hSelf);
|
||||
|
||||
for (int i = nbItem - 1; i >= 0 ; --i)
|
||||
{
|
||||
remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
int VerticalFileSwitcherListView::find(int bufferID, int iView) const
|
||||
{
|
||||
LVITEM item;
|
||||
|
|
|
@ -61,11 +61,15 @@ public:
|
|||
generic_string getFullFilePath(size_t i) const;
|
||||
|
||||
void insertColumn(const TCHAR *name, int width, int index);
|
||||
void deleteColumn(size_t i) {
|
||||
ListView_DeleteColumn(_hSelf, i);
|
||||
};
|
||||
int nbSelectedFiles() const {
|
||||
return SendMessage(_hSelf, LVM_GETSELECTEDCOUNT, 0, 0);
|
||||
};
|
||||
|
||||
std::vector<SwitcherFileInfo> getSelectedFiles(bool reverse = false) const;
|
||||
void reload();
|
||||
|
||||
protected:
|
||||
HIMAGELIST _hImaLst;
|
||||
|
@ -79,6 +83,7 @@ protected:
|
|||
int find(int bufferID, int iView) const;
|
||||
int add(int bufferID, int iView);
|
||||
void remove(int index);
|
||||
void removeAll();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue