[NEW_FEATURE] The set languages in session are remembered now.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@34 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
20f8196bec
commit
49c21209a1
@ -220,6 +220,9 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine)
|
|||||||
if (PathFileExists(pFn))
|
if (PathFileExists(pFn))
|
||||||
{
|
{
|
||||||
doOpen(pFn);
|
doOpen(pFn);
|
||||||
|
const char *pLn = lastSession._files[i]._langName.c_str();
|
||||||
|
setLangFromName(pLn);
|
||||||
|
|
||||||
cureentEditView->getCurrentBuffer().setPosition(lastSession._files[i]);
|
cureentEditView->getCurrentBuffer().setPosition(lastSession._files[i]);
|
||||||
cureentEditView->restoreCurrentPos(lastSession._files[i]);
|
cureentEditView->restoreCurrentPos(lastSession._files[i]);
|
||||||
|
|
||||||
@ -7174,7 +7177,11 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session)
|
|||||||
const Buffer & buf = _mainEditView.getBufferAt((size_t)i);
|
const Buffer & buf = _mainEditView.getBufferAt((size_t)i);
|
||||||
if (PathFileExists(buf._fullPathName))
|
if (PathFileExists(buf._fullPathName))
|
||||||
{
|
{
|
||||||
sessionFileInfo sfi(buf._fullPathName, buf._pos);
|
string languageName = getLangFromMenu( buf );
|
||||||
|
const char *langName = languageName.c_str();
|
||||||
|
|
||||||
|
sessionFileInfo sfi(buf._fullPathName, langName, buf._pos);
|
||||||
|
//sessionFileInfo sfi(buf._fullPathName, buf._pos);
|
||||||
|
|
||||||
_mainEditView.activateDocAt(i);
|
_mainEditView.activateDocAt(i);
|
||||||
int maxLine = _mainEditView.execute(SCI_GETLINECOUNT);
|
int maxLine = _mainEditView.execute(SCI_GETLINECOUNT);
|
||||||
@ -7244,6 +7251,9 @@ void Notepad_plus::fileLoadSession(const char *fn)
|
|||||||
const char *pFn = session2Load._files[i]._fileName.c_str();
|
const char *pFn = session2Load._files[i]._fileName.c_str();
|
||||||
if (doOpen(pFn))
|
if (doOpen(pFn))
|
||||||
{
|
{
|
||||||
|
const char *pLn = session2Load._files[i]._langName.c_str();
|
||||||
|
setLangFromName(pLn);
|
||||||
|
|
||||||
cureentEditView->getCurrentBuffer().setPosition(session2Load._files[i]);
|
cureentEditView->getCurrentBuffer().setPosition(session2Load._files[i]);
|
||||||
cureentEditView->restoreCurrentPos(session2Load._files[i]);
|
cureentEditView->restoreCurrentPos(session2Load._files[i]);
|
||||||
|
|
||||||
|
@ -865,6 +865,54 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible);
|
bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible);
|
||||||
|
|
||||||
|
void setLangFromName(const char * langName)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
char menuLangName[ 16 ];
|
||||||
|
|
||||||
|
for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; i++ )
|
||||||
|
if ( ::GetMenuString( ::GetMenu( _hSelf ), i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) )
|
||||||
|
if ( !strcmp( langName, menuLangName ) )
|
||||||
|
{
|
||||||
|
id = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( id == 0 )
|
||||||
|
{
|
||||||
|
for ( int i = IDM_LANG_USER + 1; i <= IDM_LANG_USER_LIMIT; i++ )
|
||||||
|
if ( ::GetMenuString( ::GetMenu( _hSelf ), i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) )
|
||||||
|
if ( !strcmp( langName, menuLangName ) )
|
||||||
|
{
|
||||||
|
id = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( id != 0 )
|
||||||
|
command( id );
|
||||||
|
}
|
||||||
|
|
||||||
|
string getLangFromMenu(Buffer buf)
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
const char * userLangName;
|
||||||
|
char menuLangName[32];
|
||||||
|
|
||||||
|
id = (NppParameters::getInstance())->langTypeToCommandID( buf.getLangType() );
|
||||||
|
|
||||||
|
if ( ( id != IDM_LANG_USER ) || !( buf.isUserDefineLangExt() ) )
|
||||||
|
{
|
||||||
|
( ::GetMenuString( ::GetMenu( _hSelf ), id, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) );
|
||||||
|
userLangName = (char *)menuLangName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userLangName = buf.getUserDefineLangName();
|
||||||
|
}
|
||||||
|
return userLangName;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //NOTEPAD_PLUS_H
|
#endif //NOTEPAD_PLUS_H
|
||||||
|
@ -630,8 +630,11 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
|
|||||||
(childNode->ToElement())->Attribute("xOffset", &position._xOffset);
|
(childNode->ToElement())->Attribute("xOffset", &position._xOffset);
|
||||||
(childNode->ToElement())->Attribute("startPos", &position._startPos);
|
(childNode->ToElement())->Attribute("startPos", &position._startPos);
|
||||||
(childNode->ToElement())->Attribute("endPos", &position._endPos);
|
(childNode->ToElement())->Attribute("endPos", &position._endPos);
|
||||||
|
const char *langName;
|
||||||
|
langName = (childNode->ToElement())->Attribute( "lang" );
|
||||||
|
|
||||||
sessionFileInfo sfi(fileName, position);
|
sessionFileInfo sfi( fileName, langName, position );
|
||||||
|
//sessionFileInfo sfi(fileName, position);
|
||||||
|
|
||||||
for (TiXmlNode *markNode = fnNode->NextSibling("Mark");
|
for (TiXmlNode *markNode = fnNode->NextSibling("Mark");
|
||||||
markNode ;
|
markNode ;
|
||||||
@ -1036,6 +1039,7 @@ void NppParameters::writeSession(const Session & session, const char *fileName)
|
|||||||
(fileNameNode->ToElement())->SetAttribute("xOffset", session._files[i]._xOffset);
|
(fileNameNode->ToElement())->SetAttribute("xOffset", session._files[i]._xOffset);
|
||||||
(fileNameNode->ToElement())->SetAttribute("startPos", session._files[i]._startPos);
|
(fileNameNode->ToElement())->SetAttribute("startPos", session._files[i]._startPos);
|
||||||
(fileNameNode->ToElement())->SetAttribute("endPos", session._files[i]._endPos);
|
(fileNameNode->ToElement())->SetAttribute("endPos", session._files[i]._endPos);
|
||||||
|
(fileNameNode->ToElement())->SetAttribute("lang", session._files[i]._langName.c_str());
|
||||||
|
|
||||||
TiXmlText fileNameFullPath(session._files[i]._fileName.c_str());
|
TiXmlText fileNameFullPath(session._files[i]._fileName.c_str());
|
||||||
fileNameNode->InsertEndChild(fileNameFullPath);
|
fileNameNode->InsertEndChild(fileNameFullPath);
|
||||||
|
@ -93,11 +93,14 @@ struct Position
|
|||||||
|
|
||||||
struct sessionFileInfo : public Position {
|
struct sessionFileInfo : public Position {
|
||||||
string _fileName;
|
string _fileName;
|
||||||
|
string _langName;
|
||||||
|
|
||||||
sessionFileInfo(const char *fn) {
|
sessionFileInfo(const char *fn) {
|
||||||
if (fn) _fileName = fn;
|
if (fn) _fileName = fn;
|
||||||
};
|
};
|
||||||
sessionFileInfo(const char *fn, Position pos) : Position(pos) {
|
sessionFileInfo(const char *fn, const char *ln, Position pos) : Position(pos) {
|
||||||
if (fn) _fileName = fn;
|
if (fn) _fileName = fn;
|
||||||
|
if (ln) _langName = ln;
|
||||||
};
|
};
|
||||||
sessionFileInfo(string fn) : _fileName(fn){};
|
sessionFileInfo(string fn) : _fileName(fn){};
|
||||||
sessionFileInfo(string fn, Position pos) : Position(pos), _fileName(fn){};
|
sessionFileInfo(string fn, Position pos) : Position(pos), _fileName(fn){};
|
||||||
|
Loading…
Reference in New Issue
Block a user