Allows user defined extension to associate workspace files
Closes #209; Close #169 Files ending in the defined extension will be opened in the project panel instead of as a normal file to edit (much like how the session file extension works).
This commit is contained in:
parent
4c53179c52
commit
1c84051d99
|
@ -250,6 +250,7 @@ public:
|
|||
//@}
|
||||
|
||||
bool isFileSession(const TCHAR * filename);
|
||||
bool isFileWorkspace(const TCHAR * filename);
|
||||
void filePrint(bool showDialog);
|
||||
bool saveScintillaParams();
|
||||
|
||||
|
|
|
@ -113,6 +113,13 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
|||
return BUFFER_INVALID;
|
||||
}
|
||||
|
||||
if (isFileWorkspace(longFileName) && PathFileExists(longFileName))
|
||||
{
|
||||
pNppParam->setWorkSpaceFilePath(0, longFileName);
|
||||
command(IDM_VIEW_PROJECT_PANEL_1);
|
||||
return BUFFER_INVALID;
|
||||
}
|
||||
|
||||
bool isWow64Off = false;
|
||||
if (!PathFileExists(longFileName))
|
||||
{
|
||||
|
@ -1335,6 +1342,29 @@ bool Notepad_plus::isFileSession(const TCHAR * filename) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Notepad_plus::isFileWorkspace(const TCHAR * filename) {
|
||||
// if filename matches the ext of user defined workspace file ext, then it'll be opened as a workspace
|
||||
const TCHAR *definedWorkspaceExt = NppParameters::getInstance()->getNppGUI()._definedWorkspaceExt.c_str();
|
||||
if (*definedWorkspaceExt != '\0')
|
||||
{
|
||||
generic_string fncp = filename;
|
||||
TCHAR *pExt = PathFindExtension(fncp.c_str());
|
||||
|
||||
generic_string usrWorkspaceExt = TEXT("");
|
||||
if (*definedWorkspaceExt != '.')
|
||||
{
|
||||
usrWorkspaceExt += TEXT(".");
|
||||
}
|
||||
usrWorkspaceExt += definedWorkspaceExt;
|
||||
|
||||
if (!generic_stricmp(pExt, usrWorkspaceExt.c_str()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Notepad_plus::loadLastSession()
|
||||
{
|
||||
NppParameters *nppParams = NppParameters::getInstance();
|
||||
|
@ -1359,11 +1389,11 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
|
|||
{
|
||||
const TCHAR *pFn = session._mainViewFiles[i]._fileName.c_str();
|
||||
|
||||
if (isFileSession(pFn))
|
||||
if (isFileSession(pFn) || isFileWorkspace(pFn))
|
||||
{
|
||||
vector<sessionFileInfo>::iterator posIt = session._mainViewFiles.begin() + i;
|
||||
session._mainViewFiles.erase(posIt);
|
||||
continue; //skip session files, not supporting recursive sessions
|
||||
continue; //skip session files, not supporting recursive sessions or embedded workspace files
|
||||
}
|
||||
|
||||
bool isWow64Off = false;
|
||||
|
@ -1454,10 +1484,10 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode)
|
|||
{
|
||||
const TCHAR *pFn = session._subViewFiles[k]._fileName.c_str();
|
||||
|
||||
if (isFileSession(pFn)) {
|
||||
if (isFileSession(pFn) || isFileWorkspace(pFn)) {
|
||||
vector<sessionFileInfo>::iterator posIt = session._subViewFiles.begin() + k;
|
||||
session._subViewFiles.erase(posIt);
|
||||
continue; //skip session files, not supporting recursive sessions
|
||||
continue; //skip session files, not supporting recursive sessions or embedded workspace files
|
||||
}
|
||||
|
||||
bool isWow64Off = false;
|
||||
|
|
|
@ -4506,6 +4506,17 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
|||
_nppGUI._definedSessionExt = val;
|
||||
}
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("workspaceExt")))
|
||||
{
|
||||
TiXmlNode *n = childNode->FirstChild();
|
||||
if (n)
|
||||
{
|
||||
const TCHAR* val = n->Value();
|
||||
val = n->Value();
|
||||
if (val)
|
||||
_nppGUI._definedWorkspaceExt = val;
|
||||
}
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("noUpdate")))
|
||||
{
|
||||
TiXmlNode *n = childNode->FirstChild();
|
||||
|
@ -4953,6 +4964,7 @@ bool NppParameters::writeGUIParams()
|
|||
bool autocExist = false;
|
||||
bool autocInsetExist = false;
|
||||
bool sessionExtExist = false;
|
||||
bool workspaceExtExist = false;
|
||||
bool noUpdateExist = false;
|
||||
bool menuBarExist = false;
|
||||
bool smartHighLightExist = false;
|
||||
|
@ -5370,6 +5382,15 @@ bool NppParameters::writeGUIParams()
|
|||
else
|
||||
childNode->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str()));
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("workspaceExt")))
|
||||
{
|
||||
workspaceExtExist = true;
|
||||
TiXmlNode *n = childNode->FirstChild();
|
||||
if (n)
|
||||
n->SetValue(_nppGUI._definedWorkspaceExt.c_str());
|
||||
else
|
||||
childNode->InsertEndChild(TiXmlText(_nppGUI._definedWorkspaceExt.c_str()));
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("noUpdate")))
|
||||
{
|
||||
noUpdateExist = true;
|
||||
|
@ -5607,6 +5628,13 @@ bool NppParameters::writeGUIParams()
|
|||
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str()));
|
||||
}
|
||||
|
||||
if (!workspaceExtExist)
|
||||
{
|
||||
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
||||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("workspaceExt"));
|
||||
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._definedWorkspaceExt.c_str()));
|
||||
}
|
||||
|
||||
if (!menuBarExist)
|
||||
{
|
||||
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
||||
|
|
|
@ -812,6 +812,8 @@ struct NppGUI final
|
|||
MatchedPairConf _matchedPairConf;
|
||||
|
||||
generic_string _definedSessionExt;
|
||||
generic_string _definedWorkspaceExt;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -144,12 +144,14 @@ BEGIN
|
|||
CONTROL "Highlight comment/php/asp zone",IDC_CHECK_HIGHLITENONEHTMLZONE,
|
||||
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,267,136,140,10
|
||||
EDITTEXT IDC_EDIT_SESSIONFILEEXT,381,157,34,14,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_EDIT_WORKSPACEFILEEXT,381,174,34,14,ES_AUTOHSCROLL
|
||||
GROUPBOX "Document Switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,37,4,155,39,BS_CENTER
|
||||
GROUPBOX "Smart Highlighting",IDC_SMARTHILITING_STATIC,37,47,155,39,BS_CENTER
|
||||
GROUPBOX "Clickable Link Settings",IDC_CLICKABLELINK_STATIC,259,4,155,39,BS_CENTER
|
||||
GROUPBOX "File Status Auto-Detection",IDC_FILEAUTODETECTION_STATIC,259,47,155,50,BS_CENTER
|
||||
GROUPBOX "Highlight Matching Tags",IDC_TAGMATCHEDHILITE_STATIC,259,101,155,50,BS_CENTER
|
||||
RTEXT "Session file ext.:",IDC_SESSIONFILEEXT_STATIC,271,160,108,8
|
||||
RTEXT "Workspace file ext.:",IDC_WORKSPACEFILEEXT_STATIC,271,177,108,8
|
||||
END
|
||||
|
||||
IDD_PREFERENCE_NEWDOCSETTING_BOX DIALOGEX 0, 0, 455, 185
|
||||
|
|
|
@ -875,6 +875,7 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
|||
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_CLICKABLELINK_NOUNDERLINE), dontUnderlineState);
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDC_EDIT_SESSIONFILEEXT, WM_SETTEXT, 0, (LPARAM)nppGUI._definedSessionExt.c_str());
|
||||
::SendDlgItemMessage(_hSelf, IDC_EDIT_WORKSPACEFILEEXT, WM_SETTEXT, 0, (LPARAM)nppGUI._definedWorkspaceExt.c_str());
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCSWITCHER, BM_SETCHECK, nppGUI._doTaskList, 0);
|
||||
::SendDlgItemMessage(_hSelf, IDC_CHECK_MAINTAININDENT, BM_SETCHECK, nppGUI._maitainIndent, 0);
|
||||
|
@ -911,6 +912,13 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
|||
nppGUI._definedSessionExt = sessionExt;
|
||||
return TRUE;
|
||||
}
|
||||
case IDC_EDIT_WORKSPACEFILEEXT:
|
||||
{
|
||||
TCHAR workspaceExt[MAX_PATH];
|
||||
::SendDlgItemMessage(_hSelf, IDC_EDIT_WORKSPACEFILEEXT, WM_GETTEXT, MAX_PATH, (LPARAM)workspaceExt);
|
||||
nppGUI._definedWorkspaceExt = workspaceExt;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,8 @@
|
|||
#define IDC_SMARTHILITING_STATIC (IDD_PREFERENCE_SETTING_BOX + 33)
|
||||
#define IDC_CHECK_DETECTENCODING (IDD_PREFERENCE_SETTING_BOX + 34)
|
||||
#define IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL (IDD_PREFERENCE_SETTING_BOX + 35)
|
||||
#define IDC_EDIT_WORKSPACEFILEEXT (IDD_PREFERENCE_SETTING_BOX + 36)
|
||||
#define IDC_WORKSPACEFILEEXT_STATIC (IDD_PREFERENCE_SETTING_BOX + 37)
|
||||
//-- FLS: xFileEditViewHistoryParameterGUI: Additional Checkbox for enabling the history for restoring the edit view per file.
|
||||
#define IDC_PREFERENCE_OFFSET_FLS 40
|
||||
#define IDC_CHECK_REMEMBEREDITVIEWPERFILE (IDD_PREFERENCE_SETTING_BOX + IDC_PREFERENCE_OFFSET_FLS + 1)
|
||||
|
|
Loading…
Reference in New Issue