~callum/barszcz

cbd324b258cab94120ed876070ca8d47af67ac20 — Callum Brown 1 year, 10 months ago f3f868f
Remove index numbering

Not very useful during actual use. Mostly just gets in the way and
makes information display unnecessarily busy.

Maybe could be brought back (in revised form) as a configurable
option?
2 files changed, 11 insertions(+), 23 deletions(-)

M README.md
M beetsplug/barszcz.py
M README.md => README.md +1 -1
@@ 46,7 46,7 @@ Required arguments are CAPITALISED.
| list  [query] | ls         | List albums and items matching the [query]. Default: [query] is blank, list all. |
| lista [query] | lsa        | List albums matching the [query]. Default: [query] is blank, list all. |
| listi [query] | lsi        | List items matching the [query]. Default: [query] is blank, list all. |
| focus [INDEX] |            | Change focus to the thing at the given [INDEX]. A negative [INDEX] focuses the last thing. |
| focus [INDEX] |            | Change focus to the thing at the given [INDEX]. A negative [INDEX] focuses the last thing. Indices are not displayed; this command is intended for internal use and shortcuts. |
| up [n]        |            | Change focus up [n] things (wraps). Default: [n] = 1. |
| down [n]      |            | Change focus down [n] things (wraps). Default: [n] = 1. |
| more          |            | Show more information about the focused thing. If an album or item is focused, its attributes will be listed. If an attribute is focused, albums and items with that attribute will be listed. |

M beetsplug/barszcz.py => beetsplug/barszcz.py +10 -22
@@ 160,39 160,30 @@ class Thing:
    # in order to delineate Things and improve readability.
    gap = gap_lines("regular")

    def format_info(self, width, indent):
    def format_info(self, width):
        """Format info to be displayed so it fits in width columns.

        Args:
            width: int, number of available columns
            indent: int, number of spaces that info must be indented

        width includes the indent space.
        """
        # Width availbale for information
        info_w = width - indent
        # Space to add at start for indent
        indent_space = " " * indent

        formatted = ""
        for left, right, ratio in self.info:
            formatted += indent_space
            if len(left) == 0 and len(right) == 0:
                pass
            elif len(left) == 0:
                f_r = shorten(right, info_w)
                formatted += " " * (info_w - len(f_r)) + f_r
                f_r = shorten(right, width)
                formatted += " " * (width - len(f_r)) + f_r
            elif len(right) == 0:
                formatted += shorten(left, info_w)
                formatted += shorten(left, width)
            else:
                # Number of columns available to the left
                # (info_w - 1) to allow a space between left and right
                w_l = round((info_w - 1) * ratio)
                # (width - 1) to allow a space between left and right
                w_l = round((width - 1) * ratio)
                f_l = shorten(left, w_l)
                # Number of columns available to the right
                w_r = info_w - len(f_l) - 1
                w_r = width - len(f_l) - 1
                f_r = shorten(right, w_r)
                space = " " * (info_w - len(f_l) - len(f_r))
                space = " " * (width - len(f_l) - len(f_r))
                formatted += f_l + space + f_r
            formatted += "\n"



@@ 315,8 306,6 @@ class Group:
        self.pad = curses.newpad(self.h, self.w)
        self.thing_pads = []
        start_line = 0
        # Leave enough room for largest index before thing info
        self.info_x = len(str(len(self.things))) + 1

        for i, thing in enumerate(self.things):
            if isinstance(thing, HeadingThing):


@@ 324,8 313,7 @@ class Group:
            else:
                attr = curses.A_NORMAL
            thing_pad = self.pad.subpad(thing.height, self.w, start_line, 0)
            thing_pad.insstr(0, 0, thing.format_info(self.w, self.info_x), attr)
            thing_pad.addstr(0, 0, str(i), attr)
            thing_pad.insstr(0, 0, thing.format_info(self.w), attr)
            self.thing_pads.append(thing_pad)
            # Leave blank lines between things
            start_line += thing.height + thing.gap


@@ 352,7 340,7 @@ class Group:
                attr = curses.A_NORMAL
            self.thing_pads[i].clear()
            self.thing_pads[i].resize(thing.height, self.w)
            self.thing_pads[i].insstr(0, 0, thing.format_info(self.w, self.info_x), attr)
            self.thing_pads[i].insstr(0, 0, thing.format_info(self.w), attr)
            self.thing_pads[i].addstr(0, 0, str(i), attr)

        self.refresh()