| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Fenrir TTY screen reader |
| 5 |
# By Chrys, Storm Dragon, and contributors. |
| 6 |
|
| 7 |
from fenrirscreenreader.core.i18n import _ |
| 8 |
|
| 9 |
|
| 10 |
class command: |
| 11 |
def __init__(self): |
| 12 |
pass |
| 13 |
|
| 14 |
def initialize(self, environment): |
| 15 |
self.env = environment |
| 16 |
|
| 17 |
def shutdown(self): |
| 18 |
pass |
| 19 |
|
| 20 |
def get_description(self): |
| 21 |
return "" |
| 22 |
|
| 23 |
def run(self): |
| 24 |
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool( |
| 25 |
"keyboard", "interrupt_on_key_press" |
| 26 |
): |
| 27 |
return |
| 28 |
if self.env["runtime"]["InputManager"].no_key_pressed(): |
| 29 |
return |
| 30 |
if self.env["runtime"]["ScreenManager"].is_screen_change(): |
| 31 |
return |
| 32 |
if len(self.env["input"]["curr_input"]) <= len( |
| 33 |
self.env["input"]["prev_input"] |
| 34 |
): |
| 35 |
return |
| 36 |
# if the filter is set |
| 37 |
if ( |
| 38 |
self.env["runtime"]["SettingsManager"] |
| 39 |
.get_setting("keyboard", "interrupt_on_key_press_filter") |
| 40 |
.strip() |
| 41 |
!= "" |
| 42 |
): |
| 43 |
filter_list = ( |
| 44 |
self.env["runtime"]["SettingsManager"] |
| 45 |
.get_setting("keyboard", "interrupt_on_key_press_filter") |
| 46 |
.split(",") |
| 47 |
) |
| 48 |
for curr_key in self.env["input"]["curr_input"]: |
| 49 |
if curr_key not in filter_list: |
| 50 |
return |
| 51 |
self.env["runtime"]["OutputManager"].interrupt_output_async() |
| 52 |
|
| 53 |
def set_callback(self, callback): |
| 54 |
pass |