@@ -685,56 +685,7 @@ def _patched_connection_made(transport: asyncio.BaseTransport) -> None:
685685
686686 client_factory : Optional [Callable [..., client_base .BaseClient ]] = _client_factory
687687
688- # Wrap the shell callback to inject color filter when enabled
689- colormatch : str = args ["colormatch" ]
690688 shell_callback = args ["shell" ]
691- if colormatch .lower () != "none" :
692- from .color_filter import (
693- PALETTES ,
694- ColorConfig ,
695- ColorFilter ,
696- PetsciiColorFilter ,
697- AtasciiControlFilter ,
698- )
699-
700- # Auto-select encoding-specific filters
701- encoding_name : str = args .get ("encoding" , "" ) or ""
702- is_petscii = encoding_name .lower () in ("petscii" , "cbm" , "commodore" , "c64" , "c128" )
703- is_atascii = encoding_name .lower () in ("atascii" , "atari8bit" , "atari_8bit" )
704- if colormatch == "petscii" :
705- colormatch = "c64"
706- if is_petscii and colormatch != "c64" :
707- colormatch = "c64"
708-
709- if colormatch not in PALETTES :
710- print (
711- f"Unknown palette { colormatch !r} ," f" available: { ', ' .join (sorted (PALETTES ))} " ,
712- file = sys .stderr ,
713- )
714- sys .exit (1 )
715- color_config = ColorConfig (
716- palette_name = colormatch ,
717- brightness = args ["color_brightness" ],
718- contrast = args ["color_contrast" ],
719- background_color = args ["background_color" ],
720- ice_colors = args ["ice_colors" ],
721- )
722- if is_petscii or colormatch == "c64" :
723- color_filter_obj : object = PetsciiColorFilter (color_config )
724- elif is_atascii :
725- color_filter_obj = AtasciiControlFilter ()
726- else :
727- color_filter_obj = ColorFilter (color_config )
728- original_shell = shell_callback
729-
730- async def _color_shell (
731- reader : Union [TelnetReader , TelnetReaderUnicode ],
732- writer_arg : Union [TelnetWriter , TelnetWriterUnicode ],
733- ) -> None :
734- writer_arg .ctx .color_filter = color_filter_obj
735- await original_shell (reader , writer_arg )
736-
737- shell_callback = _color_shell
738689
739690 # Wrap shell to inject raw_mode flag and input translation for retro encodings
740691 raw_mode_val : Optional [bool ] = args .get ("raw_mode" , False )
@@ -894,44 +845,6 @@ def _get_argument_parser() -> argparse.ArgumentParser:
894845 metavar = "OPT" ,
895846 help = "always send DO for this option (name like GMCP or number, repeatable)" ,
896847 )
897- parser .add_argument (
898- "--colormatch" ,
899- default = "vga" ,
900- metavar = "PALETTE" ,
901- help = (
902- "translate basic 16-color ANSI codes to exact 24-bit RGB values"
903- " from a named hardware palette, bypassing the terminal's custom"
904- " palette to preserve intended MUD/BBS artwork colors"
905- " (vga, xterm, none)"
906- ),
907- )
908- parser .add_argument (
909- "--color-brightness" ,
910- default = 1.0 ,
911- type = float ,
912- metavar = "FLOAT" ,
913- help = "color brightness scale [0.0..1.0], where 1.0 is original" ,
914- )
915- parser .add_argument (
916- "--color-contrast" ,
917- default = 1.0 ,
918- type = float ,
919- metavar = "FLOAT" ,
920- help = "color contrast scale [0.0..1.0], where 1.0 is original" ,
921- )
922- parser .add_argument (
923- "--background-color" ,
924- default = "#000000" ,
925- metavar = "#RRGGBB" ,
926- help = "forced background color as hex RGB (near-black by default)" ,
927- )
928- parser .add_argument (
929- "--ice-colors" ,
930- action = argparse .BooleanOptionalAction ,
931- default = True ,
932- help = "treat SGR 5 (blink) as bright background (iCE colors)"
933- " for BBS/ANSI art (default: enabled)" ,
934- )
935848 parser .add_argument (
936849 "--ascii-eol" ,
937850 action = "store_true" ,
@@ -1013,20 +926,6 @@ def _parse_option_arg(value: str) -> bytes:
1013926 return bytes ([int (value )])
1014927
1015928
1016- def _parse_background_color (value : str ) -> Tuple [int , int , int ]:
1017- """
1018- Parse hex color string to RGB tuple.
1019-
1020- :param value: Color string like ``"#RRGGBB"`` or ``"RRGGBB"``.
1021- :returns: (R, G, B) tuple with values 0-255.
1022- :raises ValueError: When *value* is not a valid hex color.
1023- """
1024- h = value .lstrip ("#" )
1025- if len (h ) != 6 :
1026- raise ValueError (f"invalid hex color: { value !r} " )
1027- return (int (h [0 :2 ], 16 ), int (h [2 :4 ], 16 ), int (h [4 :6 ], 16 ))
1028-
1029-
1030929def _transform_args (args : argparse .Namespace ) -> Dict [str , Any ]:
1031930 # Auto-enable force_binary for any non-ASCII encoding that uses high-bit bytes.
1032931 from .encodings import FORCE_BINARY_ENCODINGS
@@ -1075,11 +974,6 @@ def _transform_args(args: argparse.Namespace) -> Dict[str, Any]:
1075974 "send_environ" : tuple (v .strip () for v in args .send_environ .split ("," ) if v .strip ()),
1076975 "always_will" : {_parse_option_arg (v ) for v in args .always_will },
1077976 "always_do" : {_parse_option_arg (v ) for v in args .always_do },
1078- "colormatch" : args .colormatch ,
1079- "color_brightness" : args .color_brightness ,
1080- "color_contrast" : args .color_contrast ,
1081- "background_color" : _parse_background_color (args .background_color ),
1082- "ice_colors" : args .ice_colors ,
1083977 "raw_mode" : raw_mode ,
1084978 "ascii_eol" : args .ascii_eol ,
1085979 "ansi_keys" : args .ansi_keys ,
0 commit comments