term_ni.py 660 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python3
  2. import sys,os
  3. os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(sys.argv[0])))))
  4. sys.path[0] = os.curdir
  5. from mmgen.cfg import Config
  6. cfg = Config()
  7. from mmgen.term import init_term,get_term
  8. init_term(cfg)
  9. term = get_term()
  10. if sys.argv[1] == 'echo':
  11. from mmgen.ui import line_input
  12. from mmgen.term import get_char_raw
  13. term.init(noecho=True)
  14. line_input( cfg, 'noecho> ' )
  15. get_char_raw()
  16. term.set('echo')
  17. line_input( cfg, 'echo> ' )
  18. term.set('noecho')
  19. line_input( cfg, 'noecho> ' )
  20. get_char_raw()
  21. elif sys.argv[1] == 'cleanup':
  22. term.register_cleanup()
  23. import tty
  24. tty.setcbreak(term.stdin_fd)