LemonBoy/bar

Offset doesn't seem to honor alignment direction

domsson opened this issue · 2 comments

We can offset text via the O format option. The documentation says:

Owidth
Offset the current position by width pixels in the alignment direction.

I'm not quite sure what this would mean for centered text, but for left and right aligned text, I expected the offset would happen on opposite sides, respectively (either offset the left aligned text to the left and the right aligned text to the right, or vice versa).

However, this does not seem to be the case. Consider this simple example:

echo "%{l O8}LEFT%{c O8}CENTER%{r O8}RIGHT" | lemonbar -p

The result is as follows (magnified by a factor of 2 so it is easier to inspect):

lemonbar offset issue

I colored the left and right half of the background so it becomes easy to inspect the centered text:

lemonbar offset issue, colored

We can see that:

  • the left aligned text is offset 8 pixels to the right
  • the center aligned text is offset 7 pixels to the right
  • the right aligned text is apparently not offset at all

How can this be explained?

  1. I'm reading the documentation wrong
  2. I'm not using the format options correctly
  3. This is a bug

I was playing with this some more and suspect that 1. and 2. apply. In other words, I now believe I'm not using the format options correctly because I didn't understand the documentation correctly.

From what I can tell, O doesn't work like B, F or T , in that it doesn't affect the text that follows, but instead it simply adds empty space of the given amount in the exact spot you place it.

Example:

echo "%{l O8}LEFT%{O8}%{c O8}CENTER%{O8}%{r O8}RIGHT%{O8}" | lemonbar -p

Or simpler:

echo "%{l O8}LEFT%{c}CENTER%{r}RIGHT%{O8}" | lemonbar -p

lemonbar with offsets

Yes, the oN is handled as if a character of width N was drawn.