-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRAFT: Expand zero-width support for ZWJ and emoji sequences #85
Conversation
Codecov ReportAttention:
📢 Thoughts on this report? Let us know!. |
return fmt.format(name_len=style.name_len, | ||
ucs_printlen=UCS_PRINTLEN, | ||
delimiter=delimiter, | ||
name=name, | ||
ucs=disp_ucs, | ||
val=val) | ||
name_val=name_val, | ||
ucs=ucs) |
Check warning
Code scanning / CodeQL
Unused named argument in formatting call Warning
format "{delimiter}{ucs}{delimiter}{name_val}"
Surplus named argument for string format. An argument named 'ucs_printlen' is provided, but it is not required by
format "{delimiter}{ucs}{delimiter}{name_val}"
|
||
# local | ||
from wcwidth import ZERO_WIDTH, wcwidth, list_versions, _wcmatch_version | ||
import wcwidth | ||
from wcwidth import ZERO_WIDTH, wcwidth, list_versions, _wcmatch_version, EMOJI_ZWJ_SEQUENCES |
Check notice
Code scanning / CodeQL
Unused import Note
|
||
# local | ||
from wcwidth import ZERO_WIDTH, wcwidth, list_versions, _wcmatch_version | ||
import wcwidth |
Check notice
Code scanning / CodeQL
Module is imported with 'import' and 'import from' Note
|
||
def run(self, writer, reader): | ||
def run(self, writer, reader, automatic=False): |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns Note
# sequence clears to end-of-line | ||
clear_eol = self.term.clear_eol | ||
# sequence clears to end-of-screen | ||
clear_eos = self.term.clear_eos |
Check notice
Code scanning / CodeQL
Unused local variable Note
it's too bad the tables aren't more consistent.
ZOC terminal gets nutty with vertical position instead of horizontal around some characters. I think it is some terrible mistake, but it is closed source, bugs are private, and it costs $80 !
writer(self.text_entry(ucs, name), end='') | ||
ny, nx = self.term.get_location() | ||
assert y == ny, ("y position is out of control on ucs value=", hex(ord(ucs)) if len(ucs) == 1 else repr(ucs)) | ||
if y == ny: |
Check warning
Code scanning / CodeQL
Redundant comparison Warning
this condition
attr_text=self.term.bright_red, | ||
name_len=self.screen.style.name_len) | ||
|
||
def measure_distance(ucs: str, name: str): |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns Note
@@ -59,10 +61,11 @@ | |||
expect_length_phrase = sum(expect_length_each) | |||
|
|||
# exercise, | |||
length_phrase = wcwidth.wcswidth(phrase, end) | |||
length_each = tuple(map(wcwidth.wcwidth, phrase)) |
Check notice
Code scanning / CodeQL
Unused local variable Note test
for test_type in ('narrow', 'wide', 'zero', 'emoji-zwj'): | ||
self.initialize_page_data(test_type) | ||
self.screen.change_test_type(test_type) | ||
page_idx = page_offset = idx = offset = 0 |
Check notice
Code scanning / CodeQL
Unused local variable Note
for test_type in ('narrow', 'wide', 'zero', 'emoji-zwj'): | ||
self.initialize_page_data(test_type) | ||
self.screen.change_test_type(test_type) | ||
page_idx = page_offset = idx = offset = 0 |
Check notice
Code scanning / CodeQL
Unused local variable Note
Sorry, no need to review, I have been using this branch for multiple ideas. I will carve them into smaller PR's, beginning with the automatic tests. I am just performing automatic tests against popular terminals, now, and committing their results, when I'm finished with that I'll start smaller PR's, thank you! |
wcswidth()
for zero-width join characters such as used in emojisequences, and variations such as emoji skin tone, as well as many other
non-printable characters now correctly identified as zero-width.
width()
, a copy ofwcswidth()
withoutthe POSIX compliance to return total width of -1 for any C0 or C1 control
characters, those characters measured as width 0 by this new function.
Discussion,
idx
past the next character, assuming they are cojoined is very high-performing and easy to implementWork remaining,