1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use crate::Window;
use crate::TmuxInterface;
use crate::TmuxInterfaceError;
use crate::window::{WINDOW_VARS_REGEX_VEC, WINDOW_VARS_SEPARATOR};
pub struct Windows {
}
impl Windows {
pub fn get(target_session: &str) -> Result<Vec<Window>, TmuxInterfaceError> {
let tmux = TmuxInterface::new();
let lsw_format = WINDOW_VARS_REGEX_VEC.iter().map(|t| format!("#{{{}}}", t.0))
.collect::<Vec<String>>().join(WINDOW_VARS_SEPARATOR);
let windows_str = tmux.list_windows(false, Some(&lsw_format), Some(target_session))?;
Windows::parse(&windows_str)
}
pub fn parse(windows_str: &str) -> Result<Vec<Window>, TmuxInterfaceError> {
let mut windows: Vec<Window> = Vec::new();
for line in windows_str.lines() {
windows.push(Window::parse(line)?);
}
Ok(windows)
}
}