LemonBoy / bar

A featherweight, lemon-scented, bar based on xcb
MIT License
1.61k stars 194 forks source link

Offset doesn't seem to honor alignment direction #224

Closed domsson closed 3 years ago

domsson commented 4 years ago

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:

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
domsson commented 4 years ago

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

LemonBoy commented 3 years ago

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