-
Notifications
You must be signed in to change notification settings - Fork 38
Changing logic to include tab replacement and glyph calculation #121
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
Conversation
…s greater thant string length
@@ -91,7 +91,9 @@ def __init__( | |||
if not max_glyphs and not text: | |||
raise RuntimeError("Please provide a max size, or initial text") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could save a line and just put the text = " ".join(text.split("\t"))
before the if not max_glyphs:
statement.
It does this calculation either way, so just do it once and then do the max_glyphs
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, good point, I will change it and re-do the test just to be 100% sure. Thanks @kmatch98 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jposada202020 this works as expected.
Just one minor suggestion on the code. Also, if you are interested, will you please apply similar "\t" handling for bitmap_label?
Thanks for adding this in!
@kmatch98 yes I am in, I will do the bitmap_label too. just wanted to be open about the different approaches and let you folks discuss if needed :). |
Looks good to me. Thanks for the quick update! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I tested with Blinka_Displayio and PyPortal.
I wonder if it will throw someone off that the string they get back might be different from the input string if the access the text
property. It may be worthwhile eventually to add a parameter to control this. But I'm not sure if the complexity of that would be worth it unless folks are really having a problem with it.
I think we need to wait for the pylint fix to merge maybe so that actions will pass.
…of character of the tab replacement
@FoamyGuy Changes are made for the tab parameter. @kmatch98 I changed also for the bitmap_label :). We discuss in the stream after a suggestion from Hugo, that would be good to have that, that way the user can decide how many spaces, dashes or other characters he want the replace the \t for. I was thinking about the setter, but in the same line of thought as Foamyguy, I would like to keep the library simple, and only work if some users ask for that feature as a setter. Thanks. |
PR closed as changes were introduced in release 2.15.4 - Fix for tab characters |
Present changes allows the library to change the "\t" tabs by 4 spaces. The library then will use all the normal logic to take care of these. Present solution was chosen for two main reasons:
However this will imply import the re library. Not sure that this is what why want.
2. We could use a Post treatment using glyph.shift_x in the _update_text module
At the end, we need to return the parameter to the original value with. This needs to be done as the library uses glyph<s parameters for calculations and display:
This is a hack to disguise a tab as an space with a different shift_x parameter as "\t" will not be found as a glyph. So less Pythonic.
This was tested with the following code:
This produce the following result
