From 9e10f38d6b55e0ac38db41ef64fbb0e367381784 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Fri, 28 Jan 2022 16:55:09 +0000 Subject: [PATCH] Fixing issues with start and end of bar --- src/textual/renderables/tab_underline.py | 30 ++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/textual/renderables/tab_underline.py b/src/textual/renderables/tab_underline.py index d2fc47838..25de4b893 100644 --- a/src/textual/renderables/tab_underline.py +++ b/src/textual/renderables/tab_underline.py @@ -30,28 +30,19 @@ class UnderlineBar: half_bar_right = "╸" half_bar_left = "╺" bar = "━" - width = self.width or options.max_width + width = (self.width or options.max_width) - 1 start, end = self.highlight_range # Round start and end to nearest half start = round(start * 2) / 2 end = round(end * 2) / 2 - # start = 3.6; end = 9.6 - # full bars before = int(start) = 3 - # half_start = .6 > 0 = True - - # Bars before highlighted range half_start = start - int(start) > 0 half_end = end - int(end) > 0 - # Non-highlighted portion of bar - - if half_start: - yield Segment(bar * (int(start) + 1), style=self.other_style) - yield Segment(half_bar_left, style=self.highlight_style) - else: - yield Segment(bar * (int(start)), style=self.other_style) + # Initial non-highlighted portion of bar + yield Segment(bar * (int(start - 0.5)), style=self.other_style) + if not half_start and start > 0: yield Segment(half_bar_right, style=self.other_style) # If we have a half bar at start and end, we need 1 less full bar @@ -59,13 +50,18 @@ class UnderlineBar: if half_start and half_end: full_bar_width -= 1 - yield Segment(bar * full_bar_width, style=self.highlight_style) - + # The highlighted portion + if not half_start: + yield Segment(bar * full_bar_width, style=self.highlight_style) + else: + yield Segment(half_bar_left, style=self.highlight_style) + yield Segment(bar * full_bar_width, style=self.highlight_style) if half_end: yield Segment(half_bar_right, style=self.highlight_style) - else: - yield Segment(half_bar_left, style=self.other_style) + # The non-highlighted tail + if not half_end and end - width != 1: + yield Segment(half_bar_left, style=self.other_style) yield Segment(bar * (int(width) - int(end)), style=self.other_style)