-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-50393: "Clear and restart" IDLE shell windows #21682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ZackerySpytz
wants to merge
1
commit into
python:main
Choose a base branch
from
ZackerySpytz:bpo-6143-IDLE-clear-restart
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,7 @@ | |
| ('shell', [ | ||
| ('_View Last Restart', '<<view-restart>>'), | ||
| ('_Restart Shell', '<<restart-shell>>'), | ||
| ('_Clear and Restart', '<<clear-restart-shell>>'), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
| None, | ||
| ('_Previous History', '<<history-previous>>'), | ||
| ('_Next History', '<<history-next>>'), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -477,7 +477,7 @@ def start_subprocess(self): | |
| self.poll_subprocess() | ||
| return self.rpcclt | ||
|
|
||
| def restart_subprocess(self, with_cwd=False, filename=''): | ||
| def restart_subprocess(self, with_cwd=False, filename='', clear=False): | ||
| if self.restarting: | ||
| return self.rpcclt | ||
| self.restarting = True | ||
|
|
@@ -503,12 +503,19 @@ def restart_subprocess(self, with_cwd=False, filename=''): | |
| return None | ||
| self.transfer_path(with_cwd=with_cwd) | ||
| console.stop_readline() | ||
| # annotate restart in shell window and mark it | ||
| console.text.delete("iomark", "end-1c") | ||
| console.write('\n') | ||
| console.write(restart_line(console.width, filename)) | ||
| console.text.mark_set("restart", "end-1c") | ||
| console.text.mark_gravity("restart", "left") | ||
| if clear: | ||
| # Temporarily remove the iomark to allow deleting all text. | ||
| console.text.mark_unset("iomark") | ||
| console.text.delete("0.0", "end") | ||
| console.resetoutput() | ||
| console.write_header() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure we need this. And the new function. |
||
| else: | ||
| # Annotate restart in shell window and mark it. | ||
| console.text.delete("iomark", "end-1c") | ||
| console.write('\n') | ||
| console.write(restart_line(console.width, filename)) | ||
| console.text.mark_set("restart", "end-1c") | ||
| console.text.mark_gravity("restart", "left") | ||
| if not filename: | ||
| console.showprompt() | ||
| # restart subprocess debugger | ||
|
|
@@ -893,6 +900,7 @@ def __init__(self, flist=None): | |
| if use_subprocess: | ||
| text.bind("<<view-restart>>", self.view_restart_mark) | ||
| text.bind("<<restart-shell>>", self.restart_shell) | ||
| text.bind("<<clear-restart-shell>>", self.clear_and_restart_shell) | ||
| squeezer = self.Squeezer(self) | ||
| text.bind("<<squeeze-current-text>>", | ||
| squeezer.squeeze_current_text_event) | ||
|
|
@@ -1041,24 +1049,27 @@ def short_title(self): | |
| COPYRIGHT = \ | ||
| 'Type "help", "copyright", "credits" or "license()" for more information.' | ||
|
|
||
| def write_header(self): | ||
| self.write(f"Python {sys.version} on {sys.platform}\n" | ||
| f"{self.COPYRIGHT}\n") | ||
| if not use_subprocess: | ||
| self.write("==== No Subprocess ====\n\n" | ||
| "WARNING: Running IDLE without a Subprocess is\n" | ||
| "deprecated and will be removed in a later version.\n" | ||
| "See Help/IDLE Help for details.\n\n") | ||
|
|
||
| def begin(self): | ||
| self.text.mark_set("iomark", "insert") | ||
| self.resetoutput() | ||
| if use_subprocess: | ||
| nosub = '' | ||
| client = self.interp.start_subprocess() | ||
| if not client: | ||
| self.close() | ||
| return False | ||
| else: | ||
| nosub = ("==== No Subprocess ====\n\n" + | ||
| "WARNING: Running IDLE without a Subprocess is deprecated\n" + | ||
| "and will be removed in a later version. See Help/IDLE Help\n" + | ||
| "for details.\n\n") | ||
| sys.displayhook = rpc.displayhook | ||
|
|
||
| self.write("Python %s on %s\n%s\n%s" % | ||
| (sys.version, sys.platform, self.COPYRIGHT, nosub)) | ||
| self.write_header() | ||
| self.text.focus_force() | ||
| self.showprompt() | ||
| import tkinter | ||
|
|
@@ -1268,6 +1279,9 @@ def restart_shell(self, event=None): | |
| "Callback for Run/Restart Shell Cntl-F6" | ||
| self.interp.restart_subprocess(with_cwd=True) | ||
|
|
||
| def clear_and_restart_shell(self, event=None): | ||
| self.interp.restart_subprocess(with_cwd=True, clear=True) | ||
|
|
||
| def showprompt(self): | ||
| self.resetoutput() | ||
| self.console.write(self.prompt) | ||
|
|
||
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/IDLE/2020-07-29-22-06-13.bpo-6143.d8pzkH.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Add a "Clear and Restart" item to IDLE's "Shell" menu. This can be used to | ||
| clear the contents of the shell window. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is generated from the IDLE doc: Doc/librarary/idle.rst. Edit latter instead.