# dialog display ok, cdialog gibberish?



## arusan (Aug 23, 2011)

hi,

hope this isn't something well-known, I searched for some time for it and no success.

On my 8.2 Release, mostly generic, dialog displays totally ok (with the graphic lines).
compiled cdialog from ports (since I need the gauge box), make sure I have the latest ncurses (5.7?) - BUT i get only trash from it's output --> instead of lines i get ^@^@ and no colors.

I played around with different terminals, still the same. I use cons25 no UTF-8 (with UTF-8 dialog goes to "poor man's lines"), tried vt100, vt220, cons25w, cons50, ansi... most of them also break dialog, but cdialog is still the same.

when using --ascii-lines I get the ascii lines, but still no colors - and I would actually need the graphical lines.

any help appreciated! thanks!


----------



## freethread (Aug 23, 2011)

This happens in local ttyv consoles?

What I know about ttyv consoles is


Use the system ncurses libraraies. Avoid installing devel/ncurses
Set a console font compatible with the charset see kbdmap(1) man page or run vidfont to interactively see and choose an available font.
Set NCURSES_NO_UTF8_ACS environment variable. I guess this is useful only with real UTF8 terminal emulators, it works for remote connections.

There are some combinations in ttyv consoles that cannot be made, i.e. 'I want ISO8859 charset and graphic line chars' or 'I want full UTF8 charset'. Personally, it's better to have a sane console environment, perhaps limited, and use a graphic environment, (see this post)

Anyways, settings an ISO8859 charset (LANG and LC_ALL environment variables) and an ISO8859 console font there will be no line drawing characters (use --ascii-lines or --no-lines in cdialog), setting cp437, cp850 or similar has drawing line chars but lacks other language specific characters.

Personally I do not use ttyv consoles, the charset is UTF8, font is 'swiss' (it is wrong but looks good). If something go wrong at boot and I cannot run X server or remote connections, I set LANG and LC_ALL to ISO8859 (or cp437), in .cshrc/.shrc, and reboot the system, try to restore normal operations, when all restored set back to UTF8 and reboot.

As last note, in the past I installed sysutils/jfbterm, a graphics terminal with full UTF8 support.


----------



## arusan (Aug 24, 2011)

yes, in local consoles.
but the interface will be used over putty, so I do want to avoid to play around much with custom stuff that I cannot reproduce on putty after that...

using ncurses in c and compiling gets me good results, but also alot of extra work...

I did also not mess with the charset, console type or resolution. I expeced the defaults to work ok - they do so for dialog and ncurses in c, but not foc cdialog... and I wonder why. I run all on the same machine, same terminal, same setting - one after another. only cdialog has problems.


----------



## freethread (Aug 24, 2011)

I use putty too, but on a remote windows system with a quasi complete unicode font. I don't know how you run putty on FreeBSD, I guess it runs in graphic mode under X window, If it run in ttyv console it use the same font syscons use.

Using dialog and cdialog on the command line you should see the same result (delete or rename any personal dialog/cdialog configuration file),

```
dialog --yesno "This is a test, this is only a test" 0 0
cdialog --yesno "This is a test, this is only a test" 0 0
```
if not, try to set others charsets in LANG and LC_ALL and for each one try a different font using vidfont. There are only few combinations that works in the right way and not in the same way.


----------



## arusan (Aug 24, 2011)

the putty is used on windows, on a remote machine. when I was talking about ttyv, I was talking about local FreeBSD console, run on the same machine where the script is located.

either way, the result is the same: for dialog everything looks ok (color, borders etc), for cdialog it's trash. using the simple example you suggested, too. run in the same session/console, one after the other.
that's why I can't understand it, either...

the system is a new install, right after installation I installed the cdialog port - so no weird compat issues I think...


----------



## freethread (Aug 24, 2011)

arusan said:
			
		

> for dialog everything looks ok (color, borders etc), for cdialog it's trash.



yes, dialog and cdialog are different, I guess cdialog use the widechar ncurses library (ncursesw) and use it as appropriate.

what I found is that cdialog works fine with UTF-8 charset, in ttyv displays ASCII lines, in putty and X terminals unicode lines, while dialog dont display lines (spaces) in ttyv and ASCII lines in putty and X terminals (with UTF-8 charset both in ttyv and unicode terminals).

If dialog display semigraphic the charset is cp437 or a similar code page, cdialog should works. Try to set


```
setenv NCURSES_NO_UTF8_ACS 1
```

I don't know if it works in ttyv. The font can be wrong, try all cpXXX fonts and see if something change (with vidfont).


----------



## arusan (Aug 24, 2011)

so, with the dialog example with 0 0 I get some weird placement on the display. but for any size I explicitly set (like 10 10) it looks perfectly ok in the putty remote terminal.
cdialog still junk in all situations, no colors too.

setenv does not work on my system, so I export this variable =1. no difference for both dialog and cdialog.
set it to 0, identical display for both.

tried to use vidfont: set swiss 8x8, swiss 8x16, cp437 en 8x8 - 8x16 - 8x14 etc --> absolutely no difference.
Am i doing smtg wrong?


----------



## freethread (Aug 24, 2011)

no colors? you have installed devel/ncurses? It does not work as expected. dialog is part of the system and is not compiled with that so there are more differencies. When I installed it and recompiled all ports that depend on ncurses, all turned b/w, I guess it is a termcap/terminfo problem. Also with terminfo downloaded from ncurses site things doesn't change. The display is recognized as vt100.


----------



## arusan (Aug 24, 2011)

dammit, yes... devel/ncurses, slipped my mind even though it was mentioned before. seems it is installed.
can i get rid of it and revert to the system ncurses?


----------



## freethread (Aug 24, 2011)

arusan said:
			
		

> dammit, yes... devel/ncurses, slipped my mind even though it was mentioned before. seems it is installed.
> can i get rid of it and revert to the system ncurses?



lol, I uninstalled it. My tty console has a completely wrong settings but it works for what I need. I dont care a lot if display is color or b/w but with devel/ncurses you don't see where the selection is, there is no selection so it's difficult to navigate sysinstall or port options. My primary goal is to have UTF-8 support for xterm-like terminals (putty and X terminals). In ttyv the 'poor man's line draw' is good for me (ASCII lines), rarely I use ttyv but it's better to avoid characters like xqqqqqqqqqx or other alphanum chars, also space (no lines at all) is good for me. And more better if I have to no add switches when run programs like '--ascii-lines', '--no-lines', '-a', etc.

My super-wrong settings are

/etc/ttys
cons25l1 (that is an ISO8859-1)

for csh/tcsh
$HOME/.cshrc

```
setenv LANG en_US.UTF-8
setenv LC_ALL en_US.UTF-8
setenv MM_CHARSET UTF-8     # this is for X

setenv NCURSES_NO_UTF8_ACS 1
```

for bash/sh
$HOME/.bashrc (and/or .shrc)

```
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export MM_CHARSET=UTF-8

export NCURSES_NO_UTF8_ACS=1
```

for the above the localization can be custom, i.e. 'it_IT.UTF-8', 'fr_FR.UTF-8', etc.

font 'swiss' (cp437?)

The NCURSES_NO_UTF8_ACS should not be set in ttyv, only in xterm-capable (real UTF-8) terminals, so wrap it in an if, in tcsh I use the $tty variable, if it starts with 'ttyv' it's a ttyv console, in bash don't know how to check this (I never used bash).

Setting a ttyv in UTF-8 is not a good choice for few console programs and for the keyboard, the non ASCII keys must be avoided (i.e. Ã Ã¨Ã¬Ã²Ã¹), only 'poor man's line draw' will be used in cdialog while dialog show spaces (equivalent to --no-lines), in putty and Co all UTF-8 programs display UTF-8 characters, all ncurses (compiled without widechars library, libncurses instead of libencursesw) display ASCII lines.

If you want to display semigraphics char both for dialog and cdialog in ttyv the choice is to set a code page as charset (.cshrc and .bashrc), use cons25 in /etc/ttys, set a code page font, with this settings there is no UTF-8 support for putty and X terminals.

That's all I know. And last but not least, avoid ncurses/devel

I forgot one thing, all UTF-8 terminals are set as xterm or xterm-256colors (this for tmux in putty avoid the -2 command line switch, anyways tmux termnal is 'screen')


----------

