parent
90c68fb6a6
commit
164eb6a5b7
8 changed files with 74 additions and 6 deletions
|
|
@ -176,6 +176,7 @@ impl InputHandler {
|
||||||
let mut should_break = false;
|
let mut should_break = false;
|
||||||
|
|
||||||
match action {
|
match action {
|
||||||
|
Action::NoOp => {}
|
||||||
Action::Quit | Action::Detach => {
|
Action::Quit | Action::Detach => {
|
||||||
self.os_input
|
self.os_input
|
||||||
.send_to_server(ClientToServerMsg::Action(action));
|
.send_to_server(ClientToServerMsg::Action(action));
|
||||||
|
|
|
||||||
|
|
@ -120,10 +120,11 @@ fn route_action(
|
||||||
}
|
}
|
||||||
Action::MovePane(direction) => {
|
Action::MovePane(direction) => {
|
||||||
let screen_instr = match direction {
|
let screen_instr = match direction {
|
||||||
Direction::Left => ScreenInstruction::MovePaneLeft(client_id),
|
Some(Direction::Left) => ScreenInstruction::MovePaneLeft(client_id),
|
||||||
Direction::Right => ScreenInstruction::MovePaneRight(client_id),
|
Some(Direction::Right) => ScreenInstruction::MovePaneRight(client_id),
|
||||||
Direction::Up => ScreenInstruction::MovePaneUp(client_id),
|
Some(Direction::Up) => ScreenInstruction::MovePaneUp(client_id),
|
||||||
Direction::Down => ScreenInstruction::MovePaneDown(client_id),
|
Some(Direction::Down) => ScreenInstruction::MovePaneDown(client_id),
|
||||||
|
None => ScreenInstruction::MovePane(client_id),
|
||||||
};
|
};
|
||||||
session.senders.send_to_screen(screen_instr).unwrap();
|
session.senders.send_to_screen(screen_instr).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ pub(crate) enum ScreenInstruction {
|
||||||
MoveFocusUp(ClientId),
|
MoveFocusUp(ClientId),
|
||||||
MoveFocusRight(ClientId),
|
MoveFocusRight(ClientId),
|
||||||
MoveFocusRightOrNextTab(ClientId),
|
MoveFocusRightOrNextTab(ClientId),
|
||||||
|
MovePane(ClientId),
|
||||||
MovePaneUp(ClientId),
|
MovePaneUp(ClientId),
|
||||||
MovePaneDown(ClientId),
|
MovePaneDown(ClientId),
|
||||||
MovePaneRight(ClientId),
|
MovePaneRight(ClientId),
|
||||||
|
|
@ -106,6 +107,7 @@ impl From<&ScreenInstruction> for ScreenContext {
|
||||||
ScreenInstruction::MoveFocusRightOrNextTab(..) => {
|
ScreenInstruction::MoveFocusRightOrNextTab(..) => {
|
||||||
ScreenContext::MoveFocusRightOrNextTab
|
ScreenContext::MoveFocusRightOrNextTab
|
||||||
}
|
}
|
||||||
|
ScreenInstruction::MovePane(..) => ScreenContext::MovePane,
|
||||||
ScreenInstruction::MovePaneDown(..) => ScreenContext::MovePaneDown,
|
ScreenInstruction::MovePaneDown(..) => ScreenContext::MovePaneDown,
|
||||||
ScreenInstruction::MovePaneUp(..) => ScreenContext::MovePaneUp,
|
ScreenInstruction::MovePaneUp(..) => ScreenContext::MovePaneUp,
|
||||||
ScreenInstruction::MovePaneRight(..) => ScreenContext::MovePaneRight,
|
ScreenInstruction::MovePaneRight(..) => ScreenContext::MovePaneRight,
|
||||||
|
|
@ -736,6 +738,14 @@ pub(crate) fn screen_thread_main(
|
||||||
|
|
||||||
screen.render();
|
screen.render();
|
||||||
}
|
}
|
||||||
|
ScreenInstruction::MovePane(client_id) => {
|
||||||
|
screen
|
||||||
|
.get_active_tab_mut(client_id)
|
||||||
|
.unwrap()
|
||||||
|
.move_active_pane();
|
||||||
|
|
||||||
|
screen.render();
|
||||||
|
}
|
||||||
ScreenInstruction::MovePaneDown(client_id) => {
|
ScreenInstruction::MovePaneDown(client_id) => {
|
||||||
screen
|
screen
|
||||||
.get_active_tab_mut(client_id)
|
.get_active_tab_mut(client_id)
|
||||||
|
|
|
||||||
|
|
@ -2033,6 +2033,56 @@ impl Tab {
|
||||||
self.active_terminal = updated_active_terminal;
|
self.active_terminal = updated_active_terminal;
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
pub fn move_active_pane(&mut self) {
|
||||||
|
if !self.has_selectable_panes() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if self.fullscreen_is_active {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let active_pane_id = self.get_active_pane_id().unwrap();
|
||||||
|
let mut panes: Vec<(&PaneId, &Box<dyn Pane>)> = self.get_selectable_panes().collect();
|
||||||
|
panes.sort_by(|(_a_id, a_pane), (_b_id, b_pane)| {
|
||||||
|
if a_pane.y() == b_pane.y() {
|
||||||
|
a_pane.x().cmp(&b_pane.x())
|
||||||
|
} else {
|
||||||
|
a_pane.y().cmp(&b_pane.y())
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let active_pane_position = panes
|
||||||
|
.iter()
|
||||||
|
.position(|(id, _)| *id == &active_pane_id) // TODO: better
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let new_position_id = panes
|
||||||
|
.get(active_pane_position + 1)
|
||||||
|
.or_else(|| panes.get(0))
|
||||||
|
.map(|p| *p.0);
|
||||||
|
|
||||||
|
if let Some(p) = new_position_id {
|
||||||
|
let current_position = self.panes.get(&active_pane_id).unwrap();
|
||||||
|
let prev_geom = current_position.position_and_size();
|
||||||
|
let prev_geom_override = current_position.geom_override();
|
||||||
|
|
||||||
|
let new_position = self.panes.get_mut(&p).unwrap();
|
||||||
|
let next_geom = new_position.position_and_size();
|
||||||
|
let next_geom_override = new_position.geom_override();
|
||||||
|
new_position.set_geom(prev_geom);
|
||||||
|
if let Some(geom) = prev_geom_override {
|
||||||
|
new_position.get_geom_override(geom);
|
||||||
|
}
|
||||||
|
resize_pty!(new_position, self.os_api);
|
||||||
|
new_position.set_should_render(true);
|
||||||
|
|
||||||
|
let current_position = self.panes.get_mut(&active_pane_id).unwrap();
|
||||||
|
current_position.set_geom(next_geom);
|
||||||
|
if let Some(geom) = next_geom_override {
|
||||||
|
current_position.get_geom_override(geom);
|
||||||
|
}
|
||||||
|
resize_pty!(current_position, self.os_api);
|
||||||
|
current_position.set_should_render(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn move_active_pane_down(&mut self) {
|
pub fn move_active_pane_down(&mut self) {
|
||||||
if !self.has_selectable_panes() {
|
if !self.has_selectable_panes() {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,8 @@ keybinds:
|
||||||
key: [Ctrl: 'o',]
|
key: [Ctrl: 'o',]
|
||||||
- action: [Quit]
|
- action: [Quit]
|
||||||
key: [Ctrl: 'q']
|
key: [Ctrl: 'q']
|
||||||
|
- action: [MovePane: ,]
|
||||||
|
key: [Char: 'n', Char: "\t",]
|
||||||
- action: [MovePane: Left,]
|
- action: [MovePane: Left,]
|
||||||
key: [Char: 'h', Left,]
|
key: [Char: 'h', Left,]
|
||||||
- action: [MovePane: Down,]
|
- action: [MovePane: Down,]
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,7 @@ pub enum ScreenContext {
|
||||||
MoveFocusUp,
|
MoveFocusUp,
|
||||||
MoveFocusRight,
|
MoveFocusRight,
|
||||||
MoveFocusRightOrNextTab,
|
MoveFocusRightOrNextTab,
|
||||||
|
MovePane,
|
||||||
MovePaneDown,
|
MovePaneDown,
|
||||||
MovePaneUp,
|
MovePaneUp,
|
||||||
MovePaneRight,
|
MovePaneRight,
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ pub enum Action {
|
||||||
/// Tries to move the focus pane in specified direction.
|
/// Tries to move the focus pane in specified direction.
|
||||||
/// If there is no pane in the direction, move to previous/next Tab.
|
/// If there is no pane in the direction, move to previous/next Tab.
|
||||||
MoveFocusOrTab(Direction),
|
MoveFocusOrTab(Direction),
|
||||||
MovePane(Direction),
|
MovePane(Option<Direction>),
|
||||||
/// Scroll up in focus pane.
|
/// Scroll up in focus pane.
|
||||||
ScrollUp,
|
ScrollUp,
|
||||||
/// Scroll up at point
|
/// Scroll up at point
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@ pub fn get_mode_info(
|
||||||
let keybinds = match mode {
|
let keybinds = match mode {
|
||||||
InputMode::Normal | InputMode::Locked => Vec::new(),
|
InputMode::Normal | InputMode::Locked => Vec::new(),
|
||||||
InputMode::Resize => vec![("←↓↑→".to_string(), "Resize".to_string())],
|
InputMode::Resize => vec![("←↓↑→".to_string(), "Resize".to_string())],
|
||||||
InputMode::Move => vec![("←↓↑→".to_string(), "Move".to_string())],
|
InputMode::Move => vec![
|
||||||
|
("←↓↑→".to_string(), "Move".to_string()),
|
||||||
|
("n/Tab".to_string(), "Next Pane".to_string()),
|
||||||
|
],
|
||||||
InputMode::Pane => vec![
|
InputMode::Pane => vec![
|
||||||
("←↓↑→".to_string(), "Move focus".to_string()),
|
("←↓↑→".to_string(), "Move focus".to_string()),
|
||||||
("p".to_string(), "Next".to_string()),
|
("p".to_string(), "Next".to_string()),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue