Remove some repetition

timeout_old
Tassilo Horn 3 years ago
parent a93f2a7f1d
commit 546e0e326b
  1. 121
      src/cmds.rs

@ -30,7 +30,7 @@ use std::sync::Arc;
use std::sync::RwLock; use std::sync::RwLock;
use swayipc as s; use swayipc as s;
#[derive(Clap, Debug, Deserialize, Serialize, PartialEq)] #[derive(Clap, Debug, Deserialize, Serialize, PartialEq, Clone)]
pub enum ConsiderFloating { pub enum ConsiderFloating {
/// Include floating windows. /// Include floating windows.
IncludeFloating, IncludeFloating,
@ -38,7 +38,7 @@ pub enum ConsiderFloating {
ExcludeFloating, ExcludeFloating,
} }
#[derive(Clap, Debug, Deserialize, Serialize, PartialEq)] #[derive(Clap, Debug, Deserialize, Serialize, PartialEq, Clone)]
pub enum ConsiderWindows { pub enum ConsiderWindows {
/// Consider windows of all workspaces. /// Consider windows of all workspaces.
AllWorkspaces, AllWorkspaces,
@ -217,78 +217,51 @@ pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) {
} }
SwayrCommand::ExecuteSwaymsgCommand => exec_swaymsg_command(), SwayrCommand::ExecuteSwaymsgCommand => exec_swaymsg_command(),
SwayrCommand::ExecuteSwayrCommand => { SwayrCommand::ExecuteSwayrCommand => {
if let Some(c) = util::select_from_menu( let mut cmds = vec![
"Select swayr command", SwayrCommand::ExecuteSwaymsgCommand,
&[ SwayrCommand::QuitWindow,
SwayrCommand::ExecuteSwaymsgCommand, SwayrCommand::QuitWorkspaceOrWindow,
SwayrCommand::QuitWindow, SwayrCommand::SwitchWindow,
SwayrCommand::QuitWorkspaceOrWindow, SwayrCommand::SwitchWorkspace,
SwayrCommand::SwitchWindow, SwayrCommand::SwitchWorkspaceOrWindow,
SwayrCommand::SwitchWorkspace, SwayrCommand::SwitchToUrgentOrLRUWindow,
SwayrCommand::SwitchWorkspaceOrWindow, ];
SwayrCommand::SwitchToUrgentOrLRUWindow, for f in [
SwayrCommand::ToggleTabShuffleTileWorkspace { ConsiderFloating::ExcludeFloating,
floating: ConsiderFloating::ExcludeFloating, ConsiderFloating::IncludeFloating,
}, ] {
SwayrCommand::ToggleTabShuffleTileWorkspace { cmds.push(SwayrCommand::ToggleTabShuffleTileWorkspace {
floating: ConsiderFloating::IncludeFloating, floating: f.clone(),
}, });
SwayrCommand::TileWorkspace { cmds.push(SwayrCommand::TileWorkspace {
floating: ConsiderFloating::ExcludeFloating, floating: f.clone(),
}, });
SwayrCommand::TileWorkspace { cmds.push(SwayrCommand::TabWorkspace {
floating: ConsiderFloating::IncludeFloating, floating: f.clone(),
}, });
SwayrCommand::TabWorkspace { cmds.push(SwayrCommand::ShuffleTileWorkspace {
floating: ConsiderFloating::ExcludeFloating, floating: f.clone(),
}, });
SwayrCommand::TabWorkspace { }
floating: ConsiderFloating::IncludeFloating, for f in [
}, ConsiderWindows::AllWorkspaces,
SwayrCommand::ShuffleTileWorkspace { ConsiderWindows::CurrentWorkspace,
floating: ConsiderFloating::ExcludeFloating, ] {
}, cmds.push(SwayrCommand::NextWindow { windows: f.clone() });
SwayrCommand::ShuffleTileWorkspace { cmds.push(SwayrCommand::PrevWindow { windows: f.clone() });
floating: ConsiderFloating::IncludeFloating, cmds.push(SwayrCommand::NextTiledWindow { windows: f.clone() });
}, cmds.push(SwayrCommand::PrevTiledWindow { windows: f.clone() });
SwayrCommand::NextWindow { cmds.push(SwayrCommand::NextTabbedOrStackedWindow {
windows: ConsiderWindows::AllWorkspaces, windows: f.clone(),
}, });
SwayrCommand::NextWindow { cmds.push(SwayrCommand::PrevTabbedOrStackedWindow {
windows: ConsiderWindows::CurrentWorkspace, windows: f.clone(),
}, });
SwayrCommand::PrevWindow { }
windows: ConsiderWindows::AllWorkspaces,
}, if let Some(c) =
SwayrCommand::PrevWindow { util::select_from_menu("Select swayr command", &cmds)
windows: ConsiderWindows::CurrentWorkspace, {
},
SwayrCommand::NextTiledWindow {
windows: ConsiderWindows::AllWorkspaces,
},
SwayrCommand::NextTiledWindow {
windows: ConsiderWindows::CurrentWorkspace,
},
SwayrCommand::PrevTiledWindow {
windows: ConsiderWindows::AllWorkspaces,
},
SwayrCommand::PrevTiledWindow {
windows: ConsiderWindows::CurrentWorkspace,
},
SwayrCommand::NextTabbedOrStackedWindow {
windows: ConsiderWindows::AllWorkspaces,
},
SwayrCommand::NextTabbedOrStackedWindow {
windows: ConsiderWindows::CurrentWorkspace,
},
SwayrCommand::PrevTabbedOrStackedWindow {
windows: ConsiderWindows::AllWorkspaces,
},
SwayrCommand::PrevTabbedOrStackedWindow {
windows: ConsiderWindows::CurrentWorkspace,
},
],
) {
exec_swayr_cmd(ExecSwayrCmdArgs { exec_swayr_cmd(ExecSwayrCmdArgs {
cmd: c, cmd: c,
extra_props: props, extra_props: props,

Loading…
Cancel
Save