python / cpython

The Python programming language
https://www.python.org
Other
62.31k stars 29.93k forks source link

IDLE: Move prompts with input. #75512

Open terryjreedy opened 7 years ago

terryjreedy commented 7 years ago
BPO 31331
Nosy @terryjreedy, @mlouielu

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = 'https://github.com/terryjreedy' closed_at = None created_at = labels = ['expert-IDLE', 'type-bug', '3.7'] title = 'IDLE: Move prompts with input.' updated_at = user = 'https://github.com/terryjreedy' ``` bugs.python.org fields: ```python activity = actor = 'terry.reedy' assignee = 'terry.reedy' closed = False closed_date = None closer = None components = ['IDLE'] creation = creator = 'terry.reedy' dependencies = [] files = [] hgrepos = [] issue_num = 31331 keywords = [] message_count = 4.0 messages = ['301177', '301217', '301218', '301242'] nosy_count = 2.0 nosy_names = ['terry.reedy', 'louielu'] pr_nums = [] priority = 'normal' resolution = None stage = 'test needed' status = 'open' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue31331' versions = ['Python 3.6', 'Python 3.7'] ```

terryjreedy commented 7 years ago

When this program (from thread by Steven D'Aprano) on python-list is run

import time
from threading import Timer

def do_work():
    x = 2 + 2
    print("It is", time.asctime(), "and 2+2 is", x)

def go():
    Timer(10, do_work, ()).start()  # schedule it in one minute

The response, if it occurs while one in entering a statement, 'pushes down' the entry in progress.

\======================= RESTART: F:\Python\mypy\tem.py \=======================

>>> go()
>>> It is Sat Sep  2 19:42:10 2017 and 2+2 is 4  #<== output
a = (
    12,   # <== 2nd line of entry in progress

The prompt should be pushed down too.

9da18a29-a07d-4828-a801-24cc911246de commented 7 years ago

minimum reproduce:

>>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
>>> 'hello'
a = (
       12,

And the expect output should be something like:

>>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
>>> 'hello'    # No \<enter\> or other key-input
>>>

or:

>>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
'hello'
>>>

Right?

9da18a29-a07d-4828-a801-24cc911246de commented 7 years ago

Or the output should be:

>>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
>>>
'hello'
>>>
terryjreedy commented 7 years ago

In my example the screen before the output had

>>> go()
>>> a = 
           12,|

where '|' is the blinking input cursor. The '\n' terminated print output is inserted after '>>> ' but before the imcomplete statement. When the statement I want it before the prompt, with '\n' appended if necessary. In the minimized example, the result would be

 >>> from threading import Timer
>>> Timer(0.1, lambda: print('hello'), ()).start()
'hello'
>>>

If delayed output 'junk' does not end with '\n', we can get

>>> junkg=4  # 'g' started where the 'j' ends up.
>>> g
4

This is buggy as a history listing.

IDLE's current behavior, which keeps user input and program output better separated, is much better than interactive Python in the console Steven used, where the output is placed at the end of the incomplete statement, which is a nuisance.

The first step is to find where text from the user program is inserted into the Shell text box. Then, how is the insertion point moved back -- but just not quite far enough. The solution might then be obvious.

A 'deeper' idea that would solve this (and other issues) is a separate Shell input box (without '>>> ') under the Shell history box. But that is a separate discussion.

terryjreedy commented 1 year ago

This issue remains with prompts moved to a sidebar. I am leaning now to separate input widget.