--- Downloads/ipython_view.orig	2011-10-25 20:08:55.552315510 +0200
+++ Downloads/ipython_view.py	2011-10-25 20:21:09.120313770 +0200
@@ -71,11 +71,11 @@
       #IPython.utils.io.raw_input_original = input_func # this way?
       IPython.frontend.terminal.interactiveshell.raw_input_original = input_func
     if cin:
-      IPython.utils.io.IOTerm.cin = cin
+      IPython.utils.io.stdin = IPython.utils.io.IOStream(cin)
     if cout:
-      IPython.utils.io.IOTerm.cout = cout
+      IPython.utils.io.stdout = IPython.utils.io.IOStream(cout)
     if cerr:
-      IPython.utils.io.IOTerm.cerr = cerr
+      IPython.utils.io.stderr = IPython.utils.io.IOStream(cerr)
 
     # This is to get rid of the blockage that accurs during 
     # IPython.Shell.InteractiveShell.user_setup()
@@ -88,7 +88,12 @@
     self.term = IPython.utils.io.IOTerm(stdin=cin, stdout=cout, stderr=cerr)
     os.environ['TERM'] = 'dumb'
     excepthook = sys.excepthook 
-    self.IP = IPython.frontend.terminal.embed.InteractiveShellEmbed(user_ns=user_ns, user_global_ns=user_global_ns)
+
+    from IPython.config.loader import Config
+    cfg = Config()
+    cfg.InteractiveShell.colors = "Linux"
+
+    self.IP = IPython.frontend.terminal.embed.InteractiveShellEmbed(config=cfg, user_ns=user_ns, user_global_ns=user_global_ns)
 
 # Original way for getting our self.IP object was as follows:
 #
@@ -103,12 +108,15 @@
     self.IP.system = lambda cmd: self.shell(self.IP.var_expand(cmd),
                                             header='IPython system call: ',
                                             verbose=self.IP.rc.system_verbose)
+
+    self.IP.raw_input = input_func
     sys.excepthook = excepthook
     self.iter_more = 0
     self.history_level = 0
     self.complete_sep =  re.compile('[\s\{\}\[\]\(\)]')
     self.updateNamespace({'exit':lambda:None})
     self.updateNamespace({'quit':lambda:None})
+    self.IP.readline_startup_hook(self.IP.pre_readline)
 
   def execute(self):
     '''
@@ -117,44 +125,38 @@
     self.history_level = 0
 
     orig_stdout = sys.stdout
-    sys.stdout = IPython.utils.io.IOTerm.cout
+    sys.stdout = self.term.stdout
 
     orig_stdin = sys.stdin
-    sys.stdin = StringIO()
+    sys.stdin = IPython.utils.io.stdin;
+    self.prompt = self.IP.hooks.generate_prompt(self.iter_more)
+
+    self.IP.hooks.pre_prompt_hook()
+    if self.iter_more:
+        try:
+            self.prompt = self.IP.hooks.generate_prompt(True)
+        except:
+            self.IP.showtraceback()
+        if self.IP.autoindent:
+            self.IP.rl_do_indent = True
 
     try:
-      # Can I pass the iter_more parameter? 
-      #  - Doc says yes, code says no
-      #
-      #line = self.IP.raw_input(None, self.iter_more)
-      line = self.IP.raw_input(None)
-      if self.IP.autoindent:
-        self.IP.readline_startup_hook(None)
+      line = self.IP.raw_input(self.prompt)
     except KeyboardInterrupt:
       self.IP.write('\nKeyboardInterrupt\n')
-      self.IP.resetbuffer()
-      # keep cache in sync with the prompt counter:
-      self.IP.outputcache.prompt_count -= 1
-        
-      if self.IP.autoindent:
-        self.IP.indent_current_nsp = 0
-      self.iter_more = 0
+      self.IP.input_splitter.reset()
     except:
-      # Here I get a traceback with StringIO
-      #
-      #self.IP.showtraceback()
-      print "Commented exception"
+      self.IP.showtraceback()
     else:
-      self.iter_more = self.IP.push(line)
+      self.IP.input_splitter.push(line)
+      self.iter_more = self.IP.input_splitter.push_accepts_more()
+      self.prompt = self.IP.hooks.generate_prompt(self.iter_more)
       if (self.IP.SyntaxTB.last_syntax_error and
-          self.IP.rc.autoedit_syntax):
-        self.IP.edit_syntax_error()
-    if self.iter_more:
-      self.prompt = str(self.IP.prompt_in2).strip()
-      if self.IP.autoindent:
-        self.IP.readline_startup_hook(self.IP.pre_readline)
-    else:
-      self.prompt = str(self.IP.prompt_in1).strip()
+          self.IP.autoedit_syntax):
+          self.IP.edit_syntax_error()
+      if not self.iter_more:
+          source_raw = self.IP.input_splitter.source_raw_reset()[1]
+          self.IP.run_cell(source_raw, store_history=True)
 
     sys.stdout = orig_stdout
     sys.stdin = orig_stdin
@@ -234,11 +236,11 @@
           if not str2.startswith(str1[:i+1]):
             return str1[:i]
         return str1
-      common_prefix = reduce(_commonPrefix, possibilities)
+      common_prefix = reduce(_commonPrefix, possibilities[1])
       completed = line[:-len(split_line[-1])]+common_prefix
     else:
       completed = line
-    return completed, possibilities
+    return completed, possibilities[1]
   
 
   def shell(self, cmd,verbose=0,debug=0,header=''):
@@ -478,6 +480,7 @@
                              input_func=self.raw_input)
 #    self.connect('key_press_event', self.keyPress)
     self.execute()
+    self.prompt = self.IP.hooks.generate_prompt(False)
     self.cout.truncate(0)
     self.showPrompt(self.prompt)
     self.interrupt = False
