~callum/barszcz

6ab72e810a7e41916e5265038e567d3663790d01 — Callum Brown 1 year, 10 months ago 48e2300
Escape during input editing clears and exits

Also clears shortcut.

Fixes: https://todo.sr.ht/~callum/barszcz/32
1 files changed, 10 insertions(+), 0 deletions(-)

M beetsplug/barszcz.py
M beetsplug/barszcz.py => beetsplug/barszcz.py +10 -0
@@ 62,6 62,8 @@ class InputLine(Textbox):
    Up and down cursor keys move through command history.
    Up and Ctrl-P move to previous command.
    Down and Ctrl-N move to next command.

    Escape clears input and exits editing mode.
    """
    history = []



@@ 81,6 83,9 @@ class InputLine(Textbox):
                ch = validate(ch)
            if not ch:
                continue
            elif ch == 27: # ESCAPE
                self.win.clear()
                break
            # Change to previous command
            elif ch in (curses.ascii.DLE, curses.KEY_UP) and current > 0:
                current -= 1


@@ 552,6 557,10 @@ class Barszcz:
                curses.curs_set(True)
                text = input_box.edit().strip()
                curses.curs_set(False)
                input_win.clear()
                # Clear shortcut
                shortcut = ""
                shortcut_reps = ""
                if len(text) > 0 and text[0] == ":":
                    input_win.insstr(0, 0, "WORKING... ")
                    # Add focus background to input line to indicate working


@@ 561,6 570,7 @@ class Barszcz:
                    # Remove focus background
                    input_win.bkgd(' ', curses.color_pair(0))
                    input_win.clear()
                    # Display return value
                    if isinstance(result, str):
                        input_win.addstr(0, 0, result)
                input_win.refresh()