Commit 0b4fa0b
Eric Wheeler
feat: compress repeated terminal output lines
Add Terminal.compressTerminalOutput static method to apply run-length encoding
before truncating terminal output. This significantly reduces output size for
repeated lines while maintaining readability.
- Add compressTerminalOutput static method to Terminal class
- Replace all truncateOutput calls with Terminal.compressTerminalOutput
- Import required functions from extract-text
Test program demonstrating compression:
```python
def generate_repeats():
patterns = [
("A\n", 10), # 10 lines
("AA\n", 100), # 100 lines
("AAA\n", 1000), # 1K lines
("AAAA\n", 10000), # 10K lines
("AAAAA\n", 100000), # 100K lines
("AAAAAA\n", 1000000) # 1M lines
]
for text, count in patterns:
print(text * count, end="")
```
Sample output showing compression:
```
A
A
A
A
A
A
A
A
A
A
AA
<previous line repeated 99 additional times>
AAA
<previous line repeated 999 additional times>
AAAA
<previous line repeated 9999 additional times>
AAAAA
<previous line repeated 99999 additional times>
AAAAAA
<previous line repeated 999999 additional times>
```
Signed-off-by: Eric Wheeler <[email protected]>1 parent 131f9ad commit 0b4fa0b
2 files changed
+16
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
968 | 968 | | |
969 | 969 | | |
970 | 970 | | |
971 | | - | |
| 971 | + | |
972 | 972 | | |
973 | | - | |
| 973 | + | |
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
| |||
1000 | 1000 | | |
1001 | 1001 | | |
1002 | 1002 | | |
1003 | | - | |
| 1003 | + | |
1004 | 1004 | | |
1005 | 1005 | | |
1006 | 1006 | | |
| |||
3546 | 3546 | | |
3547 | 3547 | | |
3548 | 3548 | | |
3549 | | - | |
| 3549 | + | |
3550 | 3550 | | |
3551 | 3551 | | |
3552 | 3552 | | |
| |||
3573 | 3573 | | |
3574 | 3574 | | |
3575 | 3575 | | |
3576 | | - | |
| 3576 | + | |
3577 | 3577 | | |
3578 | 3578 | | |
3579 | 3579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
221 | 231 | | |
0 commit comments