Show More
@@ -37,7 +37,6 b' from io import UnsupportedOperation' | |||
|
37 | 37 | |
|
38 | 38 | from IPython.core import ipapi |
|
39 | 39 | from IPython.core.error import TryNext |
|
40 | from IPython.utils.cursesimport import use_curses | |
|
41 | 40 | from IPython.utils.data import chop |
|
42 | 41 | from IPython.utils import io |
|
43 | 42 | from IPython.utils.process import system |
@@ -73,22 +72,24 b' def page_dumb(strng, start=0, screen_lines=25):' | |||
|
73 | 72 | last_escape = esc_list[-1] |
|
74 | 73 | print(last_escape + os.linesep.join(screens[-1]), file=io.stdout) |
|
75 | 74 | |
|
76 |
def _detect_screen_size( |
|
|
75 | def _detect_screen_size(screen_lines_def): | |
|
77 | 76 | """Attempt to work out the number of lines on the screen. |
|
78 | 77 | |
|
79 | 78 | This is called by page(). It can raise an error (e.g. when run in the |
|
80 | 79 | test suite), so it's separated out so it can easily be called in a try block. |
|
81 | 80 | """ |
|
82 | 81 | TERM = os.environ.get('TERM',None) |
|
83 | if (TERM=='xterm' or TERM=='xterm-color') and sys.platform != 'sunos5': | |
|
84 | local_use_curses = use_curses | |
|
85 | else: | |
|
82 | if not((TERM=='xterm' or TERM=='xterm-color') and sys.platform != 'sunos5'): | |
|
86 | 83 | # curses causes problems on many terminals other than xterm, and |
|
87 | 84 | # some termios calls lock up on Sun OS5. |
|
88 | local_use_curses = False | |
|
89 | if local_use_curses: | |
|
85 | return screen_lines_def | |
|
86 | ||
|
87 | try: | |
|
90 | 88 | import termios |
|
91 | 89 | import curses |
|
90 | except ImportError: | |
|
91 | return screen_lines_def | |
|
92 | ||
|
92 | 93 |
|
|
93 | 94 |
|
|
94 | 95 |
|
@@ -110,7 +111,12 b' def _detect_screen_size(use_curses, screen_lines_def):' | |||
|
110 | 111 |
|
|
111 | 112 | |
|
112 | 113 |
|
|
114 | try: | |
|
113 | 115 | scr = curses.initscr() |
|
116 | except AttributeError: | |
|
117 | # Curses on Solaris may not be complete, so we can't use it there | |
|
118 | return screen_lines_def | |
|
119 | ||
|
114 | 120 |
|
|
115 | 121 |
|
|
116 | 122 | |
@@ -126,8 +132,6 b' def _detect_screen_size(use_curses, screen_lines_def):' | |||
|
126 | 132 |
|
|
127 | 133 |
|
|
128 | 134 |
|
|
129 | else: | |
|
130 | return screen_lines_def | |
|
131 | 135 | |
|
132 | 136 | def page(strng, start=0, screen_lines=0, pager_cmd=None): |
|
133 | 137 | """Print a string, piping through a pager after a certain length. |
@@ -184,7 +188,7 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):' | |||
|
184 | 188 | # auto-determine screen size |
|
185 | 189 | if screen_lines <= 0: |
|
186 | 190 | try: |
|
187 |
screen_lines += _detect_screen_size( |
|
|
191 | screen_lines += _detect_screen_size(screen_lines_def) | |
|
188 | 192 | except (TypeError, UnsupportedOperation): |
|
189 | 193 | print(str_toprint, file=io.stdout) |
|
190 | 194 | return |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now