88# actual user input, I couldn't think of another way of doing this.
99window = None
1010
11- def _help ( obj ):
11+
12+ def _help (obj ):
1213 """Wrapper for the regular help() function but with a ghetto
1314 PAGER since curses + less = :(
1415 As per the vanilla help(), this function special-cases for str,
@@ -17,7 +18,7 @@ def _help( obj ):
1718 """
1819 io = cStringIO .StringIO ()
1920 doc = pydoc .TextDoc ()
20- helper = pydoc .Helper ( None , io )
21+ helper = pydoc .Helper (None , io )
2122
2223 rows , columns = window .getmaxyx ()
2324 rows -= 3
@@ -29,19 +30,26 @@ def _help( obj ):
2930# the bpython help is no compliant with the vanilla help.
3031# Please let me know if you find this to be untrue.
3132 if type (obj ) is type ('' ):
32- if obj == 'help' : helper .intro ()
33- elif obj == 'keywords' : helper .listkeywords ()
34- elif obj == 'topics' : helper .listtopics ()
35- elif obj == 'modules' : helper .listmodules ()
33+ if obj == 'help' :
34+ helper .intro ()
35+ elif obj == 'keywords' :
36+ helper .listkeywords ()
37+ elif obj == 'topics' :
38+ helper .listtopics ()
39+ elif obj == 'modules' :
40+ helper .listmodules ()
3641 elif obj [:8 ] == 'modules ' :
3742 helper .listmodules (split (obj )[1 ])
38- elif obj in helper .keywords : helper .showtopic (obj )
39- elif obj in helper .topics : helper .showtopic (obj )
40- elif obj : output = doc .document ( eval (obj ) )
43+ elif obj in helper .keywords :
44+ helper .showtopic (obj )
45+ elif obj in helper .topics :
46+ helper .showtopic (obj )
47+ elif obj :
48+ output = doc .document (eval (obj ))
4149#######################
4250
4351 else :
44- output = doc .document ( obj )
52+ output = doc .document (obj )
4553 if not output :
4654 output = "No help found for %s" % obj
4755 return
@@ -63,19 +71,20 @@ def _help( obj ):
6371
6472 paragraphs = []
6573 for o in output :
66- paragraphs .append ( textwrap .wrap ( o , columns ) )
74+ paragraphs .append (textwrap .wrap (o , columns ) )
6775
6876 i = 0
69- for j , paragraph in enumerate ( paragraphs ):
77+ for j , paragraph in enumerate (paragraphs ):
7078 for line in paragraph :
71- sys .stdout .write ( line + '\n ' )
79+ sys .stdout .write (line + '\n ' )
7280 i += 1
7381# This is a little unclear, but it just waits for a
7482# keypress when the a page worth of text has been
7583# displayed and returns if 'q' is pressed:
7684 if not i % rows and not wait_for_key ():
7785 return
7886
87+
7988def wait_for_key ():
8089 """Block until a key is pressed for the ghetto paging."""
8190
@@ -90,7 +99,10 @@ def wait_for_key():
9099 clear_line ()
91100 return q
92101
102+
93103def clear_line ():
94104 y = window .getyx ()[0 ]
95105 window .move (y , 0 )
96106 window .clrtoeol ()
107+
108+ # vim: sw=4 ts=4 sts=4 ai et
0 commit comments