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 using the context menu:
- Categorized - the original view used by Geany - Uncategorized - view with a single root element "Symbols" in which all symbols are rooted and all of them either sorted by line number or alphabetically
<img width="294" alt="Screen Shot 2022-04-17 at 16 17 38" src="https://user-images.githubusercontent.com/713965/163718570-0beb2998-c646-48b...;
<img width="286" alt="Screen Shot 2022-04-17 at 16 18 33" src="https://user-images.githubusercontent.com/713965/163718574-84ba4857-7674-40a...;
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. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3172
-- Commit Summary --
* Add option to show symbols in symbol tree without root groups
-- File Changes --
M src/document.c (1) M src/documentprivate.h (2) M src/keyfile.c (2) M src/symbols.c (54) M src/tagmanager/tm_parser.c (26) M src/ui_utils.h (1)
-- Patch Links --
https://github.com/geany/geany/pull/3172.patch https://github.com/geany/geany/pull/3172.diff