* 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 <alan@touchbox> Sun, 28 Jan 2024 06:54:56 +0800
roobuilder (5.0.1) unstable; urgency=medium
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'),
if (ww == null || ww.windowstate == null || ww.windowstate.project ==null) {
continue;
}
+
ww.windowstate.updateErrorMarksAll();
ww.updateErrors();
ww.windowstate.left_tree.updateErrors();
ww.windowstate.left_props.updateErrors();
-
+
}
}
-
+
\ No newline at end of file
");",
"\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",
"",
"",
"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);",
"});",
"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);",
"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(); ",
"",
"$ 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",
""
]
},
- "| 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<int,string> 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; ",
"\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<int,string> 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" : [
" () {",
" ",
" this.el.grab_focus();",
" _this.save_button.el.sensitive = false;",
" _this.last_error_counter = -1;",
- "\t_this.updateErrorMarks();",
- " ",
"}"
]
}
"",
" // 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();",
+ " ",
" }",
" ",
"}"
"\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;",
"",
"\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 {",
"\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}",
// 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();
+
}
}
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;
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 {
}
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);
}
);
-
- /*
- 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
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);
});
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);
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();
this.el.grab_focus();
_this.save_button.el.sensitive = false;
_this.last_error_counter = -1;
- _this.updateErrorMarks();
-
}
}
public class Xcls_buffer : 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( () => {
}
// 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);
}
+ 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<int,string> validate_res) {
this.error_line = validate_res.size;
"# 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 ",
"\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" : "",
"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,
"\t}",
"\tvar ar = this.file.getErrors();",
"\tif (ar.size < 1) {",
+ "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
+ "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
+ "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
"\t\tbuf.remove_source_marks (start, end, null);",
"\t\tthis.last_error_counter = file.error_counter ;",
"\t\tGLib.debug(\"higjlight has no errors\");",
" ",
"\t ",
"\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 }",
"\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);",
}
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");
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;
}
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);
// init method
{
-
-
- this.css = new Gtk.CssProvider();
+
+
+ this.css = new Gtk.CssProvider();
this.css.load_from_string("#gtkview-view { font: 10px monospace ;}");
);
- 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) => {
// 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");
"bool loading" : false,
"bool vexpand" : true,
"id" : "LeftProps",
+ "int last_error_counter" : "-1",
"items" : [
{
"$ xns" : "Gtk",
"\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++) {",
"\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\") {",
"\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(); ",
" \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}",
}
],
"name" : "WindowLeftProps"
-}
+}
\ No newline at end of file
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;
this.loading = false;
this.allow_edit = false;
this.main_window = null;
+ this.last_error_counter = -1;
// set gobject values
this.el.homogeneous = false ;
}
-
public void updateErrors () {
var file = this.file;
var ar = file.getErrors();
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);
}
- 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();
header_height = h;
reading_header = false;
- continue;
+
}
if (child.get_type().name() != "GtkColumnViewRowWidget") {
}
// 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)
"bool hexpand" : true,
"bool vexpand" : true,
"id" : "WindowLeftTree",
+ "int last_error_counter" : "-1",
"items" : [
{
"$ xns" : "Gtk",
" 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;",
"}",
"\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" : [
"() {",
"",
" _this.main_window.windowstate.leftTreeNodeSelected(null);",
" // needed???",
" _this.main_window.windowstate.file = f;",
- " ",
+ " _this.last_error_counter = -1;",
" ",
" if (f.tree == null) {",
"\t try {",
" // 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;",
" ",
" ",
"| 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\");",
"}",
"",
""
+ ],
+ "| 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",
+ "}"
]
}
],
// 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);
// my vars (dec)
this.main_window = null;
+ this.last_error_counter = -1;
// set gobject values
this.el.hexpand = true;
}
// 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.
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;
}
_this.main_window.windowstate.leftTreeNodeSelected(null);
// needed???
_this.main_window.windowstate.file = f;
-
+ _this.last_error_counter = -1;
if (f.tree == null) {
try {
// 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 () {
}
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");
"# 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,",
"\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" : "",
"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,
]
},
"xtype" : "Buffer",
- "| bool highlightErrors" : [
- "( Gee.HashMap<int,string> 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" : [
" () {",
" ",
"}",
""
],
- "| 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;",
"\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\");",
" \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);",
}
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");
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);
// 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,
);
-
- 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) => {
}
- }
- 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..
// 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");
}
// user defined functions
- public bool highlightErrors ( Gee.HashMap<int,string> 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;
}
- public override Gee.ArrayList<CompletionProposal> suggestComplete(
- JsRender.JsRender file,
- JsRender.Node? node,
- JsRender.NodeProp? xxxprop, // is this even used?
- string complete_string
- ) {
-
- var ret = new Gee.ArrayList<CompletionProposal>();
- 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<string> ret)
}
-
+ /*
public Json.Object compressionErrors(string code , string fn)
{
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..
{
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:
*/
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);
public abstract GirObject? getClass(string ename);
public abstract bool typeOptions(string fqn, string key, string type, out string[] opts);
- public abstract Gee.ArrayList<CompletionProposal> suggestComplete(
- JsRender.JsRender file,
- JsRender.Node? node,
- JsRender.NodeProp? prop,
- string complete_string
- );
public abstract Gee.ArrayList<string> getChildList(string in_rval, bool with_prop);
public abstract Gee.ArrayList<string> getDropList(string rval);
public abstract JsRender.Node fqnToNode(string fqn);
return true;
}
- public override Gee.ArrayList<CompletionProposal> suggestComplete(
- JsRender.JsRender file,
- JsRender.Node? node,
- JsRender.NodeProp? xxprop,
- string complete_string
- ) {
-
- var ret = new Gee.ArrayList<CompletionProposal>();
- 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<string> getChildList(string in_rval, bool with_prop)
if (subdir == "autom4te.cache") { // automake?
return;
}
- if (subdir == "debian") { // debian!?
- return;
- }
+ //if (subdir == "debian") { // debian!?
+ // return;
+ //}
var dir = this.path + (subdir.length > 0 ? "/" : "") + subdir;