(prompt="")
| 338 | print(ColorStr.red(_("input error, please input again"))) |
| 339 | |
| 340 | def readchar(prompt=""): |
| 341 | if prompt: |
| 342 | sys.stdout.write(prompt) |
| 343 | sys.stdout.flush() |
| 344 | |
| 345 | fd = sys.stdin.fileno() |
| 346 | old_settings = termios.tcgetattr(fd) |
| 347 | try: |
| 348 | tty.setraw(sys.stdin.fileno()) |
| 349 | ch = sys.stdin.read(1) |
| 350 | finally: |
| 351 | termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) |
| 352 | |
| 353 | print(ch) |
| 354 | return ch.strip() |
no test coverage detected