2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# GtkSource.SearchContext searchcontext" : "null",
7 "# JsRender.JsRender? file" : "null",
8 "# JsRender.Node node" : "null",
9 "# JsRender.NodeProp? prop" : "null",
10 "# Xcls_MainWindow window" : "null",
11 "# bool dirty" : false,
13 "# int last_error_counter" : 0,
14 "# int pos_root_x" : "",
15 "# int pos_root_y" : "",
16 "# string activeEditor" : "\"\"",
17 "$ homogeneous" : false,
20 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
21 "bool hexpand" : true,
22 "bool vexpand" : true,
23 "int last_search_end" : 0,
26 "$ homogeneous" : false,
28 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
29 "bool hexpand" : true,
38 " _this.saveContents();",
47 "bool hexpand" : true,
52 "* ctor" : "new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1)",
55 "\t//this.el.set_range(6,30);",
56 " \tthis.el.set_value ( BuilderApplication.settings.editor_font_size);",
57 " \tBuilderApplication.settings.editor_font_size_updated.connect(",
59 " \t\t\tBuilderApplication.settings.editor_font_size_inchange = true;",
60 " \t\t//\tGLib.debug(\"update range\");",
61 " \t\t \tthis.el.set_value (BuilderApplication.settings.editor_font_size);",
62 " \t\t \tBuilderApplication.settings.editor_font_size_inchange = false;",
70 "bool draw_value" : false,
71 "bool has_origin" : true,
72 "bool sensitive" : true,
74 "int width_request" : 200,
78 "\tif (BuilderApplication.settings.editor_font_size_inchange) {",
81 " \tBuilderApplication.settings.editor_font_size = val;",
95 "Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL",
96 "string icon_name" : "window-close",
103 " _this.saveContents();",
104 " _this.window.windowstate.switchState(WindowState.State.PREVIEW);",
109 "string icon_name" : "window-close",
117 "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
118 "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
119 "bool overlay_scrolling" : false,
120 "bool vexpand" : true,
121 "id" : "RightEditor",
124 "# Gtk.CssProvider css" : "null",
125 "$ gboolean auto_indent" : true,
126 "$ xns" : "GtkSource",
133 "this.el.completion.add_provider(",
134 "\tnew Palete.CompletionProvider(_this)",
137 "var hover = this.el.get_hover();",
138 "hover.add_provider(new Palete.HoverProvider(_this));",
140 "//this.el.completion.unblock_interactive();",
141 "this.el.completion.select_on_show = true; // select",
142 "//this.el.completion.remember_info_visibility\t = true;",
145 "var attrs = new GtkSource.MarkAttributes();",
147 "attrs.set_icon_name ( \"process-stop\"); ",
148 "attrs.query_tooltip_text.connect(( mark) => {",
149 " GLib.debug(\"tooltip query? %s\", mark.name);",
150 " return strdup( mark.name);",
152 " attrs.query_tooltip_markup.connect(( mark) => {",
153 " GLib.debug(\"tooltip query? %s\", mark.name);",
154 " return strdup( mark.name);",
156 "this.el.set_mark_attributes (\"ERR\", attrs, 1);",
160 "var wattrs = new GtkSource.MarkAttributes();",
161 "wattrs.set_icon_name ( \"process-stop\"); ",
162 "wattrs.query_tooltip_text.connect(( mark) => {",
163 " GLib.debug(\"tooltip query? %s\", mark.name);",
164 " return strdup(mark.name);",
166 "wattrs.query_tooltip_markup.connect(( mark) => {",
167 " GLib.debug(\"tooltip query? %s\", mark.name);",
168 " return strdup(mark.name);",
170 "this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
174 "var dattrs = new GtkSource.MarkAttributes();",
176 "dattrs.set_icon_name ( \"process-stop\"); ",
178 "dattrs.query_tooltip_text.connect(( mark) => {",
179 "\tGLib.debug(\"tooltip query? %s\", mark.name);",
180 " return strdup(mark.name);",
182 "//dattrs.query_tooltip_markup.connect(( mark) => {",
183 "//\tGLib.debug(\"tooltip query? %s\", mark.name);",
184 " // return strdup(mark.name);",
186 "this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
189 " this.el.get_space_drawer().set_matrix(null);",
190 " this.el.get_space_drawer().set_types_for_locations( ",
191 "\tGtkSource.SpaceLocationFlags.ALL,",
192 "\tGtkSource.SpaceTypeFlags.ALL",
194 "this.el.get_space_drawer().set_enable_matrix(true);",
198 "bool has_tooltip" : true,
199 "bool hexpand" : true,
200 "bool insert_spaces_instead_of_tabs" : true,
201 "bool vexpand" : true,
202 "boolean show_line_marks" : true,
203 "boolean show_line_numbers" : true,
204 "css_classes" : "{ \"code-editor\" }",
205 "gboolean highlight_current_line" : true,
210 "$ Gee.HashMap<int,string>? xmarks" : "null",
211 "$ xns" : "GtkSource",
212 "$ xtype" : "Buffer",
215 "var buf = this.el;",
216 "buf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);",
217 "buf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");",
218 "buf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");",
219 "buf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");",
220 "buf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");",
221 "buf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");",
222 "buf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");",
223 "buf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");",
226 "buf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");",
227 "buf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");",
228 "buf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");",
234 "bool check_queued" : false,
235 "bool enable_undo" : true,
236 "bool highlight_matching_brackets" : true,
237 "bool highlight_syntax" : true,
239 "int error_line" : "-1",
243 " // check syntax??",
245 " _this.save_button.el.sensitive = true;",
246 " print(\"EDITOR CHANGED\");",
247 " this.checkSyntax();",
249 " _this.dirty = true;",
251 " // this.get('/LeftPanel.model').changed( str , false);",
257 "| bool OLDhighlightErrorsJson" : [
258 "(string type, Json.Object obj) {",
259 "\tGtk.TextIter start;",
260 "\tGtk.TextIter end; ",
261 "\tthis.el.get_bounds (out start, out end);",
263 "\tthis.el.remove_source_marks (start, end, type);",
264 "\tGLib.debug(\"highlight errors\");\t\t ",
266 "\t // we should highlight other types of errors..",
268 "\tif (!obj.has_member(type)) {",
269 "\t\tGLib.debug(\"Return has no errors\\n\");",
273 "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
275 "\t\t_this.window.windowstate.state != WindowState.State.CODE",
277 "\t\tGLib.debug(\"windowstate != CODEONLY?\");",
282 "\t//this.marks = new Gee.HashMap<int,string>();",
283 "\tvar err = obj.get_object_member(type);",
285 "\tif (_this.file == null) {",
286 "\t\tGLib.debug(\"file is null?\");",
290 "\tvar valafn = _this.file.path;",
292 "\tif (_this.file.xtype != \"PlainFile\") {",
294 "\t\tvalafn = \"\";",
296 "\t\t\tvar regex = new Regex(\"\\\\.bjs$\");",
297 "\t\t\t// should not happen",
298 "\t \t\tvalafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
299 "\t\t} catch (GLib.RegexError e) {",
300 "\t\t\treturn true;",
306 "\tif (!err.has_member(valafn)) {",
307 "\t\tGLib.debug(\"File path has no errors\");",
311 "\tvar lines = err.get_object_member(valafn);",
314 "\tif (obj.has_member(\"line_offset\")) { // ?? why??",
315 "\t\toffset = (int)obj.get_int_member(\"line_offset\") + 1;",
319 "\tvar tlines = this.el.get_line_count () +1;",
321 "\tif (_this.prop != null) {",
323 "\t\ttlines = _this.prop.end_line + 1;",
324 "\t\toffset = _this.prop.start_line + 1;",
330 "\tlines.foreach_member((obj, line, node) => {",
332 "\t Gtk.TextIter iter;",
333 "// print(\"get inter\\n\");",
334 "\t var eline = int.parse(line) - offset;",
335 "\t GLib.debug(\"GOT ERROR on line %s -- converted to %d (offset = %d)\\n\", line,eline, offset);",
338 "\t if (eline > tlines || eline < 0) {",
343 "\t this.el.get_iter_at_line( out iter, eline);",
344 "\t //print(\"mark line\\n\");",
345 "\t var msg = \"\";",
346 "\t var ar = lines.get_array_member(line);",
347 "\t for (var i = 0 ; i < ar.get_length(); i++) {",
348 "\t \tif (ar.get_string_element(i) == \"Success\") {",
351 "\t\t\tmsg += (msg.length > 0) ? \"\\n\" : \"\";",
352 "\t\t\tmsg += ar.get_string_element(i);",
354 "\t\tif (msg == \"\") {",
357 "\t\tmsg = \"Line: %d\".printf(eline+1) + \" \" + msg;",
358 "\t this.el.create_source_mark(msg, type, iter);",
359 "\t GLib.debug(\"set line %d to %m\", eline, msg);",
360 "\t // this.marks.set(eline, msg);",
371 "| bool checkSyntax" : [
375 " var str = this.toString();",
378 " if (this.error_line > 0) {",
379 " Gtk.TextIter start;",
380 " Gtk.TextIter end; ",
381 " this.el.get_bounds (out start, out end);",
383 " this.el.remove_source_marks (start, end, null);",
385 " if (str.length < 1) {",
386 " print(\"checkSyntax - empty string?\\n\");",
390 " // bit presumptiona",
391 " if (_this.file.xtype == \"PlainFile\") {",
393 " // assume it's gtk...",
394 " var oldcode =_this.file.toSource();",
395 " _this.file.setSource(str);",
396 "\t BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");",
397 " \t_this.file.getLanguageServer().document_change(_this.file);",
399 " _this.file.setSource(oldcode);",
405 " if (_this.file == null) {",
413 " GLib.debug(\"calling validate\"); ",
414 " // clear the buttons.",
415 " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
418 "\tvar oldcode = _this.prop.val;",
420 "\t_this.prop.val = str;",
421 "\t_this.node.updated_count++;",
422 " _this.file.getLanguageServer().document_change(_this.file);",
423 " _this.node.updated_count++;",
424 " _this.prop.val = oldcode;",
427 " //print(\"done mark line\\n\");",
429 " return true; // at present allow saving - even if it's invalid..",
433 "| bool highlightErrors" : [
434 "( Gee.HashMap<int,string> validate_res) {",
436 "\tthis.error_line = validate_res.size;",
438 "\tif (this.error_line < 1) {",
441 "\tvar tlines = this.el.get_line_count ();",
442 "\tGtk.TextIter iter;",
443 "\tvar valiter = validate_res.map_iterator();",
444 "\twhile (valiter.next()) {",
446 "\t// print(\"get inter\\n\");",
447 "\t\tvar eline = valiter.get_key();",
448 "\t\tif (eline > tlines) {",
451 "\t\tthis.el.get_iter_at_line( out iter, eline);",
452 "\t\t//print(\"mark line\\n\");",
453 "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
458 "| string toString" : [
463 " this.el.get_start_iter(out s);",
464 " this.el.get_end_iter(out e);",
465 " var ret = this.el.get_text(s,e,true);",
466 " //print(\"TO STRING? \" + ret);",
473 "# bool is_control" : false,
478 "(keyval, keycode, state) => {",
480 " \tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
481 " \t\tthis.is_control = true;",
488 "(keyval, keycode, state) => {",
490 " \t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
491 " \t\tthis.is_control = false;",
493 " if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
494 " GLib.debug(\"SAVE: ctrl-S pressed\");",
495 " _this.saveContents();",
499 " if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
500 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
501 "\t\t_this.forwardSearch(true);",
504 "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
505 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
506 "\t\t_this.search_entry.el.grab_focus();",
507 "\t\t_this.search_entry.el.select_region(0,-1);",
510 "\tif (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
511 "\t\t_this.view.el.show_completion();",
514 "\tGtk.TextIter iter;",
515 "\t_this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position); ",
516 "\tvar line = iter.get_line();",
517 "\tvar offset = iter.get_line_offset();",
518 "\tGLib.debug(\"line %d off %d\", line ,offset);",
519 "\tif (_this.prop != null) {",
520 "\t\tline += _this.prop.start_line + 1; // i think..",
521 "\t\toffset += 12; // should probably be 8 without namespaced ",
522 "\t\tGLib.debug(\"guess line %d off %d\", line ,offset);",
524 " //_this.view.el.show_completion();",
525 " // print(event.key.keyval)",
537 "xtype" : "EventControllerKey"
540 "# double distance" : "0.0f",
542 "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
546 "\tif (!_this.keystate.is_control) {",
549 "\t //GLib.debug(\"scroll %f\", dy);",
551 "\tthis.distance += dy;",
553 "\t//GLib.debug(\"scroll %f / %f\", dy, this.distance);",
555 "\t if (this.distance < -1) {",
557 "\t\tBuilderApplication.settings.editor_font_size ++;",
558 "\t\tthis.distance = 0;",
560 "\tif (this.distance > 1) {",
561 "\t\tBuilderApplication.settings.editor_font_size --;",
562 "\t\tthis.distance = 0;",
570 "xtype" : "EventControllerScroll"
575 "(x, y, keyboard_tooltip, tooltip) => {",
577 "\t//GLib.debug(\"query tooltip\");",
578 "\tGtk.TextIter iter;",
581 "\tvar yoff = (int) _this.RightEditor.el.vadjustment.value;",
583 "\t// I think this is problematic - if it's compliing / updating at same time as query.",
585 "\t//if (_this.window.statusbar_compile_spinner.el.spinning) {",
586 "\t//\treturn false;",
589 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
591 "\tvar l = iter.get_line();",
595 "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
601 "\tif (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {",
602 "\t\tGLib.debug(\"line %d setting tip to %s\", l, _this.buffer.marks.get(l));",
603 "\t\ttooltip.set_text(_this.buffer.marks.get(l).dup());",
611 "\t// this crashes?? - not sure why.",
612 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
613 "\tif (marks.is_empty()) {",
614 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
616 "\tif (marks.is_empty()) {",
617 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
620 "\t// GLib.debug(\"query tooltip line %d marks %d\", (int)l, (int) marks.length());",
622 "\tmarks.@foreach((m) => { ",
623 "\t\t//GLib.debug(\"got mark %s\", m.name);",
624 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.category + \": \" + m.name;",
626 "\t// true if there is a mark..",
627 "\tif (str.length > 0 ) {",
628 "\t\ttooltip.set_text( str );",
630 "\treturn str.length > 0 ? true : false;",
636 "string name" : "editor-view",
637 "uint tab_width" : 4,
642 "// show the help page for the active node..",
643 " //this.get('/Help').show();",
645 " // this.get('/BottomPane').el.set_current_page(0);",
646 " \tGLib.debug(\"load called - Reset undo buffer\");",
648 " var buf = (GtkSource.Buffer)this.el.get_buffer();",
649 " buf.begin_irreversible_action();",
650 " buf.set_text(str, str.length);",
651 " buf.end_irreversible_action();",
653 " var lm = GtkSource.LanguageManager.get_default();",
654 " var lang = \"vala\";",
655 " if (_this.file != null) {",
656 " lang = _this.file.language;",
658 " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
659 " var lg = _this.file.content_type.length > 0 ?",
660 " lm.guess_language(_this.file.path, _this.file.content_type) :",
661 " lm.get_language(lang);",
664 " ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); ",
666 " this.el.insert_spaces_instead_of_tabs = true;",
667 " if (lg != null) {",
668 "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);",
669 "\t\tif (lg.name == \"Vala\") {",
670 "\t\t this.el.insert_spaces_instead_of_tabs = false;",
673 " _this.dirty = false;",
674 " this.el.grab_focus();",
675 " _this.save_button.el.sensitive = false;",
676 " _this.last_error_counter = -1;",
681 "xtype" : "ScrolledWindow"
686 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
687 "bool homogeneous" : false,
688 "bool vexpand" : false,
693 "Gtk.CssProvider css" : "",
694 "bool hexpand" : true,
695 "id" : "search_entry",
701 "(keyval, keycode, state) => {",
703 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
704 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
705 "\t\t_this.forwardSearch(true);",
710 " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
711 "\t\t_this.forwardSearch(true);",
717 " // print(event.key.keyval)",
724 "xtype" : "EventControllerKey"
731 "_this.search(_this.search_entry.el.text);",
732 "\t _this.search_results.updateResults();",
734 "\tGLib.Timeout.add_seconds(1,() => {",
735 "\t\t _this.search_results.updateResults();",
736 "\t\t return false;",
742 "string name" : "editor-search-entry",
743 "string placeholder_text" : "Press enter to search",
744 "uint search_delay" : 3,
745 "xtype" : "SearchEntry",
746 "| void forwardSearch" : [
747 "(bool change_focus) {",
750 "\t_this.forwardSearch(change_focus);",
754 "\tswitch(_this.windowstate.state) {",
755 "\t\tcase WindowState.State.CODEONLY:",
756 "\t\t//case WindowState.State.CODE:",
757 "\t\t\t// search the code being edited..",
758 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
761 "\t\tcase WindowState.State.PREVIEW:",
762 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
763 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
765 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
778 "id" : "search_results",
779 "int margin_end" : 4,
780 "int margin_start" : 4,
781 "string label" : "No Results",
783 "| void updateResults" : [
785 "\tthis.el.visible = true;",
787 "\tvar res = _this.searchcontext.get_occurrences_count();",
789 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
793 "\t_this.nextBtn.el.sensitive = false;",
794 "\t_this.backBtn.el.sensitive = false;\t",
797 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
798 "\t\t_this.nextBtn.el.sensitive = true;",
799 "\t\t_this.backBtn.el.sensitive = true;",
802 "\t_this.search_results.el.label = \"No Matches\";",
809 "bool always_show_image" : true,
810 "bool sensitive" : false,
816 "\t_this.forwardSearch(true);",
823 "string icon_name" : "go-down",
828 "bool always_show_image" : true,
829 "bool sensitive" : false,
835 "\t_this.backSearch(true);",
841 "string icon_name" : "go-up",
846 "bool always_show_arrow" : true,
847 "bool always_show_image" : true,
851 "* prop" : "popover",
852 "id" : "search_settings",
857 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
868 "id" : "case_sensitive",
869 "string label" : "Case Sensitive",
870 "xtype" : "CheckButton"
881 "string label" : "Regex",
882 "xtype" : "CheckButton"
887 "string label" : "Multi-line (add \\n)",
888 "xtype" : "CheckButton"
897 "string icon_name" : "emblem-system",
898 "xtype" : "MenuButton"
905 "| bool saveContents" : [
909 " if (_this.file == null) {",
915 " var str = _this.buffer.toString();",
917 " _this.buffer.checkSyntax();",
921 " // LeftPanel.model.changed( str , false);",
922 " _this.dirty = false;",
923 " _this.save_button.el.sensitive = false;",
925 " // find the text for the node..",
926 " if (_this.file.xtype != \"PlainFile\") {",
927 " // in theory these properties have to exist!?!",
928 " \tthis.prop.val = str;",
929 " //this.window.windowstate.left_props.reload();",
931 " _this.file.setSource( str );",
934 " // call the signal..",
944 "\tvar s = new GtkSource.SearchSettings();",
945 "\ts.case_sensitive = _this.case_sensitive.el.active;",
946 "\ts.regex_enabled = _this.regex.el.active;\t",
947 "\ts.wrap_around = false;",
949 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
950 "\tthis.searchcontext.set_highlight(true);",
951 "\tvar txt = in_txt;",
953 "\tif (_this.multiline.el.active) {",
954 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
957 "\ts.set_search_text(txt);",
958 "\tGtk.TextIter beg, st,en;",
960 "\tthis.buffer.el.get_start_iter(out beg);",
961 "\tbool has_wrapped_around;",
962 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
963 "\tthis.last_search_end = 0;",
965 "\treturn this.searchcontext.get_occurrences_count();",
973 "| string tempFileContents" : [
977 " if (_this.file == null) {",
980 "\tvar str= this.buffer.toString();",
981 "\tif (_this.file.xtype == \"PlainFile\") {",
989 " GLib.debug(\"calling validate\"); ",
990 " // clear the buttons.",
991 " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
992 "\t\treturn this.file.toSource(); ;",
995 "\tvar oldcode = _this.prop.val;",
996 "\t_this.prop.val = str;",
997 " var ret = _this.file.toSource();",
998 " _this.prop.val = oldcode;",
1003 "| void backSearch" : [
1004 "(bool change_focus) {",
1006 "\tif (this.searchcontext == null) {",
1010 "\tGtk.TextIter beg, st,en;",
1011 "\tbool has_wrapped_around;",
1012 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1014 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1015 "\t\tthis.last_search_end = 0;",
1017 "\t\tthis.last_search_end = en.get_offset();",
1018 "\t\tif (change_focus) {",
1019 "\t\t\tthis.view.el.grab_focus();",
1021 "\t\tthis.buffer.el.place_cursor(st);",
1022 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1028 "| void forwardSearch" : [
1029 "(bool change_focus) {",
1031 "\tif (this.searchcontext == null) {",
1035 "\tGtk.TextIter beg, st,en;",
1036 "\t bool has_wrapped_around;",
1037 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
1038 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1040 "\t\tthis.last_search_end = 0; // not sure if this should happen",
1042 "\t\tif (has_wrapped_around) {",
1046 "\t\tthis.last_search_end = en.get_offset();",
1047 "\t\tif (change_focus) {",
1048 "\t\t\tthis.view.el.grab_focus();",
1050 "\t\tthis.buffer.el.place_cursor(st);",
1051 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1059 "\t this.file = null; ",
1061 " this.node = null;",
1062 " this.prop = null;",
1063 "\tthis.searchcontext = null;",
1068 "| void scroll_to_line" : [
1071 "\tGLib.Timeout.add(500, () => {",
1073 "\t\tvar buf = this.view.el.get_buffer();",
1075 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1078 "\t\tGtk.TextIter iter; ",
1079 "\t\tsbuf.get_iter_at_line(out iter, line);",
1080 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1081 "\t\treturn false;",
1087 "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
1090 " this.file = file; ",
1092 " if (file.xtype != \"PlainFile\") {",
1093 " \tthis.prop = prop;",
1094 " this.node = node;",
1096 " // find the text for the node..",
1097 " this.view.load( prop.val );",
1098 " this.updateErrorMarks();",
1100 " this.close_btn.el.show(); ",
1103 " this.view.load( file.toSource() );",
1104 " this.updateErrorMarks();",
1105 " this.close_btn.el.hide();",
1111 "| void updateErrorMarks" : [
1116 "\tvar buf = _this.buffer.el;",
1117 "\tGtk.TextIter start;",
1118 "\tGtk.TextIter end; ",
1119 "\tbuf.get_bounds (out start, out end);",
1124 "\t//GLib.debug(\"highlight errors\");\t\t ",
1126 "\t // we should highlight other types of errors..",
1128 "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
1130 "\t\t_this.window.windowstate.state != WindowState.State.CODE",
1132 "\t\t//GLib.debug(\"windowstate != CODEONLY?\");",
1138 "\tif (_this.file == null) {",
1139 "\t\tGLib.debug(\"file is null?\");",
1143 "\tvar ar = this.file.getErrors();",
1144 "\tif (ar.size < 1) {",
1145 "\t\tbuf.remove_source_marks (start, end, \"ERR\");",
1146 "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
1147 "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
1148 "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1149 "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1150 "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1151 "\t\tthis.last_error_counter = file.error_counter ;",
1152 "\t\t//GLib.debug(\"highlight %s : %s has no errors\", this.file.relpath, category);",
1157 " // basicaly check if there is no change, then we do not do any update..",
1158 " // we can do this by just using an error counter?",
1159 " // if that's changed then we will do an update, otherwise dont bother.",
1162 "\tvar offset = 0;",
1163 "\tvar hoffset = 0;",
1165 "\tvar tlines = buf.get_line_count () +1;",
1167 "\tif (_this.prop != null) {",
1168 "\t\t// this still seems flaky...",
1170 "\t\ttlines = _this.prop.end_line;",
1171 "\t\toffset = _this.prop.start_line;",
1172 "\t\thoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..",
1176 "\t\t// no update...",
1177 "\t\tif (this.last_error_counter == file.error_counter) {",
1183 "\tbuf.remove_source_marks (start, end, \"ERR\");",
1184 "\tbuf.remove_source_marks (start, end, \"WARN\");",
1185 "\tbuf.remove_source_marks (start, end, \"DEPR\");",
1186 "\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1187 "\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1188 "\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1190 "\tforeach(var diag in ar) { ",
1191 "\t Gtk.TextIter iter;",
1192 "// print(\"get inter\\n\");",
1193 "\t var eline = (int)diag.range.start.line - offset;",
1194 "\t var eline_to = (int)diag.range.end.line - offset;",
1195 "\t //var eline = diag.range.end_line - offset;",
1196 "\t //GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
1197 "\t //\terr.line ,eline, offset);",
1200 "\t if (eline > tlines || eline < 0) {",
1204 "\t buf.get_iter_at_line( out iter, eline);",
1205 "\t \tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
1206 "\t buf.create_source_mark( msg, diag.category, iter);",
1208 " \t var spos = (int)diag.range.start.character - hoffset;",
1209 " \t if (spos < 0) { spos =0 ; }",
1210 " \t if (spos > iter.get_chars_in_line()) {",
1211 " \t \tspos = iter.get_chars_in_line();",
1213 "\t\tbuf.get_iter_at_line( out iter, eline_to);",
1214 "\t\tvar epos = (int)diag.range.end.character - hoffset;",
1215 " \t if (epos < 0) { epos =0 ; }",
1216 " \t if (epos > iter.get_chars_in_line()) {",
1217 " \t \tepos = iter.get_chars_in_line();",
1221 " \t buf.get_iter_at_line_offset( out start, eline, spos); ",
1223 " \t buf.get_iter_at_line_offset( out end, eline_to,epos); ",
1225 "\t buf.apply_tag_by_name(diag.category, start, end);",
1227 "\t // GLib.debug(\"set line %d to %s\", eline, msg);",
1228 "\t //this.marks.set(eline, msg);",
1230 "\tthis.last_error_counter = file.error_counter ;",