Auto ellipsize top bar text when it overflows

This commit is contained in:
Kovid Goyal 2015-10-21 08:13:42 +05:30
parent 5a124d8bf1
commit 038630f669

View File

@ -23,15 +23,15 @@ class TopBar:
for bid in self.dummy_bar_id, self.bar_id: for bid in self.dummy_bar_id, self.bar_id:
bar = E.div( bar = E.div(
id=bid, class_='top-bar', id=bid, class_='top-bar',
E.div(style="display:table-cell; padding-left: 0.5em"), E.div(style="white-space:nowrap; overflow:hidden; text-overflow: ellipsis; padding-left: 0.5em;"),
E.div(style="display:table-cell; text-align:right; padding-right: 0.5em") E.div(style="white-space:nowrap; text-align:right; padding-right: 0.5em;")
) )
if bid == self.bar_id: if bid == self.bar_id:
set_css(bar, position='fixed', left='0', top='0') set_css(bar, position='fixed', left='0', top='0')
bar.appendChild(E.style(style, type='text/css')) bar.appendChild(E.style(style, type='text/css'))
set_css(bar, set_css(bar,
width='100%', display='table', font_size=get_font_size('title'), width='100%', display='flex', flex_direction='row', flex_wrap='wrap', justify_content='space-between',
padding_top='0.5ex', padding_bottom='0.5ex', user_select='none', font_size=get_font_size('title'), padding_top='0.5ex', padding_bottom='0.5ex', user_select='none',
color=get_color('bar-foreground'), background_color=get_color('bar-background') color=get_color('bar-foreground'), background_color=get_color('bar-background')
) )
document.body.appendChild(bar) document.body.appendChild(bar)
@ -58,7 +58,7 @@ class TopBar:
E.i(class_='fa fa-' + icon_name) E.i(class_='fa fa-' + icon_name)
)) ))
a = left.firstChild a = left.firstChild
left.appendChild(E.span(title, style=str.format('margin-left: {}; font-weight: bold; text-overflow:ellipsis; overflow: hidden', self.SPACING))) left.appendChild(E.span(title, style=str.format('margin-left: {}; font-weight: bold;', self.SPACING)))
if bar is self.bar: if bar is self.bar:
if icon_name == 'heart': if icon_name == 'heart':
set_css(a, set_css(a,