dzen
dzen copied to clipboard
Center/Right Alignment
Currently, if the tags ^p(_LEFT)
, ^p(_CENTER)
or ^p(_RIGHT)
are used, only the cursor is moved. This causes all following text to be drawn after the cursor rather than it being centered or right justified.
If this is intended functionality, then I would like to suggest adding a center and right-justify tag.
As i see it in the source code, there is a command named ^ba which does exactly this but i can't get it to work. It calls the function "get_block_align_vals" and sets alignment, but every time i use it my text goes out of the draw area even though i use ^ba(0,_LEFT/_CENTER/_RIGHT)
Alignment is still possible as long as you know the font width by using "^pa( $(( $WIDTH - $(( ${#TEXT} * $FONTWIDTH)) )) )" with sh though, but it isn't very practical and gets messed up when having other commands inside. Would be nice to see ^ba working
Left/right/center alignment is possible with the already mentioned (undocumented) ba
tag. E.g., ^ba(300,_RIGHT)TEXT
prints right-aligned TEXT for a 300-pixel window width. Window width can be controlled by the -w
(or -tw
) command line parameter.
So after playing around a bit I found an option that -seems to be working- for showing text on both the left and the right side, without it rendering off-screen.
This naive approach does not work (assuming 1080p resolution):
^ba(1920,_LEFT)Left Text^ba(1920,_RIGHT)Right Text
The issue here is that the left text "pushes" the right text over too far to the right. The more text is on the left the more the right text will be cut off.
Flipping left and right around however seems to work:
^ba(1920,_RIGHT)Right Text^ba(1920, _LEFT)Left Text
Now the right text is drawn first, so it doesn't get "pushed" off the edge. This is most likely a bug in how the offsets are calculated in the case of right aligned text, by assuming there is no left-aligned text to deal with.
edit: Well scratch that, now it doesn't work either. I swear it was working earlier.
edit2: This actually works:
^ba(1920,_RIGHT)Right Text^ba(1920, _LEFT)^pa(_LEFT)Left Text
edit3: Actually, as soon as you add any other directives, this stops working too:
^ba(1920,_RIGHT)Right Text^ba(1920, _LEFT)^pa(_LEFT)Left Text
Works
^ba(1920,_RIGHT)^fg(#222222)Right Text^fg()^ba(1920, _LEFT)^pa(_LEFT)Left Text
Does not work :(