"# GtkSource.SearchContext searchcontext" : "",
"# JsRender.JsRender file" : "null",
"# Xcls_MainWindow main_window" : "",
+ "# int last_error_counter" : 0,
+ "# int last_search_end" : 0,
"$ 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",
"bool hexpand" : true,
"bool vexpand" : true,
"id" : "GtkView",
- "int last_search_end" : 0,
"items" : [
{
"$ xns" : "Gtk",
"items" : [
{
"# JsRender.Node? node_selected" : "",
+ "# bool loading" : false,
"# 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);",
+ "\tthis.loading = true;",
+ "",
" ",
- " ",
- " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- "}",
- " "
+ "\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" : "set_child",
- "Gtk.CssProvider css" : "",
- "bool allow_node_scroll" : true,
- "bool loading" : true,
+ "css_classes" : "{ \"code-editor\" }",
"gboolean editable" : false,
"gboolean show_line_marks" : true,
"gboolean show_line_numbers" : true,
"items" : [
{
"$ 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",
+ "int last_line" : "-1",
"listeners" : {
- "notify[\"cursor_position\"]" : [
- "() => {",
+ "cursor_moved" : [
+ "( ) => {",
+ "GLib.debug(\"cursor moved called\");",
"",
"",
- " if (_this.sourceview.loading) {",
+ " \tif (this.in_cursor_change ) {",
+ " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
" return;",
" }",
" ",
" 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.sourceview.loading = true;",
+ " this.in_cursor_change = 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..",
- " ",
- " ",
- "",
- " }"
+ " this.in_cursor_change = false;",
+ "}",
+ ""
]
},
"xtype" : "Buffer"
},
{
+ "# bool is_control" : false,
"$ xns" : "Gtk",
+ "id" : "keystate",
"listeners" : {
"key_pressed" : [
"(keyval, keycode, state) => {",
"",
- "\t",
+ "\tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
+ " \t\tthis.is_control = true;",
+ "\t}",
"\t ",
"\t if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
"\t GLib.debug(\"SAVE: ctrl-g pressed\");",
"\treturn false;",
"}\t ",
"\t"
+ ],
+ "key_released" : [
+ "(keyval, keycode, state) => {",
+ "",
+ "\t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
+ " \t\tthis.is_control = false;",
+ "\t}",
+ "}",
+ ""
]
},
"xtype" : "EventControllerKey"
+ },
+ {
+ "# double distance" : "0.0f",
+ "$ xns" : "Gtk",
+ "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
+ "listeners" : {
+ "scroll" : [
+ "(dx, dy) => {",
+ "\tif (!_this.keystate.is_control) {",
+ "\t\treturn false;",
+ "\t}",
+ "\t//GLib.debug(\"scroll %f\", dy);",
+ "\t",
+ "\tthis.distance += dy;",
+ "\t if (this.distance < -1) {",
+ "\t\tBuilderApplication.settings.editor_font_size ++;",
+ "\t\tthis.distance = 0;",
+ "\t}",
+ "\tif (this.distance > 1) {",
+ "\t\tBuilderApplication.settings.editor_font_size --;",
+ "\t\tthis.distance = 0;",
+ "\t}",
+ "",
+ "\treturn true;",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "EventControllerScroll"
}
],
"listeners" : {
]
},
"string name" : "gtkview-view",
+ "uint tab_width" : 4,
"xtype" : "View",
"| string toString" : [
"() {",
" this.loading = true;",
" var buf = this.el.get_buffer();",
" buf.set_text(\"\",0);",
- " 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);",
" ",
" ",
" _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});",
" ",
" ",
" this.loading = false; ",
" 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} ",
" ",
" ",
" ",
"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",
" 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);",
" }",
" \t\t}",
" ",
" \t\tvar xmlstr = JsRender.NodeToGlade.mungeFile( file);",
- " \t\tvar builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length);",
+ " \t\tvar builder = new Gtk.Builder();",
+ " \t\ttry {",
+ "\t \t\tif (!builder.add_from_string(xmlstr, xmlstr.length)) {",
+ "\t \t\t\treturn;",
+ "\t\t\t}",
+ "\t\t} catch(GLib.Error e) {",
+ "\t\t\tGLib.debug(e.message);",
+ "\t\t\treturn;",
+ "\t\t}",
+ " \t\t",
+ "",
" \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;",
- "\tif (obj == null) {",
- " \treturn;",
- "\t}",
- "\tthis.lastObj = obj;",
- " ",
- " this.container.el.append(obj);",
- " obj.show();",
- " ",
- " */",
+ " ",
" ",
"}",
" "
""
],
"| void updateErrorMarks" : [
- "(string category) {",
+ "() {",
"\t",
" ",
"",
"\tGtk.TextIter end; ",
"\tbuf.get_bounds (out start, out end);",
"",
- "\tbuf.remove_source_marks (start, end, category);",
+ "",
" ",
- "\tGLib.debug(\"highlight errors\");\t\t ",
+ "\t//GLib.debug(\"highlight errors\");\t\t ",
"",
"\t // we should highlight other types of errors..",
"",
"\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);",
+ "\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, \"ERR\");",
+ "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
+ "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
+ "\t\tthis.last_error_counter = file.error_counter ;",
+ "\t\t//GLib.debug(\"higjlight has no errors\");",
"\t\treturn;",
"\t}",
- " ",
+ " \tif (this.last_error_counter == file.error_counter) {",
+ "\t\treturn;",
+ "\t}",
+ "\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);",
+ "\tbuf.remove_source_marks (start, end, \"ERR\");",
+ "\tbuf.remove_source_marks (start, end, \"WARN\");",
+ "\tbuf.remove_source_marks (start, end, \"DEPR\");",
+ "\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 = err.line - offset;",
- "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
- "\t \terr.line ,eline, offset);",
- "\t ",
- "\t ",
+ "\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 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, err.category, err.msg);",
- "\t buf.create_source_mark( msg, err.category, iter);",
+ "\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}",
- "\treturn ;",
+ "\tthis.last_error_counter = file.error_counter ;",
"",
"",
"",