Show More
@@ -1194,26 +1194,6 b' class histeditrule(object):' | |||
|
1194 | 1194 | |
|
1195 | 1195 | |
|
1196 | 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 | 1197 | def changemode(state, mode): |
|
1218 | 1198 | curmode, _ = state.mode |
|
1219 | 1199 | state.mode = (mode, curmode) |
@@ -1538,12 +1518,12 b' pgup/K: move patch up, pgdn/J: move patc' | |||
|
1538 | 1518 | return |
|
1539 | 1519 | if action in (b'down', b'move-down'): |
|
1540 | 1520 | newpos = min(oldpos + 1, len(rules) - 1) |
|
1541 |
movecursor( |
|
|
1521 | self.move_cursor(oldpos, newpos) | |
|
1542 | 1522 | if selected is not None or action == b'move-down': |
|
1543 | 1523 | swap(self, oldpos, newpos) |
|
1544 | 1524 | elif action in (b'up', b'move-up'): |
|
1545 | 1525 | newpos = max(0, oldpos - 1) |
|
1546 |
movecursor( |
|
|
1526 | self.move_cursor(oldpos, newpos) | |
|
1547 | 1527 | if selected is not None or action == b'move-up': |
|
1548 | 1528 | swap(self, oldpos, newpos) |
|
1549 | 1529 | elif action == b'next-action': |
@@ -1555,7 +1535,7 b' pgup/K: move patch up, pgdn/J: move patc' | |||
|
1555 | 1535 | makeselection(self, selected) |
|
1556 | 1536 | elif action == b'goto' and int(ch) < len(rules) and len(rules) <= 10: |
|
1557 | 1537 | newrule = next((r for r in rules if r.origpos == int(ch))) |
|
1558 |
movecursor( |
|
|
1538 | self.move_cursor(oldpos, newrule.pos) | |
|
1559 | 1539 | if selected is not None: |
|
1560 | 1540 | swap(self, oldpos, newrule.pos) |
|
1561 | 1541 | elif action.startswith(b'action-'): |
@@ -1592,6 +1572,25 b' pgup/K: move patch up, pgdn/J: move patc' | |||
|
1592 | 1572 | displayer.close() |
|
1593 | 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 | 1595 | def _chisteditmain(repo, rules, stdscr): |
|
1597 | 1596 | try: |
@@ -1652,7 +1651,7 b' def _chisteditmain(repo, rules, stdscr):' | |||
|
1652 | 1651 | if curmode != oldmode: |
|
1653 | 1652 | state.page_height = sizes[b'main'][0] |
|
1654 | 1653 | # Adjust the view to fit the current screen size. |
|
1655 |
movecursor( |
|
|
1654 | state.move_cursor(state.pos, state.pos) | |
|
1656 | 1655 | |
|
1657 | 1656 | # Pack the windows against the top, each pane spread across the |
|
1658 | 1657 | # full width of the screen. |
General Comments 0
You need to be logged in to leave comments.
Login now