Skip to content
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

IDLE: scroll text by lines, not pixels. #77845

Closed
terryjreedy opened this issue May 28, 2018 · 5 comments
Closed

IDLE: scroll text by lines, not pixels. #77845

terryjreedy opened this issue May 28, 2018 · 5 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 33664
Nosy @terryjreedy, @csabella, @miss-islington
PRs
  • bpo-33664: Scroll IDLE editor text by lines #7351
  • [3.7] bpo-33664: Scroll IDLE editor text by lines (GH-7351) #7397
  • [3.6] bpo-33664: Scroll IDLE editor text by lines (GH-7351) #7398
  • 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:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2018-06-04.16:46:53.681>
    created_at = <Date 2018-05-28.00:46:46.474>
    labels = ['3.8', 'expert-IDLE', 'type-bug', '3.7']
    title = 'IDLE:  scroll text by lines, not pixels.'
    updated_at = <Date 2018-06-04.16:46:53.680>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2018-06-04.16:46:53.680>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2018-06-04.16:46:53.681>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2018-05-28.00:46:46.474>
    creator = 'terry.reedy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33664
    keywords = ['patch']
    message_count = 5.0
    messages = ['317819', '318662', '318664', '318667', '318675']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'cheryl.sabella', 'miss-islington']
    pr_nums = ['7351', '7397', '7398']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33664'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @terryjreedy
    Copy link
    Member Author

    When tk and hence, IDLE, opens a text window, it contains an integral number of lines of text in the base font. Clicking a vertical scrollbar arrow button moves text up or down exactly one line. Clicking in the trough between the buttons and and the slider moves text up or down one 'page', a page being the number of lines in the window -2.

    The text and window can be de-synchronized with the slider and mouse wheel. (If the window size is changes to a non-integral number of lines, 'synchronized' means a complete line at the top.) By default, the wheel moves text about 3 lines per 'click'. Apparently, it is exactly 50 pixels at a time. This is discussed on bpo-25015. For that issue, the focus was on '3' (or 50) being too small.

    This issue is about changing 'about' to 'exactly', so that synchronized text remains so when using the wheel or slider. For both, the solution should be to use Text.xview_scroll(n, units).

    For the wheel, we can replace the default tk wheel handler. While we are at it, we could make the wheel effect be +- 5 lines, which would solve bpo-25015, which I will close. I don't think a configuration setting is needed.

    For the slider, we can replace xview as the scrollbar command with a function that maps command('moveto', fraction) to xview_scroll(n, 'units'). The number n should be the difference between the current top line
    ("text.index("@0,0").split('.')[0]")
    and the desired top line
    ("round(fraction * text.index('end').split('.')[0]").
    Experiments should show if we need to adjust the rounded value

    We should not need to adjust for the fact that the last <window-size> lines of text cannot become top lines. A request to scroll 'too far' goes as far as possible without raising an exception.

    @terryjreedy terryjreedy added 3.7 (EOL) end of life 3.8 (EOL) end of life labels May 28, 2018
    @terryjreedy terryjreedy self-assigned this May 28, 2018
    @terryjreedy terryjreedy added topic-IDLE type-bug An unexpected behavior, bug, or error labels May 28, 2018
    @terryjreedy
    Copy link
    Member Author

    New changeset d49dbd9 by Terry Jan Reedy (Cheryl Sabella) in branch 'master':
    bpo-33664: Scroll IDLE editor text by lines (GH-7351)
    d49dbd9

    @miss-islington
    Copy link
    Contributor

    New changeset cfc12ec by Miss Islington (bot) in branch '3.7':
    bpo-33664: Scroll IDLE editor text by lines (GH-7351)
    cfc12ec

    @miss-islington
    Copy link
    Contributor

    New changeset db22229 by Miss Islington (bot) in branch '3.6':
    bpo-33664: Scroll IDLE editor text by lines (GH-7351)
    db22229

    @terryjreedy
    Copy link
    Member Author

    I checked that with the patch, the wwindow top stayed synchronized with the text after multiple movement operations of different types.

    The minimum requirement for correct operation of the scrollbar slider is that moving the slider to the top and bottom of its trough moves the text to the top and bottom of the file. Before merging, I checked with editor.py, about 3000 lines, and a new editor with just a couple more lines than the window size.

    It is desireable that each pixel movement of the slider move the text. This requires that there be at least as many hidden lines in the text as there are exposed pixel in the slider trough. I don't know that this will always be true on all systems. As near as I could tell with editor.py, which meets this requirement, moving the slider a pixel away from top or bottom also moved the text. (I can't move a single pixel, so it was more a matter that moving 2 or 3 pixels made 2 or 3 jumps ;-)

    I considered these tests enough for now to merge.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 (EOL) end of life topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants