+ "string name" : "editor-navigation",
+ "xtype" : "ColumnView",
+ "| Gtk.Widget? getRowWidgetAt" : [
+ "(double x, double y, out string pos) {",
+ "",
+ "\tpos = \"\";",
+ "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
+ "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
+ "\tif (w == null) {",
+ "\t\treturn null;",
+ "\t}",
+ "\t",
+ "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
+ "\tif (row == null) {",
+ "\t\treturn null;",
+ "\t}",
+ "\t",
+ "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
+ "\t ",
+ " ",
+ "\t",
+ "\t//GLib.debug(\"row number is %d\", rn);",
+ "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
+ "\t// above or belw",
+ "\tGraphene.Rect bounds;",
+ "\trow.compute_bounds(this.el, out bounds);",
+ "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
+ "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
+ "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
+ "\t//\t);",
+ "\tvar ypos = y - bounds.get_y();",
+ "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
+ "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
+ "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
+ "\tpos = \"over\";",
+ "\t",
+ "\tif (rpos > 80) {",
+ "\t\tpos = \"below\";",
+ "\t} else if (rpos < 20) {",
+ "\t\tpos = \"above\";",
+ "\t} ",
+ "\treturn row;",
+ " }"
+ ],
+ "| int getRowAt" : [
+ "(double x, double y, out string pos) {",
+ "",
+ "\tpos = \"\";",
+ "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
+ "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
+ "\tif (w == null) {",
+ "\t\treturn -1;",
+ "\t}",
+ "\t",
+ "\tvar row= w.get_ancestor(GLib.Type.from_name(\"GtkColumnViewRowWidget\"));",
+ "\tif (row == null) {",
+ "\t\treturn -1;",
+ "\t}",
+ "\t",
+ "\t//GLib.debug(\"got colview %s\", row == null ? \"nothing\" : row.get_type().name());",
+ "\t ",
+ "\tvar rn = 0;",
+ "\tvar cr = row;",
+ "\t ",
+ "\twhile (cr.get_prev_sibling() != null) {",
+ "\t\trn++;",
+ "\t\tcr = cr.get_prev_sibling();",
+ "\t}",
+ "\t",
+ "\t//GLib.debug(\"row number is %d\", rn);",
+ "\t//GLib.debug(\"click %d, %d\", (int)x, (int)y);",
+ "\t// above or belw",
+ "\tGraphene.Rect bounds;",
+ "\trow.compute_bounds(this.el, out bounds);",
+ "\t//GLib.debug(\"click x=%d, y=%d, w=%d, h=%d\", ",
+ "\t//\t(int)bounds.get_x(), (int)bounds.get_y(),",
+ "\t//\t(int)bounds.get_width(), (int)bounds.get_height()",
+ "\t//\t);",
+ "\tvar ypos = y - bounds.get_y();",
+ "\t//GLib.debug(\"rel ypos = %d\", (int)ypos);\t",
+ "\tvar rpos = 100.0 * (ypos / bounds.get_height());",
+ "\t//GLib.debug(\"rel pos = %d %%\", (int)rpos);",
+ "\tpos = \"over\";",
+ "\t",
+ "\tif (rpos > 80) {",
+ "\t\tpos = \"below\";",
+ "\t} else if (rpos < 20) {",
+ "\t\tpos = \"above\";",
+ "\t} ",
+ "\treturn rn;",
+ " }"
+ ],
+ "| void show" : [
+ "(Gee.ArrayList<Lsp.DocumentSymbol> syms) {",
+ "\t_this.navigationwindow.el.show();",
+ "\t//_this.navliststore.el.remove_all();",
+ "\t",
+ "\t",
+ "\tvar ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));",
+ "\t",
+ "\tforeach(var sym in syms) {",
+ "\t\tls.append(sym);",
+ "\t}",
+ "\tLsp.DocumentSymbol.copyList(ls, _this.navliststore.el);",
+ "\t//_this.navliststore.el.append(sym);",
+ "\tthis.last_selected_line = -1;",
+ "\tGLib.Idle.add(() => {",
+ "\t\t_this.navigationsort.collapseOnLoad();",
+ "\t\tGtk.TextIter iter;",
+ "\t\t_this.buffer.el.get_iter_at_offset (",
+ "\t\t\t\tout iter, _this.buffer.el.cursor_position);",
+ "\t\t",
+ "\t\tGLib.debug(\"idle update scroll %d, %d\", iter.get_line(),",
+ "\t\t\t\titer.get_line_offset());",
+ "\t\tthis.updateSelectedLine(",
+ "\t\t\t\t(uint)iter.get_line(),",
+ "\t\t\t\t(uint)iter.get_line_offset()",
+ "\t\t);",
+ "\t\treturn false;",
+ "\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 = sym.get_data<Gtk.Widget>(\"widget\");",
+ "\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}",
+ "",
+ "",
+ "}"
+ ]