Skip to content

feat: scroll with mouse faster#137

Open
istudyatuni wants to merge 7 commits into
Cretezy:mainfrom
istudyatuni:push-nwmwvlrwullx
Open

feat: scroll with mouse faster#137
istudyatuni wants to merge 7 commits into
Cretezy:mainfrom
istudyatuni:push-nwmwvlrwullx

Conversation

@istudyatuni

@istudyatuni istudyatuni commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator

also:

  • keybinds for log tab
  • scroll with mouse in log tab

Comment thread src/ui/log_tab.rs Outdated
}
LogTabEvent::ScrollDownHalf => {
self.scroll_log(commander, self.log_height as isize / 2 / 2);
self.scroll_log(commander, self.log_height as isize / 4);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is of course mathematically correct, but I feel that it looses the essence of what is going on.

  • log_height is the number of screen rows available for the list.
  • First divide by list item height (2), to find the number of items on screen,
  • Then divide by two to find half of the number of items that will fit the screen.

I prefer the original, or maybe even adding a let log_height_in_items = log_height / 2

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.

Well, without your explanation I didn't understand both variants 😄

Comment thread src/ui/details_panel.rs
ScrollUp,

ScrollDownRows(isize),
ScrollUpRows(isize),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not eliminate ScrollDown / -Up ? ScrollDownRows is more accurate.

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.

To use it as "default" scroll

Comment thread src/ui/log_tab.rs
Comment thread src/ui/log_tab.rs
MouseEventKind::ScrollUp if is_big_scroll => {
Some(LogTabEvent::ScrollUpHalf)
}
MouseEventKind::ScrollUp => Some(LogTabEvent::ScrollUp),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be more readable to have a single match on ScrollUp and the if statement inside the arm like this

MouseEventKind::ScrollUp => {
  if is_big_scroll { Some(LogTabEvent::ScrollUpHalf) }
  else { Some(LogTabEvent::ScrollUp) }
}

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.

Maybe it's a matter of taste. Also this is formatted as

MouseEventKind::ScrollUp => {
    if is_big_scroll {
        Some(LogTabEvent::ScrollUpHalf)
    } else {
        Some(LogTabEvent::ScrollUp)
    }
}

which is bigger

Comment thread src/ui/log_tab.rs Outdated
DETAILS_PANEL => {
let action = match mouse_event.kind {
MouseEventKind::ScrollUp if is_big_scroll => Some(DetailsPanelEvent::ScrollUpHalfPage),
MouseEventKind::ScrollUp => Some(DetailsPanelEvent::ScrollUpRows(DETAILS_SCROLL)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as above

@peso peso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It makes more sense to have mouse events for detail panel handled in details_panel.rs

@peso peso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would like the match arms simplified.

Comment thread src/ui/files_tab.rs
FilesTabEvent::Unbound => return Ok(ComponentInputResult::NotHandled),
};
Ok(ComponentInputResult::Handled)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 Much easier to understand two smaller functions

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.

Do you mean like this? #137 (comment)

@peso

peso commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

@istudyatuni is it possible for you to merge this (after resolving conflicts)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants