Skip to content

Commit f77e13e

Browse files
committed
Make text in advanced output easier to copy
1 parent 2e68a25 commit f77e13e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

openandroidinstaller/widgets.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ def __init__(self, expand: bool = True, visible: bool = False):
4242

4343
def build(self):
4444
self._box = Container(
45-
content=Column(scroll="auto", expand=True, auto_scroll=True),
45+
content=Column(
46+
controls=[Text("", selectable=True)],
47+
scroll="auto",
48+
expand=True,
49+
auto_scroll=True,
50+
),
4651
margin=10,
4752
padding=10,
4853
alignment=alignment.top_left,
@@ -61,7 +66,10 @@ def write_line(self, line: str):
6166
Ignores empty lines.
6267
"""
6368
if (type(line) == str) and line.strip():
64-
self._box.content.controls.append(Text(f">{line.strip()}", selectable=True))
69+
self._box.content.controls[0].value += f"\n>{line.strip()}"
70+
self._box.content.controls[0].value = self._box.content.controls[
71+
0
72+
].value.strip("\n")
6573
self.update()
6674

6775
def toggle_visibility(self):
@@ -72,7 +80,7 @@ def toggle_visibility(self):
7280

7381
def clear(self):
7482
"""Clear terminal output."""
75-
self._box.content.controls = []
83+
self._box.content.controls[0].value = ""
7684
self.update()
7785

7886
def update(self):

tests/test_terminal_box.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def test_write_lines(mocker):
4242
for line in ["test", "test_line2", True]:
4343
terminal_box.write_line(line)
4444

45-
# two text elements should appear
46-
assert len(terminal_box._box.content.controls) == 2
45+
# two lines of text should appear
46+
assert len(terminal_box._box.content.controls[0].value.split("\n")) == 2
4747

4848

4949
def test_toggle_visibility(mocker):
@@ -87,5 +87,5 @@ def test_clear_terminal(mocker):
8787
# now clear
8888
terminal_box.clear()
8989

90-
# two text elements should appear
91-
assert len(terminal_box._box.content.controls) == 0
90+
# text element should be empty
91+
assert terminal_box._box.content.controls[0].value == ""

0 commit comments

Comments
 (0)