mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2026-03-06 01:17:32 +01:00
Add chat support for invisible interface in Bluesky buffers
ChatBuffer now has get_message(), get_formatted_message(), and view_item() so repeat_item, copy_to_clipboard, and view work correctly with chat messages. open_conversation (Ctrl+Win+Alt+C) detects chat buffers and delegates to view_chat(). Opening a chat buffer now announces its name and item count for screen reader feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -554,6 +554,10 @@ class Handler:
|
||||
|
||||
def open_conversation(self, controller, buffer):
|
||||
"""Standard action for Control+Win+C"""
|
||||
# If this is a chat conversation list, open the selected chat
|
||||
if buffer.type == "chat" and hasattr(buffer, "view_chat"):
|
||||
buffer.view_chat()
|
||||
return
|
||||
item = buffer.get_item()
|
||||
if not item:
|
||||
return
|
||||
|
||||
@@ -369,10 +369,21 @@ class ConversationListBuffer(BaseBuffer):
|
||||
start=True
|
||||
)
|
||||
|
||||
# Navigate to the newly created buffer
|
||||
# Navigate to the newly created buffer and announce it
|
||||
new_index = controller.view.search(title, account_name)
|
||||
if new_index is not None:
|
||||
controller.view.change_buffer(new_index)
|
||||
buffer_obj = controller.search_buffer(title, account_name)
|
||||
if buffer_obj and hasattr(buffer_obj.buffer, "list"):
|
||||
try:
|
||||
count = buffer_obj.buffer.list.get_count()
|
||||
if count > 0:
|
||||
msg = _("{0}, {1} of {2}").format(title, buffer_obj.buffer.list.get_selected()+1, count)
|
||||
else:
|
||||
msg = _("{0}. Empty").format(title)
|
||||
except Exception:
|
||||
msg = _("{0}. Empty").format(title)
|
||||
output.speak(msg, True)
|
||||
|
||||
def destroy_status(self):
|
||||
pass
|
||||
@@ -460,6 +471,40 @@ class ChatBuffer(BaseBuffer):
|
||||
"""Global shortcut for DM."""
|
||||
self.on_reply(None)
|
||||
|
||||
def get_message(self):
|
||||
"""Return a readable summary for the selected chat message."""
|
||||
item = self.get_item()
|
||||
if item is None:
|
||||
return None
|
||||
composed = self.compose_function(
|
||||
item, self.session.db, self.session.settings,
|
||||
self.session.settings["general"].get("relative_times", False),
|
||||
self.session.settings["general"].get("show_screen_names", False),
|
||||
)
|
||||
return " ".join(composed)
|
||||
|
||||
def get_formatted_message(self):
|
||||
"""Return the text content of the selected chat message."""
|
||||
item = self.get_item()
|
||||
if item is None:
|
||||
return None
|
||||
composed = self.compose_function(
|
||||
item, self.session.db, self.session.settings,
|
||||
self.session.settings["general"].get("relative_times", False),
|
||||
self.session.settings["general"].get("show_screen_names", False),
|
||||
)
|
||||
return composed[1]
|
||||
|
||||
def view_item(self, item=None):
|
||||
"""View the selected chat message in a dialog."""
|
||||
msg = self.get_formatted_message()
|
||||
if not msg:
|
||||
output.speak(_("No message selected."), True)
|
||||
return
|
||||
viewer = blueski_messages.text(title=_("Chat message"), text=msg)
|
||||
viewer.message.ShowModal()
|
||||
viewer.message.Destroy()
|
||||
|
||||
def remove_buffer(self, force=False):
|
||||
"""Allow removing this buffer."""
|
||||
from wxUI import commonMessageDialogs
|
||||
|
||||
Reference in New Issue
Block a user