Debian Codegraph @

src/fenrirscreenreader/commands/onCursorChange/85000-has_attribute.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 from fenrirscreenreader.core.i18n import _
8 from fenrirscreenreader.utils import screen_utils
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 _("Reads attributes of current cursor position")
23
24 def run(self):
25 # is it enabled?
26 if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
27 "general", "hasattributes"
28 ):
29 return
30 # is a vertical change?
31 if not (
32 self.env["runtime"]["CursorManager"].is_cursor_vertical_move()
33 or self.env["runtime"]["CursorManager"].is_cursor_horizontal_move()
34 ):
35 return
36
37 cursor_pos = self.env["screen"]["new_cursor"]
38
39 if not self.env["runtime"]["AttributeManager"].has_attributes(
40 cursor_pos
41 ):
42 return
43 self.env["runtime"]["OutputManager"].present_text(
44 "has attribute", sound_icon="HasAttributes", interrupt=False
45 )
46
47 def set_callback(self, callback):
48 pass