Skip to content

Support relative scroll for ListBox - #858

Merged
penguinolog merged 3 commits into
urwid:masterfrom
penguinolog:ListBox_relative_scroll
Mar 13, 2024
Merged

penguinolog merged 3 commits into
urwid:masterfrom
penguinolog:ListBox_relative_scroll

Conversation

@penguinolog

@penguinolog penguinolog commented Mar 13, 2024 •

Copy link
Copy Markdown
Collaborator
  • By default use relative scroll if amount_of_widgets >= maxrow * 3
  • Simplify typing for calculate_visible
Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)

Fix: #845

@penguinolog
penguinolog force-pushed the ListBox_relative_scroll branch from b844b3f to 5885a62 Compare March 13, 2024 09:46
@penguinolog
penguinolog requested a review from wardi March 13, 2024 09:47
ow_canv = ow.render(ow_size, focus)
self._original_widget_size = ow_size
if isinstance(ow, SupportsRelativeScroll) and ow.require_relative_scroll(size, focus):
if len(ow) == ow.get_visible_amount(size, focus):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be very special case

Comment thread urwid/widget/listbox.py Outdated
fill: list[_FillItem]


class _VisibleArea(typing.NamedTuple):

@penguinolog penguinolog Mar 13, 2024 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicer debugging, but pylint has issues with typing. Silenced pylint.

Probably we should make these types public for using in overridden method (if somebody do it)

@coveralls

coveralls commented Mar 13, 2024 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 8264076557

Details

  • 108 of 118 (91.53%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 74.528%

Changes Missing Coverage Covered Lines Changed/Added Lines %
urwid/widget/scrollable.py 25 26 96.15%
urwid/widget/listbox.py 81 90 90.0%
Files with Coverage Reduction New Missed Lines %
urwid/widget/listbox.py 1 84.73%
Totals Coverage Status
Change from base Build 8263679558: 0.1%
Covered Lines: 9349
Relevant Lines: 12684

💛 - Coveralls

@penguinolog
penguinolog force-pushed the ListBox_relative_scroll branch 2 times, most recently from 9b7f170 to 181efe4 Compare March 13, 2024 10:55
* By default use relative scroll
  if amount_of_widgets >= maxrow * 3
* Simplify typing for `calculate_visible`
@penguinolog
penguinolog force-pushed the ListBox_relative_scroll branch from 181efe4 to 8ac1718 Compare March 13, 2024 11:27
@github-actions github-actions Bot added the docs Issues related to documentation label Mar 13, 2024
* narrower `ScrollSupportingBody` API and rework `rows_max`
@penguinolog
penguinolog force-pushed the ListBox_relative_scroll branch from 8ac1718 to 77d150a Compare March 13, 2024 11:46
@penguinolog
penguinolog merged commit ca18cf5 into urwid:master Mar 13, 2024
@penguinolog
penguinolog deleted the ListBox_relative_scroll branch March 13, 2024 11:52
@penguinolog penguinolog added Feature Feature request/implementation and removed docs Issues related to documentation labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Feature request/implementation Tests Tests Widget

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Too many items in ListBox with ScrollBar tanks performance

2 participants