Repository navigation
Conversation
why: Legacy VT streams and pyte callers rely on 80/132-column switching, IBM PC CP437 graphic designations, and ISO-2022 wire-encoding switches without weakening modern UTF-8 or tmux geometry defaults. what: - Add Mode.DECCOLM (?3), Mode.ALLOW_80_132 (?40), Mode.DECNCSM (?95), and DeccolmBehavior (default GATED_BY_MODE_40; CLEAR_ONLY on tmux) - Add 'U' (IBM PC / CP437 0xA0..0xFF) G0..G3 charset mapping in latin-1 mode while keeping 'V' as a documented US-ASCII fallback - Add opt-in Parser.allow_encoding_switch for ESC % G / ESC % @ DOCS transitions, codec.explain disassembly, and feed_str() latin-1 guard
4 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #58
Summary
DeccolmBehaviorand DEC modes?3,?40, and?95.'U'(CP4370xA0..0xFF) graphic charset designations onG0..G3in"latin-1"mode.DOCS(ESC % GandESC % @) wire-encoding transitions.ValueErrorfromTerminal.feed_str()while the parser wire encoding is"latin-1".ESC % GandESC % @sequences inlibvt.codec.explain().Changes
Modes, profiles, and configuration
src/libvt/modes.py: addMode.DECCOLM(3),Mode.ALLOW_80_132(40), andMode.DECNCSM(95).src/libvt/config.py: add'U'toCharset, addDeccolmBehavior(IGNORE,GATED_BY_MODE_40,ALWAYS,CLEAR_ONLY), and adddeccolmandallow_encoding_switchfields toScreenBehavior.src/libvt/profiles.py: setdeccolm=DeccolmBehavior.IGNOREandallow_encoding_switch=TrueonLINUX_CONSOLE_PROFILE.src/libvt/contrib/tmux/profile.py: setdeccolm=DeccolmBehavior.CLEAR_ONLYintmux_profile().Parser, terminal, and codec
src/libvt/parser.py: addallow_encoding_switchandParser.set_encoding(), switching wire encoding onESC % GandESC % @(afterESCaborts any incomplete UTF-8 sequence asU+FFFD), clearing UTF-8 decoder state when entering"latin-1", and restoring the initial encoding onParser.reset().src/libvt/terminal.py: addTerminal.encoding, implementDECCOLMresize/clear/margin-reset/cursor-homing semantics, save and restoreG0..G3/GL/single-shift state acrossDOCSswitches, add the UnicodeCP4370xA0..0xFFtable for'U', order?95/?3/?40inXTRESTOREandFormatterVT output, wireRISandDECRQM, and rejectTerminal.feed_str()whenparser.encoding == "latin-1".src/libvt/codec.py: disassembleESC % G(encoding -> UTF-8) andESC % @(encoding -> legacy) asDOCSspans inexplain().Tests and documentation
tests/test_pyte_compat.py: coverDECCOLMprofiles,CP437'U'shifts andDECSC/DECRCstate,'V'fallback,DOCSsplit-sequence transitions, andfeed_str()in"latin-1"mode.docs/api/config.mdandCHANGES: add'U'to theCharsetAPI directive (DeccolmBehaviorrenders viaautomodule) and record the#58changelog entry.Design decisions
ScreenBehavior.deccolmtoDeccolmBehavior.GATED_BY_MODE_40with?40initially reset rather thanALWAYSto matchxterm'sc132=falsedefault;tmux_profile()usesCLEAR_ONLYsotmuxretains authoritative pane widths.80columns unconditionally onCSI ? 3 lrather than restoring a pre-DECCOLMcustom width soDECCOLMstays independent of host window resize state.allow_encoding_switch=FalseonDEFAULT_PROFILE,XTERM_PROFILE, andtmuxprofiles rather than enablingESC % @globally so untrusted output cannot flip UTF-8 sessions into 8-bitC1parsing;LINUX_CONSOLE_PROFILEopts in withallow_encoding_switch=True.pyte's'V'(VAX42) designation and keep the US-ASCII'B'fallback because no clean-room standard mapping satisfies ADR 0001.Test plan
?95hno-clearDECCOLMtransitions intests/test_pyte_compat.pyCP437'U'G0..G3shifts,DECSC/DECRCsave/restore, and'V'fallback intests/test_pyte_compat.pyESC % @andESC % Gchunk boundaries,RISreset, andfeed_str()guard intests/test_pyte_compat.pyruff format,ruff check,ty check,pytest, andjust build-docs