Ticket #27251: genutils_curses.patch
File genutils_curses.patch, 1.5 KB (added by jjstickel@…, 14 years ago) |
---|
-
genutils.py
old new 1668 1668 # unconditionally reset it every time. It's cheaper than making 1669 1669 # the checks. 1670 1670 term_flags = termios.tcgetattr(sys.stdout) 1671 1672 # Curses modifies the stdout buffer size by default, which messes 1673 # up Python's normal stdout buffering. This would manifest itself 1674 # to IPython users as delayed printing on stdout after having used 1675 # the pager. 1676 # 1677 # We can prevent this by manually setting the NCURSES_NO_SETBUF 1678 # environment variable. For more details, see: 1679 # http://bugs.python.org/issue10144 1680 NCURSES_NO_SETBUF = os.environ.get('NCURSES_NO_SETBUF', None) 1681 os.environ['NCURSES_NO_SETBUF'] = '' 1682 1683 # Proceed with curses initialization 1671 1684 scr = curses.initscr() 1672 1685 screen_lines_real,screen_cols = scr.getmaxyx() 1673 1686 curses.endwin() 1687 1688 # Restore environment 1689 if NCURSES_NO_SETBUF is None: 1690 del os.environ['NCURSES_NO_SETBUF'] 1691 else: 1692 os.environ['NCURSES_NO_SETBUF'] = NCURSES_NO_SETBUF 1693 1674 1694 # Restore terminal state in case endwin() didn't. 1675 1695 termios.tcsetattr(sys.stdout,termios.TCSANOW,term_flags) 1676 1696 # Now we have what we needed: the screen size in rows/columns