Show More
@@ -1194,26 +1194,6 b' class histeditrule(object):' | |||||
1194 |
|
1194 | |||
1195 |
|
1195 | |||
1196 | # ============ EVENTS =============== |
|
1196 | # ============ EVENTS =============== | |
1197 | def movecursor(state, oldpos, newpos): |
|
|||
1198 | """Change the rule/changeset that the cursor is pointing to, regardless of |
|
|||
1199 | current mode (you can switch between patches from the view patch window).""" |
|
|||
1200 | state.pos = newpos |
|
|||
1201 |
|
||||
1202 | mode, _ = state.mode |
|
|||
1203 | if mode == MODE_RULES: |
|
|||
1204 | # Scroll through the list by updating the view for MODE_RULES, so that |
|
|||
1205 | # even if we are not currently viewing the rules, switching back will |
|
|||
1206 | # result in the cursor's rule being visible. |
|
|||
1207 | modestate = state.modes[MODE_RULES] |
|
|||
1208 | if newpos < modestate[b'line_offset']: |
|
|||
1209 | modestate[b'line_offset'] = newpos |
|
|||
1210 | elif newpos > modestate[b'line_offset'] + state.page_height - 1: |
|
|||
1211 | modestate[b'line_offset'] = newpos - state.page_height + 1 |
|
|||
1212 |
|
||||
1213 | # Reset the patch view region to the top of the new patch. |
|
|||
1214 | state.modes[MODE_PATCH][b'line_offset'] = 0 |
|
|||
1215 |
|
||||
1216 |
|
||||
1217 | def changemode(state, mode): |
|
1197 | def changemode(state, mode): | |
1218 | curmode, _ = state.mode |
|
1198 | curmode, _ = state.mode | |
1219 | state.mode = (mode, curmode) |
|
1199 | state.mode = (mode, curmode) | |
@@ -1538,12 +1518,12 b' pgup/K: move patch up, pgdn/J: move patc' | |||||
1538 | return |
|
1518 | return | |
1539 | if action in (b'down', b'move-down'): |
|
1519 | if action in (b'down', b'move-down'): | |
1540 | newpos = min(oldpos + 1, len(rules) - 1) |
|
1520 | newpos = min(oldpos + 1, len(rules) - 1) | |
1541 |
movecursor( |
|
1521 | self.move_cursor(oldpos, newpos) | |
1542 | if selected is not None or action == b'move-down': |
|
1522 | if selected is not None or action == b'move-down': | |
1543 | swap(self, oldpos, newpos) |
|
1523 | swap(self, oldpos, newpos) | |
1544 | elif action in (b'up', b'move-up'): |
|
1524 | elif action in (b'up', b'move-up'): | |
1545 | newpos = max(0, oldpos - 1) |
|
1525 | newpos = max(0, oldpos - 1) | |
1546 |
movecursor( |
|
1526 | self.move_cursor(oldpos, newpos) | |
1547 | if selected is not None or action == b'move-up': |
|
1527 | if selected is not None or action == b'move-up': | |
1548 | swap(self, oldpos, newpos) |
|
1528 | swap(self, oldpos, newpos) | |
1549 | elif action == b'next-action': |
|
1529 | elif action == b'next-action': | |
@@ -1555,7 +1535,7 b' pgup/K: move patch up, pgdn/J: move patc' | |||||
1555 | makeselection(self, selected) |
|
1535 | makeselection(self, selected) | |
1556 | elif action == b'goto' and int(ch) < len(rules) and len(rules) <= 10: |
|
1536 | elif action == b'goto' and int(ch) < len(rules) and len(rules) <= 10: | |
1557 | newrule = next((r for r in rules if r.origpos == int(ch))) |
|
1537 | newrule = next((r for r in rules if r.origpos == int(ch))) | |
1558 |
movecursor( |
|
1538 | self.move_cursor(oldpos, newrule.pos) | |
1559 | if selected is not None: |
|
1539 | if selected is not None: | |
1560 | swap(self, oldpos, newrule.pos) |
|
1540 | swap(self, oldpos, newrule.pos) | |
1561 | elif action.startswith(b'action-'): |
|
1541 | elif action.startswith(b'action-'): | |
@@ -1592,6 +1572,25 b' pgup/K: move patch up, pgdn/J: move patc' | |||||
1592 | displayer.close() |
|
1572 | displayer.close() | |
1593 | return displayer.hunk[rule.ctx.rev()].splitlines() |
|
1573 | return displayer.hunk[rule.ctx.rev()].splitlines() | |
1594 |
|
1574 | |||
|
1575 | def move_cursor(self, oldpos, newpos): | |||
|
1576 | """Change the rule/changeset that the cursor is pointing to, regardless of | |||
|
1577 | current mode (you can switch between patches from the view patch window).""" | |||
|
1578 | self.pos = newpos | |||
|
1579 | ||||
|
1580 | mode, _ = self.mode | |||
|
1581 | if mode == MODE_RULES: | |||
|
1582 | # Scroll through the list by updating the view for MODE_RULES, so that | |||
|
1583 | # even if we are not currently viewing the rules, switching back will | |||
|
1584 | # result in the cursor's rule being visible. | |||
|
1585 | modestate = self.modes[MODE_RULES] | |||
|
1586 | if newpos < modestate[b'line_offset']: | |||
|
1587 | modestate[b'line_offset'] = newpos | |||
|
1588 | elif newpos > modestate[b'line_offset'] + self.page_height - 1: | |||
|
1589 | modestate[b'line_offset'] = newpos - self.page_height + 1 | |||
|
1590 | ||||
|
1591 | # Reset the patch view region to the top of the new patch. | |||
|
1592 | self.modes[MODE_PATCH][b'line_offset'] = 0 | |||
|
1593 | ||||
1595 |
|
1594 | |||
1596 | def _chisteditmain(repo, rules, stdscr): |
|
1595 | def _chisteditmain(repo, rules, stdscr): | |
1597 | try: |
|
1596 | try: | |
@@ -1652,7 +1651,7 b' def _chisteditmain(repo, rules, stdscr):' | |||||
1652 | if curmode != oldmode: |
|
1651 | if curmode != oldmode: | |
1653 | state.page_height = sizes[b'main'][0] |
|
1652 | state.page_height = sizes[b'main'][0] | |
1654 | # Adjust the view to fit the current screen size. |
|
1653 | # Adjust the view to fit the current screen size. | |
1655 |
movecursor( |
|
1654 | state.move_cursor(state.pos, state.pos) | |
1656 |
|
1655 | |||
1657 | # Pack the windows against the top, each pane spread across the |
|
1656 | # Pack the windows against the top, each pane spread across the | |
1658 | # full width of the screen. |
|
1657 | # full width of the screen. |
General Comments 0
You need to be logged in to leave comments.
Login now