{
"build_module" : "builder",
+ "gen_extended" : false,
"items" : [
{
"# Gtk.Widget lastObj" : "null",
+ "# GtkSource.SearchContext searchcontext" : "",
"# JsRender.JsRender file" : "null",
"# Xcls_MainWindow main_window" : "",
"$ xns" : "Gtk",
+ "* init" : [
+ "{",
+ "",
+ "\tthis.css = new Gtk.CssProvider();",
+ "\t ",
+ "\tthis.css.load_from_string(",
+ "\t\t\"#gtkview-view-layout { background-color: #ccc; }\"",
+ "\t);",
+ "\t ",
+ "\tGtk.StyleContext.add_provider_for_display(",
+ "\t\tthis.el.get_display(),",
+ "\t\tthis.css,",
+ "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
+ "\t);",
+ "\t\t",
+ " ",
+ "}",
+ ""
+ ],
+ "Gtk.CssProvider css" : "",
"Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
- "Gtk.SourceSearchContext searchcontext" : "",
"bool hexpand" : true,
"bool vexpand" : true,
"id" : "GtkView",
- "int height" : 0,
"int last_search_end" : 0,
- "int width" : 0,
"items" : [
{
"$ xns" : "Gtk",
- "* pack" : "pack_start,true,true,0",
+ "Gtk.Overflow overflow" : "Gtk.Overflow.VISIBLE",
"id" : "notebook",
"items" : [
{
"items" : [
{
"$ xns" : "Gtk",
- "* pack" : "add",
+ "* pack" : "set_child",
"id" : "view_layout",
"items" : [
{
"xtype" : "Box"
}
],
- "xtype" : "Layout"
+ "string name" : "gtkview-view-layout",
+ "xtype" : "Fixed"
}
],
"xtype" : "ScrolledWindow"
{
"$ 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,
+ "id" : "sourceviewscroll",
+ "items" : [
+ {
+ "# JsRender.Node? node_selected" : "",
+ "# string prop_selected" : "\"\"",
+ "$ xns" : "GtkSource",
+ "* init" : [
+ "{",
+ " ",
+ " ",
+ " \tthis.css = new Gtk.CssProvider();",
+ "\t ",
+ "\tthis.css.load_from_string(\"#gtkview-view { font: 10px monospace ;}\");",
+ "\t ",
+ "\tGtk.StyleContext.add_provider_for_display(",
+ "\t\tthis.el.get_display(),",
+ "\t\tthis.css,",
+ "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
+ "\t);",
+ "\t\t",
+ "\t\t ",
+ " this.loading = true;",
+ " ",
+ " ",
+ " ",
+ " var attrs = new GtkSource.MarkAttributes();",
+ " 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 GtkSource.MarkAttributes();",
+ " 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 GtkSource.MarkAttributes();",
+ " 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 GtkSource.MarkAttributes();",
+ " var grey = Gdk.RGBA();",
+ " grey.parse ( \"#ccc\");",
+ " gattrs.set_background ( grey);",
+ " ",
+ " ",
+ " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ "}",
+ " "
+ ],
+ "* pack" : "set_child",
+ "Gtk.CssProvider css" : "",
+ "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" : "GtkSource",
+ "* pack" : "set_buffer",
+ "bool dirty" : false,
+ "id" : "buffer",
+ "int error_line" : "-1",
+ "listeners" : {
+ "notify[\"cursor_position\"]" : [
+ "() => {",
+ "",
+ "",
+ " if (_this.sourceview.loading) {",
+ " return;",
+ " }",
+ " ",
+ " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
+ " Gtk.TextIter cpos;",
+ " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
+ " ",
+ " var ln = cpos.get_line();",
+ "",
+ " var node = _this.file.lineToNode(ln);",
+ "",
+ " if (node == null) {",
+ " print(\"can not find node\\n\");",
+ " return;",
+ " }",
+ " _this.sourceview.loading = true;",
+ " var ltree = _this.main_window.windowstate.left_tree;",
+ " ltree.model.selectNode(node);",
+ " _this.sourceview.loading = false;",
+ " ",
+ " //print(\"got tree path %s\\n\", tp);",
+ " //if (tp != \"\") {",
+ " // this.allow_node_scroll = false; ",
+ " // 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 , () => {",
+ " // this.allow_node_scroll = true;",
+ " // return false;",
+ " // });",
+ " // }",
+ " ",
+ " // highlight the node..",
+ " ",
+ " ",
+ "",
+ " }"
+ ]
+ },
+ "xtype" : "Buffer"
+ },
+ {
+ "$ xns" : "Gtk",
+ "listeners" : {
+ "key_pressed" : [
+ "(keyval, keycode, state) => {",
+ "",
+ "\t",
+ "\t ",
+ "\t if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
+ "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
+ "\t\t_this.forwardSearch(true);",
+ "\t return true;",
+ "\t}",
+ " if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
+ "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
+ "\t\t_this.search_entry.el.grab_focus();",
+ "\t return true;",
+ "\t}",
+ "\t ",
+ "\treturn false;",
+ "}\t ",
+ "\t"
+ ]
+ },
+ "xtype" : "EventControllerKey"
+ }
+ ],
+ "listeners" : {
+ "query_tooltip" : [
+ "(x, y, keyboard_tooltip, tooltip) => {",
+ "\t",
+ "\t//GLib.debug(\"query tooltip\");",
+ "\tGtk.TextIter iter;",
+ "\tint trailing;",
+ "\t",
+ "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
+ "\t",
+ "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
+ "\t ",
+ "\tvar l = iter.get_line();",
+ "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
+ "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
+ "\tif (marks.is_empty()) {",
+ "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
+ "\t}",
+ "\tif (marks.is_empty()) {",
+ "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
+ "\t}",
+ "\t",
+ "\t// GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
+ "\tvar str = \"\";",
+ "\tmarks.@foreach((m) => { ",
+ "\t\t//GLib.debug(\"got mark %s\", m.name);",
+ "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
+ "\t});",
+ "\t",
+ "\t// true if there is a mark..",
+ "\ttooltip.set_text( str);",
+ "\treturn str.length > 0 ? true : false;",
+ "",
+ "}",
+ ""
+ ]
+ },
+ "string name" : "gtkview-view",
+ "xtype" : "View",
+ "| 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 loadFile" : [
+ "( ) {",
+ " this.loading = true;",
+ " var buf = this.el.get_buffer();",
+ " buf.set_text(\"\",0);",
+ " var sbuf = (GtkSource.Buffer) 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 = GtkSource.LanguageManager.get_default();",
+ " ",
+ " //?? is javascript going to work as js?",
+ " ",
+ " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
+ " ",
+ " ",
+ " _this.main_window.windowstate.updateErrorMarksAll(); ",
+ " ",
+ " ",
+ " ",
+ " this.loading = false; ",
+ "}",
+ ""
+ ],
+ "| void nodeSelected" : [
+ "(JsRender.Node? sel, bool scroll) {",
+ " ",
+ " ",
+ " if (this.loading) {",
+ " \treturn;",
+ "\t}",
+ " // this is connected in widnowstate",
+ " print(\"Roo-view - node selected\\n\");",
+ " var buf = this.el.get_buffer();",
+ " ",
+ " var sbuf = (GtkSource.Buffer) 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" : [
+ " ",
+ "this.css = new Gtk.CssProvider();",
+ "",
+ "this.css.load_from_string(\"",
+ "\t#gtkview-search-entry { font: 10px monospace ;}\"",
+ ");",
+ "",
+ "Gtk.StyleContext.add_provider_for_display(",
+ "\tthis.el.get_display(),",
+ "\tthis.css,",
+ "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
+ ");",
+ "\t\t",
+ "",
+ ""
+ ],
+ "Gtk.CssProvider css" : "",
+ "bool hexpand" : true,
+ "id" : "search_entry",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "listeners" : {
+ "key_pressed" : [
+ "(keyval, keycode, state) => {",
+ "",
+ "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
+ "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
+ "\t\t_this.forwardSearch(true);",
+ "\t return true;",
+ "\t}",
+ " ",
+ " ",
+ " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
+ "\t\t_this.forwardSearch(true);",
+ "\t\t",
+ "\t\t",
+ "\t return true;",
+ "",
+ "\t} ",
+ " // print(event.key.keyval)",
+ " ",
+ " return false;",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "EventControllerKey"
+ }
+ ],
+ "listeners" : {
+ "search_changed" : [
+ " () => {",
+ " \t ",
+ "\t_this.search(_this.search_entry.el.text);",
+ "\t _this.search_results.updateResults();",
+ "",
+ "\tGLib.Timeout.add_seconds(1,() => {",
+ "\t\t _this.search_results.updateResults();",
+ "\t\t return false;",
+ "\t });",
+ "\t ",
+ " ",
+ " ",
+ "}"
+ ]
+ },
+ "string name" : "gtkview-search-entry",
+ "string placeholder_text" : "Press enter to search",
+ "uint search_delay" : 3,
+ "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",
+ "id" : "search_results",
+ "int margin_end" : 4,
+ "int margin_start" : 4,
+ "string label" : "No Results",
+ "xtype" : "Label",
+ "| void updateResults" : [
+ "() {",
+ "\tthis.el.visible = true;",
+ "\t",
+ "\tvar res = _this.searchcontext.get_occurrences_count();",
+ "\tif (res < 0) {",
+ "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
+ "\t\treturn;",
+ "\t}",
+ "",
+ "\t_this.nextBtn.el.sensitive = false;",
+ "\t_this.backBtn.el.sensitive = false;\t",
+ "",
+ "\tif (res > 0) {",
+ "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
+ "\t\t_this.nextBtn.el.sensitive = true;",
+ "\t\t_this.backBtn.el.sensitive = true;",
+ "\t\treturn;",
+ "\t} ",
+ "\t_this.search_results.el.label = \"No Matches\";",
+ "\t",
+ "}"
+ ]
+ },
+ {
+ "$ xns" : "Gtk",
+ "bool always_show_image" : true,
+ "bool sensitive" : false,
+ "id" : "nextBtn",
+ "listeners" : {
+ "clicked" : [
+ "( ) => {",
+ "_this.forwardSearch(true);",
+ "\t ",
+ "",
+ "}",
+ ""
+ ]
+ },
+ "string icon_name" : "go-down",
+ "xtype" : "Button"
+ },
+ {
+ "$ xns" : "Gtk",
+ "bool always_show_image" : true,
+ "bool sensitive" : false,
+ "id" : "backBtn",
+ "listeners" : {
+ "clicked" : [
+ "( ) => {",
+ "",
+ "_this.backSearch(true);",
+ "\t",
+ "}",
+ ""
+ ]
+ },
+ "string icon_name" : "go-up",
+ "xtype" : "Button"
+ },
+ {
+ "$ xns" : "Gtk",
+ "bool always_show_arrow" : true,
+ "bool always_show_image" : true,
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "* ctor" : "new Gtk.PopoverMenu.from_model(null)",
+ "* prop" : "popover",
+ "id" : "search_settings",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "set_child",
+ "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+ "int spacing" : 0,
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "id" : "case_sensitive",
+ "string label" : "Case Sensitive",
+ "xtype" : "CheckButton"
+ },
+ {
+ "$ xns" : "Gtk",
+ "id" : "regex",
+ "string label" : "Regex",
+ "xtype" : "CheckButton"
+ },
+ {
+ "$ xns" : "Gtk",
+ "id" : "multiline",
+ "string label" : "Multi-line (add \\n)",
+ "xtype" : "CheckButton"
+ }
+ ],
+ "xtype" : "Box"
+ }
+ ],
+ "xtype" : "PopoverMenu"
+ }
+ ],
+ "string icon_name" : "emblem-system",
+ "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"
}
],
- "listeners" : {
- "size_allocate" : [
- "(aloc) => {",
- " ",
- " this.width = aloc.width;",
- " this.height =aloc.height;",
- "}",
- " "
- ]
- },
"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 GtkSource.SearchSettings();",
+ "\ts.case_sensitive = _this.case_sensitive.el.active;",
+ "\ts.regex_enabled = _this.regex.el.active;\t",
+ "\ts.wrap_around = false;",
+ "\t",
+ "\tthis.searchcontext = new GtkSource.SearchContext(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.searchcontext.forward(beg, out st, out en);",
- "\tthis.last_search_end = 0;",
+ "\tbool has_wrapped_around;",
+ "\tthis.buffer.el.get_start_iter(out beg);",
+ "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
+ "\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.backward(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 ",
"}",
""
],
" }",
" ",
" ",
- " 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) {",
- " ",
- " }",
+ " \tthis.file.widgetToIcon(this.container.el); ",
"",
- " ",
+ " ",
" return;",
" ",
" ",
" ",
" ",
" // should we hold until it's printed...",
- " ",
- " ",
- "",
- " ",
- " ",
- "",
+ " ",
"",
" ",
" ",
"\t\treturn;",
"\t}",
"\tthis.notebook.el.page = 1;",
- "\tGtk.TextIter beg, st,en, stl;",
- "\t",
+ "\tGtk.TextIter beg, st,en;",
+ "\tbool has_wrapped_around;",
"\tvar buf = this.sourceview.el.get_buffer();",
"\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
- "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
+ "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
"\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// this is done from clicking on the editor..",
+ "\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.name);",
+ " ",
+ " ",
+ " // ---------- this selects the tree's node...",
+ " ",
+ " var ltree = _this.main_window.windowstate.left_tree;",
+ " ltree.model.selectNode(node);",
+ " //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 = \"\";",
+ "\t/*",
+ " 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) ",
" // hide the compile view at present..",
" ",
" ",
- " var w = this.width;",
- " var h = this.height;",
+ " var w = this.el.get_width();",
+ " var h = this.el.get_height();",
" ",
" print(\"ALLOC SET SIZES %d, %d\\n\", w,h); ",
" ",
" print(\"SET SIZES %d, %d\\n\", w,h); ",
" _this.container.el.set_size_request(w,h);",
" ",
- " _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled.",
- " var rgba = Gdk.RGBA ();",
- " rgba.parse (\"#ccc\");",
- " _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba);",
- " ",
+ " _this.view_layout.el.set_size_request(w,h); ",
+ " // should be baded on calc.. -- see update_scrolled.",
+ " ",
+ " var fc = this.container.el.get_first_child();",
+ " if (fc != null) {",
+ " \t\tthis.container.el.remove(fc);",
+ " \t\t}",
" ",
+ " \t\tvar xmlstr = JsRender.NodeToGlade.mungeFile( file);",
+ " \t\tvar builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length);",
+ " \t\tvar obj = (Gtk.Widget) builder.get_object(\"w\"+ file.tree.oid.to_string());",
+ " \t\t this.container.el.append(obj);",
+ "\t obj.show();",
+ " this.createThumb();",
+ " ",
+ " \t ",
+ " return;/*",
"\tvar x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);",
- " var obj = x.munge() as Gtk.Widget;",
- " this.lastObj = null;",
+ " var obj = x.munge() as Gtk.Widget;",
+ " this.lastObj = null;",
"\tif (obj == null) {",
" \treturn;",
"\t}",
"\tthis.lastObj = obj;",
" ",
- " this.container.el.add(obj);",
- " obj.show_all();",
+ " this.container.el.append(obj);",
+ " obj.show();",
" ",
- " ",
+ " */",
" ",
"}",
" "
],
"| void scroll_to_line" : [
"(int line) {",
- " this.notebook.el.page = 1;// code preview...",
+ " // code preview...",
" ",
- " GLib.Timeout.add(500, () => {",
+ " GLib.Timeout.add(100, () => {",
" ",
" ",
- "\t ",
+ "\t this.notebook.el.set_current_page(1);",
"\t ",
"\t\t var buf = this.sourceview.el.get_buffer();",
"\t ",
- "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
+ "\t\tvar sbuf = (GtkSource.Buffer) buf;",
"",
"",
"\t\tGtk.TextIter iter; ",
" ",
"}",
""
+ ],
+ "| void updateErrorMarks" : [
+ "(string category) {",
+ "\t",
+ " ",
+ "",
+ "\tvar buf = _this.buffer.el;",
+ "\tGtk.TextIter start;",
+ "\tGtk.TextIter end; ",
+ "\tbuf.get_bounds (out start, out end);",
+ "",
+ "\tbuf.remove_source_marks (start, end, category);",
+ " ",
+ "\tGLib.debug(\"highlight errors\");\t\t ",
+ "",
+ "\t // we should highlight other types of errors..",
+ "",
+ " ",
+ "",
+ "\t ",
+ "\tif (_this.file == null) {",
+ "\t\tGLib.debug(\"file is null?\");",
+ "\t\treturn;",
+ "",
+ "\t}",
+ "\tvar ar = this.file.getErrors(category);",
+ "\tif (ar == null || ar.get_n_items() < 1) {",
+ "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
+ "\t\treturn;",
+ "\t}",
+ " ",
+ "",
+ " ",
+ "\t",
+ "\tvar offset = 0;",
+ "\t ",
+ "",
+ "\tvar tlines = buf.get_line_count () +1;",
+ "\t",
+ " ",
+ "\t ",
+ "\tfor (var i = 0; i < ar.get_n_items();i++) {",
+ "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
+ "\t\t",
+ "\t Gtk.TextIter iter;",
+ "// print(\"get inter\\n\");",
+ "\t var eline = err.line - offset;",
+ "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
+ "\t \terr.line ,eline, offset);",
+ "\t ",
+ "\t ",
+ "\t if (eline > tlines || eline < 0) {",
+ "\t return;",
+ "\t }",
+ "\t ",
+ "\t ",
+ "\t buf.get_iter_at_line( out iter, eline);",
+ "\t ",
+ "\t ",
+ "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
+ "\t buf.create_source_mark( msg, err.category, iter);",
+ "\t GLib.debug(\"set line %d to %s\", eline, msg);",
+ "\t //this.marks.set(eline, msg);",
+ "\t}",
+ "\treturn ;",
+ "",
+ "",
+ "",
+ " ",
+ "",
+ "}"
]
}
],
- "modOrder" : "",
- "name" : "GtkView",
- "parent" : "",
- "path" : "/home/alan/gitlive/roobuilder/src/Builder4/GtkView.bjs",
- "permname" : "",
- "title" : ""
+ "name" : "GtkView"
}
\ No newline at end of file