-
-
Notifications
You must be signed in to change notification settings - Fork 32k
IDLE: usually include prompts when save or copy shell #95191
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
Comments
The 'Copy with prompts' code in pyshell.py is in copy_with_prompts_callback, lines 989 to 1023. Some middle portion could be extracted as a useful function for both that method and saving. Text to be saved is now retrieved in iomenu.py line 258 in fixline(). An add_prompts function would have to be called before the returned text is encoded in writefile(), line 241. The problems are getting a function that works for both uses and arranging it to be called when saving. Both functions currently get the text widget get as a joined string that is immediately split back into lines. Getting a list of text lines might or might not be more efficient. |
(cherry picked from commit b85411f) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit b85411f) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit b85411f) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit b85411f) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit c569526) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit c569526) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit bcc74d5) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit bcc74d5) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit bcc74d5) Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit bcc74d5) Co-authored-by: Terry Jan Reedy <[email protected]>
Up through 3.9, saving the shell saved saved the contents of the underlying text widget, which saved user input with the primary prompt and weird indents. In 3.10, the primary prompt was moved to a sidebar and secondary prompts added, allowing proper indents in the text widget. However, we left File => Save as saving the text widget text, which meant saving without the prompts. Keeping the same implementation changed the result. Prompted by a complaint by Raymond Hettinger, I regard this as a regression whose fix, by including prompts as the default mode of saving, is a high priority.
Saving both input and output without prompts had no precedent and does not seem useful, so I don't plan to keep it as an option. A useful option, already intended, is to save only code and that without prompts, so the saved code can be loaded into an editor. A possible variation would be to include output as comment blocks. Either way, this is a separate issue.
Selecting and copying is a bit trickier. In 3.9, one could select a single statement (and maybe its output) with or without the leading '>>>'. Selecting multiple statements necessarily included any output, uncommented, and prompts after the first. In 3.10, one can select text in the text area, as normal, or select lines in the sidebar with click and drag. Right click offers 2 copy options: 'copy' copies the selection as is; 'copy with prompts' extends any incomplete lines and adds prompts to input lines. Extending the lines makes the selection the same as if it had been done by a sidebar click and drag. (Adding a 'copy code' option, as discussed above, would be part of a separate issue.) I intend to keep both options, but change 'copy' to 'copy as is' or 'copy selection' and put it second.
Currently Edit=>Copy (or its hotkey, such as ^-C) copies as is. For people who select more than just one statement, this is a regression and adding prompts would be much better. When one selects at most one statement, adding a prompt might be surprising and unwanted.
We could split the Edit Copy option into 'Copy with prompts' and 'Copy as is'. (But see below.) If we do, which should get ^-C or current equivalent as hotkey. Adding another hotkey for the other is possible, but somewhat of a pain. Removing it later would be even more painful. (Again, see below.)
@rhettinger If we do not split Edit Copy, which copy option should it do? If we do split it, what should the current copy hotkey do?
I will soon open an issue that could remove the prompt sidebar from the history area and instead insert them into the text widget when a statement is execution. The history area would then look like the executed statement area of the REPL (at least as in Windows Command Prompt). Splitting Edit Copy as proposed above would then be a mistake. I will start with fixing saves.
The text was updated successfully, but these errors were encountered: