Some warning fixes

This commit is contained in:
Damien GERARD 2015-08-14 04:32:38 -07:00
parent f6aae43fb2
commit 3fb1d96671
11 changed files with 301 additions and 290 deletions

View File

@ -602,7 +602,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_toolBar.addToRebar(&_rebarTop); _toolBar.addToRebar(&_rebarTop);
_rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, willBeShown); _rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, willBeShown);
checkMacroState(); checkMacroState();
//--Init dialogs--// //--Init dialogs--//
_findReplaceDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView); _findReplaceDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
@ -621,23 +621,29 @@ LRESULT Notepad_plus::init(HWND hwnd)
bool uddShow = false; bool uddShow = false;
switch (uddStatus) switch (uddStatus)
{ {
case UDD_SHOW : // show & undocked case UDD_SHOW: // show & undocked
{
udd->doDialog(true, _nativeLangSpeaker.isRTL()); udd->doDialog(true, _nativeLangSpeaker.isRTL());
_nativeLangSpeaker.changeUserDefineLang(udd); _nativeLangSpeaker.changeUserDefineLang(udd);
uddShow = true; uddShow = true;
break; break;
case UDD_DOCKED : { // hide & docked }
case UDD_DOCKED: // hide & docked
{
_isUDDocked = true; _isUDDocked = true;
break;}
case (UDD_SHOW | UDD_DOCKED) : // show & docked
udd->doDialog(true, _nativeLangSpeaker.isRTL());
_nativeLangSpeaker.changeUserDefineLang(udd);
::SendMessage(udd->getHSelf(), WM_COMMAND, IDC_DOCK_BUTTON, 0);
uddShow = true;
break; break;
}
case (UDD_SHOW | UDD_DOCKED) : // show & docked
{
udd->doDialog(true, _nativeLangSpeaker.isRTL());
_nativeLangSpeaker.changeUserDefineLang(udd);
::SendMessage(udd->getHSelf(), WM_COMMAND, IDC_DOCK_BUTTON, 0);
uddShow = true;
break;
}
default : // hide & undocked default: // hide & undocked
break; break;
} }
@ -650,19 +656,21 @@ LRESULT Notepad_plus::init(HWND hwnd)
// //
// Initialize the default foreground & background color // Initialize the default foreground & background color
// //
StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers();
int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT);
if (i != -1)
{ {
Style & style = globalStyles.getStyler(i); StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers();
(NppParameters::getInstance())->setCurrentDefaultFgColor(style._fgColor); int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT);
(NppParameters::getInstance())->setCurrentDefaultBgColor(style._bgColor); if (i != -1)
{
Style & style = globalStyles.getStyler(i);
(NppParameters::getInstance())->setCurrentDefaultFgColor(style._fgColor);
(NppParameters::getInstance())->setCurrentDefaultBgColor(style._bgColor);
}
} }
// //
// launch the plugin dlg memorized at the last session // launch the plugin dlg memorized at the last session
// //
DockingManagerData &dmd = nppGUI._dockingData; DockingManagerData& dmd = nppGUI._dockingData;
_dockingManager.setDockedContSize(CONT_LEFT , nppGUI._dockingData._leftWidth); _dockingManager.setDockedContSize(CONT_LEFT , nppGUI._dockingData._leftWidth);
_dockingManager.setDockedContSize(CONT_RIGHT , nppGUI._dockingData._rightWidth); _dockingManager.setDockedContSize(CONT_RIGHT , nppGUI._dockingData._rightWidth);
@ -671,17 +679,13 @@ LRESULT Notepad_plus::init(HWND hwnd)
for (size_t i = 0, len = dmd._pluginDockInfo.size(); i < len ; ++i) for (size_t i = 0, len = dmd._pluginDockInfo.size(); i < len ; ++i)
{ {
PluginDlgDockingInfo & pdi = dmd._pluginDockInfo[i]; PluginDlgDockingInfo& pdi = dmd._pluginDockInfo[i];
if (pdi._isVisible) if (pdi._isVisible)
{ {
if (pdi._name == NPP_INTERNAL_FUCTION_STR) if (pdi._name == NPP_INTERNAL_FUCTION_STR)
{
_internalFuncIDs.push_back(pdi._internalID); _internalFuncIDs.push_back(pdi._internalID);
}
else else
{
_pluginsManager.runPluginCommand(pdi._name.c_str(), pdi._internalID); _pluginsManager.runPluginCommand(pdi._name.c_str(), pdi._internalID);
}
} }
} }
@ -690,6 +694,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
ContainerTabInfo & cti = dmd._containerTabInfo[i]; ContainerTabInfo & cti = dmd._containerTabInfo[i];
_dockingManager.setActiveTab(cti._cont, cti._activeTab); _dockingManager.setActiveTab(cti._cont, cti._activeTab);
} }
//Load initial docs into doctab //Load initial docs into doctab
loadBufferIntoView(_mainEditView.getCurrentBufferID(), MAIN_VIEW); loadBufferIntoView(_mainEditView.getCurrentBufferID(), MAIN_VIEW);
loadBufferIntoView(_subEditView.getCurrentBufferID(), SUB_VIEW); loadBufferIntoView(_subEditView.getCurrentBufferID(), SUB_VIEW);

View File

@ -122,8 +122,8 @@ LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPA
LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{ {
LRESULT result = FALSE; LRESULT result = FALSE;
NppParameters *pNppParam = NppParameters::getInstance(); NppParameters *pNppParam = NppParameters::getInstance();
switch (Message) switch (Message)
{ {
case WM_NCACTIVATE: case WM_NCACTIVATE:
@ -2042,7 +2042,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETAPPDATAPLUGINSALLOWED: case NPPM_GETAPPDATAPLUGINSALLOWED:
{ {
NppParameters *pNppParam = NppParameters::getInstance();
const TCHAR *appDataNpp = pNppParam->getAppDataNppDir(); const TCHAR *appDataNpp = pNppParam->getAppDataNppDir();
if (appDataNpp[0]) if (appDataNpp[0])
{ {
@ -2058,7 +2057,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
// //
case NPPM_INTERNAL_SETTING_HISTORY_SIZE: case NPPM_INTERNAL_SETTING_HISTORY_SIZE:
{ {
NppParameters *pNppParam = NppParameters::getInstance();
_lastRecentFileList.setUserMaxNbLRF(pNppParam->getNbMaxRecentFile()); _lastRecentFileList.setUserMaxNbLRF(pNppParam->getNbMaxRecentFile());
break; break;
} }

View File

@ -1856,7 +1856,7 @@ void Notepad_plus::command(int id)
return; return;
} }
Buffer * buf = _pEditView->getCurrentBuffer(); Buffer* buf = _pEditView->getCurrentBuffer();
if (buf->isDirty()) if (buf->isDirty())
{ {
generic_string warning, title; generic_string warning, title;
@ -1884,17 +1884,13 @@ void Notepad_plus::command(int id)
TEXT("Lose Undo Ability Waning"), TEXT("Lose Undo Ability Waning"),
MB_YESNO); MB_YESNO);
if (answer == IDYES) if (answer != IDYES)
{
// Do nothing
}
else
return; return;
} }
if (!buf->isDirty()) if (not buf->isDirty())
{ {
Buffer *buf = _pEditView->getCurrentBuffer(); buf = _pEditView->getCurrentBuffer();
buf->setEncoding(encoding); buf->setEncoding(encoding);
buf->setUnicodeMode(uniCookie); buf->setUnicodeMode(uniCookie);
fileReload(); fileReload();

View File

@ -37,6 +37,9 @@
using namespace std; using namespace std;
BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive, bool isReadOnly, int encoding, const TCHAR *backupFileName, time_t fileNameTimestamp) BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive, bool isReadOnly, int encoding, const TCHAR *backupFileName, time_t fileNameTimestamp)
{ {
const rsize_t longFileNameBufferSize = MAX_PATH; // TODO stop using fixed-size buffer const rsize_t longFileNameBufferSize = MAX_PATH; // TODO stop using fixed-size buffer
@ -180,7 +183,7 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
if (buffer != BUFFER_INVALID) if (buffer != BUFFER_INVALID)
{ {
bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName); bool isSnapshotMode = (backupFileName != NULL and PathFileExists(backupFileName));
if (isSnapshotMode) if (isSnapshotMode)
{ {
// To notify plugins that a snapshot dirty file is loaded on startup // To notify plugins that a snapshot dirty file is loaded on startup

View File

@ -3430,8 +3430,8 @@ void NppParameters::feedKeyWordsParameters(TiXmlNode *node)
{ {
if (_nbLang < NB_LANG) if (_nbLang < NB_LANG)
{ {
TiXmlElement *element = langNode->ToElement(); TiXmlElement* element = langNode->ToElement();
const TCHAR *name = element->Attribute(TEXT("name")); const TCHAR* name = element->Attribute(TEXT("name"));
if (name) if (name)
{ {
_langList[_nbLang] = new Lang(getLangIDFromStr(name), name); _langList[_nbLang] = new Lang(getLangIDFromStr(name), name);
@ -3439,9 +3439,10 @@ void NppParameters::feedKeyWordsParameters(TiXmlNode *node)
_langList[_nbLang]->setCommentLineSymbol(element->Attribute(TEXT("commentLine"))); _langList[_nbLang]->setCommentLineSymbol(element->Attribute(TEXT("commentLine")));
_langList[_nbLang]->setCommentStart(element->Attribute(TEXT("commentStart"))); _langList[_nbLang]->setCommentStart(element->Attribute(TEXT("commentStart")));
_langList[_nbLang]->setCommentEnd(element->Attribute(TEXT("commentEnd"))); _langList[_nbLang]->setCommentEnd(element->Attribute(TEXT("commentEnd")));
int i;
if (element->Attribute(TEXT("tabSettings"), &i)) int tabSettings;
_langList[_nbLang]->setTabInfo(i); if (element->Attribute(TEXT("tabSettings"), &tabSettings))
_langList[_nbLang]->setTabInfo(tabSettings);
for (TiXmlNode *kwNode = langNode->FirstChildElement(TEXT("Keywords")); for (TiXmlNode *kwNode = langNode->FirstChildElement(TEXT("Keywords"));
kwNode ; kwNode ;
@ -3471,21 +3472,21 @@ typedef DWORD (WINAPI * EESFUNC) (LPCTSTR, LPTSTR, DWORD);
void NppParameters::feedGUIParameters(TiXmlNode *node) void NppParameters::feedGUIParameters(TiXmlNode *node)
{ {
TiXmlNode *GUIRoot = node->FirstChildElement(TEXT("GUIConfigs")); TiXmlNode *GUIRoot = node->FirstChildElement(TEXT("GUIConfigs"));
if (!GUIRoot) return; if (nullptr == GUIRoot)
return;
for (TiXmlNode *childNode = GUIRoot->FirstChildElement(TEXT("GUIConfig")); for (TiXmlNode *childNode = GUIRoot->FirstChildElement(TEXT("GUIConfig"));
childNode ; childNode ;
childNode = childNode->NextSibling(TEXT("GUIConfig")) ) childNode = childNode->NextSibling(TEXT("GUIConfig")) )
{ {
TiXmlElement *element = childNode->ToElement(); TiXmlElement* element = childNode->ToElement();
const TCHAR *nm = element->Attribute(TEXT("name")); const TCHAR* nm = element->Attribute(TEXT("name"));
if (!nm) continue; if (nullptr == nm)
continue;
const TCHAR *val;
if (!lstrcmp(nm, TEXT("ToolBar"))) if (!lstrcmp(nm, TEXT("ToolBar")))
{ {
val = element->Attribute(TEXT("visible")); const TCHAR* val = element->Attribute(TEXT("visible"));
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("no"))) if (!lstrcmp(val, TEXT("no")))
@ -3513,7 +3514,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("hide"))) if (!lstrcmp(val, TEXT("hide")))
@ -3528,7 +3529,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("hide"))) if (!lstrcmp(val, TEXT("hide")))
@ -3542,7 +3543,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
{ {
bool isFailed = false; bool isFailed = false;
int oldValue = _nppGUI._tabStatus; int oldValue = _nppGUI._tabStatus;
val = element->Attribute(TEXT("dragAndDrop")); const TCHAR* val = element->Attribute(TEXT("dragAndDrop"));
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("yes"))) if (!lstrcmp(val, TEXT("yes")))
@ -3648,7 +3649,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("yes"))) if (!lstrcmp(val, TEXT("yes")))
@ -3672,7 +3673,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("yes"))) if (!lstrcmp(val, TEXT("yes")))
@ -3685,7 +3686,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("yes"))) if (!lstrcmp(val, TEXT("yes")))
@ -3700,7 +3701,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("yes"))) if (!lstrcmp(val, TEXT("yes")))
@ -3715,7 +3716,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("yes"))) if (!lstrcmp(val, TEXT("yes")))
@ -3731,7 +3732,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("yes"))) if (!lstrcmp(val, TEXT("yes")))
@ -3747,7 +3748,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("yes"))) if (!lstrcmp(val, TEXT("yes")))
@ -3763,7 +3764,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
_nppGUI._enableTagsMatchHilite = !lstrcmp(val, TEXT("yes")); _nppGUI._enableTagsMatchHilite = !lstrcmp(val, TEXT("yes"));
@ -3783,7 +3784,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
_nppGUI._doTaskList = (!lstrcmp(val, TEXT("yes")))?true:false; _nppGUI._doTaskList = (!lstrcmp(val, TEXT("yes")))?true:false;
@ -3796,11 +3797,9 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ _nppGUI._styleMRU = (!lstrcmp(val, TEXT("yes")));
_nppGUI._styleMRU = (!lstrcmp(val, TEXT("yes")))?true:false;
}
} }
} }
@ -3809,7 +3808,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("1"))) if (!lstrcmp(val, TEXT("1")))
@ -3827,7 +3826,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("no"))) if (!lstrcmp(val, TEXT("no")))
@ -3840,7 +3839,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("vertical"))) if (!lstrcmp(val, TEXT("vertical")))
@ -3858,7 +3857,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("hide"))) if (!lstrcmp(val, TEXT("hide")))
@ -3869,7 +3868,8 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
isFailed = true; isFailed = true;
} }
} }
val = element->Attribute(TEXT("position"));
const TCHAR* val = element->Attribute(TEXT("position"));
if (val) if (val)
{ {
if (!lstrcmp(val, TEXT("docked"))) if (!lstrcmp(val, TEXT("docked")))
@ -3885,7 +3885,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
else if (!lstrcmp(nm, TEXT("TabSetting"))) else if (!lstrcmp(nm, TEXT("TabSetting")))
{ {
int i; int i;
val = element->Attribute(TEXT("size"), &i); const TCHAR* val = element->Attribute(TEXT("size"), &i);
if (val) if (val)
_nppGUI._tabSize = i; _nppGUI._tabSize = i;
@ -3900,7 +3900,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
else if (!lstrcmp(nm, TEXT("Caret"))) else if (!lstrcmp(nm, TEXT("Caret")))
{ {
int i; int i;
val = element->Attribute(TEXT("width"), &i); const TCHAR* val = element->Attribute(TEXT("width"), &i);
if (val) if (val)
_nppGUI._caretWidth = i; _nppGUI._caretWidth = i;
@ -3911,7 +3911,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
else if (!lstrcmp(nm, TEXT("ScintillaGlobalSettings"))) else if (!lstrcmp(nm, TEXT("ScintillaGlobalSettings")))
{ {
val = element->Attribute(TEXT("enableMultiSelection")); const TCHAR* val = element->Attribute(TEXT("enableMultiSelection"));
if (val && lstrcmp(val, TEXT("yes")) == 0) if (val && lstrcmp(val, TEXT("yes")) == 0)
_nppGUI._enableMultiSelection = true; _nppGUI._enableMultiSelection = true;
} }
@ -3945,11 +3945,9 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (fuckUp) if (fuckUp)
_nppGUI._appPos = oldRect; _nppGUI._appPos = oldRect;
val = element->Attribute(TEXT("isMaximized")); const TCHAR* val = element->Attribute(TEXT("isMaximized"));
if (val) if (val)
{
_nppGUI._isMaximized = (lstrcmp(val, TEXT("yes")) == 0); _nppGUI._isMaximized = (lstrcmp(val, TEXT("yes")) == 0);
}
} }
else if (!lstrcmp(nm, TEXT("NewDocDefaultSettings"))) else if (!lstrcmp(nm, TEXT("NewDocDefaultSettings")))
{ {
@ -3966,13 +3964,14 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (element->Attribute(TEXT("codepage"), &i)) if (element->Attribute(TEXT("codepage"), &i))
_nppGUI._newDocDefaultSettings._codepage = (LangType)i; _nppGUI._newDocDefaultSettings._codepage = (LangType)i;
val = element->Attribute(TEXT("openAnsiAsUTF8")); const TCHAR* val = element->Attribute(TEXT("openAnsiAsUTF8"));
if (val) if (val)
_nppGUI._newDocDefaultSettings._openAnsiAsUtf8 = (lstrcmp(val, TEXT("yes")) == 0); _nppGUI._newDocDefaultSettings._openAnsiAsUtf8 = (lstrcmp(val, TEXT("yes")) == 0);
} }
else if (!lstrcmp(nm, TEXT("langsExcluded"))) else if (!lstrcmp(nm, TEXT("langsExcluded")))
{ {
// TODO
int g0 = 0; // up to 8 int g0 = 0; // up to 8
int g1 = 0; // up to 16 int g1 = 0; // up to 16
int g2 = 0; // up to 24 int g2 = 0; // up to 24
@ -3983,34 +3982,54 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
int g7 = 0; // up to 64 int g7 = 0; // up to 64
const int nbMax = 64; const int nbMax = 64;
int i; // TODO some refactoring needed here....
if (element->Attribute(TEXT("gr0"), &i)) {
if (i <= 255) int i;
g0 = i; if (element->Attribute(TEXT("gr0"), &i))
if (element->Attribute(TEXT("gr1"), &i)) {
if (i <= 255) if (i <= 255)
g1 = i; g0 = i;
if (element->Attribute(TEXT("gr2"), &i)) }
if (i <= 255) if (element->Attribute(TEXT("gr1"), &i))
g2 = i; {
if (element->Attribute(TEXT("gr3"), &i)) if (i <= 255)
if (i <= 255) g1 = i;
g3 = i; }
if (element->Attribute(TEXT("gr4"), &i)) if (element->Attribute(TEXT("gr2"), &i))
if (i <= 255) {
g4 = i; if (i <= 255)
if (element->Attribute(TEXT("gr5"), &i)) g2 = i;
if (i <= 255) }
g5 = i; if (element->Attribute(TEXT("gr3"), &i))
if (element->Attribute(TEXT("gr6"), &i)) {
if (i <= 255) if (i <= 255)
g6 = i; g3 = i;
if (element->Attribute(TEXT("gr7"), &i)) }
if (i <= 255) if (element->Attribute(TEXT("gr4"), &i))
g7 = i; {
if (i <= 255)
g4 = i;
}
if (element->Attribute(TEXT("gr5"), &i))
{
if (i <= 255)
g5 = i;
}
if (element->Attribute(TEXT("gr6"), &i))
{
if (i <= 255)
g6 = i;
}
if (element->Attribute(TEXT("gr7"), &i))
{
if (i <= 255)
g7 = i;
}
}
bool langArray[nbMax]; bool langArray[nbMax];
for (int i = 0 ; i < nbMax ; ++i) langArray[i] = false; for (int i = 0 ; i < nbMax ; ++i)
langArray[i] = false;
UCHAR mask = 1; UCHAR mask = 1;
for (int i = 0 ; i < 8 ; ++i) for (int i = 0 ; i < 8 ; ++i)
@ -4076,14 +4095,14 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
mask <<= 1; mask <<= 1;
} }
val = element->Attribute(TEXT("langMenuCompact")); const TCHAR* val = element->Attribute(TEXT("langMenuCompact"));
if (val) if (val)
_nppGUI._isLangMenuCompact = (!lstrcmp(val, TEXT("yes"))); _nppGUI._isLangMenuCompact = (!lstrcmp(val, TEXT("yes")));
} }
else if (!lstrcmp(nm, TEXT("Print"))) else if (!lstrcmp(nm, TEXT("Print")))
{ {
val = element->Attribute(TEXT("lineNumber")); const TCHAR* val = element->Attribute(TEXT("lineNumber"));
if (val) if (val)
_nppGUI._printSettings._printLineNumber = (!lstrcmp(val, TEXT("yes"))); _nppGUI._printSettings._printLineNumber = (!lstrcmp(val, TEXT("yes")));
@ -4195,39 +4214,27 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
bDir = element->Attribute(TEXT("bg")); bDir = element->Attribute(TEXT("bg"));
if (bDir && !lstrcmp(bDir, TEXT("yes"))) if (bDir && !lstrcmp(bDir, TEXT("yes")))
{
_nppGUI._globalOverride.enableBg = true; _nppGUI._globalOverride.enableBg = true;
}
bDir = element->Attribute(TEXT("font")); bDir = element->Attribute(TEXT("font"));
if (bDir && !lstrcmp(bDir, TEXT("yes"))) if (bDir && !lstrcmp(bDir, TEXT("yes")))
{
_nppGUI._globalOverride.enableFont = true; _nppGUI._globalOverride.enableFont = true;
}
bDir = element->Attribute(TEXT("fontSize")); bDir = element->Attribute(TEXT("fontSize"));
if (bDir && !lstrcmp(bDir, TEXT("yes"))) if (bDir && !lstrcmp(bDir, TEXT("yes")))
{
_nppGUI._globalOverride.enableFontSize = true; _nppGUI._globalOverride.enableFontSize = true;
}
bDir = element->Attribute(TEXT("bold")); bDir = element->Attribute(TEXT("bold"));
if (bDir && !lstrcmp(bDir, TEXT("yes"))) if (bDir && !lstrcmp(bDir, TEXT("yes")))
{
_nppGUI._globalOverride.enableBold = true; _nppGUI._globalOverride.enableBold = true;
}
bDir = element->Attribute(TEXT("italic")); bDir = element->Attribute(TEXT("italic"));
if (bDir && !lstrcmp(bDir, TEXT("yes"))) if (bDir && !lstrcmp(bDir, TEXT("yes")))
{
_nppGUI._globalOverride.enableItalic = true; _nppGUI._globalOverride.enableItalic = true;
}
bDir = element->Attribute(TEXT("underline")); bDir = element->Attribute(TEXT("underline"));
if (bDir && !lstrcmp(bDir, TEXT("yes"))) if (bDir && !lstrcmp(bDir, TEXT("yes")))
{
_nppGUI._globalOverride.enableUnderLine = true; _nppGUI._globalOverride.enableUnderLine = true;
}
} }
else if (!lstrcmp(nm, TEXT("auto-completion"))) else if (!lstrcmp(nm, TEXT("auto-completion")))
{ {
@ -4240,47 +4247,33 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
const TCHAR * funcParams = element->Attribute(TEXT("funcParams")); const TCHAR * funcParams = element->Attribute(TEXT("funcParams"));
if (funcParams && !lstrcmp(funcParams, TEXT("yes"))) if (funcParams && !lstrcmp(funcParams, TEXT("yes")))
{
_nppGUI._funcParams = true; _nppGUI._funcParams = true;
}
} }
else if (!lstrcmp(nm, TEXT("auto-insert"))) else if (!lstrcmp(nm, TEXT("auto-insert")))
{ {
const TCHAR * optName = element->Attribute(TEXT("htmlXmlTag")); const TCHAR * optName = element->Attribute(TEXT("htmlXmlTag"));
if (optName && !lstrcmp(optName, TEXT("yes"))) if (optName && !lstrcmp(optName, TEXT("yes")))
{
_nppGUI._matchedPairConf._doHtmlXmlTag = true; _nppGUI._matchedPairConf._doHtmlXmlTag = true;
}
optName = element->Attribute(TEXT("parentheses")); optName = element->Attribute(TEXT("parentheses"));
if (optName && !lstrcmp(optName, TEXT("yes"))) if (optName && !lstrcmp(optName, TEXT("yes")))
{
_nppGUI._matchedPairConf._doParentheses = true; _nppGUI._matchedPairConf._doParentheses = true;
}
optName = element->Attribute(TEXT("brackets")); optName = element->Attribute(TEXT("brackets"));
if (optName && !lstrcmp(optName, TEXT("yes"))) if (optName && !lstrcmp(optName, TEXT("yes")))
{
_nppGUI._matchedPairConf._doBrackets = true; _nppGUI._matchedPairConf._doBrackets = true;
}
optName = element->Attribute(TEXT("curlyBrackets")); optName = element->Attribute(TEXT("curlyBrackets"));
if (optName && !lstrcmp(optName, TEXT("yes"))) if (optName && !lstrcmp(optName, TEXT("yes")))
{
_nppGUI._matchedPairConf._doCurlyBrackets = true; _nppGUI._matchedPairConf._doCurlyBrackets = true;
}
optName = element->Attribute(TEXT("quotes")); optName = element->Attribute(TEXT("quotes"));
if (optName && !lstrcmp(optName, TEXT("yes"))) if (optName && !lstrcmp(optName, TEXT("yes")))
{
_nppGUI._matchedPairConf._doQuotes = true; _nppGUI._matchedPairConf._doQuotes = true;
}
optName = element->Attribute(TEXT("doubleQuotes")); optName = element->Attribute(TEXT("doubleQuotes"));
if (optName && !lstrcmp(optName, TEXT("yes"))) if (optName && !lstrcmp(optName, TEXT("yes")))
{
_nppGUI._matchedPairConf._doDoubleQuotes = true; _nppGUI._matchedPairConf._doDoubleQuotes = true;
}
for (TiXmlNode *subChildNode = childNode->FirstChildElement(TEXT("UserDefinePair")); for (TiXmlNode *subChildNode = childNode->FirstChildElement(TEXT("UserDefinePair"));
subChildNode; subChildNode;
@ -4290,22 +4283,16 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
int openVal = 0; int openVal = 0;
const TCHAR *openValStr = (subChildNode->ToElement())->Attribute(TEXT("open"), &openVal); const TCHAR *openValStr = (subChildNode->ToElement())->Attribute(TEXT("open"), &openVal);
if (openValStr && (openVal >= 0 && openVal < 128)) if (openValStr && (openVal >= 0 && openVal < 128))
{
open = openVal; open = openVal;
}
int close = -1; int close = -1;
int closeVal = 0; int closeVal = 0;
const TCHAR *closeValStr = (subChildNode->ToElement())->Attribute(TEXT("close"), &closeVal); const TCHAR *closeValStr = (subChildNode->ToElement())->Attribute(TEXT("close"), &closeVal);
if (closeValStr && (closeVal >= 0 && closeVal <= 128)) if (closeValStr && (closeVal >= 0 && closeVal <= 128))
{
close = closeVal; close = closeVal;
}
if (open != -1 && close != -1) if (open != -1 && close != -1)
{
_nppGUI._matchedPairConf._matchedPairsInit.push_back(pair<char, char>(char(open), char(close))); _nppGUI._matchedPairConf._matchedPairsInit.push_back(pair<char, char>(char(open), char(close)));
}
} }
} }
else if (!lstrcmp(nm, TEXT("sessionExt"))) else if (!lstrcmp(nm, TEXT("sessionExt")))
@ -4313,7 +4300,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
_nppGUI._definedSessionExt = val; _nppGUI._definedSessionExt = val;
} }
@ -4323,24 +4310,18 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
if (n) if (n)
{ {
val = n->Value(); const TCHAR* val = n->Value();
if (val) if (val)
{
_nppGUI._autoUpdateOpt._doAutoUpdate = (!lstrcmp(val, TEXT("yes")))?false:true; _nppGUI._autoUpdateOpt._doAutoUpdate = (!lstrcmp(val, TEXT("yes")))?false:true;
}
int i; int i;
val = element->Attribute(TEXT("intervalDays"), &i); val = element->Attribute(TEXT("intervalDays"), &i);
if (val) if (val)
{
_nppGUI._autoUpdateOpt._intervalDays = i; _nppGUI._autoUpdateOpt._intervalDays = i;
}
val = element->Attribute(TEXT("nextUpdateDate")); val = element->Attribute(TEXT("nextUpdateDate"));
if (val) if (val)
{
_nppGUI._autoUpdateOpt._nextUpdateDate = Date(val); _nppGUI._autoUpdateOpt._nextUpdateDate = Date(val);
}
} }
} }
else if (!lstrcmp(nm, TEXT("openSaveDir"))) else if (!lstrcmp(nm, TEXT("openSaveDir")))
@ -4355,6 +4336,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
else else
_nppGUI._openSaveDir = dir_followCurrent; _nppGUI._openSaveDir = dir_followCurrent;
} }
const TCHAR * path = element->Attribute(TEXT("defaultDirPath")); const TCHAR * path = element->Attribute(TEXT("defaultDirPath"));
if (path && path[0]) if (path && path[0])
{ {
@ -4410,22 +4392,18 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
{ {
const TCHAR * optName = element->Attribute(TEXT("fileSwitcherWithoutExtColumn")); const TCHAR * optName = element->Attribute(TEXT("fileSwitcherWithoutExtColumn"));
if (optName && !lstrcmp(optName, TEXT("yes"))) if (optName && !lstrcmp(optName, TEXT("yes")))
{
_nppGUI._fileSwitcherWithoutExtColumn = true; _nppGUI._fileSwitcherWithoutExtColumn = true;
}
const TCHAR * optNameBackSlashEscape = element->Attribute(TEXT("backSlashIsEscapeCharacterForSql")); const TCHAR * optNameBackSlashEscape = element->Attribute(TEXT("backSlashIsEscapeCharacterForSql"));
if (optNameBackSlashEscape && !lstrcmp(optNameBackSlashEscape, TEXT("no"))) if (optNameBackSlashEscape && !lstrcmp(optNameBackSlashEscape, TEXT("no")))
{
_nppGUI._backSlashIsEscapeCharacterForSql = false; _nppGUI._backSlashIsEscapeCharacterForSql = false;
}
} }
} }
} }
void NppParameters::feedScintillaParam(TiXmlNode *node) void NppParameters::feedScintillaParam(TiXmlNode *node)
{ {
TiXmlElement *element = node->ToElement(); TiXmlElement* element = node->ToElement();
// Line Number Margin // Line Number Margin
const TCHAR *nm = element->Attribute(TEXT("lineNumberMargin")); const TCHAR *nm = element->Attribute(TEXT("lineNumberMargin"));

View File

@ -1246,7 +1246,6 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
} }
_pscratchTilla->execute(SCI_CLEARALL); _pscratchTilla->execute(SCI_CLEARALL);
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
if (language < L_EXTERNAL) if (language < L_EXTERNAL)
{ {
@ -1256,28 +1255,30 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
{ {
int id = language - L_EXTERNAL; int id = language - L_EXTERNAL;
TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name;
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const char *pName = wmc->wchar2char(name, CP_ACP); const char *pName = wmc->wchar2char(name, CP_ACP);
_pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)pName); _pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)pName);
} }
if (encoding != -1) if (encoding != -1)
{
_pscratchTilla->execute(SCI_SETCODEPAGE, SC_CP_UTF8); _pscratchTilla->execute(SCI_SETCODEPAGE, SC_CP_UTF8);
}
bool success = true; bool success = true;
int format = -1; int format = -1;
__try { __try
{
// First allocate enough memory for the whole file (this will reduce memory copy during loading) // First allocate enough memory for the whole file (this will reduce memory copy during loading)
_pscratchTilla->execute(SCI_ALLOCATE, WPARAM(bufferSizeRequested)); _pscratchTilla->execute(SCI_ALLOCATE, WPARAM(bufferSizeRequested));
if(_pscratchTilla->execute(SCI_GETSTATUS) != SC_STATUS_OK) throw; if (_pscratchTilla->execute(SCI_GETSTATUS) != SC_STATUS_OK)
throw;
size_t lenFile = 0; size_t lenFile = 0;
size_t lenConvert = 0; //just in case conversion results in 0, but file not empty size_t lenConvert = 0; //just in case conversion results in 0, but file not empty
bool isFirstTime = true; bool isFirstTime = true;
int incompleteMultibyteChar = 0; int incompleteMultibyteChar = 0;
do { do
{
lenFile = fread(data+incompleteMultibyteChar, 1, blockSize-incompleteMultibyteChar, fp) + incompleteMultibyteChar; lenFile = fread(data+incompleteMultibyteChar, 1, blockSize-incompleteMultibyteChar, fp) + incompleteMultibyteChar;
if (lenFile == 0) break; if (lenFile == 0) break;
@ -1307,7 +1308,7 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
} }
else else
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor* wmc = WcharMbcsConvertor::getInstance();
int newDataLen = 0; int newDataLen = 0;
const char *newData = wmc->encode(encoding, SC_CP_UTF8, data, lenFile, &newDataLen, &incompleteMultibyteChar); const char *newData = wmc->encode(encoding, SC_CP_UTF8, data, lenFile, &newDataLen, &incompleteMultibyteChar);
_pscratchTilla->execute(SCI_APPENDTEXT, newDataLen, (LPARAM)newData); _pscratchTilla->execute(SCI_APPENDTEXT, newDataLen, (LPARAM)newData);
@ -1321,40 +1322,47 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
lenConvert = UnicodeConvertor->convert(data, lenFile); lenConvert = UnicodeConvertor->convert(data, lenFile);
_pscratchTilla->execute(SCI_APPENDTEXT, lenConvert, (LPARAM)(UnicodeConvertor->getNewBuf())); _pscratchTilla->execute(SCI_APPENDTEXT, lenConvert, (LPARAM)(UnicodeConvertor->getNewBuf()));
} }
if(_pscratchTilla->execute(SCI_GETSTATUS) != SC_STATUS_OK) throw;
if(incompleteMultibyteChar != 0) if (_pscratchTilla->execute(SCI_GETSTATUS) != SC_STATUS_OK)
throw;
if (incompleteMultibyteChar != 0)
{ {
// copy bytes to next buffer // copy bytes to next buffer
memcpy(data, data+blockSize-incompleteMultibyteChar, incompleteMultibyteChar); memcpy(data, data+blockSize-incompleteMultibyteChar, incompleteMultibyteChar);
} }
} while (lenFile > 0); }
} __except(EXCEPTION_EXECUTE_HANDLER) { //TODO: should filter correctly for other exceptions; the old filter(GetExceptionCode(), GetExceptionInformation()) was only catching access violations while (lenFile > 0);
}
__except(EXCEPTION_EXECUTE_HANDLER) //TODO: should filter correctly for other exceptions; the old filter(GetExceptionCode(), GetExceptionInformation()) was only catching access violations
{
::MessageBox(NULL, TEXT("File is too big to be opened by Notepad++"), TEXT("File open problem"), MB_OK|MB_APPLMODAL); ::MessageBox(NULL, TEXT("File is too big to be opened by Notepad++"), TEXT("File open problem"), MB_OK|MB_APPLMODAL);
success = false; success = false;
} }
fclose(fp); fclose(fp);
if (pFormat != NULL) if (pFormat != nullptr)
{ *pFormat = (format == -1) ? WIN_FORMAT : (formatType)format;
*pFormat = (format == -1)?WIN_FORMAT:(formatType)format;
}
_pscratchTilla->execute(SCI_EMPTYUNDOBUFFER); _pscratchTilla->execute(SCI_EMPTYUNDOBUFFER);
_pscratchTilla->execute(SCI_SETSAVEPOINT); _pscratchTilla->execute(SCI_SETSAVEPOINT);
if (ro) {
if (ro)
_pscratchTilla->execute(SCI_SETREADONLY, true); _pscratchTilla->execute(SCI_SETREADONLY, true);
}
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
return success; return success;
} }
BufferID FileManager::getBufferFromName(const TCHAR * name)
BufferID FileManager::getBufferFromName(const TCHAR* name)
{ {
TCHAR fullpath[MAX_PATH]; TCHAR fullpath[MAX_PATH];
::GetFullPathName(name, MAX_PATH, fullpath, NULL); ::GetFullPathName(name, MAX_PATH, fullpath, NULL);
::GetLongPathName(fullpath, fullpath, MAX_PATH); ::GetLongPathName(fullpath, fullpath, MAX_PATH);
for(size_t i = 0; i < _buffers.size(); i++) for(size_t i = 0; i < _buffers.size(); i++)
{ {
if (!lstrcmpi(name, _buffers.at(i)->getFullPathName())) if (!lstrcmpi(name, _buffers.at(i)->getFullPathName()))
@ -1363,15 +1371,20 @@ BufferID FileManager::getBufferFromName(const TCHAR * name)
return BUFFER_INVALID; return BUFFER_INVALID;
} }
BufferID FileManager::getBufferFromDocument(Document doc) {
for(size_t i = 0; i < _nrBufs; ++i) { BufferID FileManager::getBufferFromDocument(Document doc)
{
for (size_t i = 0; i < _nrBufs; ++i)
{
if (_buffers[i]->_doc == doc) if (_buffers[i]->_doc == doc)
return _buffers[i]->_id; return _buffers[i]->_id;
} }
return BUFFER_INVALID; return BUFFER_INVALID;
} }
bool FileManager::createEmptyFile(const TCHAR * path) {
bool FileManager::createEmptyFile(const TCHAR * path)
{
FILE * file = generic_fopen(path, TEXT("wb")); FILE * file = generic_fopen(path, TEXT("wb"));
if (!file) if (!file)
return false; return false;
@ -1379,15 +1392,19 @@ bool FileManager::createEmptyFile(const TCHAR * path) {
return true; return true;
} }
int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy) {
int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy)
{
if (getBufferIndexByID(id) == -1) if (getBufferIndexByID(id) == -1)
return -1; return -1;
Buffer* buf = getBufferByID(id); Buffer* buf = getBufferByID(id);
if (fn2copy) if (fn2copy)
lstrcpy(fn2copy, buf->getFullPathName()); lstrcpy(fn2copy, buf->getFullPathName());
return lstrlen(buf->getFullPathName()); return lstrlen(buf->getFullPathName());
} }
int FileManager::docLength(Buffer* buffer) const int FileManager::docLength(Buffer* buffer) const
{ {
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc);

View File

@ -1037,9 +1037,11 @@ void UserDefineDialog::updateDlg()
_symbolsStyleDlg.updateDlg(); _symbolsStyleDlg.updateDlg();
} }
INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
NppParameters *pNppParam = NppParameters::getInstance(); NppParameters *pNppParam = NppParameters::getInstance();
switch (message) switch (message)
{ {
case WM_INITDIALOG : case WM_INITDIALOG :
@ -1130,7 +1132,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
return TRUE; return TRUE;
} }
case WM_NOTIFY : case WM_NOTIFY:
{ {
NMHDR *nmhdr = (NMHDR *)lParam; NMHDR *nmhdr = (NMHDR *)lParam;
if (nmhdr->code == TCN_SELCHANGE) if (nmhdr->code == TCN_SELCHANGE)
@ -1144,7 +1146,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
break; break;
} }
case WM_HSCROLL : case WM_HSCROLL:
{ {
if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_UD_PERCENTAGE_SLIDER)) if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_UD_PERCENTAGE_SLIDER))
{ {
@ -1211,10 +1213,13 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
::SendMessage(_hParent, msg, 0, 0); ::SendMessage(_hParent, msg, 0, 0);
return TRUE; return TRUE;
} }
case IDCANCEL :
::SendMessage(_hParent, WM_CLOSE_USERDEFINE_DLG, 0, 0); case IDCANCEL:
display(false); {
return TRUE; ::SendMessage(_hParent, WM_CLOSE_USERDEFINE_DLG, 0, 0);
display(false);
return TRUE;
}
case IDC_REMOVELANG_BUTTON : case IDC_REMOVELANG_BUTTON :
{ {
@ -1327,8 +1332,6 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
} }
case IDC_IMPORT_BUTTON : case IDC_IMPORT_BUTTON :
{ {
NppParameters *pNppParam = NppParameters::getInstance();
FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL)); FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL));
fDlg.setExtFilter(TEXT("UDL"), TEXT(".xml"), NULL); fDlg.setExtFilter(TEXT("UDL"), TEXT(".xml"), NULL);
TCHAR *fn = fDlg.doOpenSingleFileDlg(); TCHAR *fn = fDlg.doOpenSingleFileDlg();
@ -1353,10 +1356,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR
case IDC_EXPORT_BUTTON : case IDC_EXPORT_BUTTON :
{ {
NppParameters *pNppParam = NppParameters::getInstance(); int i2Export = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0);
int i2Export = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0);
if (i2Export == 0) if (i2Export == 0)
{ {
// maybe a better option would be to simply send IDC_SAVEAS_BUTTON message, and display "Save As..." dialog? // maybe a better option would be to simply send IDC_SAVEAS_BUTTON message, and display "Save As..." dialog?

View File

@ -1141,7 +1141,7 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
int selIndex = -1; int selIndex = -1;
generic_string str; generic_string str;
EncodingMapper *em = EncodingMapper::getInstance(); EncodingMapper* em = EncodingMapper::getInstance();
for (size_t i = 0, encodingArraySize = sizeof(encodings)/sizeof(int) ; i < encodingArraySize ; ++i) for (size_t i = 0, encodingArraySize = sizeof(encodings)/sizeof(int) ; i < encodingArraySize ; ++i)
{ {
int cmdID = em->getIndexFromEncoding(encodings[i]); int cmdID = em->getIndexFromEncoding(encodings[i]);
@ -1165,6 +1165,7 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
ID2Check = IDC_RADIO_OTHERCP; ID2Check = IDC_RADIO_OTHERCP;
::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_SETCURSEL, selIndex, 0); ::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_SETCURSEL, selIndex, 0);
} }
::SendDlgItemMessage(_hSelf, ID2Check, BM_SETCHECK, BST_CHECKED, 0); ::SendDlgItemMessage(_hSelf, ID2Check, BM_SETCHECK, BST_CHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, (ID2Check == IDC_RADIO_UTF8SANSBOM && ndds._openAnsiAsUtf8)?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, (ID2Check == IDC_RADIO_UTF8SANSBOM && ndds._openAnsiAsUtf8)?BST_CHECKED:BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), ID2Check == IDC_RADIO_UTF8SANSBOM); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), ID2Check == IDC_RADIO_UTF8SANSBOM);
@ -1172,7 +1173,7 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
int index = 0; int index = 0;
for (int i = L_TEXT ; i < pNppParam->L_END ; ++i) for (int i = L_TEXT ; i < pNppParam->L_END ; ++i)
{ {
generic_string str; str.clear();
if ((LangType)i != L_USER) if ((LangType)i != L_USER)
{ {
int cmdID = pNppParam->langTypeToCommandID((LangType)i); int cmdID = pNppParam->langTypeToCommandID((LangType)i);
@ -1199,7 +1200,7 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
enableDlgTheme(_hSelf, ETDT_ENABLETAB); enableDlgTheme(_hSelf, ETDT_ENABLETAB);
} }
case WM_COMMAND : case WM_COMMAND:
switch (wParam) switch (wParam)
{ {
case IDC_RADIO_UCS2BIG: case IDC_RADIO_UCS2BIG:

View File

@ -800,19 +800,18 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct)
if (hImgLst && tci.iImage >= 0) if (hImgLst && tci.iImage >= 0)
{ {
IMAGEINFO info; IMAGEINFO info;
int yPos = 0, xPos = 0;
int marge = 0;
ImageList_GetImageInfo(hImgLst, tci.iImage, &info); ImageList_GetImageInfo(hImgLst, tci.iImage, &info);
RECT & imageRect = info.rcImage; RECT& imageRect = info.rcImage;
int yPos = 0;
int xPos = 0;
if (_isVertical) if (_isVertical)
xPos = (rect.left + (rect.right - rect.left) / 2 + NppParameters::getInstance()->_dpiManager.scaleX(2)) - (imageRect.right - imageRect.left) / 2; xPos = (rect.left + (rect.right - rect.left) / 2 + NppParameters::getInstance()->_dpiManager.scaleX(2)) - (imageRect.right - imageRect.left) / 2;
else else
yPos = (rect.top + (rect.bottom - rect.top) / 2 + (isSelected ? 0 : NppParameters::getInstance()->_dpiManager.scaleX(2))) - (imageRect.bottom - imageRect.top) / 2; yPos = (rect.top + (rect.bottom - rect.top) / 2 + (isSelected ? 0 : NppParameters::getInstance()->_dpiManager.scaleX(2))) - (imageRect.bottom - imageRect.top) / 2;
marge = spaceUnit; int marge = spaceUnit;
if (_isVertical) if (_isVertical)
{ {

View File

@ -219,16 +219,23 @@ MenuPosition & getMenuPosition(const char *id)
void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & pluginsTrans, generic_string & windowTrans) void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & pluginsTrans, generic_string & windowTrans)
{ {
if (!_nativeLangA) return; if (nullptr == _nativeLangA)
TiXmlNodeA *mainMenu = _nativeLangA->FirstChild("Menu"); return;
if (!mainMenu) return;
mainMenu = mainMenu->FirstChild("Main");
if (!mainMenu) return;
TiXmlNodeA *entriesRoot = mainMenu->FirstChild("Entries");
if (!entriesRoot) return;
const char *idName = NULL;
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); TiXmlNodeA *mainMenu = _nativeLangA->FirstChild("Menu");
if (nullptr == mainMenu)
return;
mainMenu = mainMenu->FirstChild("Main");
if (nullptr == mainMenu)
return;
TiXmlNodeA *entriesRoot = mainMenu->FirstChild("Entries");
if (nullptr == entriesRoot)
return;
const char* idName = nullptr;
WcharMbcsConvertor* wmc = WcharMbcsConvertor::getInstance();
for (TiXmlNodeA *childNode = entriesRoot->FirstChildElement("Item"); for (TiXmlNodeA *childNode = entriesRoot->FirstChildElement("Item");
childNode ; childNode ;
@ -286,24 +293,24 @@ void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & plugin
childNode ; childNode ;
childNode = childNode->NextSibling("Item") ) childNode = childNode->NextSibling("Item") )
{ {
TiXmlElementA *element = childNode->ToElement(); TiXmlElementA* element = childNode->ToElement();
int x, y, z;
//const char *xStr = element->Attribute("posX", &x); //const char *xStr = element->Attribute("posX", &x);
//const char *yStr = element->Attribute("posY", &y); //const char *yStr = element->Attribute("posY", &y);
const char *subMenuIdStr = element->Attribute("subMenuId"); const char* subMenuIdStr = element->Attribute("subMenuId");
const char *name = element->Attribute("name"); const char* name = element->Attribute("name");
if (!subMenuIdStr || !name) if (nullptr == subMenuIdStr or nullptr == name)
continue; continue;
MenuPosition & menuPos = getMenuPosition(subMenuIdStr); MenuPosition& menuPos = getMenuPosition(subMenuIdStr);
x = menuPos._x; int x = menuPos._x;
y = menuPos._y; int y = menuPos._y;
z = menuPos._z; int z = menuPos._z;
HMENU hSubMenu = ::GetSubMenu(menuHandle, x); HMENU hSubMenu = ::GetSubMenu(menuHandle, x);
if (!hSubMenu) if (!hSubMenu)
continue; continue;
HMENU hSubMenu2 = ::GetSubMenu(hSubMenu, y); HMENU hSubMenu2 = ::GetSubMenu(hSubMenu, y);
if (!hSubMenu2) if (!hSubMenu2)
continue; continue;
@ -326,34 +333,37 @@ void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & plugin
} }
} }
int tabContextMenuItemPos[] = {
0, // 0 : Close static const int tabContextMenuItemPos[] =
1, // 1 : Close ALL BUT This {
4, // 2 : Save 0, // 0 : Close
5, // 3 : Save As 1, // 1 : Close ALL BUT This
9, // 4 : Print 4, // 2 : Save
21,// 5 : Move to Other View 5, // 3 : Save As
22,// 6 : Clone to Other View 9, // 4 : Print
17,// 7 : Full File Path to Clipboard 21, // 5 : Move to Other View
18,// 8 : Filename to Clipboard 22, // 6 : Clone to Other View
19,// 9 : Current Dir. Path to Clipboard 17, // 7 : Full File Path to Clipboard
6, // 10: Rename 18, // 8 : Filename to Clipboard
7, // 11: Move to Recycle Bin 19, // 9 : Current Dir. Path to Clipboard
14,// 12: Read-Only 6, // 10: Rename
15,// 13: Clear Read-Only Flag 7, // 11: Move to Recycle Bin
23,// 14: Move to New Instance 14, // 12: Read-Only
24,// 15: Open to New Instance 15, // 13: Clear Read-Only Flag
8, // 16: Reload 23, // 14: Move to New Instance
2, // 17: Close ALL to the Left 24, // 15: Open to New Instance
3, // 18: Close ALL to the Right 8, // 16: Reload
11,// 19: Open Containing Folder in Explorer 2, // 17: Close ALL to the Left
12,// 20: Open Containing Folder in cmd 3, // 18: Close ALL to the Right
-1 //-------End 11, // 19: Open Containing Folder in Explorer
12, // 20: Open Containing Folder in cmd
-1 //-------End
}; };
void NativeLangSpeaker::changeLangTabContextMenu(HMENU hCM) void NativeLangSpeaker::changeLangTabContextMenu(HMENU hCM)
{ {
if (_nativeLangA) if (nullptr != _nativeLangA)
{ {
TiXmlNodeA *tabBarMenu = _nativeLangA->FirstChild("Menu"); TiXmlNodeA *tabBarMenu = _nativeLangA->FirstChild("Menu");
if (tabBarMenu) if (tabBarMenu)
@ -361,7 +371,7 @@ void NativeLangSpeaker::changeLangTabContextMenu(HMENU hCM)
tabBarMenu = tabBarMenu->FirstChild("TabBar"); tabBarMenu = tabBarMenu->FirstChild("TabBar");
if (tabBarMenu) if (tabBarMenu)
{ {
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor* wmc = WcharMbcsConvertor::getInstance();
int nbCMItems = sizeof(tabContextMenuItemPos)/sizeof(int); int nbCMItems = sizeof(tabContextMenuItemPos)/sizeof(int);
for (TiXmlNodeA *childNode = tabBarMenu->FirstChildElement("Item"); for (TiXmlNodeA *childNode = tabBarMenu->FirstChildElement("Item");
@ -395,12 +405,13 @@ void NativeLangSpeaker::changeLangTabDrapContextMenu(HMENU hCM)
if (_nativeLangA) if (_nativeLangA)
{ {
const char *goToViewA = NULL; const char *goToViewA = nullptr;
const char *cloneToViewA = NULL; const char *cloneToViewA = nullptr;
TiXmlNodeA *tabBarMenu = _nativeLangA->FirstChild("Menu"); TiXmlNodeA *tabBarMenu = _nativeLangA->FirstChild("Menu");
if (tabBarMenu) if (tabBarMenu)
tabBarMenu = tabBarMenu->FirstChild("TabBar"); tabBarMenu = tabBarMenu->FirstChild("TabBar");
if (tabBarMenu) if (tabBarMenu)
{ {
for (TiXmlNodeA *childNode = tabBarMenu->FirstChildElement("Item"); for (TiXmlNodeA *childNode = tabBarMenu->FirstChildElement("Item");
@ -433,12 +444,15 @@ void NativeLangSpeaker::changeLangTabDrapContextMenu(HMENU hCM)
} }
} }
void NativeLangSpeaker::changeConfigLang(HWND hDlg) void NativeLangSpeaker::changeConfigLang(HWND hDlg)
{ {
if (!_nativeLangA) return; if (nullptr == _nativeLangA)
return;
TiXmlNodeA *styleConfDlgNode = _nativeLangA->FirstChild("Dialog"); TiXmlNodeA *styleConfDlgNode = _nativeLangA->FirstChild("Dialog");
if (!styleConfDlgNode) return; if (!styleConfDlgNode)
return;
styleConfDlgNode = styleConfDlgNode->FirstChild("StyleConfig"); styleConfDlgNode = styleConfDlgNode->FirstChild("StyleConfig");
if (!styleConfDlgNode) return; if (!styleConfDlgNode) return;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Unicode Debug|Win32"> <ProjectConfiguration Include="Unicode Debug|Win32">
<Configuration>Unicode Debug</Configuration> <Configuration>Unicode Debug</Configuration>
@ -27,24 +27,24 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset> <PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@ -100,7 +100,7 @@
<BasicRuntimeChecks>UninitializedLocalUsageCheck</BasicRuntimeChecks> <BasicRuntimeChecks>UninitializedLocalUsageCheck</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>false</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<SmallerTypeCheck>true</SmallerTypeCheck> <SmallerTypeCheck>true</SmallerTypeCheck>