tiny icon indicating copy to clipboard operation
tiny copied to clipboard

Reloading config does not affect layout

Open trevarj opened this issue 4 years ago • 5 comments

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.

trevarj avatar May 05 '21 08:05 trevarj

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.

osa1 avatar May 05 '21 09:05 osa1

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... 😞

trevarj avatar May 05 '21 09:05 trevarj

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?

osa1 avatar May 05 '21 10:05 osa1

@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 avatar May 07 '21 05:05 trevarj

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 avatar May 07 '21 05:05 trevarj