Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

horizontal layout without boxes #23

Open
nkh opened this issue Feb 28, 2023 · 10 comments
Open

horizontal layout without boxes #23

nkh opened this issue Feb 28, 2023 · 10 comments

Comments

@nkh
Copy link

nkh commented Feb 28, 2023

Any chance to have a --style none which would not add boxes? even on a 200 characters wide terminal it's difficult to print anything that more than a few elements wide

@yzhong52
Copy link
Owner

yzhong52 commented Mar 1, 2023

Is this what you are thinking about?

     Root Node  
    ╭────┴─────╮
  Child      Child  
   (1)        (2)   

@nkh
Copy link
Author

nkh commented Mar 1, 2023

yes, a tree but without boxes

@yzhong52
Copy link
Owner

yzhong52 commented Mar 2, 2023

So what we need to change is this file:

https://github.com/yzhong52/ascii_tree/blob/main/src/tree/vertical.rs#L144

Either pass in another variable:

pub fn render(&self, style: &BoxDrawings, boxless: bool) -> String {

or make BoxDrawings Optional:

pub fn render(&self, style: Optinal<BoxDrawings>) -> String {

And based on that, change some measuring code such as:

https://github.com/yzhong52/ascii_tree/blob/main/src/tree/vertical.rs#L62


On top of that, if you looking to minimize horizontal space, there is this constant that is set to 2, meaning the space between children is two white spaces. We can make that a argument for the CLI as well --spacing=0 will make the output chart very tight.

https://github.com/yzhong52/ascii_tree/blob/main/src/tree/vertical.rs#L8


Would you be interested in giving those a try?

@nkh
Copy link
Author

nkh commented Mar 2, 2023

No, I'm not interested ... but the reason is that I don't program in rust (yet) :)

I'm working on https://github.com/nkh/P5-App-Asciio where I'm planning to list a set of utilities that can be use to generate elements. There are plenty utilities generating vertical layout but few generating horizontal layout.

Here you can see why the larger ooutput is not very usable for more than a handful of nodes.

screenshot_2023-03-02_15-00-26

@yzhong52
Copy link
Owner

yzhong52 commented Mar 2, 2023

Cool, thanks for sharing the motivations :)

I can work on that. But it won't fully solve your problem though.

With you example, it will only save 10 chars (|), and that won't be enough to draw the entire tree. I can add another option to wrap text automatically maybe.

Could you c/p me your input? I can use that for testing later.

@nkh
Copy link
Author

nkh commented Mar 2, 2023

true it won't save much in this example (https://github.com/nkh/P5-App-Asciio/blob/master/README.md) but people can tweak their input, and having the boxes or not is a good option.

it would be interesting to look at other algorithms that pack the horizontal tree better by using free space (nothing under 'interface' and 'Exporting to ASCII) https://cs.brown.edu/people/rtamassi/gdhandbook/chapters/trees.pdf, http://llimllib.github.io/pymag-trees/ and a million other ...

I did notice that GUI, TUI, SYNOPSIS, DESCRIPTION are not part of the tree, IE: level one entries are not under a virtual root which makes the graph ... vertical too

@yzhong52
Copy link
Owner

yzhong52 commented Mar 3, 2023

true it won't save much in this example (https://github.com/nkh/P5-App-Asciio/blob/master/README.md) but people can tweak their input, and having the boxes or not is a good option.

Oh, I didn't realize that it is from the readme lol.

it would be interesting to look at other algorithms that pack the horizontal tree better by using free space (nothing under 'interface' and 'Exporting to ASCII) https://cs.brown.edu/people/rtamassi/gdhandbook/chapters/trees.pdf, http://llimllib.github.io/pymag-trees/ and a million other ...

Yep, absolutely. There are certainly more ways to compact this :)

I did notice that GUI, TUI, SYNOPSIS, DESCRIPTION are not part of the tree, IE: level one entries are not under a virtual root which makes the graph ... vertical too

Yep, for vertical - it is using a dot for root. For horizontal, I don't really want to create an artificial root.

@yzhong52
Copy link
Owner

yzhong52 commented Mar 3, 2023

This is what I have for now. With your input, the width of the output is 169 chars.

cargo run -- vertical --input examples/readme.md --width 10

Screen Shot 2023-03-02 at 9 05 07 PM

Edit: #24

@yzhong52
Copy link
Owner

yzhong52 commented Mar 3, 2023

I also removed the horizontal spacing, since that's trivial to do:

cargo run -- vertical --input examples/readme.md --width 10 --spacing 0

Screen Shot 2023-03-02 at 9 31 44 PM

That makes it 149 chars.

Edit: #25

@nkh
Copy link
Author

nkh commented Mar 3, 2023

great, 20 chars is already a lot. removing the bozes should remove another 40 chars, so a total of around 30%

@github-staff github-staff deleted a comment from vishalgupta1987 Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants