mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
Revert "Support mouse scrolling (#306)"
This reverts commit 457f644f30.
This commit is contained in:
parent
59acccc484
commit
bde8eb8a7b
5 changed files with 8 additions and 95 deletions
|
|
@ -12,10 +12,7 @@ use asyncgit::{
|
|||
sync::{self, CommitDetails, CommitId, CommitMessage},
|
||||
CWD,
|
||||
};
|
||||
use crossterm::event::{
|
||||
Event,
|
||||
MouseEventKind::{ScrollDown, ScrollUp},
|
||||
};
|
||||
use crossterm::event::Event;
|
||||
use itertools::Itertools;
|
||||
use std::clone::Clone;
|
||||
use std::{borrow::Cow, cell::Cell};
|
||||
|
|
@ -397,15 +394,7 @@ impl Component for DetailsComponent {
|
|||
|
||||
fn event(&mut self, event: Event) -> Result<bool> {
|
||||
if self.focused {
|
||||
if let Event::Mouse(mouse_ev) = event {
|
||||
return Ok(match mouse_ev.kind {
|
||||
ScrollUp => self.move_scroll_top(ScrollType::Up),
|
||||
ScrollDown => {
|
||||
self.move_scroll_top(ScrollType::Down)
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
} else if let Event::Key(e) = event {
|
||||
if let Event::Key(e) = event {
|
||||
return Ok(if e == self.key_config.move_up {
|
||||
self.move_scroll_top(ScrollType::Up)
|
||||
} else if e == self.key_config.move_down {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ use crate::{
|
|||
};
|
||||
use anyhow::Result;
|
||||
use asyncgit::sync::Tags;
|
||||
use crossterm::event::{
|
||||
Event,
|
||||
MouseEventKind::{ScrollDown, ScrollUp},
|
||||
};
|
||||
use crossterm::event::Event;
|
||||
use std::{
|
||||
borrow::Cow, cell::Cell, cmp, convert::TryFrom, time::Instant,
|
||||
};
|
||||
|
|
@ -349,16 +346,7 @@ impl DrawableComponent for CommitList {
|
|||
|
||||
impl Component for CommitList {
|
||||
fn event(&mut self, ev: Event) -> Result<bool> {
|
||||
if let Event::Mouse(mouse_ev) = ev {
|
||||
let selection_changed = match mouse_ev.kind {
|
||||
ScrollUp => self.move_selection(ScrollType::Up)?,
|
||||
ScrollDown => {
|
||||
self.move_selection(ScrollType::Down)?
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
return Ok(selection_changed);
|
||||
} else if let Event::Key(k) = ev {
|
||||
if let Event::Key(k) = ev {
|
||||
let selection_changed = if k == self.key_config.move_up {
|
||||
self.move_selection(ScrollType::Up)?
|
||||
} else if k == self.key_config.move_down {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ use crate::{
|
|||
use anyhow::Result;
|
||||
use asyncgit::{hash, sync, DiffLine, DiffLineType, FileDiff, CWD};
|
||||
use bytesize::ByteSize;
|
||||
use crossterm::event::{
|
||||
Event, KeyModifiers,
|
||||
MouseEventKind::{ScrollDown, ScrollUp},
|
||||
};
|
||||
use crossterm::event::Event;
|
||||
use std::{borrow::Cow, cell::Cell, cmp, path::Path};
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
|
|
@ -632,54 +629,9 @@ impl Component for DiffComponent {
|
|||
CommandBlocking::PassingOn
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn event(&mut self, ev: Event) -> Result<bool> {
|
||||
if self.focused {
|
||||
if let Event::Mouse(mouse_ev) = ev {
|
||||
return match mouse_ev.kind {
|
||||
ScrollUp => {
|
||||
match mouse_ev.modifiers {
|
||||
KeyModifiers::SHIFT => {
|
||||
self.modify_selection(Direction::Up);
|
||||
}
|
||||
KeyModifiers::CONTROL => {
|
||||
self.modify_selection(Direction::Up);
|
||||
self.modify_selection(Direction::Up);
|
||||
self.modify_selection(Direction::Up);
|
||||
}
|
||||
KeyModifiers::NONE => {
|
||||
self.move_selection(ScrollType::Up);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
Ok(true)
|
||||
}
|
||||
ScrollDown => {
|
||||
match mouse_ev.modifiers {
|
||||
KeyModifiers::SHIFT => {
|
||||
self.modify_selection(Direction::Down)
|
||||
}
|
||||
KeyModifiers::CONTROL => {
|
||||
self.modify_selection(
|
||||
Direction::Down,
|
||||
);
|
||||
self.modify_selection(
|
||||
Direction::Down,
|
||||
);
|
||||
self.modify_selection(
|
||||
Direction::Down,
|
||||
);
|
||||
}
|
||||
KeyModifiers::NONE => {
|
||||
self.move_selection(ScrollType::Down);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
Ok(true)
|
||||
}
|
||||
_ => Ok(false),
|
||||
};
|
||||
} else if let Event::Key(e) = ev {
|
||||
if let Event::Key(e) = ev {
|
||||
return if e == self.key_config.move_down {
|
||||
self.move_selection(ScrollType::Down);
|
||||
Ok(true)
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ use crate::{
|
|||
};
|
||||
use anyhow::Result;
|
||||
use asyncgit::{hash, StatusItem, StatusItemType};
|
||||
use crossterm::event::{
|
||||
Event,
|
||||
MouseEventKind::{ScrollDown, ScrollUp},
|
||||
};
|
||||
use crossterm::event::Event;
|
||||
use std::{borrow::Cow, cell::Cell, convert::From, path::Path};
|
||||
use tui::{backend::Backend, layout::Rect, text::Span, Frame};
|
||||
|
||||
|
|
@ -396,17 +393,7 @@ impl Component for FileTreeComponent {
|
|||
|
||||
fn event(&mut self, ev: Event) -> Result<bool> {
|
||||
if self.focused {
|
||||
if let Event::Mouse(mouse_ev) = ev {
|
||||
return match mouse_ev.kind {
|
||||
ScrollUp => {
|
||||
Ok(self.move_selection(MoveSelection::Up))
|
||||
}
|
||||
ScrollDown => {
|
||||
Ok(self.move_selection(MoveSelection::Down))
|
||||
}
|
||||
_ => Ok(false),
|
||||
};
|
||||
} else if let Event::Key(e) = ev {
|
||||
if let Event::Key(e) = ev {
|
||||
return if e == self.key_config.move_down {
|
||||
Ok(self.move_selection(MoveSelection::Down))
|
||||
} else if e == self.key_config.move_up {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ use clap::{
|
|||
};
|
||||
use crossbeam_channel::{tick, unbounded, Receiver, Select};
|
||||
use crossterm::{
|
||||
event::{DisableMouseCapture, EnableMouseCapture},
|
||||
terminal::{
|
||||
disable_raw_mode, enable_raw_mode, EnterAlternateScreen,
|
||||
LeaveAlternateScreen,
|
||||
|
|
@ -168,13 +167,11 @@ fn main() -> Result<()> {
|
|||
fn setup_terminal() -> Result<()> {
|
||||
enable_raw_mode()?;
|
||||
io::stdout().execute(EnterAlternateScreen)?;
|
||||
io::stdout().execute(EnableMouseCapture)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn shutdown_terminal() -> Result<()> {
|
||||
io::stdout().execute(LeaveAlternateScreen)?;
|
||||
io::stdout().execute(DisableMouseCapture)?;
|
||||
disable_raw_mode()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue