public Xcls_navigationwindow navigationwindow;
public Xcls_navigation navigation;
public Xcls_navigationselmodel navigationselmodel;
+ public Xcls_navigationsort navigationsort;
public Xcls_navliststore navliststore;
// my vars (def)
public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
{
this.reset();
+ if (this.file != null) {
+ this.file.navigation_tree_updated.disconnect(
+ _this.navigation.show
+ );
+ }
this.file = file;
-
+ this.file.navigation_tree_updated.connect(
+ _this.navigation.show
+ );
if (file.xtype != "PlainFile") {
this.prop = prop;
this.node = node;
} else {
this.view.load( file.toSource() );
- this.updateErrorMarks();
+ this.updateErrorMarks();
this.close_btn.el.hide();
var ls = file.getLanguageServer();
- ls.documentSymbols.begin(file, (a,o) => {
- _this.navigation.show(ls.documentSymbols.end(o));
- });
+ ls.queueDocumentSymbols(file);
+ ////ls.documentSymbols.begin(file, (a,o) => {
+ // _this.navigation.show(ls.documentSymbols.end(o));
+ //});
//documentSymbols
}
buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
//listeners
+ this.el.cursor_moved.connect( ( ) => {
+
+ Gtk.TextIter iter;
+ this.el.get_iter_at_offset (
+ out iter, this.el.cursor_position);
+
+ _this.navigation.updateSelectedLine(
+ (uint)iter.get_line(),
+ (uint)iter.get_line_offset()
+ );
+
+
+ });
this.el.changed.connect( () => {
// check syntax??
// ??needed..??
_this.file.setSource(str);
BuilderApplication.showSpinner("appointment soon","document change pending");
_this.file.getLanguageServer().document_change(_this.file);
-
+ _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
_this.file.setSource(oldcode);
}
//_this.view.el.show_completion();
// print(event.key.keyval)
-
-
-
+
return;
// my vars (def)
+ public int last_selected_line;
+ public Gtk.Widget? selected_row;
// ctor
public Xcls_navigation(Editor _owner )
this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
// my vars (dec)
+ this.last_selected_line = -1;
+ this.selected_row = null;
// set gobject values
this.el.name = "editor-navigation";
var child_2 = new Xcls_ColumnViewColumn29( _this );
child_2.ref();
this.el.append_column( child_2.el );
- var child_3 = new Xcls_GestureClick34( _this );
+ var child_3 = new Xcls_GestureClick38( _this );
child_3.ref();
this.el.add_controller( child_3.el );
}
// user defined functions
+ public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
+
+ pos = "";
+ var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
+ //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
+ if (w == null) {
+ return null;
+ }
+
+ var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
+ if (row == null) {
+ return null;
+ }
+
+ //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
+
+
+
+ //GLib.debug("row number is %d", rn);
+ //GLib.debug("click %d, %d", (int)x, (int)y);
+ // above or belw
+ Graphene.Rect bounds;
+ row.compute_bounds(this.el, out bounds);
+ //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
+ // (int)bounds.get_x(), (int)bounds.get_y(),
+ // (int)bounds.get_width(), (int)bounds.get_height()
+ // );
+ var ypos = y - bounds.get_y();
+ //GLib.debug("rel ypos = %d", (int)ypos);
+ var rpos = 100.0 * (ypos / bounds.get_height());
+ //GLib.debug("rel pos = %d %%", (int)rpos);
+ pos = "over";
+
+ if (rpos > 80) {
+ pos = "below";
+ } else if (rpos < 20) {
+ pos = "above";
+ }
+ return row;
+ }
public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
_this.navigationwindow.el.show();
- _this.navliststore.el.remove_all();
+ //_this.navliststore.el.remove_all();
+
+
+ var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
+
foreach(var sym in syms) {
- _this.navliststore.el.append(sym);
+ ls.append(sym);
}
-
+ Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
+ //_this.navliststore.el.append(sym);
+ this.last_selected_line = -1;
+ GLib.Idle.add(() => {
+
+ Gtk.TextIter iter;
+ _this.buffer.el.get_iter_at_offset (
+ out iter, _this.buffer.el.cursor_position);
+
+ GLib.debug("idle update scroll %d, %d", iter.get_line(),
+ iter.get_line_offset());
+ this.updateSelectedLine(
+ (uint)iter.get_line(),
+ (uint)iter.get_line_offset()
+ );
+ return false;
+ });
}
public int getRowAt (double x, double y, out string pos) {
}
return rn;
}
+ public void updateSelectedLine (uint line, uint chr) {
+ if (line == this.last_selected_line) {
+ return;
+ }
+ GLib.debug("select line %d", (int)line);
+ this.last_selected_line = (int)line;
+
+
+ var new_row = -1;
+ var sym = _this.navliststore.symbolAtLine(line, chr);
+ if (sym != null) {
+ new_row = _this.navigationsort.getRowFromSymbol(sym);
+ GLib.debug("select line %d - row found %d", (int)line, new_row);
+ } else {
+ GLib.debug(" no symbol found at line %d", (int)line);
+ }
+
+ if (this.selected_row != null) {
+ GLib.debug(" remove selected row");
+ this.selected_row.remove_css_class("selected-row");
+ }
+ this.selected_row = null;
+ if (new_row > -1) {
+ this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
+ var row = sym.get_data<Gtk.Widget>("widget");
+ if (row != null) {
+ GLib.debug(" Add selected row");
+
+ row.add_css_class("selected-row");
+ this.selected_row = row;
+
+
+ } else {
+ GLib.debug("could not find widget on row %d", new_row);
+ }
+
+ }
+
+
+ }
}
public class Xcls_ColumnViewColumn29 : Object
{
var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
var sym = (Lsp.DocumentSymbol) lr.get_item();
- GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
+ sym.set_data<Gtk.Widget>("widget", expand.get_parent());
+ expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
+
+ //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
+
+ //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
expand.set_hide_expander( sym.children.get_n_items() < 1);
expand.set_list_row(lr);
{
_this = _owner;
_this.navigationselmodel = this;
- var child_1 = new Xcls_SortListModel60( _this );
- child_1.ref();
- this.el = new Gtk.NoSelection( child_1.el );
+ new Xcls_navigationsort( _this );
+ this.el = new Gtk.NoSelection( _this.navigationsort.el );
// my vars (dec)
}
// user defined functions
- public Lsp.DocumentSymbol? getSymoblAt (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());
-
-
- return (Lsp.DocumentSymbol)tr.get_item();
-
- }
}
- public class Xcls_SortListModel60 : Object
+ public class Xcls_navigationsort : Object
{
public Gtk.SortListModel el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_SortListModel60(Editor _owner )
+ public Xcls_navigationsort(Editor _owner )
{
_this = _owner;
- var child_1 = new Xcls_TreeListModel171( _this );
+ _this.navigationsort = this;
+ var child_1 = new Xcls_TreeListModel33( _this );
child_1.ref();
- var child_2 = new Xcls_TreeListRowSorter209( _this );
+ var child_2 = new Xcls_TreeListRowSorter35( _this );
child_2.ref();
this.el = new Gtk.SortListModel( child_1.el, child_2.el );
}
// user defined functions
+ public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
+
+ for (var i=0;i < this.el.get_n_items(); i++) {
+ var tr = (Gtk.TreeListRow)this.el.get_item(i);
+
+ if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
+ return i;
+ }
+ }
+ return -1;
+ }
+ public 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());
+
+
+ return (Lsp.DocumentSymbol)tr.get_item();
+
+ }
}
- public class Xcls_TreeListModel171 : Object
+ public class Xcls_TreeListModel33 : Object
{
public Gtk.TreeListModel el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_TreeListModel171(Editor _owner )
+ public Xcls_TreeListModel33(Editor _owner )
{
_this = _owner;
new Xcls_navliststore( _this );
}
// user defined functions
+ public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
+
+
+ for(var i = 0; i < this.el.get_n_items();i++) {
+ var el = (Lsp.DocumentSymbol)this.el.get_item(i);
+ //GLib.debug("Check sym %s : %d-%d",
+ // el.name , (int)el.range.start.line,
+ // (int)el.range.end.line
+ //);
+ var ret = el.containsLine(line,chr);
+ if (ret != null) {
+ return ret;
+ }
+
+ }
+
+ return null;
+ }
}
- public class Xcls_TreeListRowSorter209 : Object
+ public class Xcls_TreeListRowSorter35 : Object
{
public Gtk.TreeListRowSorter el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_TreeListRowSorter209(Editor _owner )
+ public Xcls_TreeListRowSorter35(Editor _owner )
{
_this = _owner;
- var child_1 = new Xcls_StringSorter217( _this );
+ var child_1 = new Xcls_StringSorter36( _this );
child_1.ref();
this.el = new Gtk.TreeListRowSorter( child_1.el );
// user defined functions
}
- public class Xcls_StringSorter217 : Object
+ public class Xcls_StringSorter36 : Object
{
public Gtk.StringSorter el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_StringSorter217(Editor _owner )
+ public Xcls_StringSorter36(Editor _owner )
{
_this = _owner;
- var child_1 = new Xcls_PropertyExpression224( _this );
+ var child_1 = new Xcls_PropertyExpression37( _this );
child_1.ref();
this.el = new Gtk.StringSorter( child_1.el );
// user defined functions
}
- public class Xcls_PropertyExpression224 : Object
+ public class Xcls_PropertyExpression37 : Object
{
public Gtk.PropertyExpression el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_PropertyExpression224(Editor _owner )
+ public Xcls_PropertyExpression37(Editor _owner )
{
_this = _owner;
this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
- public class Xcls_GestureClick34 : Object
+ public class Xcls_GestureClick38 : Object
{
public Gtk.GestureClick el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_GestureClick34(Editor _owner )
+ public Xcls_GestureClick38(Editor _owner )
{
_this = _owner;
this.el = new Gtk.GestureClick();
//listeners
this.el.pressed.connect( (n_press, x, y) => {
string pos;
- var row = _this.navigation.getRowAt(x,y, out pos );
- if (row < 0) {
+ var row = _this.navigation.getRowWidgetAt(x,y, out pos );
+
+ if (row == null) {
GLib.debug("no row selected items");
return;
}
+ GLib.debug("got click on %s", row.get_type().name());
//Lsp.DocumentSymbol
- var sym = _this.navigationselmodel.getSymoblAt(row);
+ var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
if (sym == null) {
return;
}
"character" : 39
}
},
- */
+ */
+ GLib.debug("goto line %d", (int)sym.range.start.line);
_this.scroll_to_line((int)sym.range.start.line);
+ Gtk.TextIter iter;
+ _this.buffer.el.get_iter_at_line_offset(out iter,
+ (int)sym.range.start.line,
+ (int)sym.range.start.character
+ );
+ _this.buffer.el.place_cursor(iter);
});
}