Patch #3308 2012-07-15 05:02

alpha0010

(Fix) highlight wxSmith generated code
Download
3308-Fix_highlight.patch (8.7 KB)
Category
Lexer
Status
Accepted
Close date
2012-07-18 20:48
Assigned to
mortenmacfly
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp    (revision 8133)
+++ src/sdk/editorconfigurationdlg.cpp    (working copy)
@@ -543,6 +543,7 @@
     if (cookie == wxNOT_FOUND)
         cookie = 0;
     cmbThemes->SetSelection(cookie);
+    XRCCTRL(*this, "chkColoursWxSmith", wxCheckBox)->SetValue(cfg->ReadBool(_T("/colour_sets/highlight_wxsmith"), true));
     ChangeTheme();
 }
 
@@ -612,6 +613,7 @@
     {
         wxString sel = cmbLangs->GetStringSelection();
         m_Lang = m_Theme->GetHighlightLanguage(sel);
+        XRCCTRL(*this, "chkColoursWxSmith", wxCheckBox)->Show(sel == wxT("C/C++"));
     }
 
     CreateColoursSample();
@@ -727,6 +729,7 @@
     {
         wxString sel = XRCCTRL(*this, "cmbLangs", wxComboBox)->GetStringSelection();
         m_Lang = m_Theme->GetHighlightLanguage(sel);
+        XRCCTRL(*this, "chkColoursWxSmith", wxCheckBox)->Show(sel == wxT("C/C++"));
     }
     FillColourComponents();
     CreateColoursSample();
@@ -930,6 +933,7 @@
             cfg->Write(_T("/colour_sets/active_colour_set"), m_Theme->GetName());
         }
         cfg->Write(_T("/colour_sets/active_lang"), XRCCTRL(*this, "cmbLangs", wxComboBox)->GetStringSelection());
+        cfg->Write(_T("/colour_sets/highlight_wxsmith"), XRCCTRL(*this, "chkColoursWxSmith", wxCheckBox)->GetValue());
 
         // encoding
         wxComboBox* cmbEnc = XRCCTRL(*this, "cmbEncoding", wxComboBox);
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp    (revision 8133)
+++ src/sdk/cbeditor.cpp    (working copy)
@@ -1604,6 +1604,7 @@
         control->SetProperty(_T("fold"), _T("0"));
         control->SetMarginWidth(C_FOLDING_MARGIN, 0);
     }
+    control->SetProperty(_T("highlight.wxsmith"), mgr->ReadBool(_T("/colour_sets/highlight_wxsmith"), true) ? _T("1") : _T("0"));
 
     // line numbering
     control->SetMarginType(C_LINE_MARGIN, wxSCI_MARGIN_NUMBER);
Index: src/sdk/wxscintilla/include/wx/wxscintilla.h
===================================================================
--- src/sdk/wxscintilla/include/wx/wxscintilla.h    (revision 8133)
+++ src/sdk/wxscintilla/include/wx/wxscintilla.h    (working copy)
@@ -577,7 +577,7 @@
 /* C::B begin */
 // Keep in sync with SciLexer.h      -> SCE_C_WXSMITH
 // Keep in sync with Scintilla.iface -> SCE_C_WXSMITH
-#define wxSCI_C_WXSMITH 99
+#define wxSCI_C_WXSMITH 50
 /* C::B end */
 
 // Lexical states for SCLEX_D
Index: src/sdk/wxscintilla/src/scintilla/include/Scintilla.iface
===================================================================
--- src/sdk/wxscintilla/src/scintilla/include/Scintilla.iface    (revision 8133)
+++ src/sdk/wxscintilla/src/scintilla/include/Scintilla.iface    (working copy)
@@ -273,9 +273,9 @@
 
 enu MarkerOutline=SC_MARKNUM_
 # CHANGEBAR begin #
-# Markers used for outlining and changed column. 
-val SC_MARKNUM_CHANGEUNSAVED=23 
-val SC_MARKNUM_CHANGESAVED=24 
+# Markers used for outlining and changed column.
+val SC_MARKNUM_CHANGEUNSAVED=23
+val SC_MARKNUM_CHANGESAVED=24
 # CHANGEBAR end #
 val SC_MARKNUM_FOLDEREND=25
 val SC_MARKNUM_FOLDEROPENMID=26
@@ -2565,7 +2565,7 @@
 # WXSMITH begin #
 # Keep in sync with wxscinilla.h -> wxSCI_C_WXSMITH
 # Keep in sync with SciLexer.h   -> SCE_C_WXSMITH
-val SCE_C_WXSMITH=99
+val SCE_C_WXSMITH=50
 # WXSMITH end #
 # Lexical states for SCLEX_D
 lex D=SCLEX_D SCE_D_
Index: src/sdk/wxscintilla/src/scintilla/include/SciLexer.h
===================================================================
--- src/sdk/wxscintilla/src/scintilla/include/SciLexer.h    (revision 8133)
+++ src/sdk/wxscintilla/src/scintilla/include/SciLexer.h    (working copy)
@@ -164,7 +164,7 @@
 /* C::B begin */
 // Keep in sync with wxscinilla.h    -> wxSCI_C_WXSMITH
 // Keep in sync with Scintilla.iface -> SCE_C_WXSMITH
-#define SCE_C_WXSMITH 99
+#define SCE_C_WXSMITH 50
 /* C::B end */
 #define SCE_D_DEFAULT 0
 #define SCE_D_COMMENT 1
Index: src/sdk/wxscintilla/src/scintilla/lexers/LexCPP.cxx
===================================================================
--- src/sdk/wxscintilla/src/scintilla/lexers/LexCPP.cxx    (revision 8133)
+++ src/sdk/wxscintilla/src/scintilla/lexers/LexCPP.cxx    (working copy)
@@ -218,7 +218,7 @@
     bool foldCompact;
     bool foldAtElse;
 /* C::B begin */
-    bool foldWxSmith;
+    bool highlightWxSmith;
 /* C::B end */
     OptionsCPP() {
         stylingWithinPreprocessor = false;
@@ -239,7 +239,7 @@
         foldCompact = false;
         foldAtElse = false;
 /* C::B begin */
-        foldWxSmith = false;
+        highlightWxSmith = true;
 /* C::B end */
     }
 };
@@ -306,6 +306,10 @@
 
         DefineProperty("fold.compact", &OptionsCPP::foldCompact);
 
+/* C::B begin */
+        DefineProperty("highlight.wxsmith", &OptionsCPP::highlightWxSmith);
+/* C::B end */
+
         DefineProperty("fold.at.else", &OptionsCPP::foldAtElse,
             "T
download for full patch...
alpha0010 2012-07-15 05:05

I could not help but notice someone had started extending the C++ lexer to support wxSmith code; this patch completes it.

It also adds the option to disable highlighting of wxSmith code (reverting to normal C++ syntax).

mortenmacfly 2012-07-15 07:03

I noticed something: wxSmith should always be index 99, nothing else. The reason is not to conflict with extensions of scintilla itself. Otherwise we have to adopt it everytime when a lexer is added.

Also, it really is about folding - why is it named "highlightWxSmith" now? Its there to fold wxSmith code, not to highlight it.

alpha0010 2012-07-15 12:03

Due to the enum "activeFlag" in LexCPP.cxx, the index must be < 64 (0x40); I choose 50 arbitrarily as a nice round number. (Also, scintilla would have to add 27 more items to the C++ lexer before this would conflict.)

I removed all references to "foldWxSmith" because it never was a working option (nor even accessible/used). The code that folds wxSmith is actually lines 1033-1038 (1020-1025 before the patch).

I could write an option to control this.

I added "highlightWxSmith" so that the user could turn off the identification of wxSmith code, and just see normal C++ highlighting.

mortenmacfly 2012-07-15 14:46

OK understood and agreed - in fact I never noticed that.

The patch looks fine, however, I don't like the place of the checkbox in the lexers. It applies only to the C/C++ lexer and is visible all the time.

I think it should go to the editor settings, below the option to interpret #if #else #endif.

alpha0010 2012-07-15 17:01

The editor settings page is already quite large, and I would prefer not increasing its size further.

This revision shows/hides the checkbox depending on the selected language. Is that acceptable?

mortenmacfly 2012-07-15 18:46

> Is that acceptable?

Actually not, because then we would need to transfer even more settings. I believe it simply doesn't belong there, because people don't expect it there and would not find/use it.

The best way on the long run would be to re-factor the UI of the editor settings. For now, don't worry about putting this into this UI although its a bit messy...

mortenmacfly 2012-07-15 19:35

OK, I think I got a solution: In the editor settings we should add another tab like "C/C++ editor options" and in there we can move all settings from the other tabs (including the new wxSmith one) that apply only to C/C++ editors. How does that sound?

alpha0010 2012-07-16 02:17

I think that is a good option. Do you want to work on migrating the settings? If not, I will try to get around to it.

mortenmacfly 2012-07-16 06:02

Yes, I can do it... just for this and the next week my time will definitely be limited due to "real" work. If you come up with something earlier I won't kill you. ;-)