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>
This commit is contained in:
Tal Einat 2021-04-29 01:27:55 +03:00 committed by GitHub
parent 103d5e420d
commit 15d3861856
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 888 additions and 132 deletions

View file

@ -11,7 +11,7 @@ from idlelib.searchbase import SearchDialogBase
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 @@ class ReplaceDialog(SearchDialogBase):
"""
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 @@ class ReplaceDialog(SearchDialogBase):
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 @@ class ReplaceDialog(SearchDialogBase):
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 @@ class ReplaceDialog(SearchDialogBase):
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 @@ class ReplaceDialog(SearchDialogBase):
"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 #