| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 367c2f8 commit 8e25e01
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,8 @@ | |||
| 19 | 19 | from bpython._py3compat import PythonLexer | |
| 20 | 20 | from pygments.formatters import TerminalFormatter | |
| 21 | 21 | ||
| 22 | + from wcwidth import wcswidth | ||
| 23 | + | ||
| 22 | 24 | import blessings | |
| 23 | 25 | ||
| 24 | 26 | import curtsies | |
@@ -1359,7 +1361,11 @@ def display_line_with_prompt(self): | |||
| 1359 | 1361 | ||
| 1360 | 1362 | @property | |
| 1361 | 1363 | def current_cursor_line_without_suggestion(self): | |
| 1362 | - """Current line, either output/input or Python prompt + code""" | ||
| 1364 | + """ | ||
| 1365 | + Current line, either output/input or Python prompt + code | ||
| 1366 | + | ||
| 1367 | + :returns: FmtStr | ||
| 1368 | + """ | ||
| 1363 | 1369 | value = self.current_output_line + ( | |
| 1364 | 1370 | "" if self.coderunner.running else self.display_line_with_prompt | |
| 1365 | 1371 | ) | |
@@ -1556,7 +1562,8 @@ def move_screen_up(current_line_start_row): | |||
| 1556 | 1562 | ||
| 1557 | 1563 | if self.stdin.has_focus: | |
| 1558 | 1564 | cursor_row, cursor_column = divmod( | |
| 1559 | - len(self.current_stdouterr_line) + self.stdin.cursor_offset, | ||
| 1565 | + wcswidth(self.current_stdouterr_line) | ||
| 1566 | + + wcswidth(self.stdin.current_line[: self.stdin.cursor_offset]), | ||
| 1560 | 1567 | width, | |
| 1561 | 1568 | ) | |
| 1562 | 1569 | assert cursor_column >= 0, cursor_column | |
@@ -1574,12 +1581,12 @@ def move_screen_up(current_line_start_row): | |||
| 1574 | 1581 | len(self.current_line), | |
| 1575 | 1582 | self.cursor_offset, | |
| 1576 | 1583 | ) | |
| 1577 | - else: | ||
| 1584 | + else: # Common case for determining cursor position | ||
| 1578 | 1585 | cursor_row, cursor_column = divmod( | |
| 1579 | 1586 | ( | |
| 1580 | - len(self.current_cursor_line_without_suggestion) | ||
| 1581 | - - len(self.current_line) | ||
| 1582 | - + self.cursor_offset | ||
| 1587 | + wcswidth(self.current_cursor_line_without_suggestion.s) | ||
| 1588 | + - wcswidth(self.current_line) | ||
| 1589 | + + wcswidth(self.current_line[: self.cursor_offset]) | ||
| 1583 | 1590 | ), | |
| 1584 | 1591 | width, | |
| 1585 | 1592 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -228,6 +228,7 @@ def initialize_options(self): | |||
| 228 | 228 | "curtsies >=0.1.18", | |
| 229 | 229 | "greenlet", | |
| 230 | 230 | "six >=1.5", | |
| 231 | + "wcwidth" | ||
| 231 | 232 | ] | |
| 232 | 233 | ||
| 233 | 234 | extras_require = { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments