Handles key presses. Returns True if a key was found, False otherwise.
(self)
| 458 | self.stat.update('Bold: all', self.delay) |
| 459 | |
| 460 | def get(self): |
| 461 | """ |
| 462 | Handles key presses. Returns True if a key was found, False otherwise. |
| 463 | """ |
| 464 | if args.ignore_keyboard: |
| 465 | return False; |
| 466 | |
| 467 | kp = self.screen.getch() |
| 468 | |
| 469 | if kp == -1: |
| 470 | return False |
| 471 | elif kp == ord(" ") or kp == ord("q") or kp == 27: # 27 = ESC |
| 472 | exit() |
| 473 | elif kp == ord('a'): |
| 474 | args.asynchronous = not args.asynchronous |
| 475 | on_off = 'on' if args.asynchronous else 'off' |
| 476 | self.stat.update('Async: %s' % on_off, self.delay) |
| 477 | elif kp == ord('b'): |
| 478 | self.cycle_bold() |
| 479 | elif kp == ord('f'): |
| 480 | args.flashers = not args.flashers |
| 481 | on_off = 'on' if args.flashers else 'off' |
| 482 | self.stat.update('Flash: %s' % on_off, self.delay) |
| 483 | elif kp == ord('o'): |
| 484 | self.toggle_status() |
| 485 | |
| 486 | # Speed control |
| 487 | elif kp == ord('-') or kp == ord('_') or kp == curses.KEY_LEFT: |
| 488 | self.delay = min(self.delay + 10, 10990) |
| 489 | self.show_speed() |
| 490 | elif kp == ord('=') or kp == ord('+') or kp == curses.KEY_RIGHT: |
| 491 | self.delay = max(self.delay - 10, 0) |
| 492 | self.show_speed() |
| 493 | elif kp == ord('[') or kp == curses.KEY_DOWN: |
| 494 | self.delay = min(self.delay + 100, 10990) |
| 495 | self.show_speed() |
| 496 | elif kp == ord(']') or kp == curses.KEY_UP: |
| 497 | self.delay = max(self.delay - 100, 0) |
| 498 | self.show_speed() |
| 499 | |
| 500 | # Foreground color control |
| 501 | elif kp == ord('1'): |
| 502 | self.set_fg_color('Green') |
| 503 | elif kp == ord('2'): |
| 504 | self.set_fg_color('Red') |
| 505 | elif kp == ord('3'): |
| 506 | self.set_fg_color('Blue') |
| 507 | elif kp == ord('4'): |
| 508 | self.set_fg_color('White') |
| 509 | elif kp == ord('5'): |
| 510 | self.set_fg_color('Yellow') |
| 511 | elif kp == ord('6'): |
| 512 | self.set_fg_color('Cyan') |
| 513 | elif kp == ord('7'): |
| 514 | self.set_fg_color('Magenta') |
| 515 | elif kp == ord('8'): |
| 516 | self.set_fg_color('Black') |
| 517 | elif kp == ord('9'): |
no test coverage detected