X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FBuilder4%2FEditor.vala;h=825f993e2d1e3a04ccb0a250ff0b9c443581f6e3;hb=HEAD;hp=94dd0ca1ceb08eecccc58aec75ead1b7f9de5fa4;hpb=ee48badb20ee4af798c32c9b02bb5feb75d42beb;p=roobuilder diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index 94dd0ca1c..825f993e2 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -12,7 +12,9 @@ public class Editor : Object } return _Editor; } + public Xcls_paned paned; public Xcls_save_button save_button; + public Xcls_helper helper; public Xcls_close_btn close_btn; public Xcls_RightEditor RightEditor; public Xcls_view view; @@ -26,9 +28,11 @@ public class Editor : Object public Xcls_case_sensitive case_sensitive; public Xcls_regex regex; public Xcls_multiline multiline; + public Xcls_navigation_holder navigation_holder; public Xcls_navigationwindow navigationwindow; public Xcls_navigation navigation; public Xcls_navigationselmodel navigationselmodel; + public Xcls_navigationsort navigationsort; public Xcls_navliststore navliststore; // my vars (def) @@ -68,9 +72,8 @@ public class Editor : Object this.el.homogeneous = false; this.el.hexpand = true; this.el.vexpand = true; - var child_1 = new Xcls_Paned1( _this ); - child_1.ref(); - this.el.append( child_1.el ); + new Xcls_paned( _this ); + this.el.append( _this.paned.el ); } // user defined functions @@ -137,8 +140,15 @@ public class Editor : Object 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; @@ -153,12 +163,13 @@ public class Editor : Object } 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 } @@ -391,7 +402,7 @@ public class Editor : Object return false; }); } - public class Xcls_Paned1 : Object + public class Xcls_paned : Object { public Gtk.Paned el; private Editor _this; @@ -400,19 +411,24 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_Paned1(Editor _owner ) + public Xcls_paned(Editor _owner ) { _this = _owner; + _this.paned = this; this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL ); // my vars (dec) // set gobject values + this.el.resize_start_child = false; + this.el.shrink_end_child = false; + this.el.resize_end_child = false; + this.el.shrink_start_child = false; var child_1 = new Xcls_Box2( _this ); child_1.ref(); this.el.start_child = child_1.el; - new Xcls_navigationwindow( _this ); - this.el.end_child = _this.navigationwindow.el; + new Xcls_navigation_holder( _this ); + this.el.end_child = _this.navigation_holder.el; } // user defined functions @@ -434,6 +450,7 @@ public class Editor : Object // my vars (dec) // set gobject values + this.el.hexpand = true; var child_1 = new Xcls_Box3( _this ); child_1.ref(); this.el.append( child_1.el ); @@ -464,12 +481,12 @@ public class Editor : Object // set gobject values this.el.homogeneous = false; - this.el.hexpand = true; + this.el.hexpand = false; + this.el.vexpand = false; new Xcls_save_button( _this ); this.el.append( _this.save_button.el ); - var child_2 = new Xcls_Label5( _this ); - child_2.ref(); - this.el.append( child_2.el ); + new Xcls_helper( _this ); + this.el.append( _this.helper.el ); var child_3 = new Xcls_Scale6( _this ); child_3.ref(); this.el.append( child_3.el ); @@ -497,6 +514,7 @@ public class Editor : Object // my vars (dec) // set gobject values + this.el.vexpand = true; this.el.label = "Save"; //listeners @@ -508,7 +526,7 @@ public class Editor : Object // user defined functions } - public class Xcls_Label5 : Object + public class Xcls_helper : Object { public Gtk.Label el; private Editor _this; @@ -517,18 +535,83 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_Label5(Editor _owner ) + public Xcls_helper(Editor _owner ) { _this = _owner; + _this.helper = this; this.el = new Gtk.Label( null ); // my vars (dec) // set gobject values + this.el.margin_end = 4; + this.el.margin_start = 4; + this.el.justify = Gtk.Justification.LEFT; this.el.hexpand = true; + this.el.xalign = 0f; + + //listeners + this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => { + GLib.debug("using quiery tooltip?"); + var lbl = new Gtk.Label(this.el.tooltip_markup); + lbl.width_request = 500; + tooltip.set_custom(lbl); + + return true; + }); + this.el.activate_link.connect( (uri) => { + GLib.debug("got uri %s", uri); + var ls = _this.file.getLanguageServer(); + ls.symbol.begin(uri, (a,b) => { + ls.symbol.end(b); + }); + + return true; + }); } // user defined functions + public void setHelp (Lsp.Hover? help) { + if (help == null || help.contents == null + || help.contents.size < 1) { + this.el.set_text(""); + return; + } + var sig = help.contents.get(0).value.split(" "); + string[] str = {}; + for(var i =0; i < sig.length; i++) { + + switch(sig[i]) { + case "public": + case "private": + case "protected": + case "async": + case "class": + case "{": + case "}": + case "(": + case ")": + + str += sig[i]; + continue; + + + default: + + str += ("" + + GLib.Markup.escape_text(sig[i]) + +""); + continue; + } + } + if (help.contents.size > 1) { + this.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(1).value); + } else { + this.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(0).value); + } + this.el.set_markup(string.joinv(" ",str)); + + } } public class Xcls_Scale6 : Object @@ -548,8 +631,9 @@ public class Editor : Object // my vars (dec) // set gobject values - this.el.width_request = 200; + this.el.width_request = 150; this.el.has_origin = true; + this.el.halign = Gtk.Align.END; this.el.draw_value = false; this.el.digits = 0; this.el.sensitive = true; @@ -603,6 +687,7 @@ public class Editor : Object // set gobject values this.el.icon_name = "window-close"; + this.el.halign = Gtk.Align.END; var child_1 = new Xcls_Image8( _this ); child_1.ref(); this.el.child = child_1.el; @@ -926,6 +1011,19 @@ public class Editor : Object 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.showHelp(iter); + + }); this.el.changed.connect( () => { // check syntax?? // ??needed..?? @@ -1078,7 +1176,7 @@ public class Editor : Object _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); @@ -1144,6 +1242,45 @@ public class Editor : Object //print("TO STRING? " + ret); return ret; } + public void showHelp (Gtk.TextIter iter) { + var back = iter.copy(); + back.backward_char(); + + var forward = iter.copy(); + forward.forward_char(); + + // what's the character at the iter? + var str = back.get_text(iter); + str += iter.get_text(forward); + if (str.strip().length < 1) { + return; + } + var offset = iter.get_line_offset(); + var line = iter.get_line(); + if (_this.prop != null) { + // + line += _this.prop.start_line ; + // this is based on Gtk using tabs (hence 1/2 chars); + offset += _this.node.node_pad.length; + // javascript listeners are indented 2 more spaces. + if (_this.prop.ptype == JsRender.NodePropType.LISTENER) { + offset += 2; + } + } + + var ls = _this.file.getLanguageServer(); + ls.hover.begin( + _this.file, line, offset, + ( a, o) => { + try { + var res = ls.hover.end(o ); + + _this.helper.setHelp(res); + } catch (GLib.Error e) { + // noop.. + } + }); + } } public class Xcls_keystate : Object @@ -1206,9 +1343,7 @@ public class Editor : Object } //_this.view.el.show_completion(); // print(event.key.keyval) - - - + return; @@ -1291,6 +1426,30 @@ public class Editor : Object // my vars (dec) // set gobject values + + //listeners + this.el.pressed.connect( (n_press, x, y) => { + Gtk.TextIter iter; + int buffer_x, buffer_y; + var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT); + + _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT, + (int)x - gut.get_width(), (int)y, + out buffer_x, out buffer_y); + _this.view.el.get_iter_at_location (out iter, + buffer_x, buffer_y);; + + + if (_this.buffer.el.iter_has_context_class(iter, "comment") || + _this.buffer.el.iter_has_context_class(iter, "string") + ) { + return ; + } + _this.buffer.showHelp(iter); + + + + }); } // user defined functions @@ -1728,6 +1887,59 @@ public class Editor : Object + public class Xcls_navigation_holder : Object + { + public Gtk.Box el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_navigation_holder(Editor _owner ) + { + _this = _owner; + _this.navigation_holder = this; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.width_request = 120; + this.el.hexpand = true; + this.el.vexpand = true; + this.el.visible = false; + var child_1 = new Xcls_Box28( _this ); + child_1.ref(); + this.el.append( child_1.el ); + new Xcls_navigationwindow( _this ); + this.el.append( _this.navigationwindow.el ); + } + + // user defined functions + } + public class Xcls_Box28 : Object + { + public Gtk.Box el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Box28(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_navigationwindow : Object { public Gtk.ScrolledWindow el; @@ -1746,7 +1958,9 @@ public class Editor : Object // my vars (dec) // set gobject values - this.el.visible = false; + this.el.hexpand = true; + this.el.vexpand = true; + this.el.visible = true; new Xcls_navigation( _this ); this.el.child = _this.navigation.el; } @@ -1760,6 +1974,8 @@ public class Editor : Object // my vars (def) + public int last_selected_line; + public Gtk.Widget? selected_row; // ctor public Xcls_navigation(Editor _owner ) @@ -1770,25 +1986,96 @@ public class Editor : Object 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 ); + var child_2 = new Xcls_ColumnViewColumn31( _this ); child_2.ref(); this.el.append_column( child_2.el ); - var child_3 = new Xcls_GestureClick34( _this ); + var child_3 = new Xcls_GestureClick40( _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 syms) { - _this.navigationwindow.el.show(); - _this.navliststore.el.remove_all(); + + if (!_this.navigation_holder.el.visible && syms.size > 0) { + _this.navigation_holder.el.show(); + _this.paned.el.position = + _this.paned.el.get_width() - 200; + } + //_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); } - + // if syms updated is empty, but we already have one.. + if (_this.navliststore.el.get_n_items() > 0 && ls.get_n_items() < 1) { + return; + } + Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el); + //_this.navliststore.el.append(sym); + this.last_selected_line = -1; + GLib.Idle.add(() => { + _this.navigationsort.collapseOnLoad(); + 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) { @@ -1837,8 +2124,48 @@ public class Editor : Object } 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("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 + public class Xcls_ColumnViewColumn31 : Object { public Gtk.ColumnViewColumn el; private Editor _this; @@ -1847,10 +2174,10 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_ColumnViewColumn29(Editor _owner ) + public Xcls_ColumnViewColumn31(Editor _owner ) { _this = _owner; - var child_1 = new Xcls_SignalListItemFactory30( _this ); + var child_1 = new Xcls_SignalListItemFactory32( _this ); child_1.ref(); this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el ); @@ -1862,7 +2189,7 @@ public class Editor : Object // user defined functions } - public class Xcls_SignalListItemFactory30 : Object + public class Xcls_SignalListItemFactory32 : Object { public Gtk.SignalListItemFactory el; private Editor _this; @@ -1871,7 +2198,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_SignalListItemFactory30(Editor _owner ) + public Xcls_SignalListItemFactory32(Editor _owner ) { _this = _owner; this.el = new Gtk.SignalListItemFactory(); @@ -1906,6 +2233,7 @@ public class Editor : Object }); this.el.bind.connect( (listitem) => { + // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name()); //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child(); @@ -1921,16 +2249,25 @@ public class Editor : 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("widget", expand.get_parent()); + expand.get_parent().get_parent().set_data("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.in_bind = true; + // default is to expand + + //this.in_bind = false; sym.bind_property("symbol_icon", img, "icon_name", GLib.BindingFlags.SYNC_CREATE); - hbox.add_css_class(sym.symbol_icon); + hbox.css_classes = { sym.symbol_icon }; sym.bind_property("name", lbl, "label", @@ -1961,9 +2298,8 @@ public class Editor : Object { _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) @@ -1971,19 +2307,8 @@ public class Editor : Object } // 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; @@ -1992,12 +2317,13 @@ public class Editor : Object // 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_TreeListModel35( _this ); child_1.ref(); - var child_2 = new Xcls_TreeListRowSorter209( _this ); + var child_2 = new Xcls_TreeListRowSorter37( _this ); child_2.ref(); this.el = new Gtk.SortListModel( child_1.el, child_2.el ); @@ -2007,8 +2333,48 @@ public class Editor : Object } // user defined functions + public void collapseOnLoad () { + for (var i=0;i < this.el.get_n_items(); i++) { + var tr = (Gtk.TreeListRow)this.el.get_item(i); + var sym = (Lsp.DocumentSymbol)tr.get_item(); + switch (sym.kind) { + case Lsp.SymbolKind.Enum: + tr.expanded = false; + break; + default: + //tr.expanded = true; + break; + } + } + + + + + } + 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_TreeListModel35 : Object { public Gtk.TreeListModel el; private Editor _this; @@ -2017,7 +2383,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_TreeListModel171(Editor _owner ) + public Xcls_TreeListModel35(Editor _owner ) { _this = _owner; new Xcls_navliststore( _this ); @@ -2030,6 +2396,20 @@ public class Editor : Object // my vars (dec) // set gobject values + + //listeners + this.el.items_changed.connect( (position, removed, added) => { + GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added); + if (added < 1) { + return; + } + //var sym = (Lsp.DocumentSymbol) this.el.get_item(position); + var row = this.el.get_row(position); + + GLib.debug("got %s", row.get_item().get_type().name()); + + + }); } // user defined functions @@ -2055,10 +2435,28 @@ public class Editor : Object } // 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_TreeListRowSorter37 : Object { public Gtk.TreeListRowSorter el; private Editor _this; @@ -2067,10 +2465,10 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_TreeListRowSorter209(Editor _owner ) + public Xcls_TreeListRowSorter37(Editor _owner ) { _this = _owner; - var child_1 = new Xcls_StringSorter217( _this ); + var child_1 = new Xcls_StringSorter38( _this ); child_1.ref(); this.el = new Gtk.TreeListRowSorter( child_1.el ); @@ -2081,7 +2479,7 @@ public class Editor : Object // user defined functions } - public class Xcls_StringSorter217 : Object + public class Xcls_StringSorter38 : Object { public Gtk.StringSorter el; private Editor _this; @@ -2090,10 +2488,10 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_StringSorter217(Editor _owner ) + public Xcls_StringSorter38(Editor _owner ) { _this = _owner; - var child_1 = new Xcls_PropertyExpression224( _this ); + var child_1 = new Xcls_PropertyExpression39( _this ); child_1.ref(); this.el = new Gtk.StringSorter( child_1.el ); @@ -2104,7 +2502,7 @@ public class Editor : Object // user defined functions } - public class Xcls_PropertyExpression224 : Object + public class Xcls_PropertyExpression39 : Object { public Gtk.PropertyExpression el; private Editor _this; @@ -2113,7 +2511,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_PropertyExpression224(Editor _owner ) + public Xcls_PropertyExpression39(Editor _owner ) { _this = _owner; this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" ); @@ -2130,7 +2528,7 @@ public class Editor : Object - public class Xcls_GestureClick34 : Object + public class Xcls_GestureClick40 : Object { public Gtk.GestureClick el; private Editor _this; @@ -2139,7 +2537,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_GestureClick34(Editor _owner ) + public Xcls_GestureClick40(Editor _owner ) { _this = _owner; this.el = new Gtk.GestureClick(); @@ -2151,13 +2549,15 @@ public class Editor : Object //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("symbol"); if (sym == null) { return; } @@ -2172,8 +2572,15 @@ public class Editor : Object "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); }); } @@ -2184,4 +2591,5 @@ public class Editor : Object + }