Commit Graph

908 Commits

Author SHA1 Message Date
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
Jonathan Osser
ee208766d5 Changed System.Posix.Env (specifically 'getEnv') to System.Environment 2019-02-22 23:28:07 +01:00
Jonathan Daugherty
38948b4c4f utf8Bytestring': correct typo in docstring 2018-12-27 08:54:20 -08:00
Jonathan Daugherty
0e1fc0e916 spelling cleanup: effected -> affected 2018-11-28 11:40:30 -08:00
Jonathan Daugherty
222f2bdaef Remove unneeded inline rules for wctwidth, wctlwidth 2018-11-28 11:26:38 -08:00
Jonathan Daugherty
c384656988 Add rewrite rules to use wct(l)width instead of wcswidth/unpack 2018-11-28 11:17:43 -08:00
Jonathan Daugherty
d64ff96027 Improve space performance of text width functions
This change introduces new text width functions to avoid intermediate
text/string conversions:
* Graphics.Text.Width.wctwidth
* Graphics.Text.Width.wctlwidth
* Graphics.Text.Width.safeWctwidth
* Graphics.Text.Width.safeWctlwidth

The 't' versions are for Data.Text and 'tl' are for Data.Text.Lazy. This
change also updates the string variants to use foldl' instead of (map .
sum).
2018-11-28 11:08:44 -08:00
Jonathan Daugherty
ec7b51eaa7 Bump version, update changelog 2018-11-04 07:40:46 -08:00
Jonathan Daugherty
8f32f8ea4c PictureToSpans: replace specialized lens operators with more fundamental ones
This change removes -~ and +~ definitions that can conflict with those
provided by Microlens, and which were just copies of what Microlens now
provides. Instead of using those, this change just inlines their
functionality in the right spots so that we don't have to conditionally
define or import those operators depending on the version of Microlens,
which just recently started to provide these.

This change also goes ahead and introduces an upper bound on Microlens
to avoid future issues like this.
2018-11-04 07:35:11 -08:00
Jonathan Daugherty
74a72ff59f Bump version, update changelog 2018-10-15 13:38:09 -07:00