Subject: bug#37667: 27.0.50; Tab Bar display problems with more than 5 tabs

From: Eli Zaretskii <[email-masked]>
Date: Wed, 16 Oct 2019 19:51:29 +0300

> From: Juri Linkov <[email-masked]>
> Cc: [email-masked]
> Date: Wed, 16 Oct 2019 01:39:39 +0300
> 
> I've started with implementing hscrolling for window tab-line
> because this is needed for both graphical displays and TTY.

Thanks.

> But the first question popped up quickly: I don't understand
> how to detect the situation where the tab-line is truncated?

The situation that it's truncated, or the situation that it _needs_ to
be truncated, i.e. the next tab doesn't fit on the line?

If the former, the glyph_row->truncated_on_right_p flag should be set.
You can see it being set in display_string, which is called from
display_mode_line.

If you mean the latter, then look how the truncated_on_right_p flag is
being set in display_line or in other similar display functions, like
display_tab_bar_line.

> And how to find the tab that is visible partially?
> Especially when the font is variable-pitch.

I think you will need to walk the glyphs in the tab-line looking for
the last glyph whose character position has the property you put on
tabs in tab-line (as specified in by tab-line-format).  Or maybe
tab-line-format should put some special property on the last glyph of
a tab, so that you could look for it more easily?

Let me know if the above is not detailed enough to get you off the
ground.

> What I'm trying to do is to hide leftmost tabs one by one until
> the current tab on the rightmost side becomes completely visible.

That will work, but it's inefficient.  Once you know the number N of
pixels are needed to show the tab you want to unhide, just walk the
glyphs of the tabs from the left edge until you find the first tab
whose horizontal position M is greater or equal to N.  then set
it->first_visible_x to that number M and display the tab line.

HTH