src/Builder4/WindowRooView.bjs
[app.Builder.js] / src / Builder4 / WindowRooView.vala
index 2818e6e..2061970 100644 (file)
@@ -1087,7 +1087,7 @@ public class Xcls_WindowRooView : Object
                     }
                     ltree.view.setCursor(tp, "editor");
                    // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); 
-                   this.nodeSelected(node);
+                   this.nodeSelected(node,false);
                     
                     // scrolling is disabled... as node selection calls scroll 10ms after it changes.
                     GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
@@ -1098,7 +1098,7 @@ public class Xcls_WindowRooView : Object
                 
                 // highlight the node..
         }
-        public void nodeSelected (JsRender.Node? sel) {
+        public void nodeSelected (JsRender.Node? sel, bool scroll ) {
           
             
           
@@ -1140,7 +1140,7 @@ public class Xcls_WindowRooView : Object
             //if (cur_line > sel.line_start && cur_line < sel.line_end) {
             
             //} else {
-            if (this.allow_node_scroll) {
+            if (scroll) {
                         
                this.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);
                }
@@ -1168,7 +1168,9 @@ public class Xcls_WindowRooView : Object
             if (this.el.editable && sbuf.get_has_selection()) {
                        Gtk.TextIter sel_start_iter, sel_end_iter;
                        sbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);
-                       if (sel_start_iter.get_line() < start_line || sel_start_iter.get_line() > end_line) {
+                       
+                       if (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||
+                               sel_start_iter.get_line() > end_line   || sel_end_iter.get_line() < start_line                  ) {
                                // save?
                                this.el.editable = false;
                        }
@@ -1201,6 +1203,17 @@ public class Xcls_WindowRooView : Object
         }
         public void loadFile ( ) {
             this.loading = true;
+            
+            
+            // get the cursor and scroll position....
+            var buf = this.el.get_buffer();
+               var cpos = buf.cursor_position;
+            
+        
+           
+            var vadj = this.el.get_vadjustment();
+           
+            
             var buf = this.el.get_buffer();
             buf.set_text("",0);
             var sbuf = (Gtk.SourceBuffer) buf;
@@ -1232,6 +1245,11 @@ public class Xcls_WindowRooView : Object
             sbuf.get_bounds (out start, out end);
             sbuf.remove_source_marks (start, end, null); // remove all marks..
             
+            Gtk.TextIter cpos_iter;
+            buf.get_iter_at_offset(out cpos_iter, cpos);
+            buf.place_cursor(cpos_iter); 
+            
+            this.el.set_vadjustment(vadj);