Unicode symbols in the menu title seem to produce newlines on redraw
The observed behaviour is that on each redraw (e.g. when moving the selection cursor), a newline is added in the terminal in front of the menu, if unicode characters, such as ❓ are present in the title.
The specific instanciation in our problem-case is
terminal_menu = _TerminalMenu(
candidates,
title="\n---------- ❓ Please select the references you want to modify",
multi_select=True,
show_multi_select_hint=True,
multi_select_select_on_accept=False,
multi_select_empty_ok=True,
)
As far as we could tell it is not related to the \n at the beginning of the string.
System:
- Ubuntu 16
- Python 3.8.5
ok, just verified at Ubuntu 20.04 it does not reproduce (moved 2 items down): The same with python:3.5.10 docker image: docker run -it --rm -v=/home/sos/Downloads:/test_dir python:3.5.10 /bin/bash pip3 install simple-term-menu
locale 1116ms LANG=en_US.UTF-8
python3 simple_term_menu_unicode_bug.py 1574ms
someting with unicode ->>❓<-- would reproduce issue
a
b
c
d
But please see what happen in our developement docker container with ubuntu 16.04:
each move of selection I have another line with menu printed:
$ python3 simple_term_menu_unicode_bug.py
someting with unicode ->>❓<-- would reproduce issue someting with unicode ->>❓<-- would reproduce issue someting with unicode ->>❓<-- would reproduce issue someting with unicode ->>❓<-- would reproduce issue
a
b
c
d
TEST CODE: cat simple_term_menu_unicode_bug.py from simple_term_menu import TerminalMenu
menu = TerminalMenu( ['a', 'b', 'c', 'd'], title="someting with unicode ->>❓<-- would reproduce issue", )
menu.show()
Maybe it's some issue with locale settings (affected docker container)? locale LANG= LANGUAGE= LC_CTYPE="C.UTF-8" LC_NUMERIC="C.UTF-8" LC_TIME="C.UTF-8" LC_COLLATE="C.UTF-8" LC_MONETARY="C.UTF-8" LC_MESSAGES="C.UTF-8" LC_PAPER="C.UTF-8" LC_NAME="C.UTF-8" LC_ADDRESS="C.UTF-8" LC_TELEPHONE="C.UTF-8" LC_MEASUREMENT="C.UTF-8" LC_IDENTIFICATION="C.UTF-8" LC_ALL=C.UTF-8
Thanks for your bug report. I'm currently on vacation (until the end of the month) but of course I can look into this when I am back.