src/Builder4/Editor.bjs
[app.Builder.js] / src / Builder4 / Editor.vala
index 4aca94d..5257480 100644 (file)
@@ -24,6 +24,7 @@ public class Editor : Object
     public int pos_root_x;
     public int pos_root_y;
     public string ptype;
+    public int last_search_end;
     public string key;
     public Gtk.SourceSearchContext searchcontext;
     public JsRender.JsRender file;
@@ -42,6 +43,7 @@ public class Editor : Object
         this.window = null;
         this.activeEditor = "";
         this.ptype = "";
+        this.last_search_end = 0;
         this.key = "";
         this.searchcontext = null;
         this.file = null;
@@ -126,7 +128,7 @@ public class Editor : Object
         
        this.buffer.el.get_start_iter(out beg);
        this.searchcontext.forward(beg, out st, out en);
-       
+       this.last_search_end = 0;
        
        return this.searchcontext.get_occurrences_count();
     
@@ -172,6 +174,20 @@ public class Editor : Object
                return;
        }
        
+       Gtk.TextIter beg, st,en;
+        
+       this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
+       this.searchcontext.forward(beg, out st, out en);
+       
+       if (en == null) {
+               this.last_search_end = 0;
+       } else {
+               this.last_search_end = en.get_offset();
+       
+               this.view.el.grab_focus();
+               this.buffer.el.place_cursor(st);
+               this.view.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);
+       }
     
     }
     public class Xcls_Box2 : Object