presenterm icon indicating copy to clipboard operation
presenterm copied to clipboard

[Feature Request] Inline pauses.

Open peterc-s opened this issue 6 months ago • 6 comments

Wouldn't it be nice to pause...<!--pause--> inline?

From what I saw when looking if it was a quick fix or not, this would require adding some extra stuff to the HTML parser to pick up on comments and add a pause without breaking the line. My fork's main branch has parsing stuff for pauses inline but it adds a couple of line breaks so I assume there's some extra stuff that would need to be done, but I don't have much time to do that right now.

peterc-s avatar May 24 '25 23:05 peterc-s

I think this would be nice but yeah, it will require some more work. The way pauses affect the presentation in builder purposely add new lines as it is now so that'd have to change.

mfontanini avatar May 25 '25 21:05 mfontanini

FYI I started working on this based on your code. This is going to be a bit hacky and there's a few corner cases but it should be doable.

mfontanini avatar May 28 '25 23:05 mfontanini

FYI I started working on this based on your code. This is going to be a bit hacky and there's a few corner cases but it should be doable.

Oh cool, thank you! I was going to give it a shot at some point. I was thinking maybe refactoring lines so they are made up of elements and that could include pauses or even inline typst or latex (though that might be painful to implement). But I haven't gotten around to properly reading through all the parsing and building code yet as I've been quite busy.

peterc-s avatar May 29 '25 19:05 peterc-s

Yeah I think that would be the best way to do it actually, a paragraph should contain a list of an enum like Text | Pause to be able to pause without all the newlines that pop up.

mfontanini avatar May 29 '25 23:05 mfontanini

This is a really tedious change unfortunately. I pushed the almost working code into the feat/inline-pauses branch. This creates problems when a line overflows after the pause as it is though, so it's no good.

The main problem is the way RenderText works is the positioning based on the text alignment is computed and then the cursor is moved to its first column. But when there's a pause, the text after the pause is a separate render text operation so it would by default do that ^ and overwrite the previous text. I changed this to start at the current position when there's a pause, but that causes a line that is too long to fit on the screen (which needs truncation) to not know how much text there already is on that line (because the text was previously printed by a separate RenderText) so the newline is printed without any margins, which looks off.

I feel like this needs a too big of a refactor for what it adds :(. I'm sure with enough hacks it would work too but it's making me a bit itchy.

mfontanini avatar Jun 01 '25 21:06 mfontanini

This is a really tedious change unfortunately. I pushed the almost working code into the feat/inline-pauses branch. This creates problems when a line overflows after the pause as it is though, so it's no good.

The main problem is the way RenderText works is the positioning based on the text alignment is computed and then the cursor is moved to its first column. But when there's a pause, the text after the pause is a separate render text operation so it would by default do that ^ and overwrite the previous text. I changed this to start at the current position when there's a pause, but that causes a line that is too long to fit on the screen (which needs truncation) to not know how much text there already is on that line (because the text was previously printed by a separate RenderText) so the newline is printed without any margins, which looks off.

I feel like this needs a too big of a refactor for what it adds :(. I'm sure with enough hacks it would work too but it's making me a bit itchy.

I did think it would be a big change to change but breaking up lines into parts would allow inline typst or latex which might make it worth it as inline maths would be really nice if done right. I had another idea for something, I don't know if it is relevant to this issue or refactor, but something similar to \mintinline from the minted latex package that allows syntax highlighting on inline code blocks.

I think inline maths will also have issues with text alignment. I'll have a look when I have time and see if I can find a path forward.

peterc-s avatar Jun 05 '25 12:06 peterc-s