Commit Graph

21 Commits

Author SHA1 Message Date
Jonathan Daugherty
e8e3fa3ba8 vty_deallocate_custom_table: also reset size 2020-03-05 14:19:53 -08:00
Jonathan Daugherty
0de76e531e vty_custom_table_ready: simplify 2020-03-05 14:19:42 -08:00
Jonathan Daugherty
b988b6894e vty_set_custom_table_range: avoid overflow in test 2020-03-05 14:19:28 -08:00
Jonathan Daugherty
24b9c8c0f5 vty_init_custom_table: default to 1 for widths of unknown code points 2020-03-05 14:19:00 -08:00
Jonathan Daugherty
a2d9c0a165 vty_mk_wcwidth: return -1 on failure 2020-03-05 14:18:40 -08:00
Jonathan Daugherty
1dc1239b39 vty_mk_wcwidth: simplify check 2020-03-05 14:18:30 -08:00
Jonathan Daugherty
ee91cb6245 builtin_wcwidth: make static 2020-03-05 14:18:02 -08:00
Jonathan Daugherty
2732b1be08 mk_wcwidth.c: docs nit 2020-03-05 11:09:21 -08:00
Jonathan Daugherty
3cb9cfc6d8 mk_wcwidth.c: docs nit 2020-03-05 11:08:51 -08:00
Jonathan Daugherty
d8b33ab53e mk_wcwidth.c: docs nit 2020-03-05 11:08:36 -08:00
Jonathan Daugherty
904a5b1040 mk_wcwidth.c: nit 2020-03-05 11:07:08 -08:00
Jonathan Daugherty
a247079058 mk_wcwidth.c: nit 2020-03-05 11:06:01 -08:00
Jonathan Daugherty
e07f287d07 installUnicodeWidthTable: on range population failure, deallocate the custom table 2020-03-03 16:17:02 -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
4ef603a612 mk_wcwidth.c: whitespace 2020-02-28 09:22:29 -08:00
Jonathan Daugherty
cd534c1028 Revert "Replace stale wcwidth implementation with utf8proc library call"
This reverts commit 437b27f052.
2016-11-19 11:46:35 -08:00
Jonathan Daugherty
437b27f052 Replace stale wcwidth implementation with utf8proc library call 2016-11-12 15:31:23 -08:00
Eric Mertens
21f0f9d474 Use Haskell types directly in C code, remove unused C procedures 2016-08-28 14:52:32 -07:00
Paul van der Walt
54d35d6ade prefixed all c functions to avoid Cabal bug #944 2012-04-22 15:49:25 +02:00
Mikolaj
18fe87aa96 attempt to fix a segfault possibly due to not NUL terminated strings
The strings used in withCWStringLen are (despite the incorrect comment)
supposed to come equipped with length, but no NUL at the end
(in particular nothing is allocated for an empty string).
Fortunately, here the length suffices.

See http://hackage.haskell.org/trac/ghc/ticket/5396
and https://github.com/coreyoconnor/vty/issues/14#issuecomment-1813397
2011-08-16 21:57:29 +02:00
coreyoconnor
7b38759846 use alloca instead of mallocBytes for exception safety
Ignore-this: 1d31bef2e227fefafe8bb4b6f9511e1d

darcs-hash:20090904172928-f0a0d-987b6931294fd33f7825eddc0adf04c81716a4dd.gz
2009-09-04 10:29:28 -07:00