mirror of https://github.com/lapce/lapce.git
Add settings to configure the scroll speed (#2120)
Feature requested here: https://github.com/lapce/lapce/issues/2085 Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
parent
eaa1b571dd
commit
cdae7c8a9a
|
@ -47,6 +47,7 @@ atomic-soft-tabs = false
|
|||
double-click = false
|
||||
move-focus-while-search = true
|
||||
diff-context-lines=3
|
||||
scroll-speed-modifier=1
|
||||
|
||||
[terminal]
|
||||
font-family = ""
|
||||
|
|
|
@ -475,6 +475,10 @@ pub struct EditorConfig {
|
|||
desc = "Set the default number of visible lines above and below the diff block (-1 for infinite)"
|
||||
)]
|
||||
pub diff_context_lines: i32,
|
||||
#[field_names(
|
||||
desc = "Scroll speed modifier. The scroll delta will be multiplied by whatever the value is povided here. Defaults to 1."
|
||||
)]
|
||||
pub scroll_speed_modifier: f64,
|
||||
}
|
||||
|
||||
impl EditorConfig {
|
||||
|
|
|
@ -742,11 +742,13 @@ pub fn handle_scroll(
|
|||
port: &mut Viewport,
|
||||
ctx: &mut EventCtx,
|
||||
event: &Event,
|
||||
config: &LapceConfig,
|
||||
env: &Env,
|
||||
) {
|
||||
if !ctx.is_handled() {
|
||||
if let Event::Wheel(mouse) = event {
|
||||
let mut delta = mouse.wheel_delta.round();
|
||||
let mut delta =
|
||||
mouse.wheel_delta.round() * config.editor.scroll_speed_modifier;
|
||||
if self.vertical_scroll_for_horizontal && delta.x == 0.0 {
|
||||
delta.x = delta.y;
|
||||
}
|
||||
|
@ -898,7 +900,7 @@ fn event(&mut self, ctx: &mut EventCtx, event: &Event, data: &mut T, env: &Env)
|
|||
}
|
||||
|
||||
self.clip.with_port(|port| {
|
||||
scroll_component.handle_scroll(port, ctx, event, env);
|
||||
scroll_component.handle_scroll(port, ctx, event, data.get_config(), env);
|
||||
});
|
||||
|
||||
match event {
|
||||
|
|
Loading…
Reference in New Issue