##// END OF EJS Templates
chistedit: move cycleaction() onto state class...
Martin von Zweigbergk -
r49026:7913f533 default
parent child Browse files
Show More
@@ -1194,23 +1194,6 b' class histeditrule(object):'
1194
1194
1195
1195
1196 # ============ EVENTS ===============
1196 # ============ EVENTS ===============
1197 def cycleaction(state, pos, next=False):
1198 """Changes the action state the next or the previous action from
1199 the action list"""
1200 rules = state.rules
1201 assert 0 <= pos < len(rules)
1202 current = rules[pos].action
1203
1204 assert current in KEY_LIST
1205
1206 index = KEY_LIST.index(current)
1207 if next:
1208 index += 1
1209 else:
1210 index -= 1
1211 state.change_action(pos, KEY_LIST[index % len(KEY_LIST)])
1212
1213
1214 def changeview(state, delta, unit):
1197 def changeview(state, delta, unit):
1215 """Change the region of whatever is being viewed (a patch or the list of
1198 """Change the region of whatever is being viewed (a patch or the list of
1216 changesets). 'delta' is an amount (+/- 1) and 'unit' is 'page' or 'line'."""
1199 changesets). 'delta' is an amount (+/- 1) and 'unit' is 'page' or 'line'."""
@@ -1486,9 +1469,9 b' pgup/K: move patch up, pgdn/J: move patc'
1486 if selected is not None or action == b'move-up':
1469 if selected is not None or action == b'move-up':
1487 self.swap(oldpos, newpos)
1470 self.swap(oldpos, newpos)
1488 elif action == b'next-action':
1471 elif action == b'next-action':
1489 cycleaction(self, oldpos, next=True)
1472 self.cycle_action(oldpos, next=True)
1490 elif action == b'prev-action':
1473 elif action == b'prev-action':
1491 cycleaction(self, oldpos, next=False)
1474 self.cycle_action(oldpos, next=False)
1492 elif action == b'select':
1475 elif action == b'select':
1493 selected = oldpos if selected is None else None
1476 selected = oldpos if selected is None else None
1494 self.make_selection(selected)
1477 self.make_selection(selected)
@@ -1587,6 +1570,22 b' pgup/K: move patch up, pgdn/J: move patc'
1587 assert 0 <= pos < len(rules)
1570 assert 0 <= pos < len(rules)
1588 rules[pos].action = action
1571 rules[pos].action = action
1589
1572
1573 def cycle_action(self, pos, next=False):
1574 """Changes the action state the next or the previous action from
1575 the action list"""
1576 rules = self.rules
1577 assert 0 <= pos < len(rules)
1578 current = rules[pos].action
1579
1580 assert current in KEY_LIST
1581
1582 index = KEY_LIST.index(current)
1583 if next:
1584 index += 1
1585 else:
1586 index -= 1
1587 self.change_action(pos, KEY_LIST[index % len(KEY_LIST)])
1588
1590
1589
1591 def _chisteditmain(repo, rules, stdscr):
1590 def _chisteditmain(repo, rules, stdscr):
1592 try:
1591 try:
General Comments 0
You need to be logged in to leave comments. Login now