Initial table mode added. Probably bugs.

This commit is contained in:
Storm Dragon
2025-07-07 09:46:12 -04:00
parent 3390c25dfe
commit d1a42835e4
8 changed files with 527 additions and 26 deletions

View File

@@ -6,6 +6,7 @@
from fenrirscreenreader.core.i18n import _
from fenrirscreenreader.utils import word_utils
from fenrirscreenreader.core import debug
class command:
@@ -38,14 +39,42 @@ class command:
self.env["screen"]["new_content_text"],
)
if curr_word.isspace():
self.env["runtime"]["OutputManager"].present_text(
_("blank"), interrupt=True, flush=False
)
# Check if we're in table mode and provide table-aware output
is_table_mode = self.env["runtime"]["TableManager"].is_table_mode()
self.env["runtime"]["DebugManager"].write_debug_out(
f"review_curr_word: is_table_mode={is_table_mode}",
debug.DebugLevel.INFO
)
if is_table_mode:
# Get current cell info using internal column tracking
table_info = self.env["runtime"]["TableManager"].get_current_table_cell_info()
if table_info:
# Announce with table context - cell content first, then header
output_text = f"{table_info['cell_content']} {table_info['column_header']}"
self.env["runtime"]["OutputManager"].present_text(
output_text, interrupt=True, flush=False
)
return # Exit early for table mode
else:
# Fallback to regular word announcement
if curr_word.isspace():
self.env["runtime"]["OutputManager"].present_text(
_("blank"), interrupt=True, flush=False
)
else:
self.env["runtime"]["OutputManager"].present_text(
curr_word, interrupt=True, flush=False
)
else:
self.env["runtime"]["OutputManager"].present_text(
curr_word, interrupt=True, flush=False
)
# Regular word announcement
if curr_word.isspace():
self.env["runtime"]["OutputManager"].present_text(
_("blank"), interrupt=True, flush=False
)
else:
self.env["runtime"]["OutputManager"].present_text(
curr_word, interrupt=True, flush=False
)
if end_of_screen:
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
"review", "end_of_screen"

View File

@@ -6,6 +6,7 @@
from fenrirscreenreader.core.i18n import _
from fenrirscreenreader.utils import word_utils
from fenrirscreenreader.core import debug
class command:
@@ -22,6 +23,40 @@ class command:
return _("moves review to the next word ")
def run(self):
# Check if we're in table mode FIRST - before any word navigation
is_table_mode = self.env["runtime"]["TableManager"].is_table_mode()
self.env["runtime"]["DebugManager"].write_debug_out(
f"review_next_word: is_table_mode={is_table_mode}",
debug.DebugLevel.INFO
)
if is_table_mode:
table_info = self.env["runtime"]["TableManager"].move_to_next_column()
if table_info and table_info.get("at_end"):
# Stay on current cell and play end of line sound
current_info = table_info["current_info"]
if current_info:
output_text = f"{current_info['cell_content']}"
self.env["runtime"]["OutputManager"].present_text(
output_text, interrupt=True, flush=False
)
# Play end of line sound
self.env["runtime"]["OutputManager"].present_text(
_("end of line"), interrupt=False, sound_icon="EndOfLine"
)
elif table_info:
# Normal column navigation - announce cell content with column info
output_text = f"{table_info['cell_content']} {table_info['column_header']}"
self.env["runtime"]["OutputManager"].present_text(
output_text, interrupt=True, flush=False
)
else:
# No table info available, but still in table mode
self.env["runtime"]["OutputManager"].present_text(
_("no table data"), interrupt=True, flush=False
)
return # ALWAYS return in table mode to prevent regular word navigation
# Regular word navigation (only when NOT in table mode)
self.env["screen"]["oldCursorReview"] = self.env["screen"][
"newCursorReview"
]
@@ -41,7 +76,8 @@ class command:
self.env["screen"]["newCursorReview"]["y"],
self.env["screen"]["new_content_text"],
)
# Regular word announcement
if next_word.isspace():
self.env["runtime"]["OutputManager"].present_text(
_("blank"), interrupt=True, flush=False

View File

@@ -6,6 +6,7 @@
from fenrirscreenreader.core.i18n import _
from fenrirscreenreader.utils import word_utils
from fenrirscreenreader.core import debug
class command:
@@ -22,6 +23,36 @@ class command:
return _("moves review focus to the previous word ")
def run(self):
# Check if we're in table mode FIRST - before any word navigation
is_table_mode = self.env["runtime"]["TableManager"].is_table_mode()
self.env["runtime"]["DebugManager"].write_debug_out(
f"review_prev_word: is_table_mode={is_table_mode}",
debug.DebugLevel.INFO
)
if is_table_mode:
table_info = self.env["runtime"]["TableManager"].move_to_prev_column()
if table_info and table_info.get("at_start"):
# Stay on current cell at beginning of line
current_info = table_info["current_info"]
if current_info:
output_text = f"{current_info['cell_content']} {current_info['column_header']}"
self.env["runtime"]["OutputManager"].present_text(
output_text, interrupt=True, flush=False
)
elif table_info:
# Normal column navigation - announce cell content with column info
output_text = f"{table_info['cell_content']} {table_info['column_header']}"
self.env["runtime"]["OutputManager"].present_text(
output_text, interrupt=True, flush=False
)
else:
# No table info available, but still in table mode
self.env["runtime"]["OutputManager"].present_text(
_("no table data"), interrupt=True, flush=False
)
return # ALWAYS return in table mode to prevent regular word navigation
# Regular word navigation (only when NOT in table mode)
self.env["runtime"][
"CursorManager"
].enter_review_mode_curr_text_cursor()
@@ -37,7 +68,8 @@ class command:
self.env["screen"]["newCursorReview"]["y"],
self.env["screen"]["new_content_text"],
)
# Regular word announcement
if prev_word.isspace():
self.env["runtime"]["OutputManager"].present_text(
_("blank"), interrupt=True, flush=False

View File

@@ -28,6 +28,20 @@ class command:
)
return
# If in table mode, set header row instead of regular mark
if self.env["runtime"]["TableManager"].is_table_mode():
success = self.env["runtime"]["TableManager"].set_header_row_from_cursor()
if success:
self.env["runtime"]["OutputManager"].present_text(
_("header row set"), sound_icon="PlaceStartMark", interrupt=True
)
else:
self.env["runtime"]["OutputManager"].present_text(
_("could not set header row"), interrupt=True
)
return
# Regular mark functionality
curr_mark = self.env["runtime"]["CursorManager"].set_mark()
if curr_mark == 1:
self.env["runtime"]["OutputManager"].present_text(

View File

@@ -5,6 +5,7 @@
# By Chrys, Storm Dragon, and contributors.
from fenrirscreenreader.core.i18n import _
from fenrirscreenreader.core import debug
class command:
@@ -21,26 +22,56 @@ class command:
return _("enables or disables tracking of highlighted text")
def run(self):
curr_mode = self.env["runtime"]["SettingsManager"].get_setting_as_bool(
highlight_mode = self.env["runtime"]["SettingsManager"].get_setting_as_bool(
"focus", "highlight"
)
cursor_mode = self.env["runtime"]["SettingsManager"].get_setting_as_bool(
"focus", "cursor"
)
table_mode = self.env["runtime"]["TableManager"].is_table_mode()
self.env["runtime"]["DebugManager"].write_debug_out(
f"toggle_highlight_tracking: highlight={highlight_mode}, cursor={cursor_mode}, table={table_mode}",
debug.DebugLevel.INFO
)
self.env["runtime"]["SettingsManager"].set_setting(
"focus", "highlight", str(not curr_mode)
)
self.env["runtime"]["SettingsManager"].set_setting(
"focus", "cursor", str(curr_mode)
)
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
"focus", "highlight"
):
self.env["runtime"]["OutputManager"].present_text(
_("highlight tracking"), sound_icon="", interrupt=True
# Cycle through modes: highlight → cursor → table → highlight
if highlight_mode and not table_mode:
# Switch to cursor mode
self.env["runtime"]["SettingsManager"].set_setting(
"focus", "highlight", "False"
)
else:
self.env["runtime"]["SettingsManager"].set_setting(
"focus", "cursor", "True"
)
self.env["runtime"]["TableManager"].set_table_mode(False)
self.env["runtime"]["OutputManager"].present_text(
_("cursor tracking"), sound_icon="", interrupt=True
)
elif cursor_mode and not table_mode:
# Switch to table mode
self.env["runtime"]["SettingsManager"].set_setting(
"focus", "highlight", "False"
)
self.env["runtime"]["SettingsManager"].set_setting(
"focus", "cursor", "False"
)
self.env["runtime"]["TableManager"].set_table_mode(True)
self.env["runtime"]["OutputManager"].present_text(
_("table mode"), sound_icon="", interrupt=True
)
else:
# Switch to highlight mode (default) - also handles stuck table mode
self.env["runtime"]["SettingsManager"].set_setting(
"focus", "highlight", "True"
)
self.env["runtime"]["SettingsManager"].set_setting(
"focus", "cursor", "False"
)
self.env["runtime"]["TableManager"].set_table_mode(False)
self.env["runtime"]["OutputManager"].present_text(
_("highlight tracking"), sound_icon="", interrupt=True
)
def set_callback(self, callback):
pass