|
|
@ -19,16 +19,12 @@ use crate::config as cfg; |
|
|
|
use crate::ipc; |
|
|
|
use crate::ipc; |
|
|
|
use crate::ipc::NodeMethods; |
|
|
|
use crate::ipc::NodeMethods; |
|
|
|
use crate::util; |
|
|
|
use crate::util; |
|
|
|
|
|
|
|
use crate::util::DisplayFormat; |
|
|
|
use lazy_static::lazy_static; |
|
|
|
use lazy_static::lazy_static; |
|
|
|
use std::cmp; |
|
|
|
use std::cmp; |
|
|
|
use std::collections::HashMap; |
|
|
|
use std::collections::HashMap; |
|
|
|
use std::fmt; |
|
|
|
|
|
|
|
use swayipc as s; |
|
|
|
use swayipc as s; |
|
|
|
|
|
|
|
|
|
|
|
pub trait DisplayFormat { |
|
|
|
|
|
|
|
fn format_for_display(&self, config: &cfg::Config) -> String; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
#[derive(Debug)] |
|
|
|
pub struct Window<'a> { |
|
|
|
pub struct Window<'a> { |
|
|
|
node: &'a s::Node, |
|
|
|
node: &'a s::Node, |
|
|
@ -107,20 +103,6 @@ impl PartialOrd for Window<'_> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl<'a> fmt::Display for Window<'a> { |
|
|
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { |
|
|
|
|
|
|
|
write!( |
|
|
|
|
|
|
|
f, |
|
|
|
|
|
|
|
"\"{}\" — {} on workspace {} (id: {}, urgent: {})", |
|
|
|
|
|
|
|
self.get_title(), |
|
|
|
|
|
|
|
self.get_app_name(), |
|
|
|
|
|
|
|
self.workspace.name.as_ref().unwrap(), |
|
|
|
|
|
|
|
self.get_id(), |
|
|
|
|
|
|
|
self.node.urgent |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lazy_static! { |
|
|
|
lazy_static! { |
|
|
|
static ref APP_NAME_AND_VERSION_RX: regex::Regex = |
|
|
|
static ref APP_NAME_AND_VERSION_RX: regex::Regex = |
|
|
|
regex::Regex::new("(.+)(-[0-9.]+)").unwrap(); |
|
|
|
regex::Regex::new("(.+)(-[0-9.]+)").unwrap(); |
|
|
@ -227,7 +209,9 @@ fn build_workspaces<'a>( |
|
|
|
) -> Vec<Workspace<'a>> { |
|
|
|
) -> Vec<Workspace<'a>> { |
|
|
|
let mut v = vec![]; |
|
|
|
let mut v = vec![]; |
|
|
|
for workspace in root.workspaces() { |
|
|
|
for workspace in root.workspaces() { |
|
|
|
if !include_scratchpad && workspace.is_scratchpad() { |
|
|
|
if workspace.windows().is_empty() |
|
|
|
|
|
|
|
|| workspace.is_scratchpad() && !include_scratchpad |
|
|
|
|
|
|
|
{ |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -297,18 +281,6 @@ pub enum WsOrWin<'a> { |
|
|
|
Win { win: &'a Window<'a> }, |
|
|
|
Win { win: &'a Window<'a> }, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl<'a> fmt::Display for WsOrWin<'a> { |
|
|
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { |
|
|
|
|
|
|
|
match self { |
|
|
|
|
|
|
|
WsOrWin::Ws { ws } => ws.fmt(f), |
|
|
|
|
|
|
|
WsOrWin::Win { win } => match f.write_str("\t") { |
|
|
|
|
|
|
|
Ok(()) => win.fmt(f), |
|
|
|
|
|
|
|
Err(e) => Err(e), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl DisplayFormat for WsOrWin<'_> { |
|
|
|
impl DisplayFormat for WsOrWin<'_> { |
|
|
|
fn format_for_display(&self, cfg: &cfg::Config) -> String { |
|
|
|
fn format_for_display(&self, cfg: &cfg::Config) -> String { |
|
|
|
match self { |
|
|
|
match self { |
|
|
@ -390,12 +362,6 @@ impl PartialOrd for Workspace<'_> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl<'a> fmt::Display for Workspace<'a> { |
|
|
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { |
|
|
|
|
|
|
|
write!(f, "“Workspace {}” (id: {})", self.get_name(), self.get_id()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<'a> DisplayFormat for Workspace<'a> { |
|
|
|
impl<'a> DisplayFormat for Workspace<'a> { |
|
|
|
fn format_for_display(&self, cfg: &cfg::Config) -> String { |
|
|
|
fn format_for_display(&self, cfg: &cfg::Config) -> String { |
|
|
|
let default_format = cfg::Format::default(); |
|
|
|
let default_format = cfg::Format::default(); |
|
|
|