1189 return self.conflicts |
1189 return self.conflicts |
1190 |
1190 |
1191 if other in self.conflicts: |
1191 if other in self.conflicts: |
1192 self.conflicts.remove(other) |
1192 self.conflicts.remove(other) |
1193 return self.conflicts |
1193 return self.conflicts |
1194 |
|
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 |
1194 |
1212 |
1195 |
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""" |
1584 index += 1 |
1567 index += 1 |
1585 else: |
1568 else: |
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: |
1592 curses.use_default_colors() |
1590 curses.use_default_colors() |
1593 except curses.error: |
1591 except curses.error: |
1655 mainwin, y, x = drawvertwin(sizes[b'main'], y, x) |
1653 mainwin, y, x = drawvertwin(sizes[b'main'], y, x) |
1656 commitwin, y, x = drawvertwin(sizes[b'commit'], y, x) |
1654 commitwin, y, x = drawvertwin(sizes[b'commit'], y, x) |
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(state, +1, b'page') |
1658 state.change_view(+1, b'page') |
1661 elif e == E_PAGEUP: |
1659 elif e == E_PAGEUP: |
1662 changeview(state, -1, b'page') |
1660 state.change_view(-1, b'page') |
1663 elif e == E_LINEDOWN: |
1661 elif e == E_LINEDOWN: |
1664 changeview(state, +1, b'line') |
1662 state.change_view(+1, b'line') |
1665 elif e == E_LINEUP: |
1663 elif e == E_LINEUP: |
1666 changeview(state, -1, b'line') |
1664 state.change_view(-1, b'line') |
1667 |
1665 |
1668 # start rendering |
1666 # start rendering |
1669 commitwin.erase() |
1667 commitwin.erase() |
1670 helpwin.erase() |
1668 helpwin.erase() |
1671 mainwin.erase() |
1669 mainwin.erase() |