[NEW_FEATURE] Make Recent File List totally customizable (in progress).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@781 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2011-06-27 01:23:58 +00:00
parent 16bae1a4a5
commit 9cddb4903d
15 changed files with 274 additions and 239 deletions

View File

@ -396,15 +396,13 @@ static TCHAR* convertFileName(TCHAR *buffer, const TCHAR *filename)
return buffer; return buffer;
} }
// Build Recent File menu entries from given
TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename) TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename)
{ {
TCHAR cwd[MAX_PATH];
buffer[0] = 0; buffer[0] = 0;
GetCurrentDirectory(_countof(cwd), cwd);
lstrcat(cwd, TEXT("\\"));
TCHAR *itr = buffer; TCHAR *itr = buffer;
TCHAR *end = buffer + len - 1; TCHAR *end = buffer + MAX_PATH - 1;
if (pos < 9) if (pos < 9)
{ {
*itr++ = '&'; *itr++ = '&';
@ -423,10 +421,23 @@ TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename)
} }
*itr++ = ':'; *itr++ = ':';
*itr++ = ' '; *itr++ = ' ';
if (0 == generic_strnicmp(filename, cwd, lstrlen(cwd)))
if (len > 0)
{
TCHAR cnvName[MAX_PATH*2];
convertFileName(cnvName, filename);
::PathCompactPathEx(itr, filename, len - (itr-buffer), 0);
}
else
{ {
TCHAR cnvName[MAX_PATH]; TCHAR cnvName[MAX_PATH];
const TCHAR *s1 = PathFindFileName(filename); const TCHAR *s1;
if (len == 0)
s1 = PathFindFileName(filename);
else // (len < 0)
s1 = filename;
int len = lstrlen(s1); int len = lstrlen(s1);
if (len < (end-itr)) if (len < (end-itr))
{ {
@ -441,12 +452,6 @@ TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename)
} }
convertFileName(itr, cnvName); convertFileName(itr, cnvName);
} }
else
{
TCHAR cnvName[MAX_PATH*2];
convertFileName(cnvName, filename);
PathCompactPathEx(itr, filename, len - (itr-buffer), 0);
}
return buffer; return buffer;
} }

View File

@ -430,7 +430,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
int nbLRFile = pNppParam->getNbLRFile(); int nbLRFile = pNppParam->getNbLRFile();
int pos = IDM_FILEMENU_LASTONE - IDM_FILE + 2; int pos = IDM_FILEMENU_LASTONE - IDM_FILE + 2;
_lastRecentFileList.initMenu(hFileMenu, IDM_FILEMENU_LASTONE + 1, pos, true); _lastRecentFileList.initMenu(hFileMenu, IDM_FILEMENU_LASTONE + 1, pos, pNppParam->putRecentFileInSubMenu());
_lastRecentFileList.setLangEncoding(_nativeLangSpeaker.getLangEncoding()); _lastRecentFileList.setLangEncoding(_nativeLangSpeaker.getLangEncoding());
for (int i = 0 ; i < nbLRFile ; i++) for (int i = 0 ; i < nbLRFile ; i++)
{ {
@ -1992,6 +1992,7 @@ void Notepad_plus::MaintainIndentation(TCHAR ch)
} }
} }
} }
void Notepad_plus::specialCmd(int id) void Notepad_plus::specialCmd(int id)
{ {
NppParameters *pNppParam = NppParameters::getInstance(); NppParameters *pNppParam = NppParameters::getInstance();
@ -2070,28 +2071,6 @@ void Notepad_plus::specialCmd(int id)
break; break;
} }
case IDM_SETTING_EDGE_SIZE :
{
ValueDlg nbColumnEdgeDlg;
ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP();
nbColumnEdgeDlg.init(_pPublicInterface->getHinst(), _preference.getHSelf(), svp._edgeNbColumn, TEXT("Nb of column:"));
nbColumnEdgeDlg.setNBNumber(3);
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_pPublicInterface->getHParent(), &p);
int size = nbColumnEdgeDlg.doDialog(p, _nativeLangSpeaker.isRTL());
if (size != -1)
{
svp._edgeNbColumn = size;
_mainEditView.execute(SCI_SETEDGECOLUMN, size);
_subEditView.execute(SCI_SETEDGECOLUMN, size);
}
break;
}
case IDM_VIEW_LWDEF: case IDM_VIEW_LWDEF:
case IDM_VIEW_LWALIGN: case IDM_VIEW_LWALIGN:
case IDM_VIEW_LWINDENT: case IDM_VIEW_LWINDENT:

View File

@ -1786,6 +1786,44 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return langDesc.length(); return langDesc.length();
} }
//
// These are sent by Preferences Dialog
//
case NPPM_INTERNAL_SETTING_HISTORY_SIZE:
{
NppParameters *pNppParam = NppParameters::getInstance();
_lastRecentFileList.setUserMaxNbLRF(pNppParam->getNbMaxRecentFile());
break;
}
case NPPM_INTERNAL_SETTING_EDGE_SIZE :
{
ScintillaViewParams & svp = (ScintillaViewParams &)(NppParameters::getInstance())->getSVP();
_mainEditView.execute(SCI_SETEDGECOLUMN, svp._edgeNbColumn);
_subEditView.execute(SCI_SETEDGECOLUMN, svp._edgeNbColumn);
break;
}
case NPPM_INTERNAL_SETTING_TAB_REPLCESPACE:
case NPPM_INTERNAL_SETTING_TAB_SIZE:
{
_pEditView->setTabSettings(_pEditView->getCurrentBuffer()->getCurrentLang());
break;
}
case NPPM_INTERNAL_RECENTFILELIST_UPDATE:
{
_lastRecentFileList.updateMenu();
break;
}
case NPPM_INTERNAL_RECENTFILELIST_SWITCH:
{
_lastRecentFileList.switchMode();
_lastRecentFileList.updateMenu();
break;
}
case WM_INITMENUPOPUP: case WM_INITMENUPOPUP:
{ {
_windowsMenu.initPopupMenu((HMENU)wParam, _pDocTab); _windowsMenu.initPopupMenu((HMENU)wParam, _pDocTab);

View File

@ -1758,57 +1758,6 @@ void Notepad_plus::command(int id)
break; break;
} }
*/ */
case IDM_SETTING_TAB_REPLCESPACE:
case IDM_SETTING_TAB_SIZE:
{
_pEditView->setTabSettings(_pEditView->getCurrentBuffer()->getCurrentLang());
break;
}
case IDM_SETTING_AUTOCNBCHAR:
{
const int NB_MIN_CHAR = 1;
const int NB_MAX_CHAR = 9;
ValueDlg valDlg;
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
valDlg.init(_pPublicInterface->getHinst(), _preference.getHSelf(), nppGUI._autocFromLen, TEXT("Nb char : "));
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_pPublicInterface->getHParent(), &p);
int size = valDlg.doDialog(p, _nativeLangSpeaker.isRTL());
if (size != -1)
{
if (size > NB_MAX_CHAR)
size = NB_MAX_CHAR;
else if (size < NB_MIN_CHAR)
size = NB_MIN_CHAR;
nppGUI._autocFromLen = size;
}
break;
}
case IDM_SETTING_HISTORY_SIZE :
{
ValueDlg nbHistoryDlg;
NppParameters *pNppParam = NppParameters::getInstance();
nbHistoryDlg.init(_pPublicInterface->getHinst(), _preference.getHSelf(), pNppParam->getNbMaxRecentFile(), TEXT("Max File : "));
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_pPublicInterface->getHParent(), &p);
int size = nbHistoryDlg.doDialog(p, _nativeLangSpeaker.isRTL());
if (size != -1)
{
if (size > NB_MAX_LRF_FILE)
size = NB_MAX_LRF_FILE;
pNppParam->setNbMaxRecentFile(size);
_lastRecentFileList.setUserMaxNbLRF(size);
}
break;
}
case IDM_SETTING_IMPORTPLUGIN : case IDM_SETTING_IMPORTPLUGIN :
{ {

View File

@ -1696,15 +1696,23 @@ void NppParameters::feedFileListParameters(TiXmlNode *node)
TiXmlNode *historyRoot = node->FirstChildElement(TEXT("History")); TiXmlNode *historyRoot = node->FirstChildElement(TEXT("History"));
if (!historyRoot) return; if (!historyRoot) return;
// nbMaxFile value
int nbMaxFile; int nbMaxFile;
const TCHAR *nbMaxFileStr = (historyRoot->ToElement())->Attribute(TEXT("nbMaxFile"), &nbMaxFile); const TCHAR *strVal = (historyRoot->ToElement())->Attribute(TEXT("nbMaxFile"), &nbMaxFile);
if (strVal && (nbMaxFile > 0) && (nbMaxFile <= 50))
if ((nbMaxFile < 0) || (nbMaxFile > 50))
return;
if (nbMaxFileStr)
_nbMaxRecentFile = nbMaxFile; _nbMaxRecentFile = nbMaxFile;
// customLen value
int customLen;
strVal = (historyRoot->ToElement())->Attribute(TEXT("customLength"), &customLen);
if (strVal)
_recentFileCustomLength = customLen;
// inSubMenu value
strVal = (historyRoot->ToElement())->Attribute(TEXT("inSubMenu"));
if (lstrcmp(strVal, TEXT("yes")) == 0)
_putRecentFileInSubMenu = true;
for (TiXmlNode *childNode = historyRoot->FirstChildElement(TEXT("File")); for (TiXmlNode *childNode = historyRoot->FirstChildElement(TEXT("File"));
childNode && (_nbRecentFile < NB_MAX_LRF_FILE); childNode && (_nbRecentFile < NB_MAX_LRF_FILE);
childNode = childNode->NextSibling(TEXT("File")) ) childNode = childNode->NextSibling(TEXT("File")) )
@ -2717,6 +2725,22 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode)
_nbStyler++; _nbStyler++;
} }
bool NppParameters::writeRecentFileHistorySettings(int nbMaxFile) const
{
if (!_pXmlUserDoc) return false;
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus"));
if (!nppRoot) return false;
TiXmlNode *historyNode = nppRoot->FirstChildElement(TEXT("History"));
if (!historyNode) return false;
(historyNode->ToElement())->SetAttribute(TEXT("nbMaxFile"), nbMaxFile!=-1?nbMaxFile:_nbMaxRecentFile);
(historyNode->ToElement())->SetAttribute(TEXT("inSubMenu"), _putRecentFileInSubMenu?TEXT("yes"):TEXT("no"));
(historyNode->ToElement())->SetAttribute(TEXT("customLength"), _recentFileCustomLength);
return true;
}
bool NppParameters::writeHistory(const TCHAR *fullpath) bool NppParameters::writeHistory(const TCHAR *fullpath)
{ {
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus")); TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus"));

View File

@ -1168,7 +1168,7 @@ public:
_putRecentFileInSubMenu = doSubmenu; _putRecentFileInSubMenu = doSubmenu;
}; };
int putRecentFileInSubMenu() const {return _putRecentFileInSubMenu;}; bool putRecentFileInSubMenu() const {return _putRecentFileInSubMenu;};
void setRecentFileCustomLength(int len) { void setRecentFileCustomLength(int len) {
_recentFileCustomLength = len; _recentFileCustomLength = len;
@ -1181,19 +1181,7 @@ public:
return _svp; return _svp;
}; };
bool writeNbHistoryFile(int nb) { bool writeRecentFileHistorySettings(int nbMaxFile = -1) const;
if (!_pXmlUserDoc) return false;
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus"));
if (!nppRoot) return false;
TiXmlNode *historyNode = nppRoot->FirstChildElement(TEXT("History"));
if (!historyNode) return false;
(historyNode->ToElement())->SetAttribute(TEXT("nbMaxFile"), nb);
return true;
};
bool writeHistory(const TCHAR *fullpath); bool writeHistory(const TCHAR *fullpath);
TiXmlNode * getChildElementByAttribut(TiXmlNode *pere, const TCHAR *childName,\ TiXmlNode * getChildElementByAttribut(TiXmlNode *pere, const TCHAR *childName,\
@ -1304,8 +1292,6 @@ public:
int addExternalLangToEnd(ExternalLangContainer * externalLang); int addExternalLangToEnd(ExternalLangContainer * externalLang);
//TiXmlDocument * getNativeLang() const {return _pXmlNativeLangDoc;};
TiXmlDocumentA * getNativeLangA() const {return _pXmlNativeLangDocA;}; TiXmlDocumentA * getNativeLangA() const {return _pXmlNativeLangDocA;};
TiXmlDocument * getToolIcons() const {return _pXmlToolIconsDoc;}; TiXmlDocument * getToolIcons() const {return _pXmlToolIconsDoc;};

View File

@ -484,8 +484,6 @@ size_t Printer::doPrint(bool justDoIt)
break; break;
} }
//TCHAR toto[10];
//::MessageBox(NULL, itoa(pageNum, toto, 10), TEXT("page total"), MB_OK);
if (!nppGUI._printSettings._printLineNumber) if (!nppGUI._printSettings._printLineNumber)
_pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, isShown); _pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, isShown);

View File

@ -436,9 +436,7 @@ void MarginsDlg::initScintParam()
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_BGMODE), isEnable); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_BGMODE), isEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), isEnable); ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), isEnable);
TCHAR nbColStr[10]; ::SetDlgItemInt(_hSelf, IDC_COLONENUMBER_STATIC, svp._edgeNbColumn, FALSE);
wsprintf(nbColStr, TEXT("%d"), svp._edgeNbColumn);
::SetWindowText(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), nbColStr);
::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), isEnable); ::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), isEnable);
} }
@ -453,7 +451,7 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
_verticalEdgeLineNbColVal.init(_hInst, _hSelf); _verticalEdgeLineNbColVal.init(_hInst, _hSelf);
_verticalEdgeLineNbColVal.create(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), IDM_SETTING_EDGE_SIZE); _verticalEdgeLineNbColVal.create(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), IDC_COLONENUMBER_STATIC);
::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("0")); ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("0"));
::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("1")); ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("1"));
@ -574,12 +572,26 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_EDGEBACKGROUND, iView); ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_EDGEBACKGROUND, iView);
return TRUE; return TRUE;
case IDM_SETTING_EDGE_SIZE: case IDC_COLONENUMBER_STATIC:
{ {
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_EDGE_SIZE, iView); ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP();
TCHAR nbColStr[10];
wsprintf(nbColStr, TEXT("%d"), svp._edgeNbColumn); ValueDlg nbColumnEdgeDlg;
::SetWindowText(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), nbColStr); nbColumnEdgeDlg.init(NULL, _hSelf, svp._edgeNbColumn, TEXT("Nb of column:"));
nbColumnEdgeDlg.setNBNumber(3);
POINT p;
::GetCursorPos(&p);
int val = nbColumnEdgeDlg.doDialog(p);
if (val != -1)
{
svp._edgeNbColumn = val;
::SetDlgItemInt(_hSelf, IDC_COLONENUMBER_STATIC, svp._edgeNbColumn, FALSE);
// Execute modified value
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_EDGE_SIZE, 0, 0);
}
return TRUE; return TRUE;
} }
@ -882,6 +894,7 @@ void DefaultNewDocDlg::setCustomLen(int val)
{ {
::EnableWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), val > 0); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), val > 0);
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, val, FALSE); ::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, val, FALSE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), val > 0?SW_SHOW:SW_HIDE);
} }
BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
@ -1009,7 +1022,7 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
// Max number recent file setting // Max number recent file setting
::SetDlgItemInt(_hSelf, IDC_MAXNBFILEVAL_STATIC, pNppParam->getNbMaxRecentFile(), FALSE); ::SetDlgItemInt(_hSelf, IDC_MAXNBFILEVAL_STATIC, pNppParam->getNbMaxRecentFile(), FALSE);
_nbHistoryVal.init(_hInst, _hSelf); _nbHistoryVal.init(_hInst, _hSelf);
_nbHistoryVal.create(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), IDM_SETTING_HISTORY_SIZE); _nbHistoryVal.create(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), IDC_MAXNBFILEVAL_STATIC);
// Check on launch time settings // Check on launch time settings
::SendDlgItemMessage(_hSelf, IDC_CHECK_DONTCHECKHISTORY, BM_SETCHECK, !nppGUI._checkHistoryFiles, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_DONTCHECKHISTORY, BM_SETCHECK, !nppGUI._checkHistoryFiles, 0);
@ -1033,12 +1046,13 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
length = 0; length = 0;
} }
::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, BST_CHECKED, 0); ::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, BST_CHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), id == IDC_RADIO_CUSTOMIZELENTH);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), id == IDC_RADIO_CUSTOMIZELENTH?SW_SHOW:SW_HIDE);
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, length, FALSE); ::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, length, FALSE);
_customLenVal.init(_hInst, _hSelf); _customLenVal.init(_hInst, _hSelf);
_customLenVal.create(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), NULL); _customLenVal.create(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), NULL);
// //
// To avoid the white control background to be displayed in dialog // To avoid the white control background to be displayed in dialog
// //
@ -1156,17 +1170,43 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
nppGUI._checkHistoryFiles = !isCheckedOrNot(IDC_CHECK_DONTCHECKHISTORY); nppGUI._checkHistoryFiles = !isCheckedOrNot(IDC_CHECK_DONTCHECKHISTORY);
return TRUE; return TRUE;
case IDC_MAXNBFILEVAL_STATIC:
{
ValueDlg nbFileMaxDlg;
nbFileMaxDlg.init(NULL, _hSelf, pNppParam->getNbMaxRecentFile(), TEXT("Max File: "));
POINT p;
::GetCursorPos(&p);
int nbMaxFile = nbFileMaxDlg.doDialog(p);
if (nbMaxFile != -1)
{
if (nbMaxFile > NB_MAX_LRF_FILE)
nbMaxFile = NB_MAX_LRF_FILE;
pNppParam->setNbMaxRecentFile(nbMaxFile);
::SetDlgItemInt(_hSelf, IDC_MAXNBFILEVAL_STATIC, nbMaxFile, FALSE);
// Validate modified value
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_HISTORY_SIZE, 0, 0);
}
return TRUE;
}
case IDC_CHECK_INSUBMENU: case IDC_CHECK_INSUBMENU:
pNppParam->setPutRecentFileInSubMenu(isCheckedOrNot(IDC_CHECK_INSUBMENU)); pNppParam->setPutRecentFileInSubMenu(isCheckedOrNot(IDC_CHECK_INSUBMENU));
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_SWITCH, 0, 0);
return TRUE; return TRUE;
case IDC_RADIO_ONLYFILENAME: case IDC_RADIO_ONLYFILENAME:
setCustomLen(0); setCustomLen(0);
pNppParam->setRecentFileCustomLength(0); pNppParam->setRecentFileCustomLength(0);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
return TRUE; return TRUE;
case IDC_RADIO_FULLFILENAMEPATH: case IDC_RADIO_FULLFILENAMEPATH:
setCustomLen(0); setCustomLen(0);
pNppParam->setRecentFileCustomLength(-1); pNppParam->setRecentFileCustomLength(-1);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
return TRUE; return TRUE;
case IDC_RADIO_CUSTOMIZELENTH: case IDC_RADIO_CUSTOMIZELENTH:
{ {
@ -1175,6 +1215,7 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{ {
setCustomLen(100); setCustomLen(100);
pNppParam->setRecentFileCustomLength(100); pNppParam->setRecentFileCustomLength(100);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
} }
return TRUE; return TRUE;
} }
@ -1183,6 +1224,8 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{ {
ValueDlg customLengthDlg; ValueDlg customLengthDlg;
customLengthDlg.init(NULL, _hSelf, pNppParam->getRecentFileCustomLength(), TEXT("Length: ")); customLengthDlg.init(NULL, _hSelf, pNppParam->getRecentFileCustomLength(), TEXT("Length: "));
customLengthDlg.setNBNumber(3);
POINT p; POINT p;
::GetCursorPos(&p); ::GetCursorPos(&p);
@ -1191,16 +1234,11 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{ {
::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, size, FALSE); ::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, size, FALSE);
pNppParam->setRecentFileCustomLength(size); pNppParam->setRecentFileCustomLength(size);
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RECENTFILELIST_UPDATE, 0, 0);
} }
return TRUE; return TRUE;
} }
case IDM_SETTING_HISTORY_SIZE:
{
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_HISTORY_SIZE, 0);
::SetDlgItemInt(_hSelf, IDC_MAXNBFILEVAL_STATIC, pNppParam->getNbMaxRecentFile(), FALSE);
return TRUE;
}
default: default:
if (HIWORD(wParam) == CBN_SELCHANGE) if (HIWORD(wParam) == CBN_SELCHANGE)
@ -1235,13 +1273,10 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
{ {
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
TCHAR nbStr[10]; ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE);
wsprintf(nbStr, TEXT("%d"), nppGUI._tabSize);
HWND hTabSize_val = ::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC);
::SetWindowText(hTabSize_val, nbStr);
_tabSizeVal.init(_hInst, _hSelf); _tabSizeVal.init(_hInst, _hSelf);
_tabSizeVal.create(hTabSize_val, IDM_SETTING_TAB_SIZE); _tabSizeVal.create(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), IDC_TABSIZEVAL_STATIC);
::SendDlgItemMessage(_hSelf, IDC_CHECK_REPLACEBYSPACE, BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_REPLACEBYSPACE, BM_SETCHECK, nppGUI._tabReplacedBySpace, 0);
int nbLang = pNppParam->getNbLang(); int nbLang = pNppParam->getNbLang();
@ -1294,7 +1329,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
{ {
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDM_SETTING_TAB_SIZE: case IDC_TABSIZEVAL_STATIC:
{ {
ValueDlg tabSizeDlg; ValueDlg tabSizeDlg;
tabSizeDlg.init(_hInst, _hParent, nppGUI._tabSize, TEXT("Tab Size : ")); tabSizeDlg.init(_hInst, _hParent, nppGUI._tabSize, TEXT("Tab Size : "));
@ -1303,10 +1338,8 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
int size = tabSizeDlg.doDialog(p); int size = tabSizeDlg.doDialog(p);
if (size == -1) return FALSE; if (size == -1) return FALSE;
TCHAR nbStr[10]; ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE);
wsprintf(nbStr, TEXT("%d"), size); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE);
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr);
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), nbStr);
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR) return FALSE; if (index == LB_ERR) return FALSE;
@ -1325,7 +1358,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
nppGUI._tabSize = size; nppGUI._tabSize = size;
} }
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_TAB_SIZE, 0); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_TAB_SIZE, 0, 0);
return TRUE; return TRUE;
} }
@ -1349,7 +1382,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
{ {
nppGUI._tabReplacedBySpace = isTabReplacedBySpace; nppGUI._tabReplacedBySpace = isTabReplacedBySpace;
} }
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_TAB_REPLCESPACE, 0); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_TAB_REPLCESPACE, 0, 0);
return TRUE; return TRUE;
} }
@ -1369,36 +1402,32 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
if (!lang) return FALSE; if (!lang) return FALSE;
bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0); bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0);
TCHAR nbStr[16];
wsprintf(nbStr, TEXT("%d"), useDefaultTab?nppGUI._tabSize:lang->_tabSize); ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab);
int size = useDefaultTab?nppGUI._tabSize:lang->_tabSize;
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE);
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr);
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), nbStr);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab);
if (!useDefaultTab) ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
{ ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab);
TCHAR nbStr[16]; ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
wsprintf(nbStr, TEXT("%d"),lang->_tabSize); ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0);
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0);
} if (!useDefaultTab)
{
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, lang->_tabSize, FALSE);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0);
} }
}
else else
{ {
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW);
TCHAR nbStr[16]; ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE);
wsprintf(nbStr, TEXT("%d"),nppGUI._tabSize);
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0);
@ -1422,12 +1451,9 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
lang->_tabSize = useDefaultTab?0:nppGUI._tabSize; lang->_tabSize = useDefaultTab?0:nppGUI._tabSize;
lang->_isTabReplacedBySpace = useDefaultTab?false:nppGUI._tabReplacedBySpace; lang->_isTabReplacedBySpace = useDefaultTab?false:nppGUI._tabReplacedBySpace;
TCHAR nbStr[16];
wsprintf(nbStr, TEXT("%d"), useDefaultTab?nppGUI._tabSize:lang->_tabSize);
//- set visual effect //- set visual effect
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab); ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab);
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, useDefaultTab?nppGUI._tabSize:lang->_tabSize, FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
@ -1617,29 +1643,16 @@ BOOL CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
} }
::SendDlgItemMessage(_hSelf, ID2Check, BM_SETCHECK, BST_CHECKED, 0); ::SendDlgItemMessage(_hSelf, ID2Check, BM_SETCHECK, BST_CHECKED, 0);
TCHAR valStrL[10]; ::SetDlgItemInt(_hSelf, IDC_EDIT_ML, nppGUI._printSettings._marge.left, FALSE);
wsprintf(valStrL, TEXT("%d"), nppGUI._printSettings._marge.left); ::SetDlgItemInt(_hSelf, IDC_EDIT_MR, nppGUI._printSettings._marge.right, FALSE);
::SetDlgItemInt(_hSelf, IDC_EDIT_MT, nppGUI._printSettings._marge.top, FALSE);
TCHAR valStrR[10]; ::SetDlgItemInt(_hSelf, IDC_EDIT_MB, nppGUI._printSettings._marge.bottom, FALSE);
wsprintf(valStrR, TEXT("%d"), nppGUI._printSettings._marge.right); ::SetDlgItemText(_hSelf, IDC_EDIT_HLEFT, nppGUI._printSettings._headerLeft.c_str());
::SetDlgItemText(_hSelf, IDC_EDIT_HMIDDLE, nppGUI._printSettings._headerMiddle.c_str());
TCHAR valStrT[10]; ::SetDlgItemText(_hSelf, IDC_EDIT_HRIGHT, nppGUI._printSettings._headerRight.c_str());
wsprintf(valStrT, TEXT("%d"), nppGUI._printSettings._marge.top); ::SetDlgItemText(_hSelf, IDC_EDIT_FLEFT, nppGUI._printSettings._footerLeft.c_str());
::SetDlgItemText(_hSelf, IDC_EDIT_FMIDDLE, nppGUI._printSettings._footerMiddle.c_str());
TCHAR valStrB[10]; ::SetDlgItemText(_hSelf, IDC_EDIT_FRIGHT, nppGUI._printSettings._footerRight.c_str());
wsprintf(valStrB, TEXT("%d"), nppGUI._printSettings._marge.bottom);
::SendDlgItemMessage(_hSelf, IDC_EDIT_ML, WM_SETTEXT, 0, (LPARAM)valStrL);
::SendDlgItemMessage(_hSelf, IDC_EDIT_MR, WM_SETTEXT, 0, (LPARAM)valStrR);
::SendDlgItemMessage(_hSelf, IDC_EDIT_MT, WM_SETTEXT, 0, (LPARAM)valStrT);
::SendDlgItemMessage(_hSelf, IDC_EDIT_MB, WM_SETTEXT, 0, (LPARAM)valStrB);
::SendDlgItemMessage(_hSelf, IDC_EDIT_HLEFT, WM_SETTEXT, 0, (LPARAM)nppGUI._printSettings._headerLeft.c_str());
::SendDlgItemMessage(_hSelf, IDC_EDIT_HMIDDLE, WM_SETTEXT, 0, (LPARAM)nppGUI._printSettings._headerMiddle.c_str());
::SendDlgItemMessage(_hSelf, IDC_EDIT_HRIGHT, WM_SETTEXT, 0, (LPARAM)nppGUI._printSettings._headerRight.c_str());
::SendDlgItemMessage(_hSelf, IDC_EDIT_FLEFT, WM_SETTEXT, 0, (LPARAM)nppGUI._printSettings._footerLeft.c_str());
::SendDlgItemMessage(_hSelf, IDC_EDIT_FMIDDLE, WM_SETTEXT, 0, (LPARAM)nppGUI._printSettings._footerMiddle.c_str());
::SendDlgItemMessage(_hSelf, IDC_EDIT_FRIGHT, WM_SETTEXT, 0, (LPARAM)nppGUI._printSettings._footerRight.c_str());
TCHAR intStr[5]; TCHAR intStr[5];
for(size_t i = 6 ; i < 15 ; i++) for(size_t i = 6 ; i < 15 ; i++)
@ -1912,13 +1925,9 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
{ {
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
TCHAR nbStr[10]; ::SetDlgItemInt(_hSelf, IDD_AUTOC_STATIC_N, nppGUI._autocFromLen, FALSE);
wsprintf(nbStr, TEXT("%d"), nppGUI._autocFromLen);
HWND hNbChar_val = ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N);
::SetWindowText(hNbChar_val, nbStr);
_nbCharVal.init(_hInst, _hSelf); _nbCharVal.init(_hInst, _hSelf);
_nbCharVal.create(hNbChar_val, IDM_SETTING_AUTOCNBCHAR); _nbCharVal.create(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), IDD_AUTOC_STATIC_N);
int ID2Check = 0; int ID2Check = 0;
@ -2051,12 +2060,30 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
return TRUE; return TRUE;
} }
case IDM_SETTING_AUTOCNBCHAR : case IDD_AUTOC_STATIC_N :
{ {
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_AUTOCNBCHAR, 0); const int NB_MIN_CHAR = 1;
TCHAR nbStr[10]; const int NB_MAX_CHAR = 9;
wsprintf(nbStr, TEXT("%d"), pNppParam->getNppGUI()._autocFromLen);
::SetWindowText(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), nbStr); ValueDlg valDlg;
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
valDlg.init(NULL, _hSelf, nppGUI._autocFromLen, TEXT("Nb char : "));
valDlg.setNBNumber(1);
POINT p;
::GetCursorPos(&p);
int size = valDlg.doDialog(p);
if (size != -1)
{
if (size > NB_MAX_CHAR)
size = NB_MAX_CHAR;
else if (size < NB_MIN_CHAR)
size = NB_MIN_CHAR;
nppGUI._autocFromLen = size;
::SetDlgItemInt(_hSelf, IDD_AUTOC_STATIC_N, nppGUI._autocFromLen, FALSE);
}
return TRUE; return TRUE;
} }

View File

@ -150,7 +150,6 @@ private :
class PreferenceDlg : public StaticDialog class PreferenceDlg : public StaticDialog
{ {
//friend class Notepad_plus;
friend class NativeLangSpeaker; friend class NativeLangSpeaker;
public : public :
@ -177,7 +176,6 @@ public :
_fileAssocDlg.destroy(); _fileAssocDlg.destroy();
_langMenuDlg.destroy(); _langMenuDlg.destroy();
_printSettingsDlg.destroy(); _printSettingsDlg.destroy();
//_printSettings2Dlg.destroy();
_defaultNewDocDlg.destroy(); _defaultNewDocDlg.destroy();
}; };
private : private :
@ -190,7 +188,6 @@ private :
RegExtDlg _fileAssocDlg; RegExtDlg _fileAssocDlg;
LangMenuDlg _langMenuDlg; LangMenuDlg _langMenuDlg;
PrintSettingsDlg _printSettingsDlg; PrintSettingsDlg _printSettingsDlg;
//PrintSettings2Dlg _printSettings2Dlg;
DefaultNewDocDlg _defaultNewDocDlg; DefaultNewDocDlg _defaultNewDocDlg;
BackupDlg _backupDlg; BackupDlg _backupDlg;
}; };

View File

@ -818,12 +818,4 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab)
} }
} }
} }
/*
void WindowsMenu::uninitPopupMenu(HMENU hMenu, ScintillaEditView *pView)
{
if (hMenu == _hMenu)
{
}
}
*/

View File

@ -48,11 +48,7 @@ BOOL CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
initMacroList(); initMacroList();
::SetDlgItemInt(_hSelf, IDC_M_RUN_TIMES, m_Times, FALSE);
TCHAR str[512];
wsprintf(str, TEXT("%d"), m_Times);
::SetDlgItemText(_hSelf, IDC_M_RUN_TIMES, str);
switch ( m_Mode ) switch ( m_Mode )
{ {
case RM_RUN_MULTI: case RM_RUN_MULTI:

View File

@ -39,14 +39,44 @@ void LastRecentFileList::initMenu(HMENU hMenu, int idBase, int posBase, bool doS
for (int i = 0 ; i < sizeof(_idFreeArray) ; i++) for (int i = 0 ; i < sizeof(_idFreeArray) ; i++)
_idFreeArray[i] = true; _idFreeArray[i] = true;
}
void LastRecentFileList::switchMode()
{
if (_hParentMenu == NULL) // mode main menu
{
//Remove all menu items
::RemoveMenu(_hMenu, IDM_OPEN_ALL_RECENT_FILE, MF_BYCOMMAND);
::RemoveMenu(_hMenu, IDM_CLEAN_RECENT_FILE_LIST, MF_BYCOMMAND);
for(int i = 0; i < _size; i++)
{
::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND);
}
// switch to sub-menu mode
_hParentMenu = _hMenu;
_hMenu = ::CreatePopupMenu();
}
else // mode sub-menu
{
// switch to main menu mode
::DestroyMenu(_hMenu);
_hMenu = _hParentMenu;
_hParentMenu = NULL;
}
}; };
void LastRecentFileList::updateMenu() void LastRecentFileList::updateMenu()
{ {
NppParameters *pNppParam = NppParameters::getInstance();
if (!_hasSeparators && _size > 0) if (!_hasSeparators && _size > 0)
{ {
//add separators //add separators
NativeLangSpeaker *pNativeLangSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); NativeLangSpeaker *pNativeLangSpeaker = pNppParam->getNativeLangSpeaker();
generic_string recentFileList = pNativeLangSpeaker->getSpecialMenuEntryName("RecentFiles"); generic_string recentFileList = pNativeLangSpeaker->getSpecialMenuEntryName("RecentFiles");
generic_string openAllFiles = pNativeLangSpeaker->getNativeLangMenuString(IDM_OPEN_ALL_RECENT_FILE); generic_string openAllFiles = pNativeLangSpeaker->getNativeLangMenuString(IDM_OPEN_ALL_RECENT_FILE);
@ -101,12 +131,14 @@ void LastRecentFileList::updateMenu()
TCHAR buffer[MAX_PATH]; TCHAR buffer[MAX_PATH];
for(int j = 0; j < _size; j++) for(int j = 0; j < _size; j++)
{ {
BuildMenuFileName(buffer, 100, j, _lrfl.at(j)._name.c_str()); BuildMenuFileName(buffer, pNppParam->getRecentFileCustomLength(), j, _lrfl.at(j)._name.c_str());
::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, buffer); ::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, buffer);
} }
} }
void LastRecentFileList::add(const TCHAR *fn) { void LastRecentFileList::add(const TCHAR *fn)
{
if (_userMax == 0 || _locked) if (_userMax == 0 || _locked)
return; return;
@ -128,16 +160,19 @@ void LastRecentFileList::add(const TCHAR *fn) {
updateMenu(); updateMenu();
}; };
void LastRecentFileList::remove(const TCHAR *fn) { void LastRecentFileList::remove(const TCHAR *fn)
{
int index = find(fn); int index = find(fn);
if (index != -1) if (index != -1)
remove(index); remove(index);
}; };
void LastRecentFileList::remove(int index) { void LastRecentFileList::remove(int index)
{
if (_size == 0 || _locked) if (_size == 0 || _locked)
return; return;
if (index > -1 && index < (int)_lrfl.size()) { if (index > -1 && index < (int)_lrfl.size())
{
::RemoveMenu(_hMenu, _lrfl.at(index)._id, MF_BYCOMMAND); ::RemoveMenu(_hMenu, _lrfl.at(index)._id, MF_BYCOMMAND);
setAvailable(_lrfl.at(index)._id); setAvailable(_lrfl.at(index)._id);
_lrfl.erase(_lrfl.begin() + index); _lrfl.erase(_lrfl.begin() + index);
@ -147,11 +182,13 @@ void LastRecentFileList::remove(int index) {
}; };
void LastRecentFileList::clear() { void LastRecentFileList::clear()
{
if (_size == 0) if (_size == 0)
return; return;
for(int i = (_size-1); i >= 0; i--) { for(int i = (_size-1); i >= 0; i--)
{
::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND); ::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND);
setAvailable(_lrfl.at(i)._id); setAvailable(_lrfl.at(i)._id);
_lrfl.erase(_lrfl.begin() + i); _lrfl.erase(_lrfl.begin() + i);
@ -161,9 +198,11 @@ void LastRecentFileList::clear() {
} }
generic_string & LastRecentFileList::getItem(int id) { generic_string & LastRecentFileList::getItem(int id)
{
int i = 0; int i = 0;
for(; i < _size; i++) { for(; i < _size; i++)
{
if (_lrfl.at(i)._id == id) if (_lrfl.at(i)._id == id)
break; break;
} }
@ -181,9 +220,11 @@ generic_string & LastRecentFileList::getIndex(int index)
void LastRecentFileList::setUserMaxNbLRF(int size) void LastRecentFileList::setUserMaxNbLRF(int size)
{ {
_userMax = size; _userMax = size;
if (_size > _userMax) { //start popping items if (_size > _userMax)
{ //start popping items
int toPop = _size-_userMax; int toPop = _size-_userMax;
while(toPop > 0) { while(toPop > 0)
{
::RemoveMenu(_hMenu, _lrfl.back()._id, MF_BYCOMMAND); ::RemoveMenu(_hMenu, _lrfl.back()._id, MF_BYCOMMAND);
setAvailable(_lrfl.back()._id); setAvailable(_lrfl.back()._id);
_lrfl.pop_back(); _lrfl.pop_back();
@ -200,7 +241,7 @@ void LastRecentFileList::setUserMaxNbLRF(int size)
void LastRecentFileList::saveLRFL() void LastRecentFileList::saveLRFL()
{ {
NppParameters *pNppParams = NppParameters::getInstance(); NppParameters *pNppParams = NppParameters::getInstance();
if (pNppParams->writeNbHistoryFile(_userMax)) if (pNppParams->writeRecentFileHistorySettings(_userMax))
{ {
for(int i = _size - 1; i >= 0; i--) //reverse order: so loading goes in correct order for(int i = _size - 1; i >= 0; i--) //reverse order: so loading goes in correct order
{ {

View File

@ -38,7 +38,7 @@ public :
}; };
void initMenu(HMENU hMenu, int idBase, int posBase, bool doSubMenu = false); void initMenu(HMENU hMenu, int idBase, int posBase, bool doSubMenu = false);
void switchMode();
void updateMenu(); void updateMenu();
void add(const TCHAR *fn); void add(const TCHAR *fn);
@ -76,7 +76,7 @@ public :
bool isSubMenuMode() const { bool isSubMenuMode() const {
return (_hParentMenu != NULL); return (_hParentMenu != NULL);
} };
private: private:
recentList _lrfl; recentList _lrfl;

View File

@ -396,17 +396,17 @@
#define IDM_SETTING (IDM + 8000) #define IDM_SETTING (IDM + 8000)
#define IDM_SETTING_TAB_SIZE (IDM_SETTING + 1) // #define IDM_SETTING_TAB_SIZE (IDM_SETTING + 1)
#define IDM_SETTING_TAB_REPLCESPACE (IDM_SETTING + 2) // #define IDM_SETTING_TAB_REPLCESPACE (IDM_SETTING + 2)
#define IDM_SETTING_HISTORY_SIZE (IDM_SETTING + 3) // #define IDM_SETTING_HISTORY_SIZE (IDM_SETTING + 3)
#define IDM_SETTING_EDGE_SIZE (IDM_SETTING + 4) // #define IDM_SETTING_EDGE_SIZE (IDM_SETTING + 4)
#define IDM_SETTING_IMPORTPLUGIN (IDM_SETTING + 5) #define IDM_SETTING_IMPORTPLUGIN (IDM_SETTING + 5)
#define IDM_SETTING_IMPORTSTYLETHEMS (IDM_SETTING + 6) #define IDM_SETTING_IMPORTSTYLETHEMS (IDM_SETTING + 6)
#define IDM_SETTING_TRAYICON (IDM_SETTING + 8) #define IDM_SETTING_TRAYICON (IDM_SETTING + 8)
#define IDM_SETTING_SHORTCUT_MAPPER (IDM_SETTING + 9) #define IDM_SETTING_SHORTCUT_MAPPER (IDM_SETTING + 9)
#define IDM_SETTING_REMEMBER_LAST_SESSION (IDM_SETTING + 10) #define IDM_SETTING_REMEMBER_LAST_SESSION (IDM_SETTING + 10)
#define IDM_SETTING_PREFERECE (IDM_SETTING + 11) #define IDM_SETTING_PREFERECE (IDM_SETTING + 11)
#define IDM_SETTING_AUTOCNBCHAR (IDM_SETTING + 15) // #define IDM_SETTING_AUTOCNBCHAR (IDM_SETTING + 15)
#define IDM_SETTING_SHORTCUT_MAPPER_MACRO (IDM_SETTING + 16) #define IDM_SETTING_SHORTCUT_MAPPER_MACRO (IDM_SETTING + 16)
#define IDM_SETTING_SHORTCUT_MAPPER_RUN (IDM_SETTING + 17) #define IDM_SETTING_SHORTCUT_MAPPER_RUN (IDM_SETTING + 17)
#define IDM_SETTING_EDITCONTEXTMENU (IDM_SETTING + 18) #define IDM_SETTING_EDITCONTEXTMENU (IDM_SETTING + 18)

View File

@ -321,7 +321,7 @@
#define NPPM_INTERNAL_SCINTILLAFINFERCOLLAPSE (NOTEPADPLUS_USER_INTERNAL + 8) #define NPPM_INTERNAL_SCINTILLAFINFERCOLLAPSE (NOTEPADPLUS_USER_INTERNAL + 8)
#define NPPM_INTERNAL_SCINTILLAFINFERUNCOLLAPSE (NOTEPADPLUS_USER_INTERNAL + 9) #define NPPM_INTERNAL_SCINTILLAFINFERUNCOLLAPSE (NOTEPADPLUS_USER_INTERNAL + 9)
#define NPPM_INTERNAL_DISABLEAUTOUPDATE (NOTEPADPLUS_USER_INTERNAL + 10) #define NPPM_INTERNAL_DISABLEAUTOUPDATE (NOTEPADPLUS_USER_INTERNAL + 10)
//#define NPPM_INTERNAL_DOCSWITCHIN (NOTEPADPLUS_USER_INTERNAL + 11) #define NPPM_INTERNAL_SETTING_HISTORY_SIZE (NOTEPADPLUS_USER_INTERNAL + 11)
#define NPPM_INTERNAL_ISTABBARREDUCED (NOTEPADPLUS_USER_INTERNAL + 12) #define NPPM_INTERNAL_ISTABBARREDUCED (NOTEPADPLUS_USER_INTERNAL + 12)
#define NPPM_INTERNAL_ISFOCUSEDTAB (NOTEPADPLUS_USER_INTERNAL + 13) #define NPPM_INTERNAL_ISFOCUSEDTAB (NOTEPADPLUS_USER_INTERNAL + 13)
#define NPPM_INTERNAL_GETMENU (NOTEPADPLUS_USER_INTERNAL + 14) #define NPPM_INTERNAL_GETMENU (NOTEPADPLUS_USER_INTERNAL + 14)
@ -338,13 +338,16 @@
#define NPPM_INTERNAL_RELOADNATIVELANG (NOTEPADPLUS_USER_INTERNAL + 25) #define NPPM_INTERNAL_RELOADNATIVELANG (NOTEPADPLUS_USER_INTERNAL + 25)
#define NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED (NOTEPADPLUS_USER_INTERNAL + 26) #define NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED (NOTEPADPLUS_USER_INTERNAL + 26)
#define NPPM_INTERNAL_SCINTILLAFINFERCLEARALL (NOTEPADPLUS_USER_INTERNAL + 27) #define NPPM_INTERNAL_SCINTILLAFINFERCLEARALL (NOTEPADPLUS_USER_INTERNAL + 27)
//#define NPPM_INTERNAL_SHORTCUT_MAPPER_MACRO (NOTEPADPLUS_USER_INTERNAL + 28) #define NPPM_INTERNAL_SETTING_EDGE_SIZE (NOTEPADPLUS_USER_INTERNAL + 28)
//#define NPPM_INTERNAL_SHORTCUT_MAPPER_RUN (NOTEPADPLUS_USER_INTERNAL + 29) #define NPPM_INTERNAL_SETTING_TAB_REPLCESPACE (NOTEPADPLUS_USER_INTERNAL + 29)
//#define NPPM_INTERNAL_FOCUS_ON_FOUND_RESULTS (NOTEPADPLUS_USER_INTERNAL + 30) #define NPPM_INTERNAL_SETTING_TAB_SIZE (NOTEPADPLUS_USER_INTERNAL + 30)
#define NPPM_INTERNAL_RELOADSTYLERS (NOTEPADPLUS_USER_INTERNAL + 31) #define NPPM_INTERNAL_RELOADSTYLERS (NOTEPADPLUS_USER_INTERNAL + 31)
#define NPPM_INTERNAL_DOCORDERCHANGED (NOTEPADPLUS_USER_INTERNAL + 32) #define NPPM_INTERNAL_DOCORDERCHANGED (NOTEPADPLUS_USER_INTERNAL + 32)
#define NPPM_INTERNAL_SETMULTISELCTION (NOTEPADPLUS_USER_INTERNAL + 33) #define NPPM_INTERNAL_SETMULTISELCTION (NOTEPADPLUS_USER_INTERNAL + 33)
#define NPPM_INTERNAL_SCINTILLAFINFEROPENALL (NOTEPADPLUS_USER_INTERNAL + 34) #define NPPM_INTERNAL_SCINTILLAFINFEROPENALL (NOTEPADPLUS_USER_INTERNAL + 34)
#define NPPM_INTERNAL_RECENTFILELIST_UPDATE (NOTEPADPLUS_USER_INTERNAL + 35)
#define NPPM_INTERNAL_RECENTFILELIST_SWITCH (NOTEPADPLUS_USER_INTERNAL + 36)
//wParam: 0 //wParam: 0
//lParam: document new index //lParam: document new index