[FEATURE]Add option to only show the filename in the titlebar.

[BUG] Fix bug with clearing read-only flag.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@340 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
harrybharry 2008-10-08 23:24:50 +00:00
parent 02e92ab36b
commit 8e3555f8e5
7 changed files with 93 additions and 17 deletions

View File

@ -3394,10 +3394,10 @@ void Notepad_plus::command(int id)
{
Buffer * buf = _pEditView->getCurrentBuffer();
DWORD dwFileAttribs = ::GetFileAttributes(buf->getFileName());
DWORD dwFileAttribs = ::GetFileAttributes(buf->getFullPathName());
dwFileAttribs ^= FILE_ATTRIBUTE_READONLY;
::SetFileAttributes(buf->getFileName(), dwFileAttribs);
::SetFileAttributes(buf->getFullPathName(), dwFileAttribs);
buf->setFileReadOnly(false);
}
@ -4542,6 +4542,7 @@ enum LangType Notepad_plus::menuID2LangType(int cmdID)
void Notepad_plus::setTitle()
{
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
//Get the buffer
Buffer * buf = _pEditView->getCurrentBuffer();
@ -4549,7 +4550,12 @@ void Notepad_plus::setTitle()
if (buf->isDirty()) {
result += TEXT("*");
}
result += buf->getFullPathName();
if (nppGUI._shortTitlebar) {
result += buf->getFileName();
} else {
result += buf->getFullPathName();
}
result += TEXT(" - ");
result += _className;
::SetWindowText(_hSelf, result.c_str());
@ -8071,6 +8077,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_INTERNAL_UPDATETITLEBAR :
{
setTitle();
return TRUE;
}
case WM_INITMENUPOPUP:
{
_windowsMenu.initPopupMenu((HMENU)wParam, _pDocTab);
@ -8757,6 +8769,11 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) {
setDisplayFormat(buffer->getFormat());
enableConvertMenuItems(buffer->getFormat());
}
if (mask & (BufferChangeReadonly))
{
checkDocState();
}
}
void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) {

View File

@ -2943,6 +2943,29 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
::ExpandEnvironmentStrings(_nppGUI._defaultDir, _nppGUI._defaultDirExp, 500);
}
}
else if (!lstrcmp(nm, TEXT("titleBar")))
{
const TCHAR * value = element->Attribute(TEXT("short"));
_nppGUI._shortTitlebar = false; //default state
if (value && value[0])
{
if (lstrcmp(value, TEXT("yes")) == 0)
_nppGUI._shortTitlebar = true;
else if (lstrcmp(value, TEXT("no")) == 0)
_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;
}
*/
}
}
}
@ -3229,6 +3252,7 @@ bool NppParameters::writeGUIParams()
bool tagsMatchHighLightExist = false;
bool caretExist = false;
bool openSaveDirExist = false;
bool titleBarExist = false;
TiXmlNode *dockingParamNode = NULL;
@ -3558,6 +3582,15 @@ bool NppParameters::writeGUIParams()
element->SetAttribute(TEXT("value"), _nppGUI._openSaveDir);
element->SetAttribute(TEXT("defaultDirPath"), _nppGUI._defaultDir);
}
else if (!lstrcmp(nm, TEXT("titleBar")))
{
titleBarExist = true;
const TCHAR *pStr = (_nppGUI._shortTitlebar)?TEXT("yes"):TEXT("no");
element->SetAttribute(TEXT("short"), pStr);
//pStr = (_nppGUI._showDirty)?TEXT("yes"):TEXT("no");
//element->SetAttribute(TEXT("showDirty"), pStr);
}
}
if (!noUpdateExist)
@ -3732,6 +3765,17 @@ bool NppParameters::writeGUIParams()
GUIConfigElement->SetAttribute(TEXT("defaultDirPath"), _nppGUI._defaultDir);
}
if (!titleBarExist)
{
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("titleBar"));
const TCHAR *pStr = (_nppGUI._shortTitlebar)?TEXT("yes"):TEXT("no");
GUIConfigElement->SetAttribute(TEXT("short"), pStr);
//pStr = (_nppGUI._showDirty)?TEXT("yes"):TEXT("no");
//GUIConfigElement->SetAttribute(TEXT("showDirty"), pStr);
}
insertDockingParamNode(GUIRoot);
return true;
}

View File

@ -534,7 +534,7 @@ struct NppGUI
_isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\
_doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\
_autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")), _neverUpdate(false),\
_doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1) {
_doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _shortTitlebar(false) {
_appPos.left = 0;
_appPos.top = 0;
_appPos.right = 700;
@ -608,6 +608,8 @@ struct NppGUI
int _caretBlinkRate;
int _caretWidth;
bool _shortTitlebar;
OpenSaveDirSetting _openSaveDir;
TCHAR _defaultDir[MAX_PATH];
TCHAR _defaultDirExp[MAX_PATH]; //expanded environment variables

View File

@ -98,30 +98,31 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "History File Setting",IDC_HISTORY_GB_STATIC,15,4,150,39,BS_CENTER
CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,27,133,10
RTEXT "Max number history file :",IDC_MAXNBFILE_STATIC,18,14,112,8
LTEXT "0",IDC_MAXNBFILEVAL_STATIC,137,14,15,8
CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,15,98,10
GROUPBOX "Clickable link setting",IDC_CLICKABLELINK_STATIC,193,4,150,39,BS_CENTER
CONTROL "Don't draw underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,28,119,10
EDITTEXT IDC_EDIT_SESSIONFILEEXT,298,164,67,14,ES_AUTOHSCROLL
LTEXT "Session file ext:",IDC_SESSIONFILEEXT_STATIC,300,152,66,8
CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,27,133,10
GROUPBOX "Document switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,15,48,150,39,BS_CENTER
CONTROL "Enable",IDC_CHECK_ENABLEDOCSWITCHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,59,69,10
CONTROL "Enable MRU behaviour",IDC_CHECK_STYLEMRU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,72,134,10
GROUPBOX "Document switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,15,48,150,39,BS_CENTER
CONTROL "Enable",IDC_CHECK_FILEAUTODETECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,57,98,10
CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,94,150,10
CONTROL "Smart highlighting",IDC_CHECK_ENABLSMARTHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,136,141,10
CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,108,130,10
CONTROL "Minimize to sys tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,122,130,10
CONTROL "Show only filename in titlebar",IDC_CHECK_SHORTTITLE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,150,217,10
CONTROL "Remember the current session for next launch",IDC_CHECK_REMEMBERSESSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,164,217,10
GROUPBOX "Clickable link setting",IDC_CLICKABLELINK_STATIC,193,4,150,39,BS_CENTER
CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,15,98,10
CONTROL "Don't draw underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,28,119,10
GROUPBOX "File Status Auto-detection",IDC_FILEAUTODETECTION_STATIC,193,47,150,50,BS_CENTER
CONTROL "Enable",IDC_CHECK_FILEAUTODETECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,57,98,10
CONTROL "Update silently",IDC_CHECK_UPDATESILENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,69,103,10
CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,81,141,10
CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,97,150,10
CONTROL "Smart highlighting",IDC_CHECK_ENABLSMARTHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,139,141,10
CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,111,130,10
CONTROL "Minimize to sys tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,125,130,10
CONTROL "Remember the current session for next launch",IDC_CHECK_REMEMBERSESSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,153,217,10
GROUPBOX "Highlight matching tags",IDC_TAGMATCHEDHILITE_STATIC,193,101,150,50,BS_CENTER
CONTROL "Enable",IDC_CHECK_ENABLTAGSMATCHHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,201,111,131,10
CONTROL "Highlight tag attributes",IDC_CHECK_ENABLTAGATTRHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,202,123,131,10
CONTROL "Highlight php/asp zone",IDC_CHECK_HIGHLITENONEHTMLZONE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,202,136,131,10
LTEXT "Session file ext:",IDC_SESSIONFILEEXT_STATIC,300,152,66,8
EDITTEXT IDC_EDIT_SESSIONFILEEXT,298,164,67,14,ES_AUTOHSCROLL
END

View File

@ -582,6 +582,8 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLTAGATTRHILITE), nppGUI._enableTagsMatchHilite);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_HIGHLITENONEHTMLZONE), nppGUI._enableTagsMatchHilite);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SHORTTITLE, BM_SETCHECK, nppGUI._shortTitlebar, 0);
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
if (enableDlgTheme)
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
@ -753,6 +755,14 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
nppGUI._styleMRU = !nppGUI._styleMRU;
return TRUE;
}
case IDC_CHECK_SHORTTITLE:
{
nppGUI._shortTitlebar = !nppGUI._shortTitlebar;
HWND grandParent = ::GetParent(_hParent);
::SendMessage(grandParent, NPPM_INTERNAL_UPDATETITLEBAR, 0, 0);
return TRUE;
}
}
}
}

View File

@ -105,6 +105,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define IDC_CHECK_ENABLTAGATTRHILITE (IDD_PREFERENCE_SETTING_BOX + 28)
#define IDC_TAGMATCHEDHILITE_STATIC (IDD_PREFERENCE_SETTING_BOX + 29)
#define IDC_CHECK_HIGHLITENONEHTMLZONE (IDD_PREFERENCE_SETTING_BOX + 30)
#define IDC_CHECK_SHORTTITLE (IDD_PREFERENCE_SETTING_BOX + 31)
#define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400)
#define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 1)

View File

@ -298,6 +298,7 @@
#define NPPM_INTERNAL_CLEARINDICATORTAGMATCH (NOTEPADPLUS_USER_INTERNAL + 20)
#define NPPM_INTERNAL_CLEARINDICATORTAGATTR (NOTEPADPLUS_USER_INTERNAL + 21)
#define NPPM_INTERNAL_SWITCHVIEWFROMHWND (NOTEPADPLUS_USER_INTERNAL + 22)
#define NPPM_INTERNAL_UPDATETITLEBAR (NOTEPADPLUS_USER_INTERNAL + 23)
// See Notepad_plus_msgs.h
//#define NOTEPADPLUS_USER (WM_USER + 1000)