From: Alan Date: Thu, 18 Aug 2022 11:08:51 +0000 (+0800) Subject: Fix #7352 - search improvements X-Git-Tag: release-4.4.2~15 X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=f2dd3ec658128115b59dc3f8d9e1fae66ee816cb;p=roobuilder Fix #7352 - search improvements --- diff --git a/src/Builder4/DialogSaveModule.bjs b/src/Builder4/DialogSaveModule.bjs index df56d0715..b901a5721 100644 --- a/src/Builder4/DialogSaveModule.bjs +++ b/src/Builder4/DialogSaveModule.bjs @@ -55,7 +55,7 @@ ] }, "xtype" : "Dialog", - "| string show" : [ + "| string show" : [ " (Gtk.Window parent, Project.Project project, JsRender.Node data) {", " ", " ", diff --git a/src/Builder4/DialogSaveModule.vala b/src/Builder4/DialogSaveModule.vala index f9abf2a68..f6ba799e8 100644 --- a/src/Builder4/DialogSaveModule.vala +++ b/src/Builder4/DialogSaveModule.vala @@ -15,8 +15,8 @@ public class DialogSaveModule : Object public Xcls_name name; // my vars (def) - public Project.Project project; public JsRender.Node data; + public Project.Project project; // ctor public DialogSaveModule() @@ -32,7 +32,7 @@ public class DialogSaveModule : Object this.el.modal = true; var child_0 = new Xcls_Box2( _this ); child_0.ref(); - this.el.get_content_area().add ( child_0.el ); + this.el.get_content_area().add( child_0.el ); var child_1 = new Xcls_Button5( _this ); child_1.ref(); this.el.add_action_widget ( child_1.el , 0 ); @@ -48,7 +48,7 @@ public class DialogSaveModule : Object } // user defined functions - public string show (Gtk.Window parent, Project.Project project, JsRender.Node data) { + public string show (Gtk.Window parent, Project.Project project, JsRender.Node data) { this.el.set_transient_for(parent); diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs index e556870f2..b871c8692 100644 --- a/src/Builder4/Editor.bjs +++ b/src/Builder4/Editor.bjs @@ -120,7 +120,7 @@ "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", "" ], - "* pack" : "pack_end,true,true", + "bool vexpand" : true, "id" : "RightEditor", "items" : [ { @@ -462,11 +462,18 @@ "key_release_event" : [ " (event) => {", " ", - " if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", - " print(\"SAVE: ctrl-S pressed\");", + " if (event.keyval == Gdk.Key.s && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + " GLib.debug(\"SAVE: ctrl-S pressed\");", " _this.saveContents();", " return false;", " }", + " ", + " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t GLib.debug(\"SAVE: ctrl-g pressed\");", + "\t\t_this.forwardSearch(true);", + "\t return true;", + "\t}", + " ", " // print(event.key.keyval)", " ", " return false;", @@ -518,6 +525,274 @@ } ], "xtype" : "ScrolledWindow" + }, + { + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "bool homogeneous" : false, + "bool vexpand" : false, + "int spacing" : 0, + "items" : [ + { + "$ xns" : "Gtk", + "* init" : [ + "var description = Pango.FontDescription.from_string(\"monospace\");", + "\tdescription.set_size(8000);", + "\t this.el.override_font(description);", + "", + "" + ], + "bool hexpand" : true, + "id" : "search_entry", + "int width_request" : 300, + "listeners" : { + "changed" : [ + "() => {", + "\t/*", + "\tif (this.el.text == \"\") {", + "\t\t_this.search_results.el.hide();", + "\t\treturn;", + "\t}", + "\tvar res = 0;", + "\tswitch(_this.windowstate.state) {", + "\t\tcase WindowState.State.CODEONLY:", + "\t\t///case WindowState.State.CODE:", + "\t\t\t// search the code being edited..", + "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);", + "\t\t\t", + "\t\t\tbreak;", + "\t\tcase WindowState.State.PREVIEW:", + "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", + "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);", + "\t\t\t} else { ", + "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t", + "\t\t\t}", + "\t\t", + "\t\t", + "\t\t\tbreak;", + "\t}", + "\t_this.search_results.el.show();", + "\tif (res > 0) {", + "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t} else {", + "\t\t_this.search_results.el.label = \"No Matches\";", + "\t}", + "\t\t", + "\t*/", + "\t", + "}", + "" + ], + "key_press_event" : [ + "(event) => {", + " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t GLib.debug(\"SAVE: ctrl-g pressed\");", + "\t\t_this.forwardSearch(true);", + "\t return true;", + "\t}", + " ", + " ", + " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {", + "\t\tvar res = _this.search(this.el.text);", + "\t\tif (res > 0) {", + "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t\t} else {", + "\t\t\t_this.search_results.el.label = \"No Matches\";", + "\t\t}", + "\t\t", + "\t return true;", + "", + "\t} ", + " // print(event.key.keyval)", + " ", + " return false;", + "", + "} " + ] + }, + "string placeholder_text" : "Press enter to search", + "xtype" : "SearchEntry", + "| void forwardSearch" : [ + "(bool change_focus) {", + "", + "", + "\t_this.forwardSearch(change_focus);", + "", + "/*", + "", + "\tswitch(_this.windowstate.state) {", + "\t\tcase WindowState.State.CODEONLY:", + "\t\t//case WindowState.State.CODE:", + "\t\t\t// search the code being edited..", + "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);", + "\t\t\t ", + "\t\t\tbreak;", + "\t\tcase WindowState.State.PREVIEW:", + "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", + "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);", + "\t\t\t} else { ", + "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);", + "\t\t\t}", + "\t\t", + "\t\t\tbreak;", + "\t}", + "\t*/", + "\t", + "}", + "" + ] + }, + { + "$ xns" : "Gtk", + "* pack" : "add", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "add", + "Xcls_ValaCompileErrors popup" : "", + "bool always_show_image" : true, + "id" : "search_results", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "set_image", + "bool sensitive" : false, + "utf8 icon_name" : "system-search", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "() => {", + "/*", + " if (this.popup == null) {", + " this.popup = new Xcls_ValaCompileErrors();", + " this.popup.window = _this;", + " }", + " ", + " ", + " this.popup.show(this.notices, this.el);", + " */", + " return true;", + "}" + ] + }, + "string label" : "Matches", + "xtype" : "ImageMenuItem" + } + ], + "xtype" : "MenuBar" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "go-down", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "(event) => {", + "", + "\t_this.forwardSearch(true);", + "\t", + "\treturn true;", + "}", + "" + ] + }, + "string label" : "Next", + "xtype" : "Button" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "go-up", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "(event) => {", + "", + "\t_this.backSearch(true);", + "\t", + "\treturn true;", + "}", + "" + ] + }, + "string label" : "Previous", + "xtype" : "Button" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "emblem-system", + "xtype" : "Image" + }, + { + "$ xns" : "Gtk", + "* prop" : "popup", + "id" : "search_settings", + "items" : [ + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "case_sensitive", + "string label" : "Case Sensitive", + "xtype" : "CheckMenuItem" + }, + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "regex", + "string label" : "Regex", + "xtype" : "CheckMenuItem" + }, + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "multiline", + "string label" : "Multi-line (add \\n)", + "xtype" : "CheckMenuItem" + } + ], + "xtype" : "Menu" + } + ], + "string label" : "Settings", + "xtype" : "MenuButton" + } + ], + "xtype" : "Box" } ], "xtype" : "Box", @@ -558,12 +833,21 @@ "} " ], "| int search" : [ - "(string txt) {", + "(string in_txt) {", "", "\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);", + "\tthis.searchcontext.set_highlight(true);", + "\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 ", @@ -579,6 +863,32 @@ "}", "" ], + "| 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} else {", + "\t\tthis.last_search_end = en.get_offset();", + "\t\tif (change_focus) {", + "\t\t\tthis.view.el.grab_focus();", + "\t\t}", + "\t\tthis.buffer.el.place_cursor(st);", + "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);", + "\t}", + " ", + "}", + "" + ], "| void forwardSearch" : [ "(bool change_focus) {", "", @@ -587,12 +897,16 @@ "\t} ", "\t", "\tGtk.TextIter beg, st,en;", - "\t ", + "\t bool has_wrapped_around;", "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);", - "\tif (!this.searchcontext.forward(beg, out st, out en)) {", + "\tif (!this.searchcontext.forward2(beg, out st, out en, out has_wrapped_around)) {", "\t", - "\t\tthis.last_search_end = 0;", + "\t\tthis.last_search_end = 0; // not sure if this should happen", "\t} else {", + "\t\tif (has_wrapped_around) {", + "\t\t\treturn;", + "\t\t}", + "\t", "\t\tthis.last_search_end = en.get_offset();", "\t\tif (change_focus) {", "\t\t\tthis.view.el.grab_focus();", diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index c923be027..0bcbaaaab 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -17,6 +17,12 @@ public class Editor : Object public Xcls_RightEditor RightEditor; public Xcls_view view; public Xcls_buffer buffer; + public Xcls_search_entry search_entry; + public Xcls_search_results search_results; + public Xcls_search_settings search_settings; + public Xcls_case_sensitive case_sensitive; + public Xcls_regex regex; + public Xcls_multiline multiline; // my vars (def) public Xcls_MainWindow window; @@ -58,7 +64,10 @@ public class Editor : Object this.el.pack_start ( child_0.el , false,true ); var child_1 = new Xcls_RightEditor( _this ); child_1.ref(); - this.el.pack_end ( child_1.el , true,true ); + this.el.add( child_1.el ); + var child_2 = new Xcls_Box12( _this ); + child_2.ref(); + this.el.add( child_2.el ); } // user defined functions @@ -95,6 +104,32 @@ public class Editor : Object return true; + } + public void forwardSearch (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); + if (!this.searchcontext.forward2(beg, out st, out en, out has_wrapped_around)) { + + this.last_search_end = 0; // not sure if this should happen + } else { + if (has_wrapped_around) { + return; + } + + this.last_search_end = en.get_offset(); + if (change_focus) { + 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 void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop) { @@ -115,16 +150,17 @@ public class Editor : Object } } - public void forwardSearch (bool change_focus) { + public void backSearch (bool change_focus) { if (this.searchcontext == null) { return; } Gtk.TextIter beg, st,en; - - this.buffer.el.get_iter_at_offset(out beg, this.last_search_end); - if (!this.searchcontext.forward(beg, out st, out 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; } else { @@ -137,12 +173,21 @@ public class Editor : Object } } - public int search (string txt) { + public int search (string in_txt) { 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); + this.searchcontext.set_highlight(true); + 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; @@ -411,6 +456,7 @@ public class Editor : Object // my vars (dec) // set gobject values + this.el.vexpand = true; var child_0 = new Xcls_view( _this ); child_0.ref(); this.el.add ( child_0.el ); @@ -510,11 +556,18 @@ public class Editor : Object //listeners this.el.key_release_event.connect( (event) => { - if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - print("SAVE: ctrl-S pressed"); + if (event.keyval == Gdk.Key.s && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-S pressed"); _this.saveContents(); return false; } + + if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + // print(event.key.keyval) return false; @@ -829,4 +882,544 @@ public class Editor : Object + public class Xcls_Box12 : Object + { + public Gtk.Box el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Box12(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = false; + var child_0 = new Xcls_search_entry( _this ); + child_0.ref(); + this.el.add( child_0.el ); + var child_1 = new Xcls_MenuBar14( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_Button17( _this ); + child_2.ref(); + this.el.add( child_2.el ); + var child_3 = new Xcls_Button19( _this ); + child_3.ref(); + this.el.add( child_3.el ); + var child_4 = new Xcls_MenuButton21( _this ); + child_4.ref(); + this.el.add( child_4.el ); + } + + // user defined functions + } + public class Xcls_search_entry : Object + { + public Gtk.SearchEntry el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_search_entry(Editor _owner ) + { + _this = _owner; + _this.search_entry = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 300; + this.el.hexpand = true; + this.el.placeholder_text = "Press enter to search"; + + // init method + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + this.el.override_font(description); + + //listeners + this.el.key_press_event.connect( (event) => { + if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + + + if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) { + var res = _this.search(this.el.text); + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + } else { + _this.search_results.el.label = "No Matches"; + } + + return true; + + } + // print(event.key.keyval) + + return false; + + }); + this.el.changed.connect( () => { + /* + if (this.el.text == "") { + _this.search_results.el.hide(); + return; + } + var res = 0; + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + ///case WindowState.State.CODE: + // search the code being edited.. + res = _this.windowstate.code_editor_tab.search(this.el.text); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + res = _this.windowstate.window_gladeview.search(this.el.text); + } else { + res = _this.windowstate.window_rooview.search(this.el.text); + } + + + break; + } + _this.search_results.el.show(); + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + } else { + _this.search_results.el.label = "No Matches"; + } + + */ + + }); + } + + // user defined functions + public void forwardSearch (bool change_focus) { + + + _this.forwardSearch(change_focus); + + /* + + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + //case WindowState.State.CODE: + // search the code being edited.. + _this.windowstate.code_editor_tab.forwardSearch(change_focus); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + _this.windowstate.window_gladeview.forwardSearch(change_focus); + } else { + _this.windowstate.window_rooview.forwardSearch(change_focus); + } + + break; + } + */ + + } + } + + public class Xcls_MenuBar14 : Object + { + public Gtk.MenuBar el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_MenuBar14(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.MenuBar(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_search_results( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_search_results : Object + { + public Gtk.ImageMenuItem el; + private Editor _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + + // ctor + public Xcls_search_results(Editor _owner ) + { + _this = _owner; + _this.search_results = this; + this.el = new Gtk.ImageMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Matches"; + var child_0 = new Xcls_Image16( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.button_press_event.connect( () => { + /* + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + } + + + this.popup.show(this.notices, this.el); + */ + return true; + }); + } + + // user defined functions + } + public class Xcls_Image16 : Object + { + public Gtk.Image el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Image16(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "system-search"; + this.el.sensitive = false; + } + + // user defined functions + } + + + + public class Xcls_Button17 : Object + { + public Gtk.Button el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Button17(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Next"; + var child_0 = new Xcls_Image18( _this ); + child_0.ref(); + this.el.image = child_0.el; + + //listeners + this.el.button_press_event.connect( (event) => { + + _this.forwardSearch(true); + + return true; + }); + } + + // user defined functions + } + public class Xcls_Image18 : Object + { + public Gtk.Image el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Image18(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-down"; + } + + // user defined functions + } + + + public class Xcls_Button19 : Object + { + public Gtk.Button el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Button19(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Previous"; + var child_0 = new Xcls_Image20( _this ); + child_0.ref(); + this.el.image = child_0.el; + + //listeners + this.el.button_press_event.connect( (event) => { + + _this.backSearch(true); + + return true; + }); + } + + // user defined functions + } + public class Xcls_Image20 : Object + { + public Gtk.Image el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Image20(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-up"; + } + + // user defined functions + } + + + public class Xcls_MenuButton21 : Object + { + public Gtk.MenuButton el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_MenuButton21(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.MenuButton(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Settings"; + var child_0 = new Xcls_Image22( _this ); + child_0.ref(); + this.el.image = child_0.el; + var child_1 = new Xcls_search_settings( _this ); + child_1.ref(); + this.el.popup = child_1.el; + } + + // user defined functions + } + public class Xcls_Image22 : Object + { + public Gtk.Image el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Image22(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "emblem-system"; + } + + // user defined functions + } + + public class Xcls_search_settings : Object + { + public Gtk.Menu el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_search_settings(Editor _owner ) + { + _this = _owner; + _this.search_settings = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_case_sensitive( _this ); + child_0.ref(); + this.el.append( child_0.el ); + var child_1 = new Xcls_regex( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_multiline( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_case_sensitive : Object + { + public Gtk.CheckMenuItem el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_case_sensitive(Editor _owner ) + { + _this = _owner; + _this.case_sensitive = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Case Sensitive"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + public class Xcls_regex : Object + { + public Gtk.CheckMenuItem el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_regex(Editor _owner ) + { + _this = _owner; + _this.regex = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Regex"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + public class Xcls_multiline : Object + { + public Gtk.CheckMenuItem el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_multiline(Editor _owner ) + { + _this = _owner; + _this.multiline = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Multi-line (add \\n)"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + + + } diff --git a/src/Builder4/GtkView.bjs b/src/Builder4/GtkView.bjs index 1b1854086..251f311b8 100644 --- a/src/Builder4/GtkView.bjs +++ b/src/Builder4/GtkView.bjs @@ -59,343 +59,650 @@ { "$ xns" : "Gtk", "* pack" : "append_page,_this.label_code.el", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "int spacing" : 0, "items" : [ { "$ xns" : "Gtk", - "* init" : [ - "{", - " ", - " var description = Pango.FontDescription.from_string(\"monospace\");", - " description.set_size(8000);", - " this.el.override_font(description);", - "", - " this.loading = true;", - " var buf = this.el.get_buffer();", - " buf.notify.connect((ps) => {", - " if (this.loading) {", - " return;", - " }", - " if (ps.name != \"cursor-position\") {", - " return;", - " }", - " print(\"cursor changed : %d\\n\", buf.cursor_position);", - " Gtk.TextIter cpos;", - " buf.get_iter_at_offset(out cpos, buf.cursor_position);", - " ", - " var ln = cpos.get_line();", - " ", - " var node = _this.file.lineToNode(ln);", - " ", - " if (node == null) {", - " print(\"can not find node\\n\");", - " return;", - " }", - " var ltree = _this.main_window.windowstate.left_tree;", - " var tp = ltree.model.treePathFromNode(node);", - " print(\"got tree path %s\\n\", tp);", - " if (tp != \"\") {", - "\t this.allow_node_scroll = false; ", - "\t print(\"changing cursor on tree..\\n\");", - " ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);", - " // scrolling is disabled... as node selection calls scroll 10ms after it changes.", - " GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {", - "\t this.allow_node_scroll = true;", - "\t return false;", - " });", - " }", - " ", - " // highlight the node..", - " ", - " });", - " ", - " ", - " ", - " var attrs = new Gtk.SourceMarkAttributes();", - " var pink = Gdk.RGBA();", - " pink.parse ( \"pink\");", - " attrs.set_background ( pink);", - " attrs.set_icon_name ( \"process-stop\"); ", - " attrs.query_tooltip_text.connect(( mark) => {", - " //print(\"tooltip query? %s\\n\", mark.name);", - " return mark.name;", - " });", - " ", - " this.el.set_mark_attributes (\"ERR\", attrs, 1);", - " ", - " var wattrs = new Gtk.SourceMarkAttributes();", - " var blue = Gdk.RGBA();", - " blue.parse ( \"#ABF4EB\");", - " wattrs.set_background ( blue);", - " wattrs.set_icon_name ( \"process-stop\"); ", - " wattrs.query_tooltip_text.connect(( mark) => {", - " //print(\"tooltip query? %s\\n\", mark.name);", - " return mark.name;", - " });", - " ", - " this.el.set_mark_attributes (\"WARN\", wattrs, 1);", - " ", - " ", - " ", - " var dattrs = new Gtk.SourceMarkAttributes();", - " var purple = Gdk.RGBA();", - " purple.parse ( \"#EEA9FF\");", - " dattrs.set_background ( purple);", - " dattrs.set_icon_name ( \"process-stop\"); ", - " dattrs.query_tooltip_text.connect(( mark) => {", - " //print(\"tooltip query? %s\\n\", mark.name);", - " return mark.name;", - " });", - " ", - " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);", - " ", - " ", - " var gattrs = new Gtk.SourceMarkAttributes();", - " var grey = Gdk.RGBA();", - " grey.parse ( \"#ccc\");", - " gattrs.set_background ( grey);", - " ", - " ", - " this.el.set_mark_attributes (\"grey\", gattrs, 1);", - " ", - " ", - " ", - " ", - " ", - " ", - "}", - " " - ], - "* pack" : "add", - "bool allow_node_scroll" : true, - "bool loading" : true, - "gboolean editable" : false, - "gboolean show_line_marks" : true, - "gboolean show_line_numbers" : true, - "id" : "sourceview", - "xtype" : "SourceView", - "| string toString" : [ - "() {", - " Gtk.TextIter s;", - " Gtk.TextIter e;", - " this.el.get_buffer().get_start_iter(out s);", - " this.el.get_buffer().get_end_iter(out e);", - " var ret = this.el.get_buffer().get_text(s,e,true);", - " //print(\"TO STRING? \" + ret);", - " return ret;", - "}", - "" - ], - "| void highlightErrorsJson" : [ - " (string type, Json.Object obj) {", - " Gtk.TextIter start;", - " Gtk.TextIter end; ", - " ", - " var buf = this.el.get_buffer();", - " var sbuf = (Gtk.SourceBuffer)buf;", - " buf.get_bounds (out start, out end);", - " ", - " sbuf.remove_source_marks (start, end, type);", - " ", - " ", - " // we should highlight other types of errors..", - " ", - " if (!obj.has_member(type)) {", - " print(\"Return has no errors\\n\");", - " return ;", - " }", - " var err = obj.get_object_member(type);", - " ", - " if (_this.file == null) { ", - " return; // just in case the file has not loaded yet?", - " }", - " ", - "", - " var valafn = \"\";", - " try { ", - " var regex = new Regex(\"\\\\.bjs$\");", - " ", - " ", - " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");", - " } catch (GLib.RegexError e) {", - " return;", - " } ", - "", - " if (!err.has_member(valafn)) {", - " print(\"File path has no errors\\n\");", - " return ;", - " }", - " var lines = err.get_object_member(valafn);", - " ", - " ", - " ", - " var tlines = buf.get_line_count () +1;", - " ", - " lines.foreach_member((obj, line, node) => {", - " ", - " Gtk.TextIter iter;", - " // print(\"get inter\\n\");", - " var eline = int.parse(line) -1 ;", - " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);", - " ", - " ", - " if (eline > tlines || eline < 0) {", - " return;", - " }", - " sbuf.get_iter_at_line( out iter, eline);", - " //print(\"mark line\\n\");", - " var msg = type + \" on line: %d - %s\".printf(eline+1, valafn);", - " var ar = lines.get_array_member(line);", - " for (var i = 0 ; i < ar.get_length(); i++) {", - "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";", - "\t\t msg += ar.get_string_element(i);", - "\t }", - " ", - " ", - " sbuf.create_source_mark(msg, type, iter);", - " } );", - " return ;", - " ", - " ", - "", - "", - "}" + "bool vexpand" : true, + "items" : [ + { + "# JsRender.Node? node_selected" : "", + "# string prop_selected" : "\"\"", + "$ xns" : "Gtk", + "* init" : [ + "{", + " ", + " var description = Pango.FontDescription.from_string(\"monospace\");", + " description.set_size(8000);", + " this.el.override_font(description);", + "", + " this.loading = true;", + " var buf = this.el.get_buffer();", + " buf.notify.connect((ps) => {", + " if (this.loading) {", + " return;", + " }", + " if (ps.name != \"cursor-position\") {", + " return;", + " }", + " print(\"cursor changed : %d\\n\", buf.cursor_position);", + " Gtk.TextIter cpos;", + " buf.get_iter_at_offset(out cpos, buf.cursor_position);", + " ", + " var ln = cpos.get_line();", + " ", + " var node = _this.file.lineToNode(ln);", + " ", + " if (node == null) {", + " print(\"can not find node\\n\");", + " return;", + " }", + " var ltree = _this.main_window.windowstate.left_tree;", + " var tp = ltree.model.treePathFromNode(node);", + " print(\"got tree path %s\\n\", tp);", + " if (tp != \"\") {", + "\t this.allow_node_scroll = false; ", + "\t print(\"changing cursor on tree..\\n\");", + " ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);", + " // scrolling is disabled... as node selection calls scroll 10ms after it changes.", + " GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {", + "\t this.allow_node_scroll = true;", + "\t return false;", + " });", + " }", + " ", + " // highlight the node..", + " ", + " });", + " ", + " ", + " ", + " var attrs = new Gtk.SourceMarkAttributes();", + " var pink = Gdk.RGBA();", + " pink.parse ( \"pink\");", + " attrs.set_background ( pink);", + " attrs.set_icon_name ( \"process-stop\"); ", + " attrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"ERR\", attrs, 1);", + " ", + " var wattrs = new Gtk.SourceMarkAttributes();", + " var blue = Gdk.RGBA();", + " blue.parse ( \"#ABF4EB\");", + " wattrs.set_background ( blue);", + " wattrs.set_icon_name ( \"process-stop\"); ", + " wattrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"WARN\", wattrs, 1);", + " ", + " ", + " ", + " var dattrs = new Gtk.SourceMarkAttributes();", + " var purple = Gdk.RGBA();", + " purple.parse ( \"#EEA9FF\");", + " dattrs.set_background ( purple);", + " dattrs.set_icon_name ( \"process-stop\"); ", + " dattrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);", + " ", + " ", + " var gattrs = new Gtk.SourceMarkAttributes();", + " var grey = Gdk.RGBA();", + " grey.parse ( \"#ccc\");", + " gattrs.set_background ( grey);", + " ", + " ", + " this.el.set_mark_attributes (\"grey\", gattrs, 1);", + " ", + " ", + " ", + " ", + " ", + " ", + "}", + " " + ], + "* pack" : "add", + "bool allow_node_scroll" : true, + "bool loading" : true, + "gboolean editable" : false, + "gboolean show_line_marks" : true, + "gboolean show_line_numbers" : true, + "id" : "sourceview", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "set_buffer", + "bool dirty" : false, + "id" : "buffer", + "int error_line" : "-1", + "xtype" : "SourceBuffer" + } + ], + "listeners" : { + "key_press_event" : [ + "(event) => {", + "\t", + "\t if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t GLib.debug(\"SAVE: ctrl-g pressed\");", + "\t\t_this.forwardSearch(true);", + "\t return true;", + "\t}", + " ", + "\t ", + "\treturn false;", + "}\t ", + "" + ] + }, + "xtype" : "SourceView", + "| string toString" : [ + "() {", + " Gtk.TextIter s;", + " Gtk.TextIter e;", + " this.el.get_buffer().get_start_iter(out s);", + " this.el.get_buffer().get_end_iter(out e);", + " var ret = this.el.get_buffer().get_text(s,e,true);", + " //print(\"TO STRING? \" + ret);", + " return ret;", + "}", + "" + ], + "| void highlightErrorsJson" : [ + " (string type, Json.Object obj) {", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " ", + " var buf = this.el.get_buffer();", + " var sbuf = (Gtk.SourceBuffer)buf;", + " buf.get_bounds (out start, out end);", + " ", + " sbuf.remove_source_marks (start, end, type);", + " ", + " ", + " // we should highlight other types of errors..", + " ", + " if (!obj.has_member(type)) {", + " print(\"Return has no errors\\n\");", + " return ;", + " }", + " var err = obj.get_object_member(type);", + " ", + " if (_this.file == null) { ", + " return; // just in case the file has not loaded yet?", + " }", + " ", + "", + " var valafn = \"\";", + " try { ", + " var regex = new Regex(\"\\\\.bjs$\");", + " ", + " ", + " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");", + " } catch (GLib.RegexError e) {", + " return;", + " } ", + "", + " if (!err.has_member(valafn)) {", + " print(\"File path has no errors\\n\");", + " return ;", + " }", + " var lines = err.get_object_member(valafn);", + " ", + " ", + " ", + " var tlines = buf.get_line_count () +1;", + " ", + " lines.foreach_member((obj, line, node) => {", + " ", + " Gtk.TextIter iter;", + " // print(\"get inter\\n\");", + " var eline = int.parse(line) -1 ;", + " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);", + " ", + " ", + " if (eline > tlines || eline < 0) {", + " return;", + " }", + " sbuf.get_iter_at_line( out iter, eline);", + " //print(\"mark line\\n\");", + " var msg = type + \" on line: %d - %s\".printf(eline+1, valafn);", + " var ar = lines.get_array_member(line);", + " for (var i = 0 ; i < ar.get_length(); i++) {", + "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";", + "\t\t msg += ar.get_string_element(i);", + "\t }", + " ", + " ", + " sbuf.create_source_mark(msg, type, iter);", + " } );", + " return ;", + " ", + " ", + "", + "", + "}" + ], + "| void loadFile" : [ + "( ) {", + " this.loading = true;", + " var buf = this.el.get_buffer();", + " buf.set_text(\"\",0);", + " var sbuf = (Gtk.SourceBuffer) buf;", + "", + " ", + "", + " if (_this.file == null || _this.file.xtype != \"Gtk\") {", + " print(\"xtype != Gtk\");", + " this.loading = false;", + " return;", + " }", + " ", + " var valafn = \"\";", + " try { ", + " var regex = new Regex(\"\\\\.bjs$\");", + " ", + " ", + " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");", + " } catch (GLib.RegexError e) {", + " this.loading = false;", + " return;", + " } ", + " ", + "", + " if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {", + " print(\"File path has no errors\\n\");", + " this.loading = false;", + " return ;", + " }", + " ", + " string str;", + " try {", + " ", + " GLib.FileUtils.get_contents (valafn, out str);", + " } catch (Error e) {", + " this.loading = false;", + " return ;", + " }", + "", + "// print(\"setting str %d\\n\", str.length);", + " buf.set_text(str, str.length);", + " var lm = Gtk.SourceLanguageManager.get_default();", + " ", + " //?? is javascript going to work as js?", + " ", + " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));", + " ", + " ", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " ", + " sbuf.get_bounds (out start, out end);", + " sbuf.remove_source_marks (start, end, null); // remove all marks..", + " ", + " ", + " if (_this.main_window.windowstate.last_compile_result != null) {", + " var obj = _this.main_window.windowstate.last_compile_result;", + " this.highlightErrorsJson(\"ERR\", obj);", + " this.highlightErrorsJson(\"WARN\", obj);", + " this.highlightErrorsJson(\"DEPR\", obj);\t\t\t", + " }", + " //while (Gtk.events_pending()) {", + " // Gtk.main_iteration();", + " // }", + " ", + " this.loading = false; ", + "}", + "" + ], + "| void nodeSelected" : [ + "(JsRender.Node? sel, bool scroll) {", + " ", + " ", + " ", + " // this is connected in widnowstate", + " print(\"Roo-view - node selected\\n\");", + " var buf = this.el.get_buffer();", + " ", + " var sbuf = (Gtk.SourceBuffer) buf;", + "", + " ", + " while(Gtk.events_pending()) {", + " Gtk.main_iteration();", + " }", + " ", + " ", + " // clear all the marks..", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " ", + " sbuf.get_bounds (out start, out end);", + " sbuf.remove_source_marks (start, end, \"grey\");", + " ", + " this.node_selected = sel;", + " if (sel == null) {", + " // no highlighting..", + " return;", + " }", + " Gtk.TextIter iter; ", + " sbuf.get_iter_at_line(out iter, sel.line_start);", + " ", + " ", + " Gtk.TextIter cur_iter;", + " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);", + " ", + " //var cur_line = cur_iter.get_line();", + " //if (cur_line > sel.line_start && cur_line < sel.line_end) {", + " ", + " //} else {", + " if (this.allow_node_scroll) {", + "\t\t ", + " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", + "\t}", + " ", + " ", + " ", + " for (var i = 0; i < buf.get_line_count();i++) {", + " if (i < sel.line_start || i > sel.line_end) {", + " ", + " sbuf.get_iter_at_line(out iter, i);", + " sbuf.create_source_mark(null, \"grey\", iter);", + " ", + " }", + " ", + " }", + " ", + "", + "}", + "" + ] + } ], - "| void loadFile" : [ - "( ) {", - " this.loading = true;", - " var buf = this.el.get_buffer();", - " buf.set_text(\"\",0);", - " var sbuf = (Gtk.SourceBuffer) buf;", - "", - " ", - "", - " if (_this.file == null || _this.file.xtype != \"Gtk\") {", - " print(\"xtype != Gtk\");", - " this.loading = false;", - " return;", - " }", - " ", - " var valafn = \"\";", - " try { ", - " var regex = new Regex(\"\\\\.bjs$\");", - " ", - " ", - " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");", - " } catch (GLib.RegexError e) {", - " this.loading = false;", - " return;", - " } ", - " ", - "", - " if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {", - " print(\"File path has no errors\\n\");", - " this.loading = false;", - " return ;", - " }", - " ", - " string str;", - " try {", - " ", - " GLib.FileUtils.get_contents (valafn, out str);", - " } catch (Error e) {", - " this.loading = false;", - " return ;", - " }", - "", - "// print(\"setting str %d\\n\", str.length);", - " buf.set_text(str, str.length);", - " var lm = Gtk.SourceLanguageManager.get_default();", - " ", - " //?? is javascript going to work as js?", - " ", - " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));", - " ", - " ", - " Gtk.TextIter start;", - " Gtk.TextIter end; ", - " ", - " sbuf.get_bounds (out start, out end);", - " sbuf.remove_source_marks (start, end, null); // remove all marks..", - " ", - " ", - " if (_this.main_window.windowstate.last_compile_result != null) {", - " var obj = _this.main_window.windowstate.last_compile_result;", - " this.highlightErrorsJson(\"ERR\", obj);", - " this.highlightErrorsJson(\"WARN\", obj);", - " this.highlightErrorsJson(\"DEPR\", obj);\t\t\t", - " }", - " //while (Gtk.events_pending()) {", - " // Gtk.main_iteration();", - " // }", - " ", - " this.loading = false; ", - "}", - "" + "xtype" : "ScrolledWindow" + }, + { + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "bool homogeneous" : false, + "bool vexpand" : false, + "int spacing" : 0, + "items" : [ + { + "$ xns" : "Gtk", + "* init" : [ + "var description = Pango.FontDescription.from_string(\"monospace\");", + "\tdescription.set_size(8000);", + "\t this.el.override_font(description);", + "", + "" + ], + "bool hexpand" : true, + "id" : "search_entry", + "int width_request" : 300, + "listeners" : { + "changed" : [ + "() => {", + "\t/*", + "\tif (this.el.text == \"\") {", + "\t\t_this.search_results.el.hide();", + "\t\treturn;", + "\t}", + "\tvar res = 0;", + "\tswitch(_this.windowstate.state) {", + "\t\tcase WindowState.State.CODEONLY:", + "\t\t///case WindowState.State.CODE:", + "\t\t\t// search the code being edited..", + "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);", + "\t\t\t", + "\t\t\tbreak;", + "\t\tcase WindowState.State.PREVIEW:", + "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", + "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);", + "\t\t\t} else { ", + "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t", + "\t\t\t}", + "\t\t", + "\t\t", + "\t\t\tbreak;", + "\t}", + "\t_this.search_results.el.show();", + "\tif (res > 0) {", + "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t} else {", + "\t\t_this.search_results.el.label = \"No Matches\";", + "\t}", + "\t\t", + "\t*/", + "\t", + "}", + "" + ], + "key_press_event" : [ + "(event) => {", + " ", + " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t GLib.debug(\"SAVE: ctrl-g pressed\");", + "\t\t_this.forwardSearch(true);", + "\t return true;", + "\t}", + " ", + " ", + " ", + " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {", + "\t\tvar res = _this.search(this.el.text);", + "\t\tif (res > 0) {", + "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t\t} else {", + "\t\t\t_this.search_results.el.label = \"No Matches\";", + "\t\t}", + "\t\t", + "\t return true;", + "", + "\t} ", + " // print(event.key.keyval)", + " ", + " return false;", + "", + "} " + ] + }, + "string placeholder_text" : "Press enter to search", + "xtype" : "SearchEntry", + "| void forwardSearch" : [ + "(bool change_focus) {", + "", + "", + "\t_this.forwardSearch(change_focus);", + "", + "/*", + "", + "\tswitch(_this.windowstate.state) {", + "\t\tcase WindowState.State.CODEONLY:", + "\t\t//case WindowState.State.CODE:", + "\t\t\t// search the code being edited..", + "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);", + "\t\t\t ", + "\t\t\tbreak;", + "\t\tcase WindowState.State.PREVIEW:", + "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", + "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);", + "\t\t\t} else { ", + "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);", + "\t\t\t}", + "\t\t", + "\t\t\tbreak;", + "\t}", + "\t*/", + "\t", + "}", + "" + ] + }, + { + "$ xns" : "Gtk", + "* pack" : "add", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "add", + "Xcls_ValaCompileErrors popup" : "", + "bool always_show_image" : true, + "id" : "search_results", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "set_image", + "bool sensitive" : false, + "utf8 icon_name" : "system-search", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "() => {", + "/*", + " if (this.popup == null) {", + " this.popup = new Xcls_ValaCompileErrors();", + " this.popup.window = _this;", + " }", + " ", + " ", + " this.popup.show(this.notices, this.el);", + " */", + " return true;", + "}" + ] + }, + "string label" : "Matches", + "xtype" : "ImageMenuItem" + } + ], + "xtype" : "MenuBar" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "go-down", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "(event) => {", + "", + "\t_this.forwardSearch(true);", + "\t", + "\treturn true;", + "}", + "" + ] + }, + "string label" : "Next", + "xtype" : "Button" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "go-up", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "(event) => {", + "", + "\t_this.backSearch(true);", + "\t", + "\treturn true;", + "}", + "" + ] + }, + "string label" : "Previous", + "xtype" : "Button" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "emblem-system", + "xtype" : "Image" + }, + { + "$ xns" : "Gtk", + "* prop" : "popup", + "id" : "search_settings", + "items" : [ + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "case_sensitive", + "string label" : "Case Sensitive", + "xtype" : "CheckMenuItem" + }, + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "regex", + "string label" : "Regex", + "xtype" : "CheckMenuItem" + }, + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "multiline", + "string label" : "Multi-line (add \\n)", + "xtype" : "CheckMenuItem" + } + ], + "xtype" : "Menu" + } + ], + "string label" : "Settings", + "xtype" : "MenuButton" + } ], - "| void nodeSelected" : [ - "(JsRender.Node? sel) {", - " ", - " ", - " ", - " // this is connected in widnowstate", - " print(\"Roo-view - node selected\\n\");", - " var buf = this.el.get_buffer();", - " ", - " var sbuf = (Gtk.SourceBuffer) buf;", - "", - " ", - " while(Gtk.events_pending()) {", - " Gtk.main_iteration();", - " }", - " ", - " ", - " // clear all the marks..", - " Gtk.TextIter start;", - " Gtk.TextIter end; ", - " ", - " sbuf.get_bounds (out start, out end);", - " sbuf.remove_source_marks (start, end, \"grey\");", - " ", - " ", - " if (sel == null) {", - " // no highlighting..", - " return;", - " }", - " Gtk.TextIter iter; ", - " sbuf.get_iter_at_line(out iter, sel.line_start);", - " ", - " ", - " Gtk.TextIter cur_iter;", - " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);", - " ", - " //var cur_line = cur_iter.get_line();", - " //if (cur_line > sel.line_start && cur_line < sel.line_end) {", - " ", - " //} else {", - " if (this.allow_node_scroll) {", - "\t\t ", - " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", - "\t}", - " ", - " ", - " ", - " for (var i = 0; i < buf.get_line_count();i++) {", - " if (i < sel.line_start || i > sel.line_end) {", - " ", - " sbuf.get_iter_at_line(out iter, i);", - " sbuf.create_source_mark(null, \"grey\", iter);", - " ", - " }", - " ", - " }", - " ", - "", - "}", - "" - ] + "xtype" : "Box" } ], - "xtype" : "ScrolledWindow" + "xtype" : "Box" } ], "xtype" : "Notebook" @@ -413,22 +720,65 @@ }, "xtype" : "Box", "| int search" : [ - "(string txt) {", + "(string in_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();", "", - " ", + " ", + " ", + "", + "}", + "" + ], + "| 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.sourceview.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", + " ", "}", "" ], @@ -490,20 +840,98 @@ "\tbuf.get_iter_at_offset(out beg, this.last_search_end);", "\tif (!this.searchcontext.forward(beg, out st, out en)) {", "\t\tthis.last_search_end = 0;", - "\t} else { ", - "\t\tthis.last_search_end = en.get_offset();", - "\t\tif (change_focus) {", - "\t\t\tthis.sourceview.el.grab_focus();\t", + "\t\treturn;", + "\t}", + "\tthis.last_search_end = en.get_offset();", + "\tif (change_focus) {", + "\t\tthis.sourceview.el.grab_focus();", + "\t}", + "\tbuf.place_cursor(st);", + "\t", + " ", + "\t ", + "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);", + "\t", + "\t", + "\tvar ln = st.get_line();", + "\t", + "\tthis.highlightNodeAtLine(ln);", + "}\t", + " " + ], + "| void highlightNodeAtLine" : [ + "(int ln) {", + "", + "", + "\t ", + "\t// highlight node...", + "\t", + "\t\t", + " var node = _this.file.lineToNode(ln+1);", + " ", + " if (node == null) {", + " //print(\"can not find node\\n\");", + " return;", + " }", + " var prop = node.lineToProp(ln+1);", + " print(\"prop : %s\", prop == null ? \"???\" : prop);", + " ", + " ", + " // ---------- this selects the tree's node...", + " ", + " var ltree = _this.main_window.windowstate.left_tree;", + " var tp = ltree.model.treePathFromNode(node);", + " print(\"got tree path %s\\n\", tp);", + " if (tp == \"\") {", + "\t\treturn;", + "\t}", + " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..", + "\t ", + " ", + " //print(\"changing cursor on tree..\\n\");", + " ", + "", + " ", + " // let's try allowing editing on the methods.", + " // a little klunky at present..", + "\t_this.sourceview.prop_selected = \"\";", + " if (prop != null) {", + "\t\t//see if we can find it..", + "\t\tvar kv = prop.split(\":\");", + "\t\tif (kv[0] == \"p\") {", + "\t\t", + " \t\t//var k = prop.get_key(kv[1]);", + " \t\t// fixme -- need to determine if it's an editable property...", + " \t\t_this.sourceview.prop_selected = prop;", + " \t\t", + "\t\t} else if (kv[0] == \"l\") {", + "\t\t\t _this.sourceview.prop_selected = prop;", + "\t\t\t", "\t\t}", - "\t\tbuf.place_cursor(st);", - "\t\tvar ln = st.get_line();", - "\t\tbuf.get_iter_at_line(out stl,ln);", + " }", + " ltree.view.setCursor(tp, \"editor\");", + " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ", + " _this.sourceview.nodeSelected(node,false);", + " ", + " // scrolling is disabled... as node selection calls scroll 10ms after it changes.", + " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {", + "\t // this.allow_node_scroll = true;", + "\t // return false;", + " // });", + " // }", + "\t\t", + "\t\t", + "\t\t", + "\t\t", + "\t\t", + "\t\t", + "\t\t", + "\t\t", + "\t\t", "\t\t ", - "\t\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);", - "\t}", "", "}", - "" + " " ], "| void loadFile" : [ "(JsRender.JsRender file) ", diff --git a/src/Builder4/GtkView.vala b/src/Builder4/GtkView.vala index 446e6fbd5..621f69025 100644 --- a/src/Builder4/GtkView.vala +++ b/src/Builder4/GtkView.vala @@ -18,15 +18,22 @@ public class Xcls_GtkView : Object public Xcls_view_layout view_layout; public Xcls_container container; public Xcls_sourceview sourceview; + public Xcls_buffer buffer; + public Xcls_search_entry search_entry; + public Xcls_search_results search_results; + public Xcls_search_settings search_settings; + public Xcls_case_sensitive case_sensitive; + public Xcls_regex regex; + public Xcls_multiline multiline; // my vars (def) public Gtk.Widget lastObj; + public Xcls_MainWindow main_window; + public Gtk.SourceSearchContext searchcontext; public int last_search_end; public int width; - public Gtk.SourceSearchContext searchcontext; public JsRender.JsRender file; public int height; - public Xcls_MainWindow main_window; // ctor public Xcls_GtkView() @@ -57,86 +64,6 @@ public class Xcls_GtkView : Object } // user defined functions - public void scroll_to_line (int line) { - this.notebook.el.page = 1;// code preview... - - GLib.Timeout.add(500, () => { - - - - - var buf = this.sourceview.el.get_buffer(); - - var sbuf = (Gtk.SourceBuffer) buf; - - - Gtk.TextIter iter; - sbuf.get_iter_at_line(out iter, line); - this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); - return false; - }); - - - } - 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); - this.searchcontext.set_highlight(true); - s.set_search_text(txt); - - Gtk.TextIter beg, st,en; - - buf.get_start_iter(out beg); - this.searchcontext.forward(beg, out st, out en); - this.last_search_end = 0; - return this.searchcontext.get_occurrences_count(); - - - } - public void createThumb () { - - - if (this.file == null) { - return; - } - // only screenshot the gtk preview.. - if (this.notebook.el.page > 0 ) { - return; - } - - - var filename = this.file.getIconFileName(false); - - var win = this.el.get_parent_window(); - var width = win.get_width(); - var height = win.get_height(); - try { - Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position? - screenshot.save(filename,"png"); - } catch (Error e) { - - } - - - return; - - - - - - // should we hold until it's printed... - - - - - - - - - - } public void loadFile (JsRender.JsRender file) { this.file = null; @@ -191,6 +118,77 @@ public class Xcls_GtkView : Object + } + public void highlightNodeAtLine (int ln) { + + + + // highlight node... + + + var node = _this.file.lineToNode(ln+1); + + if (node == null) { + //print("can not find node\n"); + return; + } + var prop = node.lineToProp(ln+1); + print("prop : %s", prop == null ? "???" : prop); + + + // ---------- this selects the tree's node... + + var ltree = _this.main_window.windowstate.left_tree; + var tp = ltree.model.treePathFromNode(node); + print("got tree path %s\n", tp); + if (tp == "") { + return; + } + //_this.sourceview.allow_node_scroll = false; /// block node scrolling.. + + + //print("changing cursor on tree..\n"); + + + + // let's try allowing editing on the methods. + // a little klunky at present.. + _this.sourceview.prop_selected = ""; + if (prop != null) { + //see if we can find it.. + var kv = prop.split(":"); + if (kv[0] == "p") { + + //var k = prop.get_key(kv[1]); + // fixme -- need to determine if it's an editable property... + _this.sourceview.prop_selected = prop; + + } else if (kv[0] == "l") { + _this.sourceview.prop_selected = prop; + + } + } + ltree.view.setCursor(tp, "editor"); + // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); + _this.sourceview.nodeSelected(node,false); + + // scrolling is disabled... as node selection calls scroll 10ms after it changes. + // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { + // this.allow_node_scroll = true; + // return false; + // }); + // } + + + + + + + + + + + } public void forwardSearch (bool change_focus) { @@ -204,18 +202,142 @@ public class Xcls_GtkView : Object buf.get_iter_at_offset(out beg, this.last_search_end); if (!this.searchcontext.forward(beg, out st, out en)) { this.last_search_end = 0; - } else { - this.last_search_end = en.get_offset(); - if (change_focus) { - this.sourceview.el.grab_focus(); - } - buf.place_cursor(st); - var ln = st.get_line(); - buf.get_iter_at_line(out stl,ln); - - this.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f); + return; + } + this.last_search_end = en.get_offset(); + if (change_focus) { + this.sourceview.el.grab_focus(); + } + buf.place_cursor(st); + + + + this.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f); + + + 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.sourceview.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; + + + + 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); + 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; + + 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(); + + + + + } + public void createThumb () { + + + if (this.file == null) { + return; + } + // only screenshot the gtk preview.. + if (this.notebook.el.page > 0 ) { + return; + } + + + var filename = this.file.getIconFileName(false); + + var win = this.el.get_parent_window(); + var width = win.get_width(); + var height = win.get_height(); + try { + Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position? + screenshot.save(filename,"png"); + } catch (Error e) { + + } + + + return; + + + + + + // should we hold until it's printed... + + + + + + + + + + } + public void scroll_to_line (int line) { + this.notebook.el.page = 1;// code preview... + + GLib.Timeout.add(500, () => { + + + + + var buf = this.sourceview.el.get_buffer(); + + var sbuf = (Gtk.SourceBuffer) buf; + + + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, line); + this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + return false; + }); + } public class Xcls_notebook : Object { @@ -242,7 +364,7 @@ public class Xcls_GtkView : Object var child_2 = new Xcls_ScrolledWindow5( _this ); child_2.ref(); this.el.append_page ( child_2.el , _this.label_preview.el ); - var child_3 = new Xcls_ScrolledWindow8( _this ); + var child_3 = new Xcls_Box8( _this ); child_3.ref(); this.el.append_page ( child_3.el , _this.label_code.el ); } @@ -369,7 +491,34 @@ public class Xcls_GtkView : Object - public class Xcls_ScrolledWindow8 : Object + public class Xcls_Box8 : Object + { + public Gtk.Box el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Box8(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_ScrolledWindow9( _this ); + child_0.ref(); + this.el.add( child_0.el ); + var child_1 = new Xcls_Box12( _this ); + child_1.ref(); + this.el.add( child_1.el ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow9 : Object { public Gtk.ScrolledWindow el; private Xcls_GtkView _this; @@ -378,7 +527,7 @@ public class Xcls_GtkView : Object // my vars (def) // ctor - public Xcls_ScrolledWindow8(Xcls_GtkView _owner ) + public Xcls_ScrolledWindow9(Xcls_GtkView _owner ) { _this = _owner; this.el = new Gtk.ScrolledWindow( null, null ); @@ -386,6 +535,7 @@ public class Xcls_GtkView : Object // my vars (dec) // set gobject values + this.el.vexpand = true; var child_0 = new Xcls_sourceview( _this ); child_0.ref(); this.el.add ( child_0.el ); @@ -401,7 +551,9 @@ public class Xcls_GtkView : Object // my vars (def) public bool loading; + public string prop_selected; public bool allow_node_scroll; + public JsRender.Node? node_selected; // ctor public Xcls_sourceview(Xcls_GtkView _owner ) @@ -412,12 +564,16 @@ public class Xcls_GtkView : Object // my vars (dec) this.loading = true; + this.prop_selected = ""; this.allow_node_scroll = true; // set gobject values this.el.editable = false; this.el.show_line_marks = true; this.el.show_line_numbers = true; + var child_0 = new Xcls_buffer( _this ); + child_0.ref(); + this.el.set_buffer ( child_0.el ); // init method @@ -521,88 +677,34 @@ public class Xcls_GtkView : Object } + + //listeners + this.el.key_press_event.connect( (event) => { + + if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + + + return false; + }); } // user defined functions - public string toString () { - Gtk.TextIter s; - Gtk.TextIter e; - this.el.get_buffer().get_start_iter(out s); - this.el.get_buffer().get_end_iter(out e); - var ret = this.el.get_buffer().get_text(s,e,true); - //print("TO STRING? " + ret); - return ret; - } - public void nodeSelected (JsRender.Node? sel) { - - - - // this is connected in widnowstate - print("Roo-view - node selected\n"); + public void loadFile ( ) { + this.loading = true; var buf = this.el.get_buffer(); - + buf.set_text("",0); var sbuf = (Gtk.SourceBuffer) buf; - - while(Gtk.events_pending()) { - Gtk.main_iteration(); - } - - - // clear all the marks.. - Gtk.TextIter start; - Gtk.TextIter end; - - sbuf.get_bounds (out start, out end); - sbuf.remove_source_marks (start, end, "grey"); - - - if (sel == null) { - // no highlighting.. - return; - } - Gtk.TextIter iter; - sbuf.get_iter_at_line(out iter, sel.line_start); - - - Gtk.TextIter cur_iter; - sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); - - //var cur_line = cur_iter.get_line(); - //if (cur_line > sel.line_start && cur_line < sel.line_end) { - - //} else { - if (this.allow_node_scroll) { - - this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); - } - - - - for (var i = 0; i < buf.get_line_count();i++) { - if (i < sel.line_start || i > sel.line_end) { - - sbuf.get_iter_at_line(out iter, i); - sbuf.create_source_mark(null, "grey", iter); - - } - - } - - - } - public void loadFile ( ) { - this.loading = true; - var buf = this.el.get_buffer(); - buf.set_text("",0); - var sbuf = (Gtk.SourceBuffer) buf; - - - - if (_this.file == null || _this.file.xtype != "Gtk") { - print("xtype != Gtk"); - this.loading = false; - return; + + + if (_this.file == null || _this.file.xtype != "Gtk") { + print("xtype != Gtk"); + this.loading = false; + return; } var valafn = ""; @@ -659,6 +761,64 @@ public class Xcls_GtkView : Object // } this.loading = false; + } + public void nodeSelected (JsRender.Node? sel, bool scroll) { + + + + // this is connected in widnowstate + print("Roo-view - node selected\n"); + var buf = this.el.get_buffer(); + + var sbuf = (Gtk.SourceBuffer) buf; + + + while(Gtk.events_pending()) { + Gtk.main_iteration(); + } + + + // clear all the marks.. + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, "grey"); + + this.node_selected = sel; + if (sel == null) { + // no highlighting.. + return; + } + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, sel.line_start); + + + Gtk.TextIter cur_iter; + sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position); + + //var cur_line = cur_iter.get_line(); + //if (cur_line > sel.line_start && cur_line < sel.line_end) { + + //} else { + if (this.allow_node_scroll) { + + this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + } + + + + for (var i = 0; i < buf.get_line_count();i++) { + if (i < sel.line_start || i > sel.line_end) { + + sbuf.get_iter_at_line(out iter, i); + sbuf.create_source_mark(null, "grey", iter); + + } + + } + + } public void highlightErrorsJson (string type, Json.Object obj) { Gtk.TextIter start; @@ -733,7 +893,586 @@ public class Xcls_GtkView : Object } + public string toString () { + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_buffer().get_start_iter(out s); + this.el.get_buffer().get_end_iter(out e); + var ret = this.el.get_buffer().get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + } + public class Xcls_buffer : Object + { + public Gtk.SourceBuffer el; + private Xcls_GtkView _this; + + + // my vars (def) + public int error_line; + public bool dirty; + + // ctor + public Xcls_buffer(Xcls_GtkView _owner ) + { + _this = _owner; + _this.buffer = this; + this.el = new Gtk.SourceBuffer( null ); + + // my vars (dec) + this.error_line = -1; + this.dirty = false; + + // set gobject values + } + + // user defined functions + } + + + + public class Xcls_Box12 : Object + { + public Gtk.Box el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Box12(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = false; + var child_0 = new Xcls_search_entry( _this ); + child_0.ref(); + this.el.add( child_0.el ); + var child_1 = new Xcls_MenuBar14( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_Button17( _this ); + child_2.ref(); + this.el.add( child_2.el ); + var child_3 = new Xcls_Button19( _this ); + child_3.ref(); + this.el.add( child_3.el ); + var child_4 = new Xcls_MenuButton21( _this ); + child_4.ref(); + this.el.add( child_4.el ); + } + + // user defined functions } + public class Xcls_search_entry : Object + { + public Gtk.SearchEntry el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_search_entry(Xcls_GtkView _owner ) + { + _this = _owner; + _this.search_entry = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 300; + this.el.hexpand = true; + this.el.placeholder_text = "Press enter to search"; + + // init method + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + this.el.override_font(description); + + //listeners + this.el.key_press_event.connect( (event) => { + + if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + + + + if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) { + var res = _this.search(this.el.text); + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + } else { + _this.search_results.el.label = "No Matches"; + } + + return true; + + } + // print(event.key.keyval) + + return false; + + }); + this.el.changed.connect( () => { + /* + if (this.el.text == "") { + _this.search_results.el.hide(); + return; + } + var res = 0; + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + ///case WindowState.State.CODE: + // search the code being edited.. + res = _this.windowstate.code_editor_tab.search(this.el.text); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + res = _this.windowstate.window_gladeview.search(this.el.text); + } else { + res = _this.windowstate.window_rooview.search(this.el.text); + } + + + break; + } + _this.search_results.el.show(); + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + } else { + _this.search_results.el.label = "No Matches"; + } + + */ + + }); + } + + // user defined functions + public void forwardSearch (bool change_focus) { + + + _this.forwardSearch(change_focus); + + /* + + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + //case WindowState.State.CODE: + // search the code being edited.. + _this.windowstate.code_editor_tab.forwardSearch(change_focus); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + _this.windowstate.window_gladeview.forwardSearch(change_focus); + } else { + _this.windowstate.window_rooview.forwardSearch(change_focus); + } + + break; + } + */ + + } + } + + public class Xcls_MenuBar14 : Object + { + public Gtk.MenuBar el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_MenuBar14(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.MenuBar(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_search_results( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_search_results : Object + { + public Gtk.ImageMenuItem el; + private Xcls_GtkView _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + + // ctor + public Xcls_search_results(Xcls_GtkView _owner ) + { + _this = _owner; + _this.search_results = this; + this.el = new Gtk.ImageMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Matches"; + var child_0 = new Xcls_Image16( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.button_press_event.connect( () => { + /* + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + } + + + this.popup.show(this.notices, this.el); + */ + return true; + }); + } + + // user defined functions + } + public class Xcls_Image16 : Object + { + public Gtk.Image el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Image16(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "system-search"; + this.el.sensitive = false; + } + + // user defined functions + } + + + + public class Xcls_Button17 : Object + { + public Gtk.Button el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Button17(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Next"; + var child_0 = new Xcls_Image18( _this ); + child_0.ref(); + this.el.image = child_0.el; + + //listeners + this.el.button_press_event.connect( (event) => { + + _this.forwardSearch(true); + + return true; + }); + } + + // user defined functions + } + public class Xcls_Image18 : Object + { + public Gtk.Image el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Image18(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-down"; + } + + // user defined functions + } + + + public class Xcls_Button19 : Object + { + public Gtk.Button el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Button19(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Previous"; + var child_0 = new Xcls_Image20( _this ); + child_0.ref(); + this.el.image = child_0.el; + + //listeners + this.el.button_press_event.connect( (event) => { + + _this.backSearch(true); + + return true; + }); + } + + // user defined functions + } + public class Xcls_Image20 : Object + { + public Gtk.Image el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Image20(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-up"; + } + + // user defined functions + } + + + public class Xcls_MenuButton21 : Object + { + public Gtk.MenuButton el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_MenuButton21(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.MenuButton(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Settings"; + var child_0 = new Xcls_Image22( _this ); + child_0.ref(); + this.el.image = child_0.el; + var child_1 = new Xcls_search_settings( _this ); + child_1.ref(); + this.el.popup = child_1.el; + } + + // user defined functions + } + public class Xcls_Image22 : Object + { + public Gtk.Image el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_Image22(Xcls_GtkView _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "emblem-system"; + } + + // user defined functions + } + + public class Xcls_search_settings : Object + { + public Gtk.Menu el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_search_settings(Xcls_GtkView _owner ) + { + _this = _owner; + _this.search_settings = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_case_sensitive( _this ); + child_0.ref(); + this.el.append( child_0.el ); + var child_1 = new Xcls_regex( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_multiline( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_case_sensitive : Object + { + public Gtk.CheckMenuItem el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_case_sensitive(Xcls_GtkView _owner ) + { + _this = _owner; + _this.case_sensitive = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Case Sensitive"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + public class Xcls_regex : Object + { + public Gtk.CheckMenuItem el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_regex(Xcls_GtkView _owner ) + { + _this = _owner; + _this.regex = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Regex"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + public class Xcls_multiline : Object + { + public Gtk.CheckMenuItem el; + private Xcls_GtkView _this; + + + // my vars (def) + + // ctor + public Xcls_multiline(Xcls_GtkView _owner ) + { + _this = _owner; + _this.multiline = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Multi-line (add \\n)"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + + diff --git a/src/Builder4/MainWindow.bjs b/src/Builder4/MainWindow.bjs index fa6198b4f..ffcb38fe1 100644 --- a/src/Builder4/MainWindow.bjs +++ b/src/Builder4/MainWindow.bjs @@ -395,132 +395,10 @@ "ulong handler_id" : "-1", "xtype" : "ProgressBar" }, - { - "$ xns" : "Gtk", - "* init" : [ - "var description = Pango.FontDescription.from_string(\"monospace\");", - "\tdescription.set_size(8000);", - "\t this.el.override_font(description);", - "", - "" - ], - "* pack" : "pack_start,false,true,0", - "id" : "search_entry", - "int width_request" : 300, - "listeners" : { - "changed" : [ - "() => {", - "\tif (this.el.text == \"\") {", - "\t\t_this.search_results.el.hide();", - "\t\treturn;", - "\t}", - "\tvar res = 0;", - "\tswitch(_this.windowstate.state) {", - "\t\tcase WindowState.State.CODEONLY:", - "\t\t///case WindowState.State.CODE:", - "\t\t\t// search the code being edited..", - "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);", - "\t\t\t", - "\t\t\tbreak;", - "\t\tcase WindowState.State.PREVIEW:", - "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", - "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);", - "\t\t\t} else { ", - "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t", - "\t\t\t}", - "\t\t", - "\t\t", - "\t\t\tbreak;", - "\t}", - "\t_this.search_results.el.show();", - "\tif (res > 0) {", - "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", - "\t} else {", - "\t\t_this.search_results.el.label = \"No Matches\";", - "\t}", - "\t\t", - "\t", - "\t", - "}", - "" - ], - "key_press_event" : [ - "(event) => {", - " ", - " \tif (event.keyval == Gdk.Key.Return) {", - "\t\tthis.forwardSearch(false);", - "\t return true;", - "", - "\t} ", - " // print(event.key.keyval)", - " ", - " return false;", - "", - "} " - ] - }, - "xtype" : "SearchEntry", - "| void forwardSearch" : [ - "(bool change_focus) {", - "\tswitch(_this.windowstate.state) {", - "\t\tcase WindowState.State.CODEONLY:", - "\t\t//case WindowState.State.CODE:", - "\t\t\t// search the code being edited..", - "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);", - "\t\t\t ", - "\t\t\tbreak;", - "\t\tcase WindowState.State.PREVIEW:", - "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", - "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);", - "\t\t\t} else { ", - "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);", - "\t\t\t}", - "\t\t", - "\t\t\tbreak;", - "\t}", - "\t", - "}", - "" - ] - }, { "$ xns" : "Gtk", "* pack" : "add", "items" : [ - { - "$ xns" : "Gtk", - "* pack" : "add", - "Xcls_ValaCompileErrors popup" : "", - "bool always_show_image" : true, - "id" : "search_results", - "items" : [ - { - "$ xns" : "Gtk", - "* pack" : "set_image", - "bool sensitive" : false, - "utf8 icon_name" : "system-search", - "xtype" : "Image" - } - ], - "listeners" : { - "button_press_event" : [ - "() => {", - "/*", - " if (this.popup == null) {", - " this.popup = new Xcls_ValaCompileErrors();", - " this.popup.window = _this;", - " }", - " ", - " ", - " this.popup.show(this.notices, this.el);", - " */", - " return true;", - "}" - ] - }, - "string label" : "Matches", - "xtype" : "ImageMenuItem" - }, { "$ xns" : "Gtk", "* pack" : "add", @@ -682,7 +560,6 @@ "xtype" : "ImageMenuItem" } ], - "string tooltip_text" : "Update Resources / About Roobuilder", "xtype" : "MenuBar" }, { @@ -715,7 +592,7 @@ ], "listeners" : { "delete_event" : [ - " ( event) => {", + "( event) => {", " return false;", "} " ], @@ -736,24 +613,11 @@ "key_release_event" : [ " (event) => {", " ", - " if (this.search_entry.el.is_visible()) {", - "\t\tif (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", - "\t\t print(\"SAVE: ctrl-f pressed\");", - "\t\t\tthis.search_entry.el.grab_focus();", - "\t\t return false;", - "\t\t}", - "\t\t", - "\t\tif (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", - "\t\t print(\"SAVE: ctrl-g pressed\");", - "\t\t\tthis.search_entry.forwardSearch(true);", - "\t\t return false;", - "\t\t}", - "\t\t", - "\t} ", + " ", "\t", "\tif (event.keyval == Gdk.Key.n && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", "\t\tprint(\"SAVE: ctrl-n pressed\");", - "\t\tthis.openNewWindow();", + "\t\t_this.windowstate.showPopoverFiles(_this.windowbtn.el, _this.project, true);", "\t\treturn false;", "\t}", "\t", diff --git a/src/Builder4/MainWindow.vala b/src/Builder4/MainWindow.vala index 3c957151a..922d90b7c 100644 --- a/src/Builder4/MainWindow.vala +++ b/src/Builder4/MainWindow.vala @@ -25,8 +25,6 @@ public class Xcls_MainWindow : Object public Xcls_codeeditviewbox codeeditviewbox; public Xcls_topbarmenu topbarmenu; public Xcls_statusbar statusbar; - public Xcls_search_entry search_entry; - public Xcls_search_results search_results; public Xcls_statusbar_compilestatus_label statusbar_compilestatus_label; public Xcls_statusbar_errors statusbar_errors; public Xcls_statusbar_warnings statusbar_warnings; @@ -95,24 +93,11 @@ public class Xcls_MainWindow : Object }); this.el.key_release_event.connect( (event) => { - if (this.search_entry.el.is_visible()) { - if (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - print("SAVE: ctrl-f pressed"); - this.search_entry.el.grab_focus(); - return false; - } - - if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { - print("SAVE: ctrl-g pressed"); - this.search_entry.forwardSearch(true); - return false; - } - - } + if (event.keyval == Gdk.Key.n && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { print("SAVE: ctrl-n pressed"); - this.openNewWindow(); + _this.windowstate.showPopoverFiles(_this.windowbtn.el, _this.project, true); return false; } @@ -730,15 +715,12 @@ public class Xcls_MainWindow : Object var child_4 = new Xcls_statusbar( _this ); child_4.ref(); this.el.pack_start ( child_4.el , true,true,0 ); - var child_5 = new Xcls_search_entry( _this ); + var child_5 = new Xcls_MenuBar32( _this ); child_5.ref(); - this.el.pack_start ( child_5.el , false,true,0 ); - var child_6 = new Xcls_MenuBar33( _this ); + this.el.add ( child_5.el ); + var child_6 = new Xcls_statusbar_compile_spinner( _this ); child_6.ref(); this.el.add ( child_6.el ); - var child_7 = new Xcls_statusbar_compile_spinner( _this ); - child_7.ref(); - this.el.add ( child_7.el ); } // user defined functions @@ -1079,103 +1061,7 @@ public class Xcls_MainWindow : Object // user defined functions } - public class Xcls_search_entry : Object - { - public Gtk.SearchEntry el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_search_entry(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.search_entry = this; - this.el = new Gtk.SearchEntry(); - - // my vars (dec) - - // set gobject values - this.el.width_request = 300; - - // init method - - var description = Pango.FontDescription.from_string("monospace"); - description.set_size(8000); - this.el.override_font(description); - - //listeners - this.el.key_press_event.connect( (event) => { - - if (event.keyval == Gdk.Key.Return) { - this.forwardSearch(false); - return true; - - } - // print(event.key.keyval) - - return false; - - }); - this.el.changed.connect( () => { - if (this.el.text == "") { - _this.search_results.el.hide(); - return; - } - var res = 0; - switch(_this.windowstate.state) { - case WindowState.State.CODEONLY: - ///case WindowState.State.CODE: - // search the code being edited.. - res = _this.windowstate.code_editor_tab.search(this.el.text); - - break; - case WindowState.State.PREVIEW: - if (_this.windowstate.file.xtype == "Gtk") { - res = _this.windowstate.window_gladeview.search(this.el.text); - } else { - res = _this.windowstate.window_rooview.search(this.el.text); - } - - - break; - } - _this.search_results.el.show(); - if (res > 0) { - _this.search_results.el.label = "%d Matches".printf(res); - } else { - _this.search_results.el.label = "No Matches"; - } - - - - }); - } - - // user defined functions - public void forwardSearch (bool change_focus) { - switch(_this.windowstate.state) { - case WindowState.State.CODEONLY: - //case WindowState.State.CODE: - // search the code being edited.. - _this.windowstate.code_editor_tab.forwardSearch(change_focus); - - break; - case WindowState.State.PREVIEW: - if (_this.windowstate.file.xtype == "Gtk") { - _this.windowstate.window_gladeview.forwardSearch(change_focus); - } else { - _this.windowstate.window_rooview.forwardSearch(change_focus); - } - - break; - } - - } - } - - public class Xcls_MenuBar33 : Object + public class Xcls_MenuBar32 : Object { public Gtk.MenuBar el; private Xcls_MainWindow _this; @@ -1184,7 +1070,7 @@ public class Xcls_MainWindow : Object // my vars (def) // ctor - public Xcls_MenuBar33(Xcls_MainWindow _owner ) + public Xcls_MenuBar32(Xcls_MainWindow _owner ) { _this = _owner; this.el = new Gtk.MenuBar(); @@ -1192,96 +1078,25 @@ public class Xcls_MainWindow : Object // my vars (dec) // set gobject values - this.el.tooltip_text = "Update Resources / About Roobuilder"; - var child_0 = new Xcls_search_results( _this ); + var child_0 = new Xcls_statusbar_compilestatus_label( _this ); child_0.ref(); this.el.add ( child_0.el ); - var child_1 = new Xcls_statusbar_compilestatus_label( _this ); + var child_1 = new Xcls_statusbar_errors( _this ); child_1.ref(); this.el.add ( child_1.el ); - var child_2 = new Xcls_statusbar_errors( _this ); + var child_2 = new Xcls_statusbar_warnings( _this ); child_2.ref(); this.el.add ( child_2.el ); - var child_3 = new Xcls_statusbar_warnings( _this ); + var child_3 = new Xcls_statusbar_depricated( _this ); child_3.ref(); this.el.add ( child_3.el ); - var child_4 = new Xcls_statusbar_depricated( _this ); + var child_4 = new Xcls_statusbar_run( _this ); child_4.ref(); this.el.add ( child_4.el ); - var child_5 = new Xcls_statusbar_run( _this ); - child_5.ref(); - this.el.add ( child_5.el ); } // user defined functions } - public class Xcls_search_results : Object - { - public Gtk.ImageMenuItem el; - private Xcls_MainWindow _this; - - - // my vars (def) - public Xcls_ValaCompileErrors popup; - - // ctor - public Xcls_search_results(Xcls_MainWindow _owner ) - { - _this = _owner; - _this.search_results = this; - this.el = new Gtk.ImageMenuItem(); - - // my vars (dec) - - // set gobject values - this.el.always_show_image = true; - this.el.label = "Matches"; - var child_0 = new Xcls_Image35( _this ); - child_0.ref(); - this.el.set_image ( child_0.el ); - - //listeners - this.el.button_press_event.connect( () => { - /* - if (this.popup == null) { - this.popup = new Xcls_ValaCompileErrors(); - this.popup.window = _this; - } - - - this.popup.show(this.notices, this.el); - */ - return true; - }); - } - - // user defined functions - } - public class Xcls_Image35 : Object - { - public Gtk.Image el; - private Xcls_MainWindow _this; - - - // my vars (def) - - // ctor - public Xcls_Image35(Xcls_MainWindow _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "system-search"; - this.el.sensitive = false; - } - - // user defined functions - } - - public class Xcls_statusbar_compilestatus_label : Object { public Gtk.MenuItem el; @@ -1329,7 +1144,7 @@ public class Xcls_MainWindow : Object // set gobject values this.el.always_show_image = true; this.el.label = "Errors"; - var child_0 = new Xcls_Image38( _this ); + var child_0 = new Xcls_Image35( _this ); child_0.ref(); this.el.set_image ( child_0.el ); @@ -1354,7 +1169,7 @@ public class Xcls_MainWindow : Object } } - public class Xcls_Image38 : Object + public class Xcls_Image35 : Object { public Gtk.Image el; private Xcls_MainWindow _this; @@ -1363,7 +1178,7 @@ public class Xcls_MainWindow : Object // my vars (def) // ctor - public Xcls_Image38(Xcls_MainWindow _owner ) + public Xcls_Image35(Xcls_MainWindow _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -1401,7 +1216,7 @@ public class Xcls_MainWindow : Object // set gobject values this.el.always_show_image = true; this.el.label = "Warnings"; - var child_0 = new Xcls_Image40( _this ); + var child_0 = new Xcls_Image37( _this ); child_0.ref(); this.el.set_image ( child_0.el ); @@ -1425,7 +1240,7 @@ public class Xcls_MainWindow : Object } } - public class Xcls_Image40 : Object + public class Xcls_Image37 : Object { public Gtk.Image el; private Xcls_MainWindow _this; @@ -1434,7 +1249,7 @@ public class Xcls_MainWindow : Object // my vars (def) // ctor - public Xcls_Image40(Xcls_MainWindow _owner ) + public Xcls_Image37(Xcls_MainWindow _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -1472,7 +1287,7 @@ public class Xcls_MainWindow : Object // set gobject values this.el.always_show_image = true; this.el.label = "Depricated"; - var child_0 = new Xcls_Image42( _this ); + var child_0 = new Xcls_Image39( _this ); child_0.ref(); this.el.set_image ( child_0.el ); @@ -1497,7 +1312,7 @@ public class Xcls_MainWindow : Object } } - public class Xcls_Image42 : Object + public class Xcls_Image39 : Object { public Gtk.Image el; private Xcls_MainWindow _this; @@ -1506,7 +1321,7 @@ public class Xcls_MainWindow : Object // my vars (def) // ctor - public Xcls_Image42(Xcls_MainWindow _owner ) + public Xcls_Image39(Xcls_MainWindow _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -1542,7 +1357,7 @@ public class Xcls_MainWindow : Object // set gobject values this.el.always_show_image = true; this.el.label = "Run"; - var child_0 = new Xcls_Image44( _this ); + var child_0 = new Xcls_Image41( _this ); child_0.ref(); this.el.set_image ( child_0.el ); @@ -1561,7 +1376,7 @@ public class Xcls_MainWindow : Object // user defined functions } - public class Xcls_Image44 : Object + public class Xcls_Image41 : Object { public Gtk.Image el; private Xcls_MainWindow _this; @@ -1570,7 +1385,7 @@ public class Xcls_MainWindow : Object // my vars (def) // ctor - public Xcls_Image44(Xcls_MainWindow _owner ) + public Xcls_Image41(Xcls_MainWindow _owner ) { _this = _owner; this.el = new Gtk.Image(); diff --git a/src/Builder4/WindowRooView.bjs b/src/Builder4/WindowRooView.bjs index 1fb2f884e..c98be69dc 100644 --- a/src/Builder4/WindowRooView.bjs +++ b/src/Builder4/WindowRooView.bjs @@ -93,7 +93,7 @@ " //_this.view.renderJS(true);", " FakeServerCache.clear();", " _this.view.reInit();", - "", + " ", "}" ] }, @@ -254,7 +254,6 @@ "}" ] }, - "redraws" : 0, "xtype" : "WebView", "| void initInspector" : [ "() {", @@ -561,678 +560,941 @@ { "$ xns" : "Gtk", "* pack" : "append_page,_this.label_code.el", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "int spacing" : 0, "items" : [ { - "# JsRender.Node? node_selected" : "null", - "# bool button_is_pressed" : false, - "# bool key_is_pressed" : false, - "# bool loading" : true, - "# int editable_start_pos" : "-1", - "$ string prop_selected" : "\"\"", "$ xns" : "Gtk", - "* init" : [ - "{", - " ", - " ", - " var description = Pango.FontDescription.from_string(\"monospace\");", - " description.set_size(8000);", - " this.el.override_font(description);", - "", - " this.loading = true;", - " //var buf = this.el.get_buffer();", - " //buf.notify.connect(this.onCursorChanged);", - " ", - " ", - " var attrs = new Gtk.SourceMarkAttributes();", - " var pink = Gdk.RGBA();", - " pink.parse ( \"pink\");", - " attrs.set_background ( pink);", - " attrs.set_icon_name ( \"process-stop\"); ", - " attrs.query_tooltip_text.connect(( mark) => {", - " //print(\"tooltip query? %s\\n\", mark.name);", - " return mark.name;", - " });", - " ", - " this.el.set_mark_attributes (\"ERR\", attrs, 1);", - " ", - " var wattrs = new Gtk.SourceMarkAttributes();", - " var blue = Gdk.RGBA();", - " blue.parse ( \"#ABF4EB\");", - " wattrs.set_background ( blue);", - " wattrs.set_icon_name ( \"process-stop\"); ", - " wattrs.query_tooltip_text.connect(( mark) => {", - " //print(\"tooltip query? %s\\n\", mark.name);", - " return mark.name;", - " });", - " ", - " this.el.set_mark_attributes (\"WARN\", wattrs, 1);", - " ", - " ", - " ", - " var dattrs = new Gtk.SourceMarkAttributes();", - " var purple = Gdk.RGBA();", - " purple.parse ( \"#EEA9FF\");", - " dattrs.set_background ( purple);", - " dattrs.set_icon_name ( \"process-stop\"); ", - " dattrs.query_tooltip_text.connect(( mark) => {", - " //print(\"tooltip query? %s\\n\", mark.name);", - " return mark.name;", - " });", - " ", - " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);", - " ", - " ", - " var gattrs = new Gtk.SourceMarkAttributes();", - " var grey = Gdk.RGBA();", - " grey.parse ( \"#ccc\");", - " gattrs.set_background ( grey);", - " ", - " ", - " this.el.set_mark_attributes (\"grey\", gattrs, 1);", - " ", - " ", - " ", - " ", - " ", - " ", - "}", - " " - ], - "* pack" : "add", - "gboolean editable" : false, - "gboolean show_line_marks" : true, - "gboolean show_line_numbers" : true, - "id" : "sourceview", + "bool vexpand" : true, "items" : [ { + "# JsRender.Node? node_selected" : "null", + "# bool button_is_pressed" : false, + "# bool key_is_pressed" : false, + "# bool loading" : true, + "# int editable_start_pos" : "-1", + "# string prop_selected" : "\"\"", "$ xns" : "Gtk", - "* pack" : "set_buffer", - "bool dirty" : false, - "id" : "buffer", - "int error_line" : "-1", + "* init" : [ + "{", + " ", + " ", + " var description = Pango.FontDescription.from_string(\"monospace\");", + " description.set_size(8000);", + " this.el.override_font(description);", + "", + " this.loading = true;", + " //var buf = this.el.get_buffer();", + " //buf.notify.connect(this.onCursorChanged);", + " ", + " ", + " var attrs = new Gtk.SourceMarkAttributes();", + " var pink = Gdk.RGBA();", + " pink.parse ( \"pink\");", + " attrs.set_background ( pink);", + " attrs.set_icon_name ( \"process-stop\"); ", + " attrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"ERR\", attrs, 1);", + " ", + " var wattrs = new Gtk.SourceMarkAttributes();", + " var blue = Gdk.RGBA();", + " blue.parse ( \"#ABF4EB\");", + " wattrs.set_background ( blue);", + " wattrs.set_icon_name ( \"process-stop\"); ", + " wattrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"WARN\", wattrs, 1);", + " ", + " ", + " ", + " var dattrs = new Gtk.SourceMarkAttributes();", + " var purple = Gdk.RGBA();", + " purple.parse ( \"#EEA9FF\");", + " dattrs.set_background ( purple);", + " dattrs.set_icon_name ( \"process-stop\"); ", + " dattrs.query_tooltip_text.connect(( mark) => {", + " //print(\"tooltip query? %s\\n\", mark.name);", + " return mark.name;", + " });", + " ", + " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);", + " ", + " ", + " var gattrs = new Gtk.SourceMarkAttributes();", + " var grey = Gdk.RGBA();", + " grey.parse ( \"#ccc\");", + " gattrs.set_background ( grey);", + " ", + " ", + " this.el.set_mark_attributes (\"grey\", gattrs, 1);", + " ", + " ", + " ", + " ", + " ", + " ", + "}", + " " + ], + "* pack" : "add", + "gboolean editable" : false, + "gboolean show_line_marks" : true, + "gboolean show_line_numbers" : true, + "id" : "sourceview", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "set_buffer", + "bool dirty" : false, + "id" : "buffer", + "int error_line" : "-1", + "listeners" : { + "changed" : [ + " () => {", + " ", + "", + " // check syntax??", + " // ??needed..??", + " // _this.save_button.el.sensitive = true;", + " ///?? has changed occured during loading?", + " ", + " // only trigger this if ", + " ", + " ", + " ", + " ", + " if (_this.sourceview.loading) {", + "\t\treturn;", + "\t}", + "\t", + "", + "\t", + " print(\"- PREVIEW EDITOR CHANGED--\");", + "", + " this.dirty = true; ", + " this.checkSyntax(); // this calls backs and highlights errors.. in theory... ", + "", + "", + "", + "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {", + "\t\tprint(\"button or key not pressed to generate change?!\\n\");", + "\t\treturn;", + "\t}", + "\t\t", + " ", + "\t// what are we editing??", + "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) {", + "\t\treturn;", + "\t}", + "\t", + "\t// find the colon on the first line...", + "\t", + "\tif (_this.sourceview.editable_start_pos > -1) {", + "\t\t", + "\t\tvar buf = (Gtk.SourceBuffer)_this.sourceview.el.get_buffer();", + "\t\t", + " //print(\"cursor changed : %d\\n\", buf.cursor_position);", + " Gtk.TextIter spos,epos;", + " buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);", + " buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..", + " ", + " var gotit= false;", + " var line = spos.get_line();", + " var endline = buf.get_line_count();", + " while (line < endline) {", + " \t\tline++;", + "\t buf.get_iter_at_line(out epos, line);", + "\t if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {", + "\t\t buf.get_iter_at_line(out epos, line);\t \t\t", + "\t \t\tgotit=true;", + "\t \t\tbreak;", + " \t\t}", + "\t\t}", + " ", + " \t\tif (gotit) {", + "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());", + "\t\t\t// get the pos...", + "\t\t\t// in theory the last char will be '}' or '},' .. or ','", + "\t\t\t// we should chop the ',' of the end...", + "\t\t\tvar str = buf.get_text(spos, epos, false);", + "\t\t\tprint(\"got string\\n%s\\n\", str);", + "\t\t", + "\t\t}", + "\t}", + " return ;", + "}", + "", + " ", + "" + ] + }, + "xtype" : "SourceBuffer", + "| bool checkSyntax" : [ + " () {", + " ", + " ", + " var str = this.toString();", + " ", + " // needed???", + " if (this.error_line > 0) {", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " this.el.get_bounds (out start, out end);", + "", + " this.el.remove_source_marks (start, end, \"WARN\");", + " this.el.remove_source_marks (start, end, \"ERR\"); ", + "", + " }", + " ", + " if (str.length < 1) {", + " print(\"checkSyntax - empty string?\\n\");", + " return false;", + " }", + " ", + " if (_this.file == null) {", + " return false;", + " }", + " var p = _this.file.project.palete;", + " ", + " ", + " if (_this.file.language != \"js\") {", + "\t\treturn false; // fake syntax error.", + "\t}", + "\t", + " //Gee.HashMap ret_x;", + "", + "\treturn p.javascriptHasErrors(", + "\t\t_this.main_window.windowstate,", + " str, ", + " null, // prop - not relivant.", + " _this.file, ", + " null", + " ); ", + " ", + "}", + "" + ], + "| bool highlightErrors" : [ + "( Gee.HashMap validate_res) {", + " ", + " this.error_line = validate_res.size;", + "\t", + " if (this.error_line < 1) {", + " return true;", + " }", + " var tlines = this.el.get_line_count ();", + " Gtk.TextIter iter;", + " var valiter = validate_res.map_iterator();", + " while (valiter.next()) {", + " ", + "// print(\"get inter\\n\");", + " var eline = valiter.get_key();", + " if (eline > tlines) {", + " continue;", + " }", + " this.el.get_iter_at_line( out iter, eline);", + " //print(\"mark line\\n\");", + " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);", + " } ", + " return false;", + "}" + ], + "| string toString" : [ + " () {", + " ", + " Gtk.TextIter s;", + " Gtk.TextIter e;", + " this.el.get_start_iter(out s);", + " this.el.get_end_iter(out e);", + " var ret = this.el.get_text(s,e,true);", + " //print(\"TO STRING? \" + ret);", + " return ret;", + "}", + " " + ] + } + ], "listeners" : { - "changed" : [ - " () => {", + "button_press_event" : [ + "( ) => {", " ", + "\tthis.button_is_pressed = true;", + "\treturn false;", + "}\t ", + "" + ], + "button_release_event" : [ + "() => {", "", - " // check syntax??", - " // ??needed..??", - " // _this.save_button.el.sensitive = true;", - " ///?? has changed occured during loading?", - " ", - " // only trigger this if ", - " ", - " ", - " ", - " ", - " if (_this.sourceview.loading) {", - "\t\treturn;", - "\t}", - "\t", - "", + "\tprint(\"BUTTON RELEASE EVENT\\n\");", + "\tthis.onCursorChanged();", + "\tthis.button_is_pressed = false;", + "\treturn false;", + "}" + ], + "key_press_event" : [ + " (event) => {", "\t", - " print(\"- PREVIEW EDITOR CHANGED--\");", - "", - " this.dirty = true; ", - " this.checkSyntax(); // this calls backs and highlights errors.. in theory... ", - "", - "", - "", - "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {", - "\t\tprint(\"button or key not pressed to generate change?!\\n\");", - "\t\treturn;", + "\t if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t GLib.debug(\"SAVE: ctrl-g pressed\");", + "\t\t_this.forwardSearch(true);", + "\t return true;", "\t}", - "\t\t", " ", - "\t// what are we editing??", - "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) {", - "\t\treturn;", - "\t}", - "\t", - "\t// find the colon on the first line...", - "\t", - "\tif (_this.sourceview.editable_start_pos > -1) {", - "\t\t", - "\t\tvar buf = (Gtk.SourceBuffer)_this.sourceview.el.get_buffer();", - "\t\t", - " //print(\"cursor changed : %d\\n\", buf.cursor_position);", - " Gtk.TextIter spos,epos;", - " buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);", - " buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..", - " ", - " var gotit= false;", - " var line = spos.get_line();", - " var endline = buf.get_line_count();", - " while (line < endline) {", - " \t\tline++;", - "\t buf.get_iter_at_line(out epos, line);", - "\t if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {", - "\t\t buf.get_iter_at_line(out epos, line);\t \t\t", - "\t \t\tgotit=true;", - "\t \t\tbreak;", - " \t\t}", - "\t\t}", - " ", - " \t\tif (gotit) {", - "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());", - "\t\t\t// get the pos...", - "\t\t\t// in theory the last char will be '}' or '},' .. or ','", - "\t\t\t// we should chop the ',' of the end...", - "\t\t\tvar str = buf.get_text(spos, epos, false);", - "\t\t\tprint(\"got string\\n%s\\n\", str);", - "\t\t", - "\t\t}", - "\t}", - " return ;", + "\tthis.button_is_pressed = true;", + "\treturn false;", + "}\t ", + " " + ], + "key_release_event" : [ + "() => { ", + "\tthis.key_is_pressed = false;", + "\treturn false;", "}", - "", - " ", "" ] }, - "xtype" : "SourceBuffer", - "| bool checkSyntax" : [ - " () {", + "xtype" : "SourceView", + "| string toString" : [ + "() {", + " Gtk.TextIter s;", + " Gtk.TextIter e;", + " this.el.get_buffer().get_start_iter(out s);", + " this.el.get_buffer().get_end_iter(out e);", + " var ret = this.el.get_buffer().get_text(s,e,true);", + " //print(\"TO STRING? \" + ret);", + " return ret;", + "}", + "" + ], + "| void clearGreySelection" : [ + "() {", + " // clear all the marks..", + " var sbuf = (Gtk.SourceBuffer)this.el.buffer;", + " ", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " ", + " sbuf.get_bounds (out start, out end);", + " sbuf.remove_source_marks (start, end, \"grey\");", + " ", + " ", + "}", + "" + ], + "| void highlightErrorsJson" : [ + " (string type, Json.Object obj) {", + " // this is a hook for the vala code - it has no value in javascript ", + " // as we only have one error ususally....", + " return ;", + " ", " ", + "", + "", + "}" + ], + "| void loadFile" : [ + "( ) {", + " this.loading = true;", + " ", + " ", + " // get the cursor and scroll position....", + " var buf = this.el.get_buffer();", + "\tvar cpos = buf.cursor_position;", + " ", + " print(\"BEFORE LOAD cursor = %d\\n\", cpos);", + " ", + " var vadj_pos = this.el.get_vadjustment().get_value();", " ", - " var str = this.toString();", " ", - " // needed???", - " if (this.error_line > 0) {", - " Gtk.TextIter start;", - " Gtk.TextIter end; ", - " this.el.get_bounds (out start, out end);", + " ", + " buf.set_text(\"\",0);", + " var sbuf = (Gtk.SourceBuffer) buf;", "", - " this.el.remove_source_marks (start, end, \"WARN\");", - " this.el.remove_source_marks (start, end, \"ERR\"); ", + " ", "", + " if (_this.file == null || _this.file.xtype != \"Roo\") {", + " print(\"xtype != Roo\");", + " this.loading = false;", + " return;", " }", " ", - " if (str.length < 1) {", - " print(\"checkSyntax - empty string?\\n\");", - " return false;", - " }", + " // get the string from the rendered tree...", + " ", + " var str = _this.file.toSource();", + " ", + "// print(\"setting str %d\\n\", str.length);", + " buf.set_text(str, str.length);", + " var lm = Gtk.SourceLanguageManager.get_default();", + " ", + " //?? is javascript going to work as js?", " ", - " if (_this.file == null) {", - " return false;", - " }", - " var p = _this.file.project.palete;", + " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));", + " ", " ", - " ", - " if (_this.file.language != \"js\") {", - "\t\treturn false; // fake syntax error.", - "\t}", - "\t", - " //Gee.HashMap ret_x;", + " Gtk.TextIter start;", + " Gtk.TextIter end; ", + " ", + " sbuf.get_bounds (out start, out end);", + " sbuf.remove_source_marks (start, end, null); // remove all marks..", + " ", + " GLib.Timeout.add(500, () => {", "", - "\treturn p.javascriptHasErrors(", - "\t\t_this.main_window.windowstate,", - " str, ", - " null, // prop - not relivant.", - " _this.file, ", - " null", - " ); ", - " ", + " print(\"RESORTING cursor to = %d\\n\", cpos);", + "\t\tGtk.TextIter cpos_iter;", + "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);", + "\t\tbuf.place_cursor(cpos_iter); ", + "\t\t", + "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;", + "\t\t", + "", + "\t\tthis.onCursorChanged();", + "\t\t", + "\t\t", + "\t\t_this.buffer.checkSyntax();", + "\t\treturn false;", + "\t});", + "\t\t", + " this.loading = false; ", + " _this.buffer.dirty = false;", "}", "" ], - "| string toString" : [ - " () {", + "| void nodeSelected" : [ + "(JsRender.Node? sel, bool scroll ) {", + " ", + " ", + "\t", + " // this is connected in widnowstate", + "", + "", + "\t// not sure why.... ", + " while(Gtk.events_pending()) {", + " Gtk.main_iteration();", + " }", + " ", + " this.node_selected = sel;", + " ", + " this.updateGreySelection(scroll);", + " ", + " ", " ", - " Gtk.TextIter s;", - " Gtk.TextIter e;", - " this.el.get_start_iter(out s);", - " this.el.get_end_iter(out e);", - " var ret = this.el.get_text(s,e,true);", - " //print(\"TO STRING? \" + ret);", - " return ret;", + "}", + "", + " ", + "" + ], + "| void onCursorChanged" : [ + "(/*ParamSpec ps*/) {", + "", + "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {", + "\t\t\treturn;", + "\t\t}", + "", + "\t if (this.loading) {", + " return;", + " }", + " // if (ps.name != \"cursor-position\") {", + " // return;", + " // }", + "", + " var buf = this.el.get_buffer();", + " //print(\"cursor changed : %d\\n\", buf.cursor_position);", + " Gtk.TextIter cpos;", + " buf.get_iter_at_offset(out cpos, buf.cursor_position);", + " ", + " var ln = cpos.get_line();", + " ", + " ", + " // --- select node at line....", + " ", + " var node = _this.file.lineToNode(ln+1);", + " ", + " if (node == null) {", + " print(\"can not find node\\n\");", + " return;", + " }", + " var prop = node.lineToProp(ln+1);", + " print(\"prop : %s\", prop == null ? \"???\" : prop);", + " ", + " ", + " // ---------- this selects the tree's node...", + " ", + " var ltree = _this.main_window.windowstate.left_tree;", + " var tp = ltree.model.treePathFromNode(node);", + " print(\"got tree path %s\\n\", tp);", + " if (tp != \"\") {", + "\t ", + "\t ", + "\t //print(\"changing cursor on tree..\\n\");", + "\t ", + " ", + " ", + " // let's try allowing editing on the methods.", + " // a little klunky at present..", + " this.prop_selected = \"\";", + " if (prop != null) {", + " \t\t//see if we can find it..", + " \t\tvar kv = prop.split(\":\");", + " \t\tif (kv[0] == \"p\") {", + " \t\t", + "\t \t\t//var k = prop.get_key(kv[1]);", + "\t \t\t// fixme -- need to determine if it's an editable property...", + "\t \t\tthis.prop_selected = prop;", + "\t \t\t", + " \t\t} else if (kv[0] == \"l\") {", + " \t\t\t this.prop_selected = prop;", + " \t\t\t", + " \t\t}", + " }", + " ltree.view.setCursor(tp, \"editor\");", + " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ", + " this.nodeSelected(node,false);", + " ", + " // scrolling is disabled... as node selection calls scroll 10ms after it changes.", + " ", + " }", + " ", + " // highlight the node..", "}", " " ], - "| bool highlightErrors" : [ - "( Gee.HashMap validate_res) {", - " ", - " this.error_line = validate_res.size;", - "\t", - " if (this.error_line < 1) {", - " return true;", + "| void updateGreySelection" : [ + "(bool scroll) { ", + "\tvar sel = this.node_selected;", + "\tprint(\"node selected\\n\");", + " var buf = this.el.get_buffer();", + " var sbuf = (Gtk.SourceBuffer) buf;", + "", + " ", + " this.clearGreySelection();", + " ", + " ", + " ", + " if (sel == null) {", + "\t print(\"no selected node\\n\");", + " // no highlighting..", + " return;", " }", - " var tlines = this.el.get_line_count ();", - " Gtk.TextIter iter;", - " var valiter = validate_res.map_iterator();", - " while (valiter.next()) {", " ", - "// print(\"get inter\\n\");", - " var eline = valiter.get_key();", - " if (eline > tlines) {", - " continue;", + " print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);", + " Gtk.TextIter iter; ", + " sbuf.get_iter_at_line(out iter, sel.line_start);", + " ", + " ", + " Gtk.TextIter cur_iter;", + " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);", + " ", + " var cursor_at_line = cur_iter.get_line();", + " ", + " ", + " //var cur_line = cur_iter.get_line();", + " //if (cur_line > sel.line_start && cur_line < sel.line_end) {", + " ", + " //} else {", + " if (scroll) {", + "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");", + " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", + "\t}", + " ", + " var start_line = sel.line_start;", + " var end_line = sel.line_end;", + " ", + " ", + " this.el.editable = false;", + " ", + " //var colon_pos = 0;", + " ", + " this.editable_start_pos = -1;", + " ", + " // now if we have selected a property...", + " if (this.prop_selected.length> 0 ) {", + "", + "\t\tint nstart, nend;", + "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {", + "\t\t\tstart_line = nstart;", + "\t\t\tend_line = nend;", + "\t\t\tthis.el.editable = true;", + "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);", + "\t\t\t", + "\t\t\t\t// see if we are 'right of ':'", + "\t\t\t\t// get an iter for the start of the line.", + "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;", + "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);", + "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);", + "\t\t\t ", + "\t\t\t", + "\t\t\t", + "\t\t\t", + "\t\t\tif (end_first_line_iter.forward_to_line_end()) {", + "\t\t\t\tvar first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);", + "\t\t\t\t", + "\t\t\t\tprint(\"first line = %s\\n\", first_line);", + "\t\t\t\tif (first_line.contains(\":\")) {", + "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;", + "\t\t\t\t\tprint(\"colon_pos = %d\\n\", this.editable_start_pos);", + "\t\t\t\t}", + "\t\t\t\t", + "", + "\t\t\t\t//Gtk.TextIter colon_iter;", + "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);", + "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);", + "\t\t\t}", + "\t\t\t", + "\t\t\t", + "\t\t\t", + "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);", + "\t\t\t//if (start_line - 1 == cursor_at_line) {", + "\t\t\t// should be ok - current_posssion can not be less than '-1'...", + "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {", + "\t\t\t", + "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");", + "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);", + "\t\t\t\t//print(\"before cursor string = %s\\n\", before_cursor_string);", + "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {", + "\t\t\t\t\tthis.el.editable = false;", + "\t\t\t\t//}", + "\t\t\t\t", + "\t\t\t}", + "\t\t\t ", + "\t\t\t ", + "", + "\t\t\t ", + "\t\t}", + "\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t", + "\t\t", + "\t\t", + " }", + " ", + "\tprint(\"checking selection\\n\");", + " ", + " ", + " // check selection - if it's out of 'bounds'", + " if (this.el.editable && sbuf.get_has_selection()) {", + "\t\tGtk.TextIter sel_start_iter, sel_end_iter;", + "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);", + "\t\t", + "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||", + "\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {", + "\t\t\t// save?", + "\t\t\tthis.el.editable = false;", + "\t\t}", + "\t\tif (this.editable_start_pos > 0 &&", + "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)", + "\t\t\t", + "\t\t) {", + "\t\t\tthis.el.editable = false;", + "\t\t}", + "\t\t", + "\t\t ", + " ", + " }", + " ", + " ", + " ", + " ", + " for (var i = 0; i < buf.get_line_count();i++) {", + " if (i < (start_line -1) || i > (end_line -1)) {", + " ", + " sbuf.get_iter_at_line(out iter, i);", + " sbuf.create_source_mark(null, \"grey\", iter);", + " ", " }", - " this.el.get_iter_at_line( out iter, eline);", - " //print(\"mark line\\n\");", - " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);", - " } ", - " return false;", + " ", + " }", + " if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {", + "\t Gtk.TextIter cpos_iter;", + "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);", + "\t\t", + "\t\tbuf.place_cursor(cpos_iter); ", + "\t}", + "", + "", "}" ] } ], - "listeners" : { - "button_press_event" : [ - "() => {", - "\t", - "\t", - "\tthis.button_is_pressed = true;", - "\treturn false;", - "}\t ", - "" - ], - "button_release_event" : [ - "() => {", - "", - "\tprint(\"BUTTON RELEASE EVENT\\n\");", - "\tthis.onCursorChanged();", - "\tthis.button_is_pressed = false;", - "\treturn false;", - "}" - ], - "key_press_event" : [ - "(src, key) => {", - "\tthis.key_is_pressed = true;", - "\t// is it ctrl-G -- find next?", - "\t// which will will still ignore..", - "\t ", - "\tif \t(key.str == \"g\" && key.state == Gdk.ModifierType.CONTROL_MASK) {", - "\t\tthis.key_is_pressed = false;", - "\t}", - "\t", - "\t// if cursor postion is 'at start' of editing range, ", - "\t// and backspace is pressed...", - "\t// block it..", - "\t", - "\t var buf = this.el.get_buffer();", - " //print(\"cursor changed : %d\\n\", buf.cursor_position);", - " ", - "\tif (buf.cursor_position <= this.editable_start_pos && key.keyval == Gdk.Key.BackSpace) {", - "\t\treturn true; // block...", - "\t}", - "\t// what about 'last line of 'grey...'", - "\t// get the buffer - find the line, find the next line ?? see if it's grey?", - "\t", - "\t", - "\tprint(\"KEY PRESS EVENT \\n\");", - "\tthis.onCursorChanged();", - "\treturn false; ", - "}" - ], - "key_release_event" : [ - "() => { ", - "\tthis.key_is_pressed = false;", - "\treturn false;", - "}", - "" - ] - }, - "xtype" : "SourceView", - "| string toString" : [ - "() {", - " Gtk.TextIter s;", - " Gtk.TextIter e;", - " this.el.get_buffer().get_start_iter(out s);", - " this.el.get_buffer().get_end_iter(out e);", - " var ret = this.el.get_buffer().get_text(s,e,true);", - " //print(\"TO STRING? \" + ret);", - " return ret;", - "}", - "" - ], - "| void clearGreySelection" : [ - "() {", - " // clear all the marks..", - " var sbuf = (Gtk.SourceBuffer)this.el.buffer;", - " ", - " Gtk.TextIter start;", - " Gtk.TextIter end; ", - " ", - " sbuf.get_bounds (out start, out end);", - " sbuf.remove_source_marks (start, end, \"grey\");", - " ", - " ", - "}", - "" - ], - "| void highlightErrorsJson" : [ - " (string type, Json.Object obj) {", - " // this is a hook for the vala code - it has no value in javascript ", - " // as we only have one error ususally....", - " return ;", - " ", - " ", - "", - "", - "}" - ], - "| void loadFile" : [ - "( ) {", - " this.loading = true;", - " ", - " ", - " // get the cursor and scroll position....", - " var buf = this.el.get_buffer();", - "\tvar cpos = buf.cursor_position;", - " ", - " print(\"BEFORE LOAD cursor = %d\\n\", cpos);", - " ", - " var vadj_pos = this.el.get_vadjustment().get_value();", - " ", - " ", - " ", - " buf.set_text(\"\",0);", - " var sbuf = (Gtk.SourceBuffer) buf;", - "", - " ", - "", - " if (_this.file == null || _this.file.xtype != \"Roo\") {", - " print(\"xtype != Roo\");", - " this.loading = false;", - " return;", - " }", - " ", - " // get the string from the rendered tree...", - " ", - " var str = _this.file.toSource();", - " ", - "// print(\"setting str %d\\n\", str.length);", - " buf.set_text(str, str.length);", - " var lm = Gtk.SourceLanguageManager.get_default();", - " ", - " //?? is javascript going to work as js?", - " ", - " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));", - " ", - " ", - " Gtk.TextIter start;", - " Gtk.TextIter end; ", - " ", - " sbuf.get_bounds (out start, out end);", - " sbuf.remove_source_marks (start, end, null); // remove all marks..", - " ", - " GLib.Timeout.add(500, () => {", - "", - " print(\"RESORTING cursor to = %d\\n\", cpos);", - "\t\tGtk.TextIter cpos_iter;", - "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);", - "\t\tbuf.place_cursor(cpos_iter); ", - "\t\t", - "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;", - "\t\t", - "", - "\t\tthis.onCursorChanged();", - "\t\t", - "\t\t", - "\t\t_this.buffer.checkSyntax();", - "\t\treturn false;", - "\t});", - "\t\t", - " this.loading = false; ", - " _this.buffer.dirty = false;", - "}", - "" - ], - "| void nodeSelected" : [ - "(JsRender.Node? sel, bool scroll ) {", - " ", - " ", - "\t", - " // this is connected in widnowstate", - "", - "", - "\t// not sure why.... ", - " while(Gtk.events_pending()) {", - " Gtk.main_iteration();", - " }", - " ", - " this.node_selected = sel;", - " ", - " this.updateGreySelection(scroll);", - " ", - " ", - " ", - "}", - "", - " ", - "" - ], - "| void onCursorChanged" : [ - "(/*ParamSpec ps*/) {", - "", - "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {", - "\t\t\treturn;", - "\t\t}", - "", - "\t if (this.loading) {", - " return;", - " }", - " // if (ps.name != \"cursor-position\") {", - " // return;", - " // }", - "", - " var buf = this.el.get_buffer();", - " //print(\"cursor changed : %d\\n\", buf.cursor_position);", - " Gtk.TextIter cpos;", - " buf.get_iter_at_offset(out cpos, buf.cursor_position);", - " ", - " var ln = cpos.get_line();", - " ", - " ", - " // --- select node at line....", - " ", - " var node = _this.file.lineToNode(ln+1);", - " ", - " if (node == null) {", - " print(\"can not find node\\n\");", - " return;", - " }", - " var prop = node.lineToProp(ln+1);", - " print(\"prop : %s\", prop == null ? \"???\" : prop);", - " ", - " ", - " // ---------- this selects the tree's node...", - " ", - " var ltree = _this.main_window.windowstate.left_tree;", - " var tp = ltree.model.treePathFromNode(node);", - " print(\"got tree path %s\\n\", tp);", - " if (tp != \"\") {", - "\t ", - "\t ", - "\t //print(\"changing cursor on tree..\\n\");", - "\t ", - " ", - " ", - " // let's try allowing editing on the methods.", - " // a little klunky at present..", - " this.prop_selected = \"\";", - " if (prop != null) {", - " \t\t//see if we can find it..", - " \t\tvar kv = prop.split(\":\");", - " \t\tif (kv[0] == \"p\") {", - " \t\t", - "\t \t\t//var k = prop.get_key(kv[1]);", - "\t \t\t// fixme -- need to determine if it's an editable property...", - "\t \t\tthis.prop_selected = prop;", - "\t \t\t", - " \t\t} else if (kv[0] == \"l\") {", - " \t\t\t this.prop_selected = prop;", - " \t\t\t", - " \t\t}", - " }", - " ltree.view.setCursor(tp, \"editor\");", - " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ", - " this.nodeSelected(node,false);", - " ", - " // scrolling is disabled... as node selection calls scroll 10ms after it changes.", - " ", - " }", - " ", - " // highlight the node..", - "}", - " " + "xtype" : "ScrolledWindow" + }, + { + "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "bool homogeneous" : false, + "bool vexpand" : false, + "int spacing" : 0, + "items" : [ + { + "$ xns" : "Gtk", + "* init" : [ + "var description = Pango.FontDescription.from_string(\"monospace\");", + "\tdescription.set_size(8000);", + "\t this.el.override_font(description);", + "", + "" + ], + "bool hexpand" : true, + "id" : "search_entry", + "int width_request" : 300, + "listeners" : { + "changed" : [ + "() => {", + "\t/*", + "\tif (this.el.text == \"\") {", + "\t\t_this.search_results.el.hide();", + "\t\treturn;", + "\t}", + "\tvar res = 0;", + "\tswitch(_this.windowstate.state) {", + "\t\tcase WindowState.State.CODEONLY:", + "\t\t///case WindowState.State.CODE:", + "\t\t\t// search the code being edited..", + "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);", + "\t\t\t", + "\t\t\tbreak;", + "\t\tcase WindowState.State.PREVIEW:", + "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", + "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);", + "\t\t\t} else { ", + "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t", + "\t\t\t}", + "\t\t", + "\t\t", + "\t\t\tbreak;", + "\t}", + "\t_this.search_results.el.show();", + "\tif (res > 0) {", + "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t} else {", + "\t\t_this.search_results.el.label = \"No Matches\";", + "\t}", + "\t\t", + "\t*/", + "\t", + "}", + "" + ], + "key_press_event" : [ + "(event) => {", + " ", + " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", + "\t GLib.debug(\"SAVE: ctrl-g pressed\");", + "\t\t_this.forwardSearch(true);", + "\t return true;", + "\t}", + " ", + " ", + " ", + " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {", + "\t\tvar res = _this.search(this.el.text);", + "\t\tif (res > 0) {", + "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t\t} else {", + "\t\t\t_this.search_results.el.label = \"No Matches\";", + "\t\t}", + "\t\t", + "\t return true;", + "", + "\t} ", + " // print(event.key.keyval)", + " ", + " return false;", + "", + "} " + ] + }, + "string placeholder_text" : "Press enter to search", + "xtype" : "SearchEntry", + "| void forwardSearch" : [ + "(bool change_focus) {", + "", + "", + "\t_this.forwardSearch(change_focus);", + "", + "/*", + "", + "\tswitch(_this.windowstate.state) {", + "\t\tcase WindowState.State.CODEONLY:", + "\t\t//case WindowState.State.CODE:", + "\t\t\t// search the code being edited..", + "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);", + "\t\t\t ", + "\t\t\tbreak;", + "\t\tcase WindowState.State.PREVIEW:", + "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {", + "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);", + "\t\t\t} else { ", + "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);", + "\t\t\t}", + "\t\t", + "\t\t\tbreak;", + "\t}", + "\t*/", + "\t", + "}", + "" + ] + }, + { + "$ xns" : "Gtk", + "* pack" : "add", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "add", + "Xcls_ValaCompileErrors popup" : "", + "bool always_show_image" : true, + "id" : "search_results", + "items" : [ + { + "$ xns" : "Gtk", + "* pack" : "set_image", + "bool sensitive" : false, + "utf8 icon_name" : "system-search", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "() => {", + "/*", + " if (this.popup == null) {", + " this.popup = new Xcls_ValaCompileErrors();", + " this.popup.window = _this;", + " }", + " ", + " ", + " this.popup.show(this.notices, this.el);", + " */", + " return true;", + "}" + ] + }, + "string label" : "Matches", + "xtype" : "ImageMenuItem" + } + ], + "xtype" : "MenuBar" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "go-down", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "(event) => {", + "", + "\t_this.forwardSearch(true);", + "\t", + "\treturn true;", + "}", + "" + ] + }, + "string label" : "Next", + "xtype" : "Button" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "go-up", + "xtype" : "Image" + } + ], + "listeners" : { + "button_press_event" : [ + "(event) => {", + "", + "\t_this.backSearch(true);", + "\t", + "\treturn true;", + "}", + "" + ] + }, + "string label" : "Previous", + "xtype" : "Button" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "image", + "string icon_name" : "emblem-system", + "xtype" : "Image" + }, + { + "$ xns" : "Gtk", + "* prop" : "popup", + "id" : "search_settings", + "items" : [ + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "case_sensitive", + "string label" : "Case Sensitive", + "xtype" : "CheckMenuItem" + }, + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "regex", + "string label" : "Regex", + "xtype" : "CheckMenuItem" + }, + { + "$ xns" : "Gtk", + "* init" : [ + "{", + "\tthis.el.show();", + "}", + "" + ], + "id" : "multiline", + "string label" : "Multi-line (add \\n)", + "xtype" : "CheckMenuItem" + } + ], + "xtype" : "Menu" + } + ], + "string label" : "Settings", + "xtype" : "MenuButton" + } ], - "| void updateGreySelection" : [ - "(bool scroll) { ", - "\tvar sel = this.node_selected;", - "\tprint(\"node selected\\n\");", - " var buf = this.el.get_buffer();", - " var sbuf = (Gtk.SourceBuffer) buf;", - "", - " ", - " this.clearGreySelection();", - " ", - " ", - " ", - " if (sel == null) {", - "\t print(\"no selected node\\n\");", - " // no highlighting..", - " return;", - " }", - " ", - " print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);", - " Gtk.TextIter iter; ", - " sbuf.get_iter_at_line(out iter, sel.line_start);", - " ", - " ", - " Gtk.TextIter cur_iter;", - " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);", - " ", - " var cursor_at_line = cur_iter.get_line();", - " ", - " ", - " //var cur_line = cur_iter.get_line();", - " //if (cur_line > sel.line_start && cur_line < sel.line_end) {", - " ", - " //} else {", - " if (scroll) {", - "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");", - " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", - "\t}", - " ", - " var start_line = sel.line_start;", - " var end_line = sel.line_end;", - " ", - " ", - " this.el.editable = false;", - " ", - " //var colon_pos = 0;", - " ", - " this.editable_start_pos = -1;", - " ", - " // now if we have selected a property...", - " if (this.prop_selected.length> 0 ) {", - "", - "\t\tint nstart, nend;", - "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {", - "\t\t\tstart_line = nstart;", - "\t\t\tend_line = nend;", - "\t\t\tthis.el.editable = true;", - "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);", - "\t\t\t", - "\t\t\t\t// see if we are 'right of ':'", - "\t\t\t\t// get an iter for the start of the line.", - "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;", - "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);", - "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);", - "\t\t\t ", - "\t\t\t", - "\t\t\t", - "\t\t\t", - "\t\t\tif (end_first_line_iter.forward_to_line_end()) {", - "\t\t\t\tvar first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);", - "\t\t\t\t", - "\t\t\t\tprint(\"first line = %s\\n\", first_line);", - "\t\t\t\tif (first_line.contains(\":\")) {", - "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;", - "\t\t\t\t\tprint(\"colon_pos = %d\\n\", this.editable_start_pos);", - "\t\t\t\t}", - "\t\t\t\t", - "", - "\t\t\t\t//Gtk.TextIter colon_iter;", - "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);", - "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);", - "\t\t\t}", - "\t\t\t", - "\t\t\t", - "\t\t\t", - "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);", - "\t\t\t//if (start_line - 1 == cursor_at_line) {", - "\t\t\t// should be ok - current_posssion can not be less than '-1'...", - "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {", - "\t\t\t", - "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");", - "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);", - "\t\t\t\t//print(\"before cursor string = %s\\n\", before_cursor_string);", - "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {", - "\t\t\t\t\tthis.el.editable = false;", - "\t\t\t\t//}", - "\t\t\t\t", - "\t\t\t}", - "\t\t\t ", - "\t\t\t ", - "", - "\t\t\t ", - "\t\t}", - "\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t", - "\t\t", - "\t\t", - " }", - " ", - "\tprint(\"checking selection\\n\");", - " ", - " ", - " // check selection - if it's out of 'bounds'", - " if (this.el.editable && sbuf.get_has_selection()) {", - "\t\tGtk.TextIter sel_start_iter, sel_end_iter;", - "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);", - "\t\t", - "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||", - "\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {", - "\t\t\t// save?", - "\t\t\tthis.el.editable = false;", - "\t\t}", - "\t\tif (this.editable_start_pos > 0 &&", - "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)", - "\t\t\t", - "\t\t) {", - "\t\t\tthis.el.editable = false;", - "\t\t}", - "\t\t", - "\t\t ", - " ", - " }", - " ", - " ", - " ", - " ", - " for (var i = 0; i < buf.get_line_count();i++) {", - " if (i < (start_line -1) || i > (end_line -1)) {", - " ", - " sbuf.get_iter_at_line(out iter, i);", - " sbuf.create_source_mark(null, \"grey\", iter);", - " ", - " }", - " ", - " }", - " if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {", - "\t Gtk.TextIter cpos_iter;", - "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);", - "\t\t", - "\t\tbuf.place_cursor(cpos_iter); ", - "\t}", - "", - "", - "}" - ] + "xtype" : "Box" } ], - "xtype" : "ScrolledWindow" + "xtype" : "Box" } ], "xtype" : "Notebook" @@ -1240,22 +1502,65 @@ ], "xtype" : "Box", "| int search" : [ - "(string txt) {", + "(string in_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();", "", - " ", + " ", + " ", + "", + "}", + "" + ], + "| 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.sourceview.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", + " ", "}", "" ], @@ -1309,11 +1614,23 @@ "\t\tthis.sourceview.el.grab_focus();", "\t}", "\tbuf.place_cursor(st);", - "\tvar ln = st.get_line();", - "\tbuf.get_iter_at_line(out stl,ln);", + "\t", + " ", "\t ", - "\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);", + "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);", + "\t", "\t", + "\tvar ln = st.get_line();", + "\t", + "\tthis.highlightNodeAtLine(ln);", + "}\t", + " " + ], + "| void highlightNodeAtLine" : [ + "(int ln) {", + "", + "", + "\t ", "\t// highlight node...", "\t", "\t\t", @@ -1381,7 +1698,7 @@ "\t\t ", "", "}", - "" + " " ], "| void loadFile" : [ "", diff --git a/src/Builder4/WindowRooView.vala b/src/Builder4/WindowRooView.vala index c47571b98..fcc50f7ad 100644 --- a/src/Builder4/WindowRooView.vala +++ b/src/Builder4/WindowRooView.vala @@ -23,13 +23,19 @@ public class Xcls_WindowRooView : Object public Xcls_inspectorcontainer inspectorcontainer; public Xcls_sourceview sourceview; public Xcls_buffer buffer; + public Xcls_search_entry search_entry; + public Xcls_search_results search_results; + public Xcls_search_settings search_settings; + public Xcls_case_sensitive case_sensitive; + public Xcls_regex regex; + public Xcls_multiline multiline; // my vars (def) public Gtk.Widget lastObj; - public int last_search_end; + public Xcls_MainWindow main_window; public Gtk.SourceSearchContext searchcontext; + public int last_search_end; public JsRender.JsRender file; - public Xcls_MainWindow main_window; // ctor public Xcls_WindowRooView() @@ -51,71 +57,6 @@ public class Xcls_WindowRooView : Object } // user defined functions - public void scroll_to_line (int line) { - this.notebook.el.page = 1;// code preview... - - GLib.Timeout.add(500, () => { - - - - - var buf = this.sourceview.el.get_buffer(); - - var sbuf = (Gtk.SourceBuffer) buf; - - - Gtk.TextIter iter; - sbuf.get_iter_at_line(out iter, line); - this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); - return false; - }); - - - } - 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); - this.searchcontext.set_highlight(true); - s.set_search_text(txt); - - Gtk.TextIter beg, st,en; - - buf.get_start_iter(out beg); - this.searchcontext.forward(beg, out st, out en); - this.last_search_end = 0; - return this.searchcontext.get_occurrences_count(); - - - } - public void createThumb () { - - - if (this.file == null) { - return; - } - if (this.notebook.el.page > 0 ) { - return; - } - - var filename = this.file.getIconFileName(false); - - var win = this.el.get_parent_window(); - var width = win.get_width(); - // var height = win.get_height(); - try { - Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.paned.el.position); - screenshot.save(filename,"png"); - } catch(Error e) { - //noop - } - - - - - - } public void loadFile (JsRender.JsRender file) { this.file = file; @@ -124,34 +65,10 @@ public class Xcls_WindowRooView : Object this.sourceview.loadFile(); } - public void requestRedraw () { - this.view.renderJS(false); - this.sourceview.loadFile(); - } - public void forwardSearch (bool change_focus) { + public void highlightNodeAtLine (int ln) { + - if (this.searchcontext == null) { - return; - } - this.notebook.el.page = 1; - Gtk.TextIter beg, st,en, stl; - - var buf = this.sourceview.el.get_buffer(); - buf.get_iter_at_offset(out beg, this.last_search_end); - if (!this.searchcontext.forward(beg, out st, out en)) { - this.last_search_end = 0; - return; - } - this.last_search_end = en.get_offset(); - if (change_focus) { - this.sourceview.el.grab_focus(); - } - buf.place_cursor(st); - var ln = st.get_line(); - buf.get_iter_at_line(out stl,ln); - this.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f); - // highlight node... @@ -218,6 +135,144 @@ public class Xcls_WindowRooView : Object + } + public void requestRedraw () { + this.view.renderJS(false); + this.sourceview.loadFile(); + } + public void forwardSearch (bool change_focus) { + + if (this.searchcontext == null) { + return; + } + this.notebook.el.page = 1; + Gtk.TextIter beg, st,en, stl; + + var buf = this.sourceview.el.get_buffer(); + buf.get_iter_at_offset(out beg, this.last_search_end); + if (!this.searchcontext.forward(beg, out st, out en)) { + this.last_search_end = 0; + return; + } + this.last_search_end = en.get_offset(); + if (change_focus) { + this.sourceview.el.grab_focus(); + } + buf.place_cursor(st); + + + + this.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f); + + + 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.sourceview.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; + + + + 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); + 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; + + 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(); + + + + + } + public void createThumb () { + + + if (this.file == null) { + return; + } + if (this.notebook.el.page > 0 ) { + return; + } + + var filename = this.file.getIconFileName(false); + + var win = this.el.get_parent_window(); + var width = win.get_width(); + // var height = win.get_height(); + try { + Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.paned.el.position); + screenshot.save(filename,"png"); + } catch(Error e) { + //noop + } + + + + + + } + public void scroll_to_line (int line) { + this.notebook.el.page = 1;// code preview... + + GLib.Timeout.add(500, () => { + + + + + var buf = this.sourceview.el.get_buffer(); + + var sbuf = (Gtk.SourceBuffer) buf; + + + Gtk.TextIter iter; + sbuf.get_iter_at_line(out iter, line); + this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f); + return false; + }); + + } public class Xcls_notebook : Object { @@ -244,7 +299,7 @@ public class Xcls_WindowRooView : Object var child_2 = new Xcls_paned( _this ); child_2.ref(); this.el.append_page ( child_2.el , _this.label_preview.el ); - var child_3 = new Xcls_ScrolledWindow14( _this ); + var child_3 = new Xcls_Box14( _this ); child_3.ref(); this.el.append_page ( child_3.el , _this.label_code.el ); } @@ -471,7 +526,7 @@ public class Xcls_WindowRooView : Object //_this.view.renderJS(true); FakeServerCache.clear(); _this.view.reInit(); - + }); } @@ -516,14 +571,14 @@ public class Xcls_WindowRooView : Object // my vars (def) - public string renderedData; - public bool refreshRequired; public WebKit.WebInspector inspector; - public string runjs; + public bool pendingRedraw; public int redraws; - public GLib.DateTime lastRedraw; + public bool refreshRequired; + public string runjs; public string runhtml; - public bool pendingRedraw; + public string renderedData; + public GLib.DateTime lastRedraw; // ctor public Xcls_view(Xcls_WindowRooView _owner ) @@ -533,13 +588,13 @@ public class Xcls_WindowRooView : Object this.el = new WebKit.WebView(); // my vars (dec) - this.renderedData = ""; + this.pendingRedraw = false; + this.redraws = 0; this.refreshRequired = false; this.runjs = ""; - this.redraws = 0; - this.lastRedraw = null; this.runhtml = ""; - this.pendingRedraw = false; + this.renderedData = ""; + this.lastRedraw = null; // set gobject values @@ -666,32 +721,123 @@ public class Xcls_WindowRooView : Object } // user defined functions - public void reInit () { - print("reInit?"); - // if this happens destroy the webkit.. - // recreate it.. - this.el.stop_loading(); - - if (_this.viewbox.el.get_parent() == null) { + public void initInspector () { + + /* if (this.inspector == this.el.get_inspector()) { + this.inspector.show(); + this.inspector.open_window(); + print("init inspecter called, and inspector is the same as existing\n"); return; - } - - - _this.viewbox.el.remove(_this.viewcontainer.el); - _this.paned.el.remove(_this.inspectorcontainer.el); - - // destory seems to cause problems. - //this.el.destroy(); - //_this.viewcontainer.el.destroy(); - //_this.inspectorcontainer.el.destroy(); - var inv =new Xcls_inspectorcontainer(_this); - inv.ref(); - _this.paned.el.pack2(inv.el,true,true); - - - this.el = null; - var nv =new Xcls_viewcontainer(_this); - nv.ref(); + } + print("new inspector?\n"); + */ + this.inspector = this.el.get_inspector(); + this.inspector.ref(); + + // got a new inspector... + + this.inspector.open_window.connect(() => { + this.inspector = this.el.get_inspector(); + print("inspector attach\n"); + var wv = this.inspector.get_web_view(); + if (wv != null) { + print("got inspector web view\n"); + + var cn = _this.inspectorcontainer.el.get_child(); + if (cn != null) { + _this.inspectorcontainer.el.remove(cn); + } + + _this.inspectorcontainer.el.add(wv); + wv.show(); + } else { + //this.inspector.close(); + + //this.inspector = null; + + + } + return true; + + }); + /* + this.inspector.closed.connect(() => { + print("inspector closed?!?"); + // if this happens destroy the webkit.. + // recreate it.. + this.el.stop_loading(); + + if (_this.viewbox.el.get_parent() == null) { + return; + } + + + _this.viewbox.el.remove(_this.viewcontainer.el); + _this.el.remove(_this.inspectorcontainer.el); + + // destory seems to cause problems. + //this.el.destroy(); + //_this.viewcontainer.el.destroy(); + //_this.inspectorcontainer.el.destroy(); + + this.el = null; + var nv =new Xcls_viewcontainer(_this); + nv.ref(); + _this.viewbox.el.pack_end(nv.el,true,true,0); + + var inv =new Xcls_inspectorcontainer(_this); + inv.ref(); + _this.el.pack2(inv.el,true,true); + + inv.el.show_all(); + nv.el.show_all(); + //while(Gtk.events_pending ()) Gtk.main_iteration (); + //_this.view.renderJS(true); + _this.view.refreshRequired = true; + + }); + */ + + this.inspector.show(); + } + public void renderJS (bool force) { + + // this is the public redraw call.. + // we refresh in a loop privately.. + var autodraw = _this.AutoRedraw.el.active; + if (!autodraw && !force) { + print("Skipping redraw - no force, and autodraw off"); + return; + } + + this.refreshRequired = true; + } + public void reInit () { + print("reInit?"); + // if this happens destroy the webkit.. + // recreate it.. + this.el.stop_loading(); + + if (_this.viewbox.el.get_parent() == null) { + return; + } + + + _this.viewbox.el.remove(_this.viewcontainer.el); + _this.paned.el.remove(_this.inspectorcontainer.el); + + // destory seems to cause problems. + //this.el.destroy(); + //_this.viewcontainer.el.destroy(); + //_this.inspectorcontainer.el.destroy(); + var inv =new Xcls_inspectorcontainer(_this); + inv.ref(); + _this.paned.el.pack2(inv.el,true,true); + + + this.el = null; + var nv =new Xcls_viewcontainer(_this); + nv.ref(); _this.viewbox.el.pack_end(nv.el,true,true,0); @@ -843,97 +989,6 @@ public class Xcls_WindowRooView : Object // print( "after render" + (new Date())); } - public void initInspector () { - - /* if (this.inspector == this.el.get_inspector()) { - this.inspector.show(); - this.inspector.open_window(); - print("init inspecter called, and inspector is the same as existing\n"); - return; - } - print("new inspector?\n"); - */ - this.inspector = this.el.get_inspector(); - this.inspector.ref(); - - // got a new inspector... - - this.inspector.open_window.connect(() => { - this.inspector = this.el.get_inspector(); - print("inspector attach\n"); - var wv = this.inspector.get_web_view(); - if (wv != null) { - print("got inspector web view\n"); - - var cn = _this.inspectorcontainer.el.get_child(); - if (cn != null) { - _this.inspectorcontainer.el.remove(cn); - } - - _this.inspectorcontainer.el.add(wv); - wv.show(); - } else { - //this.inspector.close(); - - //this.inspector = null; - - - } - return true; - - }); - /* - this.inspector.closed.connect(() => { - print("inspector closed?!?"); - // if this happens destroy the webkit.. - // recreate it.. - this.el.stop_loading(); - - if (_this.viewbox.el.get_parent() == null) { - return; - } - - - _this.viewbox.el.remove(_this.viewcontainer.el); - _this.el.remove(_this.inspectorcontainer.el); - - // destory seems to cause problems. - //this.el.destroy(); - //_this.viewcontainer.el.destroy(); - //_this.inspectorcontainer.el.destroy(); - - this.el = null; - var nv =new Xcls_viewcontainer(_this); - nv.ref(); - _this.viewbox.el.pack_end(nv.el,true,true,0); - - var inv =new Xcls_inspectorcontainer(_this); - inv.ref(); - _this.el.pack2(inv.el,true,true); - - inv.el.show_all(); - nv.el.show_all(); - //while(Gtk.events_pending ()) Gtk.main_iteration (); - //_this.view.renderJS(true); - _this.view.refreshRequired = true; - - }); - */ - - this.inspector.show(); - } - public void renderJS (bool force) { - - // this is the public redraw call.. - // we refresh in a loop privately.. - var autodraw = _this.AutoRedraw.el.active; - if (!autodraw && !force) { - print("Skipping redraw - no force, and autodraw off"); - return; - } - - this.refreshRequired = true; - } } @@ -967,7 +1022,34 @@ public class Xcls_WindowRooView : Object } - public class Xcls_ScrolledWindow14 : Object + public class Xcls_Box14 : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Box14(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_ScrolledWindow15( _this ); + child_0.ref(); + this.el.add( child_0.el ); + var child_1 = new Xcls_Box18( _this ); + child_1.ref(); + this.el.add( child_1.el ); + } + + // user defined functions + } + public class Xcls_ScrolledWindow15 : Object { public Gtk.ScrolledWindow el; private Xcls_WindowRooView _this; @@ -976,7 +1058,7 @@ public class Xcls_WindowRooView : Object // my vars (def) // ctor - public Xcls_ScrolledWindow14(Xcls_WindowRooView _owner ) + public Xcls_ScrolledWindow15(Xcls_WindowRooView _owner ) { _this = _owner; this.el = new Gtk.ScrolledWindow( null, null ); @@ -984,6 +1066,7 @@ public class Xcls_WindowRooView : Object // my vars (dec) // set gobject values + this.el.vexpand = true; var child_0 = new Xcls_sourceview( _this ); child_0.ref(); this.el.add ( child_0.el ); @@ -998,12 +1081,12 @@ public class Xcls_WindowRooView : Object // my vars (def) - public bool button_is_pressed; - public JsRender.Node? node_selected; public bool loading; public int editable_start_pos; + public bool button_is_pressed; public string prop_selected; public bool key_is_pressed; + public JsRender.Node? node_selected; // ctor public Xcls_sourceview(Xcls_WindowRooView _owner ) @@ -1013,12 +1096,12 @@ public class Xcls_WindowRooView : Object this.el = new Gtk.SourceView(); // my vars (dec) - this.button_is_pressed = false; - this.node_selected = null; this.loading = true; this.editable_start_pos = -1; + this.button_is_pressed = false; this.prop_selected = ""; this.key_is_pressed = false; + this.node_selected = null; // set gobject values this.el.editable = false; @@ -1104,38 +1187,21 @@ public class Xcls_WindowRooView : Object this.button_is_pressed = false; return false; }); - this.el.button_press_event.connect( () => { - - + this.el.button_press_event.connect( ( ) => { + this.button_is_pressed = true; return false; }); - this.el.key_press_event.connect( (src, key) => { - this.key_is_pressed = true; - // is it ctrl-G -- find next? - // which will will still ignore.. - - if (key.str == "g" && key.state == Gdk.ModifierType.CONTROL_MASK) { - this.key_is_pressed = false; - } - - // if cursor postion is 'at start' of editing range, - // and backspace is pressed... - // block it.. + this.el.key_press_event.connect( (event) => { - var buf = this.el.get_buffer(); - //print("cursor changed : %d\n", buf.cursor_position); - - if (buf.cursor_position <= this.editable_start_pos && key.keyval == Gdk.Key.BackSpace) { - return true; // block... + if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; } - // what about 'last line of 'grey...' - // get the buffer - find the line, find the next line ?? see if it's grey? - - - print("KEY PRESS EVENT \n"); - this.onCursorChanged(); - return false; + + this.button_is_pressed = true; + return false; }); this.el.key_release_event.connect( () => { this.key_is_pressed = false; @@ -1144,18 +1210,70 @@ public class Xcls_WindowRooView : Object } // user defined functions - public void clearGreySelection () { - // clear all the marks.. - var sbuf = (Gtk.SourceBuffer)this.el.buffer; - - Gtk.TextIter start; - Gtk.TextIter end; - - sbuf.get_bounds (out start, out end); - sbuf.remove_source_marks (start, end, "grey"); + public void loadFile ( ) { + this.loading = true; - } + // get the cursor and scroll position.... + var buf = this.el.get_buffer(); + var cpos = buf.cursor_position; + + print("BEFORE LOAD cursor = %d\n", cpos); + + var vadj_pos = this.el.get_vadjustment().get_value(); + + + + buf.set_text("",0); + var sbuf = (Gtk.SourceBuffer) buf; + + + + if (_this.file == null || _this.file.xtype != "Roo") { + print("xtype != Roo"); + this.loading = false; + return; + } + + // get the string from the rendered tree... + + var str = _this.file.toSource(); + + // print("setting str %d\n", str.length); + buf.set_text(str, str.length); + var lm = Gtk.SourceLanguageManager.get_default(); + + //?? is javascript going to work as js? + + ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language)); + + + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, null); // remove all marks.. + + GLib.Timeout.add(500, () => { + + print("RESORTING cursor to = %d\n", cpos); + Gtk.TextIter cpos_iter; + buf.get_iter_at_offset(out cpos_iter, cpos); + buf.place_cursor(cpos_iter); + + this.el.get_vadjustment().set_value(vadj_pos);; + + + this.onCursorChanged(); + + + _this.buffer.checkSyntax(); + return false; + }); + + this.loading = false; + _this.buffer.dirty = false; + } public void onCursorChanged (/*ParamSpec ps*/) { if (!this.key_is_pressed && !this.button_is_pressed) { @@ -1228,15 +1346,6 @@ public class Xcls_WindowRooView : Object // highlight the node.. } - public string toString () { - Gtk.TextIter s; - Gtk.TextIter e; - this.el.get_buffer().get_start_iter(out s); - this.el.get_buffer().get_end_iter(out e); - var ret = this.el.get_buffer().get_text(s,e,true); - //print("TO STRING? " + ret); - return ret; - } public void nodeSelected (JsRender.Node? sel, bool scroll ) { @@ -1255,70 +1364,6 @@ 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; - - print("BEFORE LOAD cursor = %d\n", cpos); - - var vadj_pos = this.el.get_vadjustment().get_value(); - - - - buf.set_text("",0); - var sbuf = (Gtk.SourceBuffer) buf; - - - - if (_this.file == null || _this.file.xtype != "Roo") { - print("xtype != Roo"); - this.loading = false; - return; - } - - // get the string from the rendered tree... - - var str = _this.file.toSource(); - - // print("setting str %d\n", str.length); - buf.set_text(str, str.length); - var lm = Gtk.SourceLanguageManager.get_default(); - - //?? is javascript going to work as js? - - ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language)); - - - Gtk.TextIter start; - Gtk.TextIter end; - - sbuf.get_bounds (out start, out end); - sbuf.remove_source_marks (start, end, null); // remove all marks.. - - GLib.Timeout.add(500, () => { - - print("RESORTING cursor to = %d\n", cpos); - Gtk.TextIter cpos_iter; - buf.get_iter_at_offset(out cpos_iter, cpos); - buf.place_cursor(cpos_iter); - - this.el.get_vadjustment().set_value(vadj_pos);; - - - this.onCursorChanged(); - - - _this.buffer.checkSyntax(); - return false; - }); - - this.loading = false; - _this.buffer.dirty = false; } public void updateGreySelection (bool scroll) { var sel = this.node_selected; @@ -1479,6 +1524,27 @@ public class Xcls_WindowRooView : Object + } + public string toString () { + Gtk.TextIter s; + Gtk.TextIter e; + this.el.get_buffer().get_start_iter(out s); + this.el.get_buffer().get_end_iter(out e); + var ret = this.el.get_buffer().get_text(s,e,true); + //print("TO STRING? " + ret); + return ret; + } + public void clearGreySelection () { + // clear all the marks.. + var sbuf = (Gtk.SourceBuffer)this.el.buffer; + + Gtk.TextIter start; + Gtk.TextIter end; + + sbuf.get_bounds (out start, out end); + sbuf.remove_source_marks (start, end, "grey"); + + } } public class Xcls_buffer : Object @@ -1488,8 +1554,8 @@ public class Xcls_WindowRooView : Object // my vars (def) - public bool dirty; public int error_line; + public bool dirty; // ctor public Xcls_buffer(Xcls_WindowRooView _owner ) @@ -1499,8 +1565,8 @@ public class Xcls_WindowRooView : Object this.el = new Gtk.SourceBuffer( null ); // my vars (dec) - this.dirty = false; this.error_line = -1; + this.dirty = false; // set gobject values @@ -1581,30 +1647,7 @@ public class Xcls_WindowRooView : Object } // user defined functions - public bool highlightErrors ( Gee.HashMap validate_res) { - - this.error_line = validate_res.size; - - if (this.error_line < 1) { - return true; - } - var tlines = this.el.get_line_count (); - Gtk.TextIter iter; - var valiter = validate_res.map_iterator(); - while (valiter.next()) { - - // print("get inter\n"); - var eline = valiter.get_key(); - if (eline > tlines) { - continue; - } - this.el.get_iter_at_line( out iter, eline); - //print("mark line\n"); - this.el.create_source_mark(valiter.get_value(), "ERR", iter); - } - return false; - } - public bool checkSyntax () { + public bool checkSyntax () { var str = this.toString(); @@ -1646,7 +1689,30 @@ public class Xcls_WindowRooView : Object ); } - public string toString () { + public bool highlightErrors ( Gee.HashMap validate_res) { + + this.error_line = validate_res.size; + + if (this.error_line < 1) { + return true; + } + var tlines = this.el.get_line_count (); + Gtk.TextIter iter; + var valiter = validate_res.map_iterator(); + while (valiter.next()) { + + // print("get inter\n"); + var eline = valiter.get_key(); + if (eline > tlines) { + continue; + } + this.el.get_iter_at_line( out iter, eline); + //print("mark line\n"); + this.el.create_source_mark(valiter.get_value(), "ERR", iter); + } + return false; + } + public string toString () { Gtk.TextIter s; Gtk.TextIter e; @@ -1660,5 +1726,548 @@ public class Xcls_WindowRooView : Object + public class Xcls_Box18 : Object + { + public Gtk.Box el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Box18(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + this.el.vexpand = false; + var child_0 = new Xcls_search_entry( _this ); + child_0.ref(); + this.el.add( child_0.el ); + var child_1 = new Xcls_MenuBar20( _this ); + child_1.ref(); + this.el.add ( child_1.el ); + var child_2 = new Xcls_Button23( _this ); + child_2.ref(); + this.el.add( child_2.el ); + var child_3 = new Xcls_Button25( _this ); + child_3.ref(); + this.el.add( child_3.el ); + var child_4 = new Xcls_MenuButton27( _this ); + child_4.ref(); + this.el.add( child_4.el ); + } + + // user defined functions + } + public class Xcls_search_entry : Object + { + public Gtk.SearchEntry el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_search_entry(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.search_entry = this; + this.el = new Gtk.SearchEntry(); + + // my vars (dec) + + // set gobject values + this.el.width_request = 300; + this.el.hexpand = true; + this.el.placeholder_text = "Press enter to search"; + + // init method + + var description = Pango.FontDescription.from_string("monospace"); + description.set_size(8000); + this.el.override_font(description); + + //listeners + this.el.key_press_event.connect( (event) => { + + if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { + GLib.debug("SAVE: ctrl-g pressed"); + _this.forwardSearch(true); + return true; + } + + + + if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) { + var res = _this.search(this.el.text); + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + } else { + _this.search_results.el.label = "No Matches"; + } + + return true; + + } + // print(event.key.keyval) + + return false; + + }); + this.el.changed.connect( () => { + /* + if (this.el.text == "") { + _this.search_results.el.hide(); + return; + } + var res = 0; + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + ///case WindowState.State.CODE: + // search the code being edited.. + res = _this.windowstate.code_editor_tab.search(this.el.text); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + res = _this.windowstate.window_gladeview.search(this.el.text); + } else { + res = _this.windowstate.window_rooview.search(this.el.text); + } + + + break; + } + _this.search_results.el.show(); + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + } else { + _this.search_results.el.label = "No Matches"; + } + + */ + + }); + } + + // user defined functions + public void forwardSearch (bool change_focus) { + + + _this.forwardSearch(change_focus); + + /* + + switch(_this.windowstate.state) { + case WindowState.State.CODEONLY: + //case WindowState.State.CODE: + // search the code being edited.. + _this.windowstate.code_editor_tab.forwardSearch(change_focus); + + break; + case WindowState.State.PREVIEW: + if (_this.windowstate.file.xtype == "Gtk") { + _this.windowstate.window_gladeview.forwardSearch(change_focus); + } else { + _this.windowstate.window_rooview.forwardSearch(change_focus); + } + + break; + } + */ + + } + } + + public class Xcls_MenuBar20 : Object + { + public Gtk.MenuBar el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_MenuBar20(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.MenuBar(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_search_results( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + } + + // user defined functions + } + public class Xcls_search_results : Object + { + public Gtk.ImageMenuItem el; + private Xcls_WindowRooView _this; + + + // my vars (def) + public Xcls_ValaCompileErrors popup; + + // ctor + public Xcls_search_results(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.search_results = this; + this.el = new Gtk.ImageMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Matches"; + var child_0 = new Xcls_Image22( _this ); + child_0.ref(); + this.el.set_image ( child_0.el ); + + //listeners + this.el.button_press_event.connect( () => { + /* + if (this.popup == null) { + this.popup = new Xcls_ValaCompileErrors(); + this.popup.window = _this; + } + + + this.popup.show(this.notices, this.el); + */ + return true; + }); + } + + // user defined functions + } + public class Xcls_Image22 : Object + { + public Gtk.Image el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Image22(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "system-search"; + this.el.sensitive = false; + } + + // user defined functions + } + + + + public class Xcls_Button23 : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Button23(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Next"; + var child_0 = new Xcls_Image24( _this ); + child_0.ref(); + this.el.image = child_0.el; + + //listeners + this.el.button_press_event.connect( (event) => { + + _this.forwardSearch(true); + + return true; + }); + } + + // user defined functions + } + public class Xcls_Image24 : Object + { + public Gtk.Image el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Image24(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-down"; + } + + // user defined functions + } + + + public class Xcls_Button25 : Object + { + public Gtk.Button el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Button25(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Button(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Previous"; + var child_0 = new Xcls_Image26( _this ); + child_0.ref(); + this.el.image = child_0.el; + + //listeners + this.el.button_press_event.connect( (event) => { + + _this.backSearch(true); + + return true; + }); + } + + // user defined functions + } + public class Xcls_Image26 : Object + { + public Gtk.Image el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Image26(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "go-up"; + } + + // user defined functions + } + + + public class Xcls_MenuButton27 : Object + { + public Gtk.MenuButton el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_MenuButton27(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.MenuButton(); + + // my vars (dec) + + // set gobject values + this.el.always_show_image = true; + this.el.label = "Settings"; + var child_0 = new Xcls_Image28( _this ); + child_0.ref(); + this.el.image = child_0.el; + var child_1 = new Xcls_search_settings( _this ); + child_1.ref(); + this.el.popup = child_1.el; + } + + // user defined functions + } + public class Xcls_Image28 : Object + { + public Gtk.Image el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_Image28(Xcls_WindowRooView _owner ) + { + _this = _owner; + this.el = new Gtk.Image(); + + // my vars (dec) + + // set gobject values + this.el.icon_name = "emblem-system"; + } + + // user defined functions + } + + public class Xcls_search_settings : Object + { + public Gtk.Menu el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_search_settings(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.search_settings = this; + this.el = new Gtk.Menu(); + + // my vars (dec) + + // set gobject values + var child_0 = new Xcls_case_sensitive( _this ); + child_0.ref(); + this.el.append( child_0.el ); + var child_1 = new Xcls_regex( _this ); + child_1.ref(); + this.el.append( child_1.el ); + var child_2 = new Xcls_multiline( _this ); + child_2.ref(); + this.el.append( child_2.el ); + } + + // user defined functions + } + public class Xcls_case_sensitive : Object + { + public Gtk.CheckMenuItem el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_case_sensitive(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.case_sensitive = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Case Sensitive"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + public class Xcls_regex : Object + { + public Gtk.CheckMenuItem el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_regex(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.regex = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Regex"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + public class Xcls_multiline : Object + { + public Gtk.CheckMenuItem el; + private Xcls_WindowRooView _this; + + + // my vars (def) + + // ctor + public Xcls_multiline(Xcls_WindowRooView _owner ) + { + _this = _owner; + _this.multiline = this; + this.el = new Gtk.CheckMenuItem(); + + // my vars (dec) + + // set gobject values + this.el.label = "Multi-line (add \\n)"; + + // init method + + { + this.el.show(); + } + } + + // user defined functions + } + + + + + } diff --git a/src/Builder4/WindowState.vala b/src/Builder4/WindowState.vala index c75747612..14f24b8ff 100644 --- a/src/Builder4/WindowState.vala +++ b/src/Builder4/WindowState.vala @@ -95,7 +95,7 @@ public class WindowState : Object this.win.statusbar_compilestatus_label.el.hide(); this.win.statusbar_run.el.hide(); - this.win.search_results.el.hide(); + this.popover_files = new Xcls_PopoverFiles(); this.popover_files.setMainWindow(this.win); @@ -135,7 +135,7 @@ public class WindowState : Object if (this.file.xtype == "Roo") { this.window_rooview.sourceview.nodeSelected(sel,true); // foce scroll. } else { - this.window_gladeview.sourceview.nodeSelected(sel); + this.window_gladeview.sourceview.nodeSelected(sel, true); } }); @@ -853,8 +853,7 @@ public class WindowState : Object - this.win.search_entry.el.hide(); - this.win.search_results.el.hide(); + switch (this.state) { case State.PREVIEW: // this is the default state when working... @@ -863,7 +862,7 @@ public class WindowState : Object - this.win.search_entry.el.show(); + // this.win.openbtn.el.show(); @@ -871,7 +870,7 @@ public class WindowState : Object case State.CODEONLY: // this.win.openbtn.el.show(); - this.win.search_entry.el.show(); + break;