Raxol.Terminal.ANSI.CharacterSets (Raxol v0.5.0)
View SourceManages character set switching and translation for the terminal emulator. Supports G0, G1, G2, G3 character sets and their switching operations.
Summary
Types
Character set state struct for terminal emulation (G0-G3, GL/GR, single/locked shift).
Functions
Map character code byte to charset atom (Based on escape_sequence.ex). Public for use in tests and other modules.
Map character code byte to charset module.
Clears any active single shift. This should be called after processing a character that was interpreted using a single-shifted charset.
Delegates to Handler.designate_charset/3 for designating a character set for a specific G-set.
Gets the active character set based on the current state. Note: This function does not consume an active single shift. The caller is responsible for calling clear_single_shift after processing the character if a single shift was active.
Map G-set index (0-3) to map key (:g0-:g3). Public for use in tests and other modules.
Invokes a character set designator into GL or GR. By default, invokes into GL (left). If the second argument is :gr, invokes into GR (right).
Creates a new character set state with default values.
Sets the active character set.
Sets the character set designator.
Sets the GL (left) character set.
Sets the GR (right) character set.
Sets the locking shift character set.
Activates a single shift for the next character. SS2 invokes the G2 character set. SS3 invokes the G3 character set.
Switches the specified character set to the given charset.
Translates a character using the active character set.
Translates a string using the active character set.
Types
@type charset() ::
:us_ascii
| :uk
| :french
| :german
| :swedish
| :swiss
| :italian
| :spanish
| :portuguese
| :japanese
| :korean
| :latin1
| :latin2
| :latin3
| :latin4
| :latin5
| :latin6
| :latin7
| :latin8
| :latin9
| :latin10
| :latin11
| :latin12
| :latin13
| :latin14
| :latin15
@type codepoint() :: non_neg_integer()
@type gl_gr_target() :: :gl | :gr
@type gset_name() :: :g0 | :g1 | :g2 | :g3
@type t() :: charset_state()
Character set state struct for terminal emulation (G0-G3, GL/GR, single/locked shift).
Functions
Map character code byte to charset atom (Based on escape_sequence.ex). Public for use in tests and other modules.
Map character code byte to charset module.
@spec clear_single_shift(charset_state()) :: charset_state()
Clears any active single shift. This should be called after processing a character that was interpreted using a single-shifted charset.
Delegates to Handler.designate_charset/3 for designating a character set for a specific G-set.
@spec get_active_charset(charset_state()) :: module()
Gets the active character set based on the current state. Note: This function does not consume an active single shift. The caller is responsible for calling clear_single_shift after processing the character if a single shift was active.
Map G-set index (0-3) to map key (:g0-:g3). Public for use in tests and other modules.
@spec invoke_designator(charset_state(), :g0 | :g1 | :g2 | :g3, :gl | :gr) :: charset_state()
Invokes a character set designator into GL or GR. By default, invokes into GL (left). If the second argument is :gr, invokes into GR (right).
Creates a new character set state with default values.
@spec set_active(charset_state(), module()) :: charset_state()
Sets the active character set.
@spec set_designator(charset_state(), :g0 | :g1 | :g2 | :g3, module()) :: charset_state()
Sets the character set designator.
@spec set_gl(charset_state(), :g0 | :g1 | :g2 | :g3) :: charset_state()
Sets the GL (left) character set.
@spec set_gr(charset_state(), :g0 | :g1 | :g2 | :g3) :: charset_state()
Sets the GR (right) character set.
@spec set_locking_shift(charset_state(), module()) :: charset_state()
Sets the locking shift character set.
@spec set_single_shift(charset_state(), :ss2 | :ss3) :: charset_state()
Activates a single shift for the next character. SS2 invokes the G2 character set. SS3 invokes the G3 character set.
@spec switch_charset(charset_state(), :g0 | :g1 | :g2 | :g3, module()) :: charset_state()
Switches the specified character set to the given charset.
@spec translate_char(codepoint(), charset_state()) :: String.t()
Translates a character using the active character set.
@spec translate_string(String.t(), charset_state()) :: String.t()
Translates a string using the active character set.