-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_terminal_size.py
More file actions
75 lines (62 loc) · 2.2 KB
/
debug_terminal_size.py
File metadata and controls
75 lines (62 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""
Debug script to test terminal size detection
"""
import os
import sys
# Add project root to path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
print("=" * 60)
print("Terminal Size Detection Test")
print("=" * 60)
# Test 1: os.get_terminal_size()
try:
size = os.get_terminal_size()
print(f"✅ os.get_terminal_size(): {size.columns} × {size.lines}")
except Exception as e:
print(f"❌ os.get_terminal_size() failed: {e}")
# Test 2: shutil.get_terminal_size()
import shutil
try:
size = shutil.get_terminal_size()
print(f"✅ shutil.get_terminal_size(): {size.columns} × {size.lines}")
except Exception as e:
print(f"❌ shutil.get_terminal_size() failed: {e}")
# Test 3: Custom driver
if sys.platform == "win32":
try:
from drivers.responsive_windows_driver import ResponsiveWindowsDriver
# Create a mock driver instance
class MockApp:
pass
driver = ResponsiveWindowsDriver(MockApp(), None)
size = driver._get_terminal_size()
print(f"✅ ResponsiveWindowsDriver: {size.width} × {size.height}")
except Exception as e:
print(f"❌ ResponsiveWindowsDriver failed: {e}")
import traceback
traceback.print_exc()
# Test 4: Run Textual app and check its size
print("\n" + "=" * 60)
print("Starting Textual App (press Ctrl+C to exit)...")
print("=" * 60)
from textual.app import App
from textual.widgets import Static
class DebugApp(App):
def on_mount(self):
# Print actual app size
print(f"\n🔍 App.size inside Textual: {self.size}")
print(f"🔍 Screen.size: {self.screen.size}")
print(f"🔍 App region: {self.screen.region}")
def compose(self):
yield Static(f"Terminal Size Test\nApp thinks size is: {self.size}", id="test")
if __name__ == "__main__":
# Check if on Windows and use custom driver
if sys.platform == "win32":
from drivers.responsive_windows_driver import ResponsiveWindowsDriver
class DebugAppWithDriver(DebugApp):
def get_driver_class(self):
return ResponsiveWindowsDriver
app = DebugAppWithDriver()
else:
app = DebugApp()
app.run()