Make some codes conform to the defined coding style

This commit is contained in:
Don HO 2020-01-28 02:20:44 +01:00
parent 230cd415dd
commit 6e6341cc61
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
22 changed files with 242 additions and 109 deletions

View File

@ -83,9 +83,11 @@ static EncodingUnit encodings[] = {
{20866, "koi8_r csKOI8R"} //IDM_FORMAT_KOI8R_CYRILLIC {20866, "koi8_r csKOI8R"} //IDM_FORMAT_KOI8R_CYRILLIC
}; };
bool isInListA(const char *token, const char *list) { bool isInListA(const char *token, const char *list)
{
if ((!token) || (!list)) if ((!token) || (!list))
return false; return false;
char word[64]; char word[64];
size_t i = 0; size_t i = 0;
size_t j = 0; size_t j = 0;

View File

@ -416,7 +416,8 @@ bool PluginsManager::getShortcutByCmdID(int cmdID, ShortcutKey *sk)
// returns false if cmdID not provided, true otherwise // returns false if cmdID not provided, true otherwise
bool PluginsManager::removeShortcutByCmdID(int cmdID) bool PluginsManager::removeShortcutByCmdID(int cmdID)
{ {
if (cmdID == 0) { return false; } if (cmdID == 0)
return false;
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
vector<PluginCmdShortcut> & pluginCmdSCList = nppParam.getPluginCommandList(); vector<PluginCmdShortcut> & pluginCmdSCList = nppParam.getPluginCommandList();

View File

@ -1068,7 +1068,8 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
} }
bool Notepad_plus::replaceInOpenedFiles() { bool Notepad_plus::replaceInOpenedFiles()
{
ScintillaEditView *pOldView = _pEditView; ScintillaEditView *pOldView = _pEditView;
_pEditView = &_invisibleEditView; _pEditView = &_invisibleEditView;
@ -2995,11 +2996,14 @@ LangType Notepad_plus::menuID2LangType(int cmdID)
return L_VISUALPROLOG; return L_VISUALPROLOG;
case IDM_LANG_USER : case IDM_LANG_USER :
return L_USER; return L_USER;
default: { default:
if (cmdID >= IDM_LANG_USER && cmdID <= IDM_LANG_USER_LIMIT) { {
if (cmdID >= IDM_LANG_USER && cmdID <= IDM_LANG_USER_LIMIT)
{
return L_USER; return L_USER;
} }
break; } break;
}
} }
return L_EXTERNAL; return L_EXTERNAL;
} }
@ -3372,17 +3376,23 @@ void Notepad_plus::showView(int whichOne)
if (viewVisible(whichOne)) //no use making visible view visible if (viewVisible(whichOne)) //no use making visible view visible
return; return;
if (_mainWindowStatus & WindowUserActive) { if (_mainWindowStatus & WindowUserActive)
{
_pMainSplitter->setWin0(&_subSplitter); _pMainSplitter->setWin0(&_subSplitter);
_pMainWindow = _pMainSplitter; _pMainWindow = _pMainSplitter;
} else { }
else
{
_pMainWindow = &_subSplitter; _pMainWindow = &_subSplitter;
} }
if (whichOne == MAIN_VIEW) { if (whichOne == MAIN_VIEW)
{
_mainEditView.display(true); _mainEditView.display(true);
_mainDocTab.display(true); _mainDocTab.display(true);
} else if (whichOne == SUB_VIEW) { }
else if (whichOne == SUB_VIEW)
{
_subEditView.display(true); _subEditView.display(true);
_subDocTab.display(true); _subDocTab.display(true);
} }
@ -3394,7 +3404,8 @@ void Notepad_plus::showView(int whichOne)
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
} }
bool Notepad_plus::viewVisible(int whichOne) { bool Notepad_plus::viewVisible(int whichOne)
{
int viewToCheck = (whichOne == SUB_VIEW?WindowSubActive:WindowMainActive); int viewToCheck = (whichOne == SUB_VIEW?WindowSubActive:WindowMainActive);
return (_mainWindowStatus & viewToCheck) != 0; return (_mainWindowStatus & viewToCheck) != 0;
} }
@ -3422,10 +3433,13 @@ void Notepad_plus::hideView(int whichOne)
_subSplitter.display(false); //hide splitter _subSplitter.display(false); //hide splitter
//hide scintilla and doctab //hide scintilla and doctab
if (whichOne == MAIN_VIEW) { if (whichOne == MAIN_VIEW)
{
_mainEditView.display(false); _mainEditView.display(false);
_mainDocTab.display(false); _mainDocTab.display(false);
} else if (whichOne == SUB_VIEW) { }
else if (whichOne == SUB_VIEW)
{
_subEditView.display(false); _subEditView.display(false);
_subDocTab.display(false); _subDocTab.display(false);
} }
@ -3566,10 +3580,13 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne)
int Notepad_plus::switchEditViewTo(int gid) int Notepad_plus::switchEditViewTo(int gid)
{ {
if (currentView() == gid) { //make sure focus is ok, then leave if (currentView() == gid)
{
//make sure focus is ok, then leave
_pEditView->getFocus(); //set the focus _pEditView->getFocus(); //set the focus
return gid; return gid;
} }
if (!viewVisible(gid)) if (!viewVisible(gid))
return currentView(); //cannot activate invisible view return currentView(); //cannot activate invisible view
@ -3658,13 +3675,16 @@ void Notepad_plus::docOpenInNewInstance(FileTransferMode mode, int x, int y)
command += TEXT("\""); command += TEXT("\"");
command += TEXT(" \"$(FULL_CURRENT_PATH)\" -multiInst -nosession"); command += TEXT(" \"$(FULL_CURRENT_PATH)\" -multiInst -nosession");
if (x) { if (x)
{
TCHAR pX[10]; TCHAR pX[10];
generic_itoa(x, pX, 10); generic_itoa(x, pX, 10);
command += TEXT(" -x"); command += TEXT(" -x");
command += pX; command += pX;
} }
if (y) {
if (y)
{
TCHAR pY[10]; TCHAR pY[10];
generic_itoa(y, pY, 10); generic_itoa(y, pY, 10);
command += TEXT(" -y"); command += TEXT(" -y");
@ -3826,15 +3846,19 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne)
return true; return true;
} }
void Notepad_plus::performPostReload(int whichOne) { void Notepad_plus::performPostReload(int whichOne)
{
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
const NppGUI & nppGUI = nppParam.getNppGUI(); const NppGUI & nppGUI = nppParam.getNppGUI();
bool toEnd = (nppGUI._fileAutoDetection & cdGo2end) ? true : false; bool toEnd = (nppGUI._fileAutoDetection & cdGo2end) ? true : false;
if (!toEnd) if (!toEnd)
return; return;
if (whichOne == MAIN_VIEW) { if (whichOne == MAIN_VIEW)
{
_mainEditView.execute(SCI_GOTOLINE, _mainEditView.execute(SCI_GETLINECOUNT) -1); _mainEditView.execute(SCI_GOTOLINE, _mainEditView.execute(SCI_GETLINECOUNT) -1);
} else { }
else
{
_subEditView.execute(SCI_GOTOLINE, _subEditView.execute(SCI_GETLINECOUNT) -1); _subEditView.execute(SCI_GOTOLINE, _subEditView.execute(SCI_GETLINECOUNT) -1);
} }
} }
@ -4336,7 +4360,8 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
_pEditView->execute(SCI_ENDUNDOACTION); _pEditView->execute(SCI_ENDUNDOACTION);
// undoStreamComment: If there were no block-comments to un-comment try uncommenting of stream-comment. // undoStreamComment: If there were no block-comments to un-comment try uncommenting of stream-comment.
if ((currCommentMode == cm_uncomment) && (nUncomments == 0)) { if ((currCommentMode == cm_uncomment) && (nUncomments == 0))
{
return undoStreamComment(false); return undoStreamComment(false);
} }
return true; return true;
@ -4384,7 +4409,8 @@ bool Notepad_plus::doStreamComment()
} }
// BlockToStreamComment: If there is no stream-comment symbol, try the block comment: // BlockToStreamComment: If there is no stream-comment symbol, try the block comment:
if ((!commentStart) || (!commentStart[0]) || (commentStart == NULL) || (!commentEnd) || (!commentEnd[0]) || (commentEnd == NULL)) { if ((!commentStart) || (!commentStart[0]) || (commentStart == NULL) || (!commentEnd) || (!commentEnd[0]) || (commentEnd == NULL))
{
if (!(!commentLineSymbol || !commentLineSymbol[0] || commentLineSymbol == NULL)) if (!(!commentLineSymbol || !commentLineSymbol[0] || commentLineSymbol == NULL))
return doBlockComment(cm_comment); return doBlockComment(cm_comment);
else else
@ -4695,7 +4721,9 @@ void Notepad_plus::fullScreenToggle()
if (!_beforeSpecialView.isPostIt) if (!_beforeSpecialView.isPostIt)
{ {
_beforeSpecialView.preStyle = ::SetWindowLongPtr(_pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP); _beforeSpecialView.preStyle = ::SetWindowLongPtr(_pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP);
if (!_beforeSpecialView.preStyle) { //something went wrong, use default settings if (!_beforeSpecialView.preStyle)
{
//something went wrong, use default settings
_beforeSpecialView.preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; _beforeSpecialView.preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
} }
} }
@ -4830,7 +4858,9 @@ void Notepad_plus::postItToggle()
//Hide window so windows can properly update it //Hide window so windows can properly update it
::ShowWindow(_pPublicInterface->getHSelf(), SW_HIDE); ::ShowWindow(_pPublicInterface->getHSelf(), SW_HIDE);
_beforeSpecialView.preStyle = ::SetWindowLongPtr( _pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP ); _beforeSpecialView.preStyle = ::SetWindowLongPtr( _pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP );
if (!_beforeSpecialView.preStyle) { //something went wrong, use default settings if (!_beforeSpecialView.preStyle)
{
//something went wrong, use default settings
_beforeSpecialView.preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; _beforeSpecialView.preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
} }
//Redraw the window and refresh windowmanager cache, dont do anything else, sizing is done later on //Redraw the window and refresh windowmanager cache, dont do anything else, sizing is done later on
@ -5066,7 +5096,8 @@ bool Notepad_plus::emergency(const generic_string& emergencySavedDir)
return dumpFiles(emergencySavedDir.c_str(), TEXT("File")); return dumpFiles(emergencySavedDir.c_str(), TEXT("File"));
} }
bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) { bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix)
{
//start dumping unsaved files to recovery directory //start dumping unsaved files to recovery directory
bool somethingsaved = false; bool somethingsaved = false;
bool somedirty = false; bool somedirty = false;
@ -6845,7 +6876,8 @@ bool Notepad_plus::undoStreamComment(bool tryBlockComment)
// BlockToStreamComment: If there is no stream-comment symbol and we came not from doBlockComment, try the block comment: // BlockToStreamComment: If there is no stream-comment symbol and we came not from doBlockComment, try the block comment:
if ((!commentStart) || (!commentStart[0]) || (commentStart == NULL) || (!commentEnd) || (!commentEnd[0]) || (commentEnd == NULL)) { if ((!commentStart) || (!commentStart[0]) || (commentStart == NULL) || (!commentEnd) || (!commentEnd[0]) || (commentEnd == NULL))
{
if (!(!commentLineSymbol || !commentLineSymbol[0] || commentLineSymbol == NULL) && tryBlockComment) if (!(!commentLineSymbol || !commentLineSymbol[0] || commentLineSymbol == NULL) && tryBlockComment)
return doBlockComment(cm_uncomment); return doBlockComment(cm_uncomment);
else else

View File

@ -302,7 +302,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return FALSE; return FALSE;
BufferID id = (BufferID)wParam; BufferID id = (BufferID)wParam;
Buffer * b = MainFileManager.getBufferByID(id); Buffer * b = MainFileManager.getBufferByID(id);
if (b && b->getStatus() == DOC_UNNAMED) { if (b && b->getStatus() == DOC_UNNAMED)
{
b->setFileName(reinterpret_cast<const TCHAR*>(lParam)); b->setFileName(reinterpret_cast<const TCHAR*>(lParam));
return TRUE; return TRUE;
} }
@ -607,7 +608,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
switchEditViewTo(MAIN_VIEW); switchEditViewTo(MAIN_VIEW);
else if (hSec == hFocus) else if (hSec == hFocus)
switchEditViewTo(SUB_VIEW); switchEditViewTo(SUB_VIEW);
else { else
{
//Other Scintilla, ignore //Other Scintilla, ignore
} }
return TRUE; return TRUE;

View File

@ -1747,13 +1747,16 @@ void Notepad_plus::fileOpen()
if (stringVector *pfns = fDlg.doOpenMultiFilesDlg()) if (stringVector *pfns = fDlg.doOpenMultiFilesDlg())
{ {
size_t sz = pfns->size(); size_t sz = pfns->size();
for (size_t i = 0 ; i < sz ; ++i) { for (size_t i = 0 ; i < sz ; ++i)
{
BufferID test = doOpen(pfns->at(i).c_str(), fDlg.isReadOnly()); BufferID test = doOpen(pfns->at(i).c_str(), fDlg.isReadOnly());
if (test != BUFFER_INVALID) if (test != BUFFER_INVALID)
lastOpened = test; lastOpened = test;
} }
} }
if (lastOpened != BUFFER_INVALID) {
if (lastOpened != BUFFER_INVALID)
{
switchToFile(lastOpened); switchToFile(lastOpened);
} }
} }
@ -1776,7 +1779,8 @@ bool Notepad_plus::fileReload()
} }
bool Notepad_plus::isFileSession(const TCHAR * filename) { bool Notepad_plus::isFileSession(const TCHAR * filename)
{
// if file2open matches the ext of user defined session file ext, then it'll be opened as a session // if file2open matches the ext of user defined session file ext, then it'll be opened as a session
const TCHAR *definedSessionExt = NppParameters::getInstance().getNppGUI()._definedSessionExt.c_str(); const TCHAR *definedSessionExt = NppParameters::getInstance().getNppGUI()._definedSessionExt.c_str();
if (*definedSessionExt != '\0') if (*definedSessionExt != '\0')
@ -1950,7 +1954,8 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
{ {
const TCHAR *pFn = session._subViewFiles[k]._fileName.c_str(); const TCHAR *pFn = session._subViewFiles[k]._fileName.c_str();
if (isFileSession(pFn) || isFileWorkspace(pFn)) { if (isFileSession(pFn) || isFileWorkspace(pFn))
{
vector<sessionFileInfo>::iterator posIt = session._subViewFiles.begin() + k; vector<sessionFileInfo>::iterator posIt = session._subViewFiles.begin() + k;
session._subViewFiles.erase(posIt); session._subViewFiles.erase(posIt);
continue; //skip session files, not supporting recursive sessions or embedded workspace files continue; //skip session files, not supporting recursive sessions or embedded workspace files
@ -1970,7 +1975,8 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding); lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding);
//check if already open in main. If so, clone //check if already open in main. If so, clone
if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) { if (_mainDocTab.getIndexByBuffer(lastOpened) != -1)
{
loadBufferIntoView(lastOpened, SUB_VIEW); loadBufferIntoView(lastOpened, SUB_VIEW);
} }
} }

View File

@ -1790,8 +1790,8 @@ void NppParameters::initMenuKeys()
} }
} }
void NppParameters::initScintillaKeys() { void NppParameters::initScintillaKeys()
{
int nbCommands = sizeof(scintKeyDefs)/sizeof(ScintillaKeyDefinition); int nbCommands = sizeof(scintKeyDefs)/sizeof(ScintillaKeyDefinition);
//Warning! Matching function have to be consecutive //Warning! Matching function have to be consecutive
@ -6139,7 +6139,8 @@ TiXmlElement * NppParameters::insertGUIConfigBoolNode(TiXmlNode *r2w, const TCHA
return GUIConfigElement; return GUIConfigElement;
} }
int RGB2int(COLORREF color) { int RGB2int(COLORREF color)
{
return (((((DWORD)color) & 0x0000FF) << 16) | ((((DWORD)color) & 0x00FF00)) | ((((DWORD)color) & 0xFF0000) >> 16)); return (((((DWORD)color) & 0x0000FF) << 16) | ((((DWORD)color) & 0x00FF00)) | ((((DWORD)color) & 0xFF0000) >> 16));
} }

View File

@ -105,7 +105,8 @@ bool AutoCompletion::showApiAndWordComplete()
wordArray.push_back(_keyWordArray[i]); wordArray.push_back(_keyWordArray[i]);
canStop = true; canStop = true;
} }
else if (canStop) { else if (canStop)
{
// Early out since no more strings will match // Early out since no more strings will match
break; break;
} }
@ -754,18 +755,23 @@ void AutoCompletion::update(int character)
} }
} }
void AutoCompletion::callTipClick(size_t direction) { void AutoCompletion::callTipClick(size_t direction)
{
if (!_funcCompletionActive) if (!_funcCompletionActive)
return; return;
if (direction == 1) { if (direction == 1)
{
_funcCalltip.showPrevOverload(); _funcCalltip.showPrevOverload();
} else if (direction == 2) { }
else if (direction == 2)
{
_funcCalltip.showNextOverload(); _funcCalltip.showNextOverload();
} }
} }
bool AutoCompletion::setLanguage(LangType language) { bool AutoCompletion::setLanguage(LangType language)
{
if (_curLang == language) if (_curLang == language)
return true; return true;
_curLang = language; _curLang = language;
@ -783,7 +789,8 @@ bool AutoCompletion::setLanguage(LangType language) {
_funcCompletionActive = _pXmlFile->LoadFile(); _funcCompletionActive = _pXmlFile->LoadFile();
TiXmlNode * pAutoNode = NULL; TiXmlNode * pAutoNode = NULL;
if (_funcCompletionActive) { if (_funcCompletionActive)
{
_funcCompletionActive = false; //safety _funcCompletionActive = false; //safety
TiXmlNode * pNode = _pXmlFile->FirstChild(TEXT("NotepadPlus")); TiXmlNode * pNode = _pXmlFile->FirstChild(TEXT("NotepadPlus"));
if (!pNode) if (!pNode)
@ -816,7 +823,8 @@ bool AutoCompletion::setLanguage(LangType language) {
{ {
const TCHAR * val = 0; const TCHAR * val = 0;
val = pElem->Attribute(TEXT("ignoreCase")); val = pElem->Attribute(TEXT("ignoreCase"));
if (val && !lstrcmp(val, TEXT("no"))) { if (val && !lstrcmp(val, TEXT("no")))
{
_ignoreCase = false; _ignoreCase = false;
_funcCalltip._ignoreCase = false; _funcCalltip._ignoreCase = false;
} }
@ -838,9 +846,12 @@ bool AutoCompletion::setLanguage(LangType language) {
} }
} }
if (_funcCompletionActive) { if (_funcCompletionActive)
{
_funcCalltip.setLanguageXML(_pXmlKeyword); _funcCalltip.setLanguageXML(_pXmlKeyword);
} else { }
else
{
_funcCalltip.setLanguageXML(NULL); _funcCalltip.setLanguageXML(NULL);
} }

View File

@ -1553,7 +1553,8 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
TCHAR *pText = new TCHAR[stringSizeFind + 1]; TCHAR *pText = new TCHAR[stringSizeFind + 1];
wcscpy_s(pText, stringSizeFind + 1, txt2find); wcscpy_s(pText, stringSizeFind + 1, txt2find);
if (pOptions->_searchType == FindExtended) { if (pOptions->_searchType == FindExtended)
{
stringSizeFind = Searching::convertExtendedToString(txt2find, pText, stringSizeFind); stringSizeFind = Searching::convertExtendedToString(txt2find, pText, stringSizeFind);
} }
@ -1982,7 +1983,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
if (op == ProcessMarkAll && colourStyleID == -1) //if marking, check if purging is needed if (op == ProcessMarkAll && colourStyleID == -1) //if marking, check if purging is needed
{ {
if (_env->_doPurge) { if (_env->_doPurge)
{
clearMarks(*_env); clearMarks(*_env);
} }
} }
@ -2006,7 +2008,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
targetEnd = int(pEditView->execute(SCI_GETTARGETEND)); targetEnd = int(pEditView->execute(SCI_GETTARGETEND));
if (targetEnd > findReplaceInfo._endRange) { //we found a result but outside our range, therefore do not process it if (targetEnd > findReplaceInfo._endRange)
{
//we found a result but outside our range, therefore do not process it
break; break;
} }
@ -2402,7 +2406,8 @@ bool FindReplaceDlg::removeFinder(Finder *finder2remove)
return false; return false;
} }
void FindReplaceDlg::setSearchText(TCHAR * txt2find) { void FindReplaceDlg::setSearchText(TCHAR * txt2find)
{
HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
if (txt2find && txt2find[0]) if (txt2find && txt2find[0])
{ {
@ -2584,7 +2589,8 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus
} }
else if (staus == FSTopReached || staus == FSEndReached) else if (staus == FSTopReached || staus == FSEndReached)
{ {
if (!isVisible()) { if (!isVisible())
{
FLASHWINFO flashInfo; FLASHWINFO flashInfo;
flashInfo.cbSize = sizeof(FLASHWINFO); flashInfo.cbSize = sizeof(FLASHWINFO);
flashInfo.hwnd = GetParent(_hSelf); flashInfo.hwnd = GetParent(_hSelf);

View File

@ -61,7 +61,8 @@ inline bool match(TCHAR c1, TCHAR c2) {
//0 if equal, <0 of before, >0 if after (name1 that is) //0 if equal, <0 of before, >0 if after (name1 that is)
int testNameNoCase(const TCHAR * name1, const TCHAR * name2, int len = -1) int testNameNoCase(const TCHAR * name1, const TCHAR * name2, int len = -1)
{ {
if (len == -1) { if (len == -1)
{
len = 1024; //magic value, but it probably fails way before it reaches this len = 1024; //magic value, but it probably fails way before it reaches this
} }
int i = 0; int i = 0;
@ -344,7 +345,8 @@ bool FunctionCallTip::loadFunction()
TiXmlElement *overloadNode = _curFunction->FirstChildElement(TEXT("Overload")); TiXmlElement *overloadNode = _curFunction->FirstChildElement(TEXT("Overload"));
TiXmlElement *paramNode = NULL; TiXmlElement *paramNode = NULL;
for (; overloadNode ; overloadNode = overloadNode->NextSiblingElement(TEXT("Overload")) ) { for (; overloadNode ; overloadNode = overloadNode->NextSiblingElement(TEXT("Overload")) )
{
const TCHAR * retVal = overloadNode->Attribute(TEXT("retVal")); const TCHAR * retVal = overloadNode->Attribute(TEXT("retVal"));
if (!retVal) if (!retVal)
continue; //malformed node continue; //malformed node
@ -357,7 +359,8 @@ bool FunctionCallTip::loadFunction()
_descriptions.push_back(TEXT("")); //"no description available" _descriptions.push_back(TEXT("")); //"no description available"
paramNode = overloadNode->FirstChildElement(TEXT("Param")); paramNode = overloadNode->FirstChildElement(TEXT("Param"));
for (; paramNode ; paramNode = paramNode->NextSiblingElement(TEXT("Param")) ) { for (; paramNode ; paramNode = paramNode->NextSiblingElement(TEXT("Param")) )
{
const TCHAR * param = paramNode->Attribute(TEXT("name")); const TCHAR * param = paramNode->Attribute(TEXT("name"));
if (!param) if (!param)
continue; //malformed node continue; //malformed node
@ -445,7 +448,8 @@ void FunctionCallTip::showCalltip()
} }
} }
void FunctionCallTip::reset() { void FunctionCallTip::reset()
{
_currentOverload = 0; _currentOverload = 0;
_currentParam = 0; _currentParam = 0;
//_curPos = 0; //_curPos = 0;
@ -456,7 +460,8 @@ void FunctionCallTip::reset() {
_descriptions.clear(); _descriptions.clear();
} }
void FunctionCallTip::cleanup() { void FunctionCallTip::cleanup()
{
reset(); reset();
delete [] _funcName; delete [] _funcName;
_funcName = 0; _funcName = 0;

View File

@ -396,7 +396,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
return TRUE; return TRUE;
} }
if (LOWORD(wParam) & MK_SHIFT) { if (LOWORD(wParam) & MK_SHIFT)
{
// move 3 columns at a time // move 3 columns at a time
::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, ((short)HIWORD(wParam) < 0) ? SB_LINERIGHT : SB_LINELEFT, NULL); ::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, ((short)HIWORD(wParam) < 0) ? SB_LINERIGHT : SB_LINELEFT, NULL);
::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, ((short)HIWORD(wParam) < 0) ? SB_LINERIGHT : SB_LINELEFT, NULL); ::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, ((short)HIWORD(wParam) < 0) ? SB_LINERIGHT : SB_LINELEFT, NULL);
@ -1895,13 +1896,15 @@ void ScintillaEditView::restoreCurrentPosPostStep()
} }
} }
void ScintillaEditView::restyleBuffer() { void ScintillaEditView::restyleBuffer()
{
execute(SCI_CLEARDOCUMENTSTYLE); execute(SCI_CLEARDOCUMENTSTYLE);
execute(SCI_COLOURISE, 0, -1); execute(SCI_COLOURISE, 0, -1);
_currentBuffer->setNeedsLexing(false); _currentBuffer->setNeedsLexing(false);
} }
void ScintillaEditView::styleChange() { void ScintillaEditView::styleChange()
{
defineDocType(_currentBuffer->getLangType()); defineDocType(_currentBuffer->getLangType());
restyleBuffer(); restyleBuffer();
} }
@ -2641,23 +2644,31 @@ void ScintillaEditView::setLineIndent(int line, int indent) const
execute(SCI_SETLINEINDENTATION, line, indent); execute(SCI_SETLINEINDENTATION, line, indent);
int32_t posAfter = static_cast<int32_t>(execute(SCI_GETLINEINDENTPOSITION, line)); int32_t posAfter = static_cast<int32_t>(execute(SCI_GETLINEINDENTPOSITION, line));
int posDifference = posAfter - posBefore; int posDifference = posAfter - posBefore;
if (posAfter > posBefore) { if (posAfter > posBefore)
{
// Move selection on // Move selection on
if (crange.cpMin >= posBefore) { if (crange.cpMin >= posBefore)
{
crange.cpMin += posDifference; crange.cpMin += posDifference;
} }
if (crange.cpMax >= posBefore) { if (crange.cpMax >= posBefore)
{
crange.cpMax += posDifference; crange.cpMax += posDifference;
} }
} else if (posAfter < posBefore) { }
else if (posAfter < posBefore)
{
// Move selection back // Move selection back
if (crange.cpMin >= posAfter) { if (crange.cpMin >= posAfter)
{
if (crange.cpMin >= posBefore) if (crange.cpMin >= posBefore)
crange.cpMin += posDifference; crange.cpMin += posDifference;
else else
crange.cpMin = posAfter; crange.cpMin = posAfter;
} }
if (crange.cpMax >= posAfter) {
if (crange.cpMax >= posAfter)
{
if (crange.cpMax >= posBefore) if (crange.cpMax >= posBefore)
crange.cpMax += posDifference; crange.cpMax += posDifference;
else else
@ -2974,7 +2985,8 @@ pair<int, int> ScintillaEditView::getWordRange()
bool ScintillaEditView::expandWordSelection() bool ScintillaEditView::expandWordSelection()
{ {
pair<int, int> wordRange = getWordRange(); pair<int, int> wordRange = getWordRange();
if (wordRange.first != wordRange.second) { if (wordRange.first != wordRange.second)
{
execute(SCI_SETSELECTIONSTART, wordRange.first); execute(SCI_SETSELECTIONSTART, wordRange.first);
execute(SCI_SETSELECTIONEND, wordRange.second); execute(SCI_SETSELECTIONEND, wordRange.second);
return true; return true;
@ -3316,7 +3328,9 @@ void ScintillaEditView::hideLines()
execute(SCI_MARKERDELETE, i, MARK_HIDELINESEND); execute(SCI_MARKERDELETE, i, MARK_HIDELINESEND);
if (scope > 0) scope--; if (scope > 0) scope--;
} }
if (openPresent) {
if (openPresent)
{
execute(SCI_MARKERDELETE, i, MARK_HIDELINESBEGIN); execute(SCI_MARKERDELETE, i, MARK_HIDELINESBEGIN);
execute(SCI_MARKERDELETE, i, MARK_HIDELINESUNDERLINE); execute(SCI_MARKERDELETE, i, MARK_HIDELINESUNDERLINE);
++scope; ++scope;
@ -3364,11 +3378,13 @@ bool ScintillaEditView::markerMarginClick(int lineNumber)
return true; return true;
} }
void ScintillaEditView::notifyMarkers(Buffer * buf, bool isHide, int location, bool del) { void ScintillaEditView::notifyMarkers(Buffer * buf, bool isHide, int location, bool del)
{
if (buf != _currentBuffer) //if not visible buffer dont do a thing if (buf != _currentBuffer) //if not visible buffer dont do a thing
return; return;
runMarkers(isHide, location, false, del); runMarkers(isHide, location, false, del);
} }
//Run through full document. When switching in or opening folding //Run through full document. When switching in or opening folding
//hide is false only when user click on margin //hide is false only when user click on margin
void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDoc, bool doDelete) void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDoc, bool doDelete)

View File

@ -8,9 +8,11 @@
#include <windows.h> #include <windows.h>
#include "UniConversion.h" #include "UniConversion.h"
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) { unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen)
{
unsigned int len = 0; unsigned int len = 0;
for (unsigned int i = 0; i < tlen && uptr[i]; ++i) { for (unsigned int i = 0; i < tlen && uptr[i]; ++i)
{
unsigned int uch = uptr[i]; unsigned int uch = uptr[i];
if (uch < 0x80) if (uch < 0x80)
++len; ++len;
@ -22,16 +24,23 @@ unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
return len; return len;
} }
void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) { void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len)
{
int k = 0; int k = 0;
for (unsigned int i = 0; i < tlen && uptr[i]; ++i) { for (unsigned int i = 0; i < tlen && uptr[i]; ++i)
{
unsigned int uch = uptr[i]; unsigned int uch = uptr[i];
if (uch < 0x80) { if (uch < 0x80)
{
putf[k++] = static_cast<char>(uch); putf[k++] = static_cast<char>(uch);
} else if (uch < 0x800) { }
else if (uch < 0x800)
{
putf[k++] = static_cast<char>(0xC0 | (uch >> 6)); putf[k++] = static_cast<char>(0xC0 | (uch >> 6));
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f)); putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
} else { }
else
{
putf[k++] = static_cast<char>(0xE0 | (uch >> 12)); putf[k++] = static_cast<char>(0xE0 | (uch >> 12));
putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f)); putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f));
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f)); putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
@ -40,9 +49,11 @@ void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned i
putf[len] = '\0'; putf[len] = '\0';
} }
unsigned int UCS2Length(const char *s, unsigned int len) { unsigned int UCS2Length(const char *s, unsigned int len)
{
unsigned int ulen = 0; unsigned int ulen = 0;
for (unsigned int i=0; i<len; ++i) { for (unsigned int i=0; i<len; ++i)
{
UCHAR ch = static_cast<UCHAR>(s[i]); UCHAR ch = static_cast<UCHAR>(s[i]);
if ((ch < 0x80) || (ch > (0x80 + 0x40))) if ((ch < 0x80) || (ch > (0x80 + 0x40)))
++ulen; ++ulen;
@ -55,15 +66,21 @@ unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsign
unsigned int ui=0; unsigned int ui=0;
const UCHAR *us = reinterpret_cast<const UCHAR *>(s); const UCHAR *us = reinterpret_cast<const UCHAR *>(s);
unsigned int i=0; unsigned int i=0;
while ((i<len) && (ui<tlen)) { while ((i<len) && (ui<tlen))
{
UCHAR ch = us[i++]; UCHAR ch = us[i++];
if (ch < 0x80) { if (ch < 0x80)
{
tbuf[ui] = ch; tbuf[ui] = ch;
} else if (ch < 0x80 + 0x40 + 0x20) { }
else if (ch < 0x80 + 0x40 + 0x20)
{
tbuf[ui] = static_cast<wchar_t>((ch & 0x1F) << 6); tbuf[ui] = static_cast<wchar_t>((ch & 0x1F) << 6);
ch = us[i++]; ch = us[i++];
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F)); tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
} else { }
else
{
tbuf[ui] = static_cast<wchar_t>((ch & 0xF) << 12); tbuf[ui] = static_cast<wchar_t>((ch & 0xF) << 12);
ch = us[i++]; ch = us[i++];
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + ((ch & 0x7F) << 6)); tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + ((ch & 0x7F) << 6));

View File

@ -463,10 +463,13 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct)
// begin with paint // begin with paint
::SetBkMode(hDc, TRANSPARENT); ::SetBkMode(hDc, TRANSPARENT);
if (_isActive == TRUE) { if (_isActive == TRUE)
{
bgbrush = ::CreateSolidBrush(::GetSysColor(COLOR_ACTIVECAPTION)); bgbrush = ::CreateSolidBrush(::GetSysColor(COLOR_ACTIVECAPTION));
::SetTextColor(hDc, ::GetSysColor(COLOR_CAPTIONTEXT)); ::SetTextColor(hDc, ::GetSysColor(COLOR_CAPTIONTEXT));
} else { }
else
{
bgbrush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE)); bgbrush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
} }

View File

@ -247,7 +247,8 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
case WM_DESTROY: case WM_DESTROY:
{ {
// unregister window event hooking BEFORE EVERYTHING ELSE // unregister window event hooking BEFORE EVERYTHING ELSE
if (hWndServer == hwnd) { if (hWndServer == hwnd)
{
UnhookWindowsHookEx(gWinCallHook); UnhookWindowsHookEx(gWinCallHook);
gWinCallHook = NULL; gWinCallHook = NULL;
hWndServer = NULL; hWndServer = NULL;

View File

@ -98,7 +98,8 @@ generic_string ShortcutMapper::getTabString(size_t i) const
} }
void ShortcutMapper::initBabyGrid() { void ShortcutMapper::initBabyGrid()
{
RECT rect; RECT rect;
getClientRect(rect); getClientRect(rect);
@ -153,7 +154,8 @@ bool ShortcutMapper::isFilterValid(Shortcut sc)
{ {
bool match = false; bool match = false;
generic_string shortcut_name = stringToLower(generic_string(sc.getName())); generic_string shortcut_name = stringToLower(generic_string(sc.getName()));
if (_shortcutFilter.empty()) { if (_shortcutFilter.empty())
{
return true; return true;
} }
// test the filter on the shortcut name // test the filter on the shortcut name

View File

@ -348,7 +348,9 @@ static LRESULT CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPAR
}; };
static TCHAR * get1stExt(TCHAR *ext) { // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt) static TCHAR * get1stExt(TCHAR *ext)
{
// precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt)
TCHAR *begin = ext; TCHAR *begin = ext;
for ( ; *begin != '.' ; begin++); for ( ; *begin != '.' ; begin++);
TCHAR *end = ++begin; TCHAR *end = ++begin;
@ -359,7 +361,8 @@ static TCHAR * get1stExt(TCHAR *ext) { // precondition : ext should be under the
return begin; return begin;
}; };
static generic_string addExt(HWND textCtrl, HWND typeCtrl) { static generic_string addExt(HWND textCtrl, HWND typeCtrl)
{
TCHAR fn[MAX_PATH]; TCHAR fn[MAX_PATH];
::GetWindowText(textCtrl, fn, MAX_PATH); ::GetWindowText(textCtrl, fn, MAX_PATH);

View File

@ -447,12 +447,15 @@ bool ReBar::addBand(REBARBANDINFO * rBand, bool useID)
} }
else else
rBand->fStyle = RBBS_GRIPPERALWAYS; rBand->fStyle = RBBS_GRIPPERALWAYS;
rBand->fMask |= RBBIM_ID | RBBIM_STYLE; rBand->fMask |= RBBIM_ID | RBBIM_STYLE;
if (useID) { if (useID)
{
if (isIDTaken(rBand->wID)) if (isIDTaken(rBand->wID))
return false; return false;
}
} else { else
{
rBand->wID = getNewID(); rBand->wID = getNewID();
} }
::SendMessage(_hSelf, RB_INSERTBAND, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(rBand)); //add to end of list ::SendMessage(_hSelf, RB_INSERTBAND, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(rBand)); //add to end of list

View File

@ -28,9 +28,11 @@ WINRECT::WINRECT(WORD f, int id, LONG p)
WINRECT* WINRECT::Parent() WINRECT* WINRECT::Parent()
{ {
WINRECT* pEntry = NULL; WINRECT* pEntry = NULL;
for (pEntry=this; pEntry->Prev(); pEntry=pEntry->Prev()) { for (pEntry=this; pEntry->Prev(); pEntry=pEntry->Prev())
; // go backwards to the end {
// go backwards to the end
} }
// the entry before the first child is the group // the entry before the first child is the group
WINRECT *parent = pEntry-1; WINRECT *parent = pEntry-1;
assert(parent->IsGroup()); assert(parent->IsGroup());
@ -42,7 +44,8 @@ WINRECT* WINRECT::Parent()
// //
BOOL WINRECT::GetMargins(int& w, int& h) BOOL WINRECT::GetMargins(int& w, int& h)
{ {
if (IsGroup()) { if (IsGroup())
{
w=(short)LOWORD(param); w=(short)LOWORD(param);
h=(short)HIWORD(param); h=(short)HIWORD(param);
return TRUE; return TRUE;
@ -62,13 +65,15 @@ WINRECT* WINRECT::InitMap(WINRECT* pWinMap, WINRECT* parent)
WINRECT* pwrc = pWinMap; // current table entry WINRECT* pwrc = pWinMap; // current table entry
WINRECT* prev = NULL; // previous entry starts out none WINRECT* prev = NULL; // previous entry starts out none
while (!pwrc->IsEndGroup()) { while (!pwrc->IsEndGroup())
{
pwrc->prev=prev; pwrc->prev=prev;
pwrc->next=NULL; pwrc->next=NULL;
if (prev) if (prev)
prev->next = pwrc; prev->next = pwrc;
prev = pwrc; prev = pwrc;
if (pwrc->IsGroup()) { if (pwrc->IsGroup())
{
pwrc = InitMap(pwrc+1,pwrc); // recurse! Returns end-of-grp pwrc = InitMap(pwrc+1,pwrc); // recurse! Returns end-of-grp
assert(pwrc->IsEndGroup()); assert(pwrc->IsEndGroup());
} }

View File

@ -55,6 +55,7 @@ const UINT WDN_NOTIFY = RegisterWindowMessage(TEXT("WDN_NOTIFY"));
inline static DWORD GetStyle(HWND hWnd) { inline static DWORD GetStyle(HWND hWnd) {
return (DWORD)GetWindowLongPtr(hWnd, GWL_STYLE); return (DWORD)GetWindowLongPtr(hWnd, GWL_STYLE);
} }
inline static DWORD GetExStyle(HWND hWnd) { inline static DWORD GetExStyle(HWND hWnd) {
return (DWORD)GetWindowLongPtr(hWnd, GWL_EXSTYLE); return (DWORD)GetWindowLongPtr(hWnd, GWL_EXSTYLE);
} }
@ -705,7 +706,8 @@ void WindowsDlg::doSave()
nmdlg.code = WDN_NOTIFY; nmdlg.code = WDN_NOTIFY;
nmdlg.nItems = ListView_GetSelectedCount(_hList); nmdlg.nItems = ListView_GetSelectedCount(_hList);
nmdlg.Items = new UINT[nmdlg.nItems]; nmdlg.Items = new UINT[nmdlg.nItems];
for (int i=-1, j=0;;++j) { for (int i=-1, j=0; ; ++j)
{
i = ListView_GetNextItem(_hList, i, LVNI_SELECTED); i = ListView_GetNextItem(_hList, i, LVNI_SELECTED);
if (i == -1) break; if (i == -1) break;
nmdlg.Items[j] = _idxMap[i]; nmdlg.Items[j] = _idxMap[i];
@ -723,7 +725,6 @@ void WindowsDlg::destroy()
HWND hSelf = _hSelf; HWND hSelf = _hSelf;
_hSelf = NULL; _hSelf = NULL;
::DestroyWindow(hSelf); ::DestroyWindow(hSelf);
} }
void WindowsDlg::activateCurrent() void WindowsDlg::activateCurrent()

View File

@ -440,10 +440,13 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
return TRUE; return TRUE;
case IDOK : case IDOK :
if (!isEnabled()) { if (!isEnabled())
{
_keyCombo._isCtrl = _keyCombo._isAlt = _keyCombo._isShift = false; _keyCombo._isCtrl = _keyCombo._isAlt = _keyCombo._isShift = false;
} }
if (_canModifyName) {
if (_canModifyName)
{
TCHAR editName[nameLenMax]; TCHAR editName[nameLenMax];
::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXT, nameLenMax, reinterpret_cast<LPARAM>(editName)); ::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXT, nameLenMax, reinterpret_cast<LPARAM>(editName));
setName(editName); setName(editName);
@ -645,8 +648,10 @@ void Accelerator::updateMenuItemByCommand(const CommandShortcut& csc)
recordedMacroStep::recordedMacroStep(int iMessage, uptr_t wParam, uptr_t lParam, int codepage) recordedMacroStep::recordedMacroStep(int iMessage, uptr_t wParam, uptr_t lParam, int codepage)
: _message(iMessage), _wParameter(wParam), _lParameter(lParam), _macroType(mtUseLParameter) : _message(iMessage), _wParameter(wParam), _lParameter(lParam), _macroType(mtUseLParameter)
{ {
if (_lParameter) { if (_lParameter)
switch (_message) { {
switch (_message)
{
case SCI_SETTEXT : case SCI_SETTEXT :
case SCI_REPLACESEL : case SCI_REPLACESEL :
case SCI_REPLACETARGET : case SCI_REPLACETARGET :
@ -971,7 +976,8 @@ void ScintillaKeyMap::validateDialog()
updateConflictState(); updateConflictState();
} }
void ScintillaKeyMap::showCurrentSettings() { void ScintillaKeyMap::showCurrentSettings()
{
auto keyIndex = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0); auto keyIndex = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0);
_keyCombo = _keyCombos[keyIndex]; _keyCombo = _keyCombos[keyIndex];
::SendDlgItemMessage(_hSelf, IDC_CTRL_CHECK, BM_SETCHECK, _keyCombo._isCtrl?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CTRL_CHECK, BM_SETCHECK, _keyCombo._isCtrl?BST_CHECKED:BST_UNCHECKED, 0);
@ -987,7 +993,8 @@ void ScintillaKeyMap::showCurrentSettings() {
} }
} }
void ScintillaKeyMap::updateListItem(int index) { void ScintillaKeyMap::updateListItem(int index)
{
::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, index, reinterpret_cast<LPARAM>(toString(index).c_str())); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, index, reinterpret_cast<LPARAM>(toString(index).c_str()));
::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, index+1, 0); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, index+1, 0);
} }
@ -1129,7 +1136,8 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA
//return FALSE; //return FALSE;
} }
CommandShortcut::CommandShortcut(const Shortcut& sc, long id) : Shortcut(sc), _id(id) { CommandShortcut::CommandShortcut(const Shortcut& sc, long id) : Shortcut(sc), _id(id)
{
if ( _id < IDM_EDIT) if ( _id < IDM_EDIT)
_category = TEXT("File"); _category = TEXT("File");
else if ( _id < IDM_SEARCH) else if ( _id < IDM_SEARCH)

View File

@ -174,14 +174,19 @@ void LastRecentFileList::add(const TCHAR *fn)
RecentItem itemToAdd(fn); RecentItem itemToAdd(fn);
int index = find(fn); int index = find(fn);
if (index != -1) { //already in list, bump upwards if (index != -1)
{
//already in list, bump upwards
remove(index); remove(index);
} }
if (_size == _userMax) { if (_size == _userMax)
{
itemToAdd._id = _lrfl.back()._id; itemToAdd._id = _lrfl.back()._id;
_lrfl.pop_back(); //remove oldest _lrfl.pop_back(); //remove oldest
} else { }
else
{
itemToAdd._id = popFirstAvailableID(); itemToAdd._id = popFirstAvailableID();
++_size; ++_size;
} }

View File

@ -55,7 +55,8 @@ float CharDistributionAnalysis::GetConfidence(void)
if (mTotalChars <= 0 || mFreqChars <= mDataThreshold) if (mTotalChars <= 0 || mFreqChars <= mDataThreshold)
return SURE_NO; return SURE_NO;
if (mTotalChars != mFreqChars) { if (mTotalChars != mFreqChars)
{
float r = mFreqChars / ((mTotalChars - mFreqChars) * mTypicalDistributionRatio); float r = mFreqChars / ((mTotalChars - mFreqChars) * mTypicalDistributionRatio);
if (r < SURE_YES) if (r < SURE_YES)

View File

@ -146,7 +146,8 @@ bool getParamVal(TCHAR c, ParamVector & params, generic_string & value)
for (size_t i = 0; i < nbItems; ++i) for (size_t i = 0; i < nbItems; ++i)
{ {
const TCHAR * token = params.at(i).c_str(); const TCHAR * token = params.at(i).c_str();
if (token[0] == '-' && lstrlen(token) >= 2 && token[1] == c) { //dash, and enough chars if (token[0] == '-' && lstrlen(token) >= 2 && token[1] == c) //dash, and enough chars
{
value = (token+2); value = (token+2);
params.erase(params.begin() + i); params.erase(params.begin() + i);
return true; return true;
@ -191,7 +192,8 @@ generic_string getLocalizationPathFromParam(ParamVector & params)
return NppParameters::getLocPathFromStr(locStr.c_str()); return NppParameters::getLocPathFromStr(locStr.c_str());
} }
int getNumberFromParam(char paramName, ParamVector & params, bool & isParamePresent) { int getNumberFromParam(char paramName, ParamVector & params, bool & isParamePresent)
{
generic_string numStr; generic_string numStr;
if (!getParamVal(paramName, params, numStr)) if (!getParamVal(paramName, params, numStr))
{ {