client_shell_win32

Windows telnet client shell implementation using blessed/jinxed.

class Terminal(telnet_writer)[source]

Context manager for terminal mode handling on Windows via blessed/jinxed.

Blessed is a guaranteed dependency on Windows (pyproject.toml environment marker). Mirrors the interface of the POSIX Terminal class in telnetlib3.client_shell.

Class Initializer.

ModeDef

alias of _WinMode

get_mode()[source]

Return current terminal mode if attached to a tty, otherwise None.

Return type:

Optional[_WinMode]

set_mode(mode)[source]

Switch terminal to raw or cooked mode using blessed context managers.

Return type:

None

determine_mode(mode)[source]

Return the appropriate mode for the current telnet negotiation state.

Windows equivalent of the POSIX Terminal.determine_mode, using ModeDef (raw/echo flags instead of termios bitfields).

Return type:

_WinMode

check_auto_mode(switched_to_raw, last_will_echo)[source]

Check if auto-mode switching is needed.

Windows equivalent of the POSIX Terminal.check_auto_mode.

Parameters:
  • switched_to_raw (bool) – Whether terminal has already switched to raw mode.

  • last_will_echo (bool) – Previous value of server’s WILL ECHO state.

Return type:

Optional[Tuple[bool, bool, bool]]

Returns:

(switched_to_raw, last_will_echo, local_echo) tuple if mode changed, or None if no change needed.

setup_winch()[source]

Poll for terminal size changes in a background thread.

Return type:

None

cleanup_winch()[source]

Stop the resize polling thread.

Return type:

None

async make_stdout()[source]

Return a StreamWriter-compatible wrapper for sys.stdout.

Return type:

Any

async connect_stdin()[source]

Return an asyncio StreamReader fed by a blessed inkey() thread.

Uses blessed/jinxed to read one keypress at a time in raw mode. Each keystroke is encoded as UTF-8 and fed to the reader.

Return type:

StreamReader

disconnect_stdin(reader)[source]

Stop the stdin reader thread and signal EOF.

Return type:

None

async telnet_client_shell(telnet_reader, telnet_writer)[source]

Windows telnet client shell using blessed/jinxed Terminal.

Requires blessed, installed automatically on Windows via the blessed; platform_system == 'Windows' directive in pyproject.toml.

Return type:

None