[MonoDevelop] A question on dynamically change the SyntaxMode of Mono.TextEditor.Document
Mike Krüger
mkrueger at novell.com
Sat Mar 20 18:44:01 EDT 2010
Hi
> "editor.Document.SyntaxMode = mode;", I tried "editor.Repaint ()" or
> "editor.Document.CommitUpdateAll", but find them didn't work.
>
CommitUpdateAll should work. Try a
SyntaxModeService.WaitUpdate(editor.Document) call before the
CommitUpdateAll.
btw. syntax mode can be set with editor.Document.MimeType =
"text/x-csharp" much faster.
Regards
Mike
> // --- source ---
>
> using Mono.TextEditor;
> using Mono.TextEditor.Highlighting;
>
> public partial class MainWindow : Gtk.Window
> {
> public MainWindow () : base(Gtk.WindowType.Toplevel)
> {
> Build ();
> var editor = new TextEditor ();
> vbox1.PackStart (editor, true, true, 0);
>
> var btn = new Button ();
> btn.Label = "debug";
> btn.Clicked += delegate {
> var mode = SyntaxModeService.GetSyntaxMode ("text/x-csharp");
> editor.Document.SyntaxMode = mode;
> };
> vbox1.PackStart (btn, false, false, 0);
>
> this.Focus = editor;
> }
> ...
> }
>
> //--- end of code ---
>
> Thanks
More information about the Monodevelop-list
mailing list