Improve wheel mode
This commit is contained in:
parent
f52df3d89e
commit
f570b4089c
1 changed files with 39 additions and 26 deletions
|
|
@ -43,7 +43,10 @@ use std::{
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{key_bind::key_binds, terminal::Metadata, Action, Terminal, TerminalScroll};
|
use crate::{
|
||||||
|
key_bind::key_binds, mouse_reporter::MouseReporter, terminal::Metadata, Action, Terminal,
|
||||||
|
TerminalScroll,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct TerminalBox<'a, Message> {
|
pub struct TerminalBox<'a, Message> {
|
||||||
terminal: &'a Mutex<Terminal>,
|
terminal: &'a Mutex<Terminal>,
|
||||||
|
|
@ -1195,33 +1198,43 @@ where
|
||||||
let row = y / terminal.size().cell_height;
|
let row = y / terminal.size().cell_height;
|
||||||
terminal.scroll_mouse(delta, &state.modifiers, col as u32, row as u32);
|
terminal.scroll_mouse(delta, &state.modifiers, col as u32, row as u32);
|
||||||
} else {
|
} else {
|
||||||
match delta {
|
if terminal.term.lock().mode().contains(TermMode::ALT_SCREEN) {
|
||||||
ScrollDelta::Lines { x: _, y } => {
|
MouseReporter::report_mouse_wheel_as_arrows(
|
||||||
//TODO: this adjustment is just a guess!
|
&terminal,
|
||||||
state.scroll_pixels = 0.0;
|
terminal.size().cell_width,
|
||||||
let lines = (-y * 6.0) as i32;
|
terminal.size().cell_height,
|
||||||
if lines != 0 {
|
delta,
|
||||||
terminal.scroll(TerminalScroll::Delta(-lines));
|
);
|
||||||
|
status = Status::Captured;
|
||||||
|
} else {
|
||||||
|
match delta {
|
||||||
|
ScrollDelta::Lines { x: _, y } => {
|
||||||
|
//TODO: this adjustment is just a guess!
|
||||||
|
state.scroll_pixels = 0.0;
|
||||||
|
let lines = (-y * 6.0) as i32;
|
||||||
|
if lines != 0 {
|
||||||
|
terminal.scroll(TerminalScroll::Delta(-lines));
|
||||||
|
}
|
||||||
|
status = Status::Captured;
|
||||||
}
|
}
|
||||||
status = Status::Captured;
|
ScrollDelta::Pixels { x: _, y } => {
|
||||||
}
|
//TODO: this adjustment is just a guess!
|
||||||
ScrollDelta::Pixels { x: _, y } => {
|
state.scroll_pixels -= y * 6.0;
|
||||||
//TODO: this adjustment is just a guess!
|
let mut lines = 0;
|
||||||
state.scroll_pixels -= y * 6.0;
|
let metrics = terminal.with_buffer(|buffer| buffer.metrics());
|
||||||
let mut lines = 0;
|
while state.scroll_pixels <= -metrics.line_height {
|
||||||
let metrics = terminal.with_buffer(|buffer| buffer.metrics());
|
lines -= 1;
|
||||||
while state.scroll_pixels <= -metrics.line_height {
|
state.scroll_pixels += metrics.line_height;
|
||||||
lines -= 1;
|
}
|
||||||
state.scroll_pixels += metrics.line_height;
|
while state.scroll_pixels >= metrics.line_height {
|
||||||
|
lines += 1;
|
||||||
|
state.scroll_pixels -= metrics.line_height;
|
||||||
|
}
|
||||||
|
if lines != 0 {
|
||||||
|
terminal.scroll(TerminalScroll::Delta(-lines));
|
||||||
|
}
|
||||||
|
status = Status::Captured;
|
||||||
}
|
}
|
||||||
while state.scroll_pixels >= metrics.line_height {
|
|
||||||
lines += 1;
|
|
||||||
state.scroll_pixels -= metrics.line_height;
|
|
||||||
}
|
|
||||||
if lines != 0 {
|
|
||||||
terminal.scroll(TerminalScroll::Delta(-lines));
|
|
||||||
}
|
|
||||||
status = Status::Captured;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue