##// END OF EJS Templates
_ip.set_next_input
vivainio -
Show More
@@ -358,6 +358,18 b' class IPApi:'
358 else:
358 else:
359 return Exception("_ip.defmacro must be called with 1 or 2 arguments")
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 def launch_new_instance(user_ns = None):
375 def launch_new_instance(user_ns = None):
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 2365 2007-05-23 15:09:43Z dan.milstein $
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 'NoColor',
636 'NoColor',
637 rc.object_info_string_level)
637 rc.object_info_string_level)
638
638
639 self.rl_next_input = None
640 self.rl_do_indent = False
639 # Load readline proper
641 # Load readline proper
640 if rc.readline:
642 if rc.readline:
641 self.init_readline()
643 self.init_readline()
642
644
645
643 # local shortcut, this is used a LOT
646 # local shortcut, this is used a LOT
644 self.log = self.logger.log
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 #debugx('self.indent_current_nsp','pre_readline:')
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 def init_readline(self):
1254 def init_readline(self):
1248 """Command history completion/saving/reloading."""
1255 """Command history completion/saving/reloading."""
@@ -1597,11 +1604,13 b' want to merge them back into the new files.""" % locals()'
1597 __builtin__.__dict__['__IPYTHON__active'] += 1
1604 __builtin__.__dict__['__IPYTHON__active'] += 1
1598
1605
1599 # exit_now is set by a call to %Exit or %Quit
1606 # exit_now is set by a call to %Exit or %Quit
1607 self.readline_startup_hook(self.pre_readline)
1600 while not self.exit_now:
1608 while not self.exit_now:
1601 if more:
1609 if more:
1602 prompt = self.hooks.generate_prompt(True)
1610 prompt = self.hooks.generate_prompt(True)
1603 if self.autoindent:
1611 if self.autoindent:
1604 self.readline_startup_hook(self.pre_readline)
1612 self.rl_do_indent = True
1613
1605 else:
1614 else:
1606 prompt = self.hooks.generate_prompt(False)
1615 prompt = self.hooks.generate_prompt(False)
1607 try:
1616 try:
@@ -1610,7 +1619,8 b' want to merge them back into the new files.""" % locals()'
1610 # quick exit on sys.std[in|out] close
1619 # quick exit on sys.std[in|out] close
1611 break
1620 break
1612 if self.autoindent:
1621 if self.autoindent:
1613 self.readline_startup_hook(None)
1622 self.rl_do_indent = False
1623
1614 except KeyboardInterrupt:
1624 except KeyboardInterrupt:
1615 self.write('\nKeyboardInterrupt\n')
1625 self.write('\nKeyboardInterrupt\n')
1616 self.resetbuffer()
1626 self.resetbuffer()
@@ -1622,6 +1632,7 b' want to merge them back into the new files.""" % locals()'
1622 more = 0
1632 more = 0
1623 except EOFError:
1633 except EOFError:
1624 if self.autoindent:
1634 if self.autoindent:
1635 self.rl_do_indent = False
1625 self.readline_startup_hook(None)
1636 self.readline_startup_hook(None)
1626 self.write('\n')
1637 self.write('\n')
1627 self.exit()
1638 self.exit()
@@ -23,6 +23,9 b''
23
23
24 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
24 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
25 handling.
25 handling.
26
27 * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default")
28 input if readline is available.
26
29
27 2007-05-23 Ville Vainio <vivainio@gmail.com>
30 2007-05-23 Ville Vainio <vivainio@gmail.com>
28
31
General Comments 0
You need to be logged in to leave comments. Login now