src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Thu, 28 May 2015 05:06:09 +0000 (13:06 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 28 May 2015 05:06:09 +0000 (13:06 +0800)
src/Builder4/Editor.vala

src/Builder4/Editor.bjs
src/Builder4/Editor.vala

index 040ee88..c6bbbdb 100644 (file)
@@ -73,7 +73,7 @@
        "gboolean highlight_current_line" : true,
        "$ gboolean auto_indent" : true,
        "$ xns" : "Gtk",
-       "|   void load" : " (string str) {\n\n// show the help page for the active node..\n   //this.get('/Help').show();\n\n\n  // this.get('/BottomPane').el.set_current_page(0);\n  var buf = (Gtk.SourceBuffer)this.el.get_buffer();\n    buf.set_text(str, str.length);\n    buf.set_undo_manager(null);\n    \n    var lm = Gtk.SourceLanguageManager.get_default();\n    var lang = \"vala\";\n    if (_this.file != null) {\n         lang = _this.file.language;\n    }\n    //?? is javascript going to work as js?\n    \n    ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language(lang));\n \n     \n    _this.dirty = false;\n    this.el.grab_focus();\n    _this.save_button.el.sensitive = false;\n}",
+       "|   void load" : " (string str) {\n\n// show the help page for the active node..\n   //this.get('/Help').show();\n\n\n  // this.get('/BottomPane').el.set_current_page(0);\n  var buf = (Gtk.SourceBuffer)this.el.get_buffer();\n    buf.set_text(str, str.length);\n    buf.set_undo_manager(null);\n    \n    var lm = Gtk.SourceLanguageManager.get_default();\n    var lang = \"vala\";\n    if (_this.file != null) {\n         lang = _this.file.language;\n    }\n    \n \n    ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(\n            _this.file.content_type.length > 0  ?\n            lm.guess_language(_this.file.path, _this.file.content_type) :\n            lm.get_language(lang)\n        );\n \n     \n    _this.dirty = false;\n    this.el.grab_focus();\n    _this.save_button.el.sensitive = false;\n}",
        "indent_width" : 4,
        "$ show_line_numbers" : true,
        "items" : [
index f2d3923..fe189b6 100644 (file)
@@ -345,9 +345,13 @@ public class Editor : Object
             if (_this.file != null) {
                  lang = _this.file.language;
             }
-            //?? is javascript going to work as js?
             
-            ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language(lang));
+         
+            ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(
+                    _this.file.content_type.length > 0  ?
+                    lm.guess_language(_this.file.path, _this.file.content_type) :
+                    lm.get_language(lang)
+                );
          
              
             _this.dirty = false;