diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index e01672008..e651430be 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -121,6 +121,26 @@ void ClientRectToScreenRect(HWND hWnd, RECT* rect) rect->bottom = pt.y; }; +std::vector tokenizeString(const std::generic_string & tokenString, const char delim) { + //Vector is created on stack and copied on return + std::vector tokens; + + // Skip delimiters at beginning. + std::string::size_type lastPos = tokenString.find_first_not_of(delim, 0); + // Find first "non-delimiter". + std::string::size_type pos = tokenString.find_first_of(delim, lastPos); + + while (pos != std::string::npos || lastPos != std::string::npos) + { + // Found a token, add it to the vector. + tokens.push_back(tokenString.substr(lastPos, pos - lastPos)); + // Skip delimiters. Note the "not_of" + lastPos = tokenString.find_first_not_of(delim, pos); + // Find next "non-delimiter" + pos = tokenString.find_first_of(delim, lastPos); + } + return tokens; +} void ScreenRectToClientRect(HWND hWnd, RECT* rect) { diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index 9cf0fc279..66b151238 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -92,6 +92,7 @@ void writeLog(const TCHAR *logFileName, const TCHAR *log2write); int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep); int getCpFromStringValue(const char * encodingStr); std::generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand = false); +std::vector tokenizeString(const std::generic_string & tokenString, const char delim); void ClientRectToScreenRect(HWND hWnd, RECT* rect); void ScreenRectToClientRect(HWND hWnd, RECT* rect); diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index ccea2a78b..18ab7120f 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -617,10 +617,19 @@ private: }; void pasteToMarkedLines() { + int clipFormat; + #ifdef UNICODE + clipFormat = CF_UNICODETEXT; + #else + clipFormat = CF_TEXT; + #endif + BOOL canPaste = ::IsClipboardFormatAvailable(clipFormat); + if (!canPaste) + return; int lastLine = _pEditView->lastZeroBasedLineNumber(); ::OpenClipboard(_hSelf); - HANDLE clipboardData = ::GetClipboardData(CF_TEXT); + HANDLE clipboardData = ::GetClipboardData(clipFormat); int len = ::GlobalSize(clipboardData); LPVOID clipboardDataPtr = ::GlobalLock(clipboardData); diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index aad4bae20..3112432fd 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -338,8 +338,6 @@ void FileManager::init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratch _pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, _scratchDocDefault); } - - void FileManager::checkFilesystemChanges() { for(size_t i = 0; i < _nrBufs; i++) { if (_buffers[i]->checkFileState()){} //something has changed. Triggers update automatically @@ -358,7 +356,6 @@ Buffer * FileManager::getBufferByIndex(int index) { return _buffers.at(index); } - void FileManager::beNotifiedOfBufferChange(Buffer * theBuf, int mask) { _pNotepadPlus->notifyBufferChanged(theBuf, mask); }; @@ -384,8 +381,10 @@ void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier) { } BufferID FileManager::loadFile(const TCHAR * filename, Document doc) { + bool ownDoc = false; if (doc == NULL) { doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); + ownDoc = true; } TCHAR fullpath[MAX_PATH]; @@ -413,7 +412,8 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc) { BufferID retval = _nextBufferID++; return id; } else { //failed loading, release document - _pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, doc); //Failure, so release document + if (ownDoc) + _pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, doc); //Failure, so release document return BUFFER_INVALID; } } @@ -573,27 +573,27 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language) { const int blockSize = 128 * 1024; //128 kB char data[blockSize]; + FILE *fp = generic_fopen(filename, TEXT("rb")); + if (!fp) + return false; + //Setup scratchtilla for new filedata + _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc); + bool ro = _pscratchTilla->execute(SCI_GETREADONLY) != 0; + if (ro) { + _pscratchTilla->execute(SCI_SETREADONLY, false); + } + _pscratchTilla->execute(SCI_CLEARALL); + if (language < L_EXTERNAL) { + _pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID); + } else { + int id = language - L_EXTERNAL; + TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; + _pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)name); + } + + bool success = true; __try { - FILE *fp = generic_fopen(filename, TEXT("rb")); - if (!fp) - return false; - - //Setup scratchtilla for new filedata - _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc); - bool ro = _pscratchTilla->execute(SCI_GETREADONLY) != 0; - if (ro) { - _pscratchTilla->execute(SCI_SETREADONLY, false); - } - _pscratchTilla->execute(SCI_CLEARALL); - if (language < L_EXTERNAL) { - _pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID); - } else { - int id = language - L_EXTERNAL; - TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; - _pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)name); - } - size_t lenFile = 0; size_t lenConvert = 0; //just in case conversion results in 0, but file not empty do { @@ -601,22 +601,22 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea lenConvert = UnicodeConvertor->convert(data, lenFile); _pscratchTilla->execute(SCI_APPENDTEXT, lenConvert, (LPARAM)(UnicodeConvertor->getNewBuf())); } while (lenFile > 0); - - fclose(fp); - - _pscratchTilla->execute(SCI_EMPTYUNDOBUFFER); - _pscratchTilla->execute(SCI_SETSAVEPOINT); - if (ro) { - _pscratchTilla->execute(SCI_SETREADONLY, true); - } - _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); - return true; - - }__except(filter(GetExceptionCode(), GetExceptionInformation())) { + } __except(filter(GetExceptionCode(), GetExceptionInformation())) { printStr(TEXT("File is too big to be opened by Notepad++")); - return false; - } + success = false; + } + + fclose(fp); + + _pscratchTilla->execute(SCI_EMPTYUNDOBUFFER); + _pscratchTilla->execute(SCI_SETSAVEPOINT); + 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); diff --git a/PowerEditor/visual.net/notepadPlus.vc.7.0.vcproj b/PowerEditor/visual.net/notepadPlus.vc.7.0.vcproj index bcaaa000a..f5b75359e 100644 --- a/PowerEditor/visual.net/notepadPlus.vc.7.0.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vc.7.0.vcproj @@ -21,8 +21,8 @@ Name="VCCLCompilerTool" AdditionalOptions="/EHa" Optimization="0" - AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\Common;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;TIXML_USE_STL" + AdditionalIncludeDirectories="..\..\scintilla\include;..\src;..\src\MISC;..\src\MISC\Common;..\src\MISC\Exception;..\src\MISC\PluginsManager;..\src\MISC\Process;..\src\MISC\RegExt;..\src\ScitillaComponent;..\src\TinyXml;..\src\TinyXml\tinyXmlA;..\src\WinControls;..\src\WinControls\AboutDlg;..\src\WinControls\ColourPicker;..\src\WinControls\ContextMenu;..\src\WinControls\DockingWnd;..\src\WinControls\Grid;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\Preference;..\src\WinControls\shortcut;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\StaticDialog\RunDlg;..\src\WinControls\StatusBar;..\src\WinControls\TabBar;..\src\WinControls\TaskList;..\src\WinControls\ToolBar;..\src\WinControls\ToolTip;..\src\WinControls\TrayIcon;..\src\WinControls\WindowsDlg" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;TIXML_USE_STL;TIXMLA_USE_STL" MinimalRebuild="TRUE" ExceptionHandling="FALSE" BasicRuntimeChecks="0" @@ -97,8 +97,8 @@ IF NOT EXIST ..\bin\userDefineLang.xml COPY ..\src\userDefineLang.xml ..\bin\use FavorSizeOrSpeed="2" OmitFramePointers="TRUE" OptimizeForWindowsApplication="TRUE" - AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\Common;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;TIXML_USE_STL" + AdditionalIncludeDirectories="..\..\scintilla\include;..\src;..\src\MISC;..\src\MISC\Common;..\src\MISC\Exception;..\src\MISC\PluginsManager;..\src\MISC\Process;..\src\MISC\RegExt;..\src\ScitillaComponent;..\src\TinyXml;..\src\TinyXml\tinyXmlA;..\src\WinControls;..\src\WinControls\AboutDlg;..\src\WinControls\ColourPicker;..\src\WinControls\ContextMenu;..\src\WinControls\DockingWnd;..\src\WinControls\Grid;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\Preference;..\src\WinControls\shortcut;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\StaticDialog\RunDlg;..\src\WinControls\StatusBar;..\src\WinControls\TabBar;..\src\WinControls\TaskList;..\src\WinControls\ToolBar;..\src\WinControls\ToolTip;..\src\WinControls\TrayIcon;..\src\WinControls\WindowsDlg" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;TIXML_USE_STL;TIXMLA_USE_STL" StringPooling="TRUE" ExceptionHandling="FALSE" RuntimeLibrary="4" @@ -167,8 +167,8 @@ IF NOT EXIST ..\bin\userDefineLang.xml COPY ..\src\userDefineLang.xml ..\bin\use Name="VCCLCompilerTool" AdditionalOptions="/EHa" Optimization="0" - AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\Common;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;TIXML_USE_STL" + AdditionalIncludeDirectories="..\..\scintilla\include;..\src;..\src\MISC;..\src\MISC\Common;..\src\MISC\Exception;..\src\MISC\PluginsManager;..\src\MISC\Process;..\src\MISC\RegExt;..\src\ScitillaComponent;..\src\TinyXml;..\src\TinyXml\tinyXmlA;..\src\WinControls;..\src\WinControls\AboutDlg;..\src\WinControls\ColourPicker;..\src\WinControls\ContextMenu;..\src\WinControls\DockingWnd;..\src\WinControls\Grid;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\Preference;..\src\WinControls\shortcut;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\StaticDialog\RunDlg;..\src\WinControls\StatusBar;..\src\WinControls\TabBar;..\src\WinControls\TaskList;..\src\WinControls\ToolBar;..\src\WinControls\ToolTip;..\src\WinControls\TrayIcon;..\src\WinControls\WindowsDlg" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;TIXML_USE_STL;TIXMLA_USE_STL" MinimalRebuild="TRUE" ExceptionHandling="FALSE" BasicRuntimeChecks="0" @@ -244,8 +244,8 @@ IF NOT EXIST ..\bin\userDefineLang.xml COPY ..\src\userDefineLang.xml ..\bin\use FavorSizeOrSpeed="2" OmitFramePointers="TRUE" OptimizeForWindowsApplication="TRUE" - AdditionalIncludeDirectories="..\src\WinControls\AboutDlg;..\..\scintilla\include;..\include;..\src\WinControls;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\TabBar;..\src\WinControls\ToolBar;..\src\MISC\Process;..\src\ScitillaComponent;..\src\MISC;..\src\MISC\Common;..\src\WinControls\StatusBar;..\src;..\src\WinControls\StaticDialog\RunDlg;..\src\tinyxml;..\src\WinControls\ColourPicker;..\src\Win32Explr;..\src\MISC\RegExt;..\src\WinControls\TrayIcon;..\src\WinControls\shortcut;..\src\WinControls\Grid;..\src\WinControls\ContextMenu;..\src\MISC\PluginsManager;..\src\WinControls\Preference;..\src\WinControls\WindowsDlg;..\src\WinControls\TaskList;..\src\WinControls\DockingWnd;..\src\WinControls\ToolTip;..\src\MISC\Exception" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;TIXML_USE_STL" + AdditionalIncludeDirectories="..\..\scintilla\include;..\src;..\src\MISC;..\src\MISC\Common;..\src\MISC\Exception;..\src\MISC\PluginsManager;..\src\MISC\Process;..\src\MISC\RegExt;..\src\ScitillaComponent;..\src\TinyXml;..\src\TinyXml\tinyXmlA;..\src\WinControls;..\src\WinControls\AboutDlg;..\src\WinControls\ColourPicker;..\src\WinControls\ContextMenu;..\src\WinControls\DockingWnd;..\src\WinControls\Grid;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\Preference;..\src\WinControls\shortcut;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\StaticDialog\RunDlg;..\src\WinControls\StatusBar;..\src\WinControls\TabBar;..\src\WinControls\TaskList;..\src\WinControls\ToolBar;..\src\WinControls\ToolTip;..\src\WinControls\TrayIcon;..\src\WinControls\WindowsDlg" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;TIXML_USE_STL;TIXMLA_USE_STL" StringPooling="TRUE" ExceptionHandling="FALSE" RuntimeLibrary="4" @@ -409,6 +409,19 @@ IF NOT EXIST ..\bin\userDefineLang.xml COPY ..\src\userDefineLang.xml ..\bin\use + + + + + + + + + + + + + + + +