Determine what method to call for each keypress.
(self)
| 712 | self.handle_keys() |
| 713 | |
| 714 | def handle_keys(self): |
| 715 | """Determine what method to call for each keypress. |
| 716 | |
| 717 | """ |
| 718 | c = self.scr.getch() # Get a keystroke |
| 719 | if c == curses.KEY_RESIZE: |
| 720 | self.resize() |
| 721 | return |
| 722 | if 0 < c < 256: |
| 723 | c = chr(c) |
| 724 | # Digits are commands without a modifier |
| 725 | try: |
| 726 | found_digit = c.isdigit() |
| 727 | except AttributeError: |
| 728 | # Since .isdigit() doesn't exist if c > 256, we need to catch the |
| 729 | # error for those keys. |
| 730 | found_digit = False |
| 731 | if found_digit and (len(self.modifier) > 0 or c not in self.keys): |
| 732 | self.handle_modifier(c) |
| 733 | elif c in self.keys: |
| 734 | self.keys[c]() |
| 735 | else: |
| 736 | self.modifier = str() |
| 737 | |
| 738 | def handle_modifier(self, mod): |
| 739 | """Append digits as a key modifier, clear the modifier if not |
no test coverage detected