Show More
@@ -358,6 +358,18 b' class IPApi:' | |||
|
358 | 358 | else: |
|
359 | 359 | return Exception("_ip.defmacro must be called with 1 or 2 arguments") |
|
360 | 360 | |
|
361 | def set_next_input(self, s): | |
|
362 | """ Sets the 'default' input string for the next command line. | |
|
363 | ||
|
364 | Requires readline. | |
|
365 | ||
|
366 | Example: | |
|
367 | ||
|
368 | [D:\ipython]|1> _ip.set_next_input("Hello Word") | |
|
369 | [D:\ipython]|2> Hello Word_ # cursor is here | |
|
370 | """ | |
|
371 | ||
|
372 | self.IP.rl_next_input = s | |
|
361 | 373 | |
|
362 | 374 | |
|
363 | 375 | def launch_new_instance(user_ns = None): |
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.' | |||
|
6 | 6 | |
|
7 | 7 | This file contains all the classes and helper functions specific to IPython. |
|
8 | 8 | |
|
9 |
$Id: iplib.py 23 |
|
|
9 | $Id: iplib.py 2385 2007-05-24 20:18:08Z vivainio $ | |
|
10 | 10 | """ |
|
11 | 11 | |
|
12 | 12 | #***************************************************************************** |
@@ -636,10 +636,13 b' class InteractiveShell(object,Magic):' | |||
|
636 | 636 | 'NoColor', |
|
637 | 637 | rc.object_info_string_level) |
|
638 | 638 | |
|
639 | self.rl_next_input = None | |
|
640 | self.rl_do_indent = False | |
|
639 | 641 | # Load readline proper |
|
640 | 642 | if rc.readline: |
|
641 | 643 | self.init_readline() |
|
642 | 644 | |
|
645 | ||
|
643 | 646 | # local shortcut, this is used a LOT |
|
644 | 647 | self.log = self.logger.log |
|
645 | 648 | |
@@ -1242,7 +1245,11 b' want to merge them back into the new files.""" % locals()' | |||
|
1242 | 1245 | |
|
1243 | 1246 | #debugx('self.indent_current_nsp','pre_readline:') |
|
1244 | 1247 | |
|
1245 | self.readline.insert_text(self.indent_current_str()) | |
|
1248 | if self.rl_do_indent: | |
|
1249 | self.readline.insert_text(self.indent_current_str()) | |
|
1250 | if self.rl_next_input is not None: | |
|
1251 | self.readline.insert_text(self.rl_next_input) | |
|
1252 | self.rl_next_input = None | |
|
1246 | 1253 | |
|
1247 | 1254 | def init_readline(self): |
|
1248 | 1255 | """Command history completion/saving/reloading.""" |
@@ -1597,11 +1604,13 b' want to merge them back into the new files.""" % locals()' | |||
|
1597 | 1604 | __builtin__.__dict__['__IPYTHON__active'] += 1 |
|
1598 | 1605 | |
|
1599 | 1606 | # exit_now is set by a call to %Exit or %Quit |
|
1607 | self.readline_startup_hook(self.pre_readline) | |
|
1600 | 1608 | while not self.exit_now: |
|
1601 | 1609 | if more: |
|
1602 | 1610 | prompt = self.hooks.generate_prompt(True) |
|
1603 | 1611 | if self.autoindent: |
|
1604 |
self.r |
|
|
1612 | self.rl_do_indent = True | |
|
1613 | ||
|
1605 | 1614 | else: |
|
1606 | 1615 | prompt = self.hooks.generate_prompt(False) |
|
1607 | 1616 | try: |
@@ -1610,7 +1619,8 b' want to merge them back into the new files.""" % locals()' | |||
|
1610 | 1619 | # quick exit on sys.std[in|out] close |
|
1611 | 1620 | break |
|
1612 | 1621 | if self.autoindent: |
|
1613 |
self.r |
|
|
1622 | self.rl_do_indent = False | |
|
1623 | ||
|
1614 | 1624 | except KeyboardInterrupt: |
|
1615 | 1625 | self.write('\nKeyboardInterrupt\n') |
|
1616 | 1626 | self.resetbuffer() |
@@ -1622,6 +1632,7 b' want to merge them back into the new files.""" % locals()' | |||
|
1622 | 1632 | more = 0 |
|
1623 | 1633 | except EOFError: |
|
1624 | 1634 | if self.autoindent: |
|
1635 | self.rl_do_indent = False | |
|
1625 | 1636 | self.readline_startup_hook(None) |
|
1626 | 1637 | self.write('\n') |
|
1627 | 1638 | self.exit() |
General Comments 0
You need to be logged in to leave comments.
Login now