Compare commits
6 Commits
b9518f52ec
...
testing
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cb83632f9 | |||
| 0c4fe50606 | |||
| 15f2435749 | |||
| 3897b63068 | |||
| f1a8e6af21 | |||
| bd54ec0edb |
@@ -736,7 +736,7 @@ send_fenrir_command("setting set speech#rate=0.9")
|
|||||||
|
|
||||||
**Commands not working:**
|
**Commands not working:**
|
||||||
- Verify `enable_command_remote=True` in settings
|
- Verify `enable_command_remote=True` in settings
|
||||||
- Check Fenrir debug logs: `/var/log/fenrir.log`
|
- Check Fenrir debug logs: `/tmp/fenrir.log`
|
||||||
- Test with simple command: `echo "command interrupt" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock`
|
- Test with simple command: `echo "command interrupt" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock`
|
||||||
|
|
||||||
## Command Line Options
|
## Command Line Options
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ https://git.stormux.org/storm/fenrir/issues
|
|||||||
|
|
||||||
For bugs, please provide a debug file that shows the issue.
|
For bugs, please provide a debug file that shows the issue.
|
||||||
How to create a debug file:
|
How to create a debug file:
|
||||||
1. first delete old stuff:
|
1. start fenrir in debug mode
|
||||||
sudo rm /var/log/fenrir.log
|
|
||||||
2. start fenrir in debug mode
|
|
||||||
sudo fenrir -d
|
sudo fenrir -d
|
||||||
<do your stuff>
|
<do your stuff>
|
||||||
3.
|
2.
|
||||||
stop fenrir (fenrirKey + q)
|
stop fenrir (fenrirKey + q)
|
||||||
the debug file is in /var/log/fenrir.log
|
the debug file is in /tmp/fenrir.log
|
||||||
|
if another Fenrir debug instance is already using it, check /tmp/fenrir2.log,
|
||||||
|
/tmp/fenrir3.log, etc.
|
||||||
|
|
||||||
please be as precise as possible to make it easy to solve the problem.
|
please be as precise as possible to make it easy to solve the problem.
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ double_tap_timeout=0.2
|
|||||||
# The default is 0, no logging.
|
# The default is 0, no logging.
|
||||||
debug_level=0
|
debug_level=0
|
||||||
# debugMode sets where the debug output should send to:
|
# debugMode sets where the debug output should send to:
|
||||||
# debugMode=File writes to debug_file (Default:/tmp/fenrir-PID.log)
|
# debugMode=File writes to debug_file (Default:/tmp/fenrir.log)
|
||||||
|
# If the default log is already in use, Fenrir uses /tmp/fenrir2.log, etc.
|
||||||
# debugMode=Print just prints on the screen
|
# debugMode=Print just prints on the screen
|
||||||
debug_mode=File
|
debug_mode=File
|
||||||
debug_file=
|
debug_file=
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ sudo ./fenrir -f -d -p
|
|||||||
|
|
||||||
# Debug output goes to:
|
# Debug output goes to:
|
||||||
# - Console (with -p flag)
|
# - Console (with -p flag)
|
||||||
# - /var/log/fenrir.log
|
# - /tmp/fenrir.log
|
||||||
```
|
```
|
||||||
|
|
||||||
## Creating Commands
|
## Creating Commands
|
||||||
|
|||||||
+4
-2
@@ -50,7 +50,9 @@ Multiple settings can be separated by semicolons.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-d ", " \-\-debug
|
.BR \-d ", " \-\-debug
|
||||||
Enable debug mode. Debug information will be logged to /var/log/fenrir.log.
|
Enable debug mode. Debug information will be logged to /tmp/fenrir.log by
|
||||||
|
default. If another Fenrir debug instance is already using it, Fenrir uses
|
||||||
|
/tmp/fenrir2.log, /tmp/fenrir3.log, etc.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-p ", " \-\-print
|
.BR \-p ", " \-\-print
|
||||||
@@ -476,7 +478,7 @@ User sound themes
|
|||||||
User scripts
|
User scripts
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B /var/log/fenrir.log
|
.B /tmp/fenrir.log
|
||||||
Debug log file
|
Debug log file
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
+3
-3
@@ -2276,13 +2276,13 @@ that shows the issue.
|
|||||||
|
|
||||||
==== How-to create a debug file
|
==== How-to create a debug file
|
||||||
|
|
||||||
. Delete old debug stuff +
|
|
||||||
`+sudo rm /var/log/fenrir.log+`
|
|
||||||
. Start fenrir in debug mode +
|
. Start fenrir in debug mode +
|
||||||
`+sudo fenrir -d+`
|
`+sudo fenrir -d+`
|
||||||
. Do your stuff to reproduce the problem
|
. Do your stuff to reproduce the problem
|
||||||
. Stop fenrir (`+fenrirKey + q+`)
|
. Stop fenrir (`+fenrirKey + q+`)
|
||||||
|
|
||||||
the debug file is located in `+/var/log/fenrir.log+`
|
the debug file is located in `+/tmp/fenrir.log+`. If another Fenrir debug
|
||||||
|
instance is already using it, check `+/tmp/fenrir2.log+`,
|
||||||
|
`+/tmp/fenrir3.log+`, etc.
|
||||||
|
|
||||||
Please be as precise as possible to make it easy to solve the problem.
|
Please be as precise as possible to make it easy to solve the problem.
|
||||||
|
|||||||
+1
-1
@@ -428,7 +428,7 @@ For a dedicated PTY/terminal screen reader, see TDSR: https://github.com/tspivey
|
|||||||
### Debug Mode
|
### Debug Mode
|
||||||
```bash
|
```bash
|
||||||
sudo fenrir -f -d
|
sudo fenrir -f -d
|
||||||
# Debug output goes to /var/log/fenrir.log
|
# Debug output goes to /tmp/fenrir.log
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting Help
|
## Getting Help
|
||||||
|
|||||||
+3
-2
@@ -1315,10 +1315,11 @@ Please report Bugs and feature requests to:
|
|||||||
|
|
||||||
for bugs please provide a [[#Howto create a debug file|debug]] file that shows the issue.
|
for bugs please provide a [[#Howto create a debug file|debug]] file that shows the issue.
|
||||||
==== How-to create a debug file ====
|
==== How-to create a debug file ====
|
||||||
- Delete old debug stuff\\ ''sudo rm /var/log/fenrir.log''
|
|
||||||
- Start fenrir in debug mode\\ ''sudo fenrir -d''
|
- Start fenrir in debug mode\\ ''sudo fenrir -d''
|
||||||
- Do your stuff to reproduce the problem
|
- Do your stuff to reproduce the problem
|
||||||
- Stop fenrir (''fenrirKey + q'')
|
- Stop fenrir (''fenrirKey + q'')
|
||||||
the debug file is located in ''/var/log/fenrir.log''
|
the debug file is located in ''/tmp/fenrir.log''. If another Fenrir debug
|
||||||
|
instance is already using it, check ''/tmp/fenrir2.log'',
|
||||||
|
''/tmp/fenrir3.log'', etc.
|
||||||
|
|
||||||
Please be as precise as possible to make it easy to solve the problem.
|
Please be as precise as possible to make it easy to solve the problem.
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ class command:
|
|||||||
"review", "end_of_screen"
|
"review", "end_of_screen"
|
||||||
):
|
):
|
||||||
self.env["runtime"]["OutputManager"].present_text(
|
self.env["runtime"]["OutputManager"].present_text(
|
||||||
_("end of screen"),
|
_("start of screen"),
|
||||||
interrupt=True,
|
interrupt=True,
|
||||||
sound_icon="EndOfScreen",
|
sound_icon="StartOfScreen",
|
||||||
)
|
)
|
||||||
if line_break:
|
if line_break:
|
||||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ class command:
|
|||||||
"review", "end_of_screen"
|
"review", "end_of_screen"
|
||||||
):
|
):
|
||||||
self.env["runtime"]["OutputManager"].present_text(
|
self.env["runtime"]["OutputManager"].present_text(
|
||||||
_("end of screen"),
|
_("start of screen"),
|
||||||
interrupt=True,
|
interrupt=True,
|
||||||
sound_icon="EndOfScreen",
|
sound_icon="StartOfScreen",
|
||||||
)
|
)
|
||||||
if line_break:
|
if line_break:
|
||||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ class command:
|
|||||||
"review", "end_of_screen"
|
"review", "end_of_screen"
|
||||||
):
|
):
|
||||||
self.env["runtime"]["OutputManager"].present_text(
|
self.env["runtime"]["OutputManager"].present_text(
|
||||||
_("end of screen"),
|
_("start of screen"),
|
||||||
interrupt=True,
|
interrupt=True,
|
||||||
sound_icon="EndOfScreen",
|
sound_icon="StartOfScreen",
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_callback(self, callback):
|
def set_callback(self, callback):
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ class command:
|
|||||||
"review", "end_of_screen"
|
"review", "end_of_screen"
|
||||||
):
|
):
|
||||||
self.env["runtime"]["OutputManager"].present_text(
|
self.env["runtime"]["OutputManager"].present_text(
|
||||||
_("end of screen"),
|
_("start of screen"),
|
||||||
interrupt=False,
|
interrupt=False,
|
||||||
sound_icon="EndOfScreen",
|
sound_icon="StartOfScreen",
|
||||||
)
|
)
|
||||||
if line_break:
|
if line_break:
|
||||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ class command:
|
|||||||
"review", "end_of_screen"
|
"review", "end_of_screen"
|
||||||
):
|
):
|
||||||
self.env["runtime"]["OutputManager"].present_text(
|
self.env["runtime"]["OutputManager"].present_text(
|
||||||
_("end of screen"),
|
_("start of screen"),
|
||||||
interrupt=True,
|
interrupt=True,
|
||||||
sound_icon="EndOfScreen",
|
sound_icon="StartOfScreen",
|
||||||
)
|
)
|
||||||
if line_break:
|
if line_break:
|
||||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ class command:
|
|||||||
"review", "end_of_screen"
|
"review", "end_of_screen"
|
||||||
):
|
):
|
||||||
self.env["runtime"]["OutputManager"].present_text(
|
self.env["runtime"]["OutputManager"].present_text(
|
||||||
_("end of screen"),
|
_("start of screen"),
|
||||||
interrupt=True,
|
interrupt=True,
|
||||||
sound_icon="EndOfScreen",
|
sound_icon="StartOfScreen",
|
||||||
)
|
)
|
||||||
if line_break:
|
if line_break:
|
||||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||||
|
|||||||
@@ -3,24 +3,22 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import fcntl
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from fenrirscreenreader.core import debug
|
from fenrirscreenreader.core import debug
|
||||||
|
|
||||||
|
|
||||||
class DebugManager:
|
class DebugManager:
|
||||||
|
DEFAULT_LOG_DIR = "/tmp"
|
||||||
|
DEFAULT_LOG_BASENAME = "fenrir"
|
||||||
|
DEFAULT_LOG_EXTENSION = ".log"
|
||||||
|
|
||||||
def __init__(self, file_name=""):
|
def __init__(self, file_name=""):
|
||||||
self._file = None
|
self._file = None
|
||||||
self._fileOpened = False
|
self._fileOpened = False
|
||||||
self._fileName = (
|
self._fileName = file_name
|
||||||
"/tmp/fenrir_"
|
self._useDefaultLogName = file_name == ""
|
||||||
+ str(os.getpid())
|
|
||||||
+ "_"
|
|
||||||
+ str(datetime.utcnow().strftime("%Y-%m-%d_%H-%M-%S"))
|
|
||||||
+ ".log"
|
|
||||||
)
|
|
||||||
if file_name != "":
|
|
||||||
self._fileName = file_name
|
|
||||||
|
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
@@ -39,6 +37,10 @@ class DebugManager:
|
|||||||
self._fileOpened = False
|
self._fileOpened = False
|
||||||
if file_name != "":
|
if file_name != "":
|
||||||
self._fileName = file_name
|
self._fileName = file_name
|
||||||
|
self._useDefaultLogName = False
|
||||||
|
if self._useDefaultLogName:
|
||||||
|
self._open_default_debug_file()
|
||||||
|
return
|
||||||
if self._fileName != "":
|
if self._fileName != "":
|
||||||
directory = os.path.dirname(self._fileName)
|
directory = os.path.dirname(self._fileName)
|
||||||
if not os.path.exists(directory):
|
if not os.path.exists(directory):
|
||||||
@@ -51,6 +53,43 @@ class DebugManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
def _open_default_debug_file(self):
|
||||||
|
pathlib.Path(self.DEFAULT_LOG_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
|
log_number = 1
|
||||||
|
while True:
|
||||||
|
log_file = self._default_log_file_name(log_number)
|
||||||
|
try:
|
||||||
|
fd = os.open(
|
||||||
|
log_file,
|
||||||
|
os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW,
|
||||||
|
0o644,
|
||||||
|
)
|
||||||
|
file_obj = os.fdopen(fd, "a")
|
||||||
|
fcntl.flock(file_obj.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
|
file_obj.seek(0)
|
||||||
|
file_obj.truncate()
|
||||||
|
os.chmod(log_file, 0o644)
|
||||||
|
self._file = file_obj
|
||||||
|
self._fileName = log_file
|
||||||
|
self._fileOpened = True
|
||||||
|
return
|
||||||
|
except BlockingIOError:
|
||||||
|
try:
|
||||||
|
file_obj.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
log_number += 1
|
||||||
|
except OSError as e:
|
||||||
|
print(e)
|
||||||
|
return
|
||||||
|
|
||||||
|
def _default_log_file_name(self, log_number):
|
||||||
|
suffix = "" if log_number == 1 else str(log_number)
|
||||||
|
return os.path.join(
|
||||||
|
self.DEFAULT_LOG_DIR,
|
||||||
|
self.DEFAULT_LOG_BASENAME + suffix + self.DEFAULT_LOG_EXTENSION,
|
||||||
|
)
|
||||||
|
|
||||||
def write_debug_out(
|
def write_debug_out(
|
||||||
self, text, level=debug.DebugLevel.DEACTIVE, on_any_level=False
|
self, text, level=debug.DebugLevel.DEACTIVE, on_any_level=False
|
||||||
):
|
):
|
||||||
@@ -120,3 +159,4 @@ class DebugManager:
|
|||||||
def set_debug_file(self, file_name):
|
def set_debug_file(self, file_name):
|
||||||
self.close_debug_file()
|
self.close_debug_file()
|
||||||
self._fileName = file_name
|
self._fileName = file_name
|
||||||
|
self._useDefaultLogName = file_name == ""
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
|
from argparse import Namespace
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
|
||||||
from fenrirscreenreader.core import applicationManager
|
from fenrirscreenreader.core import applicationManager
|
||||||
@@ -67,6 +68,15 @@ class SettingsManager:
|
|||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def format_cli_args(self, cliArgs):
|
||||||
|
if cliArgs is None:
|
||||||
|
return "{}"
|
||||||
|
if isinstance(cliArgs, Namespace):
|
||||||
|
args = vars(cliArgs)
|
||||||
|
else:
|
||||||
|
args = vars(cliArgs) if hasattr(cliArgs, "__dict__") else {}
|
||||||
|
return str({key: args[key] for key in sorted(args)})
|
||||||
|
|
||||||
def get_binding_backup(self):
|
def get_binding_backup(self):
|
||||||
return self.bindingsBackup.copy()
|
return self.bindingsBackup.copy()
|
||||||
|
|
||||||
@@ -644,6 +654,11 @@ class SettingsManager:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
environment["runtime"]["DebugManager"].initialize(environment)
|
environment["runtime"]["DebugManager"].initialize(environment)
|
||||||
|
environment["runtime"]["DebugManager"].write_debug_out(
|
||||||
|
"Fenrir startup CLI arguments: " + self.format_cli_args(cliArgs),
|
||||||
|
debug.DebugLevel.INFO,
|
||||||
|
on_any_level=True,
|
||||||
|
)
|
||||||
|
|
||||||
if cliArgs.force_all_screens:
|
if cliArgs.force_all_screens:
|
||||||
environment["runtime"]["force_all_screens"] = True
|
environment["runtime"]["force_all_screens"] = True
|
||||||
|
|||||||
@@ -132,13 +132,6 @@ class TabCompletionManager:
|
|||||||
if candidate_text:
|
if candidate_text:
|
||||||
return self._clean_text(candidate_text)
|
return self._clean_text(candidate_text)
|
||||||
|
|
||||||
delta_text = self.env["screen"]["new_delta"]
|
|
||||||
if (
|
|
||||||
delta_text
|
|
||||||
and not self.env["screen"].get("new_delta_is_typing", False)
|
|
||||||
):
|
|
||||||
return self._clean_text(delta_text)
|
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def _get_cursor_line_inserted_text(
|
def _get_cursor_line_inserted_text(
|
||||||
@@ -184,26 +177,19 @@ class TabCompletionManager:
|
|||||||
return "".join(inserted_parts)
|
return "".join(inserted_parts)
|
||||||
|
|
||||||
def _get_candidate_text(self, old_lines, new_lines, cursor_y):
|
def _get_candidate_text(self, old_lines, new_lines, cursor_y):
|
||||||
if len(old_lines) != len(new_lines):
|
|
||||||
return self._get_inserted_lines(old_lines, new_lines, cursor_y)
|
|
||||||
|
|
||||||
changed_lines = []
|
|
||||||
old_cursor_line = (
|
old_cursor_line = (
|
||||||
old_lines[cursor_y].strip() if cursor_y < len(old_lines) else ""
|
old_lines[cursor_y].strip() if cursor_y < len(old_lines) else ""
|
||||||
)
|
)
|
||||||
for index, old_line in enumerate(old_lines):
|
return self._get_inserted_lines(
|
||||||
if index == cursor_y:
|
old_lines,
|
||||||
continue
|
new_lines,
|
||||||
if index < len(new_lines) and old_line != new_lines[index]:
|
self.env["screen"]["new_cursor"]["y"],
|
||||||
if new_lines[index].strip() == old_cursor_line:
|
old_cursor_line,
|
||||||
continue
|
|
||||||
changed_lines.append(new_lines[index])
|
|
||||||
|
|
||||||
return "\n".join(
|
|
||||||
line.rstrip() for line in changed_lines if line.strip()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _get_inserted_lines(self, old_lines, new_lines, cursor_y):
|
def _get_inserted_lines(
|
||||||
|
self, old_lines, new_lines, new_cursor_y, old_cursor_line
|
||||||
|
):
|
||||||
matcher = difflib.SequenceMatcher(
|
matcher = difflib.SequenceMatcher(
|
||||||
None, old_lines, new_lines, autojunk=False
|
None, old_lines, new_lines, autojunk=False
|
||||||
)
|
)
|
||||||
@@ -217,10 +203,15 @@ class TabCompletionManager:
|
|||||||
) in matcher.get_opcodes():
|
) in matcher.get_opcodes():
|
||||||
if tag not in ["insert", "replace"]:
|
if tag not in ["insert", "replace"]:
|
||||||
continue
|
continue
|
||||||
if new_end <= cursor_y:
|
if new_start > new_cursor_y:
|
||||||
|
continue
|
||||||
|
if tag == "replace" and any(
|
||||||
|
line.strip() for line in old_lines[old_start:old_end]
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
for line in new_lines[new_start:new_end]:
|
for line in new_lines[new_start:new_end]:
|
||||||
if line.strip():
|
stripped_line = line.strip()
|
||||||
|
if stripped_line and stripped_line != old_cursor_line:
|
||||||
inserted_lines.append(line.rstrip())
|
inserted_lines.append(line.rstrip())
|
||||||
return "\n".join(inserted_lines)
|
return "\n".join(inserted_lines)
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,5 @@
|
|||||||
# Fenrir TTY screen reader
|
# Fenrir TTY screen reader
|
||||||
# By Chrys, Storm Dragon, and contributors.
|
# By Chrys, Storm Dragon, and contributors.
|
||||||
|
|
||||||
version = "2026.05.24"
|
version = "2026.05.31"
|
||||||
code_name = "testing"
|
code_name = "testing"
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ class driver(inputDriver):
|
|||||||
self.fenrir_keys = set()
|
self.fenrir_keys = set()
|
||||||
self.failed_grabs = 0
|
self.failed_grabs = 0
|
||||||
self.modifier_state = 0
|
self.modifier_state = 0
|
||||||
|
self.modifier_interrupt_state = 0
|
||||||
|
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
@@ -194,6 +195,7 @@ class driver(inputDriver):
|
|||||||
)
|
)
|
||||||
self.num_lock_mask = self.find_num_lock_mask()
|
self.num_lock_mask = self.find_num_lock_mask()
|
||||||
self.refresh_modifier_state()
|
self.refresh_modifier_state()
|
||||||
|
self.modifier_interrupt_state = self.modifier_state
|
||||||
self.refresh_interesting_keys()
|
self.refresh_interesting_keys()
|
||||||
self.refresh_grabs(force=True)
|
self.refresh_grabs(force=True)
|
||||||
self.env["runtime"]["ProcessManager"].add_custom_event_thread(
|
self.env["runtime"]["ProcessManager"].add_custom_event_thread(
|
||||||
@@ -274,6 +276,7 @@ class driver(inputDriver):
|
|||||||
while active.value:
|
while active.value:
|
||||||
try:
|
try:
|
||||||
self.refresh_grabs()
|
self.refresh_grabs()
|
||||||
|
self.poll_modifier_interrupt_keys()
|
||||||
if not self.display.pending_events():
|
if not self.display.pending_events():
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
continue
|
continue
|
||||||
@@ -371,6 +374,56 @@ class driver(inputDriver):
|
|||||||
"event_x_time": getattr(event, "time", X.CurrentTime),
|
"event_x_time": getattr(event, "time", X.CurrentTime),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def poll_modifier_interrupt_keys(self):
|
||||||
|
if not self.active or not self.should_poll_modifier_interrupt_keys():
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
pointer = self.root.query_pointer()
|
||||||
|
current_state = getattr(pointer, "mask", 0)
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
previous_state = self.modifier_interrupt_state
|
||||||
|
self.modifier_interrupt_state = current_state
|
||||||
|
self.modifier_state = current_state
|
||||||
|
for key_name, modifier_mask in self.interrupt_modifier_masks():
|
||||||
|
if current_state & modifier_mask and not previous_state & modifier_mask:
|
||||||
|
self.interrupt_output_on_modifier_key(key_name)
|
||||||
|
|
||||||
|
def should_poll_modifier_interrupt_keys(self):
|
||||||
|
try:
|
||||||
|
settings_manager = self.env["runtime"]["SettingsManager"]
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
if not settings_manager.get_setting_as_bool(
|
||||||
|
"keyboard", "interrupt_on_key_press"
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
return (
|
||||||
|
settings_manager.get_setting(
|
||||||
|
"keyboard", "interrupt_on_key_press_filter"
|
||||||
|
).strip()
|
||||||
|
== ""
|
||||||
|
)
|
||||||
|
|
||||||
|
def interrupt_modifier_masks(self):
|
||||||
|
return [
|
||||||
|
("KEY_CTRL", X.ControlMask),
|
||||||
|
("KEY_SHIFT", X.ShiftMask),
|
||||||
|
("KEY_ALT", X.Mod1Mask),
|
||||||
|
]
|
||||||
|
|
||||||
|
def interrupt_output_on_modifier_key(self, key_name):
|
||||||
|
try:
|
||||||
|
self.env["runtime"]["OutputManager"].interrupt_output_async()
|
||||||
|
except Exception as e:
|
||||||
|
self.env["runtime"]["DebugManager"].write_debug_out(
|
||||||
|
"x11Driver modifier interrupt failed for "
|
||||||
|
+ key_name
|
||||||
|
+ ": "
|
||||||
|
+ str(e),
|
||||||
|
debug.DebugLevel.ERROR,
|
||||||
|
)
|
||||||
|
|
||||||
def refresh_modifier_state(self):
|
def refresh_modifier_state(self):
|
||||||
try:
|
try:
|
||||||
pointer = self.root.query_pointer()
|
pointer = self.root.query_pointer()
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ def get_up_char(curr_x, curr_y, curr_text):
|
|||||||
curr_y -= 1
|
curr_y -= 1
|
||||||
if curr_y < 0:
|
if curr_y < 0:
|
||||||
curr_y = 0
|
curr_y = 0
|
||||||
else:
|
|
||||||
end_of_screen = True
|
end_of_screen = True
|
||||||
curr_char = ""
|
curr_char = ""
|
||||||
if not end_of_screen:
|
if not end_of_screen:
|
||||||
@@ -63,7 +62,6 @@ def get_down_char(curr_x, curr_y, curr_text):
|
|||||||
curr_y += 1
|
curr_y += 1
|
||||||
if curr_y >= len(wrapped_lines):
|
if curr_y >= len(wrapped_lines):
|
||||||
curr_y = len(wrapped_lines) - 1
|
curr_y = len(wrapped_lines) - 1
|
||||||
else:
|
|
||||||
end_of_screen = True
|
end_of_screen = True
|
||||||
curr_char = ""
|
curr_char = ""
|
||||||
if not end_of_screen:
|
if not end_of_screen:
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
from fenrirscreenreader.core.debugManager import DebugManager
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_debug_file_uses_flat_name(tmp_path, monkeypatch):
|
||||||
|
monkeypatch.setattr(DebugManager, "DEFAULT_LOG_DIR", str(tmp_path))
|
||||||
|
manager = DebugManager()
|
||||||
|
try:
|
||||||
|
manager.open_debug_file()
|
||||||
|
|
||||||
|
assert manager.get_debug_file() == str(tmp_path / "fenrir.log")
|
||||||
|
assert (tmp_path / "fenrir.log").exists()
|
||||||
|
finally:
|
||||||
|
manager.close_debug_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_debug_file_uses_next_number_when_locked(
|
||||||
|
tmp_path, monkeypatch
|
||||||
|
):
|
||||||
|
monkeypatch.setattr(DebugManager, "DEFAULT_LOG_DIR", str(tmp_path))
|
||||||
|
first_manager = DebugManager()
|
||||||
|
second_manager = DebugManager()
|
||||||
|
try:
|
||||||
|
first_manager.open_debug_file()
|
||||||
|
second_manager.open_debug_file()
|
||||||
|
|
||||||
|
assert first_manager.get_debug_file() == str(tmp_path / "fenrir.log")
|
||||||
|
assert second_manager.get_debug_file() == str(
|
||||||
|
tmp_path / "fenrir2.log"
|
||||||
|
)
|
||||||
|
assert (tmp_path / "fenrir2.log").exists()
|
||||||
|
finally:
|
||||||
|
second_manager.close_debug_file()
|
||||||
|
first_manager.close_debug_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_debug_file_reuses_unlocked_flat_name(tmp_path, monkeypatch):
|
||||||
|
monkeypatch.setattr(DebugManager, "DEFAULT_LOG_DIR", str(tmp_path))
|
||||||
|
first_manager = DebugManager()
|
||||||
|
second_manager = DebugManager()
|
||||||
|
try:
|
||||||
|
first_manager.open_debug_file()
|
||||||
|
first_manager.close_debug_file()
|
||||||
|
second_manager.open_debug_file()
|
||||||
|
|
||||||
|
assert second_manager.get_debug_file() == str(tmp_path / "fenrir.log")
|
||||||
|
finally:
|
||||||
|
second_manager.close_debug_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_explicit_debug_file_uses_exact_path(tmp_path):
|
||||||
|
debug_file = tmp_path / "custom.log"
|
||||||
|
manager = DebugManager(str(debug_file))
|
||||||
|
try:
|
||||||
|
manager.open_debug_file()
|
||||||
|
|
||||||
|
assert manager.get_debug_file() == str(debug_file)
|
||||||
|
assert debug_file.exists()
|
||||||
|
finally:
|
||||||
|
manager.close_debug_file()
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
import importlib.util
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import Mock
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from fenrirscreenreader.utils import char_utils
|
||||||
|
|
||||||
|
|
||||||
|
COMMANDS_DIR = (
|
||||||
|
Path(__file__).resolve().parents[2]
|
||||||
|
/ "src"
|
||||||
|
/ "fenrirscreenreader"
|
||||||
|
/ "commands"
|
||||||
|
/ "commands"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def load_command(name):
|
||||||
|
spec = importlib.util.spec_from_file_location(
|
||||||
|
f"fenrir_{name}", COMMANDS_DIR / f"{name}.py"
|
||||||
|
)
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
return module.command()
|
||||||
|
|
||||||
|
|
||||||
|
def build_environment(cursor):
|
||||||
|
settings_manager = Mock()
|
||||||
|
settings_manager.get_setting_as_bool.return_value = True
|
||||||
|
output_manager = Mock()
|
||||||
|
cursor_manager = Mock()
|
||||||
|
cursor_manager.enter_review_mode_curr_text_cursor.return_value = None
|
||||||
|
cursor_manager.get_review_or_text_cursor.return_value = cursor
|
||||||
|
|
||||||
|
return {
|
||||||
|
"punctuation": {"PUNCTDICT": {" ": "space"}},
|
||||||
|
"screen": {
|
||||||
|
"newCursorReview": cursor.copy(),
|
||||||
|
"new_cursor": cursor.copy(),
|
||||||
|
"new_content_text": "abc\ndef",
|
||||||
|
},
|
||||||
|
"runtime": {
|
||||||
|
"AttributeManager": Mock(has_attributes=Mock(return_value=False)),
|
||||||
|
"CursorManager": cursor_manager,
|
||||||
|
"OutputManager": output_manager,
|
||||||
|
"SettingsManager": settings_manager,
|
||||||
|
"TableManager": Mock(is_table_mode=Mock(return_value=False)),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def run_command(name, cursor):
|
||||||
|
env = build_environment(cursor)
|
||||||
|
command = load_command(name)
|
||||||
|
command.initialize(env)
|
||||||
|
command.run()
|
||||||
|
return env["runtime"]["OutputManager"]
|
||||||
|
|
||||||
|
|
||||||
|
def boundary_call(output_manager):
|
||||||
|
return output_manager.present_text.call_args_list[-1]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_previous_line_uses_start_of_screen_sound_at_top():
|
||||||
|
output_manager = run_command("review_prev_line", {"x": 0, "y": 0})
|
||||||
|
|
||||||
|
call = boundary_call(output_manager)
|
||||||
|
assert call.args[0] == "start of screen"
|
||||||
|
assert call.kwargs["sound_icon"] == "StartOfScreen"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_next_line_uses_end_of_screen_sound_at_bottom():
|
||||||
|
output_manager = run_command("review_next_line", {"x": 0, "y": 1})
|
||||||
|
|
||||||
|
call = boundary_call(output_manager)
|
||||||
|
assert call.args[0] == "end of screen"
|
||||||
|
assert call.kwargs["sound_icon"] == "EndOfScreen"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_previous_character_uses_start_of_screen_sound_at_top_left():
|
||||||
|
output_manager = run_command("review_prev_char", {"x": 0, "y": 0})
|
||||||
|
|
||||||
|
call = boundary_call(output_manager)
|
||||||
|
assert call.args[0] == "start of screen"
|
||||||
|
assert call.kwargs["sound_icon"] == "StartOfScreen"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_next_character_uses_end_of_screen_sound_at_bottom_right():
|
||||||
|
output_manager = run_command("review_next_char", {"x": 2, "y": 1})
|
||||||
|
|
||||||
|
call = boundary_call(output_manager)
|
||||||
|
assert call.args[0] == "end of screen"
|
||||||
|
assert call.kwargs["sound_icon"] == "EndOfScreen"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_vertical_character_navigation_reports_boundaries_only_at_edges():
|
||||||
|
assert char_utils.get_up_char(0, 1, "abc\ndef") == (
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
"a",
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
assert char_utils.get_up_char(0, 0, "abc\ndef") == (
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
"",
|
||||||
|
True,
|
||||||
|
)
|
||||||
|
assert char_utils.get_down_char(0, 0, "abc\ndef") == (
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
"d",
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
assert char_utils.get_down_char(0, 1, "abc\ndef") == (
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
"",
|
||||||
|
True,
|
||||||
|
)
|
||||||
@@ -5,6 +5,8 @@ Tests the _validate_setting_value method to ensure proper input validation
|
|||||||
for all configurable settings that could cause crashes or accessibility issues.
|
for all configurable settings that could cause crashes or accessibility issues.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from argparse import Namespace
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -206,6 +208,30 @@ def test_focus_settings_define_tui_toggle():
|
|||||||
assert settings_data["focus"]["tui"] is False
|
assert settings_data["focus"]["tui"] is False
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
@pytest.mark.settings
|
||||||
|
def test_format_cli_args_reports_startup_flags_in_stable_order():
|
||||||
|
manager = SettingsManager()
|
||||||
|
cli_args = Namespace(
|
||||||
|
debug=True,
|
||||||
|
foreground=False,
|
||||||
|
force_all_screens=False,
|
||||||
|
ignore_screen=["7"],
|
||||||
|
options="speech#rate=1.2",
|
||||||
|
print=False,
|
||||||
|
setting="/tmp/settings.conf",
|
||||||
|
x11=True,
|
||||||
|
x11_window_id="0x123",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert manager.format_cli_args(cli_args) == (
|
||||||
|
"{'debug': True, 'force_all_screens': False, 'foreground': False, "
|
||||||
|
"'ignore_screen': ['7'], 'options': 'speech#rate=1.2', "
|
||||||
|
"'print': False, 'setting': '/tmp/settings.conf', 'x11': True, "
|
||||||
|
"'x11_window_id': '0x123'}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
@pytest.mark.settings
|
@pytest.mark.settings
|
||||||
class TestSettingsPathSelection:
|
class TestSettingsPathSelection:
|
||||||
|
|||||||
@@ -140,6 +140,93 @@ def test_candidate_list_speaks_visible_list_without_cursor_advance():
|
|||||||
assert manager.process_update() == "Documents/ Downloads/"
|
assert manager.process_update() == "Documents/ Downloads/"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_full_screen_scroll_speaks_only_inserted_candidate_list():
|
||||||
|
old_text = "\n".join(
|
||||||
|
[
|
||||||
|
"old top".ljust(30),
|
||||||
|
"old middle".ljust(30),
|
||||||
|
"old lower".ljust(30),
|
||||||
|
"old bottom".ljust(30),
|
||||||
|
"$ ./Toby".ljust(30),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
manager, env, _input_manager = _build_env(old_text, {"x": 8, "y": 4})
|
||||||
|
|
||||||
|
manager.capture_if_tab()
|
||||||
|
_set_screen_update(
|
||||||
|
env,
|
||||||
|
"\n".join(
|
||||||
|
[
|
||||||
|
"old middle".ljust(30),
|
||||||
|
"old lower".ljust(30),
|
||||||
|
"old bottom".ljust(30),
|
||||||
|
"TobyAccMod_V10-0.pk3 TobyConfig.ini".ljust(30),
|
||||||
|
"$ ./Toby".ljust(30),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
{"x": 8, "y": 4},
|
||||||
|
delta="\n".join(
|
||||||
|
[
|
||||||
|
"old middle",
|
||||||
|
"old lower",
|
||||||
|
"old bottom",
|
||||||
|
"TobyAccMod_V10-0.pk3 TobyConfig.ini",
|
||||||
|
"$ ./Toby",
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert manager.process_update() == "TobyAccMod_V10-0.pk3 TobyConfig.ini"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_same_height_repaint_without_inserted_candidates_stays_silent():
|
||||||
|
old_text = "\n".join(
|
||||||
|
[
|
||||||
|
"old top".ljust(30),
|
||||||
|
"old middle".ljust(30),
|
||||||
|
"old lower".ljust(30),
|
||||||
|
"$ ./Toby".ljust(30),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
manager, env, _input_manager = _build_env(old_text, {"x": 8, "y": 3})
|
||||||
|
|
||||||
|
manager.capture_if_tab()
|
||||||
|
_set_screen_update(
|
||||||
|
env,
|
||||||
|
"\n".join(
|
||||||
|
[
|
||||||
|
"status line".ljust(30),
|
||||||
|
"old prompt history".ljust(30),
|
||||||
|
"unrelated output".ljust(30),
|
||||||
|
"$ ./Toby".ljust(30),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
{"x": 8, "y": 3},
|
||||||
|
delta="status line\nold prompt history\nunrelated output\n$ ./Toby",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert manager.process_update() == ""
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_recent_tab_does_not_speak_delta_without_detected_completion():
|
||||||
|
old_text = "\n".join(["$ ./Toby".ljust(20), "".ljust(20)])
|
||||||
|
manager, env, _input_manager = _build_env(old_text, {"x": 8, "y": 0})
|
||||||
|
|
||||||
|
manager.capture_if_tab()
|
||||||
|
_set_screen_update(
|
||||||
|
env,
|
||||||
|
old_text,
|
||||||
|
{"x": 8, "y": 0},
|
||||||
|
delta="old unrelated screen content\n$ ./Toby",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert manager.process_update() == ""
|
||||||
|
assert env["commandBuffer"]["tabCompletion"]["pending"] is not None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
def test_no_screen_change_stays_silent_and_keeps_pending_briefly():
|
def test_no_screen_change_stays_silent_and_keeps_pending_briefly():
|
||||||
manager, env, _input_manager = _build_env(
|
manager, env, _input_manager = _build_env(
|
||||||
|
|||||||
@@ -217,6 +217,47 @@ def test_x11_build_passive_grabs_for_fenrir_keys_and_shortcuts():
|
|||||||
assert ("KEY_BACKSPACE", X.Mod4Mask, True) in grabs
|
assert ("KEY_BACKSPACE", X.Mod4Mask, True) in grabs
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"modifier_mask",
|
||||||
|
[X.ControlMask, X.ShiftMask, X.Mod1Mask],
|
||||||
|
)
|
||||||
|
def test_x11_poll_modifier_interrupt_keys_interrupts_without_input_events(
|
||||||
|
modifier_mask,
|
||||||
|
):
|
||||||
|
x11 = X11Driver()
|
||||||
|
x11.active = True
|
||||||
|
x11.modifier_interrupt_state = 0
|
||||||
|
x11.modifier_state = 0
|
||||||
|
x11.root = Mock()
|
||||||
|
x11.root.query_pointer.return_value = Mock(mask=modifier_mask)
|
||||||
|
settings_manager = Mock()
|
||||||
|
settings_manager.get_setting_as_bool.return_value = True
|
||||||
|
settings_manager.get_setting.return_value = ""
|
||||||
|
output_manager = Mock()
|
||||||
|
x11.env = {
|
||||||
|
"input": {"event_buffer": []},
|
||||||
|
"runtime": {
|
||||||
|
"SettingsManager": settings_manager,
|
||||||
|
"OutputManager": output_manager,
|
||||||
|
"DebugManager": Mock(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
x11.poll_modifier_interrupt_keys()
|
||||||
|
|
||||||
|
output_manager.interrupt_output_async.assert_called_once()
|
||||||
|
assert x11.env["input"]["event_buffer"] == []
|
||||||
|
|
||||||
|
output_manager.interrupt_output_async.reset_mock()
|
||||||
|
x11.root.query_pointer.return_value = Mock(mask=0)
|
||||||
|
|
||||||
|
x11.poll_modifier_interrupt_keys()
|
||||||
|
|
||||||
|
output_manager.interrupt_output_async.assert_not_called()
|
||||||
|
assert x11.env["input"]["event_buffer"] == []
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
def test_x11_optional_modifier_masks_can_exclude_numlock():
|
def test_x11_optional_modifier_masks_can_exclude_numlock():
|
||||||
x11 = X11Driver()
|
x11 = X11Driver()
|
||||||
|
|||||||
Reference in New Issue
Block a user