bpo-37903: IDLE: Shell sidebar with prompts (GH-22682)

The first followup will change shell indents to spaces.
More are expected.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
diff --git a/Lib/idlelib/replace.py b/Lib/idlelib/replace.py
index 6be034a..2f9ca23 100644
--- a/Lib/idlelib/replace.py
+++ b/Lib/idlelib/replace.py
@@ -11,7 +11,7 @@
 from idlelib import searchengine
 
 
-def replace(text):
+def replace(text, insert_tags=None):
     """Create or reuse a singleton ReplaceDialog instance.
 
     The singleton dialog saves user entries and preferences
@@ -25,7 +25,7 @@ def replace(text):
     if not hasattr(engine, "_replacedialog"):
         engine._replacedialog = ReplaceDialog(root, engine)
     dialog = engine._replacedialog
-    dialog.open(text)
+    dialog.open(text, insert_tags=insert_tags)
 
 
 class ReplaceDialog(SearchDialogBase):
@@ -49,8 +49,9 @@ def __init__(self, root, engine):
         """
         super().__init__(root, engine)
         self.replvar = StringVar(root)
+        self.insert_tags = None
 
-    def open(self, text):
+    def open(self, text, insert_tags=None):
         """Make dialog visible on top of others and ready to use.
 
         Also, highlight the currently selected text and set the
@@ -72,6 +73,7 @@ def open(self, text):
         last = last or first
         self.show_hit(first, last)
         self.ok = True
+        self.insert_tags = insert_tags
 
     def create_entries(self):
         "Create base and additional label and text entry widgets."
@@ -177,7 +179,7 @@ def replace_all(self, event=None):
                 if first != last:
                     text.delete(first, last)
                 if new:
-                    text.insert(first, new)
+                    text.insert(first, new, self.insert_tags)
             col = i + len(new)
             ok = False
         text.undo_block_stop()
@@ -231,7 +233,7 @@ def do_replace(self):
         if m.group():
             text.delete(first, last)
         if new:
-            text.insert(first, new)
+            text.insert(first, new, self.insert_tags)
         text.undo_block_stop()
         self.show_hit(first, text.index("insert"))
         self.ok = False
@@ -264,6 +266,7 @@ def close(self, event=None):
         "Close the dialog and remove hit tags."
         SearchDialogBase.close(self, event)
         self.text.tag_remove("hit", "1.0", "end")
+        self.insert_tags = None
 
 
 def _replace_dialog(parent):  # htest #