| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Fenrir TTY screen reader |
| 5 |
# By Chrys, Storm Dragon, and contributors. |
| 6 |
|
| 7 |
|
| 8 |
from fenrirscreenreader.core.i18n import _ |
| 9 |
|
| 10 |
|
| 11 |
class command: |
| 12 |
def __init__(self): |
| 13 |
pass |
| 14 |
|
| 15 |
def initialize(self, environment): |
| 16 |
self.env = environment |
| 17 |
|
| 18 |
def shutdown(self): |
| 19 |
pass |
| 20 |
|
| 21 |
def get_description(self): |
| 22 |
return _("disables speech until next keypress") |
| 23 |
|
| 24 |
def run(self): |
| 25 |
if self.env["runtime"]["InputManager"].no_key_pressed(): |
| 26 |
return |
| 27 |
if len(self.env["input"]["prev_input"]) > 0: |
| 28 |
return |
| 29 |
if not self.env["commandBuffer"]["enableSpeechOnKeypress"]: |
| 30 |
return |
| 31 |
self.env["runtime"]["SettingsManager"].set_setting( |
| 32 |
"speech", |
| 33 |
"enabled", |
| 34 |
str(self.env["commandBuffer"]["enableSpeechOnKeypress"]), |
| 35 |
) |
| 36 |
self.env["commandBuffer"]["enableSpeechOnKeypress"] = False |
| 37 |
# Also disable prompt watching since speech was manually re-enabled |
| 38 |
if "silenceUntilPrompt" in self.env["commandBuffer"]: |
| 39 |
self.env["commandBuffer"]["silenceUntilPrompt"] = False |
| 40 |
self.env["runtime"]["OutputManager"].present_text( |
| 41 |
_("speech enabled"), sound_icon="SpeechOn", interrupt=True |
| 42 |
) |
| 43 |
|
| 44 |
def set_callback(self, callback): |
| 45 |
pass |