Skip to content

Commit

Permalink
Fix docked panels appear with "-nosession" cmd line parameters
Browse files Browse the repository at this point in the history
Fix #8005
  • Loading branch information
donho committed Nov 9, 2020
1 parent 1961f70 commit 7399257
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 76 deletions.
144 changes: 74 additions & 70 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ LRESULT Notepad_plus::init(HWND hwnd)

// Menu
_mainMenuHandle = ::GetMenu(hwnd);
int langPos2BeRemoved = MENUINDEX_LANGUAGE+1;
int langPos2BeRemoved = MENUINDEX_LANGUAGE + 1;
if (nppGUI._isLangMenuCompact)
langPos2BeRemoved = MENUINDEX_LANGUAGE;
::RemoveMenu(_mainMenuHandle, langPos2BeRemoved, MF_BYPOSITION);

//Views
_pDocTab = &_mainDocTab;
_pEditView = &_mainEditView;
_pDocTab = &_mainDocTab;
_pEditView = &_mainEditView;
_pNonDocTab = &_subDocTab;
_pNonEditView = &_subEditView;

Expand All @@ -230,10 +230,10 @@ LRESULT Notepad_plus::init(HWND hwnd)
_mainWindowStatus = WindowMainActive;
_activeView = MAIN_VIEW;

const ScintillaViewParams & svp1 = nppParam.getSVP();
const ScintillaViewParams & svp1 = nppParam.getSVP();

int tabBarStatus = nppGUI._tabStatus;

_toReduceTabBar = ((tabBarStatus & TAB_REDUCE) != 0);
int iconDpiDynamicalSize = nppParam._dpiManager.scaleY(_toReduceTabBar ? 13 : 20);
_docTabIconList.create(iconDpiDynamicalSize, _pPublicInterface->getHinst(), docTabIconIDs, sizeof(docTabIconIDs) / sizeof(int));
Expand All @@ -254,13 +254,13 @@ LRESULT Notepad_plus::init(HWND hwnd)
_invisibleEditView.wrap(false); // Make sure no slow down

// Configuration of 2 scintilla views
_mainEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp1._lineNumberMarginShow);
_mainEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp1._lineNumberMarginShow);
_subEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp1._lineNumberMarginShow);
_mainEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp1._bookMarkMarginShow);
_mainEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp1._bookMarkMarginShow);
_subEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp1._bookMarkMarginShow);

_mainEditView.showIndentGuideLine(svp1._indentGuideLineShow);
_subEditView.showIndentGuideLine(svp1._indentGuideLineShow);
_mainEditView.showIndentGuideLine(svp1._indentGuideLineShow);
_subEditView.showIndentGuideLine(svp1._indentGuideLineShow);

::SendMessage(hwnd, NPPM_INTERNAL_SETCARETWIDTH, 0, 0);
::SendMessage(hwnd, NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0);
Expand All @@ -269,15 +269,15 @@ LRESULT Notepad_plus::init(HWND hwnd)
_preference.init(_pPublicInterface->getHinst(), hwnd);
_pluginsAdminDlg.init(_pPublicInterface->getHinst(), hwnd);

//Marker Margin config
_mainEditView.setMakerStyle(svp1._folderStyle);
_subEditView.setMakerStyle(svp1._folderStyle);
//Marker Margin config
_mainEditView.setMakerStyle(svp1._folderStyle);
_subEditView.setMakerStyle(svp1._folderStyle);
_mainEditView.defineDocType(_mainEditView.getCurrentBuffer()->getLangType());
_subEditView.defineDocType(_subEditView.getCurrentBuffer()->getLangType());

//Line wrap method
_mainEditView.setWrapMode(svp1._lineWrapMethod);
_subEditView.setWrapMode(svp1._lineWrapMethod);
_subEditView.setWrapMode(svp1._lineWrapMethod);

_mainEditView.execute(SCI_SETCARETLINEVISIBLE, svp1._currentLineHilitingShow);
_subEditView.execute(SCI_SETCARETLINEVISIBLE, svp1._currentLineHilitingShow);
Expand Down Expand Up @@ -318,7 +318,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_mainEditView.execute(SCI_SETZOOM, svp1._zoom);
_subEditView.execute(SCI_SETZOOM, svp1._zoom2);

::SendMessage(hwnd, NPPM_INTERNAL_SETMULTISELCTION, 0, 0);
::SendMessage(hwnd, NPPM_INTERNAL_SETMULTISELCTION, 0, 0);

// Make backspace or delete work with multiple selections
_mainEditView.execute(SCI_SETADDITIONALSELECTIONTYPING, true);
Expand Down Expand Up @@ -367,23 +367,23 @@ LRESULT Notepad_plus::init(HWND hwnd)
TabBarPlus::setVertical((tabBarStatus & TAB_VERTICAL) != 0);
drawTabbarColoursFromStylerArray();

//--Splitter Section--//
//--Splitter Section--//
bool isVertical = (nppGUI._splitterPos == POS_VERTICAL);

_subSplitter.init(_pPublicInterface->getHinst(), hwnd);
_subSplitter.create(&_mainDocTab, &_subDocTab, 8, SplitterMode::DYNAMIC, 50, isVertical);
_subSplitter.init(_pPublicInterface->getHinst(), hwnd);
_subSplitter.create(&_mainDocTab, &_subDocTab, 8, SplitterMode::DYNAMIC, 50, isVertical);

//--Status Bar Section--//
//--Status Bar Section--//
bool willBeShown = nppGUI._statusBarShow;
_statusBar.init(_pPublicInterface->getHinst(), hwnd, 6);
_statusBar.init(_pPublicInterface->getHinst(), hwnd, 6);
_statusBar.setPartWidth(STATUSBAR_DOC_SIZE, nppParam._dpiManager.scaleX(220));
_statusBar.setPartWidth(STATUSBAR_CUR_POS, nppParam._dpiManager.scaleX(260));
_statusBar.setPartWidth(STATUSBAR_EOF_FORMAT, nppParam._dpiManager.scaleX(110));
_statusBar.setPartWidth(STATUSBAR_UNICODE_TYPE, nppParam._dpiManager.scaleX(120));
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, nppParam._dpiManager.scaleX(30));
_statusBar.display(willBeShown);
_statusBar.display(willBeShown);

_pMainWindow = &_mainDocTab;
_pMainWindow = &_mainDocTab;

_dockingManager.init(_pPublicInterface->getHinst(), hwnd, &_pMainWindow);

Expand All @@ -405,7 +405,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_pluginsManager.init(nppData);

_pluginsManager.loadPluginsV2(nppParam.getPluginRootDir());
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);

// ------------ //
// Menu Section //
Expand All @@ -414,21 +414,21 @@ LRESULT Notepad_plus::init(HWND hwnd)
setupColorSampleBitmapsOnMainMenuItems();

// Macro Menu
std::vector<MacroShortcut> & macros = nppParam.getMacroList();
std::vector<MacroShortcut> & macros = nppParam.getMacroList();
HMENU hMacroMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_MACRO);
size_t const posBase = 6;
size_t nbMacro = macros.size();
if (nbMacro >= 1)
::InsertMenu(hMacroMenu, posBase - 1, MF_BYPOSITION, static_cast<UINT>(-1), 0);

for (size_t i = 0 ; i < nbMacro ; ++i)
for (size_t i = 0; i < nbMacro; ++i)
::InsertMenu(hMacroMenu, static_cast<UINT>(posBase + i), MF_BYPOSITION, ID_MACRO + i, macros[i].toMenuItemString().c_str());

if (nbMacro >= 1)
{
::InsertMenu(hMacroMenu, static_cast<UINT>(posBase + nbMacro + 1), MF_BYPOSITION, static_cast<UINT>(-1), 0);
::InsertMenu(hMacroMenu, static_cast<UINT>(posBase + nbMacro + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro..."));
}
if (nbMacro >= 1)
{
::InsertMenu(hMacroMenu, static_cast<UINT>(posBase + nbMacro + 1), MF_BYPOSITION, static_cast<UINT>(-1), 0);
::InsertMenu(hMacroMenu, static_cast<UINT>(posBase + nbMacro + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro..."));
}

// Run Menu
std::vector<UserCommand> & userCommands = nppParam.getUserCommandList();
Expand All @@ -438,16 +438,16 @@ LRESULT Notepad_plus::init(HWND hwnd)
if (nbUserCommand >= 1)
::InsertMenu(hRunMenu, runPosBase - 1, MF_BYPOSITION, static_cast<UINT>(-1), 0);

for (size_t i = 0 ; i < nbUserCommand ; ++i)
for (size_t i = 0; i < nbUserCommand; ++i)
{
::InsertMenu(hRunMenu, static_cast<UINT>(runPosBase + i), MF_BYPOSITION, ID_USER_CMD + i, userCommands[i].toMenuItemString().c_str());
}

if (nbUserCommand >= 1)
{
::InsertMenu(hRunMenu, static_cast<UINT>(runPosBase + nbUserCommand + 1), MF_BYPOSITION, static_cast<UINT>(-1), 0);
::InsertMenu(hRunMenu, static_cast<UINT>(runPosBase + nbUserCommand + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, TEXT("Modify Shortcut/Delete Command..."));
}
if (nbUserCommand >= 1)
{
::InsertMenu(hRunMenu, static_cast<UINT>(runPosBase + nbUserCommand + 1), MF_BYPOSITION, static_cast<UINT>(-1), 0);
::InsertMenu(hRunMenu, static_cast<UINT>(runPosBase + nbUserCommand + 2), MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, TEXT("Modify Shortcut/Delete Command..."));
}

// Updater menu item
if (!nppGUI._doesExistUpdater)
Expand All @@ -465,7 +465,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE);

// Add external languages to menu
for (int i = 0 ; i < nppParam.getNbExternalLang() ; ++i)
for (int i = 0; i < nppParam.getNbExternalLang(); ++i)
{
ExternalLangContainer & externalLangContainer = nppParam.getELCFromIndex(i);

Expand All @@ -479,12 +479,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
::GetMenuString(hLangMenu, x, buffer, bufferSize, MF_BYPOSITION);
}

::InsertMenu(hLangMenu, x-1, MF_BYPOSITION, IDM_LANG_EXTERNAL + i, externalLangContainer._name);
::InsertMenu(hLangMenu, x - 1, MF_BYPOSITION, IDM_LANG_EXTERNAL + i, externalLangContainer._name);
}

if (nppGUI._excludedLangList.size() > 0)
{
for (size_t i = 0, len = nppGUI._excludedLangList.size(); i < len ; ++i)
for (size_t i = 0, len = nppGUI._excludedLangList.size(); i < len; ++i)
{
int cmdID = nppParam.langTypeToCommandID(nppGUI._excludedLangList[i]._langType);
const int itemSize = 256;
Expand All @@ -500,7 +500,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
// Add User Defined Languages Entry
int udlpos = ::GetMenuItemCount(hLangMenu) - 1;

for (int i = 0, len = nppParam.getNbUserLang(); i < len ; ++i)
for (int i = 0, len = nppParam.getNbUserLang(); i < len; ++i)
{
UserLangContainer & userLangContainer = nppParam.getULCFromIndex(i);
::InsertMenu(hLangMenu, udlpos + i, MF_BYPOSITION, IDM_LANG_USER + i + 1, userLangContainer.getName());
Expand All @@ -513,7 +513,7 @@ LRESULT Notepad_plus::init(HWND hwnd)

_lastRecentFileList.initMenu(hFileMenu, IDM_FILEMENU_LASTONE + 1, IDM_FILEMENU_EXISTCMDPOSITION, &_accelerator, nppParam.putRecentFileInSubMenu());
_lastRecentFileList.setLangEncoding(_nativeLangSpeaker.getLangEncoding());
for (int i = 0 ; i < nbLRFile ; ++i)
for (int i = 0; i < nbLRFile; ++i)
{
generic_string * stdStr = nppParam.getLRFile(i);
if (!nppGUI._checkHistoryFiles || PathFileExists(stdStr->c_str()))
Expand Down Expand Up @@ -553,7 +553,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
vector<MenuItemUnit> & tmp = nppParam.getContextMenuItems();
size_t len = tmp.size();
TCHAR menuName[64];
for (size_t i = 0 ; i < len ; ++i)
for (size_t i = 0; i < len; ++i)
{
if (tmp[i]._itemName.empty())
{
Expand Down Expand Up @@ -586,7 +586,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
::DrawMenuBar(hwnd);


//-- Tool Bar Section --//
//-- Tool Bar Section --//
toolBarStatusType tbStatus = nppGUI._toolBarStatus;
willBeShown = nppGUI._toolbarShow;

Expand All @@ -597,7 +597,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
scnN.nmhdr.idFrom = 0;
_pluginsManager.notify(&scnN);

_toolBar.init(_pPublicInterface->getHinst(), hwnd, tbStatus, toolBarIcons, sizeof(toolBarIcons)/sizeof(ToolBarButtonUnit));
_toolBar.init(_pPublicInterface->getHinst(), hwnd, tbStatus, toolBarIcons, sizeof(toolBarIcons) / sizeof(ToolBarButtonUnit));

changeToolBarIcons();

Expand All @@ -609,14 +609,14 @@ LRESULT Notepad_plus::init(HWND hwnd)
checkMacroState();

//--Init dialogs--//
_findReplaceDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_findReplaceDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_findInFinderDlg.init(_pPublicInterface->getHinst(), hwnd);
_incrementFindDlg.init(_pPublicInterface->getHinst(), hwnd, &_findReplaceDlg, _nativeLangSpeaker.isRTL());
_incrementFindDlg.addToRebar(&_rebarBottom);
_goToLineDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_goToLineDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_findCharsInRangeDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_colEditorDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_aboutDlg.init(_pPublicInterface->getHinst(), hwnd);
_aboutDlg.init(_pPublicInterface->getHinst(), hwnd);
_debugInfoDlg.init(_pPublicInterface->getHinst(), hwnd, _isAdministrator, _pluginsManager.getLoadedPluginNames());
_runDlg.init(_pPublicInterface->getHinst(), hwnd);
_runMacroDlg.init(_pPublicInterface->getHinst(), hwnd);
Expand All @@ -632,9 +632,9 @@ LRESULT Notepad_plus::init(HWND hwnd)
_sha2FromTextDlg.setHashType(hash_sha256);


//--User Define Dialog Section--//
//--User Define Dialog Section--//
int uddStatus = nppGUI._userDefineDlgStatus;
UserDefineDialog *udd = _pEditView->getUserDefineDlg();
UserDefineDialog *udd = _pEditView->getUserDefineDlg();

bool uddShow = false;
switch (uddStatus)
Expand All @@ -646,12 +646,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
uddShow = true;
break;
}
case UDD_DOCKED: // hide & docked
case UDD_DOCKED: // hide & docked
{
_isUDDocked = true;
break;
break;
}
case (UDD_SHOW | UDD_DOCKED) : // show & docked
case (UDD_SHOW | UDD_DOCKED): // show & docked
{
udd->doDialog(true, _nativeLangSpeaker.isRTL());
_nativeLangSpeaker.changeUserDefineLang(udd);
Expand All @@ -662,7 +662,7 @@ LRESULT Notepad_plus::init(HWND hwnd)

default: // hide & undocked
break;
}
}

//
// Menu & toolbar for UserDefine Dialog
Expand All @@ -687,29 +687,33 @@ LRESULT Notepad_plus::init(HWND hwnd)
//
// launch the plugin dlg memorized at the last session
//
DockingManagerData& dmd = nppGUI._dockingData;

_dockingManager.setDockedContSize(CONT_LEFT , nppGUI._dockingData._leftWidth);
_dockingManager.setDockedContSize(CONT_RIGHT , nppGUI._dockingData._rightWidth);
_dockingManager.setDockedContSize(CONT_TOP , nppGUI._dockingData._topHeight);
_dockingManager.setDockedContSize(CONT_BOTTOM, nppGUI._dockingData._bottomHight);

for (size_t i = 0, len = dmd._pluginDockInfo.size(); i < len ; ++i)
if (!nppGUI._isCmdlineNosessionActivated)
{
PluginDlgDockingInfo& pdi = dmd._pluginDockInfo[i];
if (pdi._isVisible)
DockingManagerData& dmd = nppGUI._dockingData;

_dockingManager.setDockedContSize(CONT_LEFT, nppGUI._dockingData._leftWidth);
_dockingManager.setDockedContSize(CONT_RIGHT, nppGUI._dockingData._rightWidth);
_dockingManager.setDockedContSize(CONT_TOP, nppGUI._dockingData._topHeight);
_dockingManager.setDockedContSize(CONT_BOTTOM, nppGUI._dockingData._bottomHight);

for (size_t i = 0, len = dmd._pluginDockInfo.size(); i < len; ++i)
{
if (pdi._name == NPP_INTERNAL_FUCTION_STR)
_internalFuncIDs.push_back(pdi._internalID);
else
_pluginsManager.runPluginCommand(pdi._name.c_str(), pdi._internalID);
PluginDlgDockingInfo& pdi = dmd._pluginDockInfo[i];
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);
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
Expand Down
5 changes: 3 additions & 2 deletions PowerEditor/src/Notepad_plus_Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
if (cmdLineParams->_isNoPlugin)
_notepad_plus_plus_core._pluginsManager.disable();

nppGUI._isCmdlineNosessionActivated = cmdLineParams->_isNoSession;

_hSelf = ::CreateWindowEx(
WS_EX_ACCEPTFILES | (_notepad_plus_plus_core._nativeLangSpeaker.isRTL()?WS_EX_LAYOUTRTL:0),
_className,
Expand Down Expand Up @@ -168,8 +170,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
if (cmdLineParams->_alwaysOnTop)
::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0);

nppGUI._isCmdlineNosessionActivated = cmdLineParams->_isNoSession;
if (nppGUI._rememberLastSession && !cmdLineParams->_isNoSession)
if (nppGUI._rememberLastSession && !nppGUI._isCmdlineNosessionActivated)
_notepad_plus_plus_core.loadLastSession();

if (nppParams.doFunctionListExport() || nppParams.doPrintAndExit())
Expand Down

3 comments on commit 7399257

@donho
Copy link
Member Author

@donho donho commented on 7399257 Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chcg the build for this commit failed - with no reason (at least I don't see from the console, there's no error message): https://ci.appveyor.com/project/donho/notepad-plus-plus/builds/36200903
Could you enlighten me what's going on please?

Edit: just saw the following message Build execution time has reached the maximum allowed time for your plan (60 minutes). - what made such situation? Is it due to Appveyor server?

@donho
Copy link
Member Author

@donho donho commented on 7399257 Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chcg
I relaunch a build, it's stuck on Downloading npp.7.9.portable.minimalist.7z (1,454,804 bytes)...100%

if ($env:PLATFORM_INPUT -eq "mingw") {
    Push-AppveyorArtifact "PowerEditor\bin\NotepadPP.exe" -FileName "$nppFileName"
    Push-AppveyorArtifact "PowerEditor\bin\NotepadPP.exe_dynamic" -FileName "$nppFileName_dynamic"
}
Uploading artifact SciLexer.dll (2,753,024 bytes)...100%
Uploading artifact Notepad++.exe (5,404,672 bytes)...100%
Downloading npp.7.9.portable.minimalist.7z (1,454,804 bytes)...100%

I suppose npp.7.9.portable.minimalist.7z is completely downloaded, but it's blocked on the next instruction.
After checking in appveyor.yml of Notepad++ (https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/appveyor.yml#L62):

        if ($env:PLATFORM_INPUT -eq "Win32" -and $env:CONFIGURATION -eq "Unicode Debug") {
            Push-AppveyorArtifact "PowerEditor\visual.net\Unicode Debug\Notepad++.exe" -FileName "$nppFileName"

            Start-FileDownload 'https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v7.9/npp.7.9.portable.minimalist.7z'
            7z x -y npp.7.9.portable.minimalist.7z | Out-Null

I guess it's due to 7z x -y npp.7.9.portable.minimalist.7z | Out-Null or later instructions.
What's your diagnostic?

@donho
Copy link
Member Author

@donho donho commented on 7399257 Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by c58f3f7

Please sign in to comment.