Title: IDLE Shell: Refine restart line
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.9, Python 3.8, Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: iritkatriel, miss-islington, terry.reedy
Priority: normal Keywords: patch

Created on 2019-09-05 18:52 by terry.reedy, last changed 2020-10-16 22:59 by terry.reedy. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 15709 merged terry.reedy, 2019-09-06 03:24
PR 15719 merged miss-islington, 2019-09-06 17:55
PR 15720 merged miss-islington, 2019-09-06 17:55
Messages (6)
msg351218 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-09-05 18:52
Currently, Shell prints restart lines as 
=...= RESTART filename =...=
where filename is 'Shell' or the full pathname.  The code is 

        tag = 'RESTART: ' + (filename if filename else 'Shell')
        halfbar = ((int(console.width) -len(tag) - 4) // 2) * '='
        console.write("\n{0} {1} {0}".format(halfbar, tag))

The initial '\n' is needed because typically the cursor is sitting at a prompt.  The -4 is from #21192 when I added 'Shell' or filename.  It is -2 for the spaces plus a couple of extra spaces that were there before.  I believe -2 is sufficient but will have to test to be sure.

The number of '='s is the currently the same on both ends.  (Because this is easiest.)  It does not have to be, and would sometimes not be if we exactly filled the console width.  I think we should because it would show the actual non-printable margin and would allow 

The minimum number of '='s is 0.  The problem revealed in
is that if console.width is exactly 10 + len(filename), the remaining trailing space wraps to the next line, making it look like a spurious print(' ') had occurred.

Possible solutions:

0. Do nothing.  I rejected this by opening this issue.  The SO beginner was apparently genuinely confused and might not be the only such person.  With no spec for the restart line, this is not an implementation bug but is a design glitch.  As I hinted above, some current details are the result of adding filenames with minimal change.

1. Delete the ' 's surrounding the tag when there are no '='s.  This looks strange because the '='s visually mark a restart line as much as 'RESTART'.

2. Print a minimum of 1 '=' on each end (by adding them to the format). This could result in a wrap of exactly ' =' or '=', either of which are bad.  If there is any wrap, it should be the filename, so the user can recognize it as such.

3. A hybrid solution with a minimum of 1 '=' on the front and 0 on the end, with no space if no '='.  I intend to try this after extracting the restart line into a testable function and writing tests that now fail.

4. Add a horizontal scrollbar to Shell.  This not happening now, might be made optional, and would still require specification decisions.
msg351264 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-09-06 17:54
New changeset 38da805d563422cf1bb9cd9be24c73806840fe30 by Terry Jan Reedy in branch 'master':
 bpo-38041: Refine IDLE Shell restart lines.  (GH-15709)
msg351266 - (view) Author: miss-islington (miss-islington) Date: 2019-09-06 18:14
New changeset 4009a8522d774c36918005527dfb0975f389c8c2 by Miss Islington (bot) in branch '3.8':
bpo-38041: Refine IDLE Shell restart lines.  (GH-15709)
msg351267 - (view) Author: miss-islington (miss-islington) Date: 2019-09-06 18:19
New changeset 084ba337a93facac4694459b460cf329d58d2b62 by Miss Islington (bot) in branch '3.7':
bpo-38041: Refine IDLE Shell restart lines.  (GH-15709)
msg378779 - (view) Author: Irit Katriel (iritkatriel) * (Python triager) Date: 2020-10-16 22:51
Can this be closed?
msg378781 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-10-16 22:59
Yes, the further changes I am thinking about should be a new issue.
Date User Action Args
2020-10-16 22:59:33terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg378781

stage: patch review -> resolved
2020-10-16 22:51:59iritkatrielsetnosy: + iritkatriel
messages: + msg378779
2019-09-06 18:19:33miss-islingtonsetmessages: + msg351267
2019-09-06 18:14:59miss-islingtonsetnosy: + miss-islington
messages: + msg351266
2019-09-06 17:55:14miss-islingtonsetpull_requests: + pull_request15374
2019-09-06 17:55:07miss-islingtonsetstage: commit review -> patch review
pull_requests: + pull_request15373
2019-09-06 17:54:50terry.reedysetmessages: + msg351264
2019-09-06 03:42:31terry.reedysettitle: Refine IDLE Shell restart line -> IDLE Shell: Refine restart line
stage: patch review -> commit review
2019-09-06 03:29:06terry.reedysettitle: IDLE Shell: Redesign minimum restart line -> Refine IDLE Shell restart line
2019-09-06 03:24:49terry.reedysetkeywords: + patch
stage: test needed -> patch review
pull_requests: + pull_request15364
2019-09-05 18:52:14terry.reedycreate