# HG changeset patch # User Steve Fink # Date 1454696031 28800 # Fri Feb 05 10:13:51 2016 -0800 # Node ID 7ce96cab0b8d0d826117d4988467555f66b4b455 # Parent 8bf61a5a1fc63e6e888aaafca1fb573a73197f82 chistedit: allow reordering changes without selecting diff --git a/chistedit.py b/chistedit.py --- a/chistedit.py +++ b/chistedit.py @@ -48,6 +48,8 @@ KEY_PREV_ACTION = ['l', 'KEY_LEFT'] KEY_DOWN = ['j', 'KEY_DOWN'] KEY_UP = ['k', 'KEY_UP'] +KEY_MOVE_DOWN = ['J'] +KEY_MOVE_UP = ['K'] KEY_SEL = [' '] KEY_QUIT = ['q'] KEY_HISTEDIT = ['C'] @@ -120,7 +122,8 @@ rules[newpos].checkconflicts(rules[r]) rules[oldpos].checkconflicts(rules[r]) - makeselection(state, newpos) + if state['selected']: + makeselection(state, newpos) def changeaction(state, pos, action): """Change the action state on the given position to the new action""" @@ -154,15 +157,15 @@ selected = state['selected'] oldpos = state['pos'] rules = state['rules'] - if ch in KEY_DOWN: + if ch in KEY_DOWN or ch in KEY_MOVE_DOWN: newpos = min(oldpos + 1, len(rules) - 1) movecursor(state, oldpos, newpos) - if selected is not None: + if selected is not None or ch in KEY_MOVE_DOWN: swap(state, oldpos, newpos) - if ch in KEY_UP: + if ch in KEY_UP or ch in KEY_MOVE_UP: newpos = max(0, oldpos - 1) movecursor(state, oldpos, newpos) - if selected is not None: + if selected is not None or ch in KEY_MOVE_UP: swap(state, oldpos, newpos) if ch in KEY_NEXT_ACTION: cycleaction(state, oldpos, next=True)