mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
Add terminal size fallback (#5623)
This commit is contained in:
parent
b699a15062
commit
f498d855ba
@ -1,5 +1,6 @@
|
|||||||
from app.logger import on_flush
|
from app.logger import on_flush
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
class TerminalService:
|
class TerminalService:
|
||||||
@ -10,15 +11,27 @@ class TerminalService:
|
|||||||
self.subscriptions = set()
|
self.subscriptions = set()
|
||||||
on_flush(self.send_messages)
|
on_flush(self.send_messages)
|
||||||
|
|
||||||
|
def get_terminal_size(self):
|
||||||
|
try:
|
||||||
|
size = os.get_terminal_size()
|
||||||
|
return (size.columns, size.lines)
|
||||||
|
except OSError:
|
||||||
|
try:
|
||||||
|
size = shutil.get_terminal_size()
|
||||||
|
return (size.columns, size.lines)
|
||||||
|
except OSError:
|
||||||
|
return (80, 24) # fallback to 80x24
|
||||||
|
|
||||||
def update_size(self):
|
def update_size(self):
|
||||||
sz = os.get_terminal_size()
|
columns, lines = self.get_terminal_size()
|
||||||
changed = False
|
changed = False
|
||||||
if sz.columns != self.cols:
|
|
||||||
self.cols = sz.columns
|
if columns != self.cols:
|
||||||
|
self.cols = columns
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if sz.lines != self.rows:
|
if lines != self.rows:
|
||||||
self.rows = sz.lines
|
self.rows = lines
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
|
Loading…
Reference in New Issue
Block a user