Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Center/Right Alignment #26

Open
Lindenk opened this issue Oct 3, 2014 · 3 comments
Open

Center/Right Alignment #26

Lindenk opened this issue Oct 3, 2014 · 3 comments

Comments

@Lindenk
Copy link

Lindenk commented Oct 3, 2014

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.

@johan-bjareholt
Copy link

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

@srkuberski
Copy link

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.

@jpentland
Copy link

jpentland commented Mar 2, 2023

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 :(

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants