Skip to content
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

Fix ellipsis encoding in the text layout #809

Merged
merged 1 commit into from Feb 16, 2024

Conversation

penguinolog
Copy link
Collaborator

Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)

* Use `...` substitution in case of `…` encoding fails and cache result
* * do not encode multiple times the same value
* * handle unsupported encodings
@penguinolog penguinolog added the Unicode Issues related to Unicode <-> bytes conversion label Feb 16, 2024
@github-actions github-actions bot added the Tests Tests label Feb 16, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 7928555744

Details

  • 0 of 19 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 71.213%

Totals Coverage Status
Change from base Build 7927756327: 0.1%
Covered Lines: 8925
Relevant Lines: 12631

💛 - Coveralls

@penguinolog penguinolog merged commit d8a0e5e into urwid:master Feb 16, 2024
35 checks passed
@penguinolog penguinolog deleted the text_layout_encoding branch February 16, 2024 11:35
@AnonymouX47
Copy link
Contributor

AnonymouX47 commented Feb 16, 2024

EDIT: Never mind... Will open a new issue.


CanvasError is raised when ... (triple period) is used and 1 <= maxcols < 3 e.g

import urwid
urwid.set_encoding("ascii")
text = urwid.Text("Cool", wrap="ellipsis")
text.render((2,))

results in

urwid.canvas.CanvasError: Canvas text is wider than the maxcol specified:
maxcol=2
widths=[3]
text=[b'...']
urwid target encoding=ascii

Might also want to include these edge cases in the tests.

Thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Tests Tests Unicode Issues related to Unicode <-> bytes conversion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ellipsis wrap mode is supported only for UTF and limited list of other encodings
3 participants