diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 02c14bb3..0a822603 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -67,7 +67,7 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p _recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(false), _linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _sysMenuEntering(false), _autoCompleteMain(&_mainEditView), _autoCompleteSub(&_subEditView), _smartHighlighter(&_findReplaceDlg), - _nativeLangEncoding(CP_ACP), _isFileOpening(false) + _nativeLangEncoding(CP_ACP), _isFileOpening(false), _rememberThisSession(true) { ZeroMemory(&_prevSelectedRange, sizeof(_prevSelectedRange)); _winVersion = (NppParameters::getInstance())->getWinVersion(); @@ -276,6 +276,7 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdL ::SendMessage(_hSelf, NPPM_HIDETABBAR, 0, TRUE); } + _rememberThisSession = !cmdLineParams->_isNoSession; if (nppGUI._rememberLastSession && !cmdLineParams->_isNoSession) { loadLastSession(); @@ -2650,14 +2651,16 @@ BOOL Notepad_plus::notify(SCNotification *notification) LPTOOLTIPTEXT lpttt; lpttt = (LPTOOLTIPTEXT)notification; - lpttt->hinst = _hInst; + + //Joce's fix + lpttt->hinst = NULL; POINT p; ::GetCursorPos(&p); ::ScreenToClient(_hSelf, &p); HWND hWin = ::RealChildWindowFromPoint(_hSelf, p); const int tipMaxLen = 1024; - static TCHAR tip[tipMaxLen]; + /*static */TCHAR tip[tipMaxLen]; tip[0] = '\0'; generic_string tipTmp(TEXT("")); int id = int(lpttt->hdr.idFrom); @@ -8031,7 +8034,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { case COPYDATA_PARAMS : { - pNppParam->setCmdlineParam(*((CmdLineParams *)pCopyData->lpData)); + CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; + pNppParam->setCmdlineParam(*cmdLineParam); + _rememberThisSession = !cmdLineParam->_isNoSession; break; } @@ -8956,7 +8961,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa saveGUIParams(); saveUserDefineLangs(); saveShortcuts(); - if (nppgui._rememberLastSession) + if (nppgui._rememberLastSession && _rememberThisSession) saveSession(currentSession); diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 2f1b2780..500f007a 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -385,6 +385,7 @@ private: vector > _hideLinesMarks; StyleArray _hotspotStyles; + bool _rememberThisSession; // always true. except -nosession is indicated on the launch time static LRESULT CALLBACK Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 0523915d..f8a2c3a2 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2063,6 +2063,84 @@ void ScintillaEditView::setMultiSelections(const ColumnModeInfos & cmi) } } +pair ScintillaEditView::getSelectionLinesRange() const +{ + pair range(-1, -1); + if (execute(SCI_GETSELECTIONS) > 1) + return range; + int start = execute(SCI_GETSELECTIONSTART); + int end = execute(SCI_GETSELECTIONEND); + + range.first = execute(SCI_LINEFROMPOSITION, start); + range.second = execute(SCI_LINEFROMPOSITION, end); + if (range.first > range.second) + range.swap(range); + return range; +} + +void ScintillaEditView::currentLinesUp() const +{ + pair lineRange = getSelectionLinesRange(); + if ((lineRange.first == -1 || lineRange.first == 0)) + return; + + int nbSelLines = lineRange.second - lineRange.first + 1; + + int line2swap = lineRange.first - 1; + int nbChar = execute(SCI_LINELENGTH, line2swap); + + int posStart = execute(SCI_POSITIONFROMLINE, lineRange.first); + int posEnd = execute(SCI_GETLINEENDPOSITION, lineRange.second); + + execute(SCI_BEGINUNDOACTION); + execute(SCI_GOTOLINE, line2swap); + + for (int i = 0 ; i < nbSelLines ; i++) + { + /* + execute(SCI_GOTOLINE, line2swap); + execute(SCI_LINETRANSPOSE); + + line2swap++; + */ + currentLineDown(); + } + execute(SCI_ENDUNDOACTION); + + execute(SCI_SETSELECTIONSTART, posStart - nbChar); + execute(SCI_SETSELECTIONEND, posEnd - nbChar); +} + +void ScintillaEditView::currentLinesDown() const +{ + pair lineRange = getSelectionLinesRange(); + if ((lineRange.first == -1 || lineRange.first == 0)) + return; + + int nbSelLines = lineRange.second - lineRange.first + 1; + + int line2swap = lineRange.first - 1; + int nbChar = execute(SCI_LINELENGTH, line2swap); + + execute(SCI_BEGINUNDOACTION); + execute(SCI_GOTOLINE, line2swap); + + for (int i = 0 ; i < nbSelLines ; i++) + { + /* + execute(SCI_GOTOLINE, line2swap); + execute(SCI_LINETRANSPOSE); + + line2swap++; + */ + currentLineDown(); + } + execute(SCI_ENDUNDOACTION); + + execute(SCI_SETSELECTIONSTART, lineRange.first - nbChar); + execute(SCI_SETSELECTIONEND, lineRange.second - nbChar); +} + void ScintillaEditView::convertSelectedTextTo(bool Case) { unsigned int codepage = _codepage; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 5077f8e2..ba13df4e 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -479,6 +479,9 @@ public: execute(SCI_ENDUNDOACTION); } }; + pair getSelectionLinesRange() const; + void currentLinesUp() const; + void currentLinesDown() const; void currentLineDown() const { int currentLine = getCurrentLineNumber(); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index cf6b8cae..8cf36b94 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -1332,7 +1332,7 @@ void DockingCont::SelectTab(int iTab) for (int iItem = 0; iItem < iItemCnt; iItem++) { generic_string szText(TEXT("")); - if (iItem == iTab) + if (iItem == iTab && pszMaxTxt) { // fake here an icon before text ... szText = TEXT(" "); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index b5d017c7..72785884 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -642,8 +642,9 @@ void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible) } } - /* attach toolbar */ - _vContainer[iCont]->createToolbar(data); + // attach toolbar + if (_vContainer.size() > (size_t)iCont && _vContainer[iCont] != NULL) + _vContainer[iCont]->createToolbar(data); /* notify client app */ if (iCont < DOCKCONT_MAX)