Browse Source

[BUG_FIXED] Fix crash issue while file's language is "User Defined" in the last session.

Fix the User Defined language and some languages' syntax highlighting problem while reload last session.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@247 f5eea248-9336-0410-98b8-ebc06183d4e3
pull/343/head^2
donho 17 years ago
parent
commit
8e9e2f30bc
  1. 20
      PowerEditor/src/Notepad_plus.cpp
  2. 2
      PowerEditor/src/Notepad_plus.h
  3. 6
      PowerEditor/src/Parameters.h
  4. 25
      PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp
  5. 2
      PowerEditor/src/ScitillaComponent/ScintillaEditView.h

20
PowerEditor/src/Notepad_plus.cpp

@ -487,7 +487,7 @@ bool Notepad_plus::loadSession(Session & session)
const char *pLn = session._mainViewFiles[i]._langName.c_str();
int id = getLangFromMenuName(pLn);
LangType typeToSet = L_TXT;
if (id != 0)
if (id != 0 && strcmp(pLn, "User Defined") != 0)
typeToSet = menuID2LangType(id);
Buffer * buf = MainFileManager->getBufferByID(lastOpened);
@ -5242,9 +5242,11 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode)
Buffer * buf = _pEditView->getCurrentBuffer();
if (buf->getLangType() == L_USER)
{
UserLangContainer & userLangContainer = NppParameters::getInstance()->getULCFromName(buf->getUserDefineLangName());
//::MessageBox(NULL, userLangContainer._keywordLists[4], "User", MB_OK);
symbol = extractSymbol('0', userLangContainer._keywordLists[4]);
UserLangContainer * userLangContainer = NppParameters::getInstance()->getULCFromName(buf->getUserDefineLangName());
if (!userLangContainer)
return false;
symbol = extractSymbol('0', userLangContainer->_keywordLists[4]);
commentLineSybol = symbol.c_str();
}
else
@ -5358,10 +5360,14 @@ bool Notepad_plus::doStreamComment()
Buffer * buf = _pEditView->getCurrentBuffer();
if (buf->getLangType() == L_USER)
{
UserLangContainer & userLangContainer = NppParameters::getInstance()->getULCFromName(buf->getUserDefineLangName());
symbolStart = extractSymbol('1', userLangContainer._keywordLists[4]);
UserLangContainer * userLangContainer = NppParameters::getInstance()->getULCFromName(buf->getUserDefineLangName());
if (!userLangContainer)
return false;
symbolStart = extractSymbol('1', userLangContainer->_keywordLists[4]);
commentStart = symbolStart.c_str();
symbolEnd = extractSymbol('2', userLangContainer._keywordLists[4]);
symbolEnd = extractSymbol('2', userLangContainer->_keywordLists[4]);
commentEnd = symbolEnd.c_str();
}
else

2
PowerEditor/src/Notepad_plus.h

@ -693,7 +693,7 @@ private:
int getLangFromMenuName(const char * langName) {
int id = 0;
char menuLangName[ 16 ];
char menuLangName[64];
for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; i++ )
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) )

6
PowerEditor/src/Parameters.h

@ -900,12 +900,12 @@ public:
int getNbUserLang() const {return _nbUserLang;};
UserLangContainer & getULCFromIndex(int i) {return *_userLangArray[i];};
UserLangContainer & getULCFromName(const char *userLangName) {
UserLangContainer * getULCFromName(const char *userLangName) {
for (int i = 0 ; i < _nbUserLang ; i++)
if (!strcmp(userLangName, _userLangArray[i]->_name))
return *_userLangArray[i];
return _userLangArray[i];
//qui doit etre jamais passer
return *_userLangArray[0];
return NULL;
};
int getNbExternalLang() const {return _nbExternalLang;};

25
PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp

@ -426,23 +426,27 @@ void ScintillaEditView::setUserLexer(const char *userLangName)
{
execute(SCI_SETLEXER, SCLEX_USER);
UserLangContainer & userLangContainer = userLangName?NppParameters::getInstance()->getULCFromName(userLangName):*(_userDefineDlg._pCurrentUserLang);
execute(SCI_SETPROPERTY, (WPARAM)"userDefine.ignoreCase", (LPARAM)(userLangContainer._isCaseIgnored?"1":"0"));
execute(SCI_SETPROPERTY, (WPARAM)"userDefine.commentLineSymbol", (LPARAM)(userLangContainer._isCommentLineSymbol?"1":"0"));
execute(SCI_SETPROPERTY, (WPARAM)"userDefine.commentSymbol", (LPARAM)(userLangContainer._isCommentSymbol?"1":"0"));
UserLangContainer * userLangContainer = userLangName?NppParameters::getInstance()->getULCFromName(userLangName):_userDefineDlg._pCurrentUserLang;
if (!userLangContainer)
return;
execute(SCI_SETPROPERTY, (WPARAM)"userDefine.ignoreCase", (LPARAM)(userLangContainer->_isCaseIgnored?"1":"0"));
execute(SCI_SETPROPERTY, (WPARAM)"userDefine.commentLineSymbol", (LPARAM)(userLangContainer->_isCommentLineSymbol?"1":"0"));
execute(SCI_SETPROPERTY, (WPARAM)"userDefine.commentSymbol", (LPARAM)(userLangContainer->_isCommentSymbol?"1":"0"));
const char strArray[4][20] = {"userDefine.g1Prefix", "userDefine.g2Prefix", "userDefine.g3Prefix", "userDefine.g4Prefix"};
for (int i = 0 ; i < 4 ; i++)
execute(SCI_SETPROPERTY, (WPARAM)strArray[i], (LPARAM)(userLangContainer._isPrefix[i]?"1":"0"));
execute(SCI_SETPROPERTY, (WPARAM)strArray[i], (LPARAM)(userLangContainer->_isPrefix[i]?"1":"0"));
for (int i = 0 ; i < userLangContainer.getNbKeywordList() ; i++)
for (int i = 0 ; i < userLangContainer->getNbKeywordList() ; i++)
{
execute(SCI_SETKEYWORDS, i, reinterpret_cast<LPARAM>(userLangContainer._keywordLists[i]));
execute(SCI_SETKEYWORDS, i, reinterpret_cast<LPARAM>(userLangContainer->_keywordLists[i]));
}
for (int i = 0 ; i < userLangContainer._styleArray.getNbStyler() ; i++)
for (int i = 0 ; i < userLangContainer->_styleArray.getNbStyler() ; i++)
{
Style & style = userLangContainer._styleArray.getStyler(i);
Style & style = userLangContainer->_styleArray.getStyler(i);
setStyle(style);
}
}
@ -1093,6 +1097,9 @@ void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask) {
if (buffer == _currentBuffer) {
if (mask & BufferChangeLanguage) {
defineDocType(buffer->getLangType());
int end = execute(SCI_GETENDSTYLED); //style up to the last styled byte.
execute(SCI_CLEARDOCUMENTSTYLE);
execute(SCI_COLOURISE, 0, end);
foldAll(fold_uncollapse);
}

2
PowerEditor/src/ScitillaComponent/ScintillaEditView.h

@ -52,7 +52,7 @@ class NppParameters;
typedef int (* SCINTILLA_FUNC) (void*, int, int, int);
typedef void * SCINTILLA_PTR;
typedef std::vector<Buffer> buf_vec_t;
//typedef std::vector<Buffer> buf_vec_t;
#define WM_DOCK_USERDEFINE_DLG (SCINTILLA_USER + 1)
#define WM_UNDOCK_USERDEFINE_DLG (SCINTILLA_USER + 2)

Loading…
Cancel
Save