From 8b58b368d5d6c1ae4517a488212e20231d07025a Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Tue, 2 Jan 2007 02:33:42 +0000 Subject: [PATCH] Implemented syntax highlight for drawing codes Originally committed to SVN as r679. --- aegisub/subs_edit_ctrl.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/aegisub/subs_edit_ctrl.cpp b/aegisub/subs_edit_ctrl.cpp index 9e464d000..516ea01c0 100644 --- a/aegisub/subs_edit_ctrl.cpp +++ b/aegisub/subs_edit_ctrl.cpp @@ -147,13 +147,16 @@ void SubsTextEditCtrl::UpdateStyle(int start, int _length) { int end = start + _length; if (_length < 0) end = text.Length(); + // Flags + bool numMode = false; // everything is considered a number/parameter until this is unset + bool drawingMode = false; // for \p1 -> \p0 stuff + // Begin styling StartStyling(0,255); int ran = 0; int depth = 0; int curStyle = 0; int curPos = 0; - bool numMode = false; wxChar curChar = 0; wxChar prevChar = 0; wxChar nextChar = 0; @@ -216,7 +219,8 @@ void SubsTextEditCtrl::UpdateStyle(int start, int _length) { SetUnicodeStyling(curPos,ran,curStyle); curPos += ran; ran = 0; - curStyle = 0; + if (drawingMode) curStyle = 6; + else curStyle = 0; } } @@ -261,6 +265,17 @@ void SubsTextEditCtrl::UpdateStyle(int start, int _length) { ran = tagLen-1; i+=ran; } + + // Set drawing mode if it's \p + if (text.Mid(curPos,1) == _T("p")) { + if (curPos+2 < (signed) text.Length()) { + wxChar nextNext = text[curPos+2]; + if (nextNext == _T('\\') || nextNext == _T('}')) { + if (nextChar == _T('0')) drawingMode = false; + if (nextChar == _T('1')) drawingMode = true; + } + } + } } } }