MCPcopy Create free account
hub / github.com/TabViewer/tabview / handle_keys

Method handle_keys

tabview/tabview.py:714–736  ·  view source on GitHub ↗

Determine what method to call for each keypress.

(self)

Source from the content-addressed store, hash-verified

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

Callers 1

runMethod · 0.95

Calls 2

resizeMethod · 0.95
handle_modifierMethod · 0.95

Tested by

no test coverage detected