From 3e29d2a75eff0343385916c2c84ab00067551044 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Wed, 3 May 2023 20:48:12 -0400 Subject: [PATCH] Split action_paste and paste --- src/textual_paint/paint.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/textual_paint/paint.py b/src/textual_paint/paint.py index 331cbab..f42586d 100755 --- a/src/textual_paint/paint.py +++ b/src/textual_paint/paint.py @@ -2170,7 +2170,7 @@ class PaintApp(App[None]): return True def action_paste(self) -> None: - """Paste the clipboard as a selection.""" + """Paste the clipboard (ANSI art allowed), either as a selection, or into a textbox.""" try: import pyperclip text: str = pyperclip.paste() @@ -2179,6 +2179,10 @@ class PaintApp(App[None]): return if not text: return + self.paste(text) + + def paste(self, text: str) -> None: + """Paste the given text (ANSI art allowed), either as a selection, or into a textbox.""" if self.image.selection and self.image.selection.textbox_mode: # paste into textbox pasted_image = AnsiArtDocument.from_text(text, default_bg=self.selected_bg_color, default_fg=self.selected_fg_color)