Commit Graph

32 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
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
cd534c1028 Revert "Replace stale wcwidth implementation with utf8proc library call"
This reverts commit 437b27f052.
2016-11-19 11:46:35 -08:00
Jonathan Daugherty
c0f919c533 Revert "Add bundled utf8proc so we don't have to depend on a local version"
This reverts commit 989de89a42.
2016-11-19 11:46:32 -08:00
Jonathan Daugherty
989de89a42 Add bundled utf8proc so we don't have to depend on a local version 2016-11-12 16:17:17 -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
Corey O'Connor
dbb8ff9612 use hack from SendFile for determining Fd for handle. Use when requesting window size 2014-04-09 17:08:40 -07:00
Corey O'Connor
87e09a1484 derive new input loop 2014-01-21 03:50:57 -08:00
Corey O'Connor
451b12eee9 add back in tab support 2014-01-16 00:16:05 -08:00
Corey O'Connor
0bbc3397e1 split input table generation based on terminal type 2013-12-24 22:06:58 -08:00
Corey O'Connor
b3013245fd start refactoring input layer into a nice interface structure 2013-12-21 23:22:49 -08: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
4e956571eb remove stdout_output_buffer. Not used anymore
Ignore-this: 14dfb4c96aaf726b6c0794846d9a04aa

darcs-hash:20101111191217-f0a0d-e9e1046c7af4804b0d18516157566b6a26ec5c3d.gz
2010-11-11 11:12:17 -08:00
coreyoconnor
9bad126948 be certain to use the same output device as before any stdout redirection
Ignore-this: 8d49a95192e5f40a7e26bd403138425

darcs-hash:20100806211634-f0a0d-b80d746b71da80a8e5b7e54e0731a989f837a642.gz
2010-08-06 14:16:34 -07:00
coreyoconnor
4f06259de3 Invoke write directly instead of via hPutBuf
Ignore-this: 172072f7a4876e5864c8e54f896bf0b0

darcs-hash:20100114091229-f0a0d-915e8160f8cf596abbae4df8c9d883febeedf509.gz
2010-01-14 01:12:29 -08: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