Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
thomasballinger merged 4 commits intobpython:masterfromrybarczykj:master
Jul 14, 2020

Conversation

rybarczykj
Copy link
Contributor

This addresses issue#749. It should now be fixed for normal input as well as stdin input.

Before:
widetextbefore

After:
widetextafter

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.
widetextwrap

- Works with normal input and stdin input- There still are issues with line wrapping when using full-width chars
@rybarczykjrybarczykj changed the titleCorrect cursor position on input with full-width (2 column) charactersCorrected cursor positioning on inputs with full-width (2 column) charactersJul 1, 2020
@thomasballinger
Copy link
Member

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:

  • when I paste "he above, there are" into the save dialog, I get greater-than signs. What's up with that?
  • the cursor in input("he above, there are ") isn't aligned yet
  • wrapping, as you've pointed out
  • F7 works, great!
  • Are there any examples you can find that are a the wrong width, as perhttps://jeffquast.com/post/terminal_wcwidth_solution/? If we we should open an issue and you might look at this too.

@thomasballinger
Copy link
Member

Another thing, it'd be great to close#731 once this or another PR supersedes it for fixing wrapping

@thomasballinger
Copy link
Member

Could you confirm that this fixes#605 too?

@thomasballinger
Copy link
Member

and#670!

@rybarczykj
Copy link
ContributorAuthor

when I paste "he above, there are" into the save dialog, I get greater-than signs. What's up with that?

Oh yeah, that's weird. I think I'll leave that for now though. It seems outside of scope.

the cursor ininput("he above, there are ") isn't aligned yet

Should be fixed with commit 9e380

wrapping

Yep, inputs with wide chars now work fine until you exceed one line. I'll look at this next.

#605

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 aknown wcwidth issue.

- len(self.current_line)
+ self.cursor_offset
self.current_cursor_line_without_suggestion.width
- wcswidth(self.current_line)

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?)

@thomasballinger
Copy link
Member

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.

@rybarczykj
Copy link
ContributorAuthor

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, becauseFmtStr.width is essentially a wrapper forwcswidth(FmtStr.s). I'll do that and update the setup.py

- Use wcswidth(FmtStr.s) instead of FmtStr.width
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@thomasballingerthomasballingerthomasballinger left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@rybarczykj@thomasballinger

[8]ページ先頭

©2009-2025 Movatter.jp