Commit Graph

783 Commits

Author SHA1 Message Date
Jonathan Daugherty
0bea225b6d Rename vty-build-table to vty-build-width-table, rename main source file 2020-03-05 08:39:16 -08:00
Jonathan Daugherty
4de0a40be0 Long line 2020-03-03 16:46:32 -08:00
Jonathan Daugherty
73950ca0de Add missing conditional import 2020-03-03 16:26:23 -08:00
Jonathan Daugherty
c1e534b991 Naming nit 2020-03-03 16:18:32 -08:00
Jonathan Daugherty
e07f287d07 installUnicodeWidthTable: on range population failure, deallocate the custom table 2020-03-03 16:17:02 -08:00
Jonathan Daugherty
7845acd565 Add missing conditional imports 2020-03-03 16:05:54 -08:00
Jonathan Daugherty
124436e1de installWidthTable: handle and log exceptions raised by readUnicodeWidthTable 2020-03-03 15:49:58 -08:00
Jonathan Daugherty
16d5f27832 installUnicodeWidthTable: improve documentation again 2020-03-03 13:13:41 -08:00
Jonathan Daugherty
36b72dc2ed installUnicodeWidthTable: improve documentation 2020-03-03 13:12:18 -08:00
Jonathan Daugherty
1545df3207 UnicodeWidthTable: documentation improvements 2020-03-03 13:07:05 -08:00
Jonathan Daugherty
1352476439 Vty: improve docstring 2020-03-03 09:38:04 -08:00
Jonathan Daugherty
a3c009b69a Haddock formatting fix 2020-03-03 09:34:57 -08:00
Jonathan Daugherty
00c42b6f34 Naming nit 2020-03-03 09:25:07 -08:00
Jonathan Daugherty
b212597194 Whitespace 2020-03-03 09:24:13 -08:00
Jonathan Daugherty
b7861b38a5 Whitespace 2020-03-03 09:23:49 -08:00
Jonathan Daugherty
092cca91ca mkVty: clarify fallback behavior 2020-03-03 09:22:20 -08:00
Jonathan Daugherty
e3ccaa7675 mkVty: document table loading behavior 2020-03-03 09:21:25 -08:00
Jonathan Daugherty
ff8fd2dd32 Correct misspelling in allowCustomUnicodeWidthTables field name 2020-03-03 09:19:35 -08:00
Jonathan Daugherty
8ecdb953e4 Config: make allowCustomUnicodeWithTables more usable in Semigroup instance 2020-03-03 09:19:01 -08:00
Jonathan Daugherty
18ee5fe883 Whitespace 2020-03-03 09:16:04 -08:00
Jonathan Daugherty
ee1bf20c37 Whitespace 2020-03-03 09:13:25 -08:00
Jonathan Daugherty
11e0f2b0a2 Whitespace 2020-03-03 09:12:32 -08:00
Jonathan Daugherty
c4ab1e9b53 Whitespace 2020-03-03 09:11:56 -08:00
Jonathan Daugherty
59f90de8b2 Config: make Semigroup instance take disjunction of allowCustomUnicodeWithTables values 2020-03-03 09:06:23 -08:00
Jonathan Daugherty
9737f2b4ee Config: add allowCustomUnicodeWithTables to control whether a custom table load is ever attempted 2020-03-02 16:25:06 -08:00
Jonathan Daugherty
9edfd029cb mkVty: automatically load a custom unicode width table if one is available and configured 2020-03-02 14:40:20 -08:00
Jonathan Daugherty
21d75153c1 isCustomTableReady: translate C integer to Haskell Bool 2020-03-02 14:40:07 -08:00
Jonathan Daugherty
bd07727819 BuildUnicodeTable: print out configuration advice after finishing 2020-03-02 14:27:05 -08:00
Jonathan Daugherty
b73efb4b73 Config: support specifying character width map paths
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"
2020-03-02 14:24:36 -08:00
Jonathan Daugherty
e882198035 Graphics.Vty.Config: add and export currentTerminalName function 2020-03-02 14:24:14 -08:00
Jonathan Daugherty
771dee8ae1 Remove stale import 2020-03-02 14:15:07 -08:00
Jonathan Daugherty
74a7c557fb Add support for custom character width table installation
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.
2020-03-02 14:05:40 -08:00
Jonathan Daugherty
f48e4493c7 BuildUnicodeTable: use foldr 2020-03-02 13:37:32 -08:00
Jonathan Daugherty
a80e99b669 Graphics.Text.Width: remove stale comment 2020-02-28 13:05:31 -08:00
Jonathan Daugherty
4ef603a612 mk_wcwidth.c: whitespace 2020-02-28 09:22:29 -08:00
Jonathan Daugherty
1faafd71d9 buildUnicodeWidthTable: cleanup 2020-02-27 17:02:36 -08:00
Jonathan Daugherty
f475aaaaa5 Graphics.Vty.UnicodeWidthTable.Query: factor out table upper bound constant and docs 2020-02-27 16:58:44 -08:00
Jonathan Daugherty
7fdc7151c8 buildUnicodeWidthTable: add cautionary note about code point space 2020-02-27 16:54:31 -08:00
Jonathan Daugherty
0db1f71923 vty-build-table: use GetOpt to clean up and improve command line UI 2020-02-27 16:40:56 -08:00
Jonathan Daugherty
154800b4a8 Graphics.Vty.Config: expose widthTableFilename, vtyDataDirectory, and terminalWidthTablePath 2020-02-27 16:40:42 -08:00
Jonathan Daugherty
e0d05e3571 vty-build-table: write built table to a file for testing 2020-02-27 16:09:35 -08:00
Jonathan Daugherty
cd9e17b6b0 Whitespace 2020-02-27 16:09:21 -08:00
Jonathan Daugherty
9e785f693f Document buildUnicodeWidthTable 2020-02-27 16:08:44 -08:00
Jonathan Daugherty
e8841e7b3d vty-build-table: call buildUnicodeWidthTable and print the result 2020-02-27 15:58:31 -08:00
Jonathan Daugherty
e271a43a01 Add Graphics.Vty.UnicodeWidthTable.Query to build a unicode width table by querying the terminal on stdin 2020-02-27 15:58:12 -08:00
Jonathan Daugherty
60c55bae3d Add tools/BuildUnicodeTable.hs, a testing program for unicode table API 2020-02-27 15:25:30 -08:00
Jonathan Daugherty
908d189422 Add Graphics.Vty.UnicodeWidthTable.IO to read and write table files 2020-02-27 15:25:08 -08:00
Jonathan Daugherty
345c0bfa64 Add Graphics.Vty.UnicodeWidthTable.Types (data types for unicode width tables) 2020-02-27 15:00:30 -08:00
Jonathan Daugherty
bd8a18c924 Bump version, update changelog 2020-02-27 10:57:05 -08:00
Jonathan Daugherty
4362b3cb1c Add Graphics.Vty.Config.getTtyEraseChar
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.
2020-02-27 09:46:04 -08:00