Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 895a607

Browse files
committed
potentially expensive but working history browsing
this fetches the current history's entire session on every execution. It would be fairly easy to make this happen *only* after an initial 'cursor up' motion, and also chunk it to not grab the full thing.
1 parent d1eacaf commit 895a607

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,15 @@ TODO / KNOWN ISSUES:
106106

107107
[x] maybe i should hook into interp and just turn that into a no-op,
108108
that way i can keep the current (cheap) history as is?
109+
110+
[ ] history saves only last input, make it work with all
109111

110112
[ ] make history work *across* sessions, not just current one
111113

112114
[ ] make multiline history work
113115

114116
[ ] handle History.enabled = False case gracefully as well
117+
115118

116119
[x] MUSTFIX: Python 3 compatability (all of my dependencies meet them)
117120

@@ -295,3 +298,8 @@ TODO / KNOWN ISSUES:
295298
[ ] up-arrow shouldn't search for partial completion (since that won't work)
296299

297300
[ ] cheap completion is broken again :(
301+
302+
[ ] non-ascii completion breaks bipython (yay unicode)
303+
304+
[ ] run completion for "import <tab>" since ipython supports that.
305+

bipython/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ def move_cursor_to_coords(self, *args):
430430
def keypress(self, size, key):
431431
if urwid.command_map[key] in ['cursor up', 'cursor down']:
432432
# Do not handle up/down arrow, leave them for the repl.
433+
#sys.stderr.write("cursor keys")
433434
return key
434435

435436
self._bpy_may_move_cursor = True
@@ -1049,6 +1050,7 @@ def cw(self):
10491050
text = self.edit.get_edit_text()
10501051
if pos != len(text):
10511052
# Disable autocomplete if not at end of line, like cli does.
1053+
# XXX: I think we can make this compeltion work here -pi
10521054
return
10531055

10541056
# Stolen from cli. TODO: clean up and split out.
@@ -1497,6 +1499,7 @@ def push(self, s, insert_into_history=True):
14971499
# Pretty blindly adapted from bpython.cli
14981500
try:
14991501
msg_id = self.send_ipython(s)
1502+
#self.rl_history.enter(s)
15001503
if hasattr(repl.Repl, 'insert_into_history'):
15011504
# this is only in unreleased version of bpython
15021505
self.insert_into_history(s)
@@ -1580,7 +1583,7 @@ def prompt(self, more):
15801583
# sitting above this prompt:
15811584
self.current_output = None
15821585
# XXX is this the right place?
1583-
self.rl_history.reset()
1586+
#self.rl_history.reset()
15841587
# XXX what is s_hist?
15851588

15861589
# We need the caption to use unicode as urwid normalizes later
@@ -1650,6 +1653,9 @@ def handle_input(self, event):
16501653
self.main_loop.draw_screen()
16511654
more = self.push(inp)
16521655
self.prompt(more)
1656+
# XXX: fetching all history is expensive, but better than nothing
1657+
# for now
1658+
self.rl_history = IPythonHistory(self)
16531659
elif event == 'ctrl d':
16541660
# ctrl+d on an empty line exits, otherwise deletes
16551661
if self.edit is not None:
@@ -1672,7 +1678,9 @@ def handle_input(self, event):
16721678
elif urwid.command_map[event] == 'prev selectable':
16731679
self.tab(True)
16741680
elif event == 'esc':
1675-
self.clear_docstring() # why is this so slow?, ARGH!
1681+
self.ipython_get_doc('')
1682+
#self.clear_docstring() # why is this so slow?, ARGH!
1683+
# XXX: tab redraws really quickly
16761684
else:
16771685
self.echo(repr(event))
16781686

0 commit comments

Comments
 (0)