curses: Add support for wide output
v2 cover curses: Add support for wide output
Hello,
This adds support for wide output in the curses frontend
Difference with previous version:
- Add more rationale in commit message
- Move charset option to curses-only section.
Samuel Thibault (2):
iconv: detect and make curses depend on it
curses: add option to specify VGA font encoding
configure | 45 ++++++- qapi/ui.json | 14 +++ qemu-options.hx | 5 +- ui/curses.c | 315 ++++++++++++++++++++++++++++++++++++++++-------- vl.c | 2 +- 5 files changed, 331 insertions(+), 50 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/2 iconv: detect and make curses depend on it
curses will use it for proper wide output support.
--- configure | 40 ++++++++++++++++++++++++++++++++++++++++ vl.c | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-)
configure +40 -0
@@ -1217,6 +1217,10 @@ for opt do ;; --enable-curses) curses="yes" ;; + --disable-iconv) iconv="no" + ;; + --enable-iconv) iconv="yes" + ;; --disable-curl) curl="no" ;; --enable-curl) curl="yes"
@@ -1718,6 +1722,7 @@ disabled with --disable-FEATURE, default is enabled if available: gtk gtk UI vte vte support for the gtk UI curses curses UI + iconv font glyph conversion support vnc VNC UI support vnc-sasl SASL encryption for VNC server vnc-jpeg JPEG lossy compression for VNC server
@@ -3398,8 +3403,39 @@ EOF fi fi +########################################## +# iconv probe +if test "$iconv" != "no" ; then + cat > $TMPC << EOF +#include <iconv.h> +int main(void) { + iconv_t conv = iconv_open("WCHAR_T", "UCS-2"); + return conv != (iconv_t) -1; +} +EOF + for iconv_lib in '' -liconv; do + if compile_prog "" "$iconv_lib" ; then + iconv_found=yes + libs_softmmu="$iconv_lib $libs_softmmu" + break + fi + done + if test "$iconv_found" = "yes" ; then + iconv=yes + else + if test "$iconv" = "yes" ; then + feature_not_found "iconv" "Install iconv devel" + fi + iconv=no + fi +fi + ########################################## # curses probe +if test "$iconv" = "no" ; then + # curses will need iconv + curses=no +fi if test "$curses" != "no" ; then if test "$mingw32" = "yes" ; then curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
@@ -6111,6 +6147,7 @@ echo "libgcrypt $gcrypt" echo "nettle $nettle $(echo_version $nettle $nettle_version)" echo "libtasn1 $tasn1" echo "PAM $auth_pam" +echo "iconv support $iconv" echo "curses support $curses" echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)" echo "curl support $curl"
@@ -6435,6 +6472,9 @@ fi if test "$cocoa" = "yes" ; then echo "CONFIG_COCOA=y" >> $config_host_mak fi +if test "$iconv" = "yes" ; then + echo "CONFIG_ICONV=y" >> $config_host_mak +fi if test "$curses" = "yes" ; then echo "CONFIG_CURSES=m" >> $config_host_mak echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
vl.c +1 -1
@@ -3171,7 +3171,7 @@ int main(int argc, char **argv, char **envp)#ifdef CONFIG_CURSES dpy.type =DISPLAY_TYPE_CURSES ;#else -error_report ("curses support is disabled" ); +error_report ("curses or iconv support is disabled" );exit (1 );#endif break ;
Signature · 1 line
2.20.1
PATCH v2 2/2 curses: add option to specify VGA font encoding
In reply to Samuel ThibaultThis uses iconv to convert glyphs from the specified VGA font encoding to unicode, and makes use of cchar_t instead of chtype when using ncursesw, which allows to store all wide char as well as the WACS values. The default charset is made CP437 since that is the charset of the hardware default VGA font. This also makes the curses backend set the LC_CTYPE locale to "" to allow curses to emit wide characters.
--- configure | 5 +- qapi/ui.json | 14 +++ qemu-options.hx | 5 +- ui/curses.c | 315 ++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 290 insertions(+), 49 deletions(-)
configure +4 -1
@@ -3449,14 +3449,17 @@ if test "$curses" != "no" ; then #include <locale.h> #include <curses.h> #include <wchar.h> +#include <langinfo.h> int main(void) { + const char *codeset; wchar_t wch = L'w'; setlocale(LC_ALL, ""); resize_term(0, 0); addwstr(L"wide chars\n"); addnwstr(&wch, 1); add_wch(WACS_DEGREE); - return 0; + codeset = nl_langinfo(CODESET); + return codeset != 0; } EOF IFS=:
qapi/ui.json +14 -0
@@ -1080,6 +1080,19 @@ { 'enum' : 'DisplayGLMode', 'data' : [ 'off', 'on', 'core', 'es' ] } +## +# @DisplayCurses: +# +# Curses display options. +# +# @charset: Font charset used by guest (default: CP437). +# +# Since: 4.0 +# +## +{ 'struct' : 'DisplayCurses', + 'data' : { '*charset' : 'str' } } + ## # @DisplayType: #
@@ -1142,6 +1155,7 @@ '*gl' : 'DisplayGLMode' }, 'discriminator' : 'type', 'data' : { 'gtk' : 'DisplayGTK', + 'curses' : 'DisplayCurses', 'egl-headless' : 'DisplayEGLHeadless'} } ##
qemu-options.hx +4 -1
@@ -1216,7 +1216,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, " [,window_close=on|off][,gl=on|core|es|off]\n" "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n" "-display vnc=<display>[,<optargs>]\n" - "-display curses\n" + "-display curses[,charset=<encoding>]\n" "-display none\n" "-display egl-headless[,rendernode=<file>]" " select display type\n"
@@ -1248,6 +1248,9 @@ support a text mode, QEMU can display this output using a curses/ncurses interface. Nothing is displayed when the graphics device is in graphical mode or if the graphics device does not support a text mode. Generally only the VGA device models support text mode. +The font charset used by the guest can be specified with the +@code{charset} option, for example @code{charset=CP850} for IBM CP850 +encoding. The default is @code{CP437}. @item none Do not display video output. The guest will still see an emulated graphics card, but its output will not be displayed to the QEMU
ui/curses.c +268 -47
358 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCHv2 2/2] curses: add option to specify VGA font encoding
Quoted 9 lines · Samuel Thibault
This uses iconv to convert glyphs from the specified VGA font encoding to unicode, and makes use of
cchar_tinstead of chtype when using ncursesw, which allows to store all wide char as well as the WACS values. The default charset is made CP437 since that is the charset of the hardware default VGA font. This also makes the curses backend set theLC_CTYPElocale to "" to allow curses to emit wide characters.Signed-off-by Samuel Thibault <[email protected]>Cc Eddie Kohler <[email protected]>
For the QAPI / CLI part:
Quoted 7 lines · Samuel Thibault
Hello,
This adds support for wide output in the curses frontend
Difference with previous version:
- Add more rationale in commit message
- Move charset option to curses-only section.
Added to UI patch queue (the other curses patches too).
thanks,
Gerd
Gerd Hoffmann, le jeu. 07 mars 2019 14:21:12 +0100, a ecrit:
Quoted 8 lines · Samuel Thibault
Quoted 5 lines
This adds support for wide output in the curses frontend
Difference with previous version:
- Add more rationale in commit message
- Move charset option to curses-only section.Added to UI patch queue (the other curses patches too).
Thanks!
Samuel