From 5eb063973450629b54eea9cda2b0b65f3e70362d Mon Sep 17 00:00:00 2001 From: "g@localhost.localdomain" Date: Wed, 13 Dec 2006 20:32:25 +0100 Subject: [PATCH] Add the possibility to put the name and the size on the same line in ASCII mode --- pysize/ui/ascii/ui_ascii.py | 6 +++--- pysize/ui/char_matrix.py | 3 +++ pysize/ui/curses/ui_curses.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pysize/ui/ascii/ui_ascii.py b/pysize/ui/ascii/ui_ascii.py index 11e2b98..b3dc290 100644 --- a/pysize/ui/ascii/ui_ascii.py +++ b/pysize/ui/ascii/ui_ascii.py @@ -47,15 +47,15 @@ def _draw_progress(): def run(options, args): columns, lines = terminal_size() lines -= 3 # Summary + Prompt + Last line - # An entry needs 3 lines - min_size = min_size_to_consider(options.min_size, lines / 3) + # An entry needs 2 lines + min_size = min_size_to_consider(options.min_size, lines / 2) size_observable.add_observer(_draw_progress) args = args or ['.'] tree = pysize_tree(args, options.max_depth, min_size, options) if not tree.root: sys.exit(1) # The last entry needs an additional terminating line - total_lines = int(math.ceil(3.0 * tree.root.size / + total_lines = int(math.ceil(2.0 * tree.root.size / tree.root.minimum_node_size())) + 1 matrix = CharMatrix(columns, total_lines, tree) print '\n'.join([''.join(map(_transform, line)) for line in matrix.matrix]) diff --git a/pysize/ui/char_matrix.py b/pysize/ui/char_matrix.py index 0909f6a..2d769fc 100644 --- a/pysize/ui/char_matrix.py +++ b/pysize/ui/char_matrix.py @@ -97,6 +97,9 @@ class CharMatrix(object): if y1 > y0 + 2: self._draw_string(x0+1, (y0+y1)/2 + 1, length - 2, human_unit(node.size)) + elif len(node.get_name()) + 1 + len(human_unit(node.size)) < length: + self._draw_string(x0+2+len(node.get_name()), (y0+y1)/2, length - 2, + human_unit(node.size)) def _draw_boxes(self, node, depth, offset, length, total_size): x0 = depth * (self.width - 1) / self.tree.height diff --git a/pysize/ui/curses/ui_curses.py b/pysize/ui/curses/ui_curses.py index 77b5623..9b92d88 100644 --- a/pysize/ui/curses/ui_curses.py +++ b/pysize/ui/curses/ui_curses.py @@ -94,7 +94,7 @@ class _CursesApp(object): if self.need_tree: # -1 accounts for the last horizontal line self.tree = pysize_tree(self.paths, self.max_depth, - 3.0 / (self.height - 1), self.options) + 2.0 / (self.height - 1), self.options) self.need_tree = False if not self.tree.root: return -- 2.11.4.GIT