Commit Graph

767 Commits

Author SHA1 Message Date
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
Jonathan Daugherty
0f08358bd3 Bump version, update changelog 2019-10-01 10:10:30 -07:00
Jonathan Daugherty
a2dc0a9a38
Merge pull request #178 from jtdaugherty/import-warnings
Remove import warnings
2019-10-01 09:58:01 -07:00
Jonathan Daugherty
6aa1d0539b
Merge pull request #177 from glguy/just-io-patch
Remove unnecessary MonadIO and MonadFail uses
2019-10-01 09:33:00 -07:00
Eric Mertens
7d1bcce9a9 Remove import warnings 2019-10-01 09:23:51 -07:00
Eric Mertens
4fcd927f29 Remove now redundant imports 2019-10-01 08:42:34 -07:00
Eric Mertens
afa2cb0600 Remove unnecessary MonadIO and MonadFail uses 2019-09-30 16:51:01 -07:00
Jonathan Daugherty
66a2f0102a
Merge pull request #176 from mcschroeder/master
Add missing MonadFail constraints
2019-09-18 09:10:40 -07:00
Michael Schröder
dff049003a Add missing MonadFail constraints
Beginning with GHC 8.8, 'fail' is no longer part of the Monad class.
2019-09-18 16:43:43 +02:00
Jonathan Daugherty
3ce0db6a5b
Merge pull request #173 from cjenn/colornote
Clarify documentation for ANSI colors, rename rgbColor to rgbColorToColor240
2019-06-26 09:34:24 -07:00
Colby Jenn
1125b2fb11 rename "make240ColorCodeFromRGB" to "rgbColorToColor240" 2019-06-26 00:23:22 -05:00
Jonathan Daugherty
edd09450b2
Merge pull request #174 from neongreen/patch-1
Bump microlens
2019-06-20 07:06:12 -07:00
Artyom Kazak
3caad88a19
Bump microlens bound 2019-06-20 08:52:10 +03:00
Colby Jenn
800336f789 move color documentation to separate module 2019-06-16 13:14:14 -05:00
Colby Jenn
ed27311ba7 Clarify haddock for ANSI colors
We have to copy the Color.hs exports to Attributes.hs
to be able to write haddocks, unfortunately
2019-06-07 00:35:27 -05:00
Jonathan Daugherty
fc95860718
Merge pull request #168 from Supernerd11/lookupEnv
Changed System.Posix.Env (specifically 'getEnv') to System.Environment
2019-02-23 08:40:32 -08:00
Jonathan Osser
0a41207bea Removed commented out import System.Posix.Env 2019-02-23 10:20:10 +01:00