rmux_core/session/
layout_cycle.rs1use rmux_proto::{LayoutName, RmuxError};
2
3use super::Session;
4
5impl Session {
6 pub fn select_layout(&mut self, layout: LayoutName) {
8 self.select_layout_in_window(self.active_window, layout)
9 .expect("active session window must exist");
10 }
11
12 pub fn select_layout_in_window(
14 &mut self,
15 window_index: u32,
16 layout: LayoutName,
17 ) -> Result<(), RmuxError> {
18 self.select_layout_in_window_with_main_pane_size(window_index, layout, None, None)
19 }
20
21 pub fn select_layout_in_window_with_main_pane_size(
23 &mut self,
24 window_index: u32,
25 layout: LayoutName,
26 main_width: Option<u16>,
27 main_height: Option<u16>,
28 ) -> Result<(), RmuxError> {
29 self.resolve_window_target_mut(window_index)?
30 .set_layout_with_main_pane_size(layout, main_width, main_height);
31 Ok(())
32 }
33
34 pub fn select_custom_layout_in_window(
36 &mut self,
37 window_index: u32,
38 layout: &str,
39 ) -> Result<(), RmuxError> {
40 self.resolve_window_target_mut(window_index)?
41 .apply_custom_layout(layout)
42 }
43
44 pub fn reapply_old_layout_in_window(&mut self, window_index: u32) -> Result<bool, RmuxError> {
46 self.resolve_window_target_mut(window_index)?
47 .reapply_old_layout()
48 }
49
50 pub fn save_old_layout_in_window(&mut self, window_index: u32) -> Result<(), RmuxError> {
52 self.resolve_window_target_mut(window_index)?
53 .save_old_layout();
54 Ok(())
55 }
56
57 pub fn spread_layout_in_window(&mut self, window_index: u32) -> Result<bool, RmuxError> {
59 let window = self.resolve_window_target_mut(window_index)?;
60 Ok(window.spread_layout(window.active_pane_index()))
61 }
62
63 pub fn next_layout_in_window(&mut self, window_index: u32) -> Result<LayoutName, RmuxError> {
65 self.next_layout_in_window_with_main_pane_size(window_index, None, None)
66 }
67
68 pub fn next_layout_in_window_with_main_pane_size(
70 &mut self,
71 window_index: u32,
72 main_width: Option<u16>,
73 main_height: Option<u16>,
74 ) -> Result<LayoutName, RmuxError> {
75 Ok(self
76 .resolve_window_target_mut(window_index)?
77 .next_layout_with_main_pane_size(main_width, main_height))
78 }
79
80 pub fn previous_layout_in_window(
82 &mut self,
83 window_index: u32,
84 ) -> Result<LayoutName, RmuxError> {
85 self.previous_layout_in_window_with_main_pane_size(window_index, None, None)
86 }
87
88 pub fn previous_layout_in_window_with_main_pane_size(
90 &mut self,
91 window_index: u32,
92 main_width: Option<u16>,
93 main_height: Option<u16>,
94 ) -> Result<LayoutName, RmuxError> {
95 Ok(self
96 .resolve_window_target_mut(window_index)?
97 .previous_layout_with_main_pane_size(main_width, main_height))
98 }
99}