Browse Source

[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
remotes/patch_testing@481
Don Ho 17 years ago
parent
commit
236ab0356e
  1. 15
      PowerEditor/src/Notepad_plus.cpp
  2. 2
      PowerEditor/src/Notepad_plus.h
  3. 34
      PowerEditor/src/Parameters.cpp
  4. 4
      PowerEditor/src/Parameters.h

15
PowerEditor/src/Notepad_plus.cpp

@ -401,7 +401,6 @@ bool Notepad_plus::doOpen(const char *fileName, bool isReadOnly)
char longFileName[MAX_PATH];
::GetFullPathName(fileName, MAX_PATH, longFileName, NULL);
//printInt(getCurrentView());
if (switchToFile(longFileName))
{
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;
@ -7272,8 +7280,9 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session)
_subEditView.activateDocAt(currentDocIndex);
}
void Notepad_plus::fileLoadSession(const char *fn)
bool Notepad_plus::fileLoadSession(const char *fn)
{
bool result = false;
const char *sessionFileName = NULL;
if (fn == NULL)
{
@ -7297,10 +7306,12 @@ void Notepad_plus::fileLoadSession(const char *fn)
if ((NppParameters::getInstance())->loadSession(session2Load, sessionFileName))
{
isAllSuccessful = loadSession(session2Load);
result = true;
}
if (!isAllSuccessful)
(NppParameters::getInstance())->writeSession(session2Load, sessionFileName);
}
return result;
}

2
PowerEditor/src/Notepad_plus.h

@ -312,7 +312,7 @@ public:
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 = 0, char ** fileNames = NULL);

34
PowerEditor/src/Parameters.cpp

@ -2151,7 +2151,18 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (element->Attribute("autoCAction", &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)
@ -2424,6 +2435,7 @@ void NppParameters::writeGUIParams()
bool URLExist = false;
bool globalOverrideExist = false;
bool autocExist = false;
bool sessionExtExist = false;
TiXmlNode *dockingParamNode = NULL;
@ -2606,12 +2618,20 @@ void NppParameters::writeGUIParams()
pStr = _nppGUI._globalOverride.enableUnderLine?"yes":"no";
element->SetAttribute("underline", pStr);
}
if (!strcmp(nm, "auto-completion"))
else if (!strcmp(nm, "auto-completion"))
{
autocExist = true;
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)
@ -2656,6 +2676,7 @@ void NppParameters::writeGUIParams()
GUIConfigElement->SetAttribute("name", "langsExcluded");
writeExcludedLangList(GUIConfigElement);
}
if (!printSettingExist)
{
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement();
@ -2724,6 +2745,15 @@ void NppParameters::writeGUIParams()
// Rase tout
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);
}

4
PowerEditor/src/Parameters.h

@ -510,7 +510,8 @@ struct NppGUI
_splitterPos(POS_HORIZOTAL), _userDefineDlgStatus(UDD_DOCKED), _tabSize(8),\
_tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _checkHistoryFiles(true),\
_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.top = 0;
_appPos.right = 700;
@ -564,6 +565,7 @@ struct NppGUI
GlobalOverride _globalOverride;
enum AutocStatus{autoc_none, autoc_func, autoc_word};
AutocStatus _autocStatus;
string _definedSessionExt;
};
struct ScintillaViewParams

Loading…
Cancel
Save