[NEW_FEATURE] Tab settings per language(implementation terminated).
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@522 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
7472160a99
commit
f3a451f61c
@ -8710,6 +8710,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
if (nppgui._rememberLastSession)
|
||||
saveSession(currentSession);
|
||||
|
||||
|
||||
//Sends WM_DESTROY, Notepad++ will end
|
||||
::DestroyWindow(hwnd);
|
||||
|
||||
|
@ -957,6 +957,8 @@ void NppParameters::destroyInstance()
|
||||
{
|
||||
if (_pXmlDoc != NULL)
|
||||
{
|
||||
if (_pXmlDoc->isDirty())
|
||||
_pXmlDoc->SaveFile();
|
||||
delete _pXmlDoc;
|
||||
}
|
||||
|
||||
@ -969,8 +971,9 @@ void NppParameters::destroyInstance()
|
||||
delete _pXmlUserStylerDoc;
|
||||
|
||||
if (_pXmlUserLangDoc)
|
||||
{
|
||||
delete _pXmlUserLangDoc;
|
||||
|
||||
}
|
||||
if (_pXmlNativeLangDocA)
|
||||
delete _pXmlNativeLangDocA;
|
||||
|
||||
@ -2471,7 +2474,7 @@ void NppParameters::feedKeyWordsParameters(TiXmlNode *node)
|
||||
_langList[_nbLang]->setCommentStart(element->Attribute(TEXT("commentStart")));
|
||||
_langList[_nbLang]->setCommentEnd(element->Attribute(TEXT("commentEnd")));
|
||||
int i;
|
||||
if (element->Attribute(TEXT("TabSettings"), &i))
|
||||
if (element->Attribute(TEXT("tabSettings"), &i))
|
||||
_langList[_nbLang]->setTabInfo(i);
|
||||
|
||||
for (TiXmlNode *kwNode = langNode->FirstChildElement(TEXT("Keywords"));
|
||||
@ -4578,6 +4581,27 @@ void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & g
|
||||
_pXmlUserStylerDoc->SaveFile();
|
||||
}
|
||||
|
||||
|
||||
bool NppParameters::insertTabInfo(const TCHAR *langName, int tabInfo)
|
||||
{
|
||||
if (!_pXmlDoc) return false;
|
||||
TiXmlNode *langRoot = (_pXmlDoc->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("Languages"));
|
||||
for (TiXmlNode *childNode = langRoot->FirstChildElement(TEXT("Language"));
|
||||
childNode ;
|
||||
childNode = childNode->NextSibling(TEXT("Language")))
|
||||
{
|
||||
TiXmlElement *element = childNode->ToElement();
|
||||
const TCHAR *nm = element->Attribute(TEXT("name"));
|
||||
if (nm && lstrcmp(langName, nm) == 0)
|
||||
{
|
||||
childNode->ToElement()->SetAttribute(TEXT("tabSettings"), tabInfo);
|
||||
_pXmlDoc->makeDirty();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void NppParameters::writeStyle2Element(Style & style2Wite, Style & style2Sync, TiXmlElement *element)
|
||||
{
|
||||
if (HIBYTE(HIWORD(style2Wite._fgColor)) != 0xFF)
|
||||
|
@ -801,7 +801,7 @@ struct Lang
|
||||
};
|
||||
|
||||
void setTabInfo(int tabInfo) {
|
||||
if (tabInfo & MASK_TabSize)
|
||||
if (tabInfo != -1 && tabInfo & MASK_TabSize)
|
||||
{
|
||||
_isTabReplacedBySpace = (tabInfo & MASK_ReplaceBySpc) != 0;
|
||||
_tabSize = tabInfo & MASK_TabSize;
|
||||
@ -825,7 +825,7 @@ struct Lang
|
||||
|
||||
int getTabInfo() const {
|
||||
if (_tabSize == -1) return -1;
|
||||
return _isTabReplacedBySpace?0x80:0x00 | _tabSize;
|
||||
return (_isTabReplacedBySpace?0x80:0x00) | _tabSize;
|
||||
};
|
||||
};
|
||||
|
||||
@ -1141,6 +1141,7 @@ public:
|
||||
bool writeGUIParams();
|
||||
|
||||
void writeStyles(LexerStylerArray & lexersStylers, StyleArray & globalStylers);
|
||||
bool insertTabInfo(const TCHAR *langName, int tabInfo);
|
||||
|
||||
LexerStylerArray & getLStylerArray() {return _lexerStylerArray;};
|
||||
StyleArray & getGlobalStylers() {return _widgetStyleArray;};
|
||||
|
@ -2586,12 +2586,12 @@ void ScintillaEditView::setTabSettings(Lang *lang)
|
||||
if (lang && lang->_tabSize != -1 && lang->_tabSize != 0)
|
||||
{
|
||||
execute(SCI_SETTABWIDTH, lang->_tabSize);
|
||||
execute(SCI_SETUSETABS, lang->_isTabReplacedBySpace);
|
||||
execute(SCI_SETUSETABS, !lang->_isTabReplacedBySpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
const NppGUI & nppgui = (NppParameters::getInstance())->getNppGUI();
|
||||
execute(SCI_SETTABWIDTH, nppgui._tabSize);
|
||||
execute(SCI_SETUSETABS, nppgui._tabReplacedBySpace);
|
||||
execute(SCI_SETUSETABS, !nppgui._tabReplacedBySpace);
|
||||
}
|
||||
}
|
||||
|
@ -1107,6 +1107,13 @@ public:
|
||||
virtual void Print( FILE* cfile, int depth = 0 ) const;
|
||||
// [internal use]
|
||||
void SetError( int err, const TCHAR* errorLocation, TiXmlParsingData* prevData );
|
||||
void makeDirty() {
|
||||
_isDirty = true;
|
||||
};
|
||||
|
||||
bool isDirty() const {
|
||||
return _isDirty;
|
||||
};
|
||||
|
||||
protected :
|
||||
virtual void StreamOut ( TIXML_OSTREAM * out) const;
|
||||
@ -1122,6 +1129,7 @@ private:
|
||||
TIXML_STRING errorDesc;
|
||||
int tabsize;
|
||||
TiXmlCursor errorLocation;
|
||||
bool _isDirty;
|
||||
};
|
||||
|
||||
|
||||
|
@ -173,6 +173,7 @@ BEGIN
|
||||
CONTROL "Use default value",IDC_CHECK_DEFAULTTABVALUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,246,125,85,10
|
||||
RTEXT "Tab size : ",IDC_TABSIZE_STATIC,251,138,58,8
|
||||
LTEXT "0",IDC_TABSIZEVAL_STATIC,311,138,18,8
|
||||
LTEXT "0",IDC_TABSIZEVAL_DISABLE_STATIC,311,138,18,8
|
||||
CONTROL "Replace by space",IDC_CHECK_REPLACEBYSPACE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,258,149,100,10
|
||||
END
|
||||
|
||||
|
@ -65,7 +65,7 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
|
||||
_wVector.push_back(DlgInfo(&_marginsDlg, TEXT("Edit Components"), TEXT("Scintillas")));
|
||||
_wVector.push_back(DlgInfo(&_defaultNewDocDlg, TEXT("New Document/Open Save Directory"), TEXT("NewDoc")));
|
||||
_wVector.push_back(DlgInfo(&_fileAssocDlg, TEXT("File Association"), TEXT("FileAssoc")));
|
||||
_wVector.push_back(DlgInfo(&_langMenuDlg, TEXT("Language Menu"), TEXT("LangMenu")));
|
||||
_wVector.push_back(DlgInfo(&_langMenuDlg, TEXT("Language Menu/Tab Settings"), TEXT("LangMenu")));
|
||||
_wVector.push_back(DlgInfo(&_printSettingsDlg, TEXT("Print - Colour and Margin"), TEXT("Print1")));
|
||||
_wVector.push_back(DlgInfo(&_printSettings2Dlg, TEXT("Print - Header and Footer"), TEXT("Print2")));
|
||||
_wVector.push_back(DlgInfo(&_backupDlg, TEXT("Backup/Auto-completion"), TEXT("Backup")));
|
||||
@ -1039,7 +1039,8 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_SETCURSEL, 0, index2Begin);
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), SW_HIDE);
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), SW_HIDE);
|
||||
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), FALSE);
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE);
|
||||
|
||||
for (int i = L_TXT ; i < pNppParam->L_END ; i++)
|
||||
{
|
||||
@ -1091,6 +1092,8 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
TCHAR nbStr[10];
|
||||
wsprintf(nbStr, TEXT("%d"), size);
|
||||
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr);
|
||||
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), nbStr);
|
||||
|
||||
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
|
||||
if (index == LB_ERR) return FALSE;
|
||||
|
||||
@ -1099,11 +1102,15 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
Lang *lang = pNppParam->getLangFromIndex(index - 1);
|
||||
if (!lang) return FALSE;
|
||||
lang->_tabSize = size;
|
||||
|
||||
// write in langs.xml
|
||||
pNppParam->insertTabInfo(lang->getLangName(), lang->getTabInfo());
|
||||
}
|
||||
else
|
||||
{
|
||||
nppGUI._tabSize = size;
|
||||
}
|
||||
|
||||
::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_TAB_SIZE, 0);
|
||||
return TRUE;
|
||||
}
|
||||
@ -1117,7 +1124,12 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
{
|
||||
Lang *lang = pNppParam->getLangFromIndex(index - 1);
|
||||
if (!lang) return FALSE;
|
||||
if (!lang->_tabSize || lang->_tabSize == -1)
|
||||
lang->_tabSize = nppGUI._tabSize;
|
||||
lang->_isTabReplacedBySpace = isTabReplacedBySpace;
|
||||
|
||||
// write in langs.xml
|
||||
pNppParam->insertTabInfo(lang->getLangName(), lang->getTabInfo());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1129,7 +1141,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
|
||||
case IDC_LIST_TABSETTNG :
|
||||
{
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||
if (HIWORD(wParam) == LBN_SELCHANGE)
|
||||
{
|
||||
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
|
||||
if (index == LB_ERR)
|
||||
@ -1150,7 +1162,10 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab);
|
||||
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr);
|
||||
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), nbStr);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab);
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
|
||||
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab);
|
||||
|
||||
@ -1166,11 +1181,11 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
{
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE);
|
||||
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW);
|
||||
TCHAR nbStr[16];
|
||||
wsprintf(nbStr, TEXT("%d"),nppGUI._tabSize);
|
||||
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr);
|
||||
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE);
|
||||
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0);
|
||||
}
|
||||
@ -1200,9 +1215,15 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab);
|
||||
::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab);
|
||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
|
||||
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab);
|
||||
|
||||
// write in langs.xml
|
||||
if (useDefaultTab)
|
||||
pNppParam->insertTabInfo(lang->getLangName(), -1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#define IDC_LIST_TABSETTNG (IDD_PREFERENCE_LANG_BOX + 9)
|
||||
#define IDC_CHECK_DEFAULTTABVALUE (IDD_PREFERENCE_LANG_BOX + 10)
|
||||
#define IDC_GR_TABVALUE_STATIC (IDD_PREFERENCE_LANG_BOX + 11)
|
||||
#define IDC_TABSIZEVAL_DISABLE_STATIC (IDD_PREFERENCE_LANG_BOX + 12)
|
||||
|
||||
#define IDD_PREFERENCE_PRINT_BOX 6600 //(IDD_PREFERENCE_BOX + 600)
|
||||
#define IDC_CHECK_PRINTLINENUM (IDD_PREFERENCE_PRINT_BOX + 1)
|
||||
|
Loading…
Reference in New Issue
Block a user