menu: draw dialog borders with Unicode box characters

dialog draws its borders through the ncurses alternate charset: the
VT100 switch ESC(0 followed by letters. PuTTY (default TERM=xterm),
mosh and hterm ignore that switch in UTF-8 mode, so the borders show
up as letters (lqqqk, x, mqqqj).

Set NCURSES_NO_UTF8_ACS=1 for the dialog call. ncurses then emits
U+2500 box-drawing characters directly; every UTF-8 terminal renders
those. Outside UTF-8 locales ncurses ignores the variable, so
non-UTF-8 terminals keep the alternate charset.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Igor Velkov
2026-09-08 08:34:43 +02:00
committed by Igor
co-authored by Claude Fable 5.1
parent f0531fe7be
commit 9ebabb47b0
+6 -4
View File
@@ -34,10 +34,12 @@ function dialog_if_terminal_set_vars() {
set +o errtrace # do not trap errors inside a subshell/function
set +o errexit # disable
exec 3>&1 # open fd 3...
DIALOG_RESULT=$(dialog "$@" 2>&1 1>&3) # juggle fds and capture.
DIALOG_EXIT_CODE=$? # get the exit code.
exec 3>&- # close fd 3...
# Draw borders with Unicode box characters rather than the VT100 alternate charset:
# PuTTY and other emulators that report TERM=xterm but ignore that charset switch in UTF-8 mode show letters.
exec 3>&1 # open fd 3...
DIALOG_RESULT=$(NCURSES_NO_UTF8_ACS=1 dialog "$@" 2>&1 1>&3) # juggle fds and capture.
DIALOG_EXIT_CODE=$? # get the exit code.
exec 3>&- # close fd 3...
set -e # back to normal
set -o errtrace # back to normal