Show More
@@ -1564,6 +1564,33 b' pgup/K: move patch up, pgdn/J: move patc' | |||||
1564 |
|
1564 | |||
1565 | rulesscr.noutrefresh() |
|
1565 | rulesscr.noutrefresh() | |
1566 |
|
1566 | |||
|
1567 | def render_string(self, win, output, diffcolors=False): | |||
|
1568 | maxy, maxx = win.getmaxyx() | |||
|
1569 | length = min(maxy - 1, len(output)) | |||
|
1570 | for y in range(0, length): | |||
|
1571 | line = output[y] | |||
|
1572 | if diffcolors: | |||
|
1573 | if line and line[0] == b'+': | |||
|
1574 | win.addstr( | |||
|
1575 | y, 0, line, curses.color_pair(COLOR_DIFF_ADD_LINE) | |||
|
1576 | ) | |||
|
1577 | elif line and line[0] == b'-': | |||
|
1578 | win.addstr( | |||
|
1579 | y, 0, line, curses.color_pair(COLOR_DIFF_DEL_LINE) | |||
|
1580 | ) | |||
|
1581 | elif line.startswith(b'@@ '): | |||
|
1582 | win.addstr(y, 0, line, curses.color_pair(COLOR_DIFF_OFFSET)) | |||
|
1583 | else: | |||
|
1584 | win.addstr(y, 0, line) | |||
|
1585 | else: | |||
|
1586 | win.addstr(y, 0, line) | |||
|
1587 | win.noutrefresh() | |||
|
1588 | ||||
|
1589 | def render_patch(self, win): | |||
|
1590 | start = self.modes[MODE_PATCH][b'line_offset'] | |||
|
1591 | content = self.modes[MODE_PATCH][b'patchcontents'] | |||
|
1592 | self.render_string(win, content[start:], diffcolors=True) | |||
|
1593 | ||||
1567 |
|
1594 | |||
1568 | def _chisteditmain(repo, rules, stdscr): |
|
1595 | def _chisteditmain(repo, rules, stdscr): | |
1569 | try: |
|
1596 | try: | |
@@ -1592,33 +1619,6 b' def _chisteditmain(repo, rules, stdscr):' | |||||
1592 | except curses.error: |
|
1619 | except curses.error: | |
1593 | pass |
|
1620 | pass | |
1594 |
|
1621 | |||
1595 | def renderstring(win, state, output, diffcolors=False): |
|
|||
1596 | maxy, maxx = win.getmaxyx() |
|
|||
1597 | length = min(maxy - 1, len(output)) |
|
|||
1598 | for y in range(0, length): |
|
|||
1599 | line = output[y] |
|
|||
1600 | if diffcolors: |
|
|||
1601 | if line and line[0] == b'+': |
|
|||
1602 | win.addstr( |
|
|||
1603 | y, 0, line, curses.color_pair(COLOR_DIFF_ADD_LINE) |
|
|||
1604 | ) |
|
|||
1605 | elif line and line[0] == b'-': |
|
|||
1606 | win.addstr( |
|
|||
1607 | y, 0, line, curses.color_pair(COLOR_DIFF_DEL_LINE) |
|
|||
1608 | ) |
|
|||
1609 | elif line.startswith(b'@@ '): |
|
|||
1610 | win.addstr(y, 0, line, curses.color_pair(COLOR_DIFF_OFFSET)) |
|
|||
1611 | else: |
|
|||
1612 | win.addstr(y, 0, line) |
|
|||
1613 | else: |
|
|||
1614 | win.addstr(y, 0, line) |
|
|||
1615 | win.noutrefresh() |
|
|||
1616 |
|
||||
1617 | def renderpatch(win, state): |
|
|||
1618 | start = state.modes[MODE_PATCH][b'line_offset'] |
|
|||
1619 | content = state.modes[MODE_PATCH][b'patchcontents'] |
|
|||
1620 | renderstring(win, state, content[start:], diffcolors=True) |
|
|||
1621 |
|
||||
1622 | def drawvertwin(size, y, x): |
|
1622 | def drawvertwin(size, y, x): | |
1623 | win = curses.newwin(size[0], size[1], y, x) |
|
1623 | win = curses.newwin(size[0], size[1], y, x) | |
1624 | y += size[0] |
|
1624 | y += size[0] | |
@@ -1675,9 +1675,9 b' def _chisteditmain(repo, rules, stdscr):' | |||||
1675 | helpwin.erase() |
|
1675 | helpwin.erase() | |
1676 | mainwin.erase() |
|
1676 | mainwin.erase() | |
1677 | if curmode == MODE_PATCH: |
|
1677 | if curmode == MODE_PATCH: | |
1678 |
renderpatch(mainwin |
|
1678 | state.render_patch(mainwin) | |
1679 | elif curmode == MODE_HELP: |
|
1679 | elif curmode == MODE_HELP: | |
1680 |
renderstring(mainwin |
|
1680 | state.render_string(mainwin, __doc__.strip().splitlines()) | |
1681 | else: |
|
1681 | else: | |
1682 | state.render_rules(mainwin) |
|
1682 | state.render_rules(mainwin) | |
1683 | state.render_commit(commitwin) |
|
1683 | state.render_commit(commitwin) |
General Comments 0
You need to be logged in to leave comments.
Login now