-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from mil-ad/basic-tmux-support
Adding tmux passthrough support
- Loading branch information
Showing
5 changed files
with
122 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import array | ||
import fcntl | ||
import math | ||
import sys | ||
import termios | ||
|
||
from PIL import Image | ||
|
||
|
||
def get_char_cell_height() -> int: | ||
"""Source https://sw.kovidgoyal.net/kitty/graphics-protocol/#getting-the-window-size""" | ||
|
||
buf = array.array("H", [0, 0, 0, 0]) | ||
fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, buf) | ||
num_rows, _, _, screen_height = buf | ||
|
||
return int(screen_height // num_rows) | ||
|
||
|
||
def num_required_lines(img_buf): | ||
with Image.open(img_buf) as img: | ||
_, img_height = img.size | ||
img_buf.seek(0) | ||
|
||
return math.ceil(img_height / get_char_cell_height()) |
Oops, something went wrong.