mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
Move terminal dimensions detection to asciinema.term module
This commit is contained in:
@@ -13,6 +13,7 @@ import time
|
||||
|
||||
import asciinema.asciicast.v2 as v2
|
||||
import asciinema.pty as pty
|
||||
import asciinema.term as term
|
||||
|
||||
|
||||
def record_asciicast(path, command=None, append=False, idle_time_limit=None,
|
||||
@@ -29,9 +30,11 @@ def record_asciicast(path, command=None, append=False, idle_time_limit=None,
|
||||
if capture_env is None:
|
||||
capture_env = ['SHELL', 'TERM']
|
||||
|
||||
w, h = term.get_size()
|
||||
|
||||
full_metadata = {
|
||||
'width': int(subprocess.check_output(['tput', 'cols'])),
|
||||
'height': int(subprocess.check_output(['tput', 'lines'])),
|
||||
'width': w,
|
||||
'height': h,
|
||||
'timestamp': int(time.time())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import tty
|
||||
import select
|
||||
import os
|
||||
import select
|
||||
import subprocess
|
||||
import tty
|
||||
|
||||
|
||||
class raw():
|
||||
@@ -26,3 +27,11 @@ def read_blocking(fd, timeout):
|
||||
return os.read(fd, 1024)
|
||||
|
||||
return b''
|
||||
|
||||
|
||||
def get_size():
|
||||
# TODO maybe use os.get_terminal_size ?
|
||||
return (
|
||||
int(subprocess.check_output(['tput', 'cols'])),
|
||||
int(subprocess.check_output(['tput', 'lines']))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user