Patch #2067 2007-06-19 13:36

olipfei

'Highlight mode' reflects current syntax highlighting
Download
2067-Highlight_mode.patch (2.3 KB)
Category
Application::Refinement
Status
Accepted
Close date
2007-07-21 19:59
Assigned to
biplab
Index: src/src/main.cpp
===================================================================
--- src/src/main.cpp    (revision 4107)
+++ src/src/main.cpp    (working copy)
@@ -785,10 +785,10 @@
                 wxArrayString langs = theme->GetAllHighlightLanguages();
                 for (size_t i = 0; i < langs.GetCount(); ++i)
                 {
-                    if (i == 20 || i == 40 || i ==60 || i == 80)
+                    if (i > 0 && !(i % 20))
                         hl->Break(); // break into columns every 20 items
                     int id = wxNewId();
-                    hl->Append(id, langs[i],
+                    hl->AppendRadioItem(id, langs[i],
                                 wxString::Format(_("Switch highlighting mode for current document to \"%s\""), langs[i].c_str()));
                     Connect(id, -1, wxEVT_COMMAND_MENU_SELECTED,
                             (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)
@@ -3033,7 +3033,7 @@
                         lang = theme->GetHighlightLanguage(item->GetLabel());
                 }
             }
-            theme->Apply(lang, ed->GetControl());
+            ed->SetLanguage(lang);
         }
     }
 }
@@ -3402,6 +3402,11 @@
         mbar->Check(idEditEncodingUnicode16LE, ed && ed->GetEncoding() == wxFONTENCODING_UTF16LE);
         mbar->Check(idEditEncodingUnicode32BE, ed && ed->GetEncoding() == wxFONTENCODING_UTF32BE);
         mbar->Check(idEditEncodingUnicode32LE, ed && ed->GetEncoding() == wxFONTENCODING_UTF32LE);
+
+        wxMenu* hl = 0;
+        mbar->FindItem(idEditHighlightModeText, &hl);
+        if (hl)
+            mbar->Check(hl->FindItem(ed->GetColourSet()->GetLanguageName(ed->GetLanguage())), true);
     }
 
     if (m_pToolbar)
Index: src/src/resources/main_menu.xrc
===================================================================
--- src/src/resources/main_menu.xrc    (revision 4107)
+++ src/src/resources/main_menu.xrc    (working copy)
@@ -213,6 +213,7 @@
         <help>Switch highlighting mode for the active editor</help>
         <object class="wxMenuItem" name="idEditHighlightModeText">
           <label>Plain text</label>
+          <radio>1</radio>
           <help>Switch highlighting mode for current document to &quot;Plain text&quot;</help>
         </object>
       </object>
olipfei 2007-06-19 14:00

Syntax highlighting of active editor is displayed as checked radio menu item under 'Edit->Highlight mode'. Switching mode to 'Plain text' is currently not working, but this is due to handling of HL_NONE in EditorColourSet::Apply(). I will further investigate this issue.

biplab 2007-07-21 19:59

Thanks for your patch.

olipfei 2007-07-22 19:33

Thanks for applying the patch, keep up the good work, and I hope I will be able to continue to contribute to Code::Blocks.