" return ;",
"}",
""
+ ],
+ "cursor_moved" : [
+ "( ) => {",
+ "",
+ "\tGtk.TextIter iter;",
+ "\tthis.el.get_iter_at_offset (",
+ "\t\t\tout iter, this.el.cursor_position);",
+ "\tvar line = iter.get_line();",
+ "\t_this.navigation.updateSelectedLine(",
+ "\t\t\t(uint)iter.get_line(),",
+ "\t\t\t(uint)iter.get_line_offset()",
+ "\t\t);",
+ "",
+ "",
+ "}",
+ ""
]
},
"| bool OLDhighlightErrorsJson" : [
"id" : "navigationwindow",
"items" : [
{
+ "# int last_selected_line" : "-1",
+ "$ Gtk.Widget? selected_row" : "null",
"$ xns" : "Gtk",
"* prop" : "child",
"id" : "navigation",
{
"$ xns" : "Gtk",
"* prop" : "model",
+ "id" : "navigationsort",
"items" : [
{
"$ Gtk.TreeListModelCreateModelFunc create_func" : [
"$ xns" : "GLib",
"* prop" : "root",
"id" : "navliststore",
- "xtype" : "ListStore"
+ "xtype" : "ListStore",
+ "| Lsp.DocumentSymbol? symbolAtLine" : [
+ "(uint line, uint chr) {",
+ " ",
+ "\t",
+ "\tfor(var i = 0; i < this.el.get_n_items();i++) {",
+ "\t\tvar el = (Lsp.DocumentSymbol)this.el.get_item(i);",
+ "\t\t//GLib.debug(\"Check sym %s : %d-%d\",",
+ "\t\t//\tel.name , (int)el.range.start.line,",
+ "\t\t//\t(int)el.range.end.line",
+ "\t\t//);",
+ "\t\tvar ret = el.containsLine(line,chr);",
+ "\t\tif (ret != null) {",
+ "\t\t\treturn ret;",
+ "\t\t}",
+ "\t\t",
+ "\t}",
+ "\t",
+ "\treturn null;",
+ "}"
+ ]
}
],
"xtype" : "TreeListModel"
"xtype" : "TreeListRowSorter"
}
],
- "xtype" : "SortListModel"
+ "xtype" : "SortListModel",
+ "| Lsp.DocumentSymbol? getSymbolAt" : [
+ "(uint row) {",
+ "",
+ " var tr = (Gtk.TreeListRow)this.el.get_item(row);",
+ " ",
+ " var a = tr.get_item();; ",
+ " GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
+ " \t",
+ " ",
+ " return (Lsp.DocumentSymbol)tr.get_item();",
+ "\t ",
+ "}"
+ ],
+ "| int getRowFromSymbol" : [
+ "(Lsp.DocumentSymbol sym) {",
+ "",
+ "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
+ "\t\tvar tr = (Gtk.TreeListRow)this.el.get_item(i);",
+ "\t ",
+ "\t\tif (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {",
+ "\t\t\treturn i;",
+ "\t\t}",
+ "\t}",
+ " \treturn -1;",
+ "}"
+ ]
}
],
"xtype" : "NoSelection",
- "| Lsp.DocumentSymbol? getSymoblAt" : [
+ "| Lsp.DocumentSymbol? getSymbollAtOLD" : [
"(uint row) {",
"",
" var tr = (Gtk.TreeListRow)this.el.get_item(row);",
" return (Lsp.DocumentSymbol)tr.get_item();",
"\t ",
"}"
+ ],
+ "| int getRowFromSymbolx" : [
+ "(Lsp.DocumentSymbol sym) {",
+ "",
+ "\tfor (var i=0;i < this.el.get_n_items(); i++) {",
+ "\t\tvar tr = (Gtk.TreeListRow)this.el.get_item(i);",
+ "\t ",
+ "\t\tif (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {",
+ "\t\t\treturn i;",
+ "\t\t}",
+ "\t}",
+ " \treturn -1;",
+ "}"
]
},
{
"\t return;",
" }",
" //Lsp.DocumentSymbol",
- " var sym = _this.navigationselmodel.getSymoblAt(row);",
+ " var sym = _this.navigationsort.getSymbolAt(row);",
" if (sym == null) {",
" \treturn;",
"\t}",
" \"character\" : 39",
" }",
" },",
- " */",
+ " */",
+ " GLib.debug(\"goto line %d\", (int)sym.range.start.line); ",
" _this.scroll_to_line((int)sym.range.start.line);",
"\t",
"}"
],
"string name" : "editor-navigation",
"xtype" : "ColumnView",
+ "| Gtk.Widget? getWidgetAtRow" : [
+ "(uint row) {",
+ "/*",
+ " \t",
+ "from \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
+ " \tvar colview = gesture.widget;",
+ " \tvar line_no = check_list_widget(colview, x,y);",
+ " if (line_no > -1) {",
+ " \t\tvar item = colview.model.get_item(line_no);",
+ " \t\t ",
+ " \t}",
+ " \t*/",
+ "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
+ " var child = this.el.get_first_child(); ",
+ " \tvar line_no = -1; ",
+ " \tvar reading_header = true;",
+ "\t ",
+ " \twhile (child != null) {",
+ "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
+ " \t ",
+ " \t if (reading_header) {",
+ "\t\t\t\t",
+ "",
+ "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
+ "\t\t\t\t ",
+ "\t\t\t\t\tchild = child.get_next_sibling();",
+ "\t\t\t\t\tcontinue;",
+ "\t\t\t\t}",
+ "\t\t\t\t// should be columnlistview",
+ "\t\t\t\tchild = child.get_first_child(); ",
+ "\t\t\t ",
+ "\t\t\t ",
+ "\t\t\t\t",
+ "\t\t\t\treading_header = false;",
+ "\t\t\t\tcontinue;",
+ "\t\t }",
+ "\t\t ",
+ "\t\t ",
+ " \t ",
+ "\t\t line_no++;",
+ "\t\t\tif (line_no == row) {",
+ "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
+ "\t\t\t return (Gtk.Widget)child;",
+ "\t\t }",
+ "\t child = child.get_next_sibling(); ",
+ " \t}",
+ "\t\tGLib.debug(\"Failed to find row (max = %d)\", line_no);",
+ " return null;",
+ "",
+ " }"
+ ],
"| int getRowAt" : [
"(double x, double y, out string pos) {",
"",
"\t",
"",
"}"
+ ],
+ "| void updateSelectedLine" : [
+ "(uint line, uint chr) {",
+ "\tif (line == this.last_selected_line) {",
+ "\t\treturn;",
+ "\t}",
+ "\tGLib.debug(\"select line %d\", (int)line);",
+ "\tthis.last_selected_line = (int)line;",
+ "\t",
+ "\t",
+ "\tvar new_row = -1;",
+ "\tvar sym = _this.navliststore.symbolAtLine(line, chr);",
+ "\tif (sym != null) {",
+ "\t \tnew_row = _this.navigationsort.getRowFromSymbol(sym);",
+ " \t\tGLib.debug(\"select line %d - row found %d\", (int)line, new_row);",
+ " \t} else {",
+ " \t\tGLib.debug(\" no symbol found at line %d\", (int)line);",
+ " \t}",
+ " \t",
+ "\tif (this.selected_row != null) { ",
+ "\t\tGLib.debug(\" remove selected row\");",
+ "\t\tthis.selected_row.remove_css_class(\"selected-row\");",
+ "\t}",
+ "\tthis.selected_row = null;",
+ "\tif (new_row > -1) {",
+ "\t\tthis.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);",
+ "\t\tvar row = this.getWidgetAtRow(new_row);",
+ "\t\tif (row != null) {",
+ "\t\t\tGLib.debug(\" Add selected row\");",
+ " \t\t\t",
+ "\t\t\trow.add_css_class(\"selected-row\");",
+ "\t\t\tthis.selected_row = row;",
+ "",
+ "\t\t\t",
+ "\t\t} else {",
+ "\t\t\tGLib.debug(\"could not find widget on row %d\", new_row);",
+ "\t\t}",
+ "",
+ "\t}",
+ "",
+ "",
+ "}"
]
}
],