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);",
271 "\t_this.view.el.get_iter_at_offset (",
272 "\t\t\tout iter, _this.view.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 selected_row" : "-1",
948 "bool expand" : true,
952 "* prop" : "factory",
956 "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
958 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
959 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
962 "\tvar hbox = (Gtk.Box) expand.child;",
965 "\tvar img = (Gtk.Image) hbox.get_first_child();",
966 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
968 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
969 "\tvar sym = (Lsp.DocumentSymbol) lr.get_item();",
971 "\tGLib.debug(\"got %d children for %s\" , (int)sym.children.get_n_items(), sym.name);",
973 " expand.set_hide_expander( sym.children.get_n_items() < 1);",
974 " \texpand.set_list_row(lr);",
976 " \tsym.bind_property(\"symbol_icon\",",
977 " img, \"icon_name\",",
978 " GLib.BindingFlags.SYNC_CREATE);",
980 " \thbox.add_css_class(sym.symbol_icon);",
982 " \tsym.bind_property(\"name\",",
984 " GLib.BindingFlags.SYNC_CREATE);",
985 " \t// should be better?- --line no?",
986 " \tsym.bind_property(\"tooltip\",",
987 " lbl, \"tooltip_markup\",",
988 " GLib.BindingFlags.SYNC_CREATE);",
989 " \t// bind image...",
997 "\tvar expand = new Gtk.TreeExpander();",
999 "\texpand.set_indent_for_depth(true);",
1000 "\texpand.set_indent_for_icon(true);",
1001 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
1002 "\tvar icon = new Gtk.Image();",
1003 "\tvar lbl = new Gtk.Label(\"\");",
1004 "\tlbl.use_markup = true;",
1005 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1007 "\ticon.margin_end = 4;",
1008 " \tlbl.justify = Gtk.Justification.LEFT;",
1009 " \tlbl.xalign = 0;",
1011 "//\tlistitem.activatable = true; ??",
1013 "\thbox.append(icon);",
1014 "\thbox.append(lbl);",
1015 "\texpand.set_child(hbox);",
1016 "\t((Gtk.ListItem)listitem).set_child(expand);",
1022 "xtype" : "SignalListItemFactory"
1025 "string title" : "Code Navigation",
1026 "xtype" : "ColumnViewColumn"
1031 "id" : "navigationselmodel",
1038 "$ Gtk.TreeListModelCreateModelFunc create_func" : [
1041 "\treturn ((Lsp.DocumentSymbol)item).children;",
1047 "bool autoexpand" : true,
1048 "bool passthrough" : false,
1051 "$ GLib.Type item_type" : "typeof(Lsp.DocumentSymbol)",
1054 "id" : "navliststore",
1055 "xtype" : "ListStore",
1056 "| Lsp.DocumentSymbol? symbolAtLine" : [
1060 "\tfor(var i = 0; i < this.el.get_n_items();i++) {",
1061 "\t\tvar el = (Lsp.DocumentSymbol)this.el.get_item(i);",
1062 "\t\tvar ret = el.containsLine(i);",
1063 "\t\tif (ret != null) {",
1064 "\t\t\treturn ret;",
1074 "xtype" : "TreeListModel"
1078 "* prop" : "sorter",
1082 "* prop" : "sorter",
1085 "$ GLib.Type this_type" : "typeof(Lsp.DocumentSymbol)",
1087 "* prop" : "expression",
1088 "string property_name" : "sort_key",
1089 "xtype" : "PropertyExpression"
1092 "xtype" : "StringSorter"
1095 "xtype" : "TreeListRowSorter"
1098 "xtype" : "SortListModel"
1101 "xtype" : "NoSelection",
1102 "| Lsp.DocumentSymbol? getSymbollAt" : [
1105 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1107 " var a = tr.get_item();; ",
1108 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1111 " return (Lsp.DocumentSymbol)tr.get_item();",
1115 "| int getRowFromSymbol" : [
1116 "(Lsp.DocumentSymbol sym) {",
1118 "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
1121 "\t var tr = (Gtk.TreeListRow)this.el.get_item(i);",
1123 "\t if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {",
1135 "(n_press, x, y) => {",
1137 " \tvar row = _this.navigation.getRowAt(x,y, out pos );",
1139 "\t GLib.debug(\"no row selected items\");",
1142 " //Lsp.DocumentSymbol",
1143 " var sym = _this.navigationselmodel.getSymbollAt(row);",
1144 " if (sym == null) {",
1150 " \"line\" : 1410,",
1151 " \"character\" : 8",
1154 " \"line\" : 1410,",
1155 " \"character\" : 39",
1159 " GLib.debug(\"goto line %d\", (int)sym.range.start.line); ",
1160 " _this.scroll_to_line((int)sym.range.start.line);",
1165 "xtype" : "GestureClick"
1168 "string name" : "editor-navigation",
1169 "xtype" : "ColumnView",
1170 "| Gtk.Widget? getWidgetAtRow" : [
1174 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1175 " \tvar colview = gesture.widget;",
1176 " \tvar line_no = check_list_widget(colview, x,y);",
1177 " if (line_no > -1) {",
1178 " \t\tvar item = colview.model.get_item(line_no);",
1182 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1183 " var child = this.el.get_first_child(); ",
1184 " \tvar line_no = -1; ",
1185 " \tvar reading_header = true;",
1187 " \twhile (child != null) {",
1188 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1190 " \t if (reading_header) {",
1193 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1195 "\t\t\t\t\tchild = child.get_next_sibling();",
1196 "\t\t\t\t\tcontinue;",
1198 "\t\t\t\t// should be columnlistview",
1199 "\t\t\t\tchild = child.get_first_child(); ",
1203 "\t\t\t\treading_header = false;",
1204 "\t\t\t\tcontinue;",
1210 "\t\t\tif (line_no == row) {",
1211 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1212 "\t\t\t return (Gtk.Widget)child;",
1214 "\t child = child.get_next_sibling(); ",
1216 "\t\t//GLib.debug(\"Rturning null\");",
1221 "| int getRowAt" : [
1222 "(double x, double y, out string pos) {",
1225 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1226 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1227 "\tif (w == null) {",
1231 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1232 "\tif (row == null) {",
1236 "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1241 "\twhile (cr.get_prev_sibling() != null) {",
1243 "\t\tcr = cr.get_prev_sibling();",
1246 "\t//GLib.debug(\"row number is %d\", rn);",
1247 "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1248 "\t// above or belw",
1249 "\tGraphene.Rect bounds;",
1250 "\trow.compute_bounds(this.el, out bounds);",
1251 "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1252 "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1253 "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1255 "\tvar ypos = y - bounds.get_y();",
1256 "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1257 "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1258 "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1259 "\tpos = \"over\";",
1261 "\tif (rpos > 80) {",
1262 "\t\tpos = \"below\";",
1263 "\t} else if (rpos < 20) {",
1264 "\t\tpos = \"above\";",
1270 "(Gee.ArrayList<Lsp.DocumentSymbol> syms) {",
1271 "\t_this.navigationwindow.el.show();",
1272 "\t_this.navliststore.el.remove_all();",
1273 "\tforeach(var sym in syms) {",
1274 "\t\t_this.navliststore.el.append(sym);",
1280 "| void updateSelectedLine" : [
1283 "\tvar new_row = -1;",
1284 "\tvar sym = _this.navliststore.symbolAtLine(line);",
1285 "\tif (sym != null) {",
1286 "\t \tnew_row = _this.navigationselmodel.getRowFromSymbol(sym);",
1288 " \tif (new_row == this.selected_row) {",
1291 "\tif (this.selected_row > -1) {",
1292 "\t\tvar old = this.getWidgetAtRow(this.selected_row);",
1293 "\t\tif (old !=null) {",
1294 "\t\t\told.remove_css_class(\"selcted-row\");",
1297 "\tif (new_row > -1) {",
1298 "\t\tvar row = this.getWidgetAtRow(new_row);",
1299 "\t\tif (row != null) {",
1300 "\t\t\trow.add_css_class(\"selcted-row\");",
1302 "\t\tthis.selected_row = new_row;",
1310 "xtype" : "ScrolledWindow"
1317 "| bool saveContents" : [
1321 " if (_this.file == null) {",
1327 " var str = _this.buffer.toString();",
1329 " _this.buffer.checkSyntax();",
1333 " // LeftPanel.model.changed( str , false);",
1334 " _this.dirty = false;",
1335 " _this.save_button.el.sensitive = false;",
1337 " // find the text for the node..",
1338 " if (_this.file.xtype != \"PlainFile\") {",
1339 " // in theory these properties have to exist!?!",
1340 " \tthis.prop.val = str;",
1341 " //this.window.windowstate.left_props.reload();",
1343 " _this.file.setSource( str );",
1346 " // call the signal..",
1354 "(string in_txt) {",
1356 "\tvar s = new GtkSource.SearchSettings();",
1357 "\ts.case_sensitive = _this.case_sensitive.el.active;",
1358 "\ts.regex_enabled = _this.regex.el.active;\t",
1359 "\ts.wrap_around = false;",
1361 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
1362 "\tthis.searchcontext.set_highlight(true);",
1363 "\tvar txt = in_txt;",
1365 "\tif (_this.multiline.el.active) {",
1366 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1369 "\ts.set_search_text(txt);",
1370 "\tGtk.TextIter beg, st,en;",
1372 "\tthis.buffer.el.get_start_iter(out beg);",
1373 "\tbool has_wrapped_around;",
1374 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
1375 "\tthis.last_search_end = 0;",
1377 "\treturn this.searchcontext.get_occurrences_count();",
1385 "| string tempFileContents" : [
1389 " if (_this.file == null) {",
1392 "\tvar str= this.buffer.toString();",
1393 "\tif (_this.file.xtype == \"PlainFile\") {",
1401 " GLib.debug(\"calling validate\"); ",
1402 " // clear the buttons.",
1403 " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
1404 "\t\treturn this.file.toSource(); ;",
1407 "\tvar oldcode = _this.prop.val;",
1408 "\t_this.prop.val = str;",
1409 " var ret = _this.file.toSource();",
1410 " _this.prop.val = oldcode;",
1415 "| void backSearch" : [
1416 "(bool change_focus) {",
1418 "\tif (this.searchcontext == null) {",
1422 "\tGtk.TextIter beg, st,en;",
1423 "\tbool has_wrapped_around;",
1424 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1426 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1427 "\t\tthis.last_search_end = 0;",
1429 "\t\tthis.last_search_end = en.get_offset();",
1430 "\t\tif (change_focus) {",
1431 "\t\t\tthis.view.el.grab_focus();",
1433 "\t\tthis.buffer.el.place_cursor(st);",
1434 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1440 "| void forwardSearch" : [
1441 "(bool change_focus) {",
1443 "\tif (this.searchcontext == null) {",
1447 "\tGtk.TextIter beg, st,en;",
1448 "\t bool has_wrapped_around;",
1449 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
1450 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1452 "\t\tthis.last_search_end = 0; // not sure if this should happen",
1454 "\t\tif (has_wrapped_around) {",
1458 "\t\tthis.last_search_end = en.get_offset();",
1459 "\t\tif (change_focus) {",
1460 "\t\t\tthis.view.el.grab_focus();",
1462 "\t\tthis.buffer.el.place_cursor(st);",
1463 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1471 "\t this.file = null; ",
1473 " this.node = null;",
1474 " this.prop = null;",
1475 "\tthis.searchcontext = null;",
1480 "| void scroll_to_line" : [
1483 "\tGLib.Timeout.add(500, () => {",
1485 "\t\tvar buf = this.view.el.get_buffer();",
1487 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1490 "\t\tGtk.TextIter iter; ",
1491 "\t\tsbuf.get_iter_at_line(out iter, line);",
1492 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1493 "\t\treturn false;",
1499 "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
1502 " this.file = file; ",
1504 " if (file.xtype != \"PlainFile\") {",
1505 " \tthis.prop = prop;",
1506 " this.node = node;",
1508 " // find the text for the node..",
1509 " this.view.load( prop.val );",
1510 " this.updateErrorMarks();",
1514 " this.close_btn.el.show(); ",
1517 " this.view.load( file.toSource() );",
1518 " this.updateErrorMarks();",
1519 " this.close_btn.el.hide();",
1520 " var ls = file.getLanguageServer();",
1521 " ls.documentSymbols.begin(file, (a,o) => {",
1522 " \t_this.navigation.show(ls.documentSymbols.end(o)); ",
1524 " //documentSymbols",
1530 "| void updateErrorMarks" : [
1535 "\tvar buf = _this.buffer.el;",
1536 "\tGtk.TextIter start;",
1537 "\tGtk.TextIter end; ",
1538 "\tbuf.get_bounds (out start, out end);",
1543 "\t//GLib.debug(\"highlight errors\");\t\t ",
1545 "\t // we should highlight other types of errors..",
1547 "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
1549 "\t\t_this.window.windowstate.state != WindowState.State.CODE",
1551 "\t\t//GLib.debug(\"windowstate != CODEONLY?\");",
1557 "\tif (_this.file == null) {",
1558 "\t\tGLib.debug(\"file is null?\");",
1562 "\tvar ar = this.file.getErrors();",
1563 "\tif (ar.size < 1) {",
1564 "\t\tbuf.remove_source_marks (start, end, \"ERR\");",
1565 "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
1566 "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
1567 "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1568 "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1569 "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1570 "\t\tthis.last_error_counter = file.error_counter ;",
1571 "\t\t//GLib.debug(\"highlight %s : %s has no errors\", this.file.relpath, category);",
1576 " // basicaly check if there is no change, then we do not do any update..",
1577 " // we can do this by just using an error counter?",
1578 " // if that's changed then we will do an update, otherwise dont bother.",
1581 "\tvar offset = 0;",
1582 "\tvar hoffset = 0;",
1584 "\tvar tlines = buf.get_line_count () +1;",
1586 "\tif (_this.prop != null) {",
1587 "\t\t// this still seems flaky...",
1589 "\t\ttlines = _this.prop.end_line;",
1590 "\t\toffset = _this.prop.start_line;",
1591 "\t\thoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..",
1595 "\t\t// no update...",
1596 "\t\tif (this.last_error_counter == file.error_counter) {",
1602 "\tbuf.remove_source_marks (start, end, \"ERR\");",
1603 "\tbuf.remove_source_marks (start, end, \"WARN\");",
1604 "\tbuf.remove_source_marks (start, end, \"DEPR\");",
1605 "\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1606 "\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1607 "\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1609 "\tforeach(var diag in ar) { ",
1610 "\t Gtk.TextIter iter;",
1611 "// print(\"get inter\\n\");",
1612 "\t var eline = (int)diag.range.start.line - offset;",
1613 "\t var eline_to = (int)diag.range.end.line - offset;",
1614 "\t //var eline = diag.range.end_line - offset;",
1615 "\t //GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
1616 "\t //\terr.line ,eline, offset);",
1619 "\t if (eline > tlines || eline < 0) {",
1623 "\t buf.get_iter_at_line( out iter, eline);",
1624 "\t \tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
1625 "\t buf.create_source_mark( msg, diag.category, iter);",
1627 " \t var spos = (int)diag.range.start.character - hoffset;",
1628 " \t if (spos < 0) { spos =0 ; }",
1629 " \t if (spos > iter.get_chars_in_line()) {",
1630 " \t \tspos = iter.get_chars_in_line();",
1632 "\t\tbuf.get_iter_at_line( out iter, eline_to);",
1633 "\t\tvar epos = (int)diag.range.end.character - hoffset;",
1634 " \t if (epos < 0) { epos =0 ; }",
1635 " \t if (epos > iter.get_chars_in_line()) {",
1636 " \t \tepos = iter.get_chars_in_line();",
1640 " \t buf.get_iter_at_line_offset( out start, eline, spos); ",
1642 " \t buf.get_iter_at_line_offset( out end, eline_to,epos); ",
1644 "\t buf.apply_tag_by_name(diag.category, start, end);",
1646 "\t // GLib.debug(\"set line %d to %s\", eline, msg);",
1647 "\t //this.marks.set(eline, msg);",
1649 "\tthis.last_error_counter = file.error_counter ;",