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);",
275 "| bool OLDhighlightErrorsJson" : [
276 "(string type, Json.Object obj) {",
277 "\tGtk.TextIter start;",
278 "\tGtk.TextIter end; ",
279 "\tthis.el.get_bounds (out start, out end);",
281 "\tthis.el.remove_source_marks (start, end, type);",
282 "\tGLib.debug(\"highlight errors\");\t\t ",
284 "\t // we should highlight other types of errors..",
286 "\tif (!obj.has_member(type)) {",
287 "\t\tGLib.debug(\"Return has no errors\\n\");",
291 "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
293 "\t\t_this.window.windowstate.state != WindowState.State.CODE",
295 "\t\tGLib.debug(\"windowstate != CODEONLY?\");",
300 "\t//this.marks = new Gee.HashMap<int,string>();",
301 "\tvar err = obj.get_object_member(type);",
303 "\tif (_this.file == null) {",
304 "\t\tGLib.debug(\"file is null?\");",
308 "\tvar valafn = _this.file.path;",
310 "\tif (_this.file.xtype != \"PlainFile\") {",
312 "\t\tvalafn = \"\";",
314 "\t\t\tvar regex = new Regex(\"\\\\.bjs$\");",
315 "\t\t\t// should not happen",
316 "\t \t\tvalafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
317 "\t\t} catch (GLib.RegexError e) {",
318 "\t\t\treturn true;",
324 "\tif (!err.has_member(valafn)) {",
325 "\t\tGLib.debug(\"File path has no errors\");",
329 "\tvar lines = err.get_object_member(valafn);",
332 "\tif (obj.has_member(\"line_offset\")) { // ?? why??",
333 "\t\toffset = (int)obj.get_int_member(\"line_offset\") + 1;",
337 "\tvar tlines = this.el.get_line_count () +1;",
339 "\tif (_this.prop != null) {",
341 "\t\ttlines = _this.prop.end_line + 1;",
342 "\t\toffset = _this.prop.start_line + 1;",
348 "\tlines.foreach_member((obj, line, node) => {",
350 "\t Gtk.TextIter iter;",
351 "// print(\"get inter\\n\");",
352 "\t var eline = int.parse(line) - offset;",
353 "\t GLib.debug(\"GOT ERROR on line %s -- converted to %d (offset = %d)\\n\", line,eline, offset);",
356 "\t if (eline > tlines || eline < 0) {",
361 "\t this.el.get_iter_at_line( out iter, eline);",
362 "\t //print(\"mark line\\n\");",
363 "\t var msg = \"\";",
364 "\t var ar = lines.get_array_member(line);",
365 "\t for (var i = 0 ; i < ar.get_length(); i++) {",
366 "\t \tif (ar.get_string_element(i) == \"Success\") {",
369 "\t\t\tmsg += (msg.length > 0) ? \"\\n\" : \"\";",
370 "\t\t\tmsg += ar.get_string_element(i);",
372 "\t\tif (msg == \"\") {",
375 "\t\tmsg = \"Line: %d\".printf(eline+1) + \" \" + msg;",
376 "\t this.el.create_source_mark(msg, type, iter);",
377 "\t GLib.debug(\"set line %d to %m\", eline, msg);",
378 "\t // this.marks.set(eline, msg);",
389 "| bool checkSyntax" : [
393 " var str = this.toString();",
396 " if (this.error_line > 0) {",
397 " Gtk.TextIter start;",
398 " Gtk.TextIter end; ",
399 " this.el.get_bounds (out start, out end);",
401 " this.el.remove_source_marks (start, end, null);",
403 " if (str.length < 1) {",
404 " print(\"checkSyntax - empty string?\\n\");",
408 " // bit presumptiona",
409 " if (_this.file.xtype == \"PlainFile\") {",
411 " // assume it's gtk...",
412 " var oldcode =_this.file.toSource();",
413 " _this.file.setSource(str);",
414 "\t BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");",
415 " \t_this.file.getLanguageServer().document_change(_this.file);",
417 " _this.file.setSource(oldcode);",
423 " if (_this.file == null) {",
431 " GLib.debug(\"calling validate\"); ",
432 " // clear the buttons.",
433 " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
436 "\tvar oldcode = _this.prop.val;",
438 "\t_this.prop.val = str;",
439 "\t_this.node.updated_count++;",
440 " _this.file.getLanguageServer().document_change(_this.file);",
441 " _this.node.updated_count++;",
442 " _this.prop.val = oldcode;",
445 " //print(\"done mark line\\n\");",
447 " return true; // at present allow saving - even if it's invalid..",
451 "| bool highlightErrors" : [
452 "( Gee.HashMap<int,string> validate_res) {",
454 "\tthis.error_line = validate_res.size;",
456 "\tif (this.error_line < 1) {",
459 "\tvar tlines = this.el.get_line_count ();",
460 "\tGtk.TextIter iter;",
461 "\tvar valiter = validate_res.map_iterator();",
462 "\twhile (valiter.next()) {",
464 "\t// print(\"get inter\\n\");",
465 "\t\tvar eline = valiter.get_key();",
466 "\t\tif (eline > tlines) {",
469 "\t\tthis.el.get_iter_at_line( out iter, eline);",
470 "\t\t//print(\"mark line\\n\");",
471 "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
476 "| string toString" : [
481 " this.el.get_start_iter(out s);",
482 " this.el.get_end_iter(out e);",
483 " var ret = this.el.get_text(s,e,true);",
484 " //print(\"TO STRING? \" + ret);",
491 "# bool is_control" : false,
496 "(keyval, keycode, state) => {",
498 " \tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
499 " \t\tthis.is_control = true;",
506 "(keyval, keycode, state) => {",
508 " \t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
509 " \t\tthis.is_control = false;",
511 " if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
512 " GLib.debug(\"SAVE: ctrl-S pressed\");",
513 " _this.saveContents();",
517 " if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
518 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
519 "\t\t_this.forwardSearch(true);",
522 "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
523 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
524 "\t\t_this.search_entry.el.grab_focus();",
525 "\t\t_this.search_entry.el.select_region(0,-1);",
528 "\tif (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
529 "\t\t_this.view.el.show_completion();",
532 "\tGtk.TextIter iter;",
533 "\t_this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position); ",
534 "\tvar line = iter.get_line();",
535 "\tvar offset = iter.get_line_offset();",
536 "\tGLib.debug(\"line %d off %d\", line ,offset);",
537 "\tif (_this.prop != null) {",
538 "\t\tline += _this.prop.start_line + 1; // i think..",
539 "\t\toffset += 12; // should probably be 8 without namespaced ",
540 "\t\tGLib.debug(\"guess line %d off %d\", line ,offset);",
542 " //_this.view.el.show_completion();",
543 " // print(event.key.keyval)",
555 "xtype" : "EventControllerKey"
558 "# double distance" : "0.0f",
560 "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
564 "\tif (!_this.keystate.is_control) {",
567 "\t //GLib.debug(\"scroll %f\", dy);",
569 "\tthis.distance += dy;",
571 "\t//GLib.debug(\"scroll %f / %f\", dy, this.distance);",
573 "\t if (this.distance < -1) {",
575 "\t\tBuilderApplication.settings.editor_font_size ++;",
576 "\t\tthis.distance = 0;",
578 "\tif (this.distance > 1) {",
579 "\t\tBuilderApplication.settings.editor_font_size --;",
580 "\t\tthis.distance = 0;",
588 "xtype" : "EventControllerScroll"
592 "xtype" : "GestureClick"
597 "(x, y, keyboard_tooltip, tooltip) => {",
599 "\t//GLib.debug(\"query tooltip\");",
600 "\tGtk.TextIter iter;",
603 "\tvar yoff = (int) _this.RightEditor.el.vadjustment.value;",
605 "\t// I think this is problematic - if it's compliing / updating at same time as query.",
607 "\t//if (_this.window.statusbar_compile_spinner.el.spinning) {",
608 "\t//\treturn false;",
611 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
613 "\tvar l = iter.get_line();",
617 "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
623 "\tif (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {",
624 "\t\tGLib.debug(\"line %d setting tip to %s\", l, _this.buffer.marks.get(l));",
625 "\t\ttooltip.set_text(_this.buffer.marks.get(l).dup());",
633 "\t// this crashes?? - not sure why.",
634 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
635 "\tif (marks.is_empty()) {",
636 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
638 "\tif (marks.is_empty()) {",
639 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
642 "\t// GLib.debug(\"query tooltip line %d marks %d\", (int)l, (int) marks.length());",
644 "\tmarks.@foreach((m) => { ",
645 "\t\t//GLib.debug(\"got mark %s\", m.name);",
646 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.category + \": \" + m.name;",
648 "\t// true if there is a mark..",
649 "\tif (str.length > 0 ) {",
650 "\t\ttooltip.set_text( str );",
652 "\treturn str.length > 0 ? true : false;",
658 "string name" : "editor-view",
659 "uint tab_width" : 4,
664 "// show the help page for the active node..",
665 " //this.get('/Help').show();",
667 " // this.get('/BottomPane').el.set_current_page(0);",
668 " \tGLib.debug(\"load called - Reset undo buffer\");",
670 " var buf = (GtkSource.Buffer)this.el.get_buffer();",
671 " buf.begin_irreversible_action();",
672 " buf.set_text(str, str.length);",
673 " buf.end_irreversible_action();",
675 " var lm = GtkSource.LanguageManager.get_default();",
676 " var lang = \"vala\";",
677 " if (_this.file != null) {",
678 " lang = _this.file.language;",
680 " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
681 " var lg = _this.file.content_type.length > 0 ?",
682 " lm.guess_language(_this.file.path, _this.file.content_type) :",
683 " lm.get_language(lang);",
686 " ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); ",
688 " this.el.insert_spaces_instead_of_tabs = true;",
689 " if (lg != null) {",
690 "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);",
691 "\t\tif (lg.name == \"Vala\") {",
692 "\t\t this.el.insert_spaces_instead_of_tabs = false;",
695 " _this.dirty = false;",
696 " this.el.grab_focus();",
697 " _this.save_button.el.sensitive = false;",
698 " _this.last_error_counter = -1;",
703 "xtype" : "ScrolledWindow"
708 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
709 "bool homogeneous" : false,
710 "bool vexpand" : false,
715 "Gtk.CssProvider css" : "",
716 "bool hexpand" : true,
717 "id" : "search_entry",
723 "(keyval, keycode, state) => {",
725 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
726 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
727 "\t\t_this.forwardSearch(true);",
732 " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
733 "\t\t_this.forwardSearch(true);",
739 " // print(event.key.keyval)",
746 "xtype" : "EventControllerKey"
753 "_this.search(_this.search_entry.el.text);",
754 "\t _this.search_results.updateResults();",
756 "\tGLib.Timeout.add_seconds(1,() => {",
757 "\t\t _this.search_results.updateResults();",
758 "\t\t return false;",
764 "string name" : "editor-search-entry",
765 "string placeholder_text" : "Press enter to search",
766 "uint search_delay" : 3,
767 "xtype" : "SearchEntry",
768 "| void forwardSearch" : [
769 "(bool change_focus) {",
772 "\t_this.forwardSearch(change_focus);",
776 "\tswitch(_this.windowstate.state) {",
777 "\t\tcase WindowState.State.CODEONLY:",
778 "\t\t//case WindowState.State.CODE:",
779 "\t\t\t// search the code being edited..",
780 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
783 "\t\tcase WindowState.State.PREVIEW:",
784 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
785 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
787 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
800 "id" : "search_results",
801 "int margin_end" : 4,
802 "int margin_start" : 4,
803 "string label" : "No Results",
805 "| void updateResults" : [
807 "\tthis.el.visible = true;",
809 "\tvar res = _this.searchcontext.get_occurrences_count();",
811 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
815 "\t_this.nextBtn.el.sensitive = false;",
816 "\t_this.backBtn.el.sensitive = false;\t",
819 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
820 "\t\t_this.nextBtn.el.sensitive = true;",
821 "\t\t_this.backBtn.el.sensitive = true;",
824 "\t_this.search_results.el.label = \"No Matches\";",
831 "bool always_show_image" : true,
832 "bool sensitive" : false,
838 "\t_this.forwardSearch(true);",
845 "string icon_name" : "go-down",
850 "bool always_show_image" : true,
851 "bool sensitive" : false,
857 "\t_this.backSearch(true);",
863 "string icon_name" : "go-up",
868 "bool always_show_arrow" : true,
869 "bool always_show_image" : true,
873 "* prop" : "popover",
874 "id" : "search_settings",
879 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
890 "id" : "case_sensitive",
891 "string label" : "Case Sensitive",
892 "xtype" : "CheckButton"
903 "string label" : "Regex",
904 "xtype" : "CheckButton"
909 "string label" : "Multi-line (add \\n)",
910 "xtype" : "CheckButton"
919 "string icon_name" : "emblem-system",
920 "xtype" : "MenuButton"
930 "* prop" : "end_child",
931 "bool visible" : false,
932 "id" : "navigationwindow",
935 "# int selected_row" : "-1",
942 "bool expand" : true,
946 "* prop" : "factory",
950 "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
952 "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
953 "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
956 "\tvar hbox = (Gtk.Box) expand.child;",
959 "\tvar img = (Gtk.Image) hbox.get_first_child();",
960 "\tvar lbl = (Gtk.Label) img.get_next_sibling();",
962 "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
963 "\tvar sym = (Lsp.DocumentSymbol) lr.get_item();",
965 "\tGLib.debug(\"got %d children for %s\" , (int)sym.children.get_n_items(), sym.name);",
967 " expand.set_hide_expander( sym.children.get_n_items() < 1);",
968 " \texpand.set_list_row(lr);",
970 " \tsym.bind_property(\"symbol_icon\",",
971 " img, \"icon_name\",",
972 " GLib.BindingFlags.SYNC_CREATE);",
974 " \thbox.add_css_class(sym.symbol_icon);",
976 " \tsym.bind_property(\"name\",",
978 " GLib.BindingFlags.SYNC_CREATE);",
979 " \t// should be better?- --line no?",
980 " \tsym.bind_property(\"tooltip\",",
981 " lbl, \"tooltip_markup\",",
982 " GLib.BindingFlags.SYNC_CREATE);",
983 " \t// bind image...",
991 "\tvar expand = new Gtk.TreeExpander();",
993 "\texpand.set_indent_for_depth(true);",
994 "\texpand.set_indent_for_icon(true);",
995 "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
996 "\tvar icon = new Gtk.Image();",
997 "\tvar lbl = new Gtk.Label(\"\");",
998 "\tlbl.use_markup = true;",
999 "\tlbl.ellipsize = Pango.EllipsizeMode.END;",
1001 "\ticon.margin_end = 4;",
1002 " \tlbl.justify = Gtk.Justification.LEFT;",
1003 " \tlbl.xalign = 0;",
1005 "//\tlistitem.activatable = true; ??",
1007 "\thbox.append(icon);",
1008 "\thbox.append(lbl);",
1009 "\texpand.set_child(hbox);",
1010 "\t((Gtk.ListItem)listitem).set_child(expand);",
1016 "xtype" : "SignalListItemFactory"
1019 "string title" : "Code Navigation",
1020 "xtype" : "ColumnViewColumn"
1025 "id" : "navigationselmodel",
1032 "$ Gtk.TreeListModelCreateModelFunc create_func" : [
1035 "\treturn ((Lsp.DocumentSymbol)item).children;",
1041 "bool autoexpand" : true,
1042 "bool passthrough" : false,
1045 "$ GLib.Type item_type" : "typeof(Lsp.DocumentSymbol)",
1048 "id" : "navliststore",
1049 "xtype" : "ListStore",
1050 "| Lsp.DocumentSymbol? symbolAtLine" : [
1054 "\tfor(var i = 0; i < this.el.get_n_items();i++) {",
1055 "\t\tvar el = (Lsp.DocumentSymbol)this.el.get_item(i);",
1056 "\t\tvar ret = el.containsLine(i);",
1057 "\t\tif (ret != null) {",
1058 "\t\t\treturn ret;",
1068 "xtype" : "TreeListModel"
1072 "* prop" : "sorter",
1076 "* prop" : "sorter",
1079 "$ GLib.Type this_type" : "typeof(Lsp.DocumentSymbol)",
1081 "* prop" : "expression",
1082 "string property_name" : "sort_key",
1083 "xtype" : "PropertyExpression"
1086 "xtype" : "StringSorter"
1089 "xtype" : "TreeListRowSorter"
1092 "xtype" : "SortListModel"
1095 "xtype" : "NoSelection",
1096 "| Lsp.DocumentSymbol? getSymbollAt" : [
1099 " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
1101 " var a = tr.get_item();; ",
1102 " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
1105 " return (Lsp.DocumentSymbol)tr.get_item();",
1109 "| int getRowFromSymbol" : [
1110 "(Lsp.DocumentSymbol sym) {",
1112 "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
1115 "\t var tr = (Gtk.TreeListRow)this.el.get_item(i);",
1117 "\t if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {",
1129 "(n_press, x, y) => {",
1131 " \tvar row = _this.navigation.getRowAt(x,y, out pos );",
1133 "\t GLib.debug(\"no row selected items\");",
1136 " //Lsp.DocumentSymbol",
1137 " var sym = _this.navigationselmodel.getSymbollAt(row);",
1138 " if (sym == null) {",
1144 " \"line\" : 1410,",
1145 " \"character\" : 8",
1148 " \"line\" : 1410,",
1149 " \"character\" : 39",
1153 " GLib.debug(\"goto line %d\", (int)sym.range.start.line); ",
1154 " _this.scroll_to_line((int)sym.range.start.line);",
1159 "xtype" : "GestureClick"
1162 "string name" : "editor-navigation",
1163 "xtype" : "ColumnView",
1164 "| Gtk.Widget? getWidgetAtRow" : [
1168 "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
1169 " \tvar colview = gesture.widget;",
1170 " \tvar line_no = check_list_widget(colview, x,y);",
1171 " if (line_no > -1) {",
1172 " \t\tvar item = colview.model.get_item(line_no);",
1176 "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
1177 " var child = this.el.get_first_child(); ",
1178 " \tvar line_no = -1; ",
1179 " \tvar reading_header = true;",
1181 " \twhile (child != null) {",
1182 "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
1184 " \t if (reading_header) {",
1187 "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
1189 "\t\t\t\t\tchild = child.get_next_sibling();",
1190 "\t\t\t\t\tcontinue;",
1192 "\t\t\t\t// should be columnlistview",
1193 "\t\t\t\tchild = child.get_first_child(); ",
1197 "\t\t\t\treading_header = false;",
1198 "\t\t\t\tcontinue;",
1204 "\t\t\tif (line_no == row) {",
1205 "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
1206 "\t\t\t return (Gtk.Widget)child;",
1208 "\t child = child.get_next_sibling(); ",
1210 "\t\t//GLib.debug(\"Rturning null\");",
1215 "| int getRowAt" : [
1216 "(double x, double y, out string pos) {",
1219 "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
1220 "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
1221 "\tif (w == null) {",
1225 "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
1226 "\tif (row == null) {",
1230 "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
1235 "\twhile (cr.get_prev_sibling() != null) {",
1237 "\t\tcr = cr.get_prev_sibling();",
1240 "\t//GLib.debug(\"row number is %d\", rn);",
1241 "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
1242 "\t// above or belw",
1243 "\tGraphene.Rect bounds;",
1244 "\trow.compute_bounds(this.el, out bounds);",
1245 "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
1246 "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
1247 "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
1249 "\tvar ypos = y - bounds.get_y();",
1250 "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
1251 "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
1252 "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
1253 "\tpos = \"over\";",
1255 "\tif (rpos > 80) {",
1256 "\t\tpos = \"below\";",
1257 "\t} else if (rpos < 20) {",
1258 "\t\tpos = \"above\";",
1264 "(Gee.ArrayList<Lsp.DocumentSymbol> syms) {",
1265 "\t_this.navigationwindow.el.show();",
1266 "\t_this.navliststore.el.remove_all();",
1267 "\tforeach(var sym in syms) {",
1268 "\t\t_this.navliststore.el.append(sym);",
1274 "| void updateSelectedLine" : [
1277 "\tvar new_row = -1;",
1278 "\tvar sym = _this.navliststore.symbolAtLine(line);",
1279 "\tif (sym != null) {",
1280 "\t \tnew_row = _this.navigationselmodel.getRowFromSymbol(sym);",
1282 " \tif (new_row == this.selected_row) {",
1285 "\tif (this.selected_row > -1) {",
1286 "\t\tvar old = this.getWidgetAtRow(this.selected_row);",
1287 "\t\tif (old !=null) {",
1288 "\t\t\told.remove_css_class(\"selcted-row\");",
1291 "\tif (new_row > -1) {",
1292 "\t\tvar row = this.getWidgetAtRow(new_row);",
1293 "\t\tif (row != null) {",
1294 "\t\t\trow.add_css_class(\"selcted-row\");",
1296 "\t\tthis.selected_row = new_row;",
1304 "xtype" : "ScrolledWindow"
1311 "| bool saveContents" : [
1315 " if (_this.file == null) {",
1321 " var str = _this.buffer.toString();",
1323 " _this.buffer.checkSyntax();",
1327 " // LeftPanel.model.changed( str , false);",
1328 " _this.dirty = false;",
1329 " _this.save_button.el.sensitive = false;",
1331 " // find the text for the node..",
1332 " if (_this.file.xtype != \"PlainFile\") {",
1333 " // in theory these properties have to exist!?!",
1334 " \tthis.prop.val = str;",
1335 " //this.window.windowstate.left_props.reload();",
1337 " _this.file.setSource( str );",
1340 " // call the signal..",
1348 "(string in_txt) {",
1350 "\tvar s = new GtkSource.SearchSettings();",
1351 "\ts.case_sensitive = _this.case_sensitive.el.active;",
1352 "\ts.regex_enabled = _this.regex.el.active;\t",
1353 "\ts.wrap_around = false;",
1355 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
1356 "\tthis.searchcontext.set_highlight(true);",
1357 "\tvar txt = in_txt;",
1359 "\tif (_this.multiline.el.active) {",
1360 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1363 "\ts.set_search_text(txt);",
1364 "\tGtk.TextIter beg, st,en;",
1366 "\tthis.buffer.el.get_start_iter(out beg);",
1367 "\tbool has_wrapped_around;",
1368 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
1369 "\tthis.last_search_end = 0;",
1371 "\treturn this.searchcontext.get_occurrences_count();",
1379 "| string tempFileContents" : [
1383 " if (_this.file == null) {",
1386 "\tvar str= this.buffer.toString();",
1387 "\tif (_this.file.xtype == \"PlainFile\") {",
1395 " GLib.debug(\"calling validate\"); ",
1396 " // clear the buttons.",
1397 " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
1398 "\t\treturn this.file.toSource(); ;",
1401 "\tvar oldcode = _this.prop.val;",
1402 "\t_this.prop.val = str;",
1403 " var ret = _this.file.toSource();",
1404 " _this.prop.val = oldcode;",
1409 "| void backSearch" : [
1410 "(bool change_focus) {",
1412 "\tif (this.searchcontext == null) {",
1416 "\tGtk.TextIter beg, st,en;",
1417 "\tbool has_wrapped_around;",
1418 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1420 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1421 "\t\tthis.last_search_end = 0;",
1423 "\t\tthis.last_search_end = en.get_offset();",
1424 "\t\tif (change_focus) {",
1425 "\t\t\tthis.view.el.grab_focus();",
1427 "\t\tthis.buffer.el.place_cursor(st);",
1428 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1434 "| void forwardSearch" : [
1435 "(bool change_focus) {",
1437 "\tif (this.searchcontext == null) {",
1441 "\tGtk.TextIter beg, st,en;",
1442 "\t bool has_wrapped_around;",
1443 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
1444 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1446 "\t\tthis.last_search_end = 0; // not sure if this should happen",
1448 "\t\tif (has_wrapped_around) {",
1452 "\t\tthis.last_search_end = en.get_offset();",
1453 "\t\tif (change_focus) {",
1454 "\t\t\tthis.view.el.grab_focus();",
1456 "\t\tthis.buffer.el.place_cursor(st);",
1457 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1465 "\t this.file = null; ",
1467 " this.node = null;",
1468 " this.prop = null;",
1469 "\tthis.searchcontext = null;",
1474 "| void scroll_to_line" : [
1477 "\tGLib.Timeout.add(500, () => {",
1479 "\t\tvar buf = this.view.el.get_buffer();",
1481 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1484 "\t\tGtk.TextIter iter; ",
1485 "\t\tsbuf.get_iter_at_line(out iter, line);",
1486 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1487 "\t\treturn false;",
1493 "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
1496 " this.file = file; ",
1498 " if (file.xtype != \"PlainFile\") {",
1499 " \tthis.prop = prop;",
1500 " this.node = node;",
1502 " // find the text for the node..",
1503 " this.view.load( prop.val );",
1504 " this.updateErrorMarks();",
1508 " this.close_btn.el.show(); ",
1511 " this.view.load( file.toSource() );",
1512 " this.updateErrorMarks();",
1513 " this.close_btn.el.hide();",
1514 " var ls = file.getLanguageServer();",
1515 " ls.documentSymbols.begin(file, (a,o) => {",
1516 " \t_this.navigation.show(ls.documentSymbols.end(o)); ",
1518 " //documentSymbols",
1524 "| void updateErrorMarks" : [
1529 "\tvar buf = _this.buffer.el;",
1530 "\tGtk.TextIter start;",
1531 "\tGtk.TextIter end; ",
1532 "\tbuf.get_bounds (out start, out end);",
1537 "\t//GLib.debug(\"highlight errors\");\t\t ",
1539 "\t // we should highlight other types of errors..",
1541 "\tif (_this.window.windowstate.state != WindowState.State.CODEONLY ",
1543 "\t\t_this.window.windowstate.state != WindowState.State.CODE",
1545 "\t\t//GLib.debug(\"windowstate != CODEONLY?\");",
1551 "\tif (_this.file == null) {",
1552 "\t\tGLib.debug(\"file is null?\");",
1556 "\tvar ar = this.file.getErrors();",
1557 "\tif (ar.size < 1) {",
1558 "\t\tbuf.remove_source_marks (start, end, \"ERR\");",
1559 "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
1560 "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
1561 "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1562 "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1563 "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1564 "\t\tthis.last_error_counter = file.error_counter ;",
1565 "\t\t//GLib.debug(\"highlight %s : %s has no errors\", this.file.relpath, category);",
1570 " // basicaly check if there is no change, then we do not do any update..",
1571 " // we can do this by just using an error counter?",
1572 " // if that's changed then we will do an update, otherwise dont bother.",
1575 "\tvar offset = 0;",
1576 "\tvar hoffset = 0;",
1578 "\tvar tlines = buf.get_line_count () +1;",
1580 "\tif (_this.prop != null) {",
1581 "\t\t// this still seems flaky...",
1583 "\t\ttlines = _this.prop.end_line;",
1584 "\t\toffset = _this.prop.start_line;",
1585 "\t\thoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..",
1589 "\t\t// no update...",
1590 "\t\tif (this.last_error_counter == file.error_counter) {",
1596 "\tbuf.remove_source_marks (start, end, \"ERR\");",
1597 "\tbuf.remove_source_marks (start, end, \"WARN\");",
1598 "\tbuf.remove_source_marks (start, end, \"DEPR\");",
1599 "\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1600 "\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1601 "\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1603 "\tforeach(var diag in ar) { ",
1604 "\t Gtk.TextIter iter;",
1605 "// print(\"get inter\\n\");",
1606 "\t var eline = (int)diag.range.start.line - offset;",
1607 "\t var eline_to = (int)diag.range.end.line - offset;",
1608 "\t //var eline = diag.range.end_line - offset;",
1609 "\t //GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
1610 "\t //\terr.line ,eline, offset);",
1613 "\t if (eline > tlines || eline < 0) {",
1617 "\t buf.get_iter_at_line( out iter, eline);",
1618 "\t \tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
1619 "\t buf.create_source_mark( msg, diag.category, iter);",
1621 " \t var spos = (int)diag.range.start.character - hoffset;",
1622 " \t if (spos < 0) { spos =0 ; }",
1623 " \t if (spos > iter.get_chars_in_line()) {",
1624 " \t \tspos = iter.get_chars_in_line();",
1626 "\t\tbuf.get_iter_at_line( out iter, eline_to);",
1627 "\t\tvar epos = (int)diag.range.end.character - hoffset;",
1628 " \t if (epos < 0) { epos =0 ; }",
1629 " \t if (epos > iter.get_chars_in_line()) {",
1630 " \t \tepos = iter.get_chars_in_line();",
1634 " \t buf.get_iter_at_line_offset( out start, eline, spos); ",
1636 " \t buf.get_iter_at_line_offset( out end, eline_to,epos); ",
1638 "\t buf.apply_tag_by_name(diag.category, start, end);",
1640 "\t // GLib.debug(\"set line %d to %s\", eline, msg);",
1641 "\t //this.marks.set(eline, msg);",
1643 "\tthis.last_error_counter = file.error_counter ;",