|
4 | 4 | from queue import Empty, Queue |
5 | 5 | from operator import itemgetter |
6 | 6 | import platform |
| 7 | +import pyperclip |
7 | 8 | from threading import Event, RLock, Thread |
8 | 9 |
|
9 | 10 | from textual.message import Message |
@@ -139,6 +140,7 @@ class LogLines(ScrollView, inherit_bindings=False): |
139 | 140 | Binding("pagedown,space", "page_down", "Page Down", show=False), |
140 | 141 | Binding("enter", "select", "Select line", show=False), |
141 | 142 | Binding("escape", "dismiss", "Dismiss", show=False, priority=True), |
| 143 | + Binding("y", "copy", "Copy (yank) current selection", show=False, priority=True), |
142 | 144 | Binding("m", "navigate(+1, 'm')"), |
143 | 145 | Binding("M", "navigate(-1, 'm')"), |
144 | 146 | Binding("o", "navigate(+1, 'h')"), |
@@ -906,6 +908,11 @@ def action_navigate(self, steps: int, unit: Literal["m", "h", "d"]) -> None: |
906 | 908 | self.pointer_line = line_no |
907 | 909 | self.scroll_pointer_to_center(animate=abs(initial_line_no - line_no) < 100) |
908 | 910 |
|
| 911 | + def action_copy(self, **argv): |
| 912 | + if self.pointer_line: |
| 913 | + line = self.get_line_from_index(self.pointer_line) |
| 914 | + pyperclip.copy(line) |
| 915 | + |
909 | 916 | def watch_tail(self, tail: bool) -> None: |
910 | 917 | self.set_class(tail, "-tail") |
911 | 918 | if tail: |
|
0 commit comments