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

src/Builder4/WindowRooView.bjs
src/Builder4/WindowRooView.vala

index 11d4f37..0f5590a 100644 (file)
    "| int search" : [
     "(string txt) {",
     "\tthis.notebook.el.page = 1;",
-    " \tvar s = new Gtk.SourceSearchSettings();",
-    "\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();",
-    "\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);",
+    "\t",
+    " ",
+    "   ",
+    "\tvar s = new Gtk.SourceSearchSettings();",
+    "\ts.case_sensitive = _this.case_sensitive.el.active;",
+    "\ts.regex_enabled = _this.regex.el.active;\t",
+    "\ts.wrap_around = false;",
+    "\t",
+    "\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);",
     "\tthis.searchcontext.set_highlight(true);",
-    "\ts.set_search_text(txt);",
+    "\tvar txt = in_txt;",
+    "\t",
+    "\tif (_this.multiline.el.active) {",
+    "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
+    "\t}",
     "\t",
+    "\ts.set_search_text(txt);",
     "\tGtk.TextIter beg, st,en;",
     "\t ",
-    "\tbuf.get_start_iter(out beg);",
+    "\tthis.buffer.el.get_start_iter(out beg);",
     "\tthis.searchcontext.forward(beg, out st, out en);",
-    "\tthis.last_search_end  = 0;",
+    "\tthis.last_search_end = 0;",
+    "\t",
     "\treturn this.searchcontext.get_occurrences_count();",
     "",
-    "   ",
+    " ",
+    "    ",
+    "",
     "}",
     ""
    ],
index 2b9a974..3585abc 100644 (file)
@@ -162,20 +162,34 @@ public class Xcls_WindowRooView : Object
     }
     public int search (string txt) {
        this.notebook.el.page = 1;
-       var s = new Gtk.SourceSearchSettings();
-       var buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();
-       this.searchcontext = new Gtk.SourceSearchContext(buf,s);
+       
+     
+       
+       var s = new Gtk.SourceSearchSettings();
+       s.case_sensitive = _this.case_sensitive.el.active;
+       s.regex_enabled = _this.regex.el.active;        
+       s.wrap_around = false;
+       
+       this.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);
        this.searchcontext.set_highlight(true);
-       s.set_search_text(txt);
+       var txt = in_txt;
+       
+       if (_this.multiline.el.active) {
+               txt = in_txt.replace("\\n", "\n");
+       }
        
+       s.set_search_text(txt);
        Gtk.TextIter beg, st,en;
         
-       buf.get_start_iter(out beg);
+       this.buffer.el.get_start_iter(out beg);
        this.searchcontext.forward(beg, out st, out en);
-       this.last_search_end  = 0;
+       this.last_search_end = 0;
+       
        return this.searchcontext.get_occurrences_count();
     
-       
+     
+        
+    
     }
     public void createThumb () {