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
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletionsbpython/curtsiesfrontend/repl.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,8 @@
from bpython._py3compat import PythonLexer
from pygments.formatters import TerminalFormatter

from wcwidth import wcswidth

import blessings

import curtsies
Expand DownExpand Up@@ -1359,7 +1361,11 @@ def display_line_with_prompt(self):

@property
def current_cursor_line_without_suggestion(self):
"""Current line, either output/input or Python prompt + code"""
"""
Current line, either output/input or Python prompt + code

:returns: FmtStr
"""
value = self.current_output_line + (
"" if self.coderunner.running else self.display_line_with_prompt
)
Expand DownExpand Up@@ -1556,7 +1562,8 @@ def move_screen_up(current_line_start_row):

if self.stdin.has_focus:
cursor_row, cursor_column = divmod(
len(self.current_stdouterr_line) + self.stdin.cursor_offset,
wcswidth(self.current_stdouterr_line)
+ wcswidth(self.stdin.current_line[: self.stdin.cursor_offset]),
width,
)
assert cursor_column >= 0, cursor_column
Expand All@@ -1574,12 +1581,12 @@ def move_screen_up(current_line_start_row):
len(self.current_line),
self.cursor_offset,
)
else:
else: # Common case for determining cursor position
cursor_row, cursor_column = divmod(
(
len(self.current_cursor_line_without_suggestion)
-len(self.current_line)
+ self.cursor_offset
wcswidth(self.current_cursor_line_without_suggestion.s)
-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?)

+wcswidth(self.current_line[: self.cursor_offset])
),
width,
)
Expand Down
1 change: 1 addition & 0 deletionssetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -228,6 +228,7 @@ def initialize_options(self):
"curtsies >=0.1.18",
"greenlet",
"six >=1.5",
"wcwidth"
]

extras_require = {
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp