noctuid / zscroll

A text scroller for panels or terminals
GNU General Public License v3.0
198 stars 10 forks source link

Support formatting #14

Open Br31zh opened 3 years ago

Br31zh commented 3 years ago

I made a custom bash script that do a sort of scrolling, and I’m trying to replace it by your program (because of some limitations, like fullwidth characters).

But I got another problem, my custom script was able to manage formatting. In case of MPD, the artist name was bold, so the output look like this (for a 10-wide scrolling):

<b>Eric Prydz</b>
<b>ric Prydz</b> 
<b>ic Prydz</b> P
<b>c Prydz</b> Pj
<b> Prydz</b> Pja
<b>Prydz</b> Pjan
<b>rydz</b> Pjano
<b>ydz</b> Pjanoo
<b>dz</b> Pjanoo 
<b>z</b> Pjanoo (
 Pjanoo (C
Pjanoo (Cl
janoo (Clu
anoo (Club
[…]

So the <b></b> weren’t counted in the total length, and removed when not necessary.

I have no idea on how something similar can be implemented in you program (and generic, not only <> tags). It’s probably easy to ignore a substring in the count, but it’s harder to decide when adding or removing tags from the final string… but I think it can be a really cool enhancement.

(The way I’m doing it in Bash is… terrible.)

noctuid commented 3 years ago

Where are you printing text that supports formatting? Is this some panel? It would potentially be possible to support a specific format by changing the visual_len and make_visual_len, but I can't think of a way to support generic formatting... Maybe a regexp to strip out formatting (if a regexp is good enough to handle the formatting)?

Br31zh commented 3 years ago

In i3blocks. It support pango formatting, so I’m using it.