New submission from Terry J. Reedy <tjre...@udel.edu>:
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 https://stackoverflow.com/questions/57795679/why-is-this-code-printing-an-empty-line-when-run-under-idle 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. ---------- assignee: terry.reedy components: IDLE messages: 351218 nosy: terry.reedy priority: normal severity: normal stage: test needed status: open title: IDLE Shell: Redesign minimum restart line type: behavior versions: Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38041> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com