From 33c0f91a6319fc418d424aa08854fe625fac6205 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Fri, 13 Sep 2024 22:17:24 +0100 Subject: [PATCH] Improve selection --- elia_chat/elia.scss | 4 ++++ elia_chat/widgets/chatbox.py | 11 +---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/elia_chat/elia.scss b/elia_chat/elia.scss index ceb202c..c6b5cb8 100644 --- a/elia_chat/elia.scss +++ b/elia_chat/elia.scss @@ -264,6 +264,7 @@ Chatbox { } &.assistant-message { + width: 1fr; border: round $accent 60%; &:focus-within { border: round $accent; @@ -296,6 +297,9 @@ Chatbox { background: $main-lighten-2; } } + & TextArea { + width: 1fr; + } } } diff --git a/elia_chat/widgets/chatbox.py b/elia_chat/widgets/chatbox.py index edac17b..cf6090b 100644 --- a/elia_chat/widgets/chatbox.py +++ b/elia_chat/widgets/chatbox.py @@ -136,7 +136,7 @@ def action_copy_to_clipboard(self) -> None: text_to_copy = self.selected_text if text_to_copy: - message = f"Copied {len(text_to_copy)} selected characters to clipboard." + message = f"Copied {len(text_to_copy)} characters to clipboard." title = "Selection copied" else: text_to_copy = self.text @@ -381,15 +381,6 @@ def render(self) -> RenderableType: return "" return self.markdown - def get_content_width(self, container: Size, viewport: Size) -> int: - # Naive approach. Can sometimes look strange, but works well enough. - content = self.message.message.get("content") - if isinstance(content, str): - content_width = min(cell_len(content), container.width) - else: - content_width = 10 # Arbitrary - return content_width - def append_chunk(self, chunk: str) -> None: """Append a chunk of text to the end of the message.""" content = self.message.message.get("content")