File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ v0.5.0
2+ ======
3+ A few people have commented that the help() built-in function
4+ doesn't work so well with bpython, since Python will try to output
5+ the help string to PAGER (usually "less") which obviously makes
6+ everything go wrong when curses is involved. With a bit of hackery
7+ I've written my own ghetto pager and injected my own help function
8+ into the interpreter when it initialises in an attempt to rectify this.
9+ As such, it's pretty untested but it seems to be working okay for me.
10+ Suggestions/bug reports/patches are welcome regarding this.
11+
12+ v0.4.2
13+ ======
14+ Well, hopefully we're one step closer to making the list sizing
15+ stuff work. I really hate doing code for that kind of thing as I
16+ never get it quite right, but with perseverence it should end up
17+ being completely stable; it's not the hardest thing in the world.
18+
19+ Various cosmetic fixes have been put in at the request of a bunch
20+ of people who were kind enough to send me emails regarding their
21+ experiences.
22+
23+ PYTHONSTARTUP is now dealt with and used properly, as per the vanilla
24+ interpreter.
25+
126v0.4.1
227======
328It looks like the last release was actually pretty bug-free, aside
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
2- # bpython 0.4.2 ::fancy curses interface to the Python repl::Bob Farrell 2008
2+ # bpython 0.5.0 ::fancy curses interface to the Python repl::Bob Farrell 2008
33#
44# The MIT License
55#
@@ -64,11 +64,20 @@ class Dummy( object ):
6464except ImportError :
6565 OPTS .argspec = False
6666else :
67- import pydoc
6867 OPTS .argspec = True
6968
69+ import pydoc
70+
7071# TODO:
7172#
73+ #
74+ # No config file yet. This will allow things like "indent depth" for requiring
75+ # the user to hit return n times to signify the end of a code block.
76+ #
77+ # C-l doesn't repaint the screen yet.
78+ #
79+ # Tab completion does not work if not at the end of the line.
80+ #
7281# Triple-quoted strings over multiple lines are not colourised correctly.
7382#
7483# Numerous optimisations can be made but it seems to do all the lookup stuff
@@ -719,6 +728,13 @@ def repl( self ):
719728 self .push ( line )
720729 self .push ( '\n ' )
721730
731+ # The regular help() function uses PAGER to display the help, which
732+ # screws with bpython.
733+ from bpython import internal
734+ internal .window = self .scr
735+ self .push ('from bpython import internal\n ' )
736+ self .push ('help = internal._help' )
737+
722738 self .iy , self .ix = self .scr .getyx ()
723739 more = False
724740 while not self .do_exit :
Original file line number Diff line number Diff line change 1+ import pydoc
2+ import textwrap
3+ import sys
4+
5+ window = None
6+
7+ def _help ( query ):
8+ """Wrapper for the regular help() function but with a ghetto
9+ PAGER since curses + less = :(
10+ query : the actual search thing
11+ window : a curses window instance to use getch() on
12+ and for extrapolating the window size to work it all out"""
13+
14+ rows , columns = window .getmaxyx ()
15+ rows -= 3
16+ columns -= 1
17+ output = pydoc .getdoc ( query )
18+ if '\n ' in output :
19+ output = output .replace ('\n \n ' , '\n ' )
20+ output = output .split ('\n ' )
21+ else :
22+ output = [output ]
23+
24+ paragraphs = []
25+ for o in output :
26+ paragraphs .append ( textwrap .wrap ( o , columns ) )
27+
28+ i = 0
29+ for j , paragraph in enumerate ( paragraphs ):
30+ for line in paragraph :
31+ sys .stdout .write ( line + '\n ' )
32+ i += 1
33+ if not i % rows :
34+ wait_for_key ( window )
35+ if j + 1 < len ( paragraphs ):
36+ sys .stdout .write ('\n ' )
37+
38+ def wait_for_key ( window ):
39+ """Block until a key is pressed for the ghetto paging."""
40+
41+ window .addstr ("Press any key..." )
42+ while True :
43+ c = window .getch ()
44+ if c :
45+ break
46+
47+ y = window .getyx ()[0 ]
48+ window .move (y - 1 , 0 )
49+ window .clrtoeol ()
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def copy_tree(*args, **kwargs):
3131 "site-packages" )
3232
3333setup (name = "bpython" ,
34- version = "0.3.1 " ,
34+ version = "0.5.0 " ,
3535 description = "Fancy Interface to the Python Interpreter" ,
3636 author = "Robert Anthony Farrell" ,
3737 author_email = "robertanthonyfarrell@gmail.com" ,
You can’t perform that action at this time.
0 commit comments