From: Alan Knowles Date: Sat, 23 Mar 2024 08:43:01 +0000 (+0800) Subject: Fix #8106 - tidy up color higlighting on nav tree X-Git-Url: http://git.roojs.org/?p=roobuilder;a=commitdiff_plain;h=36c7c3bd492414b11eca1937f5c41b0d1274cfe5 Fix #8106 - tidy up color higlighting on nav tree --- diff --git a/resources/css/roobuilder.css b/resources/css/roobuilder.css index 8927bdd0f..c70776fa7 100644 --- a/resources/css/roobuilder.css +++ b/resources/css/roobuilder.css @@ -40,9 +40,15 @@ border-bottom-color: #EEA9FF; } -#left-tree-view indent { - -gtk-icon-size : 2px; + +#left-tree-view indent, +#left-tree-view expander +{ + -gtk-icon-size : 4px; + min-width: 4px; } + + #left-tree-view indent:nth-last-child(2) { min-width: 24px; } @@ -95,8 +101,11 @@ } -#editor-navigation indent { - -gtk-icon-size : 2px; +#editor-navigation indent, +#editor-navigation expander +{ + -gtk-icon-size : 10px; + min-width: 10px; } #editor-navigation { font-size: 12px; @@ -109,38 +118,46 @@ #editor-navigation .selected-row { background-color:#88a3bc; } - -.lang-class-symbolic { - color : #266b02; +/** + language symbols? +*/ +.lang-class-symbolic , +.lang-constructor-symbolic { font-weight: bold; } -.lang-method-symbolic, -.lang-function-symbolic { +.lang-method-symbolic { color : #029f2b; font-weight: bold; } -.lang-struct-field-symbolic { +.lang-property-symbolic, +.lang-field-symbolic { color : #1111ff; } +.lang-enummember-symbolic { + color : #666; +} tooltip { - padding: 2px; + padding: 1px; margin: 0px 0px 0px 0px; border-width: 1px; border-style: solid; border-radius: 2px; border-color: #eee; background-image: none; - background-color: #eee; + background-color: #fff; color: #000; - border: 0px; + border-bottom: 4px solid #ccc; + border-right: 4px solid #aaa; + border-top: 4px solid #eee; + border-left: 4px solid #ddd; } tooltip * { - background-color: #eee; - padding: 5px 5px 5px 5px; + background-color: #fff; + padding: 3px 3px 3px 3px; margin: 0px 0px 0px 0px; border-width: 1px; color: #000; diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs index af1b6bc81..ebadf15db 100644 --- a/src/Builder4/Editor.bjs +++ b/src/Builder4/Editor.bjs @@ -935,422 +935,482 @@ { "$ xns" : "Gtk", "* prop" : "end_child", - "bool visible" : false, - "id" : "navigationwindow", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", + "bool hexpand" : true, + "bool vexpand" : true, + "int spacing" : 0, "items" : [ { - "# int last_selected_line" : "-1", - "$ Gtk.Widget? selected_row" : "null", "$ xns" : "Gtk", - "* prop" : "child", - "id" : "navigation", + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", + "int spacing" : 0, + "xtype" : "Box" + }, + { + "$ xns" : "Gtk", + "bool hexpand" : true, + "bool vexpand" : true, + "bool visible" : false, + "id" : "navigationwindow", "items" : [ { + "# int last_selected_line" : "-1", + "$ Gtk.Widget? selected_row" : "null", "$ xns" : "Gtk", - "bool expand" : true, + "* prop" : "child", + "id" : "navigation", "items" : [ { "$ xns" : "Gtk", - "* prop" : "factory", - "listeners" : { - "bind" : [ - "(listitem) => {", - "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());", - "\t", - "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", - "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", - "\t ", - "\t ", - "\tvar hbox = (Gtk.Box) expand.child;", - " ", - "\t", - "\tvar img = (Gtk.Image) hbox.get_first_child();", - "\tvar lbl = (Gtk.Label) img.get_next_sibling();", - "\t", - "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", - "\tvar sym = (Lsp.DocumentSymbol) lr.get_item();", - "\t", - "\tsym.set_data(\"widget\", expand.get_parent());", - "\texpand.get_parent().get_parent().set_data(\"symbol\", sym);", - "\t", - "\t//GLib.debug(\"save sym on %s\", expand.get_parent().get_parent().get_type().name());", - "\t", - "\t//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);", - " \texpand.set_list_row(lr);", - " \t", - " \tsym.bind_property(\"symbol_icon\",", - " img, \"icon_name\",", - " GLib.BindingFlags.SYNC_CREATE);", - " \t", - " \thbox.add_css_class(sym.symbol_icon);", - " \t", - " \tsym.bind_property(\"name\",", - " lbl, \"label\",", - " GLib.BindingFlags.SYNC_CREATE);", - " \t// should be better?- --line no?", - " \tsym.bind_property(\"tooltip\",", - " lbl, \"tooltip_markup\",", - " GLib.BindingFlags.SYNC_CREATE);", - " \t// bind image...", - " \t", - "}", - "" - ], - "setup" : [ - "(listitem) => {", - "\t", - "\tvar expand = new Gtk.TreeExpander();", - "\t ", - "\texpand.set_indent_for_depth(true);", - "\texpand.set_indent_for_icon(true);", - "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);", - "\tvar icon = new Gtk.Image();", - "\tvar lbl = new Gtk.Label(\"\");", - "\tlbl.use_markup = true;", - "\tlbl.ellipsize = Pango.EllipsizeMode.END;", - "\t", - "\ticon.margin_end = 4;", - " \tlbl.justify = Gtk.Justification.LEFT;", - " \tlbl.xalign = 0;", - "", - "//\tlistitem.activatable = true; ??", - "\t", - "\thbox.append(icon);", - "\thbox.append(lbl);", - "\texpand.set_child(hbox);", - "\t((Gtk.ListItem)listitem).set_child(expand);", - "\t", - "}", - "" - ] - }, - "xtype" : "SignalListItemFactory" - } - ], - "string title" : "Code Navigation", - "xtype" : "ColumnViewColumn" - }, - { - "$ xns" : "Gtk", - "* prop" : "model", - "id" : "navigationselmodel", - "items" : [ + "bool expand" : true, + "items" : [ + { + "$ xns" : "Gtk", + "* prop" : "factory", + "listeners" : { + "bind" : [ + "(listitem) => {", + "\t ", + "\t// GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());", + "\t", + "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", + "\tvar expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();", + "\t ", + "\t ", + "\tvar hbox = (Gtk.Box) expand.child;", + " ", + "\t", + "\tvar img = (Gtk.Image) hbox.get_first_child();", + "\tvar lbl = (Gtk.Label) img.get_next_sibling();", + "\t", + "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();", + "\tvar sym = (Lsp.DocumentSymbol) lr.get_item();", + "\t", + "\tsym.set_data(\"widget\", expand.get_parent());", + "\texpand.get_parent().get_parent().set_data(\"symbol\", sym);", + "\t", + "\t//GLib.debug(\"save sym on %s\", expand.get_parent().get_parent().get_type().name());", + "\t", + "\t//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);", + " \texpand.set_list_row(lr);", + " \t//this.in_bind = true;", + " \t// default is to expand", + " ", + " \t//this.in_bind = false;", + " \t", + " \tsym.bind_property(\"symbol_icon\",", + " img, \"icon_name\",", + " GLib.BindingFlags.SYNC_CREATE);", + " \t", + " \thbox.css_classes = { sym.symbol_icon };", + " \t", + " \tsym.bind_property(\"name\",", + " lbl, \"label\",", + " GLib.BindingFlags.SYNC_CREATE);", + " \t// should be better?- --line no?", + " \tsym.bind_property(\"tooltip\",", + " lbl, \"tooltip_markup\",", + " GLib.BindingFlags.SYNC_CREATE);", + " \t// bind image...", + " \t", + "}", + "" + ], + "setup" : [ + "(listitem) => {", + "\t", + "\tvar expand = new Gtk.TreeExpander();", + "\t ", + "\texpand.set_indent_for_depth(true);", + "\texpand.set_indent_for_icon(true);", + "\tvar hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);", + "\tvar icon = new Gtk.Image();", + "\tvar lbl = new Gtk.Label(\"\");", + "\tlbl.use_markup = true;", + "\tlbl.ellipsize = Pango.EllipsizeMode.END;", + "\t", + "\ticon.margin_end = 4;", + " \tlbl.justify = Gtk.Justification.LEFT;", + " \tlbl.xalign = 0;", + "", + "//\tlistitem.activatable = true; ??", + "\t", + "\thbox.append(icon);", + "\thbox.append(lbl);", + "\texpand.set_child(hbox);", + "\t((Gtk.ListItem)listitem).set_child(expand);", + "\t", + "}", + "" + ] + }, + "xtype" : "SignalListItemFactory" + } + ], + "string title" : "Code Navigation", + "xtype" : "ColumnViewColumn" + }, { "$ xns" : "Gtk", "* prop" : "model", - "id" : "navigationsort", + "id" : "navigationselmodel", "items" : [ { - "$ Gtk.TreeListModelCreateModelFunc create_func" : [ - "(item) => {", - " ", - "\treturn ((Lsp.DocumentSymbol)item).children;", - "}", - "" - ], "$ xns" : "Gtk", "* prop" : "model", - "bool autoexpand" : true, - "bool passthrough" : false, + "id" : "navigationsort", "items" : [ { - "$ GLib.Type item_type" : "typeof(Lsp.DocumentSymbol)", - "$ xns" : "GLib", - "* prop" : "root", - "id" : "navliststore", - "xtype" : "ListStore", - "| Lsp.DocumentSymbol? symbolAtLine" : [ - "(uint line, uint chr) {", + "$ Gtk.TreeListModelCreateModelFunc create_func" : [ + "(item) => {", " ", - "\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" - }, - { - "$ xns" : "Gtk", - "* prop" : "sorter", - "items" : [ + "\treturn ((Lsp.DocumentSymbol)item).children;", + "}", + "" + ], + "$ xns" : "Gtk", + "* prop" : "model", + "bool autoexpand" : true, + "bool passthrough" : false, + "items" : [ + { + "$ GLib.Type item_type" : "typeof(Lsp.DocumentSymbol)", + "$ xns" : "GLib", + "* prop" : "root", + "id" : "navliststore", + "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;", + "}" + ] + } + ], + "listeners" : { + "items_changed" : [ + "(position, removed, added) => {", + "\tGLib.debug(\"tree item changed %d , %d , %d\",(int) position, (int)removed, (int) added);", + "\t if (added < 1) { ", + "\t \treturn;", + " \t}", + "\t//var sym = (Lsp.DocumentSymbol) this.el.get_item(position);", + "\tvar row = this.el.get_row(position);", + "\t", + "\tGLib.debug(\"got %s\", row.get_item().get_type().name());", + "\t", + "", + "}", + "" + ] + }, + "xtype" : "TreeListModel" + }, { "$ xns" : "Gtk", "* prop" : "sorter", "items" : [ { - "$ GLib.Type this_type" : "typeof(Lsp.DocumentSymbol)", "$ xns" : "Gtk", - "* prop" : "expression", - "string property_name" : "sort_key", - "xtype" : "PropertyExpression" + "* prop" : "sorter", + "items" : [ + { + "$ GLib.Type this_type" : "typeof(Lsp.DocumentSymbol)", + "$ xns" : "Gtk", + "* prop" : "expression", + "string property_name" : "sort_key", + "xtype" : "PropertyExpression" + } + ], + "xtype" : "StringSorter" } ], - "xtype" : "StringSorter" + "xtype" : "TreeListRowSorter" } ], - "xtype" : "TreeListRowSorter" + "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;", + "}" + ], + "| void collapseOnLoad" : [ + "() {", + "\tfor (var i=0;i < this.el.get_n_items(); i++) {", + "\t\tvar tr = (Gtk.TreeListRow)this.el.get_item(i);", + "\t\tvar sym = (Lsp.DocumentSymbol)tr.get_item();", + "\t\tswitch (sym.kind) {", + "\t \t\tcase Lsp.SymbolKind.Enum: ", + "\t \t\t\ttr.expanded = false;", + "\t \t\t\tbreak;", + "\t\t\tdefault:", + "\t\t\t\t//tr.expanded = true;", + "\t\t\t\tbreak;", + "\t\t}", + "\t}", + " ", + "\t", + "", + "", + "}" + ] } ], - "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" + }, + { + "$ xns" : "Gtk", + "listeners" : { + "pressed" : [ + "(n_press, x, y) => {", + "\tstring pos;", + " \tvar row = _this.navigation.getRowWidgetAt(x,y, out pos );", + "", + " if (row == null) {", + "\t GLib.debug(\"no row selected items\");", + "\t return;", + " }", + "\tGLib.debug(\"got click on %s\", row.get_type().name()); ", + " //Lsp.DocumentSymbol", + " var sym = row.get_data(\"symbol\");", + " if (sym == null) {", + " \treturn;", + "\t}", + "\t/*", + "\t \"range\" : {", + " \"start\" : {", + " \"line\" : 1410,", + " \"character\" : 8", + " },", + " \"end\" : {", + " \"line\" : 1410,", + " \"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, ", + " \t(int)sym.range.start.line,", + " \t(int)sym.range.start.character", + "\t);", + " _this.buffer.el.place_cursor(iter);", + "\t", + "}" + ] + }, + "xtype" : "GestureClick" } ], - "xtype" : "NoSelection" - }, - { - "$ xns" : "Gtk", - "listeners" : { - "pressed" : [ - "(n_press, x, y) => {", - "\tstring pos;", - " \tvar row = _this.navigation.getRowWidgetAt(x,y, out pos );", - "", - " if (row == null) {", - "\t GLib.debug(\"no row selected items\");", - "\t return;", - " }", - "\tGLib.debug(\"got click on %s\", row.get_type().name()); ", - " //Lsp.DocumentSymbol", - " var sym = row.get_data(\"symbol\");", - " if (sym == null) {", - " \treturn;", - "\t}", - "\t/*", - "\t \"range\" : {", - " \"start\" : {", - " \"line\" : 1410,", - " \"character\" : 8", - " },", - " \"end\" : {", - " \"line\" : 1410,", - " \"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, ", - " \t(int)sym.range.start.line,", - " \t(int)sym.range.start.character", - "\t);", - " _this.buffer.el.place_cursor(iter);", - "\t", - "}" - ] - }, - "xtype" : "GestureClick" + "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 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(\"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}", + "", + "", + "}" + ] } ], - "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 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\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(\"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}", - "", - "", - "}" - ] + "xtype" : "ScrolledWindow" } ], - "xtype" : "ScrolledWindow" + "xtype" : "Box" } ], "xtype" : "Paned" diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index d54bc2ad5..742a21214 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -420,8 +420,9 @@ public class Editor : Object 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; + var child_2 = new Xcls_Box27( _this ); + child_2.ref(); + this.el.end_child = child_2.el; } // user defined functions @@ -1748,6 +1749,56 @@ public class Editor : Object + public class Xcls_Box27 : Object + { + public Gtk.Box el; + private Editor _this; + + + // my vars (def) + + // ctor + public Xcls_Box27(Editor _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; + 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; @@ -1766,6 +1817,8 @@ public class Editor : Object // my vars (dec) // set gobject values + this.el.hexpand = true; + this.el.vexpand = true; this.el.visible = false; new Xcls_navigation( _this ); this.el.child = _this.navigation.el; @@ -1797,10 +1850,10 @@ public class Editor : Object // 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_GestureClick38( _this ); + var child_3 = new Xcls_GestureClick40( _this ); child_3.ref(); this.el.add_controller( child_3.el ); } @@ -1860,7 +1913,7 @@ public class Editor : Object //_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); @@ -1962,7 +2015,7 @@ public class Editor : Object } } - public class Xcls_ColumnViewColumn29 : Object + public class Xcls_ColumnViewColumn31 : Object { public Gtk.ColumnViewColumn el; private Editor _this; @@ -1971,10 +2024,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 ); @@ -1986,7 +2039,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; @@ -1995,7 +2048,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(); @@ -2030,6 +2083,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(); @@ -2054,12 +2108,16 @@ public class Editor : Object 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", @@ -2113,9 +2171,9 @@ public class Editor : Object { _this = _owner; _this.navigationsort = this; - var child_1 = new Xcls_TreeListModel33( _this ); + var child_1 = new Xcls_TreeListModel35( _this ); child_1.ref(); - var child_2 = new Xcls_TreeListRowSorter35( _this ); + var child_2 = new Xcls_TreeListRowSorter37( _this ); child_2.ref(); this.el = new Gtk.SortListModel( child_1.el, child_2.el ); @@ -2125,6 +2183,24 @@ 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++) { @@ -2148,7 +2224,7 @@ public class Editor : Object } } - public class Xcls_TreeListModel33 : Object + public class Xcls_TreeListModel35 : Object { public Gtk.TreeListModel el; private Editor _this; @@ -2157,7 +2233,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_TreeListModel33(Editor _owner ) + public Xcls_TreeListModel35(Editor _owner ) { _this = _owner; new Xcls_navliststore( _this ); @@ -2170,6 +2246,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 @@ -2216,7 +2306,7 @@ public class Editor : Object } - public class Xcls_TreeListRowSorter35 : Object + public class Xcls_TreeListRowSorter37 : Object { public Gtk.TreeListRowSorter el; private Editor _this; @@ -2225,10 +2315,10 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_TreeListRowSorter35(Editor _owner ) + public Xcls_TreeListRowSorter37(Editor _owner ) { _this = _owner; - var child_1 = new Xcls_StringSorter36( _this ); + var child_1 = new Xcls_StringSorter38( _this ); child_1.ref(); this.el = new Gtk.TreeListRowSorter( child_1.el ); @@ -2239,7 +2329,7 @@ public class Editor : Object // user defined functions } - public class Xcls_StringSorter36 : Object + public class Xcls_StringSorter38 : Object { public Gtk.StringSorter el; private Editor _this; @@ -2248,10 +2338,10 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_StringSorter36(Editor _owner ) + public Xcls_StringSorter38(Editor _owner ) { _this = _owner; - var child_1 = new Xcls_PropertyExpression37( _this ); + var child_1 = new Xcls_PropertyExpression39( _this ); child_1.ref(); this.el = new Gtk.StringSorter( child_1.el ); @@ -2262,7 +2352,7 @@ public class Editor : Object // user defined functions } - public class Xcls_PropertyExpression37 : Object + public class Xcls_PropertyExpression39 : Object { public Gtk.PropertyExpression el; private Editor _this; @@ -2271,7 +2361,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_PropertyExpression37(Editor _owner ) + public Xcls_PropertyExpression39(Editor _owner ) { _this = _owner; this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" ); @@ -2288,7 +2378,7 @@ public class Editor : Object - public class Xcls_GestureClick38 : Object + public class Xcls_GestureClick40 : Object { public Gtk.GestureClick el; private Editor _this; @@ -2297,7 +2387,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_GestureClick38(Editor _owner ) + public Xcls_GestureClick40(Editor _owner ) { _this = _owner; this.el = new Gtk.GestureClick(); @@ -2351,4 +2441,5 @@ public class Editor : Object + } diff --git a/src/Lsp.vala b/src/Lsp.vala index 21ab644f2..97552c115 100644 --- a/src/Lsp.vala +++ b/src/Lsp.vala @@ -441,7 +441,8 @@ namespace Lsp { owned get { //GLib.debug("%s : %s", this.name, this.detail); //var detail = this.detail == "" ? (this.kind.to_string() + ": " + this.name) : this.detail; - return GLib.Markup.escape_text(this.detail + "\nline: " + this.range.start.line.to_string()); + return "" + this.kind.to_string().replace( "LSP_SYMBOL_KIND_", "" ) + "\n" + + GLib.Markup.escape_text(this.detail + "\nline: " + this.range.start.line.to_string()); } } @@ -567,40 +568,8 @@ namespace Lsp { TypeParameter = 26; public string icon () { - - switch (this) { - - // case SymbolKind.Text: return "completion-snippet-symbolic"; - case SymbolKind.Method: return "lang-method-symbolic"; - case SymbolKind.Function: return "lang-function-symbolic"; - case SymbolKind.Constructor: return "lang-method-symbolic"; - case SymbolKind.Field: return "lang-struct-field-symbolic"; - case SymbolKind.Variable: return "lang-variable-symbolic"; - case SymbolKind.Class: return "lang-class-symbolic"; - case SymbolKind.Interface: return "lang-class-symbolic"; - case SymbolKind.Module: return "lang-namespace-symbolic"; - case SymbolKind.Property:return "lang-struct-field-symbolic"; - //case SymbolKind.Unit: return "lang-variable-symbolic"; - //case SymbolKind.Value: return "lang-variable-symbolic"; - case SymbolKind.Enum: return "lang-enum-symbolic"; - //case SymbolKind.Keyword: return "completion-word-symbolic"; - //case SymbolKind.Snippet: return "completion-snippet-symbolic"; - - //case SymbolKind.Color: return "lang-typedef-symbolic"; - case SymbolKind.File:return "lang-typedef-symbolic"; - //case SymbolKind.Reference: return "lang-typedef-symbolic"; - //case SymbolKind.Folder:return "lang-typedef-symbolic"; - case SymbolKind.EnumMember: return "lang-typedef-symbolic"; - case SymbolKind.Constant:return "lang-typedef-symbolic"; - case SymbolKind.Struct: return "lang-struct-symbolic"; - case SymbolKind.Event:return "lang-typedef-symbolic"; - case SymbolKind.Operator:return "lang-typedef-symbolic"; - case SymbolKind.TypeParameter:return "lang-typedef-symbolic"; - - default: - return "completion-snippet-symbolic"; - - } + return "lang-" + this.to_string().replace( "LSP_SYMBOL_KIND_", "" ).down() + "-symbolic"; + } public int sort_key() {