[NEW_FEATURE] Add the session file ext association feature (not yet finish).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@60 f5eea248-9336-0410-98b8-ebc06183d4e3
pull/343/head^2
donho 17 years ago
parent 0ea22b1a1e
commit 27d6d9b280

@ -401,7 +401,6 @@ bool Notepad_plus::doOpen(const char *fileName, bool isReadOnly)
char longFileName[MAX_PATH]; char longFileName[MAX_PATH];
::GetFullPathName(fileName, MAX_PATH, longFileName, NULL); ::GetFullPathName(fileName, MAX_PATH, longFileName, NULL);
//printInt(getCurrentView());
if (switchToFile(longFileName)) if (switchToFile(longFileName))
{ {
if (_pTrayIco) if (_pTrayIco)
@ -433,6 +432,15 @@ bool Notepad_plus::doOpen(const char *fileName, bool isReadOnly)
} }
} }
// if file2open matches the ext of user defined session file ext, then it'll be opened as a session
char fncp[MAX_PATH];
strcpy(fncp, longFileName);
char *pExt = PathFindExtension(fncp);
const char *definedSessionExt = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str();
if (strcmp(pExt, definedSessionExt))
{
return fileLoadSession(longFileName);
}
Utf8_16_Read UnicodeConvertor; Utf8_16_Read UnicodeConvertor;
@ -7272,8 +7280,9 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session)
_subEditView.activateDocAt(currentDocIndex); _subEditView.activateDocAt(currentDocIndex);
} }
void Notepad_plus::fileLoadSession(const char *fn) bool Notepad_plus::fileLoadSession(const char *fn)
{ {
bool result = false;
const char *sessionFileName = NULL; const char *sessionFileName = NULL;
if (fn == NULL) if (fn == NULL)
{ {
@ -7297,10 +7306,12 @@ void Notepad_plus::fileLoadSession(const char *fn)
if ((NppParameters::getInstance())->loadSession(session2Load, sessionFileName)) if ((NppParameters::getInstance())->loadSession(session2Load, sessionFileName))
{ {
isAllSuccessful = loadSession(session2Load); isAllSuccessful = loadSession(session2Load);
result = true;
} }
if (!isAllSuccessful) if (!isAllSuccessful)
(NppParameters::getInstance())->writeSession(session2Load, sessionFileName); (NppParameters::getInstance())->writeSession(session2Load, sessionFileName);
} }
return result;
} }

@ -312,7 +312,7 @@ public:
void getCurrentOpenedFiles(Session & session); void getCurrentOpenedFiles(Session & session);
void fileLoadSession(const char *fn = NULL); bool fileLoadSession(const char *fn = NULL);
const char * fileSaveSession(size_t nbFile, char ** fileNames, const char *sessionFile2save); const char * fileSaveSession(size_t nbFile, char ** fileNames, const char *sessionFile2save);
const char * fileSaveSession(size_t nbFile = 0, char ** fileNames = NULL); const char * fileSaveSession(size_t nbFile = 0, char ** fileNames = NULL);

@ -2151,7 +2151,18 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (element->Attribute("autoCAction", &i)) if (element->Attribute("autoCAction", &i))
_nppGUI._autocStatus = (NppGUI::AutocStatus)i; _nppGUI._autocStatus = (NppGUI::AutocStatus)i;
} }
else if (!strcmp(nm, "sessionExt"))
{
TiXmlNode *n = childNode->FirstChild();
if (n)
{
val = n->Value();
if (val)
_nppGUI._definedSessionExt = val;
}
}
} }
} }
void NppParameters::feedScintillaParam(bool whichOne, TiXmlNode *node) void NppParameters::feedScintillaParam(bool whichOne, TiXmlNode *node)
@ -2424,6 +2435,7 @@ void NppParameters::writeGUIParams()
bool URLExist = false; bool URLExist = false;
bool globalOverrideExist = false; bool globalOverrideExist = false;
bool autocExist = false; bool autocExist = false;
bool sessionExtExist = false;
TiXmlNode *dockingParamNode = NULL; TiXmlNode *dockingParamNode = NULL;
@ -2606,12 +2618,20 @@ void NppParameters::writeGUIParams()
pStr = _nppGUI._globalOverride.enableUnderLine?"yes":"no"; pStr = _nppGUI._globalOverride.enableUnderLine?"yes":"no";
element->SetAttribute("underline", pStr); element->SetAttribute("underline", pStr);
} }
else if (!strcmp(nm, "auto-completion"))
if (!strcmp(nm, "auto-completion"))
{ {
autocExist = true; autocExist = true;
element->SetAttribute("autoCAction", _nppGUI._autocStatus); element->SetAttribute("autoCAction", _nppGUI._autocStatus);
} }
else if (!strcmp(nm, "sessionExt"))
{
sessionExtExist = true;
TiXmlNode *n = childNode->FirstChild();
if (n)
n->SetValue(_nppGUI._definedSessionExt.c_str());
else
childNode->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str()));
}
} }
if (!autoDetectionExist) if (!autoDetectionExist)
@ -2656,6 +2676,7 @@ void NppParameters::writeGUIParams()
GUIConfigElement->SetAttribute("name", "langsExcluded"); GUIConfigElement->SetAttribute("name", "langsExcluded");
writeExcludedLangList(GUIConfigElement); writeExcludedLangList(GUIConfigElement);
} }
if (!printSettingExist) if (!printSettingExist)
{ {
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement();
@ -2724,6 +2745,15 @@ void NppParameters::writeGUIParams()
// Rase tout // Rase tout
GUIRoot->RemoveChild(dockingParamNode); GUIRoot->RemoveChild(dockingParamNode);
} }
if (!sessionExtExist)
{
//const char *pStr = bVal?"yes":"no";
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement();
GUIConfigElement->SetAttribute("name", "sessionExt");
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str()));
}
insertDockingParamNode(GUIRoot); insertDockingParamNode(GUIRoot);
} }

@ -510,7 +510,8 @@ struct NppGUI
_splitterPos(POS_HORIZOTAL), _userDefineDlgStatus(UDD_DOCKED), _tabSize(8),\ _splitterPos(POS_HORIZOTAL), _userDefineDlgStatus(UDD_DOCKED), _tabSize(8),\
_tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _checkHistoryFiles(true),\ _tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _checkHistoryFiles(true),\
_isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\ _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\
_doTaskList(true), _maitainIndent(true), _saveOpenKeepInSameDir(false), _styleMRU(true), _styleURL(0), _autocStatus(autoc_none) { _doTaskList(true), _maitainIndent(true), _saveOpenKeepInSameDir(false), _styleMRU(true), _styleURL(0),
_autocStatus(autoc_none), _definedSessionExt("") {
_appPos.left = 0; _appPos.left = 0;
_appPos.top = 0; _appPos.top = 0;
_appPos.right = 700; _appPos.right = 700;
@ -564,6 +565,7 @@ struct NppGUI
GlobalOverride _globalOverride; GlobalOverride _globalOverride;
enum AutocStatus{autoc_none, autoc_func, autoc_word}; enum AutocStatus{autoc_none, autoc_func, autoc_word};
AutocStatus _autocStatus; AutocStatus _autocStatus;
string _definedSessionExt;
}; };
struct ScintillaViewParams struct ScintillaViewParams

Loading…
Cancel
Save