Skip to content

Word wrapping #1887

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Add styling fixes
  • Loading branch information
Cimbali committed Jun 14, 2024
commit ec2784d14a5ec96346061d0b16cc13f1f12fdbab
8 changes: 4 additions & 4 deletions src/prompt_toolkit/layout/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from abc import ABCMeta, abstractmethod
from enum import Enum
from functools import partial
from typing import TYPE_CHECKING, Callable, Sequence, Tuple, Union, cast
from typing import TYPE_CHECKING, Callable, Sequence, Union, cast

from prompt_toolkit.application.current import get_app
from prompt_toolkit.cache import SimpleCache
Expand Down Expand Up @@ -1967,7 +1967,7 @@ def _whitespace_wrap_finder(

def wrap_finder(
lineno: int, start: int, end: int
) -> Tuple[int, int, AnyFormattedText]:
) -> tuple[int, int, AnyFormattedText]:
line = explode_text_fragments(ui_content.get_line(lineno))
cont_reserved = 0
while cont_reserved < cont_width:
Expand Down Expand Up @@ -2001,7 +2001,7 @@ def _copy_body(
has_focus: bool = False,
align: WindowAlign = WindowAlign.LEFT,
get_line_prefix: Callable[[int, int], AnyFormattedText] | None = None,
wrap_finder: Callable[[int, int, int], Tuple[int, int, AnyFormattedText] | None]
wrap_finder: Callable[[int, int, int], tuple[int, int, AnyFormattedText] | None]
| None = None,
) -> tuple[dict[int, tuple[int, int]], dict[tuple[int, int], tuple[int, int]]]:
"""
Expand Down Expand Up @@ -2030,7 +2030,7 @@ def find_next_wrap(remaining_width, is_input, lineno, fragment=0, char_pos=0):

line = ui_content.get_line(lineno)
style0, text0, *more = line[fragment]
fragment_pos = char_pos - fragment_list_len(line[:fragment])
char_pos - fragment_list_len(line[:fragment])
line_part = [(style0, text0[char_pos:], *more), *line[fragment + 1 :]]
line_width = [fragment_list_width([fragment]) for fragment in line_part]

Expand Down
4 changes: 1 addition & 3 deletions src/prompt_toolkit/layout/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import time
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING, Callable, Hashable, Iterable, NamedTuple
from typing import TYPE_CHECKING, Callable, Hashable, Iterable, NamedTuple, Tuple

from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
Expand Down Expand Up @@ -40,8 +40,6 @@
merge_processors,
)

from typing import Tuple

if TYPE_CHECKING:
from prompt_toolkit.key_binding.key_bindings import (
KeyBindingsBase,
Expand Down
Loading