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

Reloading config does not affect layout #321

Open
trevarj opened this issue May 5, 2021 · 5 comments
Open

Reloading config does not affect layout #321

trevarj opened this issue May 5, 2021 · 5 comments

Comments

@trevarj
Copy link
Contributor

trevarj commented May 5, 2021

If you change the msg area layout in your config (e.g layout: aligned ) and use the command /reload it will not change the layout until restarting Tiny.

This can either be removed or fixed. Fixing may help solve #318, which will need the ability to toggle the layout based on window width.

@osa1
Copy link
Owner

osa1 commented May 5, 2021

If we fix #318 first then fixing this should be a few lines of code for calling the code added in #318 after a /reload.

@trevarj
Copy link
Contributor Author

trevarj commented May 5, 2021

Quickly tried to hack this together, and realized that for alignment we pad the lines so that they actually contain whitespace. Toggling the config to compact will take effect for new messages but won't redraw ones that already came... 😞

@osa1
Copy link
Owner

osa1 commented May 5, 2021

Hm, it seems like we may need to remove those whitespace in lines, yes. I know I should've asked this in the aligned layout PR, but couldn't we use the old Line implementation without much changes, by tweaking where we draw the lines? For example, if a tab looks like this in "compact" layout:

|osa1: blah blah|
|blah blah blah |

IIRC in the old implementation, when rendering the line for "blah blah ...", we start rendering from column 6, and the follow-up lines can continue from column 0.

We use the same idea, except we start rendering from column 0, but move the line to column 6. That should automatically give us this rendering:

|osa1: blah blah|
|      blah blah|
|      blah     |

In other words, we change where we start drawing Lines, but we don't change how a Line is drawn.

Am I missing anything?

@trevarj
Copy link
Contributor Author

trevarj commented May 7, 2021

@osa1, Just checked and the whitespace only affects the nick (being padded for right alignment). The line wrapping actually does not draw whitespace, but decides where to draw, as you described. I will put up a PR to fix that

@trevarj
Copy link
Contributor Author

trevarj commented May 7, 2021

More info:
I think the reasoning behind why I decided to add the whitespace padding in timestamp and nick is because of the way we don't distinguish the type of segment when drawing a line. It all turns into chars and just gets iterated over.
I had another look at what it would take to add the padding later during line height calculation and drawing and it would probably be just as complicated but give us the ability to switch layouts on the fly...

trevarj added a commit to trevarj/tiny that referenced this issue May 8, 2021
Instead of applying padding to the actual data in the line buffers, this
applies the correct padding on the fly during line height calculation
and drawing.

Not a very good solution since I did this in order to be able to switch
layouts on the fly (osa1#321) but it still doesn't work because we don't always
align every line (i.e topic line, server stuff).
trevarj added a commit to trevarj/tiny that referenced this issue Aug 29, 2021
* Message alignment on draw

Instead of applying padding to the actual data in the line buffers, this
applies the correct padding on the fly during line height calculation
and drawing.

Not a very good solution since I did this in order to be able to switch
layouts on the fly (osa1#321) but it still doesn't work because we don't always
align every line (i.e topic line, server stuff).

* Change alignment on the fly after reloading from config

* Fixed unit test
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

Successfully merging a pull request may close this issue.

2 participants