Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[canvas- graph-] fix handling of label chars with screen width > 1 #2665

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions visidata/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ def _mark_overlap_text(labels, textobj):
def _overlaps(a, b):
a_x1, _, a_txt, _, _ = a
b_x1, _, b_txt, _, _ = b
a_x2 = a_x1 + len(a_txt)
b_x2 = b_x1 + len(b_txt)
a_x2 = a_x1 + dispwidth(a_txt)
b_x2 = b_x1 + dispwidth(b_txt)
if a_x1 < b_x1 < a_x2 or a_x1 < b_x2 < a_x2 or \
b_x1 < a_x1 < b_x2 or b_x1 < a_x2 < b_x2:
return True
Expand All @@ -325,10 +325,10 @@ def _overlaps(a, b):
for pix_x, pix_y, txt, attr, row in self.labels:
if attr in self.hiddenAttrs:
continue
if row is not None:
pix_x -= len(txt)/2*2
char_y = int(pix_y/4)
char_x = int(pix_x/2)
if row is not None:
char_x -= math.ceil(dispwidth(txt)/2)*2
o = (char_x, char_y, txt, attr, row)
_mark_overlap_text(labels_by_line[char_y], o)

Expand Down
4 changes: 2 additions & 2 deletions visidata/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ def add_x_axis_label(self, frac):
txt = tick + txt
else:
right_margin = self.plotwidth - 1 - self.plotviewBox.xmax
if (len(txt)+len(tick))*2 <= right_margin:
if (dispwidth(txt)+dispwidth(tick))*2 <= right_margin:
txt = tick + txt
else:
# shift rightmost label to be left of its tick
x -= len(txt)*2
x -= dispwidth(txt)*2
if len(tick) == 0:
x += 1
txt = txt + tick
Expand Down
Loading