IngoMeyer441 / simple-term-menu

A Python package which creates simple interactive menus on the command line.
MIT License
504 stars 44 forks source link

Wide Unicode characters in menu_entries breaks display #73

Open ghost opened 1 year ago

ghost commented 1 year ago

Using strings with emojis or other wide characters in the menu_entries strings causes draw errors where the highlight does not match the cursor and duplicate lines get drawn above the menu every time a navigation key is pressed.

Environment is Mac OSX 12.4, iTerm2 terminal emulator.

    options = [
        "🔥  !NOW",
        "⏰  !Pending Tasks",
        "🧩  !Pending Tasks :: Consolidate",
    ]

    menu = TerminalMenu(options, title="select tag")
    menu.show()

First Render:

image

One Keypress down:

image

After several key presses:

image

Note that if there are many options for menu_entries, then not just the title line is repeated, but so are the first few lines of the option list:

image
IngoMeyer441 commented 1 year ago

Thanks for your report. Which version of simple_term_menu do you use? Since version 0.10.3, unicode characters are (or should be) fully supported. You can check with:

python -c 'import simple_tem_menu; print(simple_term_menu.__version__)'

Which OS do you use?

ghost commented 1 year ago

Version of simple_term_menu is 1.5.2.

OS is OSX 12.4 (Monterey).

Terminal is iTerm2 3.4.18.

IngoMeyer441 commented 1 year ago

I cannot reproduce this on Manjaro Linux with Kitty terminal. :disappointed: Maybe this is an Apple related problem. I will run some more tests on macOS.

IngoMeyer441 commented 1 year ago

I can reproduce this issue on macOS Catalina with the default Apple Terminal.app. If you remove the menu item

"🧩  !Pending Tasks :: Consolidate",

simple-term-menu works as usual. Somehow the 🧩 character seems to be interpreted as terminal escape sequence and moves the cursor down by one line. But I don't quite understand why this happens...

dammaer commented 1 year ago

Hello! Unfortunately, control sequences also create problems.

main_menu_title = "\033[36mMain Menu.\nPress Q or Esc to quit.\033[0m\n"

menu

OS Ubuntu 22.04

IngoMeyer441 commented 1 year ago

@dammaer This is probably related to #14.

deivshon commented 1 year ago

Hi, I just wanted to report that I'm getting this same bug on Arch Linux but only using the terminal foot (v1.15.1-1)

Both on alacritty (v0.12.2-1) and on my st build the bug does not seem to show up