mirror of
https://github.com/ghndrx/shellmate.git
synced 2026-02-10 06:45:02 +00:00
Fix: remove invalid set_terminal_size_handler call
asyncssh SSHServerProcess doesn't have that method. Simplified input handling - now updates size on each keypress instead.
This commit is contained in:
@@ -92,9 +92,6 @@ async def handle_client(process: asyncssh.SSHServerProcess) -> None:
|
||||
# Create terminal session
|
||||
session = TerminalSession(process)
|
||||
|
||||
# Set up resize handler
|
||||
process.channel.set_terminal_size_handler(session.handle_resize)
|
||||
|
||||
term_type = process.get_terminal_type() or "xterm-256color"
|
||||
logger.info(f"Client {username}: term={term_type}, size={session.width}x{session.height}")
|
||||
|
||||
@@ -195,32 +192,18 @@ async def run_simple_menu(process, session: TerminalSession, username: str, mode
|
||||
|
||||
render_menu()
|
||||
|
||||
# Wait for input with resize handling
|
||||
# Wait for input
|
||||
while True:
|
||||
try:
|
||||
# Use asyncio.wait with timeout to check for resize
|
||||
read_task = asyncio.create_task(process.stdin.read(1))
|
||||
|
||||
done, pending = await asyncio.wait(
|
||||
[read_task],
|
||||
timeout=0.5,
|
||||
return_when=asyncio.FIRST_COMPLETED
|
||||
)
|
||||
|
||||
# Check if resize happened
|
||||
if session._resize_event.is_set():
|
||||
render_menu()
|
||||
continue
|
||||
|
||||
if not done:
|
||||
continue
|
||||
|
||||
data = read_task.result()
|
||||
data = await process.stdin.read(1)
|
||||
if not data:
|
||||
break
|
||||
|
||||
char = data.decode() if isinstance(data, bytes) else data
|
||||
|
||||
# Update terminal size in case it changed
|
||||
session._update_size()
|
||||
|
||||
if char in ('q', 'Q', '\x03', '\x04'): # q, Ctrl+C, Ctrl+D
|
||||
session.clear()
|
||||
session.write("\r\n\033[33mGoodbye! Thanks for playing!\033[0m\r\n\r\n")
|
||||
@@ -376,29 +359,15 @@ async def run_chess_game(process, session: TerminalSession, username: str, oppon
|
||||
|
||||
while not board.is_game_over():
|
||||
try:
|
||||
read_task = asyncio.create_task(process.stdin.read(1))
|
||||
|
||||
done, pending = await asyncio.wait(
|
||||
[read_task],
|
||||
timeout=0.5,
|
||||
return_when=asyncio.FIRST_COMPLETED
|
||||
)
|
||||
|
||||
# Handle resize
|
||||
if session._resize_event.is_set():
|
||||
render_board()
|
||||
session.write(move_buffer)
|
||||
continue
|
||||
|
||||
if not done:
|
||||
continue
|
||||
|
||||
data = read_task.result()
|
||||
data = await process.stdin.read(1)
|
||||
if not data:
|
||||
break
|
||||
|
||||
char = data.decode() if isinstance(data, bytes) else data
|
||||
|
||||
# Update terminal size in case it changed
|
||||
session._update_size()
|
||||
|
||||
if char in ('\x03', '\x04'): # Ctrl+C/D
|
||||
break
|
||||
elif char in ('q', 'r'):
|
||||
|
||||
Reference in New Issue
Block a user