Raxol.Terminal.CharacterHandling (Raxol v0.4.0)

View Source

Handles wide character and bidirectional text support for the terminal emulator.

This module provides functions for:

  • Determining character width (single, double, or variable width)
  • Handling bidirectional text rendering
  • Managing character combining
  • Supporting Unicode character properties

Summary

Functions

Determines the bidirectional character type. Returns :LTR, :RTL, :NEUTRAL, or :COMBINING.

Determine the display width of a given character code point or string.

Gets the effective width of a string, taking into account wide characters and ignoring combining characters.

Determines if a character is a combining character.

Determines if a character is a wide character (takes up two cells).

Processes a string for bidirectional text rendering. Returns a list of segments with their rendering order.

Splits a string at a given width, respecting wide characters.

Functions

get_bidi_type(char)

Determines the bidirectional character type. Returns :LTR, :RTL, :NEUTRAL, or :COMBINING.

get_char_width(codepoint)

@spec get_char_width(codepoint :: integer() | String.t()) :: 1 | 2

Determine the display width of a given character code point or string.

get_string_width(string)

@spec get_string_width(String.t()) :: non_neg_integer()

Gets the effective width of a string, taking into account wide characters and ignoring combining characters.

is_combining_char?(char)

@spec is_combining_char?(char()) :: boolean()

Determines if a character is a combining character.

is_wide_char?(char)

@spec is_wide_char?(char()) :: boolean()

Determines if a character is a wide character (takes up two cells).

process_bidi_text(string)

@spec process_bidi_text(String.t()) :: [{:LTR | :RTL | :NEUTRAL, String.t()}]

Processes a string for bidirectional text rendering. Returns a list of segments with their rendering order.

split_at_width(string, width)

@spec split_at_width(String.t(), non_neg_integer()) :: {String.t(), String.t()}

Splits a string at a given width, respecting wide characters.