[BUG_FIXED] Fix cancel to save file in Notepad++ can not stop system shutdown problem.

Fix ANSI version copy file name bug.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@341 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-10-11 00:57:03 +00:00
parent 8e3555f8e5
commit d2c8c52c51
3 changed files with 63 additions and 105 deletions

View File

@ -4127,7 +4127,6 @@ void Notepad_plus::command(int id)
break; break;
case IDM_EDIT_AUTOCOMPLETE_CURRENTFILE : case IDM_EDIT_AUTOCOMPLETE_CURRENTFILE :
//MessageBox(NULL, TEXT("IDM_EDIT_AUTOCOMPLETE_CURRENTFILE"), TEXT(""), MB_OK);
autoCompFromCurrentFile(); autoCompFromCurrentFile();
break; break;
@ -4249,7 +4248,6 @@ void Notepad_plus::command(int id)
long exStyle = ::GetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE); long exStyle = ::GetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE);
exStyle = (id == IDM_EDIT_RTL)?exStyle|WS_EX_LAYOUTRTL:exStyle&(~WS_EX_LAYOUTRTL); exStyle = (id == IDM_EDIT_RTL)?exStyle|WS_EX_LAYOUTRTL:exStyle&(~WS_EX_LAYOUTRTL);
::SetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE, exStyle); ::SetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE, exStyle);
//_pEditView->defineDocType(_pEditView->getCurrentDocType());
_pEditView->redraw(); _pEditView->redraw();
} }
break; break;
@ -4267,8 +4265,6 @@ void Notepad_plus::command(int id)
dlgNode = searchDlgNode(dlgNode, TEXT("Window")); dlgNode = searchDlgNode(dlgNode, TEXT("Window"));
} }
_windowsDlg.doDialog(dlgNode); _windowsDlg.doDialog(dlgNode);
//changeDlgLang(_windowsDlg.getHSelf(), TEXT("Window"));
} }
break; break;
@ -4793,11 +4789,8 @@ void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose)
} }
MainFileManager->addBufferReference(id, viewToOpen); MainFileManager->addBufferReference(id, viewToOpen);
//viewToOpen->activateBuffer(id);
//activateBuffer(id, whichOne);
if (idToClose != BUFFER_INVALID) { //close clean doc. Use special logic to prevent flicker of tab showing then hiding if (idToClose != BUFFER_INVALID) { //close clean doc. Use special logic to prevent flicker of tab showing then hiding
//removeBufferFromView(idToClose, whichOne);
tabToOpen->setBuffer(0, id); //index 0 since only one open tabToOpen->setBuffer(0, id); //index 0 since only one open
activateBuffer(id, whichOne); //activate. DocTab already activated but not a problem activateBuffer(id, whichOne); //activate. DocTab already activated but not a problem
MainFileManager->closeBuffer(idToClose, viewToOpen); //delete the buffer MainFileManager->closeBuffer(idToClose, viewToOpen); //delete the buffer
@ -4827,8 +4820,6 @@ void Notepad_plus::removeBufferFromView(BufferID id, int whichOne) {
int active = tabToClose->getCurrentTabIndex(); int active = tabToClose->getCurrentTabIndex();
if (active == index) { //need an alternative (close real doc, put empty one back if (active == index) { //need an alternative (close real doc, put empty one back
if (tabToClose->nbItem() == 1) { //need alternative doc, add new one. Use special logic to prevent flicker of adding new tab then closing other if (tabToClose->nbItem() == 1) { //need alternative doc, add new one. Use special logic to prevent flicker of adding new tab then closing other
//loadBufferIntoView(newID, whichOne);
//viewToOpen->activateBuffer(id);
BufferID newID = MainFileManager->newEmptyDocument(); BufferID newID = MainFileManager->newEmptyDocument();
MainFileManager->addBufferReference(newID, viewToClose); MainFileManager->addBufferReference(newID, viewToClose);
tabToClose->setBuffer(0, newID); //can safely use id 0, last (only) tab open tabToClose->setBuffer(0, newID); //can safely use id 0, last (only) tab open
@ -4922,8 +4913,8 @@ void Notepad_plus::undockUserDlg()
_mainWindowStatus &= ~WindowUserActive; _mainWindowStatus &= ~WindowUserActive;
(ScintillaEditView::getUserDefineDlg())->display(); (ScintillaEditView::getUserDefineDlg())->display();
//(_pEditView->getUserDefineDlg())->display();
} }
void Notepad_plus::docOpenInNewInstance(FileTransferMode mode) void Notepad_plus::docOpenInNewInstance(FileTransferMode mode)
{ {
BufferID bufferID = _pEditView->getCurrentBufferID(); BufferID bufferID = _pEditView->getCurrentBufferID();
@ -5469,8 +5460,6 @@ void Notepad_plus::changeUserDefineLang()
int nbGpArray[nbDlg] = {nbGrpFolder, nbGrpKeywords, nbGrpComment, nbGrpOperator}; int nbGpArray[nbDlg] = {nbGrpFolder, nbGrpKeywords, nbGrpComment, nbGrpOperator};
const TCHAR nodeNameArray[nbDlg][16] = {TEXT("Folder"), TEXT("Keywords"), TEXT("Comment"), TEXT("Operator")}; const TCHAR nodeNameArray[nbDlg][16] = {TEXT("Folder"), TEXT("Keywords"), TEXT("Comment"), TEXT("Operator")};
//int **idArrays[nbDlg] = {(int **)folderID, (int **)keywordsID, (int **)commentID, (int **)operatorID};
for (int i = 0 ; i < nbDlg ; i++) for (int i = 0 ; i < nbDlg ; i++)
{ {
@ -5884,13 +5873,10 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, i); int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, i);
if ((lineEnd - lineIndent) >= linebufferSize) // Avoid buffer size problems if ((lineEnd - lineIndent) >= linebufferSize) // Avoid buffer size problems
continue; continue;
/*if (props.GetInt(comment_at_line_start.c_str())) {
GetRange(wEditor, lineIndent, lineEnd, linebuf);
} else*/
{
lineIndent = _pEditView->execute(SCI_GETLINEINDENTPOSITION, i); lineIndent = _pEditView->execute(SCI_GETLINEINDENTPOSITION, i);
_pEditView->getGenericText(linebuf, lineIndent, lineEnd); _pEditView->getGenericText(linebuf, lineIndent, lineEnd);
}
// empty lines are not commented // empty lines are not commented
if (lstrlen(linebuf) < 1) if (lstrlen(linebuf) < 1)
continue; continue;
@ -6282,7 +6268,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_invisibleEditView.init(_hInst, hwnd); _invisibleEditView.init(_hInst, hwnd);
_invisibleEditView.execute(SCI_SETUNDOCOLLECTION); _invisibleEditView.execute(SCI_SETUNDOCOLLECTION);
_invisibleEditView.execute(SCI_EMPTYUNDOBUFFER); _invisibleEditView.execute(SCI_EMPTYUNDOBUFFER);
//_invisibleEditView.attachDefaultDoc();
// Configuration of 2 scintilla views // Configuration of 2 scintilla views
_mainEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp1._lineNumberMarginShow); _mainEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp1._lineNumberMarginShow);
@ -6753,15 +6738,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_findReplaceDlg.launchFindInFilesDlg(); _findReplaceDlg.launchFindInFilesDlg();
const TCHAR *dir = NULL; const TCHAR *dir = NULL;
//TCHAR currentDir[MAX_PATH];
generic_string fltr; generic_string fltr;
if (wParam) if (wParam)
dir = (const TCHAR *)wParam; dir = (const TCHAR *)wParam;
else else
{ {
//::GetCurrentDirectory(MAX_PATH, currentDir);
//dir = currentDir;
dir = NppParameters::getInstance()->getWorkingDir(); dir = NppParameters::getInstance()->getWorkingDir();
} }
@ -6893,7 +6875,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
getMainClientRect(rc); getMainClientRect(rc);
_dockingManager.reSizeTo(rc); _dockingManager.reSizeTo(rc);
//_pMainWindow->reSizeTo(rc);
result = TRUE; result = TRUE;
} }
@ -6919,7 +6900,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_COPYDATA : case WM_COPYDATA :
{ {
//const DWORD LASTBYTEMASK = 0x000000FF;
COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)lParam; COPYDATASTRUCT *pCopyData = (COPYDATASTRUCT *)lParam;
switch (pCopyData->dwData) switch (pCopyData->dwData)
@ -7224,21 +7204,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
for (size_t j = 0 ; j < session2Load.nbSubFiles() ; j++) for (size_t j = 0 ; j < session2Load.nbSubFiles() ; j++)
{ {
const TCHAR *pFn = session2Load._subViewFiles[j]._fileName.c_str(); const TCHAR *pFn = session2Load._subViewFiles[j]._fileName.c_str();
// comment to remove
/*
// make sure that the same file is not cloned in another view
bool foundInMainView = false;
for (size_t k = 0 ; k < session2Load.nbMainFiles() ; k++)
{
const TCHAR *pFnMain = session2Load._mainViewFiles[k]._fileName.c_str();
if (lstrcmp(pFn, pFnMain) == 0)
{
foundInMainView = true;
break;
}
}
if (!foundInMainView)
*/
lstrcpy(sessionFileArray[i++], pFn); lstrcpy(sessionFileArray[i++], pFn);
} }
return TRUE; return TRUE;
@ -7767,26 +7732,39 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return TRUE; return TRUE;
} }
//case WM_ENDSESSION:
case WM_QUERYENDSESSION: case WM_QUERYENDSESSION:
case WM_CLOSE: case WM_CLOSE:
{ {
if (_isfullScreen)
fullScreenToggle();
const NppGUI & nppgui = pNppParam->getNppGUI(); const NppGUI & nppgui = pNppParam->getNppGUI();
Session currentSession;
if (nppgui._rememberLastSession)
{
getCurrentOpenedFiles(currentSession);
//Lock the recent file list so it isnt populated with opened files
//Causing them to show on restart even though they are loaded by session
_lastRecentFileList.setLock(true); //only lock when the session is remembered
}
bool allClosed = fileCloseAll(); //try closing files before doing anything else
if (nppgui._rememberLastSession)
{
_lastRecentFileList.setLock(false); //only lock when the session is remembered
}
if (!allClosed)
{
//User cancelled the shutdown
return FALSE;
}
if (_isfullScreen) //closing, return to windowed mode
fullScreenToggle();
if (_configStyleDlg.isCreated() && ::IsWindowVisible(_configStyleDlg.getHSelf())) if (_configStyleDlg.isCreated() && ::IsWindowVisible(_configStyleDlg.getHSelf()))
_configStyleDlg.restoreGlobalOverrideValues(); _configStyleDlg.restoreGlobalOverrideValues();
Session currentSession;
if (nppgui._rememberLastSession) {
getCurrentOpenedFiles(currentSession);
_lastRecentFileList.setLock(true); //only lock when the session is remembered
}
if (fileCloseAll())
{
SCNotification scnN; SCNotification scnN;
scnN.nmhdr.code = NPPN_SHUTDOWN; scnN.nmhdr.code = NPPN_SHUTDOWN;
scnN.nmhdr.hwndFrom = _hSelf; scnN.nmhdr.hwndFrom = _hSelf;
@ -7802,8 +7780,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (nppgui._rememberLastSession) if (nppgui._rememberLastSession)
saveSession(currentSession); saveSession(currentSession);
//Sends WM_DESTROY, Notepad++ will end
::DestroyWindow(hwnd); ::DestroyWindow(hwnd);
}
return TRUE; return TRUE;
} }
@ -8539,27 +8518,25 @@ bool Notepad_plus::str2Cliboard(const TCHAR *str2cpy)
if (!str2cpy) if (!str2cpy)
return false; return false;
if (!::OpenClipboard(_hSelf)) int len2Allocate = lstrlen(str2cpy) + 1;
return false; len2Allocate *= sizeof(TCHAR);
::EmptyClipboard();
int len2Allocate = lstrlen(str2cpy);
unsigned int cilpboardFormat = CF_TEXT; unsigned int cilpboardFormat = CF_TEXT;
#ifdef UNICODE #ifdef UNICODE
len2Allocate = len2Allocate * 2 + 3;
cilpboardFormat = CF_UNICODETEXT; cilpboardFormat = CF_UNICODETEXT;
#endif #endif
HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, len2Allocate); HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, len2Allocate);
if (hglbCopy == NULL) if (hglbCopy == NULL)
{ {
::CloseClipboard();
return false; return false;
} }
if (!::OpenClipboard(_hSelf))
return false;
::EmptyClipboard();
// Lock the handle and copy the text to the buffer. // Lock the handle and copy the text to the buffer.
TCHAR *pStr = (TCHAR *)::GlobalLock(hglbCopy); TCHAR *pStr = (TCHAR *)::GlobalLock(hglbCopy);
lstrcpy(pStr, str2cpy); lstrcpy(pStr, str2cpy);

View File

@ -437,7 +437,6 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty
//Initialize current directory to startup directory //Initialize current directory to startup directory
::GetCurrentDirectory(MAX_PATH, _currentDirectory); ::GetCurrentDirectory(MAX_PATH, _currentDirectory);
//lstrcpy(_currentDirectory, nppPath);
::SetCurrentDirectory(_nppPath); //force working directory to path of module, preventing lock ::SetCurrentDirectory(_nppPath); //force working directory to path of module, preventing lock
_appdataNppDir[0] = '\0'; _appdataNppDir[0] = '\0';
@ -1761,7 +1760,6 @@ void NppParameters::writeShortcuts()
if (!root) if (!root)
{ {
root = _pXmlShortcutDoc->InsertEndChild(TiXmlElement(TEXT("NotepadPlus"))); root = _pXmlShortcutDoc->InsertEndChild(TiXmlElement(TEXT("NotepadPlus")));
//root = _pXmlShortcutDoc->FirstChild(TEXT("NotepadPlus"));
} }
TiXmlNode *cmdRoot = root->FirstChild(TEXT("InternalCommands")); TiXmlNode *cmdRoot = root->FirstChild(TEXT("InternalCommands"));
@ -2207,9 +2205,6 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
val = n->Value(); val = n->Value();
if (val) if (val)
{ {
//if (!lstrcmp(val, TEXT("hide")))
// _nppGUI._toolBarStatus = TB_HIDE;
//else
if (!lstrcmp(val, TEXT("small"))) if (!lstrcmp(val, TEXT("small")))
_nppGUI._toolBarStatus = TB_SMALL; _nppGUI._toolBarStatus = TB_SMALL;
else if (!lstrcmp(val, TEXT("large"))) else if (!lstrcmp(val, TEXT("large")))
@ -2938,8 +2933,6 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (path && path[0]) if (path && path[0])
{ {
lstrcpyn(_nppGUI._defaultDir, path, MAX_PATH); lstrcpyn(_nppGUI._defaultDir, path, MAX_PATH);
//lstrcpyn(_nppGUI._defaultDirExp, path, MAX_PATH);
::ExpandEnvironmentStrings(_nppGUI._defaultDir, _nppGUI._defaultDirExp, 500); ::ExpandEnvironmentStrings(_nppGUI._defaultDir, _nppGUI._defaultDirExp, 500);
} }
} }
@ -2954,20 +2947,8 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
else if (lstrcmp(value, TEXT("no")) == 0) else if (lstrcmp(value, TEXT("no")) == 0)
_nppGUI._shortTitlebar = false; _nppGUI._shortTitlebar = false;
} }
/*
value = element->Attribute(TEXT("showDirty"));
_nppGUI._showDirty = true; //default state
if (value && value[0])
{
if (lstrcmp(value, TEXT("yes")) == 0)
_nppGUI._showDirty = true;
else if (lstrcmp(value, TEXT("no")) == 0)
_nppGUI._showDirty = false;
}
*/
} }
} }
} }
void NppParameters::feedScintillaParam(bool whichOne, TiXmlNode *node) void NppParameters::feedScintillaParam(bool whichOne, TiXmlNode *node)
@ -3735,7 +3716,6 @@ bool NppParameters::writeGUIParams()
if (!sessionExtExist) if (!sessionExtExist)
{ {
//const TCHAR *pStr = bVal?TEXT("yes"):TEXT("no");
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("sessionExt")); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("sessionExt"));
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str())); GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str()));
@ -3743,7 +3723,6 @@ bool NppParameters::writeGUIParams()
if (!menuBarExist) if (!menuBarExist)
{ {
//const TCHAR *pStr = bVal?TEXT("yes"):TEXT("no");
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("MenuBar")); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("MenuBar"));
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._menuBarShow?TEXT("show"):TEXT("hide"))); GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._menuBarShow?TEXT("show"):TEXT("hide")));
@ -3771,9 +3750,6 @@ bool NppParameters::writeGUIParams()
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("titleBar")); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("titleBar"));
const TCHAR *pStr = (_nppGUI._shortTitlebar)?TEXT("yes"):TEXT("no"); const TCHAR *pStr = (_nppGUI._shortTitlebar)?TEXT("yes"):TEXT("no");
GUIConfigElement->SetAttribute(TEXT("short"), pStr); GUIConfigElement->SetAttribute(TEXT("short"), pStr);
//pStr = (_nppGUI._showDirty)?TEXT("yes"):TEXT("no");
//GUIConfigElement->SetAttribute(TEXT("showDirty"), pStr);
} }
insertDockingParamNode(GUIRoot); insertDockingParamNode(GUIRoot);
@ -4103,7 +4079,6 @@ void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & g
if (pLs) if (pLs)
{ {
const TCHAR *extStr = pLs->getLexerUserExt(); const TCHAR *extStr = pLs->getLexerUserExt();
//pLs2->setLexerUserExt(extStr);
element->SetAttribute(TEXT("ext"), extStr); element->SetAttribute(TEXT("ext"), extStr);
for (TiXmlNode *grChildNode = childNode->FirstChildElement(TEXT("WordsStyle")); for (TiXmlNode *grChildNode = childNode->FirstChildElement(TEXT("WordsStyle"));

View File

@ -870,8 +870,13 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
// Sinon y'aura un soucis de performance! // Sinon y'aura un soucis de performance!
if (isCJK()) if (isCJK())
{ {
if (getCurrentBuffer()->getUnicodeMode() == uni8Bit && typeDoc != L_CSS) if (getCurrentBuffer()->getUnicodeMode() == uni8Bit)
{
if (typeDoc != L_CSS || typeDoc != L_CAML || typeDoc != L_ASM || typeDoc != L_MATLAB)
execute(SCI_SETCODEPAGE, _codepage); execute(SCI_SETCODEPAGE, _codepage);
else
execute(SCI_SETCODEPAGE, CP_ACP);
}
} }
showMargin(_SC_MARGE_FOLDER, isNeededFolderMarge(typeDoc)); showMargin(_SC_MARGE_FOLDER, isNeededFolderMarge(typeDoc));
@ -1252,7 +1257,8 @@ void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask) {
{ {
if (buffer->getUnicodeMode() == uni8Bit) if (buffer->getUnicodeMode() == uni8Bit)
{ //either 0 or CJK codepage { //either 0 or CJK codepage
if (isCJK() && buffer->getLangType() != L_CSS) LangType typeDoc = buffer->getLangType();
if (isCJK() && (typeDoc != L_CSS || typeDoc != L_CAML || typeDoc != L_ASM || typeDoc != L_MATLAB))
{ {
execute(SCI_SETCODEPAGE, _codepage); //you may also want to set charsets here, not yet implemented execute(SCI_SETCODEPAGE, _codepage); //you may also want to set charsets here, not yet implemented
} }