Add option to show symbols in symbol tree without root groups
commit6809d3a8eabbe6b3ffe362c80cbbf29280e02bf7
authorJiří Techet <techet@gmail.com>
Sun, 17 Apr 2022 12:44:07 +0000 (17 14:44 +0200)
committerJiří Techet <techet@gmail.com>
Tue, 13 Sep 2022 22:22:23 +0000 (14 00:22 +0200)
tree960ee14893ea390a3d77b0f3a069ab793784a889
parentdf27d1b226bd7261be5482b06d3a69123ff0c514
Add option to show symbols in symbol tree without root groups

While the current way of grouping symbols under various categories
like "Functions", "Structures", "Macros" etc. may be useful in some
situations, it doesn't allow true sorting by name or sorting by line
number because this sorting is only valid within the group and not
globally which makes it sometimes hard to find some symbol.

This patch adds the option to switch between two views of the symbol tree
by using a new checkbox called "Group by Type" to the context menu:

- checked - the original view used by Geany
- unchecked - view with a single root element "Symbols" in which
  all symbols are rooted and all of them either sorted by line number
  or alphabetically

The core of the implementation is rather simple - there's always the
"Symbols" root present at position 0 in tv_iters and when categorized
view is selected, this root is used for all the tags. (We still need
to keep the category roots in this situation to copy the icons for
the tags from them but they are always empty and hidden).

The rest is some UI stuff for creating entries in the context menu, I also
added a config preference so this settings is remembered across Geany
re-launches. I made this option global for all open files because
I would find it annoying to apply this setting manually for every open
file. So the code also checks whether the view type changed for the
given file when switching tabs and re-creates the tree with the new
setting.
doc/geany.txt
src/document.c
src/documentprivate.h
src/keyfile.c
src/symbols.c
src/tagmanager/tm_parser.c
src/ui_utils.h