From 97512819719f3a912c1376ce037930ae1cc1fdd8 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 30 Jan 2024 17:48:35 +0800 Subject: [PATCH] fix last merge - highlight support --- debian/changelog | 4 +- meson.build | 1 - src/Application.vala | 5 +- src/Builder4/Editor.bjs | 278 +++++++++++++++-------------- src/Builder4/Editor.vala | 219 ++++++++++++----------- src/Builder4/GtkView.bjs | 149 +++++++++------- src/Builder4/GtkView.vala | 142 ++++++++------- src/Builder4/WindowLeftProps.bjs | 43 ++++- src/Builder4/WindowLeftProps.vala | 42 ++++- src/Builder4/WindowLeftTree.bjs | 180 +++++++++++++++---- src/Builder4/WindowLeftTree.vala | 175 ++++++++++++++---- src/Builder4/WindowRooView.bjs | 194 +++++++++----------- src/Builder4/WindowRooView.vala | 185 +++++++++---------- src/Palete/Gtk.vala | 251 +------------------------- src/Palete/Javascript.vala | 16 +- src/Palete/LanguageClientVala.vala | 4 +- src/Palete/Palete.vala | 6 - src/Palete/Roo.vala | 198 +------------------- src/Project/Project.vala | 6 +- 19 files changed, 966 insertions(+), 1132 deletions(-) diff --git a/debian/changelog b/debian/changelog index 91557a466..c1fa04429 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,8 +7,10 @@ roobuilder (5.0.2) UNRELEASED; urgency=medium * Fixed sending wrong 'save' to language-server (caused LS to crash) * Fixed Gtkview - uses toSource(), rather than file.get_contents() * Fixed updating of errors (should only update changed error mark or tree item)) + * Errors now shown on widget tree / node properties / and node edit as selected + * Error highlighting now on character location of errors, along with marks + * roojspacker dependancy removed for now (too slow to work currently) - -- Alan Knowles Sun, 28 Jan 2024 06:54:56 +0800 roobuilder (5.0.1) unstable; urgency=medium diff --git a/meson.build b/meson.build index 6e12dd8c8..c5d929ac5 100644 --- a/meson.build +++ b/meson.build @@ -26,7 +26,6 @@ deps = [ dependency('libvala-0.56'), dependency('libxml-2.0'), valac.find_library('posix'), - dependency('roojspacker-1.4'), dependency('gtksourceview-5'), dependency('libgda-5.0'), dependency('jsonrpc-glib-1.0'), diff --git a/src/Application.vala b/src/Application.vala index 4df8de019..9708a4a83 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -710,6 +710,7 @@ flutter-project - was try and read flutter data (but desnt work.) if (ww == null || ww.windowstate == null || ww.windowstate.project ==null) { continue; } + ww.windowstate.updateErrorMarksAll(); @@ -717,7 +718,7 @@ flutter-project - was try and read flutter data (but desnt work.) ww.updateErrors(); ww.windowstate.left_tree.updateErrors(); ww.windowstate.left_props.updateErrors(); - + } } @@ -804,4 +805,4 @@ flutter-project - was try and read flutter data (but desnt work.) - + \ No newline at end of file diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs index c0555bf9c..30bfedde6 100644 --- a/src/Builder4/Editor.bjs +++ b/src/Builder4/Editor.bjs @@ -132,19 +132,10 @@ ");", "\t", " ", - "\t ", - "/*", - "this is pretty flakey - triggers Gtk with < 0 d", - " var cp = new GtkSource.CompletionWords(\"test\"); ", - " cp.minimum_word_size = 3;", - " //cp.priority = 100; //?? does this do anything", - " cp.proposals_batch_size = 10;", - " cp.scan_batch_size = 1000;", " ", - "cp.register(_this.buffer.el);", - "this.el.completion.add_provider(cp);", - "*/", - "this.el.completion.add_provider(new Palete.CompletionProvider(_this));", + "this.el.completion.add_provider(", + "\tnew Palete.CompletionProvider(_this)", + ");", " ", "//this.el.completion.unblock_interactive();", "this.el.completion.select_on_show = true; // select", @@ -152,9 +143,7 @@ "", "", "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) => {", " GLib.debug(\"tooltip query? %s\", mark.name);", @@ -166,10 +155,9 @@ "});", "this.el.set_mark_attributes (\"ERR\", attrs, 1);", "attrs.ref();", - " var wattrs = new GtkSource.MarkAttributes();", - "var blue = Gdk.RGBA();", - "blue.parse ( \"#ABF4EB\");", - "wattrs.set_background ( blue);", + "", + "", + "var wattrs = new GtkSource.MarkAttributes();", "wattrs.set_icon_name ( \"process-stop\"); ", "wattrs.query_tooltip_text.connect(( mark) => {", " GLib.debug(\"tooltip query? %s\", mark.name);", @@ -182,20 +170,19 @@ "this.el.set_mark_attributes (\"WARN\", wattrs, 1);", "wattrs.ref();", "", + " ", + "var dattrs = new GtkSource.MarkAttributes();", + " ", + "dattrs.set_icon_name ( \"process-stop\"); ", "", - " 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) => {", "\tGLib.debug(\"tooltip query? %s\", mark.name);", " return strdup(mark.name);", "});", - "dattrs.query_tooltip_markup.connect(( mark) => {", - "\tGLib.debug(\"tooltip query? %s\", mark.name);", - " return strdup(mark.name);", - "});", + "//dattrs.query_tooltip_markup.connect(( mark) => {", + "//\tGLib.debug(\"tooltip query? %s\", mark.name);", + " // return strdup(mark.name);", + "//});", "this.el.set_mark_attributes (\"DEPR\", dattrs, 1);", "dattrs.ref(); ", "", @@ -223,18 +210,23 @@ "$ xns" : "GtkSource", "$ xtype" : "Buffer", "* init" : [ - "{", - "\tvar buf = this.el;", - "\tbuf.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\");", "", - "}", + "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\");", + "", + "", "" ], "* prop" : "buffer", @@ -261,94 +253,7 @@ "" ] }, - "| 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, null);", - " }", - " if (str.length < 1) {", - " print(\"checkSyntax - empty string?\\n\");", - " return true;", - " }", - " ", - " // bit presumptiona", - " if (_this.file.xtype == \"PlainFile\") {", - " ", - " // assume it's gtk...", - " var oldcode =_this.file.toSource();", - " _this.file.setSource(str);", - "\t BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");", - " \t_this.file.getLanguageServer().document_change(_this.file);", - "", - " _this.file.setSource(oldcode);", - " ", - "\t\t ", - " return true;", - " ", - " }", - " if (_this.file == null) {", - " return true;", - " }", - " ", - " ", - "", - " ", - " ", - " GLib.debug(\"calling validate\"); ", - " // clear the buttons.", - " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {", - "\t\treturn true ;", - "\t}", - "\tvar oldcode = _this.prop.val;", - "\t", - "\t_this.prop.val = str;", - "\t_this.node.updated_count++;", - " _this.file.getLanguageServer().document_change(_this.file);", - " _this.node.updated_count++;", - " _this.prop.val = oldcode;", - " ", - " ", - " //print(\"done mark line\\n\");", - " ", - " return true; // at present allow saving - even if it's invalid..", - "}", - "" - ], - "| bool highlightErrors" : [ - "( Gee.HashMap validate_res) {", - " ", - "\tthis.error_line = validate_res.size;", - "", - "\tif (this.error_line < 1) {", - "\t\treturn true;", - "\t}", - "\tvar tlines = this.el.get_line_count ();", - "\tGtk.TextIter iter;", - "\tvar valiter = validate_res.map_iterator();", - "\twhile (valiter.next()) {", - "", - "\t// print(\"get inter\\n\");", - "\t\tvar eline = valiter.get_key();", - "\t\tif (eline > tlines) {", - "\t\t\tcontinue;", - "\t\t}", - "\t\tthis.el.get_iter_at_line( out iter, eline);", - "\t\t//print(\"mark line\\n\");", - "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);", - "\t} ", - "\treturn false;", - "}" - ], - "| bool highlightErrorsJson" : [ + "| bool OLDhighlightErrorsJson" : [ "(string type, Json.Object obj) {", "\tGtk.TextIter start;", "\tGtk.TextIter end; ", @@ -462,6 +367,93 @@ "\t}", "" ], + "| 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, null);", + " }", + " if (str.length < 1) {", + " print(\"checkSyntax - empty string?\\n\");", + " return true;", + " }", + " ", + " // bit presumptiona", + " if (_this.file.xtype == \"PlainFile\") {", + " ", + " // assume it's gtk...", + " var oldcode =_this.file.toSource();", + " _this.file.setSource(str);", + "\t BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");", + " \t_this.file.getLanguageServer().document_change(_this.file);", + "", + " _this.file.setSource(oldcode);", + " ", + "\t\t ", + " return true;", + " ", + " }", + " if (_this.file == null) {", + " return true;", + " }", + " ", + " ", + "", + " ", + " ", + " GLib.debug(\"calling validate\"); ", + " // clear the buttons.", + " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {", + "\t\treturn true ;", + "\t}", + "\tvar oldcode = _this.prop.val;", + "\t", + "\t_this.prop.val = str;", + "\t_this.node.updated_count++;", + " _this.file.getLanguageServer().document_change(_this.file);", + " _this.node.updated_count++;", + " _this.prop.val = oldcode;", + " ", + " ", + " //print(\"done mark line\\n\");", + " ", + " return true; // at present allow saving - even if it's invalid..", + "}", + "" + ], + "| bool highlightErrors" : [ + "( Gee.HashMap validate_res) {", + " ", + "\tthis.error_line = validate_res.size;", + "", + "\tif (this.error_line < 1) {", + "\t\treturn true;", + "\t}", + "\tvar tlines = this.el.get_line_count ();", + "\tGtk.TextIter iter;", + "\tvar valiter = validate_res.map_iterator();", + "\twhile (valiter.next()) {", + "", + "\t// print(\"get inter\\n\");", + "\t\tvar eline = valiter.get_key();", + "\t\tif (eline > tlines) {", + "\t\t\tcontinue;", + "\t\t}", + "\t\tthis.el.get_iter_at_line( out iter, eline);", + "\t\t//print(\"mark line\\n\");", + "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);", + "\t} ", + "\treturn false;", + "}" + ], "| string toString" : [ " () {", " ", @@ -634,8 +626,6 @@ " this.el.grab_focus();", " _this.save_button.el.sensitive = false;", " _this.last_error_counter = -1;", - "\t_this.updateErrorMarks();", - " ", "}" ] } @@ -1057,12 +1047,15 @@ "", " // find the text for the node..", " this.view.load( prop.val );", - "", + " this.updateErrorMarks();", + " ", " this.close_btn.el.show(); ", " ", " } else {", " this.view.load( file.toSource() );", + " this.updateErrorMarks();", " this.close_btn.el.hide();", + " ", " }", " ", "}" @@ -1102,6 +1095,9 @@ "\tvar ar = this.file.getErrors();", "\tif (ar.size < 1) {", "\t\tbuf.remove_source_marks (start, end, null);", + "\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\tthis.last_error_counter = file.error_counter ;", "\t\t//GLib.debug(\"highlight %s : %s has no errors\", this.file.relpath, category);", "\t\treturn;", @@ -1123,7 +1119,7 @@ "", "\t\ttlines = _this.prop.end_line;", "\t\toffset = _this.prop.start_line;", - "\t\thoffset = _this.node.node_pad.length;", + "\t\thoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..", "\t\t", "\t\t ", "\t} else {", @@ -1135,26 +1131,36 @@ "\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);", + "\t", "\tforeach(var diag in ar) { ", "\t Gtk.TextIter iter;", "// print(\"get inter\\n\");", "\t var eline = (int)diag.range.start.line - offset;", + "\t var eline_to = (int)diag.range.end.line - offset;", "\t //var eline = diag.range.end_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 continue;", "\t }", "\t ", "\t ", - "\t buf.get_iter_at_line_offset( out iter, eline, (int)diag.range.start.character - hoffset);", - "\t ", - "\t ", - "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);", + "\t buf.get_iter_at_line( out iter, eline);", + "\t \tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);", "\t buf.create_source_mark( msg, diag.category, iter);", + " \t ", + " \t buf.get_iter_at_line_offset( out start, ", + " \t \teline, (int)diag.range.start.character - hoffset); ", + " \t buf.get_iter_at_line_offset( out end, ", + " \t \teline_to, (int)diag.range.end.character - hoffset); ", + " \t \t", + "\t buf.apply_tag_by_name(diag.category, start, end);", + "\t ", "\t // GLib.debug(\"set line %d to %s\", eline, msg);", "\t //this.marks.set(eline, msg);", "\t}", diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index da17b3e69..bdd158cbd 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -145,12 +145,15 @@ public class Editor : Object // find the text for the node.. this.view.load( prop.val ); - + this.updateErrorMarks(); + this.close_btn.el.show(); } else { this.view.load( file.toSource() ); + this.updateErrorMarks(); this.close_btn.el.hide(); + } } @@ -275,6 +278,9 @@ public class Editor : Object var ar = this.file.getErrors(); if (ar.size < 1) { buf.remove_source_marks (start, end, null); + buf.remove_tag_by_name ("ERR", start, end); + buf.remove_tag_by_name ("WARN", start, end); + buf.remove_tag_by_name ("DEPR", start, end); this.last_error_counter = file.error_counter ; //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category); return; @@ -296,7 +302,7 @@ public class Editor : Object tlines = _this.prop.end_line; offset = _this.prop.start_line; - hoffset = _this.node.node_pad.length; + hoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? .. } else { @@ -308,26 +314,36 @@ public class Editor : Object } buf.remove_source_marks (start, end, null); + buf.remove_tag_by_name ("ERR", start, end); + buf.remove_tag_by_name ("WARN", start, end); + buf.remove_tag_by_name ("DEPR", start, end); + foreach(var diag in ar) { Gtk.TextIter iter; // print("get inter\n"); var eline = (int)diag.range.start.line - offset; + var eline_to = (int)diag.range.end.line - offset; //var eline = diag.range.end_line - offset; //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)", // err.line ,eline, offset); if (eline > tlines || eline < 0) { - continue; } - buf.get_iter_at_line_offset( out iter, eline, (int)diag.range.start.character - hoffset); - - - var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message); + buf.get_iter_at_line( out iter, eline); + var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message); buf.create_source_mark( msg, diag.category, iter); + + buf.get_iter_at_line_offset( out start, + eline, (int)diag.range.start.character - hoffset); + buf.get_iter_at_line_offset( out end, + eline_to, (int)diag.range.end.character - hoffset); + + buf.apply_tag_by_name(diag.category, start, end); + // GLib.debug("set line %d to %s", eline, msg); //this.marks.set(eline, msg); } @@ -620,19 +636,10 @@ public class Editor : Object ); - - /* - this is pretty flakey - triggers Gtk with < 0 d - var cp = new GtkSource.CompletionWords("test"); - cp.minimum_word_size = 3; - //cp.priority = 100; //?? does this do anything - cp.proposals_batch_size = 10; - cp.scan_batch_size = 1000; - cp.register(_this.buffer.el); - this.el.completion.add_provider(cp); - */ - this.el.completion.add_provider(new Palete.CompletionProvider(_this)); + this.el.completion.add_provider( + new Palete.CompletionProvider(_this) + ); //this.el.completion.unblock_interactive(); this.el.completion.select_on_show = true; // select @@ -640,9 +647,7 @@ public class Editor : Object 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) => { GLib.debug("tooltip query? %s", mark.name); @@ -654,10 +659,9 @@ public class Editor : Object }); this.el.set_mark_attributes ("ERR", attrs, 1); attrs.ref(); - var wattrs = new GtkSource.MarkAttributes(); - var blue = Gdk.RGBA(); - blue.parse ( "#ABF4EB"); - wattrs.set_background ( blue); + + + var wattrs = new GtkSource.MarkAttributes(); wattrs.set_icon_name ( "process-stop"); wattrs.query_tooltip_text.connect(( mark) => { GLib.debug("tooltip query? %s", mark.name); @@ -670,20 +674,19 @@ public class Editor : Object this.el.set_mark_attributes ("WARN", wattrs, 1); wattrs.ref(); + + var dattrs = new GtkSource.MarkAttributes(); + + dattrs.set_icon_name ( "process-stop"); - 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) => { GLib.debug("tooltip query? %s", mark.name); return strdup(mark.name); }); - dattrs.query_tooltip_markup.connect(( mark) => { - GLib.debug("tooltip query? %s", mark.name); - return strdup(mark.name); - }); + //dattrs.query_tooltip_markup.connect(( mark) => { + // GLib.debug("tooltip query? %s", mark.name); + // return strdup(mark.name); + //}); this.el.set_mark_attributes ("DEPR", dattrs, 1); dattrs.ref(); @@ -793,8 +796,6 @@ public class Editor : Object this.el.grab_focus(); _this.save_button.el.sensitive = false; _this.last_error_counter = -1; - _this.updateErrorMarks(); - } } public class Xcls_buffer : Object @@ -827,18 +828,20 @@ public class Editor : Object // init method - { - 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"); + 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"); //listeners this.el.changed.connect( () => { @@ -856,66 +859,7 @@ public class Editor : Object } // user defined functions - public 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, null); - } - if (str.length < 1) { - print("checkSyntax - empty string?\n"); - return true; - } - - // bit presumptiona - if (_this.file.xtype == "PlainFile") { - - // assume it's gtk... - var oldcode =_this.file.toSource(); - _this.file.setSource(str); - BuilderApplication.showSpinner("appointment soon","document change pending"); - _this.file.getLanguageServer().document_change(_this.file); - - _this.file.setSource(oldcode); - - - return true; - - } - if (_this.file == null) { - return true; - } - - - - - - GLib.debug("calling validate"); - // clear the buttons. - if (_this.prop.name == "xns" || _this.prop.name == "xtype") { - return true ; - } - var oldcode = _this.prop.val; - - _this.prop.val = str; - _this.node.updated_count++; - _this.file.getLanguageServer().document_change(_this.file); - _this.node.updated_count++; - _this.prop.val = oldcode; - - - //print("done mark line\n"); - - return true; // at present allow saving - even if it's invalid.. - } - public bool highlightErrorsJson (string type, Json.Object obj) { + public bool OLDhighlightErrorsJson (string type, Json.Object obj) { Gtk.TextIter start; Gtk.TextIter end; this.el.get_bounds (out start, out end); @@ -1026,6 +970,65 @@ public class Editor : Object } + public 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, null); + } + if (str.length < 1) { + print("checkSyntax - empty string?\n"); + return true; + } + + // bit presumptiona + if (_this.file.xtype == "PlainFile") { + + // assume it's gtk... + var oldcode =_this.file.toSource(); + _this.file.setSource(str); + BuilderApplication.showSpinner("appointment soon","document change pending"); + _this.file.getLanguageServer().document_change(_this.file); + + _this.file.setSource(oldcode); + + + return true; + + } + if (_this.file == null) { + return true; + } + + + + + + GLib.debug("calling validate"); + // clear the buttons. + if (_this.prop.name == "xns" || _this.prop.name == "xtype") { + return true ; + } + var oldcode = _this.prop.val; + + _this.prop.val = str; + _this.node.updated_count++; + _this.file.getLanguageServer().document_change(_this.file); + _this.node.updated_count++; + _this.prop.val = oldcode; + + + //print("done mark line\n"); + + return true; // at present allow saving - even if it's invalid.. + } public bool highlightErrors ( Gee.HashMap validate_res) { this.error_line = validate_res.size; diff --git a/src/Builder4/GtkView.bjs b/src/Builder4/GtkView.bjs index d48b32a98..6dd3dc9a7 100644 --- a/src/Builder4/GtkView.bjs +++ b/src/Builder4/GtkView.bjs @@ -93,10 +93,10 @@ "# string prop_selected" : "\"\"", "$ xns" : "GtkSource", "* init" : [ - "{", - " ", - " ", - " \tthis.css = new Gtk.CssProvider();", + "\t{", + "", + "", + "\tthis.css = new Gtk.CssProvider();", "\t ", "\tthis.css.load_from_string(\"#gtkview-view { font: 10px monospace ;}\");", "\t ", @@ -107,64 +107,55 @@ "\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);", - " ", - " ", - " ", - " ", - " ", - " ", - "}", - " " + "\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" : "set_child", "Gtk.CssProvider css" : "", @@ -177,6 +168,26 @@ "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, @@ -984,6 +995,9 @@ "\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\");", @@ -1002,13 +1016,16 @@ " ", "\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 ", + "\t var eline_to = (int)diag.range.end.line;", "\t if (eline > tlines || eline < 0) {", "\t return;", "\t }", @@ -1016,6 +1033,12 @@ "\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);", diff --git a/src/Builder4/GtkView.vala b/src/Builder4/GtkView.vala index d7a1ee937..73202c5e3 100644 --- a/src/Builder4/GtkView.vala +++ b/src/Builder4/GtkView.vala @@ -345,6 +345,9 @@ public class Xcls_GtkView : Object } var ar = this.file.getErrors(); if (ar.size < 1) { + buf.remove_tag_by_name ("ERR", start, end); + buf.remove_tag_by_name ("WARN", start, end); + buf.remove_tag_by_name ("DEPR", start, end); buf.remove_source_marks (start, end, null); this.last_error_counter = file.error_counter ; GLib.debug("higjlight has no errors"); @@ -363,13 +366,16 @@ public class Xcls_GtkView : Object buf.remove_source_marks (start, end, null); + buf.remove_tag_by_name ("ERR", start, end); + buf.remove_tag_by_name ("WARN", start, end); + buf.remove_tag_by_name ("DEPR", start, end); foreach(var diag in ar) { Gtk.TextIter iter; // print("get inter\n"); var eline = (int)diag.range.start.line ; - + var eline_to = (int)diag.range.end.line; if (eline > tlines || eline < 0) { return; } @@ -377,6 +383,12 @@ public class Xcls_GtkView : Object buf.get_iter_at_line( out iter, eline); + buf.get_iter_at_line_offset( out start, + eline, (int)diag.range.start.character); + buf.get_iter_at_line_offset( out end, + eline_to, (int)diag.range.end.character); + + buf.apply_tag_by_name(diag.category, start, end); var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message); @@ -653,9 +665,9 @@ public class Xcls_GtkView : Object // init method { - - - this.css = new Gtk.CssProvider(); + + + this.css = new Gtk.CssProvider(); this.css.load_from_string("#gtkview-view { font: 10px monospace ;}"); @@ -666,63 +678,54 @@ public class Xcls_GtkView : Object ); - 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); - - - - - - - } + this.loading = true; + + + + var attrs = new GtkSource.MarkAttributes(); + 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(); + 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(); + 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); + + + + + + + } //listeners this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { @@ -928,6 +931,23 @@ public class Xcls_GtkView : Object // set gobject values + // init method + + 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"); + //listeners this.el.cursor_moved.connect( ( ) => { GLib.debug("cursor moved called"); diff --git a/src/Builder4/WindowLeftProps.bjs b/src/Builder4/WindowLeftProps.bjs index f84d8faca..8d82cc8ee 100644 --- a/src/Builder4/WindowLeftProps.bjs +++ b/src/Builder4/WindowLeftProps.bjs @@ -18,6 +18,7 @@ "bool loading" : false, "bool vexpand" : true, "id" : "LeftProps", + "int last_error_counter" : "-1", "items" : [ { "$ xns" : "Gtk", @@ -672,6 +673,19 @@ "\t ", "}" ], + "| int propToRow" : [ + "(JsRender.NodeProp prop) {", + "\tfor (var i = 0 ; i < this.el.n_items; i++) {", + "\t\tvar r = (JsRender.NodeProp)this.el.get_item(i);", + "\t\tif (r.equals(prop)) {", + "\t\t\treturn i;", + "\t\t\t", + "\t\t}", + "\t}", + "\treturn -1;", + "\t ", + "}" + ], "| void selectProp" : [ "(JsRender.NodeProp prop) {", "\tfor (var i = 0 ; i < this.el.n_items; i++) {", @@ -1103,7 +1117,7 @@ "\t\t\t\theader_height = h;", "\t\t\t\t", "\t\t\t\treading_header = false;", - "\t\t\t\tcontinue;", + "\t\t\t\t", "\t }", "\t ", "\t\t if (child.get_type().name() != \"GtkColumnViewRowWidget\") {", @@ -1461,8 +1475,15 @@ "\t\t\t ", "\t }", "\t ", - "\t \tif (!child.has_css_class(\"error-node\")) {", - "\t\t\tchild.remove_css_class(\"error-node\");", + "\t \tif (!child.has_css_class(\"node-err\")) {", + "\t\t\tchild.remove_css_class(\"node-err\");", + "\t\t}", + "\t\tif (!child.has_css_class(\"node-warn\")) {", + "\t\t\tchild.remove_css_class(\"node-warn\");", + "\t\t}", + "\t\t", + "\t\tif (!child.has_css_class(\"node-depr\")) {", + "\t\t\tchild.remove_css_class(\"node-depr\");", "\t\t}", "\t\t", " child = child.get_next_sibling(); ", @@ -1504,8 +1525,18 @@ " \tif (w == null) {", " \t\treturn;", "\t\t}", - "\t\tif (!w.has_css_class(\"node-error\")) {", - "\t\t\tw.add_css_class(\"node-error\");", + "\t \t\tvar ed = diag.category.down();", + "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {", + "\t\t\tcontinue;", + "\t\t}", + "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {", + "\t\t\tw.remove_css_class(\"node-warn\");", + "\t\t}", + "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {", + "\t\t\tw.remove_css_class(\"node-depr\");", + "\t\t}", + "\t\tif (!w.has_css_class(\"node-\"+ ed)) {", + "\t\t\tw.add_css_class(\"node-\" + ed);", "\t\t}", "\t\t", "\t}", @@ -1515,4 +1546,4 @@ } ], "name" : "WindowLeftProps" -} +} \ No newline at end of file diff --git a/src/Builder4/WindowLeftProps.vala b/src/Builder4/WindowLeftProps.vala index bed742865..b53de34d9 100644 --- a/src/Builder4/WindowLeftProps.vala +++ b/src/Builder4/WindowLeftProps.vala @@ -28,6 +28,7 @@ public class Xcls_LeftProps : Object public signal void show_add_props (string type); public signal bool stop_editor (); public Xcls_MainWindow main_window; + public int last_error_counter; public signal void changed (); public JsRender.JsRender file; public JsRender.Node node; @@ -43,6 +44,7 @@ public class Xcls_LeftProps : Object this.loading = false; this.allow_edit = false; this.main_window = null; + this.last_error_counter = -1; // set gobject values this.el.homogeneous = false ; @@ -84,7 +86,6 @@ public class Xcls_LeftProps : Object } - public void updateErrors () { var file = this.file; var ar = file.getErrors(); @@ -117,14 +118,23 @@ public class Xcls_LeftProps : Object if (w == null) { return; } - if (!w.has_css_class("node-error")) { - w.add_css_class("node-error"); + var ed = diag.category.down(); + if (ed != "err" && w.has_css_class("node-err")) { + continue; + } + if (ed == "err" && w.has_css_class("node-warn")) { + w.remove_css_class("node-warn"); + } + if (ed == "err" && w.has_css_class("node-depr")) { + w.remove_css_class("node-depr"); + } + if (!w.has_css_class("node-"+ ed)) { + w.add_css_class("node-" + ed); } } } - public string keyFormat (string val, string type) { // Glib.markup_escape_text(val); @@ -251,8 +261,15 @@ public class Xcls_LeftProps : Object } - if (!child.has_css_class("error-node")) { - child.remove_css_class("error-node"); + if (!child.has_css_class("node-err")) { + child.remove_css_class("node-err"); + } + if (!child.has_css_class("node-warn")) { + child.remove_css_class("node-warn"); + } + + if (!child.has_css_class("node-depr")) { + child.remove_css_class("node-depr"); } child = child.get_next_sibling(); @@ -1518,7 +1535,7 @@ public class Xcls_LeftProps : Object header_height = h; reading_header = false; - continue; + } if (child.get_type().name() != "GtkColumnViewRowWidget") { @@ -1784,6 +1801,17 @@ public class Xcls_LeftProps : Object } // user defined functions + public int propToRow (JsRender.NodeProp prop) { + for (var i = 0 ; i < this.el.n_items; i++) { + var r = (JsRender.NodeProp)this.el.get_item(i); + if (r.equals(prop)) { + return i; + + } + } + return -1; + + } public void startEditing (JsRender.NodeProp prop) { // should we call select?? - caller does int (from windowstate) diff --git a/src/Builder4/WindowLeftTree.bjs b/src/Builder4/WindowLeftTree.bjs index 5ac6726db..fad8976de 100644 --- a/src/Builder4/WindowLeftTree.bjs +++ b/src/Builder4/WindowLeftTree.bjs @@ -12,6 +12,7 @@ "bool hexpand" : true, "bool vexpand" : true, "id" : "WindowLeftTree", + "int last_error_counter" : "-1", "items" : [ { "$ xns" : "Gtk", @@ -56,6 +57,31 @@ " border-top-style: solid;", " border-top-color: #88a3bc;", "}", + ".node-err {", + " border-top-width: 5px;", + " border-top-style: solid;", + " border-top-color: red;", + " border-bottom-width: 5px; ", + " border-bottom-style: solid;", + " border-bottom-color: red;", + "}", + ".node-warn {", + " border-top-width: 5px;", + " border-top-style: solid;", + " border-top-color: #ABF4EB;", + " border-bottom-width: 5px; ", + " border-bottom-style: solid;", + " border-bottom-color: #ABF4EB;", + "}", + ".node-depr {", + " border-top-width: 5px;", + " border-top-style: solid;", + " border-top-color: #EEA9FF;", + " border-bottom-width: 5px; ", + " border-bottom-style: solid;", + " border-bottom-color: #EEA9FF;", + "}", + "", "#left-tree-view indent {", "-gtk-icon-size : 2px;", "}", @@ -842,6 +868,25 @@ "\treturn this.el;", "}" ], + "| int nodeToRow" : [ + "(JsRender.Node node) ", + "{", + "\tvar row = -1;", + "\tvar s = _this.view.el.model as Gtk.SingleSelection;", + "\tfor (var i = 0; i < s.n_items; i++) {", + "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());", + "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;", + "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());", + "\t\tif ((lr.get_item() as JsRender.Node).oid == node.oid) {", + "\t\t\treturn i;", + "\t\t\t", + "\t\t}", + "\t}", + "\treturn -1;\t\t\t", + "\t", + "", + "}" + ], "| void deleteSelected" : [ "() {", "", @@ -922,7 +967,7 @@ " _this.main_window.windowstate.leftTreeNodeSelected(null);", " // needed???", " _this.main_window.windowstate.file = f;", - " ", + " _this.last_error_counter = -1;", " ", " if (f.tree == null) {", "\t try {", @@ -934,34 +979,14 @@ " // if it's still null?", " if (f.tree == null) {", "\t\t_this.main_window.windowstate.showAddObject(_this.view.el, null);", - " ", + " \t_this.updateErrors();", " return;", " }", " \tm.append(f.tree);", - " \t", - " \t// expand???", - "", - "/*", - " if (f.tree.readItems().size < 1) {", - " // single item..", - " ", - " //this.get('/Window.leftvpaned').el.set_position(80);", - " // select first...", - " _this.view.el.set_cursor( ", - " new Gtk.TreePath.from_string(\"0\"), null, false);", - " ", - " ", - " } else {", - " //this.get('/Window.leftvpaned').el.set_position(200);", - " }", - " */ ", - " ", - " ", - "", - " //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);", + "\t_this.updateErrors();", " ", " _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);", - " _this.updateErrors();", + " ", " return;", " ", " ", @@ -971,17 +996,9 @@ "| void selectNode" : [ "(JsRender.Node node) ", "{", - "\tvar row = -1;", - "\tvar s = (Gtk.SingleSelection)_this.view.el.model;", - "\tfor (var i = 0; i < s.n_items; i++) {", - "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());", - "\t\tvar lr = (Gtk.TreeListRow)s.get_item(i);", - "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());", - "\t\tif (((JsRender.Node)lr.get_item()).oid == node.oid) {", - "\t\t\trow = i;", - "\t\t\tbreak;", - "\t\t}", - "\t}", + "\tvar row = this.nodeToRow(node);", + "\tvar s = _this.view.el.model as Gtk.SingleSelection;", + "\t ", "\tif (row < 0) {", "\t\t// select none?", "\t\tGLib.debug(\"Could not find node\");", @@ -1657,6 +1674,99 @@ "}", "", "" + ], + "| void removeErrors" : [ + "() {", + "\tvar child = this.view.el.get_first_child(); ", + " ", + "\tvar reading_header = true;", + " ", + "\twhile (child != null) {", + "\t\tGLib.debug(\"Got %s\", child.get_type().name());", + "\t ", + "\t if (reading_header) {", + "\t\t\t", + "", + "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {", + "\t\t\t ", + "\t\t\t\tchild = child.get_next_sibling();", + "\t\t\t\tcontinue;", + "\t\t\t}", + "\t\t\t// should be columnlistview", + "\t\t\tchild = child.get_first_child(); ", + "\t\t ", + "\t\t ", + "\t\t\t", + "\t\t\treading_header = false;", + "\t\t\t ", + "\t }", + "\t ", + "\t \tif (!child.has_css_class(\"node-err\")) {", + "\t\t\tchild.remove_css_class(\"node-err\");", + "\t\t}", + "\t\tif (!child.has_css_class(\"node-warn\")) {", + "\t\t\tchild.remove_css_class(\"node-warn\");", + "\t\t}", + "\t\t", + "\t\tif (!child.has_css_class(\"node-depr\")) {", + "\t\t\tchild.remove_css_class(\"node-depr\");", + "\t\t}", + "\t\t", + " child = child.get_next_sibling(); ", + "\t}", + "\t//GLib.debug(\"Rturning null\");", + " ", + "}" + ], + "| void updateErrors" : [ + "() {", + "\tvar file = this.getActiveFile();", + "\tvar ar = file.getErrors();", + "\tif (ar.size < 1) {", + "\t\tthis.removeErrors();", + "\t\tthis.last_error_counter = file.error_counter ;", + "", + "\t\treturn;", + "\t}", + " \tif (this.last_error_counter == file.error_counter) {", + "\t\treturn;", + "\t}", + "\tthis.removeErrors();", + "\t", + "\tforeach(var diag in ar) { ", + "\t", + "\t\t ", + "// print(\"get inter\\n\");", + "\t var node= file.lineToNode( (int)diag.range.start.line) ;", + "\t if (node == null) {", + "\t \tcontinue;", + " \t}", + " \tvar row = _this.model.nodeToRow(node);", + " \tif (row < 0) {", + " \t\tcontinue;", + "\t\t}", + " \tvar w = this.view.getWidgetAtRow(row);", + " \tif (w == null) {", + " \t\treturn;", + "\t\t}", + "\t\t// always show errors.", + "\t\tvar ed = diag.category.down();", + "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {", + "\t\t\tcontinue;", + "\t\t}", + "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {", + "\t\t\tw.remove_css_class(\"node-warn\");", + "\t\t}", + "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {", + "\t\t\tw.remove_css_class(\"node-depr\");", + "\t\t}", + "\t\tif (!w.has_css_class(\"node-\"+ ed)) {", + "\t\t\tw.add_css_class(\"node-\" + ed);", + "\t\t}", + "\t\t", + "\t}", + "\t", + "}" ] } ], diff --git a/src/Builder4/WindowLeftTree.vala b/src/Builder4/WindowLeftTree.vala index f14651f83..6c61cf504 100644 --- a/src/Builder4/WindowLeftTree.vala +++ b/src/Builder4/WindowLeftTree.vala @@ -24,6 +24,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) public signal bool before_node_change (); public Xcls_MainWindow main_window; + public int last_error_counter; public signal void changed (); public signal void node_selected (JsRender.Node? node); @@ -35,6 +36,7 @@ public class Xcls_WindowLeftTree : Object // my vars (dec) this.main_window = null; + this.last_error_counter = -1; // set gobject values this.el.hexpand = true; @@ -47,11 +49,100 @@ public class Xcls_WindowLeftTree : Object } // user defined functions + public void updateErrors () { + var file = this.getActiveFile(); + var ar = file.getErrors(); + if (ar.size < 1) { + this.removeErrors(); + this.last_error_counter = file.error_counter ; + + return; + } + if (this.last_error_counter == file.error_counter) { + return; + } + this.removeErrors(); + + foreach(var diag in ar) { + + + // print("get inter\n"); + var node= file.lineToNode( (int)diag.range.start.line) ; + if (node == null) { + continue; + } + var row = _this.model.nodeToRow(node); + if (row < 0) { + continue; + } + var w = this.view.getWidgetAtRow(row); + if (w == null) { + return; + } + // always show errors. + var ed = diag.category.down(); + if (ed != "err" && w.has_css_class("node-err")) { + continue; + } + if (ed == "err" && w.has_css_class("node-warn")) { + w.remove_css_class("node-warn"); + } + if (ed == "err" && w.has_css_class("node-depr")) { + w.remove_css_class("node-depr"); + } + if (!w.has_css_class("node-"+ ed)) { + w.add_css_class("node-" + ed); + } + + } + + } public void onresize () { //GLib.debug("Got allocation width of scrolled view %d", allocation.width ); // _this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 ); + } + public void removeErrors () { + var child = this.view.el.get_first_child(); + + var reading_header = true; + + while (child != null) { + GLib.debug("Got %s", child.get_type().name()); + + if (reading_header) { + + + if (child.get_type().name() != "GtkColumnListView") { + + child = child.get_next_sibling(); + continue; + } + // should be columnlistview + child = child.get_first_child(); + + + + reading_header = false; + + } + + if (!child.has_css_class("node-err")) { + child.remove_css_class("node-err"); + } + if (!child.has_css_class("node-warn")) { + child.remove_css_class("node-warn"); + } + + if (!child.has_css_class("node-depr")) { + child.remove_css_class("node-depr"); + } + + child = child.get_next_sibling(); + } + //GLib.debug("Rturning null"); + } public JsRender.Node? getActiveElement () { // return path to actie node. @@ -213,6 +304,31 @@ public class Xcls_WindowLeftTree : Object border-top-style: solid; border-top-color: #88a3bc; } + .node-err { + border-top-width: 5px; + border-top-style: solid; + border-top-color: red; + border-bottom-width: 5px; + border-bottom-style: solid; + border-bottom-color: red; + } + .node-warn { + border-top-width: 5px; + border-top-style: solid; + border-top-color: #ABF4EB; + border-bottom-width: 5px; + border-bottom-style: solid; + border-bottom-color: #ABF4EB; + } + .node-depr { + border-top-width: 5px; + border-top-style: solid; + border-top-color: #EEA9FF; + border-bottom-width: 5px; + border-bottom-style: solid; + border-bottom-color: #EEA9FF; + } + #left-tree-view indent { -gtk-icon-size : 2px; } @@ -1382,7 +1498,7 @@ public class Xcls_WindowLeftTree : Object _this.main_window.windowstate.leftTreeNodeSelected(null); // needed??? _this.main_window.windowstate.file = f; - + _this.last_error_counter = -1; if (f.tree == null) { try { @@ -1394,37 +1510,34 @@ public class Xcls_WindowLeftTree : Object // if it's still null? if (f.tree == null) { _this.main_window.windowstate.showAddObject(_this.view.el, null); - + _this.updateErrors(); return; } m.append(f.tree); - - // expand??? - - /* - if (f.tree.readItems().size < 1) { - // single item.. - - //this.get('/Window.leftvpaned').el.set_position(80); - // select first... - _this.view.el.set_cursor( - new Gtk.TreePath.from_string("0"), null, false); - - - } else { - //this.get('/Window.leftvpaned').el.set_position(200); - } - */ - - - - //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32); + _this.updateErrors(); _this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION); - _this.updateErrors(); + return; + } + public int nodeToRow (JsRender.Node node) + { + var row = -1; + var s = _this.view.el.model as Gtk.SingleSelection; + for (var i = 0; i < s.n_items; i++) { + //GLib.debug("check node %s", s.get_item(i).get_type().name()); + var lr = s.get_item(i) as Gtk.TreeListRow; + GLib.debug("check node %s", lr.get_item().get_type().name()); + if ((lr.get_item() as JsRender.Node).oid == node.oid) { + return i; + + } + } + return -1; + + } public void deleteSelected () { @@ -1510,17 +1623,9 @@ public class Xcls_WindowLeftTree : Object } public void selectNode (JsRender.Node node) { - var row = -1; - var s = (Gtk.SingleSelection)_this.view.el.model; - for (var i = 0; i < s.n_items; i++) { - //GLib.debug("check node %s", s.get_item(i).get_type().name()); - var lr = (Gtk.TreeListRow)s.get_item(i); - GLib.debug("check node %s", lr.get_item().get_type().name()); - if (((JsRender.Node)lr.get_item()).oid == node.oid) { - row = i; - break; - } - } + var row = this.nodeToRow(node); + var s = _this.view.el.model as Gtk.SingleSelection; + if (row < 0) { // select none? GLib.debug("Could not find node"); diff --git a/src/Builder4/WindowRooView.bjs b/src/Builder4/WindowRooView.bjs index e9da027dc..10100d7f2 100644 --- a/src/Builder4/WindowRooView.bjs +++ b/src/Builder4/WindowRooView.bjs @@ -506,14 +506,14 @@ "# string prop_selected" : "\"\"", "$ xns" : "GtkSource", "* init" : [ - "{", - " ", - " this.css = new Gtk.CssProvider();", + "\t{", + "", + "\tthis.css = new Gtk.CssProvider();", "\t ", "\tthis.css.load_from_string(", "\t\t\"#roo-view { font: 10px monospace; }\"", "\t);", - " ", + "", "\tGtk.StyleContext.add_provider_for_display(", "\t\tthis.el.get_display(),", "\t\tthis.css,", @@ -521,66 +521,56 @@ "\t);", "\t\t", "\t ", - " ", - " this.loading = true;", - " //var buf = this.el.get_buffer();", - " //buf.notify.connect(this.onCursorChanged);", - " ", - " ", - " 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;", + "\t//var buf = this.el.get_buffer();", + "\t//buf.notify.connect(this.onCursorChanged);", + "", + "", + "\tvar attrs = new GtkSource.MarkAttributes();", + "\tattrs.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();", + "\twattrs.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);", + "", + "", " ", - " ", - " this.el.set_mark_attributes (\"grey\", gattrs, 1);", - " ", - " ", - " ", - " ", - " ", - " ", - "}", - " " + "", + "", + "\t}", + "" ], "* pack" : "set_child", "Gtk.CssProvider css" : "", @@ -591,6 +581,26 @@ "items" : [ { "$ xns" : "GtkSource", + "* init" : [ + "{", + "\tvar buf = this.el;", + "\tbuf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);", + "\tbuf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");", + "\tbuf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");", + "\tbuf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");", + "\tbuf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");", + "\tbuf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");", + "\tbuf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");", + "\tbuf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");", + "", + "", + "\tbuf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");", + "\tbuf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");", + "\tbuf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");", + "}", + "", + "" + ], "* pack" : "set_buffer", "bool dirty" : false, "bool in_cursor_change" : false, @@ -709,31 +719,6 @@ ] }, "xtype" : "Buffer", - "| 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" : [ " () {", " ", @@ -841,17 +826,6 @@ "}", "" ], - "| 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;", @@ -1639,6 +1613,9 @@ "\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\");", @@ -1647,30 +1624,35 @@ " \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 + 1;", - "\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 ", - "\t buf.get_iter_at_line_offset( out iter, eline, (int)diag.range.start.character);", + "\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);", diff --git a/src/Builder4/WindowRooView.vala b/src/Builder4/WindowRooView.vala index bdb59cf26..7c4f1dfff 100644 --- a/src/Builder4/WindowRooView.vala +++ b/src/Builder4/WindowRooView.vala @@ -271,6 +271,9 @@ public class Xcls_WindowRooView : Object } var ar = this.file.getErrors(); if (ar.size < 1) { + buf.remove_tag_by_name ("ERR", start, end); + buf.remove_tag_by_name ("WARN", start, end); + buf.remove_tag_by_name ("DEPR", start, end); buf.remove_source_marks (start, end, null); this.last_error_counter = file.error_counter ; GLib.debug("higjlight has no errors"); @@ -279,30 +282,35 @@ public class Xcls_WindowRooView : Object if (this.last_error_counter == file.error_counter) { return; } - - - - var tlines = buf.get_line_count () +1; buf.remove_source_marks (start, end, null); + buf.remove_tag_by_name ("ERR", start, end); + buf.remove_tag_by_name ("WARN", start, end); + buf.remove_tag_by_name ("DEPR", start, end); foreach(var diag in ar) { Gtk.TextIter iter; // print("get inter\n"); - var eline = (int)diag.range.start.line + 1; - + var eline = (int)diag.range.start.line ; + var eline_to = (int)diag.range.end.line; if (eline > tlines || eline < 0) { return; } - buf.get_iter_at_line_offset( out iter, eline, (int)diag.range.start.character); + buf.get_iter_at_line( out iter, eline); + buf.get_iter_at_line_offset( out start, + eline, (int)diag.range.start.character); + buf.get_iter_at_line_offset( out end, + eline_to, (int)diag.range.end.character); + + buf.apply_tag_by_name(diag.category, start, end); var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message); @@ -1091,13 +1099,13 @@ public class Xcls_WindowRooView : Object // init method { - - this.css = new Gtk.CssProvider(); + + this.css = new Gtk.CssProvider(); this.css.load_from_string( "#roo-view { font: 10px monospace; }" ); - + Gtk.StyleContext.add_provider_for_display( this.el.get_display(), this.css, @@ -1105,65 +1113,55 @@ public class Xcls_WindowRooView : Object ); - - this.loading = true; - //var buf = this.el.get_buffer(); - //buf.notify.connect(this.onCursorChanged); - - - 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.loading = true; + //var buf = this.el.get_buffer(); + //buf.notify.connect(this.onCursorChanged); + + + var attrs = new GtkSource.MarkAttributes(); + 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(); + 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(); + 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); + + - - this.el.set_mark_attributes ("grey", gattrs, 1); - - - - - - - } + + + } //listeners this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { @@ -1462,15 +1460,6 @@ public class Xcls_WindowRooView : Object } - } - public 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 ; - - - - } public void clearGreySelection () { // clear all the marks.. @@ -1521,6 +1510,25 @@ public class Xcls_WindowRooView : Object // set gobject values + // init method + + { + 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"); + } + //listeners this.el.cursor_moved.connect( ( ) => { GLib.debug("cursor moved called"); @@ -1626,29 +1634,6 @@ 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 string toString () { Gtk.TextIter s; diff --git a/src/Palete/Gtk.vala b/src/Palete/Gtk.vala index 53873b2e9..f880ebdbc 100644 --- a/src/Palete/Gtk.vala +++ b/src/Palete/Gtk.vala @@ -665,256 +665,7 @@ namespace Palete { } - public override Gee.ArrayList suggestComplete( - JsRender.JsRender file, - JsRender.Node? node, - JsRender.NodeProp? xxxprop, // is this even used? - string complete_string - ) { - - var ret = new Gee.ArrayList(); - return ret; - /* - // completion rules?? - - // make sure data is loaded - Gir.factory(this.project,"Gtk"); - - // Roo...... - - // this. (based on the node type) - // this.xxx // Node and any determination... - - if (complete_string.index_of(".",0) < 0) { - // string does not have a '.' - // offer up vala keywords... / _this .. / look for var string = .. in the code.. - - var max = (int)Vala.TokenType.YIELD +1; - for (var i =0; i < max;i++) { - var m = (Vala.TokenType)i; - var s = m.to_string(); - var ss = s.slice(1,-1); - if (s[0] == '`' && GLib.Regex.match_simple("^[a-z]+$", ss) && - complete_string != ss && ss.index_of(complete_string,0) == 0 ) { - var sci = new CompletionProposal(ss,ss, "vala : " + ss); - ret.add(sci); - } - } - var miter = ((Project.Gtk)this.project).gir_cache.map_iterator(); - while (miter.next()) { - var ss = miter.get_key(); - - if (complete_string != ss && ss.index_of(complete_string,0) == 0 ) { - var sci = new CompletionProposal(ss,ss, "vala namespace: " + ss); - ret.add(sci); - - } - } - - - if (complete_string != "_this" && "_this".index_of(complete_string,0) == 0 ) { // should we ignore exact matches... ??? - var sci = new CompletionProposal("_this - the top level element","_this", - "Reference to the container object instance of this file"); - ret.add(sci); - - } - // basic types.. - - return ret; - } - - - // got at least one ".". - var parts = complete_string.split("."); - var curtype = ""; - var cur_instance = false; - if (parts[0] == "this") { - // work out from the node, what the type is... - if (node == null) { - print("node is empty - no return\n"); - return ret; // no idea.. - } - curtype = "*" + node.fqn(); - cur_instance = true; - } else { - if (((Project.Gtk)this.project).gir_cache.get(parts[0]) == null) { - return ret; - } - curtype = parts[0]; - } - // all Gtk.... etc.. types... - - - //if (parts[0] == "Roo") { - // curtype = "Roo"; - // cur_instance = false; - //} - - var prevbits = parts[0] + "."; - for(var i =1; i < parts.length; i++) { - print("matching %d/%d\n", i, parts.length); - var is_last = i == parts.length -1; - - - - // look up all the properties of the type... - var cls = this.getClass(curtype); - if (cls == null && curtype[0] != '*') { - print("could not get class of curtype %s\n", curtype); - return ret; - } - - if (!is_last) { - - if (curtype[0] == '*' && parts[i] == "el") { - curtype = curtype.substring(1); - prevbits += parts[i] + "."; - continue; - } - - // only exact matches from here on... - if (cur_instance) { - if (cls == null) { - return ret; - } - if (cls.props.has_key(parts[i])) { - var clsprop = cls.props.get(parts[i]); - if (clsprop.type.index_of(".",0) > -1) { - // type is another roo object.. - curtype = clsprop.type; - prevbits += parts[i] + "."; - continue; - } - return ret; - } - - - - // check methods?? - we do not export that at present.. - return ret; //no idea... - } - var look = prevbits + parts[i]; - var scls = this.getClass(look); - if (scls == null) { - return ret; - } - curtype = look; - prevbits += parts[i] + "."; - continue; - - } - - // got to the last element.. - print("Got last element\n"); - if (curtype == "") { // should not happen.. we would have returned already.. - return ret; - } - print("Got last element type %s\n",curtype); - if (!cur_instance) { - print("matching instance"); - // it's a static reference.. - var citer = cls.classes.map_iterator(); - while (citer.next()) { - var scls = citer.get_key(); - - if (parts[i].length > 0 && scls.index_of(parts[i],0) != 0) { - continue; - } - // got a starting match.. - var sci = new CompletionProposal(prevbits + scls,prevbits + scls,scls); - ret.add(sci); - - - } - // methods.... - citer = cls.methods.map_iterator(); - while (citer.next()) { - var scls = citer.get_key(); - - if (parts[i].length > 0 && scls.index_of(parts[i],0) != 0) { - continue; - } - // got a starting match.. - - var sci = new CompletionProposal(prevbits + scls + citer.get_value().sig,prevbits + scls,scls); - ret.add(sci); - - } - - // enums.... - citer = cls.consts.map_iterator(); - while (citer.next()) { - var scls = citer.get_key(); - - if (parts[i].length > 0 && scls.index_of(parts[i],0) != 0) { - continue; - } - // got a starting match.. - var sci = new CompletionProposal(prevbits + scls + citer.get_value().sig,prevbits + scls,scls); - ret.add(sci); - - } - - - return ret; - } - print("matching property"); - if (cls == null) { - return ret; - } - - - var citer = cls.methods.map_iterator(); - while (citer.next()) { - var cprop = citer.get_value(); - // does the name start with ... - if (parts[i].length > 0 && cprop.name.index_of(parts[i],0) != 0) { - continue; - } - // got a matching property... - // return type? - var sci = new CompletionProposal( cprop.name + cprop.sig + " : ("+ cprop.propertyof + ")", - prevbits + cprop.name + "(",cprop.doctxt); - ret.add(sci); - - - } - - // get the properties / methods and subclasses.. of cls.. - // we have cls.. - see if the string matches any of the properties.. - citer = cls.props.map_iterator(); - while (citer.next()) { - var cprop = citer.get_value(); - // does the name start with ... - if (parts[i].length > 0 && cprop.name.index_of(parts[i],0) != 0) { - continue; - } - // got a matching property... - var sci = new CompletionProposal(cprop.name + " : " + cprop.type + " ("+ cprop.propertyof + ")", - prevbits + cprop.name,cprop.doctxt); - ret.add(sci); - - - - } - - - return ret; - - - - - - } - - - - - - - return ret; - */ - } + void add_classes_from_method(GirObject cls, string method , Gee.ArrayList ret) diff --git a/src/Palete/Javascript.vala b/src/Palete/Javascript.vala index bb8390f28..6a7512b83 100644 --- a/src/Palete/Javascript.vala +++ b/src/Palete/Javascript.vala @@ -103,7 +103,7 @@ namespace Palete { } - + /* public Json.Object compressionErrors(string code , string fn) { @@ -124,21 +124,11 @@ namespace Palete { p.packFile(code, fn,""); - //state.showCompileResult(p.result); - /* - var g = new Json.Generator (); - - g.pretty = true; - g.indent = 2; - var n = new Json.Node(Json.NodeType.OBJECT); - n.set_object(p.result); - g.set_root (n); - - GLib.debug("got %s", g.to_data (null)); - */ + return p.result; } + */ /** * extension API concept.. diff --git a/src/Palete/LanguageClientVala.vala b/src/Palete/LanguageClientVala.vala index d535822b4..b92035e9e 100644 --- a/src/Palete/LanguageClientVala.vala +++ b/src/Palete/LanguageClientVala.vala @@ -241,7 +241,7 @@ namespace Palete { { switch (method) { case "textDocument/publishDiagnostics": - GLib.debug("got notification %s : %s", method , Json.to_string (Json.gvariant_serialize (return_value), true)); + //GLib.debug("got notification %s : %s", method , Json.to_string (Json.gvariant_serialize (return_value), true)); this.onDiagnostic(return_value); return; default: @@ -257,7 +257,7 @@ namespace Palete { */ public void onDiagnostic(Variant? return_value) { - GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true)); + //GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true)); var dg = Json.gobject_deserialize (typeof (Lsp.Diagnostics), Json.gvariant_serialize (return_value)) as Lsp.Diagnostics; this.log(LanguageClientAction.DIAG, dg.filename); var f = this.project.getByPath(dg.filename); diff --git a/src/Palete/Palete.vala b/src/Palete/Palete.vala index d677c5f3a..92b37bd76 100644 --- a/src/Palete/Palete.vala +++ b/src/Palete/Palete.vala @@ -127,12 +127,6 @@ namespace Palete public abstract GirObject? getClass(string ename); public abstract bool typeOptions(string fqn, string key, string type, out string[] opts); - public abstract Gee.ArrayList suggestComplete( - JsRender.JsRender file, - JsRender.Node? node, - JsRender.NodeProp? prop, - string complete_string - ); public abstract Gee.ArrayList getChildList(string in_rval, bool with_prop); public abstract Gee.ArrayList getDropList(string rval); public abstract JsRender.Node fqnToNode(string fqn); diff --git a/src/Palete/Roo.vala b/src/Palete/Roo.vala index e0b913177..853b8e0e0 100644 --- a/src/Palete/Roo.vala +++ b/src/Palete/Roo.vala @@ -373,203 +373,7 @@ namespace Palete { return true; } - public override Gee.ArrayList suggestComplete( - JsRender.JsRender file, - JsRender.Node? node, - JsRender.NodeProp? xxprop, - string complete_string - ) { - - var ret = new Gee.ArrayList(); - return ret; - /* - // completion rules?? - - // Roo...... - - // this. (based on the node type) - // this.xxx // Node and any determination... - - if (complete_string.index_of(".",0) < 0) { - // string does not have a '.' - // offer up this / Roo / javascript keywords... / look for var string = .. in the code.. - for(var i = 0; i < JsRender.Lang.match_strings.size ; i++) { - var str = JsRender.Lang.match_strings.get(i); - if (complete_string != str && str.index_of(complete_string,0) == 0 ) { - // should we ignore exact matches... ???tr,str, - var sci = new CompletionProposal(str,str, "javascript: " + str); - ret.add(sci); - - } - - - } - if (complete_string != "Roo" && "Roo".index_of(complete_string,0) == 0 ) { - // should we ignore exact matches... ??? - - var sci = new CompletionProposal("Roo - A Roo class","Roo", "Roo Library"); - ret.add(sci); - - } - if (complete_string != "_this" && "_this".index_of(complete_string,0) == 0 ) { - // should we ignore exact matches... ??? - var sci = new CompletionProposal("_this - Reference to the global pointer to the files main class instance", - "_this", "Reference to the global pointer to the files main class instance"); - ret.add(sci); - - } - return ret; - } - // got at least one ".". - var parts = complete_string.split("."); - var curtype = ""; - var cur_instance = false; - if (parts[0] == "this") { - // work out from the node, what the type is... - if (node == null) { - print("node is empty - no return\n"); - return ret; // no idea.. - } - curtype = node.fqn(); - cur_instance = true; - } - if (parts[0] == "Roo") { - curtype = "Roo"; - cur_instance = false; - } - - var prevbits = parts[0] + "."; - for(var i =1; i < parts.length; i++) { - print("matching %d/%d\n", i, parts.length); - var is_last = i == parts.length -1; - - // look up all the properties of the type... - var cls = this.getClass(curtype); - if (cls == null) { - print("could not get class of curtype %s\n", curtype); - return ret; - } - - if (!is_last) { - - // only exact matches from here on... - if (cur_instance) { - if (cls.props.has_key(parts[i])) { - var prop = cls.props.get(parts[i]); - if (prop.type.index_of(".",0) > -1) { - // type is another roo object.. - curtype = prop.type; - prevbits += parts[i] + "."; - continue; - } - return ret; - } - - - - // check methods?? - we do not export that at present.. - return ret; //no idea... - } - - // not a instance.. - //look for child classes. - var citer = this.classes.map_iterator(); - var foundit = false; - while (citer.next()) { - var scls = citer.get_key(); - var look = prevbits + parts[i]; - if (scls.index_of(look,0) != 0) { - continue; - } - // got a starting match.. - curtype = look; - cur_instance = false; - foundit =true; - break; - } - if (!foundit) { - return ret; - } - prevbits += parts[i] + "."; - continue; - } - // got to the last element.. - print("Got last element\n"); - if (curtype == "") { // should not happen.. we would have returned already.. - return ret; - } - print("Got last element type %s\n",curtype); - if (!cur_instance) { - print("matching instance"); - // it's a static reference.. - var citer = this.classes.map_iterator(); - while (citer.next()) { - var scls = citer.get_key(); - var look = prevbits + parts[i]; - if (parts[i].length > 0 && scls.index_of(look,0) != 0) { - continue; - } - - // got a starting match.. - var sci = new CompletionProposal(scls,scls,scls); - ret.add(sci); - } - return ret; - } - print("matching property"); - - - - var citer = cls.methods.map_iterator(); - while (citer.next()) { - var prop = citer.get_value(); - // does the name start with ... - if (parts[i].length > 0 && prop.name.index_of(parts[i],0) != 0) { - continue; - } - // got a matching property... - // return type? - - - var sci = new CompletionProposal(prop.name + prop.sig + " : ("+ prop.propertyof + ")", - prevbits + prop.name + "(",prop.doctxt); - ret.add(sci); - - } - - // get the properties / methods and subclasses.. of cls.. - // we have cls.. - see if the string matches any of the properties.. - citer = cls.props.map_iterator(); - while (citer.next()) { - var prop = citer.get_value(); - // does the name start with ... - if (parts[i].length > 0 && prop.name.index_of(parts[i],0) != 0) { - continue; - } - // got a matching property.. - var sci = new CompletionProposal(prop.name + prop.type + " : ("+ prop.propertyof + ")", - prevbits + prop.name + "(",prop.doctxt); - ret.add(sci); - - } - - - return ret; - - - - - - } - - - - - - - return ret; - */ - } + public override Gee.ArrayList getChildList(string in_rval, bool with_prop) diff --git a/src/Project/Project.vala b/src/Project/Project.vala index 8ffeef840..0b7d5d1a6 100644 --- a/src/Project/Project.vala +++ b/src/Project/Project.vala @@ -696,9 +696,9 @@ namespace Project { if (subdir == "autom4te.cache") { // automake? return; } - if (subdir == "debian") { // debian!? - return; - } + //if (subdir == "debian") { // debian!? + // return; + //} var dir = this.path + (subdir.length > 0 ? "/" : "") + subdir; -- 2.39.2