src/Builder4/GtkView.bjs
authorAlan <alan@roojs.com>
Thu, 18 Aug 2022 10:53:25 +0000 (18:53 +0800)
committerAlan <alan@roojs.com>
Thu, 18 Aug 2022 10:53:25 +0000 (18:53 +0800)
src/Builder4/GtkView.vala
src/Builder4/WindowRooView.bjs
src/Builder4/WindowRooView.vala

src/Builder4/GtkView.bjs
src/Builder4/GtkView.vala

index 266d669..33ae4b4 100644 (file)
     "}",
     ""
    ],
+   "| void backSearch" : [
+    "(bool change_focus) {",
+    "",
+    "\tif (this.searchcontext == null) {",
+    "\t\treturn;",
+    "\t} ",
+    "\t",
+    "\tGtk.TextIter beg, st,en;",
+    "\tbool has_wrapped_around;",
+    "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
+    "\t",
+    "\tif (!this.searchcontext.backward2(beg, out st, out en, out has_wrapped_around)) {",
+    "\t",
+    "\t\tthis.last_search_end = 0;",
+    "\t\treturn;",
+    "\t}",
+    "\tthis.last_search_end = en.get_offset();",
+    "\tif (change_focus) {",
+    "\t\tthis.view.el.grab_focus();",
+    "\t}",
+    "\tthis.buffer.el.place_cursor(st);",
+    "\tthis.sourceview.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);",
+    "\tvar ln = st.get_line();",
+    "\tthis.highlightNodeAtLine(ln);",
+    "\t",
+    " ",
+    "}",
+    ""
+   ],
    "| void createThumb" : [
     "() {",
     "    ",
index 9fd5921..964cfb1 100644 (file)
@@ -146,6 +146,32 @@ public class Xcls_GtkView : Object
        var ln = st.get_line();
        
        this.highlightNodeAtLine(ln);
+    }
+    public void backSearch (bool change_focus) {
+    
+       if (this.searchcontext == null) {
+               return;
+       } 
+       
+       Gtk.TextIter beg, st,en;
+       bool has_wrapped_around;
+       this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
+       
+       if (!this.searchcontext.backward2(beg, out st, out en, out has_wrapped_around)) {
+       
+               this.last_search_end = 0;
+               return;
+       }
+       this.last_search_end = en.get_offset();
+       if (change_focus) {
+               this.view.el.grab_focus();
+       }
+       this.buffer.el.place_cursor(st);
+       this.sourceview.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);
+       var ln = st.get_line();
+       this.highlightNodeAtLine(ln);
+       
+     
     }
     public int search (string in_txt) {
        this.notebook.el.page = 1;