Add Terminal.text_sized() kitty text sizing#368
Conversation
Merging this PR will degrade performance by 20.7%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_truncate_cjk |
7,034.3 µs | 485.9 µs | ×14 |
| ⚡ | test_truncate_emoji_zwj |
1,609.3 µs | 937.9 µs | +71.59% |
| 👁 | test_rjust_ansi |
363.2 µs | 458 µs | -20.7% |
| 👁 | test_ljust_ansi |
363.4 µs | 458 µs | -20.65% |
| 👁 | test_center_ansi |
366.2 µs | 460.8 µs | -20.54% |
Comparing jq/text-sizing (58821f2) with master (ab1b0be)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #368 +/- ##
==========================================
+ Coverage 97.44% 97.46% +0.02%
==========================================
Files 13 13
Lines 3642 3673 +31
Branches 631 640 +9
==========================================
+ Hits 3549 3580 +31
Misses 71 71
Partials 22 22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The 3 regressions in ljust, center, and, rjust is that we now use wcwidth.width() with argument "ignoring" control codes worked pretty well, but the more complex ones like OSC 66 kitty text sizing, and basic backspacing and cursor left "overtyping" all new in wcwidth 0.7.0 release require 'parse' to parse them. So this regression is acceptable, we get better results by using 'parse' by default, >>> wcwidth.ljust('hello\b\b\b\bworld', 10, control_codes='ignore', fillchar='.')
'hello\x08\x08\x08\x08world'
>>> wcwidth.ljust('hello\b\b\b\bworld', 10, control_codes='parse', fillchar='.')
'hello\x08\x08\x08\x08world....'
I have included new documentation in docs/measuring.txt about the new ability to parse cursor movement sequences. |
- allow vertical/horizontal_align='top' (str) in addition to protocol code - better "cleanup" our sequences on return, and verify with tests, the first use of 'text_sized()' call would cause some erroneous output, though partially fixed, it is now also well-documented in the documentation
From bin/text_sizing_protocol.py:
From bin/scroller.py:
kitty-text-sizing-.2.mp4