mirror of https://github.com/odrling/Aegisub
Intermediate implementation of #498 - karaoke template syntax highlighting. Only !! blocks and $variables are highlighted right now, and no actual Lua specific highlighting is done.
Originally committed to SVN as r1470.
This commit is contained in:
parent
53a95b3af2
commit
4e48317803
|
@ -228,14 +228,14 @@ DialogOptions::DialogOptions(wxWindow *parent)
|
||||||
|
|
||||||
// Second static box
|
// Second static box
|
||||||
wxControl *control;
|
wxControl *control;
|
||||||
wxString labels2[9] = { _("Normal"), _("Brackets"), _("Slashes and Parentheses"), _("Tags"), _("Parameters") ,
|
wxString labels2[10] = { _("Normal"), _("Brackets"), _("Slashes and Parentheses"), _("Tags"), _("Parameters") ,
|
||||||
_("Error"), _("Error Background"), _("Line Break"), _("Modified Background") };
|
_("Error"), _("Error Background"), _("Line Break"), _("Karaoke templates"), _("Modified Background") };
|
||||||
wxString options2[11] = { _T("Normal"), _T("Brackets"), _T("Slashes"), _T("Tags"), _T("Parameters") ,
|
wxString options2[12] = { _T("Normal"), _T("Brackets"), _T("Slashes"), _T("Tags"), _T("Parameters") ,
|
||||||
_T("Error"), _T("Error Background"), _T("Line Break"), _T("Edit box need enter background"), _T("Edit Font Face"), _T("Edit Font Size") };
|
_T("Error"), _T("Error Background"), _T("Line Break"), _T("Karaoke Template"), _T("Edit box need enter background"), _T("Edit Font Face"), _T("Edit Font Size") };
|
||||||
for (int i=0;i<9;i++) {
|
for (int i=0;i<10;i++) {
|
||||||
wxString caption = labels2[i]+_T(": ");
|
wxString caption = labels2[i]+_T(": ");
|
||||||
wxString option = options2[i];
|
wxString option = options2[i];
|
||||||
if (i < 8) {
|
if (i < 9) {
|
||||||
caption = _("Syntax highlighter - ") + caption;
|
caption = _("Syntax highlighter - ") + caption;
|
||||||
option = _T("Syntax highlight ") + option;
|
option = _T("Syntax highlight ") + option;
|
||||||
}
|
}
|
||||||
|
@ -251,11 +251,11 @@ DialogOptions::DialogOptions(wxWindow *parent)
|
||||||
browse = new BrowseButton(editPage,-1,_T(""),BROWSE_FONT);
|
browse = new BrowseButton(editPage,-1,_T(""),BROWSE_FONT);
|
||||||
control = new wxTextCtrl(editPage,-1);
|
control = new wxTextCtrl(editPage,-1);
|
||||||
browse->Bind((wxTextCtrl*)control);
|
browse->Bind((wxTextCtrl*)control);
|
||||||
Bind(control,options2[9]);
|
Bind(control,options2[10]);
|
||||||
editSizer5->Add(control,1,wxEXPAND | wxRIGHT,5);
|
editSizer5->Add(control,1,wxEXPAND | wxRIGHT,5);
|
||||||
control = new wxTextCtrl(editPage,-1,_T(""),wxDefaultPosition,wxSize(50,-1),0,NumValidator(NULL,false));;
|
control = new wxTextCtrl(editPage,-1,_T(""),wxDefaultPosition,wxSize(50,-1),0,NumValidator(NULL,false));;
|
||||||
browse->Bind((wxTextCtrl*)control,1);
|
browse->Bind((wxTextCtrl*)control,1);
|
||||||
Bind(control,options2[10]);
|
Bind(control,options2[11]);
|
||||||
editSizer5->Add(control,0,wxEXPAND | wxRIGHT,5);
|
editSizer5->Add(control,0,wxEXPAND | wxRIGHT,5);
|
||||||
editSizer5->Add(browse,0,wxEXPAND);
|
editSizer5->Add(browse,0,wxEXPAND);
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
|
||||||
SetColour(_T("Syntax Highlight Error"),wxColour(200,0,0));
|
SetColour(_T("Syntax Highlight Error"),wxColour(200,0,0));
|
||||||
SetColour(_T("Syntax Highlight Error Background"),wxColour(255,200,200));
|
SetColour(_T("Syntax Highlight Error Background"),wxColour(255,200,200));
|
||||||
SetColour(_T("Syntax Highlight Line Break"),wxColour(160,160,160));
|
SetColour(_T("Syntax Highlight Line Break"),wxColour(160,160,160));
|
||||||
|
SetColour(_T("Syntax Highlight Karaoke Template"), wxColour(128,0,192));
|
||||||
SetColour(_T("Edit Box Need Enter Background"),wxColour(192,192,255));
|
SetColour(_T("Edit Box Need Enter Background"),wxColour(192,192,255));
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
SetInt(_T("Edit Font Size"),9);
|
SetInt(_T("Edit Font Size"),9);
|
||||||
|
|
|
@ -214,6 +214,13 @@ void SubsTextEditCtrl::SetStyles() {
|
||||||
StyleSetBold(6,true);
|
StyleSetBold(6,true);
|
||||||
StyleSetForeground(6,Options.AsColour(_T("Syntax Highlight Line Break")));
|
StyleSetForeground(6,Options.AsColour(_T("Syntax Highlight Line Break")));
|
||||||
|
|
||||||
|
// Karaoke template code block style
|
||||||
|
StyleSetFont(7,font);
|
||||||
|
StyleSetSize(7,size);
|
||||||
|
StyleSetBold(7,true);
|
||||||
|
//StyleSetItalic(7,true);
|
||||||
|
StyleSetForeground(7,Options.AsColour(_T("Syntax Highlight Karaoke Template")));
|
||||||
|
|
||||||
// Misspelling indicator
|
// Misspelling indicator
|
||||||
IndicatorSetStyle(0,wxSTC_INDIC_SQUIGGLE);
|
IndicatorSetStyle(0,wxSTC_INDIC_SQUIGGLE);
|
||||||
IndicatorSetForeground(0,wxColour(255,0,0));
|
IndicatorSetForeground(0,wxColour(255,0,0));
|
||||||
|
@ -237,10 +244,10 @@ void SubsTextEditCtrl::UpdateStyle(int start, int _length) {
|
||||||
|
|
||||||
// Begin styling
|
// Begin styling
|
||||||
StartStyling(0,255);
|
StartStyling(0,255);
|
||||||
int ran = 0;
|
int ran = 0; // length of current range
|
||||||
int depth = 0;
|
int depth = 0; // brace nesting depth
|
||||||
int curStyle = 0;
|
int curStyle = 0; // style to apply to current range
|
||||||
int curPos = 0;
|
int curPos = 0; // start of current range?
|
||||||
wxChar curChar = 0;
|
wxChar curChar = 0;
|
||||||
wxChar prevChar = 0;
|
wxChar prevChar = 0;
|
||||||
wxChar nextChar = 0;
|
wxChar nextChar = 0;
|
||||||
|
@ -284,6 +291,40 @@ void SubsTextEditCtrl::UpdateStyle(int start, int _length) {
|
||||||
numMode = false;
|
numMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Karaoke template block
|
||||||
|
else if (curChar == _T('!')) {
|
||||||
|
// Apply previous style
|
||||||
|
SetUnicodeStyling(curPos,ran,curStyle);
|
||||||
|
curPos += ran;
|
||||||
|
ran = -1; // such that ran++ later on resets it to 0 !
|
||||||
|
// Eat entire template block
|
||||||
|
int endPos = i+1;
|
||||||
|
while (endPos < end && text[endPos] != _T('!'))
|
||||||
|
endPos++;
|
||||||
|
SetUnicodeStyling(curPos,endPos-curPos+1,7);
|
||||||
|
curPos = endPos+1;
|
||||||
|
i = endPos+0;
|
||||||
|
}
|
||||||
|
// Karaoke template variable
|
||||||
|
else if (curChar == _T('$')) {
|
||||||
|
// Apply previous style
|
||||||
|
SetUnicodeStyling(curPos,ran,curStyle);
|
||||||
|
curPos += ran;
|
||||||
|
ran = -1; // such that ran++ later on resets it to 0 !
|
||||||
|
// Eat entire variable
|
||||||
|
int endPos = i+1;
|
||||||
|
while (endPos < end) {
|
||||||
|
wxChar ch = text[endPos];
|
||||||
|
if ((ch >= _T('A') && ch <= _T('Z')) || (ch >= _T('a') && ch <= _T('z')) || ch == _T('_'))
|
||||||
|
endPos++;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SetUnicodeStyling(curPos,endPos-curPos,7);
|
||||||
|
curPos = endPos;
|
||||||
|
i = curPos-1;
|
||||||
|
}
|
||||||
|
|
||||||
// Outside
|
// Outside
|
||||||
else if (depth == 0) {
|
else if (depth == 0) {
|
||||||
// Reset number mode
|
// Reset number mode
|
||||||
|
|
Loading…
Reference in New Issue