public Xcls_sourceviewscroll sourceviewscroll;
public Xcls_sourceview sourceview;
public Xcls_buffer buffer;
+ public Xcls_keystate keystate;
public Xcls_search_entry search_entry;
public Xcls_search_results search_results;
public Xcls_nextBtn nextBtn;
// my vars (def)
public Gtk.Widget lastObj;
public Xcls_MainWindow main_window;
+ public int last_error_counter;
public int last_search_end;
public GtkSource.SearchContext searchcontext;
public JsRender.JsRender file;
// my vars (dec)
this.lastObj = null;
+ this.last_error_counter = 0;
this.last_search_end = 0;
this.file = null;
this.view.renderJS(true);
this.notebook.el.page = 0;// gtk preview
this.sourceview.loadFile();
+ this.last_error_counter = -1;
+ this.updateErrorMarks();
}
public void highlightNodeAtLine (int ln) {
}
- public void updateErrorMarks (string category) {
+ public void updateErrorMarks () {
Gtk.TextIter end;
buf.get_bounds (out start, out end);
- buf.remove_source_marks (start, end, category);
+
GLib.debug("highlight errors");
return;
}
- var ar = this.file.getErrors(category);
- if (ar == null || ar.get_n_items() < 1) {
- GLib.debug("higjlight %s has no errors", category);
+ 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, "ERR");
+ buf.remove_source_marks (start, end, "WARN");
+ buf.remove_source_marks (start, end, "DEPR");
+ this.last_error_counter = file.error_counter ;
+ GLib.debug("higjlight has no errors");
+ return;
+ }
+ if (this.last_error_counter == file.error_counter) {
return;
}
-
-
-
-
- var offset = 0;
-
var tlines = buf.get_line_count () +1;
- for (var i = 0; i < ar.get_n_items();i++) {
- var err = (Palete.CompileError) ar.get_item(i);
+ buf.remove_source_marks (start, end, "ERR");
+ buf.remove_source_marks (start, end, "WARN");
+ buf.remove_source_marks (start, end, "DEPR");
+ 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 = err.line - offset;
- GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
- err.line ,eline, offset);
-
-
+ 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, err.category, err.msg);
- buf.create_source_mark( msg, err.category, iter);
+ var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
+ buf.create_source_mark( msg, diag.category, iter);
GLib.debug("set line %d to %s", eline, msg);
//this.marks.set(eline, msg);
}
- return ;
+ this.last_error_counter = file.error_counter ;
new Xcls_label_code( _this );
new Xcls_paned( _this );
this.el.append_page ( _this.paned.el , _this.label_preview.el );
- var child_4 = new Xcls_Box13( _this );
+ var child_4 = new Xcls_Box12( _this );
child_4.ref();
this.el.append_page ( child_4.el , _this.label_code.el );
}
// set gobject values
this.el.homogeneous = false;
this.el.vexpand = true;
- var child_1 = new Xcls_Box7( _this );
+ var child_1 = new Xcls_Box6( _this );
child_1.ref();
this.el.append( child_1.el );
new Xcls_view( _this );
// user defined functions
}
- public class Xcls_Box7 : Object
+ public class Xcls_Box6 : Object
{
public Gtk.Box el;
private Xcls_WindowRooView _this;
// my vars (def)
// ctor
- public Xcls_Box7(Xcls_WindowRooView _owner )
+ public Xcls_Box6(Xcls_WindowRooView _owner )
{
_this = _owner;
this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
this.el.homogeneous = true;
this.el.height_request = 20;
this.el.vexpand = false;
- var child_1 = new Xcls_Button8( _this );
+ var child_1 = new Xcls_Button7( _this );
child_1.ref();
this.el.append( child_1.el );
new Xcls_AutoRedraw( _this );
this.el.append( _this.AutoRedraw.el );
- var child_3 = new Xcls_Button10( _this );
+ var child_3 = new Xcls_Button9( _this );
child_3.ref();
this.el.append( child_3.el );
}
// user defined functions
}
- public class Xcls_Button8 : Object
+ public class Xcls_Button7 : Object
{
public Gtk.Button el;
private Xcls_WindowRooView _this;
// my vars (def)
// ctor
- public Xcls_Button8(Xcls_WindowRooView _owner )
+ public Xcls_Button7(Xcls_WindowRooView _owner )
{
_this = _owner;
this.el = new Gtk.Button();
// user defined functions
}
- public class Xcls_Button10 : Object
+ public class Xcls_Button9 : Object
{
public Gtk.Button el;
private Xcls_WindowRooView _this;
// my vars (def)
// ctor
- public Xcls_Button10(Xcls_WindowRooView _owner )
+ public Xcls_Button9(Xcls_WindowRooView _owner )
{
_this = _owner;
this.el = new Gtk.Button();
//listeners
this.el.script_dialog.connect( (dialog) => {
-
-
- if (this.el == null) {
- return true;
- }
-
- var msg = dialog.get_message();
- if (msg.length < 4) {
- return false;
- }
-
- GLib.debug("script dialog got %s", msg);
-
- if (msg.substring(0,4) != "IPC:") {
- return false;
- }
- var ar = msg.split(":", 3);
- if (ar.length < 3) {
- return false;
- }
- switch(ar[1]) {
- case "SAVEHTML":
- GLib.debug("GOT saveHTML %d", ar[2].length);
- _this.file.saveHTML(ar[2]);
- _this.createThumb();
- return true;
- default:
- return false;
- }
+ if (this.el == null) {
+ return true;
+ }
+
+ var msg = dialog.get_message();
+ if (msg.length < 4) {
+ return false;
+ }
+
+ //GLib.debug("script dialog got %s", msg);
+
+ if (msg.substring(0,4) != "IPC:") {
+ return false;
+ }
+ var ar = msg.split(":", 3);
+ if (ar.length < 3) {
+ return false;
+ }
+
+ switch(ar[1]) {
+
+ case "SAVEHTML":
+ // GLib.debug("GOT saveHTML %d", ar[2].length);
+ _this.file.saveHTML(ar[2]);
+ _this.createThumb();
+ return true;
+
+ default:
+ return false;
+ }
});
this.el.ready_to_show.connect( ( ) => {
}
this.refreshRequired = true;
+
}
public void reInit () {
print("reInit?");
{
// this is run every 2 seconds from the init..
-
-
+
if (!this.refreshRequired) {
// print("no refresh required");
return;
this.pendingRedraw = true;
var runhtml = "<script type=\"text/javascript\">\n" ;
- string builderhtml;
+ uint8[] builderhtml;
try {
- GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + "/resources/roo.builder.js", out builderhtml);
+ GLib. File.new_for_uri("resource:///html/roo.builder.js").load_contents(null, out builderhtml, null);
} catch (Error e) {
- builderhtml = "";
+ builderhtml = {};
}
- runhtml += builderhtml + "\n";
+ runhtml += (string) builderhtml + "\n";
runhtml += "</script>\n" ;
// fix to make sure they are the same..
this.runhtml = project.runhtml;
// need to modify paths
- string inhtml;
+ uint8[] inhtml;
var base_template = project.base_template;
+ var f = GLib. File.new_for_uri("resource:///html/" + base_template);
- if (base_template.length > 0 && !FileUtils.test(
- BuilderApplication.configDirectory() + "/resources/" + base_template, FileTest.EXISTS)
- ) {
- print("invalid base_template name - using default: %s\n", base_template);
- base_template = "";
+ if (base_template.length > 0 && !f.query_exists(null)) {
+
+ GLib.debug("invalid base_template name - using default: %s", base_template);
+ f = GLib. File.new_for_uri("resource:///html/roo.builder.html");
}
try {
- GLib.FileUtils.get_contents(
- BuilderApplication.configDirectory() + "/resources/" +
- (base_template.length > 0 ? base_template : "roo.builder.html")
- , out inhtml);
+ f.load_contents(null, out inhtml, null);
+
} catch (Error e) {
- inhtml = "";
+ inhtml = {};
}
this.renderedData = js;
//this.runjs = js_src;
var fc = FakeServerCache.factory_with_data(js_src);
this.runjs = fc.fname;
+ var html = (string) inhtml;
+ html = html.replace("</head>", runhtml + this.runhtml +
+ "<script type=\"text/javascript\" src=\"xhttp://localhost" + fc.fname + "\"></script>" +
+ // "<script type=\"text/javascript\">\n" +
+ // js_src + "\n" +
+ // "</script>" +
+
+ "</head>");
+ //print("LOAD HTML " + html);
+
+ var rootURL = project.rootURL;
+
- var html = inhtml.replace("</head>", runhtml + this.runhtml +
- "<script type=\"text/javascript\" src=\"xhttp://localhost" + fc.fname + "\"></script>" +
- // "<script type=\"text/javascript\">\n" +
- // js_src + "\n" +
- // "</script>" +
-
- "</head>");
- //print("LOAD HTML " + html);
-
- var rootURL = project.rootURL;
-
-
-
- this.el.load_html( html ,
- //fixme - should be a config option!
- (rootURL.length > 0 ? rootURL : "xhttp://localhost/roobuilder/")
- );
- this.initInspector();
+
+ this.el.load_html( html ,
+ //fixme - should be a config option!
+ (rootURL.length > 0 ? rootURL : "xhttp://localhost/roobuilder/")
+ );
+ this.initInspector();
// force the inspector...
// this.initInspector();
}
- public class Xcls_Box13 : Object
+ public class Xcls_Box12 : Object
{
public Gtk.Box el;
private Xcls_WindowRooView _this;
// my vars (def)
// ctor
- public Xcls_Box13(Xcls_WindowRooView _owner )
+ public Xcls_Box12(Xcls_WindowRooView _owner )
{
_this = _owner;
this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
this.el.vexpand = true;
new Xcls_sourceviewscroll( _this );
this.el.append( _this.sourceviewscroll.el );
- var child_2 = new Xcls_Box18( _this );
+ var child_2 = new Xcls_Box17( _this );
child_2.ref();
this.el.append( child_2.el );
}
public bool loading;
public bool button_is_pressed;
public string prop_selected;
+ public Gtk.CssProvider? css;
public bool key_is_pressed;
- public Gtk.CssProvider css;
public JsRender.Node? node_selected;
// ctor
this.loading = true;
this.button_is_pressed = false;
this.prop_selected = "";
+ this.css = null;
this.key_is_pressed = false;
this.node_selected = null;
this.el.editable = false;
this.el.show_line_marks = true;
this.el.show_line_numbers = true;
+ this.el.css_classes = { "code-editor" };
new Xcls_buffer( _this );
this.el.set_buffer ( _this.buffer.el );
- var child_2 = new Xcls_EventControllerKey17( _this );
- child_2.ref();
- this.el.add_controller ( child_2.el );
+ new Xcls_keystate( _this );
+ this.el.add_controller ( _this.keystate.el );
+ var child_3 = new Xcls_EventControllerScroll32( _this );
+ child_3.ref();
+ this.el.add_controller( child_3.el );
// init method
{
-
- 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,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
- );
-
+
-
- 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) => {
buf.set_text("",0);
- var sbuf = (GtkSource.Buffer) buf;
+
}
- }
- 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 class Xcls_EventControllerKey17 : Object
+ public class Xcls_keystate : Object
{
public Gtk.EventControllerKey el;
private Xcls_WindowRooView _this;
// my vars (def)
+ public bool is_control;
// ctor
- public Xcls_EventControllerKey17(Xcls_WindowRooView _owner )
+ public Xcls_keystate(Xcls_WindowRooView _owner )
{
_this = _owner;
+ _this.keystate = this;
this.el = new Gtk.EventControllerKey();
// my vars (dec)
+ this.is_control = false;
// set gobject values
//listeners
+ this.el.key_released.connect( (keyval, keycode, state) => {
+
+
+ if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
+ this.is_control = false;
+ }
+ });
this.el.key_pressed.connect( (keyval, keycode, state) => {
-
+ if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
+ this.is_control = true;
+ }
if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
GLib.debug("SAVE: ctrl-g pressed");
// user defined functions
}
+ public class Xcls_EventControllerScroll32 : Object
+ {
+ public Gtk.EventControllerScroll el;
+ private Xcls_WindowRooView _this;
- public class Xcls_Box18 : Object
+ // my vars (def)
+ public double distance;
+
+ // ctor
+ public Xcls_EventControllerScroll32(Xcls_WindowRooView _owner )
+ {
+ _this = _owner;
+ this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
+
+ // my vars (dec)
+ this.distance = 0.0f;
+
+ // set gobject values
+
+ //listeners
+ this.el.scroll.connect( (dx, dy) => {
+ if (!_this.keystate.is_control) {
+ return false;
+ }
+ //GLib.debug("scroll %f", dy);
+
+ this.distance += dy;
+ if (this.distance < 1) {
+ BuilderApplication.settings.editor_font_size ++;
+ this.distance = 0;
+ }
+ if (this.distance > -1) {
+ BuilderApplication.settings.editor_font_size --;
+ this.distance = 0;
+ }
+
+ return true;
+ });
+ }
+
+ // user defined functions
+ }
+
+
+
+ public class Xcls_Box17 : Object
{
public Gtk.Box el;
private Xcls_WindowRooView _this;
// my vars (def)
// ctor
- public Xcls_Box18(Xcls_WindowRooView _owner )
+ public Xcls_Box17(Xcls_WindowRooView _owner )
{
_this = _owner;
this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
this.el.append( _this.nextBtn.el );
new Xcls_backBtn( _this );
this.el.append( _this.backBtn.el );
- var child_5 = new Xcls_MenuButton24( _this );
+ var child_5 = new Xcls_MenuButton23( _this );
child_5.ref();
this.el.append( child_5.el );
}
// my vars (def)
- public Gtk.CssProvider css;
// ctor
public Xcls_search_entry(Xcls_WindowRooView _owner )
this.el.name = "roo-search-entry";
this.el.hexpand = true;
this.el.placeholder_text = "Press enter to search";
- var child_1 = new Xcls_EventControllerKey20( _this );
+ var child_1 = new Xcls_EventControllerKey19( _this );
child_1.ref();
this.el.add_controller( child_1.el );
- // init method
-
- this.css = new Gtk.CssProvider();
-
- this.css.load_from_string(
- "#roo-search-entry { background-color: #ccc; }"
- );
-
- Gtk.StyleContext.add_provider_for_display(
- this.el.get_display(),
- this.css,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
- );
-
//listeners
this.el.search_changed.connect( ( ) => {
}
}
- public class Xcls_EventControllerKey20 : Object
+ public class Xcls_EventControllerKey19 : Object
{
public Gtk.EventControllerKey el;
private Xcls_WindowRooView _this;
// my vars (def)
// ctor
- public Xcls_EventControllerKey20(Xcls_WindowRooView _owner )
+ public Xcls_EventControllerKey19(Xcls_WindowRooView _owner )
{
_this = _owner;
this.el = new Gtk.EventControllerKey();
// user defined functions
}
- public class Xcls_MenuButton24 : Object
+ public class Xcls_MenuButton23 : Object
{
public Gtk.MenuButton el;
private Xcls_WindowRooView _this;
public bool always_show_image;
// ctor
- public Xcls_MenuButton24(Xcls_WindowRooView _owner )
+ public Xcls_MenuButton23(Xcls_WindowRooView _owner )
{
_this = _owner;
this.el = new Gtk.MenuButton();
// my vars (dec)
// set gobject values
- var child_1 = new Xcls_Box26( _this );
+ var child_1 = new Xcls_Box25( _this );
+ child_1.ref();
this.el.child = child_1.el;
}
// user defined functions
}
- public class Xcls_Box26 : Object
+ public class Xcls_Box25 : Object
{
public Gtk.Box el;
private Xcls_WindowRooView _this;
// my vars (def)
// ctor
- public Xcls_Box26(Xcls_WindowRooView _owner )
+ public Xcls_Box25(Xcls_WindowRooView _owner )
{
_this = _owner;
this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );