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
|
# Create terminal session
|
||||||
session = TerminalSession(process)
|
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"
|
term_type = process.get_terminal_type() or "xterm-256color"
|
||||||
logger.info(f"Client {username}: term={term_type}, size={session.width}x{session.height}")
|
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()
|
render_menu()
|
||||||
|
|
||||||
# Wait for input with resize handling
|
# Wait for input
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
# Use asyncio.wait with timeout to check for resize
|
data = await process.stdin.read(1)
|
||||||
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()
|
|
||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
|
|
||||||
char = data.decode() if isinstance(data, bytes) else data
|
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
|
if char in ('q', 'Q', '\x03', '\x04'): # q, Ctrl+C, Ctrl+D
|
||||||
session.clear()
|
session.clear()
|
||||||
session.write("\r\n\033[33mGoodbye! Thanks for playing!\033[0m\r\n\r\n")
|
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():
|
while not board.is_game_over():
|
||||||
try:
|
try:
|
||||||
read_task = asyncio.create_task(process.stdin.read(1))
|
data = await 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()
|
|
||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
|
|
||||||
char = data.decode() if isinstance(data, bytes) else data
|
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
|
if char in ('\x03', '\x04'): # Ctrl+C/D
|
||||||
break
|
break
|
||||||
elif char in ('q', 'r'):
|
elif char in ('q', 'r'):
|
||||||
|
|||||||
Reference in New Issue
Block a user