Skip to content

Commit 1b39538

Browse files
Truncate long file paths for display in table
Signed-off-by: Jacob Stopak <jacob@initialcommit.io>
1 parent 715f094 commit 1b39538

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

git_sim/git_sim_base_command.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,17 @@ def setup_and_draw_zones(self, first_column_name="Untracked files", second_colum
372372
thirdColumnFilesDict = {}
373373

374374
for i, f in enumerate(firstColumnFileNames):
375-
text = m.Text(f, font="Monospace", font_size=24, color=self.scene.fontColor).move_to((firstColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)).shift(m.DOWN*0.5*(i+1))
375+
text = m.Text(self.trim_path(f), font="Monospace", font_size=24, color=self.scene.fontColor).move_to((firstColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)).shift(m.DOWN*0.5*(i+1))
376376
firstColumnFiles.add(text)
377377
firstColumnFilesDict[f] = text
378378

379379
for j, f in enumerate(secondColumnFileNames):
380-
text = m.Text(f, font="Monospace", font_size=24, color=self.scene.fontColor).move_to((secondColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)).shift(m.DOWN*0.5*(j+1))
380+
text = m.Text(self.trim_path(f), font="Monospace", font_size=24, color=self.scene.fontColor).move_to((secondColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)).shift(m.DOWN*0.5*(j+1))
381381
secondColumnFiles.add(text)
382382
secondColumnFilesDict[f] = text
383383

384384
for h, f in enumerate(thirdColumnFileNames):
385-
text = m.Text(f, font="Monospace", font_size=24, color=self.scene.fontColor).move_to((thirdColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)).shift(m.DOWN*0.5*(h+1))
385+
text = m.Text(self.trim_path(f), font="Monospace", font_size=24, color=self.scene.fontColor).move_to((thirdColumnTitle.get_center()[0], horizontal2.get_center()[1], 0)).shift(m.DOWN*0.5*(h+1))
386386
thirdColumnFiles.add(text)
387387
thirdColumnFilesDict[f] = text
388388

@@ -547,6 +547,9 @@ def draw_dark_ref(self):
547547
self.toFadeOut.add(refRec)
548548
self.prevRef = refRec
549549

550+
def trim_path(self, path):
551+
return (path[:5] + "..." + path[-15:]) if len(path) > 20 else path
552+
550553

551554
class DottedLine(m.Line):
552555

0 commit comments

Comments
 (0)