simple-term-menu icon indicating copy to clipboard operation
simple-term-menu copied to clipboard

Tabulators in text brake the menu

Open mreitschuster opened this issue 2 years ago • 0 comments

#!/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

mreitschuster avatar Aug 07 '22 16:08 mreitschuster