Debian Codegraph @

src/fenrirscreenreader/commands/onCursorChange/45000-char_delete_echo.py

raw
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 "No Description found"
23
24 def run(self):
25 if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
26 "keyboard", "char_delete_echo"
27 ):
28 return
29 # detect typing or chilling
30 if (
31 self.env["screen"]["new_cursor"]["x"]
32 >= self.env["screen"]["old_cursor"]["x"]
33 ):
34 return
35
36 # More than just a deletion happend
37 if self.env["runtime"]["ScreenManager"].is_delta(ignoreSpace=True):
38 return
39
40 # no deletion
41 if not self.env["runtime"]["ScreenManager"].is_negative_delta():
42 return
43
44 # too much for a single backspace...
45 # word begin produce a diff wiht len == 2 |a | others with 1 |a|
46 if len(self.env["screen"]["newNegativeDelta"]) > 2:
47 return
48
49 curr_negative_delta = self.env["screen"]["newNegativeDelta"]
50 if (
51 len(curr_negative_delta.strip()) != len(curr_negative_delta)
52 and curr_negative_delta.strip() != ""
53 ):
54 curr_negative_delta = curr_negative_delta.strip()
55 self.env["runtime"]["OutputManager"].present_text(
56 curr_negative_delta,
57 interrupt=True,
58 ignore_punctuation=True,
59 announce_capital=True,
60 flush=False,
61 )
62
63 def set_callback(self, callback):
64 pass