src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 2 Jun 2015 11:14:14 +0000 (19:14 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 2 Jun 2015 11:14:14 +0000 (19:14 +0800)
src/Builder4/Editor.vala

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

index 1b445d7..95f4a2b 100644 (file)
@@ -11,7 +11,7 @@
    "# Xcls_MainWindow window" : "null",
    "# string activeEditor" : "\"\"",
    "|   bool saveContents" : "  ()  {\n    \n    \n    if (_this.file == null) {\n        return true;\n    }\n    \n    \n   \n   \n     \n     var str = _this.buffer.toString();\n     \n     _this.buffer.checkSyntax();\n     \n     \n     \n     // LeftPanel.model.changed(  str , false);\n     _this.dirty = false;\n     _this.save_button.el.sensitive = false;\n     \n    // find the text for the node..\n    if (_this.file.xtype != \"PlainFile\") {\n        if (ptype == \"listener\") {\n            this.node.listeners.set(key,str);\n        \n        } else {\n             this.node.props.set(key,str);\n        }\n    } else {\n        _this.file.setSource(  str );\n     }\n    \n    // call the signal..\n    this.save();\n    \n    return true;\n\n} ",
-   "| void scroll_to_line" : "(int line) {\n   \n}\n",
+   "| void scroll_to_line" : "(int line) {\n     var buf = this.view.el.get_buffer();\n \n    var sbuf = (Gtk.SourceBuffer) buf;\n\n\n\tGtk.TextIter iter;   \n    sbuf.get_iter_at_line(out iter,  line);\n    this.view.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.0f);\n   \n}\n",
    "# int pos_root_x" : "",
    "# int pos_root_y" : "",
    "# string ptype" : "\"\"",
index a8f4ad1..d615af2 100644 (file)
@@ -99,6 +99,14 @@ public class Editor : Object
     
     }
     public void scroll_to_line (int line) {
+         var buf = this.view.el.get_buffer();
+     
+        var sbuf = (Gtk.SourceBuffer) buf;
+    
+    
+       Gtk.TextIter iter;   
+        sbuf.get_iter_at_line(out iter,  line);
+        this.view.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.0f);
        
     }
     public   void show (JsRender.JsRender file, JsRender.Node? node, string ptype, string key)