{
"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_error_counter" : 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",
"bool vexpand" : true,
+ "id" : "sourceviewscroll",
"items" : [
{
"# JsRender.Node? node_selected" : "",
"# string prop_selected" : "\"\"",
- "$ xns" : "Gtk",
+ "$ xns" : "GtkSource",
"* init" : [
- "{",
- " ",
- " var description = Pango.FontDescription.from_string(\"monospace\");",
- " description.set_size(8000);",
- " this.el.override_font(description);",
+ "\t{",
"",
- " 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);",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- "}",
- " "
+ "",
+ "\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 ",
+ "\tthis.loading = true;",
+ "",
+ "",
+ "",
+ "\tvar attrs = new GtkSource.MarkAttributes();",
+ "\t attrs.set_icon_name ( \"process-stop\"); ",
+ "\tattrs.query_tooltip_text.connect(( mark) => {",
+ "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
+ "\t\treturn mark.name;",
+ "\t});",
+ "",
+ "\tthis.el.set_mark_attributes (\"ERR\", attrs, 1);",
+ "",
+ "\t var wattrs = new GtkSource.MarkAttributes();",
+ "\t wattrs.set_icon_name ( \"process-stop\"); ",
+ "\twattrs.query_tooltip_text.connect(( mark) => {",
+ "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
+ "\t\treturn mark.name;",
+ "\t});",
+ "",
+ "\tthis.el.set_mark_attributes (\"WARN\", wattrs, 1);",
+ "",
+ "",
+ "",
+ "\t var dattrs = new GtkSource.MarkAttributes();",
+ "\tdattrs.set_icon_name ( \"process-stop\"); ",
+ "\tdattrs.query_tooltip_text.connect(( mark) => {",
+ "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
+ "\t\treturn mark.name;",
+ "\t});",
+ "",
+ "\tthis.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
+ "",
+ "",
+ "\tvar gattrs = new GtkSource.MarkAttributes();",
+ "\tvar grey = Gdk.RGBA();",
+ "\tgrey.parse ( \"#ccc\");",
+ "\tgattrs.set_background ( grey);",
+ "",
+ "",
+ "\tthis.el.set_mark_attributes (\"grey\", gattrs, 1);",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "\t}",
+ ""
],
- "* pack" : "add",
- "bool allow_node_scroll" : true,
- "bool loading" : true,
+ "* pack" : "set_child",
+ "Gtk.CssProvider css" : "",
+ "bool loading" : false,
+ "bool zallow_node_scroll" : true,
"gboolean editable" : false,
"gboolean show_line_marks" : true,
"gboolean show_line_numbers" : true,
"id" : "sourceview",
"items" : [
{
- "$ xns" : "Gtk",
+ "$ xns" : "GtkSource",
+ "* init" : [
+ "",
+ "var buf = this.el;",
+ "buf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);",
+ "buf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");",
+ "buf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");",
+ "buf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");",
+ "buf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");",
+ "buf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");",
+ "buf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");",
+ "buf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");",
+ "",
+ "",
+ "buf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");",
+ "buf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");",
+ "buf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");",
+ "",
+ "",
+ ""
+ ],
"* pack" : "set_buffer",
"bool dirty" : false,
+ "bool in_cursor_change" : false,
"id" : "buffer",
"int error_line" : "-1",
- "xtype" : "SourceBuffer"
+ "int last_line" : "-1",
+ "listeners" : {
+ "cursor_moved" : [
+ "( ) => {",
+ "GLib.debug(\"cursor moved called\");",
+ "",
+ "",
+ " \tif (this.in_cursor_change ) {",
+ " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
+ " 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();",
+ " if (this.last_line == ln ){",
+ " \treturn;",
+ "\t}",
+ "\tthis.last_line = ln;",
+ " var node = _this.file.lineToNode(ln);",
+ "",
+ " if (node == null) {",
+ " print(\"can not find node\\n\");",
+ " return;",
+ " }",
+ " this.in_cursor_change = true;",
+ " var ltree = _this.main_window.windowstate.left_tree;",
+ " ltree.model.selectNode(node);",
+ " this.in_cursor_change = false;",
+ "}",
+ ""
+ ]
+ },
+ "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" : {
- "key_press_event" : [
- "(event) => {",
+ "query_tooltip" : [
+ "(x, y, keyboard_tooltip, tooltip) => {",
"\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//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 ",
- "\treturn false;",
- "}\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;",
+ "",
+ "}",
""
]
},
- "xtype" : "SourceView",
+ "string name" : "gtkview-view",
+ "uint tab_width" : 4,
+ "xtype" : "View",
"| string toString" : [
"() {",
" Gtk.TextIter s;",
"}",
""
],
- "| 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;",
- "",
+ " var sbuf = (GtkSource.Buffer) buf;",
+ "\tvar cpos = buf.cursor_position;",
" ",
+ " \tprint(\"BEFORE LOAD cursor = %d\\n\", cpos);",
+ " var vadj_pos = this.el.get_vadjustment().get_value();",
"",
" if (_this.file == null || _this.file.xtype != \"Gtk\") {",
" print(\"xtype != Gtk\");",
" this.loading = false;",
" return;",
" }",
- " ",
+ " /*",
" var valafn = \"\";",
" try { ",
" var regex = new Regex(\"\\\\.bjs$\");",
" this.loading = false;",
" return ;",
" }",
+ " */",
+ " var str = _this.file.toSource();",
"",
"// print(\"setting str %d\\n\", str.length);",
" buf.set_text(str, str.length);",
- " var lm = Gtk.SourceLanguageManager.get_default();",
+ " var lm = GtkSource.LanguageManager.get_default();",
" ",
" //?? is javascript going to work as js?",
" ",
- " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
+ " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
+ " ",
+ " ",
+ " _this.main_window.windowstate.updateErrorMarksAll(); ",
+ " // restore the cursor position?",
+ " // after reloading the contents.",
+ " GLib.Timeout.add(500, () => {",
+ "\t\t_this.buffer.in_cursor_change = true;",
+ " 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_this.buffer.in_cursor_change = false;",
+ " ",
+ "\t\t",
+ "\t\t",
+ "\t\t//_this.buffer.checkSyntax();",
+ "\t\treturn false;",
+ "\t});",
" ",
- " ",
- " 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; ",
"}",
"(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 = (Gtk.SourceBuffer) buf;",
+ " var sbuf = (GtkSource.Buffer) buf;",
"",
" ",
- " while(Gtk.events_pending()) {",
- " Gtk.main_iteration();",
- " }",
+ " ",
" ",
" ",
" // clear all the marks..",
" 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 ",
+ " if (!_this.buffer.in_cursor_change) {",
+ "",
" \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
- "\t}",
+ "\t} ",
" ",
" ",
" ",
{
"$ xns" : "Gtk",
"* init" : [
- "var description = Pango.FontDescription.from_string(\"monospace\");",
- "\tdescription.set_size(8000);",
- "\t this.el.override_font(description);",
+ " ",
+ "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",
- "int width_request" : 300,
+ "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" : {
- "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\t _this.search_results.updateResults();",
+ "search_changed" : [
+ " () => {",
+ " \t ",
+ "\t_this.search(_this.search_entry.el.text);",
+ "\t _this.search_results.updateResults();",
"",
- "\t\tGLib.Timeout.add_seconds(2,() => {",
- "\t\t\t _this.search_results.updateResults();",
- "\t\t\t return false;",
- "\t\t });",
- "\t ",
- "\t\t",
- "\t return true;",
- "",
- "\t} ",
- " // print(event.key.keyval)",
+ "\tGLib.Timeout.add_seconds(1,() => {",
+ "\t\t _this.search_results.updateResults();",
+ "\t\t return false;",
+ "\t });",
+ "\t ",
" ",
- " return false;",
- "",
- "} "
+ " ",
+ "}"
]
},
+ "string name" : "gtkview-search-entry",
"string placeholder_text" : "Press enter to search",
+ "uint search_delay" : 3,
"xtype" : "SearchEntry",
"| void forwardSearch" : [
"(bool change_focus) {",
},
{
"$ xns" : "Gtk",
- "* pack" : "add",
- "items" : [
- {
- "$ xns" : "Gtk",
- "* pack" : "add",
- "bool always_show_image" : true,
- "bool visible" : false,
- "id" : "search_results",
- "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;",
- "}"
- ]
- },
- "xtype" : "ImageMenuItem",
- "| 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",
- "}"
- ]
- }
- ],
- "xtype" : "MenuBar"
+ "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",
- "items" : [
- {
- "$ xns" : "Gtk",
- "* prop" : "image",
- "string icon_name" : "go-down",
- "xtype" : "Image"
- }
- ],
"listeners" : {
- "button_press_event" : [
- "(event) => {",
+ "clicked" : [
+ "( ) => {",
+ "_this.forwardSearch(true);",
+ "\t ",
"",
- "\t_this.forwardSearch(true);",
- "\t",
- "\treturn true;",
"}",
""
]
},
- "string label" : "Next",
+ "string icon_name" : "go-down",
"xtype" : "Button"
},
{
"bool always_show_image" : true,
"bool sensitive" : false,
"id" : "backBtn",
- "items" : [
- {
- "$ xns" : "Gtk",
- "* prop" : "image",
- "string icon_name" : "go-up",
- "xtype" : "Image"
- }
- ],
"listeners" : {
- "button_press_event" : [
- "(event) => {",
+ "clicked" : [
+ "( ) => {",
"",
- "\t_this.backSearch(true);",
+ "_this.backSearch(true);",
"\t",
- "\treturn true;",
"}",
""
]
},
- "string label" : "Previous",
+ "string icon_name" : "go-up",
"xtype" : "Button"
},
{
"$ xns" : "Gtk",
+ "bool always_show_arrow" : true,
"bool always_show_image" : true,
"items" : [
{
"$ xns" : "Gtk",
- "* prop" : "image",
- "string icon_name" : "emblem-system",
- "xtype" : "Image"
- },
- {
- "$ xns" : "Gtk",
- "* prop" : "popup",
+ "* ctor" : "new Gtk.PopoverMenu.from_model(null)",
+ "* prop" : "popover",
"id" : "search_settings",
"items" : [
{
"$ xns" : "Gtk",
- "* init" : [
- "{",
- "\tthis.el.show();",
- "}",
- ""
+ "* 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"
+ }
],
- "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" : "Box"
}
],
- "xtype" : "Menu"
+ "xtype" : "PopoverMenu"
}
],
- "string label" : "Settings",
+ "string icon_name" : "emblem-system",
"xtype" : "MenuButton"
}
],
"xtype" : "Notebook"
}
],
- "listeners" : {
- "size_allocate" : [
- "(aloc) => {",
- " ",
- " this.width = aloc.width;",
- " this.height =aloc.height;",
- "}",
- " "
- ]
- },
"xtype" : "Box",
"| int search" : [
"(string in_txt) {",
"\t",
" ",
" ",
- "\tvar s = new Gtk.SourceSearchSettings();",
+ "\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 Gtk.SourceSearchContext(this.buffer.el,s);",
+ "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
"\tthis.searchcontext.set_highlight(true);",
"\tvar txt = in_txt;",
"\t",
"\t",
"\ts.set_search_text(txt);",
"\tGtk.TextIter beg, st,en;",
- "\t ",
+ "\tbool has_wrapped_around;",
"\tthis.buffer.el.get_start_iter(out beg);",
- "\tthis.searchcontext.forward(beg, out st, out en);",
+ "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
"\tthis.last_search_end = 0;",
"\t",
"\treturn this.searchcontext.get_occurrences_count();",
"\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)) {",
+ "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
"\t",
"\t\tthis.last_search_end = 0;",
"\t\treturn;",
"\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
"\tvar ln = st.get_line();",
"\tthis.highlightNodeAtLine(ln);",
- "\t",
- " ",
+ "\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\treturn;",
"\t}",
"| void highlightNodeAtLine" : [
"(int ln) {",
"",
- "",
+ "\t// this is done from clicking on the editor..",
"\t ",
"\t// highlight node...",
"\t",
" return;",
" }",
" var prop = node.lineToProp(ln+1);",
- " print(\"prop : %s\", prop == null ? \"???\" : prop);",
+ " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
" ",
" ",
" // ---------- 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}",
+ " 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 ",
" ",
" // 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\t\t",
"\t\t}",
" }",
- " ltree.view.setCursor(tp, \"editor\");",
+ " */",
+ " //ltree.view.setCursor(tp, \"editor\");",
" // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
" _this.sourceview.nodeSelected(node,false);",
" ",
" if (file.tree == null) {",
" return;",
" }",
+ " this.last_error_counter = -1;",
" this.notebook.el.page = 0;// gtk preview ",
" ",
" ",
" ",
" this.file = file; ",
" this.sourceview.loadFile();",
+ " ",
" this.searchcontext = null;",
- " ",
- "",
+ " this.last_error_counter = -1;",
+ "\t\tthis.updateErrorMarks();",
" if (this.lastObj != null) {",
" this.container.el.remove(this.lastObj);",
" }",
" // 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);",
- " ",
- " ",
- "\tvar x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);",
- " 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.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 ",
+ " ",
" ",
"}",
" "
],
"| 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" : [
+ "() {",
+ "\t",
+ " ",
+ "",
+ "\tvar buf = _this.buffer.el;",
+ "\tGtk.TextIter start;",
+ "\tGtk.TextIter end; ",
+ "\tbuf.get_bounds (out start, out end);",
+ "",
+ "",
+ " ",
+ "\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();",
+ "\tif (ar.size < 1) {",
+ "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
+ "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
+ "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
+ "\t\tbuf.remove_source_marks (start, end, null);",
+ "\t\tthis.last_error_counter = file.error_counter ;",
+ "\t\tGLib.debug(\"higjlight has no errors\");",
+ "\t\treturn;",
+ "\t}",
+ " \tif (this.last_error_counter == file.error_counter) {",
+ "\t\treturn;",
+ "\t}",
+ "\t",
+ "",
+ " ",
+ "\t ",
+ "",
+ "\tvar tlines = buf.get_line_count () +1;",
+ "\t",
+ " ",
+ "\t ",
+ "\tbuf.remove_source_marks (start, end, null);",
+ "\tbuf.remove_tag_by_name (\"ERR\", start, end);",
+ "\tbuf.remove_tag_by_name (\"WARN\", start, end);",
+ "\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
+ "\tforeach(var diag in ar) { ",
+ "\t",
+ "\t\t",
+ "\t Gtk.TextIter iter;",
+ "// print(\"get inter\\n\");",
+ "\t var eline = (int)diag.range.start.line ;",
+ "\t var eline_to = (int)diag.range.end.line;",
+ "\t if (eline > tlines || eline < 0) {",
+ "\t return;",
+ "\t }",
+ "\t ",
+ "\t ",
+ "\t buf.get_iter_at_line( out iter, eline);",
+ "\t ",
+ "\t \t buf.get_iter_at_line_offset( out start, ",
+ " \t \teline, (int)diag.range.start.character); ",
+ " \t buf.get_iter_at_line_offset( out end, ",
+ " \t \teline_to, (int)diag.range.end.character); ",
+ " \t \t",
+ "\t buf.apply_tag_by_name(diag.category, start, end);",
+ "\t ",
+ "\t ",
+ "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
+ "\t buf.create_source_mark( msg, diag.category, iter);",
+ "\t GLib.debug(\"set line %d to %s\", eline, msg);",
+ "\t //this.marks.set(eline, msg);",
+ "\t}",
+ "\tthis.last_error_counter = file.error_counter ;",
+ "",
+ "",
+ "",
+ " ",
+ "",
+ "}"
]
}
],
- "modOrder" : "",
- "name" : "GtkView",
- "parent" : "",
- "path" : "/home/alan/gitlive/roobuilder/src/Builder4/GtkView.bjs",
- "permname" : "",
- "title" : ""
+ "name" : "GtkView"
}
\ No newline at end of file