Simon de Vlieger avatar Simon de Vlieger committed e5d43bc Merge

Merge

Comments (0)

Files changed (1)

 
         self.edits = []
         self.edit = None
+        self.current_output = None
         self._completion_update_suppressed = False
 
         load_urwid_command_map(config)
 
     # Subclasses of Repl need to implement echo, current_line, cw
-    def echo(self, s):
-        s = s.rstrip('\n')
+    def echo(self, orig_s):
+        s = orig_s.rstrip('\n')
         if s:
-            text = urwid.Text(('output', s))
-            if self.edit is None:
-                self.listbox.body.append(text)
+            if self.current_output is None:
+                self.current_output = urwid.Text(('output', s))
+                if self.edit is None:
+                    self.listbox.body.append(self.current_output)
+                else:
+                    self.listbox.body.insert(-1, self.current_output)
+                    # The edit widget should be focused and *stay* focused.
+                    # XXX TODO: make sure the cursor stays in the same spot.
+                    self.listbox.set_focus(len(self.listbox.body) - 1)
             else:
-                self.listbox.body.insert(-1, text)
-                # The edit widget should be focused and *stay* focused.
-                # XXX TODO: make sure the cursor stays in the same spot.
-                self.listbox.set_focus(len(self.listbox.body) - 1)
+                # XXX this assumes this all has "output" markup applied.
+                self.current_output.set_text(
+                    ('output', self.current_output.text + s))
+        if orig_s.endswith('\n'):
+            self.current_output = None
         # TODO: maybe do the redraw after a short delay
         # (for performance)
         self.main_loop.draw_screen()
         self.echo('KeyboardInterrupt')
 
     def prompt(self, more):
+        # Clear current output here, or output resulting from the
+        # current prompt run will end up appended to the edit widget
+        # sitting above this prompt:
+        self.current_output = None
         # XXX is this the right place?
         self.rl_history.reset()
         # XXX what is s_hist?
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.