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,
27 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
31 "* prop" : "start_child",
32 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
36 "$ homogeneous" : false,
38 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
39 "bool hexpand" : true,
48 " _this.saveContents();",
57 "bool hexpand" : true,
62 "* ctor" : "new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1)",
65 "\t//this.el.set_range(6,30);",
66 " \tthis.el.set_value ( BuilderApplication.settings.editor_font_size);",
67 " \tBuilderApplication.settings.editor_font_size_updated.connect(",
69 " \t\t\tBuilderApplication.settings.editor_font_size_inchange = true;",
70 " \t\t//\tGLib.debug(\"update range\");",
71 " \t\t \tthis.el.set_value (BuilderApplication.settings.editor_font_size);",
72 " \t\t \tBuilderApplication.settings.editor_font_size_inchange = false;",
80 "bool draw_value" : false,
81 "bool has_origin" : true,
82 "bool sensitive" : true,
84 "int width_request" : 200,
88 "\tif (BuilderApplication.settings.editor_font_size_inchange) {",
91 " \tBuilderApplication.settings.editor_font_size = val;",
105 "Gtk.IconSize icon_size" : "Gtk.IconSize.NORMAL",
106 "string icon_name" : "window-close",
113 " _this.saveContents();",
114 " _this.window.windowstate.switchState(WindowState.State.PREVIEW);",
119 "string icon_name" : "window-close",
127 "Gtk.PolicyType hscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
128 "Gtk.PolicyType vscrollbar_policy" : "Gtk.PolicyType.AUTOMATIC",
129 "bool overlay_scrolling" : false,
130 "bool vexpand" : true,
131 "id" : "RightEditor",
134 "# Gtk.CssProvider css" : "null",
135 "$ gboolean auto_indent" : true,
136 "$ xns" : "GtkSource",
143 "this.el.completion.add_provider(",
144 "\tnew Palete.CompletionProvider(_this)",
147 "// hover seems pretty useless.. - ??",
148 "//var hover = this.el.get_hover();",
149 "//hover.add_provider(new Palete.HoverProvider(_this));",
151 "//this.el.completion.unblock_interactive();",
152 "this.el.completion.select_on_show = true; // select",
153 "//this.el.completion.remember_info_visibility\t = true;",
156 "var attrs = new GtkSource.MarkAttributes();",
158 "attrs.set_icon_name ( \"process-stop\"); ",
159 "attrs.query_tooltip_text.connect(( mark) => {",
160 " GLib.debug(\"tooltip query? %s\", mark.name);",
161 " return strdup( mark.name);",
163 " attrs.query_tooltip_markup.connect(( mark) => {",
164 " GLib.debug(\"tooltip query? %s\", mark.name);",
165 " return strdup( mark.name);",
167 "this.el.set_mark_attributes (\"ERR\", attrs, 1);",
171 "var wattrs = new GtkSource.MarkAttributes();",
172 "wattrs.set_icon_name ( \"process-stop\"); ",
173 "wattrs.query_tooltip_text.connect(( mark) => {",
174 " GLib.debug(\"tooltip query? %s\", mark.name);",
175 " return strdup(mark.name);",
177 "wattrs.query_tooltip_markup.connect(( mark) => {",
178 " GLib.debug(\"tooltip query? %s\", mark.name);",
179 " return strdup(mark.name);",
181 "this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
185 "var dattrs = new GtkSource.MarkAttributes();",
187 "dattrs.set_icon_name ( \"process-stop\"); ",
189 "dattrs.query_tooltip_text.connect(( mark) => {",
190 "\tGLib.debug(\"tooltip query? %s\", mark.name);",
191 " return strdup(mark.name);",
193 "//dattrs.query_tooltip_markup.connect(( mark) => {",
194 "//\tGLib.debug(\"tooltip query? %s\", mark.name);",
195 " // return strdup(mark.name);",
197 "this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
200 " this.el.get_space_drawer().set_matrix(null);",
201 " this.el.get_space_drawer().set_types_for_locations( ",
202 "\tGtkSource.SpaceLocationFlags.ALL,",
203 "\tGtkSource.SpaceTypeFlags.ALL",
205 "this.el.get_space_drawer().set_enable_matrix(true);",
209 "bool has_tooltip" : true,
210 "bool hexpand" : true,
211 "bool insert_spaces_instead_of_tabs" : true,
212 "bool vexpand" : true,
213 "boolean show_line_marks" : true,
214 "boolean show_line_numbers" : true,
215 "css_classes" : "{ \"code-editor\" }",
216 "gboolean highlight_current_line" : true,
221 "$ Gee.HashMap<int,string>? xmarks" : "null",
222 "$ xns" : "GtkSource",
223 "$ xtype" : "Buffer",
226 "var buf = this.el;",
227 "buf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);",
228 "buf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");",
229 "buf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");",
230 "buf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");",
231 "buf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");",
232 "buf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");",
233 "buf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");",
234 "buf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");",
237 "buf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");",
238 "buf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");",
239 "buf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");",
245 "bool check_queued" : false,
246 "bool enable_undo" : true,
247 "bool highlight_matching_brackets" : true,
248 "bool highlight_syntax" : true,
250 "int error_line" : "-1",
254 " // check syntax??",
256 " _this.save_button.el.sensitive = true;",
257 " print(\"EDITOR CHANGED\");",
258 " this.checkSyntax();",
260 " _this.dirty = true;",
262 " // this.get('/LeftPanel.model').changed( str , false);",
270 "\tGtk.TextIter iter;",
271 "\tthis.el.get_iter_at_offset (",
272 "\t\t\tout iter, this.el.cursor_position);",
273 "\tvar line = iter.get_line();",
274 "\t_this.navigation.updateSelectedLine(iter.get_line());",
281 "| bool OLDhighlightErrorsJson" : [
282 "(string type, Json.Object obj) {",
283 "\tGtk.TextIter start;",
284 "\tGtk.TextIter end; ",
285 "\tthis.el.get_bounds (out start, out end);",
287 "\tthis.el.remove_source_marks (start, end, type);",
288 "\tGLib.debug(\"highlight errors\");\t\t ",
290 "\t // we should highlight other types of errors..",
292 "\tif (!obj.has_member(type)) {",
293 "\t\tGLib.debug(\"Return has no errors\\n\");",
297 "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
299 "\t\t_this.window.windowstate.state != WindowState.State.CODE",
301 "\t\tGLib.debug(\"windowstate != CODEONLY?\");",
306 "\t//this.marks = new Gee.HashMap<int,string>();",
307 "\tvar err = obj.get_object_member(type);",
309 "\tif (_this.file == null) {",
310 "\t\tGLib.debug(\"file is null?\");",
314 "\tvar valafn = _this.file.path;",
316 "\tif (_this.file.xtype != \"PlainFile\") {",
318 "\t\tvalafn = \"\";",
320 "\t\t\tvar regex = new Regex(\"\\\\.bjs$\");",
321 "\t\t\t// should not happen",
322 "\t \t\tvalafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
323 "\t\t} catch (GLib.RegexError e) {",
324 "\t\t\treturn true;",
330 "\tif (!err.has_member(valafn)) {",
331 "\t\tGLib.debug(\"File path has no errors\");",
335 "\tvar lines = err.get_object_member(valafn);",
338 "\tif (obj.has_member(\"line_offset\")) { // ?? why??",
339 "\t\toffset = (int)obj.get_int_member(\"line_offset\") + 1;",
343 "\tvar tlines = this.el.get_line_count () +1;",
345 "\tif (_this.prop != null) {",
347 "\t\ttlines = _this.prop.end_line + 1;",
348 "\t\toffset = _this.prop.start_line + 1;",
354 "\tlines.foreach_member((obj, line, node) => {",
356 "\t Gtk.TextIter iter;",
357 "// print(\"get inter\\n\");",
358 "\t var eline = int.parse(line) - offset;",
359 "\t GLib.debug(\"GOT ERROR on line %s -- converted to %d (offset = %d)\\n\", line,eline, offset);",
362 "\t if (eline > tlines || eline < 0) {",
367 "\t this.el.get_iter_at_line( out iter, eline);",
368 "\t //print(\"mark line\\n\");",
369 "\t var msg = \"\";",
370 "\t var ar = lines.get_array_member(line);",
371 "\t for (var i = 0 ; i < ar.get_length(); i++) {",
372 "\t \tif (ar.get_string_element(i) == \"Success\") {",
375 "\t\t\tmsg += (msg.length > 0) ? \"\\n\" : \"\";",
376 "\t\t\tmsg += ar.get_string_element(i);",
378 "\t\tif (msg == \"\") {",
381 "\t\tmsg = \"Line: %d\".printf(eline+1) + \" \" + msg;",
382 "\t this.el.create_source_mark(msg, type, iter);",
383 "\t GLib.debug(\"set line %d to %m\", eline, msg);",
384 "\t // this.marks.set(eline, msg);",
395 "| bool checkSyntax" : [
399 " var str = this.toString();",
402 " if (this.error_line > 0) {",
403 " Gtk.TextIter start;",
404 " Gtk.TextIter end; ",
405 " this.el.get_bounds (out start, out end);",
407 " this.el.remove_source_marks (start, end, null);",
409 " if (str.length < 1) {",
410 " print(\"checkSyntax - empty string?\\n\");",
414 " // bit presumptiona",
415 " if (_this.file.xtype == \"PlainFile\") {",
417 " // assume it's gtk...",
418 " var oldcode =_this.file.toSource();",
419 " _this.file.setSource(str);",
420 "\t BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");",
421 " \t_this.file.getLanguageServer().document_change(_this.file);",
423 " _this.file.setSource(oldcode);",
429 " if (_this.file == null) {",
437 " GLib.debug(\"calling validate\"); ",
438 " // clear the buttons.",
439 " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
442 "\tvar oldcode = _this.prop.val;",
444 "\t_this.prop.val = str;",
445 "\t_this.node.updated_count++;",
446 " _this.file.getLanguageServer().document_change(_this.file);",
447 " _this.node.updated_count++;",
448 " _this.prop.val = oldcode;",
451 " //print(\"done mark line\\n\");",
453 " return true; // at present allow saving - even if it's invalid..",
457 "| bool highlightErrors" : [
458 "( Gee.HashMap<int,string> validate_res) {",
460 "\tthis.error_line = validate_res.size;",
462 "\tif (this.error_line < 1) {",
465 "\tvar tlines = this.el.get_line_count ();",
466 "\tGtk.TextIter iter;",
467 "\tvar valiter = validate_res.map_iterator();",
468 "\twhile (valiter.next()) {",
470 "\t// print(\"get inter\\n\");",
471 "\t\tvar eline = valiter.get_key();",
472 "\t\tif (eline > tlines) {",
475 "\t\tthis.el.get_iter_at_line( out iter, eline);",
476 "\t\t//print(\"mark line\\n\");",
477 "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
482 "| string toString" : [
487 " this.el.get_start_iter(out s);",
488 " this.el.get_end_iter(out e);",
489 " var ret = this.el.get_text(s,e,true);",
490 " //print(\"TO STRING? \" + ret);",
497 "# bool is_control" : false,
502 "(keyval, keycode, state) => {",
504 " \tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
505 " \t\tthis.is_control = true;",
512 "(keyval, keycode, state) => {",
514 " \t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
515 " \t\tthis.is_control = false;",
517 " if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
518 " GLib.debug(\"SAVE: ctrl-S pressed\");",
519 " _this.saveContents();",
523 " if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
524 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
525 "\t\t_this.forwardSearch(true);",
528 "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
529 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
530 "\t\t_this.search_entry.el.grab_focus();",
531 "\t\t_this.search_entry.el.select_region(0,-1);",
534 "\tif (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
535 "\t\t_this.view.el.show_completion();",
538 "\tGtk.TextIter iter;",
539 "\t_this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position); ",
540 "\tvar line = iter.get_line();",
541 "\tvar offset = iter.get_line_offset();",
542 "\tGLib.debug(\"line %d off %d\", line ,offset);",
543 "\tif (_this.prop != null) {",
544 "\t\tline += _this.prop.start_line + 1; // i think..",
545 "\t\toffset += 12; // should probably be 8 without namespaced ",
546 "\t\tGLib.debug(\"guess line %d off %d\", line ,offset);",
548 " //_this.view.el.show_completion();",
549 " // print(event.key.keyval)",
561 "xtype" : "EventControllerKey"
564 "# double distance" : "0.0f",
566 "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
570 "\tif (!_this.keystate.is_control) {",
573 "\t //GLib.debug(\"scroll %f\", dy);",
575 "\tthis.distance += dy;",
577 "\t//GLib.debug(\"scroll %f / %f\", dy, this.distance);",
579 "\t if (this.distance < -1) {",
581 "\t\tBuilderApplication.settings.editor_font_size ++;",
582 "\t\tthis.distance = 0;",
584 "\tif (this.distance > 1) {",
585 "\t\tBuilderApplication.settings.editor_font_size --;",
586 "\t\tthis.distance = 0;",
594 "xtype" : "EventControllerScroll"
598 "xtype" : "GestureClick"
603 "(x, y, keyboard_tooltip, tooltip) => {",
605 "\t//GLib.debug(\"query tooltip\");",
606 "\tGtk.TextIter iter;",
609 "\tvar yoff = (int) _this.RightEditor.el.vadjustment.value;",
611 "\t// I think this is problematic - if it's compliing / updating at same time as query.",
613 "\t//if (_this.window.statusbar_compile_spinner.el.spinning) {",
614 "\t//\treturn false;",
617 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
619 "\tvar l = iter.get_line();",
623 "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
629 "\tif (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {",
630 "\t\tGLib.debug(\"line %d setting tip to %s\", l, _this.buffer.marks.get(l));",
631 "\t\ttooltip.set_text(_this.buffer.marks.get(l).dup());",
639 "\t// this crashes?? - not sure why.",
640 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
641 "\tif (marks.is_empty()) {",
642 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
644 "\tif (marks.is_empty()) {",
645 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
648 "\t// GLib.debug(\"query tooltip line %d marks %d\", (int)l, (int) marks.length());",
650 "\tmarks.@foreach((m) => { ",
651 "\t\t//GLib.debug(\"got mark %s\", m.name);",
652 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.category + \": \" + m.name;",
654 "\t// true if there is a mark..",
655 "\tif (str.length > 0 ) {",
656 "\t\ttooltip.set_text( str );",
658 "\treturn str.length > 0 ? true : false;",
664 "string name" : "editor-view",
665 "uint tab_width" : 4,
670 "// show the help page for the active node..",
671 " //this.get('/Help').show();",
673 " // this.get('/BottomPane').el.set_current_page(0);",
674 " \tGLib.debug(\"load called - Reset undo buffer\");",
676 " var buf = (GtkSource.Buffer)this.el.get_buffer();",
677 " buf.begin_irreversible_action();",
678 " buf.set_text(str, str.length);",
679 " buf.end_irreversible_action();",
681 " var lm = GtkSource.LanguageManager.get_default();",
682 " var lang = \"vala\";",
683 " if (_this.file != null) {",
684 " lang = _this.file.language;",
686 " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
687 " var lg = _this.file.content_type.length > 0 ?",
688 " lm.guess_language(_this.file.path, _this.file.content_type) :",
689 " lm.get_language(lang);",
692 " ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); ",
694 " this.el.insert_spaces_instead_of_tabs = true;",
695 " if (lg != null) {",
696 "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);",
697 "\t\tif (lg.name == \"Vala\") {",
698 "\t\t this.el.insert_spaces_instead_of_tabs = false;",
701 " _this.dirty = false;",
702 " this.el.grab_focus();",
703 " _this.save_button.el.sensitive = false;",
704 " _this.last_error_counter = -1;",
709 "xtype" : "ScrolledWindow"
714 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
715 "bool homogeneous" : false,
716 "bool vexpand" : false,
721 "Gtk.CssProvider css" : "",
722 "bool hexpand" : true,
723 "id" : "search_entry",
729 "(keyval, keycode, state) => {",
731 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
732 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
733 "\t\t_this.forwardSearch(true);",
738 " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
739 "\t\t_this.forwardSearch(true);",
745 " // print(event.key.keyval)",
752 "xtype" : "EventControllerKey"
759 "_this.search(_this.search_entry.el.text);",
760 "\t _this.search_results.updateResults();",
762 "\tGLib.Timeout.add_seconds(1,() => {",
763 "\t\t _this.search_results.updateResults();",
764 "\t\t return false;",
770 "string name" : "editor-search-entry",
771 "string placeholder_text" : "Press enter to search",
772 "uint search_delay" : 3,
773 "xtype" : "SearchEntry",
774 "| void forwardSearch" : [
775 "(bool change_focus) {",
778 "\t_this.forwardSearch(change_focus);",
782 "\tswitch(_this.windowstate.state) {",
783 "\t\tcase WindowState.State.CODEONLY:",
784 "\t\t//case WindowState.State.CODE:",
785 "\t\t\t// search the code being edited..",
786 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
789 "\t\tcase WindowState.State.PREVIEW:",
790 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
791 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
793 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
806 "id" : "search_results",
807 "int margin_end" : 4,
808 "int margin_start" : 4,
809 "string label" : "No Results",
811 "| void updateResults" : [
813 "\tthis.el.visible = true;",
815 "\tvar res = _this.searchcontext.get_occurrences_count();",
817 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
821 "\t_this.nextBtn.el.sensitive = false;",
822 "\t_this.backBtn.el.sensitive = false;\t",
825 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
826 "\t\t_this.nextBtn.el.sensitive = true;",
827 "\t\t_this.backBtn.el.sensitive = true;",
830 "\t_this.search_results.el.label = \"No Matches\";",
837 "bool always_show_image" : true,
838 "bool sensitive" : false,
844 "\t_this.forwardSearch(true);",
851 "string icon_name" : "go-down",
856 "bool always_show_image" : true,
857 "bool sensitive" : false,
863 "\t_this.backSearch(true);",
869 "string icon_name" : "go-up",
874 "bool always_show_arrow" : true,
875 "bool always_show_image" : true,
879 "* prop" : "popover",
880 "id" : "search_settings",
885 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
896 "id" : "case_sensitive",
897 "string label" : "Case Sensitive",
898 "xtype" : "CheckButton"
909 "string label" : "Regex",
910 "xtype" : "CheckButton"
915 "string label" : "Multi-line (add \\n)",
916 "xtype" : "CheckButton"
925 "string icon_name" : "emblem-system",
926 "xtype" : "MenuButton"
936 "* prop" : "end_child",
937 "bool visible" : false,
938 "id" : "navigationwindow",
941 "# int last_selected_line" : "-1",
942 "# int selected_row" : "-1",
949 "bool expand" : true,
953 "* prop" : "factory",
957 "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
959 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
960 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
963 "\tvar hbox = (Gtk.Box) expand.child;",
966 "\tvar img = (Gtk.Image) hbox.get_first_child();",
967 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
969 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
970 "\tvar sym = (Lsp.DocumentSymbol) lr.get_item();",
972 "\tGLib.debug(\"got %d children for %s\" , (int)sym.children.get_n_items(), sym.name);",
974 " expand.set_hide_expander( sym.children.get_n_items() < 1);",
975 " \texpand.set_list_row(lr);",
977 " \tsym.bind_property(\"symbol_icon\",",
978 " img, \"icon_name\",",
979 " GLib.BindingFlags.SYNC_CREATE);",
981 " \thbox.add_css_class(sym.symbol_icon);",
983 " \tsym.bind_property(\"name\",",
985 " GLib.BindingFlags.SYNC_CREATE);",
986 " \t// should be better?- --line no?",
987 " \tsym.bind_property(\"tooltip\",",
988 " lbl, \"tooltip_markup\",",
989 " GLib.BindingFlags.SYNC_CREATE);",
990 " \t// bind image...",
998 "\tvar expand = new Gtk.TreeExpander();",
1000 "\texpand.set_indent_for_depth(true);",
1001 "\texpand.set_indent_for_icon(true);",
1002 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1003 "\tvar icon = new Gtk.Image();",
1004 "\tvar lbl = new Gtk.Label(\"\");",
1005 "\tlbl.use_markup = true;",
1006 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1008 "\ticon.margin_end = 4;",
1009 " \tlbl.justify = Gtk.Justification.LEFT;",
1010 " \tlbl.xalign = 0;",
1012 "//\tlistitem.activatable = true; ??",
1014 "\thbox.append(icon);",
1015 "\thbox.append(lbl);",
1016 "\texpand.set_child(hbox);",
1017 "\t((Gtk.ListItem)listitem).set_child(expand);",
1023 "xtype" : "SignalListItemFactory"
1026 "string title" : "Code Navigation",
1027 "xtype" : "ColumnViewColumn"
1032 "id" : "navigationselmodel",
1039 "$ Gtk.TreeListModelCreateModelFunc create_func" : [
1042 "\treturn ((Lsp.DocumentSymbol)item).children;",
1048 "bool autoexpand" : true,
1049 "bool passthrough" : false,
1052 "$ GLib.Type item_type" : "typeof(Lsp.DocumentSymbol)",
1055 "id" : "navliststore",
1056 "xtype" : "ListStore",
1057 "| Lsp.DocumentSymbol? symbolAtLine" : [
1061 "\tfor(var i = 0; i < this.el.get_n_items();i++) {",
1062 "\t\tvar el = (Lsp.DocumentSymbol)this.el.get_item(i);",
1063 "\t\tvar ret = el.containsLine(i);",
1064 "\t\tif (ret != null) {",
1065 "\t\t\treturn ret;",
1075 "xtype" : "TreeListModel"
1079 "* prop" : "sorter",
1083 "* prop" : "sorter",
1086 "$ GLib.Type this_type" : "typeof(Lsp.DocumentSymbol)",
1088 "* prop" : "expression",
1089 "string property_name" : "sort_key",
1090 "xtype" : "PropertyExpression"
1093 "xtype" : "StringSorter"
1096 "xtype" : "TreeListRowSorter"
1099 "xtype" : "SortListModel"
1102 "xtype" : "NoSelection",
1103 "| Lsp.DocumentSymbol? getSymbollAt" : [
1106 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1108 " var a = tr.get_item();; ",
1109 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1112 " return (Lsp.DocumentSymbol)tr.get_item();",
1116 "| int getRowFromSymbol" : [
1117 "(Lsp.DocumentSymbol sym) {",
1119 "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
1120 "\t\tvar tr = (Gtk.TreeListRow)this.el.get_item(i);",
1122 "\t\tif (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {",
1134 "(n_press, x, y) => {",
1136 " \tvar row = _this.navigation.getRowAt(x,y, out pos );",
1138 "\t GLib.debug(\"no row selected items\");",
1141 " //Lsp.DocumentSymbol",
1142 " var sym = _this.navigationselmodel.getSymbollAt(row);",
1143 " if (sym == null) {",
1149 " \"line\" : 1410,",
1150 " \"character\" : 8",
1153 " \"line\" : 1410,",
1154 " \"character\" : 39",
1158 " GLib.debug(\"goto line %d\", (int)sym.range.start.line); ",
1159 " _this.scroll_to_line((int)sym.range.start.line);",
1164 "xtype" : "GestureClick"
1167 "string name" : "editor-navigation",
1168 "xtype" : "ColumnView",
1169 "| Gtk.Widget? getWidgetAtRow" : [
1173 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1174 " \tvar colview = gesture.widget;",
1175 " \tvar line_no = check_list_widget(colview, x,y);",
1176 " if (line_no > -1) {",
1177 " \t\tvar item = colview.model.get_item(line_no);",
1181 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1182 " var child = this.el.get_first_child(); ",
1183 " \tvar line_no = -1; ",
1184 " \tvar reading_header = true;",
1186 " \twhile (child != null) {",
1187 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1189 " \t if (reading_header) {",
1192 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1194 "\t\t\t\t\tchild = child.get_next_sibling();",
1195 "\t\t\t\t\tcontinue;",
1197 "\t\t\t\t// should be columnlistview",
1198 "\t\t\t\tchild = child.get_first_child(); ",
1202 "\t\t\t\treading_header = false;",
1203 "\t\t\t\tcontinue;",
1209 "\t\t\tif (line_no == row) {",
1210 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1211 "\t\t\t return (Gtk.Widget)child;",
1213 "\t child = child.get_next_sibling(); ",
1215 "\t\t//GLib.debug(\"Rturning null\");",
1220 "| int getRowAt" : [
1221 "(double x, double y, out string pos) {",
1224 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1225 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1226 "\tif (w == null) {",
1230 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1231 "\tif (row == null) {",
1235 "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1240 "\twhile (cr.get_prev_sibling() != null) {",
1242 "\t\tcr = cr.get_prev_sibling();",
1245 "\t//GLib.debug(\"row number is %d\", rn);",
1246 "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1247 "\t// above or belw",
1248 "\tGraphene.Rect bounds;",
1249 "\trow.compute_bounds(this.el, out bounds);",
1250 "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1251 "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1252 "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1254 "\tvar ypos = y - bounds.get_y();",
1255 "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1256 "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1257 "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1258 "\tpos = \"over\";",
1260 "\tif (rpos > 80) {",
1261 "\t\tpos = \"below\";",
1262 "\t} else if (rpos < 20) {",
1263 "\t\tpos = \"above\";",
1269 "(Gee.ArrayList<Lsp.DocumentSymbol> syms) {",
1270 "\t_this.navigationwindow.el.show();",
1271 "\t_this.navliststore.el.remove_all();",
1272 "\tforeach(var sym in syms) {",
1273 "\t\t_this.navliststore.el.append(sym);",
1279 "| void updateSelectedLine" : [
1281 "\tif (line == this.last_selected_line) {",
1284 "\tGLib.debug(\"select line %d\", line);",
1285 "\tthis.last_selected_line = line;",
1288 "\tvar new_row = -1;",
1289 "\tvar sym = _this.navliststore.symbolAtLine(line);",
1290 "\tif (sym != null) {",
1291 "\t \tnew_row = _this.navigationselmodel.getRowFromSymbol(sym);",
1292 " \t\tGLib.debug(\"select line %d - row found %d\", line, new_row);",
1294 " \t\tGLib.debug(\" no symbol found at line %d\", line);",
1296 " \tif (new_row == this.selected_row) {",
1299 "\tif (this.selected_row > -1) {",
1300 "\t\tvar old = this.getWidgetAtRow(this.selected_row);",
1301 "\t\tif (old !=null) {",
1302 "\t\t\told.remove_css_class(\"selected-row\");",
1305 "\tif (new_row > -1) {",
1306 "\t\tvar row = this.getWidgetAtRow(new_row);",
1307 "\t\tif (row != null) {",
1308 "\t\t\tGLib.debug(\" Add selected row\");",
1310 "\t\t\trow.add_css_class(\"selected-row\");",
1312 "\t\tthis.selected_row = new_row;",
1320 "xtype" : "ScrolledWindow"
1327 "| bool saveContents" : [
1331 " if (_this.file == null) {",
1337 " var str = _this.buffer.toString();",
1339 " _this.buffer.checkSyntax();",
1343 " // LeftPanel.model.changed( str , false);",
1344 " _this.dirty = false;",
1345 " _this.save_button.el.sensitive = false;",
1347 " // find the text for the node..",
1348 " if (_this.file.xtype != \"PlainFile\") {",
1349 " // in theory these properties have to exist!?!",
1350 " \tthis.prop.val = str;",
1351 " //this.window.windowstate.left_props.reload();",
1353 " _this.file.setSource( str );",
1356 " // call the signal..",
1364 "(string in_txt) {",
1366 "\tvar s = new GtkSource.SearchSettings();",
1367 "\ts.case_sensitive = _this.case_sensitive.el.active;",
1368 "\ts.regex_enabled = _this.regex.el.active;\t",
1369 "\ts.wrap_around = false;",
1371 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
1372 "\tthis.searchcontext.set_highlight(true);",
1373 "\tvar txt = in_txt;",
1375 "\tif (_this.multiline.el.active) {",
1376 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1379 "\ts.set_search_text(txt);",
1380 "\tGtk.TextIter beg, st,en;",
1382 "\tthis.buffer.el.get_start_iter(out beg);",
1383 "\tbool has_wrapped_around;",
1384 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
1385 "\tthis.last_search_end = 0;",
1387 "\treturn this.searchcontext.get_occurrences_count();",
1395 "| string tempFileContents" : [
1399 " if (_this.file == null) {",
1402 "\tvar str= this.buffer.toString();",
1403 "\tif (_this.file.xtype == \"PlainFile\") {",
1411 " GLib.debug(\"calling validate\"); ",
1412 " // clear the buttons.",
1413 " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
1414 "\t\treturn this.file.toSource(); ;",
1417 "\tvar oldcode = _this.prop.val;",
1418 "\t_this.prop.val = str;",
1419 " var ret = _this.file.toSource();",
1420 " _this.prop.val = oldcode;",
1425 "| void backSearch" : [
1426 "(bool change_focus) {",
1428 "\tif (this.searchcontext == null) {",
1432 "\tGtk.TextIter beg, st,en;",
1433 "\tbool has_wrapped_around;",
1434 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1436 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1437 "\t\tthis.last_search_end = 0;",
1439 "\t\tthis.last_search_end = en.get_offset();",
1440 "\t\tif (change_focus) {",
1441 "\t\t\tthis.view.el.grab_focus();",
1443 "\t\tthis.buffer.el.place_cursor(st);",
1444 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1450 "| void forwardSearch" : [
1451 "(bool change_focus) {",
1453 "\tif (this.searchcontext == null) {",
1457 "\tGtk.TextIter beg, st,en;",
1458 "\t bool has_wrapped_around;",
1459 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
1460 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1462 "\t\tthis.last_search_end = 0; // not sure if this should happen",
1464 "\t\tif (has_wrapped_around) {",
1468 "\t\tthis.last_search_end = en.get_offset();",
1469 "\t\tif (change_focus) {",
1470 "\t\t\tthis.view.el.grab_focus();",
1472 "\t\tthis.buffer.el.place_cursor(st);",
1473 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1481 "\t this.file = null; ",
1483 " this.node = null;",
1484 " this.prop = null;",
1485 "\tthis.searchcontext = null;",
1490 "| void scroll_to_line" : [
1493 "\tGLib.Timeout.add(500, () => {",
1495 "\t\tvar buf = this.view.el.get_buffer();",
1497 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1500 "\t\tGtk.TextIter iter; ",
1501 "\t\tsbuf.get_iter_at_line(out iter, line);",
1502 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1503 "\t\treturn false;",
1509 "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
1512 " this.file = file; ",
1514 " if (file.xtype != \"PlainFile\") {",
1515 " \tthis.prop = prop;",
1516 " this.node = node;",
1518 " // find the text for the node..",
1519 " this.view.load( prop.val );",
1520 " this.updateErrorMarks();",
1524 " this.close_btn.el.show(); ",
1527 " this.view.load( file.toSource() );",
1528 " this.updateErrorMarks();",
1529 " this.close_btn.el.hide();",
1530 " var ls = file.getLanguageServer();",
1531 " ls.documentSymbols.begin(file, (a,o) => {",
1532 " \t_this.navigation.show(ls.documentSymbols.end(o)); ",
1534 " //documentSymbols",
1540 "| void updateErrorMarks" : [
1545 "\tvar buf = _this.buffer.el;",
1546 "\tGtk.TextIter start;",
1547 "\tGtk.TextIter end; ",
1548 "\tbuf.get_bounds (out start, out end);",
1553 "\t//GLib.debug(\"highlight errors\");\t\t ",
1555 "\t // we should highlight other types of errors..",
1557 "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
1559 "\t\t_this.window.windowstate.state != WindowState.State.CODE",
1561 "\t\t//GLib.debug(\"windowstate != CODEONLY?\");",
1567 "\tif (_this.file == null) {",
1568 "\t\tGLib.debug(\"file is null?\");",
1572 "\tvar ar = this.file.getErrors();",
1573 "\tif (ar.size < 1) {",
1574 "\t\tbuf.remove_source_marks (start, end, \"ERR\");",
1575 "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
1576 "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
1577 "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1578 "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1579 "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1580 "\t\tthis.last_error_counter = file.error_counter ;",
1581 "\t\t//GLib.debug(\"highlight %s : %s has no errors\", this.file.relpath, category);",
1586 " // basicaly check if there is no change, then we do not do any update..",
1587 " // we can do this by just using an error counter?",
1588 " // if that's changed then we will do an update, otherwise dont bother.",
1591 "\tvar offset = 0;",
1592 "\tvar hoffset = 0;",
1594 "\tvar tlines = buf.get_line_count () +1;",
1596 "\tif (_this.prop != null) {",
1597 "\t\t// this still seems flaky...",
1599 "\t\ttlines = _this.prop.end_line;",
1600 "\t\toffset = _this.prop.start_line;",
1601 "\t\thoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..",
1605 "\t\t// no update...",
1606 "\t\tif (this.last_error_counter == file.error_counter) {",
1612 "\tbuf.remove_source_marks (start, end, \"ERR\");",
1613 "\tbuf.remove_source_marks (start, end, \"WARN\");",
1614 "\tbuf.remove_source_marks (start, end, \"DEPR\");",
1615 "\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1616 "\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1617 "\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1619 "\tforeach(var diag in ar) { ",
1620 "\t Gtk.TextIter iter;",
1621 "// print(\"get inter\\n\");",
1622 "\t var eline = (int)diag.range.start.line - offset;",
1623 "\t var eline_to = (int)diag.range.end.line - offset;",
1624 "\t //var eline = diag.range.end_line - offset;",
1625 "\t //GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
1626 "\t //\terr.line ,eline, offset);",
1629 "\t if (eline > tlines || eline < 0) {",
1633 "\t buf.get_iter_at_line( out iter, eline);",
1634 "\t \tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
1635 "\t buf.create_source_mark( msg, diag.category, iter);",
1637 " \t var spos = (int)diag.range.start.character - hoffset;",
1638 " \t if (spos < 0) { spos =0 ; }",
1639 " \t if (spos > iter.get_chars_in_line()) {",
1640 " \t \tspos = iter.get_chars_in_line();",
1642 "\t\tbuf.get_iter_at_line( out iter, eline_to);",
1643 "\t\tvar epos = (int)diag.range.end.character - hoffset;",
1644 " \t if (epos < 0) { epos =0 ; }",
1645 " \t if (epos > iter.get_chars_in_line()) {",
1646 " \t \tepos = iter.get_chars_in_line();",
1650 " \t buf.get_iter_at_line_offset( out start, eline, spos); ",
1652 " \t buf.get_iter_at_line_offset( out end, eline_to,epos); ",
1654 "\t buf.apply_tag_by_name(diag.category, start, end);",
1656 "\t // GLib.debug(\"set line %d to %s\", eline, msg);",
1657 "\t //this.marks.set(eline, msg);",
1659 "\tthis.last_error_counter = file.error_counter ;",