-
-
Notifications
You must be signed in to change notification settings - Fork 245
Corrected cursor positioning on inputs with full-width (2 column) characters #817
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
- Works with normal input and stdin input - There still are issues with line wrapping when using full-width chars
This is great, nice. Could you check whether this works + whether the .width method exists in the lowest required version of curtsies, as defined in the bpython setup.py? This might be good as is, but some other pieces to look at:
|
Another thing, it'd be great to close #731 once this or another PR supersedes it for fixing wrapping |
Could you confirm that this fixes #605 too? |
and #670! |
from 0.1.18 to 0.2.0 so as to allow .width
Oh yeah, that's weird. I think I'll leave that for now though. It seems outside of scope.
Should be fixed with commit 9e380
Yep, inputs with wide chars now work fine until you exceed one line. I'll look at this next. This seems fixed now, at least for all non-emoji combined characters I could find. Some emojis that combine characters do actually break it, but that's obviously not very urgent. For reference the emoji thing is a known wcwidth issue. |
- len(self.current_line) | ||
+ self.cursor_offset | ||
self.current_cursor_line_without_suggestion.width | ||
- wcswidth(self.current_line) |
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.
What's the distinction here between the wcswidth and .width, are some of these FmtStrs and some of them plain strs? (and if it's not clear, could you add comments to the definitions or initialization lines?)
Sorry about the delay here. This looks good, only thing left is to clarify why we're using both techniques instead of just one or the other, since dropping either (removing wcswidth when we haven't added it to setup.py, or eliminating the need for the Curtsies upgrade) would be nice. Also, assuming we do keep the wcwidth library, it should be added to the explicit setup.py dependencies. |
Oh yep. I had used both because some of those objects were FmtStr and some str, but I can definitely make it only use wcswidth() to avoid the curtsies upgrade for now, because |
- Use wcswidth(FmtStr.s) instead of FmtStr.width
This addresses issue #749. It should now be fixed for normal input as well as stdin input.
Before:

After:

Also, because the issue with width aware text wrapping still exists (#731), it gets a little weird when you exceed one line. Still, I think the cursor is in the correct spot. In the below example the un-wrapped part is '67890'. The cursor seems right despite the text not wrapping.
