You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In jonathanj/eliottree#76, a suggestion has been made to color the tree lines. I've tried implementing a hacky solution via Options (on master) without modifying tree_format but it turns out to be quite tricky to guess when to change the colour.
I've tried a couple of modifications and would like some advice on whether any of them seem like things that would fit into this package.
1. Options factory
Instead of format_tree accepting an Options instance, rather accept a function (taking the current tree depth) that returns an Options instance. My factory implementation uses the depth to pick a colour from a smaller set and wraps all line drawing characters in properties that are decorated with that colour.
This keeps the concept of colour outside of this package's knowledge.
2. Introduce a Options.next_color method
Fetches the next colour on each call to _format_tree and wraps all line drawing characters with it.
The problem with this method is that sub-trees of siblings will be different colours, and thus the colours do not form clear columns, maybe this is useful in same cases but in eliottree's case it's more useful to have colours run strictly vertically.
3. Introduce a format_prefix argument
format_node formats the node, format_prefix would format the prefix, likely only accepting input describing the kind of prefix such as fork, last and probably depth.
This actually obviates the need for Options (at least as an argument to format_tree) because format_prefix is wholly in charge of returning the prefix string based on what kind of branch to draw.
This option is also hypothetical because I didn't actually get around to implementing it.
The text was updated successfully, but these errors were encountered:
In jonathanj/eliottree#76, a suggestion has been made to color the tree lines. I've tried implementing a hacky solution via
Options
(on master) without modifyingtree_format
but it turns out to be quite tricky to guess when to change the colour.I've tried a couple of modifications and would like some advice on whether any of them seem like things that would fit into this package.
1. Options factory
Instead of
format_tree
accepting anOptions
instance, rather accept a function (taking the current tree depth) that returns anOptions
instance. My factory implementation uses the depth to pick a colour from a smaller set and wraps all line drawing characters in properties that are decorated with that colour.This keeps the concept of colour outside of this package's knowledge.
2. Introduce a
Options.next_color
methodFetches the next colour on each call to
_format_tree
and wraps all line drawing characters with it.The problem with this method is that sub-trees of siblings will be different colours, and thus the colours do not form clear columns, maybe this is useful in same cases but in eliottree's case it's more useful to have colours run strictly vertically.
3. Introduce a
format_prefix
argumentformat_node
formats the node,format_prefix
would format the prefix, likely only accepting input describing the kind of prefix such asfork
,last
and probablydepth
.This actually obviates the need for
Options
(at least as an argument toformat_tree
) becauseformat_prefix
is wholly in charge of returning the prefix string based on what kind of branch to draw.This option is also hypothetical because I didn't actually get around to implementing it.
The text was updated successfully, but these errors were encountered: