Show More
@@ -1193,23 +1193,6 b' class histeditrule(object):' | |||||
1193 | return self.conflicts |
|
1193 | return self.conflicts | |
1194 |
|
1194 | |||
1195 |
|
1195 | |||
1196 | # ============ EVENTS =============== |
|
|||
1197 | def changeview(state, delta, unit): |
|
|||
1198 | """Change the region of whatever is being viewed (a patch or the list of |
|
|||
1199 | changesets). 'delta' is an amount (+/- 1) and 'unit' is 'page' or 'line'.""" |
|
|||
1200 | mode, _ = state.mode |
|
|||
1201 | if mode != MODE_PATCH: |
|
|||
1202 | return |
|
|||
1203 | mode_state = state.modes[mode] |
|
|||
1204 | num_lines = len(mode_state[b'patchcontents']) |
|
|||
1205 | page_height = state.page_height |
|
|||
1206 | unit = page_height if unit == b'page' else 1 |
|
|||
1207 | num_pages = 1 + (num_lines - 1) // page_height |
|
|||
1208 | max_offset = (num_pages - 1) * page_height |
|
|||
1209 | newline = mode_state[b'line_offset'] + delta * unit |
|
|||
1210 | mode_state[b'line_offset'] = max(0, min(max_offset, newline)) |
|
|||
1211 |
|
||||
1212 |
|
||||
1213 | def makecommands(rules): |
|
1196 | def makecommands(rules): | |
1214 | """Returns a list of commands consumable by histedit --commands based on |
|
1197 | """Returns a list of commands consumable by histedit --commands based on | |
1215 | our list of rules""" |
|
1198 | our list of rules""" | |
@@ -1586,6 +1569,21 b' pgup/K: move patch up, pgdn/J: move patc' | |||||
1586 | index -= 1 |
|
1569 | index -= 1 | |
1587 | self.change_action(pos, KEY_LIST[index % len(KEY_LIST)]) |
|
1570 | self.change_action(pos, KEY_LIST[index % len(KEY_LIST)]) | |
1588 |
|
1571 | |||
|
1572 | def change_view(self, delta, unit): | |||
|
1573 | """Change the region of whatever is being viewed (a patch or the list of | |||
|
1574 | changesets). 'delta' is an amount (+/- 1) and 'unit' is 'page' or 'line'.""" | |||
|
1575 | mode, _ = self.mode | |||
|
1576 | if mode != MODE_PATCH: | |||
|
1577 | return | |||
|
1578 | mode_state = self.modes[mode] | |||
|
1579 | num_lines = len(mode_state[b'patchcontents']) | |||
|
1580 | page_height = self.page_height | |||
|
1581 | unit = page_height if unit == b'page' else 1 | |||
|
1582 | num_pages = 1 + (num_lines - 1) // page_height | |||
|
1583 | max_offset = (num_pages - 1) * page_height | |||
|
1584 | newline = mode_state[b'line_offset'] + delta * unit | |||
|
1585 | mode_state[b'line_offset'] = max(0, min(max_offset, newline)) | |||
|
1586 | ||||
1589 |
|
1587 | |||
1590 | def _chisteditmain(repo, rules, stdscr): |
|
1588 | def _chisteditmain(repo, rules, stdscr): | |
1591 | try: |
|
1589 | try: | |
@@ -1657,13 +1655,13 b' def _chisteditmain(repo, rules, stdscr):' | |||||
1657 |
|
1655 | |||
1658 | if e in (E_PAGEDOWN, E_PAGEUP, E_LINEDOWN, E_LINEUP): |
|
1656 | if e in (E_PAGEDOWN, E_PAGEUP, E_LINEDOWN, E_LINEUP): | |
1659 | if e == E_PAGEDOWN: |
|
1657 | if e == E_PAGEDOWN: | |
1660 |
changeview( |
|
1658 | state.change_view(+1, b'page') | |
1661 | elif e == E_PAGEUP: |
|
1659 | elif e == E_PAGEUP: | |
1662 |
changeview( |
|
1660 | state.change_view(-1, b'page') | |
1663 | elif e == E_LINEDOWN: |
|
1661 | elif e == E_LINEDOWN: | |
1664 |
changeview( |
|
1662 | state.change_view(+1, b'line') | |
1665 | elif e == E_LINEUP: |
|
1663 | elif e == E_LINEUP: | |
1666 |
changeview( |
|
1664 | state.change_view(-1, b'line') | |
1667 |
|
1665 | |||
1668 | # start rendering |
|
1666 | # start rendering | |
1669 | commitwin.erase() |
|
1667 | commitwin.erase() |
General Comments 0
You need to be logged in to leave comments.
Login now