Remove some repetition

timeout_old
Tassilo Horn 3 years ago
parent a93f2a7f1d
commit 546e0e326b
  1. 107
      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,9 +217,7 @@ 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::ExecuteSwaymsgCommand,
SwayrCommand::QuitWindow, SwayrCommand::QuitWindow,
SwayrCommand::QuitWorkspaceOrWindow, SwayrCommand::QuitWorkspaceOrWindow,
@ -227,68 +225,43 @@ pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) {
SwayrCommand::SwitchWorkspace, SwayrCommand::SwitchWorkspace,
SwayrCommand::SwitchWorkspaceOrWindow, SwayrCommand::SwitchWorkspaceOrWindow,
SwayrCommand::SwitchToUrgentOrLRUWindow, SwayrCommand::SwitchToUrgentOrLRUWindow,
SwayrCommand::ToggleTabShuffleTileWorkspace { ];
floating: ConsiderFloating::ExcludeFloating, for f in [
}, ConsiderFloating::ExcludeFloating,
SwayrCommand::ToggleTabShuffleTileWorkspace { ConsiderFloating::IncludeFloating,
floating: ConsiderFloating::IncludeFloating, ] {
}, cmds.push(SwayrCommand::ToggleTabShuffleTileWorkspace {
SwayrCommand::TileWorkspace { floating: f.clone(),
floating: ConsiderFloating::ExcludeFloating, });
}, cmds.push(SwayrCommand::TileWorkspace {
SwayrCommand::TileWorkspace { floating: f.clone(),
floating: ConsiderFloating::IncludeFloating, });
}, cmds.push(SwayrCommand::TabWorkspace {
SwayrCommand::TabWorkspace { floating: f.clone(),
floating: ConsiderFloating::ExcludeFloating, });
}, cmds.push(SwayrCommand::ShuffleTileWorkspace {
SwayrCommand::TabWorkspace { floating: f.clone(),
floating: ConsiderFloating::IncludeFloating, });
}, }
SwayrCommand::ShuffleTileWorkspace { for f in [
floating: ConsiderFloating::ExcludeFloating, ConsiderWindows::AllWorkspaces,
}, ConsiderWindows::CurrentWorkspace,
SwayrCommand::ShuffleTileWorkspace { ] {
floating: ConsiderFloating::IncludeFloating, cmds.push(SwayrCommand::NextWindow { windows: f.clone() });
}, cmds.push(SwayrCommand::PrevWindow { windows: f.clone() });
SwayrCommand::NextWindow { cmds.push(SwayrCommand::NextTiledWindow { windows: f.clone() });
windows: ConsiderWindows::AllWorkspaces, cmds.push(SwayrCommand::PrevTiledWindow { windows: f.clone() });
}, cmds.push(SwayrCommand::NextTabbedOrStackedWindow {
SwayrCommand::NextWindow { windows: f.clone(),
windows: ConsiderWindows::CurrentWorkspace, });
}, cmds.push(SwayrCommand::PrevTabbedOrStackedWindow {
SwayrCommand::PrevWindow { windows: f.clone(),
windows: ConsiderWindows::AllWorkspaces, });
}, }
SwayrCommand::PrevWindow {
windows: ConsiderWindows::CurrentWorkspace, if let Some(c) =
}, util::select_from_menu("Select swayr command", &cmds)
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