Skip to content

Commit

Permalink
fix: Fix erasure of *iterm2* image last column
Browse files Browse the repository at this point in the history
- fix: Restrict graphics image clear workaround to the *kitty* style
  and *iterm2* style on Konsole.

  - The workaround caused the erasure of the last column of
    iterm2-style images on non-Konsole terminal emulators.
  • Loading branch information
AnonymouX47 committed Apr 13, 2023
1 parent f790806 commit 5d828d1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/termvisage/tui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import List, Optional, Tuple

import urwid
from term_image.image import BaseImage, Size
from term_image.image import BaseImage, ITerm2Image, KittyImage, Size
from term_image.utils import get_terminal_name_version, get_terminal_size

from .. import logging
Expand Down Expand Up @@ -419,15 +419,25 @@ def content(self, trim_left=0, trim_top=0, cols=None, rows=None, attr_map=None):

fill = b" " * cols
fill_left = b" " * pad_left
fill_right = b" " * pad_right + b"\b " * self._ti_change_state
fill_right = b" " * pad_right

disguise = (
b"\b "
* self._ti_change_state
* (
issubclass(tui_main.ImageClass, KittyImage)
or issubclass(tui_main.ImageClass, ITerm2Image)
and get_terminal_name_version()[0] == "konsole"
)
)

# Visible padding may be larger than the visible rows
for _ in range(min(rows, pad_up)):
yield [(None, "U", fill)]

# See the description of `pad_up` and `pad_down` above
for line in self.lines[-min(0, pad_up) : min(0, pad_down) or len(self.lines)]:
yield [(None, "U", fill_left + line + fill_right)]
yield [(None, "U", fill_left + line + fill_right + disguise)]

# Visible padding may be larger than the visible rows
for _ in range(min(rows, pad_down)):
Expand Down

0 comments on commit 5d828d1

Please sign in to comment.