IngoMeyer441 / simple-term-menu

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

Tabulators in text brake the menu #61

Open mreitschuster opened 2 years ago

mreitschuster commented 2 years ago
#!/usr/bin/env python3

from simple_term_menu import TerminalMenu

def main():
    options = ["entry \t 1", "entry \t 2", "entry \t 3"]
    terminal_menu = TerminalMenu(options)
    menu_entry_index = terminal_menu.show()
    print(f"You have selected {options[menu_entry_index]}!")

if __name__ == "__main__":
    main()

A small change from the original example - adding tabs in the option list - makes the tool behave unexpectedly. Instead of being able to move the cursor, clicking an arrow button now makes the menu confusing:


python simple-term-menu.py 
  entry          1 

  entry          2 
> entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
> entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
> entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

> entry          2                                                                                                                                                                                                                          
> entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

> entry          2                                                                                                                                                                                                                          
> entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

> entry          2                                                                                                                                                                                                                          
> entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

> entry          2                                                                                                                                                                                                                          
> entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

> entry          2                                                                                                                                                                                                                          
> entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

  entry          2                                                                                                                                                                                                                          
  entry          1                                                                                                                                                                                                                          

> entry          2