1621 # eventloop |
1621 # eventloop |
1622 ch = None |
1622 ch = None |
1623 stdscr.clear() |
1623 stdscr.clear() |
1624 stdscr.refresh() |
1624 stdscr.refresh() |
1625 while True: |
1625 while True: |
1626 try: |
1626 oldmode, unused = state[b'mode'] |
1627 oldmode, unused = state[b'mode'] |
1627 if oldmode == MODE_INIT: |
1628 if oldmode == MODE_INIT: |
1628 changemode(state, MODE_RULES) |
1629 changemode(state, MODE_RULES) |
1629 e = event(state, ch) |
1630 e = event(state, ch) |
1630 |
1631 |
1631 if e == E_QUIT: |
1632 if e == E_QUIT: |
1632 return False |
1633 return False |
1633 if e == E_HISTEDIT: |
1634 if e == E_HISTEDIT: |
1634 return state[b'rules'] |
1635 return state[b'rules'] |
1635 else: |
|
1636 if e == E_RESIZE: |
|
1637 size = screen_size() |
|
1638 if size != stdscr.getmaxyx(): |
|
1639 curses.resizeterm(*size) |
|
1640 |
|
1641 curmode, unused = state[b'mode'] |
|
1642 sizes = layout(curmode) |
|
1643 if curmode != oldmode: |
|
1644 state[b'page_height'] = sizes[b'main'][0] |
|
1645 # Adjust the view to fit the current screen size. |
|
1646 movecursor(state, state[b'pos'], state[b'pos']) |
|
1647 |
|
1648 # Pack the windows against the top, each pane spread across the |
|
1649 # full width of the screen. |
|
1650 y, x = (0, 0) |
|
1651 helpwin, y, x = drawvertwin(sizes[b'help'], y, x) |
|
1652 mainwin, y, x = drawvertwin(sizes[b'main'], y, x) |
|
1653 commitwin, y, x = drawvertwin(sizes[b'commit'], y, x) |
|
1654 |
|
1655 if e in (E_PAGEDOWN, E_PAGEUP, E_LINEDOWN, E_LINEUP): |
|
1656 if e == E_PAGEDOWN: |
|
1657 changeview(state, +1, b'page') |
|
1658 elif e == E_PAGEUP: |
|
1659 changeview(state, -1, b'page') |
|
1660 elif e == E_LINEDOWN: |
|
1661 changeview(state, +1, b'line') |
|
1662 elif e == E_LINEUP: |
|
1663 changeview(state, -1, b'line') |
|
1664 |
|
1665 # start rendering |
|
1666 commitwin.erase() |
|
1667 helpwin.erase() |
|
1668 mainwin.erase() |
|
1669 if curmode == MODE_PATCH: |
|
1670 renderpatch(mainwin, state) |
|
1671 elif curmode == MODE_HELP: |
|
1672 renderstring(mainwin, state, __doc__.strip().splitlines()) |
1636 else: |
1673 else: |
1637 if e == E_RESIZE: |
1674 renderrules(mainwin, state) |
1638 size = screen_size() |
1675 rendercommit(commitwin, state) |
1639 if size != stdscr.getmaxyx(): |
1676 renderhelp(helpwin, state) |
1640 curses.resizeterm(*size) |
1677 curses.doupdate() |
1641 |
1678 # done rendering |
1642 curmode, unused = state[b'mode'] |
1679 ch = encoding.strtolocal(stdscr.getkey()) |
1643 sizes = layout(curmode) |
|
1644 if curmode != oldmode: |
|
1645 state[b'page_height'] = sizes[b'main'][0] |
|
1646 # Adjust the view to fit the current screen size. |
|
1647 movecursor(state, state[b'pos'], state[b'pos']) |
|
1648 |
|
1649 # Pack the windows against the top, each pane spread across the |
|
1650 # full width of the screen. |
|
1651 y, x = (0, 0) |
|
1652 helpwin, y, x = drawvertwin(sizes[b'help'], y, x) |
|
1653 mainwin, y, x = drawvertwin(sizes[b'main'], y, x) |
|
1654 commitwin, y, x = drawvertwin(sizes[b'commit'], y, x) |
|
1655 |
|
1656 if e in (E_PAGEDOWN, E_PAGEUP, E_LINEDOWN, E_LINEUP): |
|
1657 if e == E_PAGEDOWN: |
|
1658 changeview(state, +1, b'page') |
|
1659 elif e == E_PAGEUP: |
|
1660 changeview(state, -1, b'page') |
|
1661 elif e == E_LINEDOWN: |
|
1662 changeview(state, +1, b'line') |
|
1663 elif e == E_LINEUP: |
|
1664 changeview(state, -1, b'line') |
|
1665 |
|
1666 # start rendering |
|
1667 commitwin.erase() |
|
1668 helpwin.erase() |
|
1669 mainwin.erase() |
|
1670 if curmode == MODE_PATCH: |
|
1671 renderpatch(mainwin, state) |
|
1672 elif curmode == MODE_HELP: |
|
1673 renderstring(mainwin, state, __doc__.strip().splitlines()) |
|
1674 else: |
|
1675 renderrules(mainwin, state) |
|
1676 rendercommit(commitwin, state) |
|
1677 renderhelp(helpwin, state) |
|
1678 curses.doupdate() |
|
1679 # done rendering |
|
1680 ch = encoding.strtolocal(stdscr.getkey()) |
|
1681 except curses.error: |
|
1682 pass |
|
1683 |
1680 |
1684 |
1681 |
1685 def _chistedit(ui, repo, freeargs, opts): |
1682 def _chistedit(ui, repo, freeargs, opts): |
1686 """interactively edit changeset history via a curses interface |
1683 """interactively edit changeset history via a curses interface |
1687 |
1684 |