Window ID / Window Title / Pane number missing
pbartyik opened this issue · comments
use tmux_interface;
use tmux_interface::session::SESSION_ALL;
fn main() {
let sessions = tmux_interface::Sessions::get(SESSION_ALL).unwrap();
for s in sessions {
let session_name = s.name.unwrap();
let ws = tmux_interface::Windows::get(&session_name, 64).unwrap();
println!("Session {}", session_name);
for w in ws {
println!("{:?}", w);
}
}
}
Session 0 has two windows, one unnamed (id 0) and one named asd
(id 1).
Session 0 window id 1 has two panes.
Output of program:
Session 0
Window { active: None, activity: None, activity_flag: None, bell_flag: None, bigger: None, end_flag: None, flags: Some(WindowFlag(2)), form
at: None, height: None, id: None, index: None, last_flag: None, layout: None, linked: None, name: None, offset_x: None, offset_y: None, pan
es: None, silence_flag: None, stack_index: None, start_flag: None, visible_layout: None, width: None, zoomed_flag: None }
Window { active: None, activity: None, activity_flag: None, bell_flag: None, bigger: None, end_flag: None, flags: Some(WindowFlag(1)), form
at: None, height: None, id: None, index: None, last_flag: None, layout: None, linked: None, name: None, offset_x: None, offset_y: None, pan
es: None, silence_flag: None, stack_index: None, start_flag: None, visible_layout: None, width: None, zoomed_flag: None }
Session 7
Window { active: None, activity: None, activity_flag: None, bell_flag: None, bigger: None, end_flag: None, flags: Some(WindowFlag(1)), form
at: None, height: None, id: None, index: None, last_flag: None, layout: None, linked: None, name: None, offset_x: None, offset_y: None, pan
es: None, silence_flag: None, stack_index: None, start_flag: None, visible_layout: None, width: None, zoomed_flag: None }
[Process exited 0]
let ws = tmux_interface::Windows::get(&session_name, tmux_interface::window::WINDOW_ALL).unwrap();
fixes
Hi,
thank you for your feedback, for choosing/using the library.
If you are calling the function Windows::get()
:
let ws = tmux_interface::Windows::get(&session_name, 64).unwrap();
it expects one or many WINDOW_XXXXXX
flags as the secondary argument. In your example 64
is equal to 1 << 6
(bitwise shift left) and it is equal to WINDOW_FLAGS
flag. This produces the following string as request command to tmux:
tmux list-windows -t session_name -F "#{window_flags}"
and the resulting Windows
structure will be something like:
Vec {
// first window, all fields except window_flag are empty
Window {
None, None, None, ..., Some(WindowFlag(WINDOW_FLAG_DEFAULT), None, None, ...}
},
// second window
Window {
None, None, None, ..., Some(WindowFlag(WINDOW_FLAG_CURRENT), None, None, ...}
},
...
}
You are right you can request all supported fields by using WINDOW_ALL
flag:
let ws = tmux_interface::Windows::get(&session_name, WINDOW_ALL).unwrap();
or you can manually set the bitflag combination for fields you need, for example WINDOW_ID | WINDOW_FLAGS | WINDOW_NAME | WINDOW_HEIGHT | WINDOW_WIDTH
let ws = tmux_interface::Windows::get(
&session_name,
WINDOW_ID | WINDOW_FLAGS | WINDOW_NAME | WINDOW_HEIGHT | WINDOW_WIDTH
).unwrap();
It is made to reduce the size of the text exchanging between tmux and user application.
Sorry for missing documentation which would help you faster. I mark this as documentation required issue.
Please be advised, the library (especially dev
branch) is still in experimental development stage and it is not well tested:
many features are not implemented, or can fail
some APIs/structures/names/... can be changed in future
some design patterns of the library can be changed
etc…
Thanks, digged solution out from source code :)