This change adds a new Config record field, termWidthMaps, which holds a
list of pairs that map terminal names to width table file paths.
This change also extends the configuration parser to support lines of
the form
widthMap <Terminal> <Path>
where <Terminal> must be a double-quoted string literal indicating the
value of TERM for which the specified map should be active, and <Path>
must be a double-quoted string literal specifying the file path to the
width table file to use. E.g.,
widthMap "xterm" "/home/user/.vty/width_table_xterm.dat"
This change introduces a new module,
Graphics.Vty.UnicodeWidthTable.Install, that is responsible for
installing custom unicode width tables into the process. It does so by
allocating memory to hold the table, populating the table's character
ranges with widths from the UnicodeWidthTable, and then marking the
table as ready for use. That causes future calls to 'wcwidth' to consult
the new table rather than relying on the built-in logic to compute
widths.
Note that this functionality breaks the purity of 'wcwidth': 'wcwidth'
calls made before the installation of a custom table may return
different values after the table is installed, despite 'wcwidth' being a
pure function. This choice was made deliberately to simplify the API and
is based on the observation that in practice this will probably never be
an issue.
It's also worth nothing (as is spelled out in the docs, too) that a
custom table installation can only be performed at most once per program
lifetime. Once a custom table installation is performed, it cannot be
undone and no new table can be installed. This, too, is a simplification
based on the assumption that in practice multiple tables will usually
not be required.
This commit adds getTtyEraseChar. This function queries the kernel
for the current terminal's settings to obtain the character assigned
by the "stty erase" command. The "erase" character indicates which
input character the terminal should interpret to mean "backspace" when
the terminal is in canonical input mode. Vty applications run with
canonical mode disabled, but even in those cases some users may want
their "stty erase" setting honored by Vty's input-handling so that
incoming erase characters (according to stty) result in "KBS" key events
being delivered to the application.