|
55 | 55 | from idlelib.outwin import OutputWindow |
56 | 56 | from idlelib import rpc |
57 | 57 | from idlelib.run import idle_formatwarning, PseudoInputFile, PseudoOutputFile |
| 58 | +from idlelib.textview import view_text |
58 | 59 | from idlelib.undo import UndoDelegator |
59 | 60 |
|
60 | 61 | HOST = '127.0.0.1' # python execution server on localhost loopback |
@@ -906,18 +907,26 @@ def __init__(self, flist=None): |
906 | 907 | sys.stderr = self.stderr |
907 | 908 | sys.stdin = self.stdin |
908 | 909 | try: |
909 | | - # page help() text to shell. |
910 | | - import pydoc # import must be done here to capture i/o rebinding. |
911 | | - # XXX KBK 27Dec07 use text viewer someday, but must work w/o subproc |
912 | | - pydoc.pager = pydoc.plainpager |
913 | | - except: |
| 910 | + import pydoc # import must be done here to capture i/o rebinding. |
| 911 | + pydoc.pager = self.pager |
| 912 | + except Exception: |
914 | 913 | sys.stderr = sys.__stderr__ |
915 | 914 | raise |
916 | 915 | # |
917 | 916 | self.history = self.History(self.text) |
918 | 917 | # |
919 | 918 | self.pollinterval = 50 # millisec |
920 | 919 |
|
| 920 | + def pager(self, text): |
| 921 | + """pydoc.pager compatible callback for showing help() output.""" |
| 922 | + import pydoc # Import here to avoid i/o binding issues. |
| 923 | + text = pydoc.plain(text) # Remove fancy pydoc formatting. |
| 924 | + try: |
| 925 | + title, text = text.split(':\n\n', 1) |
| 926 | + except ValueError: |
| 927 | + title = "Help" |
| 928 | + view_text(self.text, title, text, modal=False) |
| 929 | + |
921 | 930 | def get_standard_extension_names(self): |
922 | 931 | return idleConf.GetExtensions(shell_only=True) |
923 | 932 |
|
|
0 commit comments