Skip to content

Commit

Permalink
Change quitOnEmpty trigger from command line to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
donho committed Sep 11, 2016
1 parent f71fd6c commit e31e37e
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 37 deletions.
3 changes: 2 additions & 1 deletion PowerEditor/src/Notepad_plus.cpp
Expand Up @@ -762,7 +762,8 @@ bool Notepad_plus::saveGUIParams()
(TabBarPlus::isDbClk2Close()?TAB_DBCLK2CLOSE:0) | \
(TabBarPlus::isVertical() ? TAB_VERTICAL:0) | \
(TabBarPlus::isMultiLine() ? TAB_MULTILINE:0) |\
(nppGUI._tabStatus & TAB_HIDE);
(nppGUI._tabStatus & TAB_HIDE) | \
(nppGUI._tabStatus & TAB_QUITONEMPTY);
nppGUI._splitterPos = _subSplitter.isVertical()?POS_VERTICAL:POS_HORIZOTAL;
UserDefineDialog *udd = _pEditView->getUserDefineDlg();
bool b = udd->isDocked();
Expand Down
2 changes: 0 additions & 2 deletions PowerEditor/src/Notepad_plus_Window.cpp
Expand Up @@ -176,8 +176,6 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
if (nppGUI._rememberLastSession && !cmdLineParams->_isNoSession)
_notepad_plus_plus_core.loadLastSession();

nppGUI._quitOnEmpty = cmdLineParams->_quitOnEmpty;

if (not cmdLineParams->_isPreLaunch)
{
if (cmdLineParams->isPointValid())
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/NppIO.cpp
Expand Up @@ -673,7 +673,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
}
command(IDM_VIEW_REFRESHTABAR);

if (NppParameters::getInstance()->getNppGUI()._quitOnEmpty)
if (NppParameters::getInstance()->getNppGUI()._tabStatus & TAB_QUITONEMPTY)
{
// the user closed the last open tab
if (numInitialOpenBuffers == 1 && isEmpty() && !_isAttemptingCloseOnQuit)
Expand Down
15 changes: 15 additions & 0 deletions PowerEditor/src/Parameters.cpp
Expand Up @@ -3890,6 +3890,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
else
isFailed = true;
}

val = element->Attribute(TEXT("hide"));
if (val)
{
Expand All @@ -3900,6 +3901,17 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
else
isFailed = true;
}

val = element->Attribute(TEXT("quitOnEmpty"));
if (val)
{
if (!lstrcmp(val, TEXT("yes")))
_nppGUI._tabStatus |= TAB_QUITONEMPTY;
else if (!lstrcmp(val, TEXT("no")))
_nppGUI._tabStatus |= 0;
else
isFailed = true;
}
if (isFailed)
_nppGUI._tabStatus = oldValue;

Expand Down Expand Up @@ -5143,6 +5155,9 @@ bool NppParameters::writeGUIParams()
pStr = (_nppGUI._tabStatus & TAB_HIDE)?TEXT("yes"):TEXT("no");
element->SetAttribute(TEXT("hide"), pStr);

pStr = (_nppGUI._tabStatus & TAB_QUITONEMPTY) ? TEXT("yes") : TEXT("no");
element->SetAttribute(TEXT("quitOnEmpty"), pStr);

}
else if (!lstrcmp(nm, TEXT("ScintillaViewsSplitter")))
{
Expand Down
21 changes: 10 additions & 11 deletions PowerEditor/src/Parameters.h
Expand Up @@ -52,15 +52,16 @@ const int UDD_DOCKED = 2; // 0000 0010
// 2 : 0000 0010 hide & docked
// 3 : 0000 0011 show & docked

const int TAB_DRAWTOPBAR = 1; // 0000 0001
const int TAB_DRAWINACTIVETAB = 2; // 0000 0010
const int TAB_DRAGNDROP = 4; // 0000 0100
const int TAB_REDUCE = 8; // 0000 1000
const int TAB_CLOSEBUTTON = 16; // 0001 0000
const int TAB_DBCLK2CLOSE = 32; // 0010 0000
const int TAB_VERTICAL = 64; // 0100 0000
const int TAB_MULTILINE = 128; // 1000 0000
const int TAB_HIDE = 256; //1 0000 0000
const int TAB_DRAWTOPBAR = 1; //0000 0000 0001
const int TAB_DRAWINACTIVETAB = 2; //0000 0000 0010
const int TAB_DRAGNDROP = 4; //0000 0000 0100
const int TAB_REDUCE = 8; //0000 0000 1000
const int TAB_CLOSEBUTTON = 16; //0000 0001 0000
const int TAB_DBCLK2CLOSE = 32; //0000 0010 0000
const int TAB_VERTICAL = 64; //0000 0100 0000
const int TAB_MULTILINE = 128; //0000 1000 0000
const int TAB_HIDE = 256; //0001 0000 0000
const int TAB_QUITONEMPTY = 512; //0010 0000 0000


enum class EolType: std::uint8_t
Expand Down Expand Up @@ -183,7 +184,6 @@ struct CmdLineParams
int _line2go = -1;
int _column2go = -1;
int _pos2go = -1;
bool _quitOnEmpty = false;

POINT _point;
bool _isPointXValid = false;
Expand Down Expand Up @@ -756,7 +756,6 @@ struct NppGUI final
char _rightmostDelimiter = ')';
bool _delimiterSelectionOnEntireDocument = false;
bool _backSlashIsEscapeCharacterForSql = true;
bool _quitOnEmpty = false;


// 0 : do nothing
Expand Down
28 changes: 12 additions & 16 deletions PowerEditor/src/WinControls/Preference/preference.rc
Expand Up @@ -47,33 +47,29 @@ IDD_PREFERENCE_BAR_BOX DIALOGEX 0, 0, 455, 185
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Localization",IDC_LOCALIZATION_GB_STATIC,57,6,147,35,BS_CENTER
COMBOBOX IDC_COMBO_LOCALIZATION,68,20,119,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Toolbar",IDC_TOOLBAR_GB_STATIC,57,45,147,68,BS_CENTER
CONTROL "Hide",IDC_CHECK_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,64,55,94,10
CONTROL "Small icons",IDC_RADIO_SMALLICON,"Button",BS_AUTORADIOBUTTON,64,69,114,10
CONTROL "Big icons",IDC_RADIO_BIGICON,"Button",BS_AUTORADIOBUTTON,64,83,109,10
CONTROL "Standard icons",IDC_RADIO_STANDARD,"Button",BS_AUTORADIOBUTTON,64,97,119,10
GROUPBOX "Tab Bar",IDC_TABBAR_GB_STATIC,223,6,176,142,BS_CENTER
GROUPBOX "Document List Panel",IDC_DOCSWITCH_GB_STATIC,57,121,147,41,BS_CENTER
CONTROL "Show",IDC_CHECK_DOCSWITCH,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,64,131,135,10
CONTROL "Disable extension column",IDC_CHECK_DOCSWITCH_NOEXTCOLUMN, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,64,146,124,10
GROUPBOX "Tab Bar",IDC_TABBAR_GB_STATIC,223,6,176,156,BS_CENTER
CONTROL "Hide",IDC_CHECK_TAB_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,15,108,10
CONTROL "Multi-line",IDC_CHECK_TAB_MULTILINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,29,134,10
CONTROL "Vertical",IDC_CHECK_TAB_VERTICAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,43,134,10
CONTROL "Reduce",IDC_CHECK_REDUCE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,58,108,10
CONTROL "Lock (no drag and drop)",IDC_CHECK_LOCK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,72,134,10
CONTROL "Darken inactive tabs",IDC_CHECK_DRAWINACTIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,87,134,10
CONTROL "Draw a coloured bar on active tab",IDC_CHECK_ORANGE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,102,137,10
CONTROL "Show close button on each tab",IDC_CHECK_ENABLETABCLOSE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,117,133,10
CONTROL "Double click to close document",IDC_CHECK_DBCLICK2CLOSE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,229,132,133,10
CONTROL "Show status bar",IDC_CHECK_SHOWSTATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,169,130,10
CONTROL "Hide menu bar (use Alt or F10 key to toggle)",IDC_CHECK_HIDEMENUBAR,
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,223,153,218,10
GROUPBOX "Localization",IDC_LOCALIZATION_GB_STATIC,57,6,147,35,BS_CENTER
COMBOBOX IDC_COMBO_LOCALIZATION,68,20,119,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Document List Panel",IDC_DOCSWITCH_GB_STATIC,57,121,147,40,BS_CENTER
CONTROL "Show",IDC_CHECK_DOCSWITCH,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,64,131,135,10
CONTROL "Disable extension column",IDC_CHECK_DOCSWITCH_NOEXTCOLUMN,
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,64,146,124,10
CONTROL "Draw a coloured bar on active tab",IDC_CHECK_ORANGE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,229,102,137,10
CONTROL "Show close button on each tab",IDC_CHECK_ENABLETABCLOSE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,229,117,133,10
CONTROL "Double click to close document",IDC_CHECK_DBCLICK2CLOSE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,229,132,133,10
CONTROL "Exit on close the last tab",IDC_CHECK_TAB_LAST_EXIT, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,229,147,145,10
CONTROL "Show status bar",IDC_CHECK_SHOWSTATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,57,169,130,10
CONTROL "Hide menu bar (use Alt or F10 key to toggle)",IDC_CHECK_HIDEMENUBAR, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,223,169,218,10
END

IDD_PREFERENCE_MARGEIN_BOX DIALOGEX 0, 0, 455, 185
Expand Down
8 changes: 8 additions & 0 deletions PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
Expand Up @@ -376,6 +376,7 @@ INT_PTR CALLBACK BarsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
::SendDlgItemMessage(_hSelf, IDC_CHECK_DBCLICK2CLOSE, BM_SETCHECK, tabBarStatus & TAB_DBCLK2CLOSE, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_TAB_VERTICAL, BM_SETCHECK, tabBarStatus & TAB_VERTICAL, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_TAB_MULTILINE, BM_SETCHECK, tabBarStatus & TAB_MULTILINE, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_TAB_LAST_EXIT, BM_SETCHECK, tabBarStatus & TAB_QUITONEMPTY, 0);

::SendDlgItemMessage(_hSelf, IDC_CHECK_TAB_HIDE, BM_SETCHECK, tabBarStatus & TAB_HIDE, 0);
::SendMessage(_hSelf, WM_COMMAND, IDC_CHECK_TAB_HIDE, 0);
Expand Down Expand Up @@ -455,6 +456,7 @@ INT_PTR CALLBACK BarsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_DRAWINACTIVE), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLETABCLOSE), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_DBCLICK2CLOSE), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_LAST_EXIT), !toBeHidden);

::SendMessage(::GetParent(_hParent), NPPM_HIDETABBAR, 0, toBeHidden);
return TRUE;
Expand All @@ -468,6 +470,12 @@ INT_PTR CALLBACK BarsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_DRAWTABBAR_MULTILINE, 0);
return TRUE;

case IDC_CHECK_TAB_LAST_EXIT:
{
NppGUI & nppGUI = const_cast<NppGUI &>(pNppParam->getNppGUI());
nppGUI._tabStatus ^= TAB_QUITONEMPTY;
}
return TRUE;


case IDC_CHECK_REDUCE :
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/WinControls/Preference/preference_rc.h
Expand Up @@ -55,7 +55,7 @@
#define IDC_CHECK_TAB_HIDE (IDD_PREFERENCE_BAR_BOX + 18)
#define IDC_CHECK_TAB_MULTILINE (IDD_PREFERENCE_BAR_BOX + 19)
#define IDC_CHECK_TAB_VERTICAL (IDD_PREFERENCE_BAR_BOX + 20)
//#define IDC_MENUBAR_GB_STATIC (IDD_PREFERENCE_BAR_BOX + 21)
#define IDC_CHECK_TAB_LAST_EXIT (IDD_PREFERENCE_BAR_BOX + 21)
#define IDC_CHECK_HIDEMENUBAR (IDD_PREFERENCE_BAR_BOX + 22)
#define IDC_LOCALIZATION_GB_STATIC (IDD_PREFERENCE_BAR_BOX + 23)
#define IDC_COMBO_LOCALIZATION (IDD_PREFERENCE_BAR_BOX + 24)
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/config.model.xml
Expand Up @@ -6,7 +6,7 @@
<!-- 2 status : "show" or "hide"-->
<GUIConfig name="StatusBar">show</GUIConfig>
<!-- For all attributs, 2 status : "yes" or "no"-->
<GUIConfig name="TabBar" dragAndDrop="yes" drawTopBar="yes" drawInactiveTab="yes" reduce="yes" closeButton="yes" doubleClick2Close="no" vertical="no" multiLine="no" hide="no" />
<GUIConfig name="TabBar" dragAndDrop="yes" drawTopBar="yes" drawInactiveTab="yes" reduce="yes" closeButton="yes" doubleClick2Close="no" vertical="no" multiLine="no" hide="no" quitOnEmpty="no"/>
<!-- 2 positions : "horizontal" or "vertical"-->
<GUIConfig name="ScintillaViewsSplitter">vertical</GUIConfig>
<!-- For the attribut of position, 2 status : docked or undocked ; 2 status : "show" or "hide" -->
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/contextMenu.xml
Expand Up @@ -4,7 +4,7 @@ By modifying this file, you can customize your context menu popuped as right cli
It may be more convinient to access to your frequent used commands via context menu than via the top menu.
Please check "How to Customize the Context Menu" on:
http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Context_Menu
http://docs.notepad-plus-plus.org/index.php/Context_Menu
-->
<NotepadPlus>
<ScintillaContextMenu>
Expand All @@ -25,7 +25,7 @@ http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Context_Menu

<!-- You can use command id to add the commands you want.
Check english.xml to get commands id:
http://notepad-plus.svn.sourceforge.net/viewvc/notepad-plus/trunk/PowerEditor/installer/nativeLang/english.xml
https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/installer/nativeLang/english.xml
Use FolderName (optional) to create sub-menu. FolderName can be used in any type of item.
FolderName value can be in any language.
Expand Down
2 changes: 0 additions & 2 deletions PowerEditor/src/winmain.cpp
Expand Up @@ -240,7 +240,6 @@ const TCHAR FLAG_HELP[] = TEXT("--help");
const TCHAR FLAG_ALWAYS_ON_TOP[] = TEXT("-alwaysOnTop");
const TCHAR FLAG_OPENSESSIONFILE[] = TEXT("-openSession");
const TCHAR FLAG_RECURSIVE[] = TEXT("-r");
const TCHAR FLAG_QUIT_ON_EMPTY[] = TEXT("-quitOnEmpty");


static void doException(Notepad_plus_Window & notepad_plus_plus)
Expand Down Expand Up @@ -305,7 +304,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid);
cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid);
cmdLineParams._easterEggName = getEasterEggNameFromParam(params, cmdLineParams._quoteType);
cmdLineParams._quitOnEmpty = isInList(FLAG_QUIT_ON_EMPTY, params);


if (showHelp)
Expand Down

0 comments on commit e31e37e

Please sign in to comment.