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

@ -623,19 +623,25 @@ LRESULT Notepad_plus::init(HWND hwnd)
switch (uddStatus)
{
case UDD_SHOW: // show & undocked
{
udd->doDialog(true, _nativeLangSpeaker.isRTL());
_nativeLangSpeaker.changeUserDefineLang(udd);
uddShow = true;
break;
case UDD_DOCKED : { // hide & docked
}
case UDD_DOCKED: // hide & docked
{
_isUDDocked = 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
break;
@ -650,6 +656,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
//
// Initialize the default foreground & background color
//
{
StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers();
int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT);
if (i != -1)
@ -658,6 +665,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
(NppParameters::getInstance())->setCurrentDefaultFgColor(style._fgColor);
(NppParameters::getInstance())->setCurrentDefaultBgColor(style._bgColor);
}
}
//
// launch the plugin dlg memorized at the last session
@ -675,21 +683,18 @@ LRESULT Notepad_plus::init(HWND hwnd)
if (pdi._isVisible)
{
if (pdi._name == NPP_INTERNAL_FUCTION_STR)
{
_internalFuncIDs.push_back(pdi._internalID);
}
else
{
_pluginsManager.runPluginCommand(pdi._name.c_str(), pdi._internalID);
}
}
}
for (size_t i = 0, len = dmd._containerTabInfo.size(); i < len; ++i)
{
ContainerTabInfo & cti = dmd._containerTabInfo[i];
_dockingManager.setActiveTab(cti._cont, cti._activeTab);
}
//Load initial docs into doctab
loadBufferIntoView(_mainEditView.getCurrentBufferID(), MAIN_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 result = FALSE;
NppParameters *pNppParam = NppParameters::getInstance();
switch (Message)
{
case WM_NCACTIVATE:
@ -2042,7 +2042,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_GETAPPDATAPLUGINSALLOWED:
{
NppParameters *pNppParam = NppParameters::getInstance();
const TCHAR *appDataNpp = pNppParam->getAppDataNppDir();
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:
{
NppParameters *pNppParam = NppParameters::getInstance();
_lastRecentFileList.setUserMaxNbLRF(pNppParam->getNbMaxRecentFile());
break;
}

View File

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

View File

@ -37,6 +37,9 @@
using namespace std;
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
@ -180,7 +183,7 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
if (buffer != BUFFER_INVALID)
{
bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName);
bool isSnapshotMode = (backupFileName != NULL and PathFileExists(backupFileName));
if (isSnapshotMode)
{
// To notify plugins that a snapshot dirty file is loaded on startup

View File

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

View File

@ -1246,7 +1246,6 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
}
_pscratchTilla->execute(SCI_CLEARALL);
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
if (language < L_EXTERNAL)
{
@ -1256,28 +1255,30 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
{
int id = language - L_EXTERNAL;
TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name;
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const char *pName = wmc->wchar2char(name, CP_ACP);
_pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)pName);
}
if (encoding != -1)
{
_pscratchTilla->execute(SCI_SETCODEPAGE, SC_CP_UTF8);
}
bool success = true;
int format = -1;
__try {
__try
{
// First allocate enough memory for the whole file (this will reduce memory copy during loading)
_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 lenConvert = 0; //just in case conversion results in 0, but file not empty
bool isFirstTime = true;
int incompleteMultibyteChar = 0;
do {
do
{
lenFile = fread(data+incompleteMultibyteChar, 1, blockSize-incompleteMultibyteChar, fp) + incompleteMultibyteChar;
if (lenFile == 0) break;
@ -1321,7 +1322,9 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
lenConvert = UnicodeConvertor->convert(data, lenFile);
_pscratchTilla->execute(SCI_APPENDTEXT, lenConvert, (LPARAM)(UnicodeConvertor->getNewBuf()));
}
if(_pscratchTilla->execute(SCI_GETSTATUS) != SC_STATUS_OK) throw;
if (_pscratchTilla->execute(SCI_GETSTATUS) != SC_STATUS_OK)
throw;
if (incompleteMultibyteChar != 0)
{
@ -1329,32 +1332,37 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
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);
success = false;
}
fclose(fp);
if (pFormat != NULL)
{
if (pFormat != nullptr)
*pFormat = (format == -1) ? WIN_FORMAT : (formatType)format;
}
_pscratchTilla->execute(SCI_EMPTYUNDOBUFFER);
_pscratchTilla->execute(SCI_SETSAVEPOINT);
if (ro) {
if (ro)
_pscratchTilla->execute(SCI_SETREADONLY, true);
}
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
return success;
}
BufferID FileManager::getBufferFromName(const TCHAR* name)
{
TCHAR fullpath[MAX_PATH];
::GetFullPathName(name, MAX_PATH, fullpath, NULL);
::GetLongPathName(fullpath, fullpath, MAX_PATH);
for(size_t i = 0; i < _buffers.size(); i++)
{
if (!lstrcmpi(name, _buffers.at(i)->getFullPathName()))
@ -1363,15 +1371,20 @@ BufferID FileManager::getBufferFromName(const TCHAR * name)
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)
return _buffers[i]->_id;
}
return BUFFER_INVALID;
}
bool FileManager::createEmptyFile(const TCHAR * path) {
bool FileManager::createEmptyFile(const TCHAR * path)
{
FILE * file = generic_fopen(path, TEXT("wb"));
if (!file)
return false;
@ -1379,15 +1392,19 @@ bool FileManager::createEmptyFile(const TCHAR * path) {
return true;
}
int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy) {
int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy)
{
if (getBufferIndexByID(id) == -1)
return -1;
Buffer* buf = getBufferByID(id);
if (fn2copy)
lstrcpy(fn2copy, buf->getFullPathName());
return lstrlen(buf->getFullPathName());
}
int FileManager::docLength(Buffer* buffer) const
{
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc);

View File

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

View File

@ -1165,6 +1165,7 @@ INT_PTR CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
ID2Check = IDC_RADIO_OTHERCP;
::SendDlgItemMessage(_hSelf, IDC_COMBO_OTHERCP, CB_SETCURSEL, selIndex, 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);
::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;
for (int i = L_TEXT ; i < pNppParam->L_END ; ++i)
{
generic_string str;
str.clear();
if ((LangType)i != L_USER)
{
int cmdID = pNppParam->langTypeToCommandID((LangType)i);

View File

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

View File

@ -219,15 +219,22 @@ MenuPosition & getMenuPosition(const char *id)
void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & pluginsTrans, generic_string & windowTrans)
{
if (!_nativeLangA) return;
TiXmlNodeA *mainMenu = _nativeLangA->FirstChild("Menu");
if (!mainMenu) return;
mainMenu = mainMenu->FirstChild("Main");
if (!mainMenu) return;
TiXmlNodeA *entriesRoot = mainMenu->FirstChild("Entries");
if (!entriesRoot) return;
const char *idName = NULL;
if (nullptr == _nativeLangA)
return;
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");
@ -287,23 +294,23 @@ void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & plugin
childNode = childNode->NextSibling("Item") )
{
TiXmlElementA* element = childNode->ToElement();
int x, y, z;
//const char *xStr = element->Attribute("posX", &x);
//const char *yStr = element->Attribute("posY", &y);
const char* subMenuIdStr = element->Attribute("subMenuId");
const char* name = element->Attribute("name");
if (!subMenuIdStr || !name)
if (nullptr == subMenuIdStr or nullptr == name)
continue;
MenuPosition& menuPos = getMenuPosition(subMenuIdStr);
x = menuPos._x;
y = menuPos._y;
z = menuPos._z;
int x = menuPos._x;
int y = menuPos._y;
int z = menuPos._z;
HMENU hSubMenu = ::GetSubMenu(menuHandle, x);
if (!hSubMenu)
continue;
HMENU hSubMenu2 = ::GetSubMenu(hSubMenu, y);
if (!hSubMenu2)
continue;
@ -326,7 +333,9 @@ void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & plugin
}
}
int tabContextMenuItemPos[] = {
static const int tabContextMenuItemPos[] =
{
0, // 0 : Close
1, // 1 : Close ALL BUT This
4, // 2 : Save
@ -351,9 +360,10 @@ int tabContextMenuItemPos[] = {
-1 //-------End
};
void NativeLangSpeaker::changeLangTabContextMenu(HMENU hCM)
{
if (_nativeLangA)
if (nullptr != _nativeLangA)
{
TiXmlNodeA *tabBarMenu = _nativeLangA->FirstChild("Menu");
if (tabBarMenu)
@ -395,12 +405,13 @@ void NativeLangSpeaker::changeLangTabDrapContextMenu(HMENU hCM)
if (_nativeLangA)
{
const char *goToViewA = NULL;
const char *cloneToViewA = NULL;
const char *goToViewA = nullptr;
const char *cloneToViewA = nullptr;
TiXmlNodeA *tabBarMenu = _nativeLangA->FirstChild("Menu");
if (tabBarMenu)
tabBarMenu = tabBarMenu->FirstChild("TabBar");
if (tabBarMenu)
{
for (TiXmlNodeA *childNode = tabBarMenu->FirstChildElement("Item");
@ -433,12 +444,15 @@ void NativeLangSpeaker::changeLangTabDrapContextMenu(HMENU hCM)
}
}
void NativeLangSpeaker::changeConfigLang(HWND hDlg)
{
if (!_nativeLangA) return;
if (nullptr == _nativeLangA)
return;
TiXmlNodeA *styleConfDlgNode = _nativeLangA->FirstChild("Dialog");
if (!styleConfDlgNode) return;
if (!styleConfDlgNode)
return;
styleConfDlgNode = styleConfDlgNode->FirstChild("StyleConfig");
if (!styleConfDlgNode) return;

View File

@ -1,5 +1,5 @@
<?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">
<ProjectConfiguration Include="Unicode Debug|Win32">
<Configuration>Unicode Debug</Configuration>
@ -27,24 +27,24 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@ -100,7 +100,7 @@
<BasicRuntimeChecks>UninitializedLocalUsageCheck</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<TreatWarningAsError>false</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<SmallerTypeCheck>true</SmallerTypeCheck>