Trying to clena the mess opened by plugins
This commit is contained in:
@@ -26,6 +26,56 @@ pub(crate) fn cycle_option_value(ctx: &mut InputContext, right: bool) {
|
||||
OptionsFocus::ShowSpectrum => ctx.dispatch(AppCommand::ToggleSpectrum),
|
||||
OptionsFocus::ShowCompletion => ctx.dispatch(AppCommand::ToggleCompletion),
|
||||
OptionsFocus::ShowPreview => ctx.dispatch(AppCommand::TogglePreview),
|
||||
OptionsFocus::Font => {
|
||||
const FONTS: &[&str] = &["6x13", "7x13", "8x13", "9x15", "9x18", "10x20"];
|
||||
let pos = FONTS.iter().position(|f| *f == ctx.app.ui.font).unwrap_or(2);
|
||||
let new_pos = if right {
|
||||
(pos + 1) % FONTS.len()
|
||||
} else {
|
||||
(pos + FONTS.len() - 1) % FONTS.len()
|
||||
};
|
||||
ctx.dispatch(AppCommand::SetFont(FONTS[new_pos].to_string()));
|
||||
}
|
||||
OptionsFocus::ZoomFactor => {
|
||||
const ZOOMS: &[f32] = &[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0];
|
||||
let pos = ZOOMS
|
||||
.iter()
|
||||
.position(|z| (z - ctx.app.ui.zoom_factor).abs() < 0.01)
|
||||
.unwrap_or(4);
|
||||
let new_pos = if right {
|
||||
(pos + 1) % ZOOMS.len()
|
||||
} else {
|
||||
(pos + ZOOMS.len() - 1) % ZOOMS.len()
|
||||
};
|
||||
ctx.dispatch(AppCommand::SetZoomFactor(ZOOMS[new_pos]));
|
||||
}
|
||||
OptionsFocus::WindowSize => {
|
||||
const WINDOW_SIZES: &[(u32, u32)] = &[
|
||||
(900, 600), (1050, 700), (1200, 800), (1350, 900), (1500, 1000),
|
||||
];
|
||||
let pos = WINDOW_SIZES
|
||||
.iter()
|
||||
.position(|&(w, h)| w == ctx.app.ui.window_width && h == ctx.app.ui.window_height)
|
||||
.unwrap_or_else(|| {
|
||||
WINDOW_SIZES
|
||||
.iter()
|
||||
.enumerate()
|
||||
.min_by_key(|&(_, &(w, h))| {
|
||||
let dw = w as i64 - ctx.app.ui.window_width as i64;
|
||||
let dh = h as i64 - ctx.app.ui.window_height as i64;
|
||||
dw * dw + dh * dh
|
||||
})
|
||||
.map(|(i, _)| i)
|
||||
.unwrap_or(2)
|
||||
});
|
||||
let new_pos = if right {
|
||||
(pos + 1) % WINDOW_SIZES.len()
|
||||
} else {
|
||||
(pos + WINDOW_SIZES.len() - 1) % WINDOW_SIZES.len()
|
||||
};
|
||||
let (w, h) = WINDOW_SIZES[new_pos];
|
||||
ctx.dispatch(AppCommand::SetWindowSize(w, h));
|
||||
}
|
||||
OptionsFocus::LinkEnabled => ctx.link.set_enabled(!ctx.link.is_enabled()),
|
||||
OptionsFocus::StartStopSync => ctx
|
||||
.link
|
||||
|
||||
Reference in New Issue
Block a user