add(style): add trailing comma in match blocks (#1483)

This makes it easier to distinguish from normal blocks
This commit is contained in:
a-kenji 2022-06-10 20:03:13 +02:00 committed by GitHub
parent bcaa6b82c5
commit 67d2673cae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 627 additions and 626 deletions

1
.rustfmt.toml Normal file
View File

@ -0,0 +1 @@
match_block_trailing_comma = true

View File

@ -49,23 +49,23 @@ impl ZellijPlugin for State {
} else { } else {
eprintln!("Could not find active tab."); eprintln!("Could not find active tab.");
} }
} },
Event::Mouse(me) => match me { Event::Mouse(me) => match me {
Mouse::LeftClick(_, col) => { Mouse::LeftClick(_, col) => {
self.mouse_click_pos = col; self.mouse_click_pos = col;
self.should_render = true; self.should_render = true;
} },
Mouse::ScrollUp(_) => { Mouse::ScrollUp(_) => {
switch_tab_to(min(self.active_tab_idx + 1, self.tabs.len()) as u32); switch_tab_to(min(self.active_tab_idx + 1, self.tabs.len()) as u32);
} },
Mouse::ScrollDown(_) => { Mouse::ScrollDown(_) => {
switch_tab_to(max(self.active_tab_idx.saturating_sub(1), 1) as u32); switch_tab_to(max(self.active_tab_idx.saturating_sub(1), 1) as u32);
} },
_ => {} _ => {},
}, },
_ => { _ => {
eprintln!("Got unrecognized event: {:?}", event); eprintln!("Got unrecognized event: {:?}", event);
} },
} }
} }
@ -130,10 +130,10 @@ impl ZellijPlugin for State {
match background { match background {
PaletteColor::Rgb((r, g, b)) => { PaletteColor::Rgb((r, g, b)) => {
println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b); println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b);
} },
PaletteColor::EightBit(color) => { PaletteColor::EightBit(color) => {
println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color); println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color);
} },
} }
self.should_render = false; self.should_render = false;
} }

View File

@ -261,16 +261,16 @@ fn single_letter_ctrl_key(
match key.mode { match key.mode {
CtrlKeyMode::Unselected => { CtrlKeyMode::Unselected => {
unselected_mode_shortcut_single_letter(letter_shortcut, palette, separator) unselected_mode_shortcut_single_letter(letter_shortcut, palette, separator)
} },
CtrlKeyMode::UnselectedAlternate => { CtrlKeyMode::UnselectedAlternate => {
unselected_alternate_mode_shortcut_single_letter(letter_shortcut, palette, separator) unselected_alternate_mode_shortcut_single_letter(letter_shortcut, palette, separator)
} },
CtrlKeyMode::Selected => { CtrlKeyMode::Selected => {
selected_mode_shortcut_single_letter(letter_shortcut, palette, separator) selected_mode_shortcut_single_letter(letter_shortcut, palette, separator)
} },
CtrlKeyMode::Disabled => { CtrlKeyMode::Disabled => {
disabled_mode_shortcut(&format!(" {}", letter_shortcut), palette, separator) disabled_mode_shortcut(&format!(" {}", letter_shortcut), palette, separator)
} },
} }
} }

View File

@ -237,21 +237,21 @@ impl ZellijPlugin for State {
match event { match event {
Event::ModeUpdate(mode_info) => { Event::ModeUpdate(mode_info) => {
self.mode_info = mode_info; self.mode_info = mode_info;
} },
Event::TabUpdate(tabs) => { Event::TabUpdate(tabs) => {
self.tabs = tabs; self.tabs = tabs;
} },
Event::CopyToClipboard(copy_destination) => { Event::CopyToClipboard(copy_destination) => {
self.text_copy_destination = Some(copy_destination); self.text_copy_destination = Some(copy_destination);
} },
Event::SystemClipboardFailure => { Event::SystemClipboardFailure => {
self.display_system_clipboard_failure = true; self.display_system_clipboard_failure = true;
} },
Event::InputReceived => { Event::InputReceived => {
self.text_copy_destination = None; self.text_copy_destination = None;
self.display_system_clipboard_failure = false; self.display_system_clipboard_failure = false;
} },
_ => {} _ => {},
} }
} }
@ -284,10 +284,10 @@ impl ZellijPlugin for State {
match background { match background {
PaletteColor::Rgb((r, g, b)) => { PaletteColor::Rgb((r, g, b)) => {
println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", first_line, r, g, b); println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", first_line, r, g, b);
} },
PaletteColor::EightBit(color) => { PaletteColor::EightBit(color) => {
println!("{}\u{1b}[48;5;{}m\u{1b}[0K", first_line, color); println!("{}\u{1b}[48;5;{}m\u{1b}[0K", first_line, color);
} },
} }
println!("\u{1b}[m{}\u{1b}[0K", second_line); println!("\u{1b}[m{}\u{1b}[0K", second_line);
} }
@ -319,7 +319,7 @@ impl State {
InputMode::Normal => floating_panes_are_visible(&self.mode_info.style.colors), InputMode::Normal => floating_panes_are_visible(&self.mode_info.style.colors),
InputMode::Locked => { InputMode::Locked => {
locked_floating_panes_are_visible(&self.mode_info.style.colors) locked_floating_panes_are_visible(&self.mode_info.style.colors)
} },
_ => keybinds(&self.mode_info, &self.tip_name, cols), _ => keybinds(&self.mode_info, &self.tip_name, cols),
} }
} else { } else {

View File

@ -224,7 +224,7 @@ fn shortened_shortcut_list(help: &ModeInfo, tip: TipFn) -> LinePart {
InputMode::Tmux => short_tmux_mode_indication(help), InputMode::Tmux => short_tmux_mode_indication(help),
InputMode::RenamePane => { InputMode::RenamePane => {
shortened_shortcut_list_nonstandard_mode(select_pane_shortcut)(help) shortened_shortcut_list_nonstandard_mode(select_pane_shortcut)(help)
} },
_ => shortened_shortcut_list_nonstandard_mode(confirm_pane_selection)(help), _ => shortened_shortcut_list_nonstandard_mode(confirm_pane_selection)(help),
} }
} }
@ -279,7 +279,7 @@ fn best_effort_shortcut_list(help: &ModeInfo, tip: TipFn, max_len: usize) -> Lin
} else { } else {
LinePart::default() LinePart::default()
} }
} },
InputMode::Locked => { InputMode::Locked => {
let line_part = locked_interface_indication(help.style.colors); let line_part = locked_interface_indication(help.style.colors);
if line_part.len <= max_len { if line_part.len <= max_len {
@ -287,11 +287,11 @@ fn best_effort_shortcut_list(help: &ModeInfo, tip: TipFn, max_len: usize) -> Lin
} else { } else {
LinePart::default() LinePart::default()
} }
} },
InputMode::Tmux => best_effort_tmux_shortcut_list(help, max_len), InputMode::Tmux => best_effort_tmux_shortcut_list(help, max_len),
InputMode::RenamePane => { InputMode::RenamePane => {
best_effort_shortcut_list_nonstandard_mode(select_pane_shortcut)(help, max_len) best_effort_shortcut_list_nonstandard_mode(select_pane_shortcut)(help, max_len)
} },
_ => best_effort_shortcut_list_nonstandard_mode(confirm_pane_selection)(help, max_len), _ => best_effort_shortcut_list_nonstandard_mode(confirm_pane_selection)(help, max_len),
} }
} }

View File

@ -47,7 +47,7 @@ impl LocalCache {
}); });
} }
Err(LocalCacheError::Serde(err)) Err(LocalCacheError::Serde(err))
} },
} }
} }
@ -64,7 +64,7 @@ impl LocalCache {
let metadata = LocalCache::from_json(&json_cache)?; let metadata = LocalCache::from_json(&json_cache)?;
Ok(LocalCache { path, metadata }) Ok(LocalCache { path, metadata })
} },
Err(e) => Err(LocalCacheError::IoPath(e, path)), Err(e) => Err(LocalCacheError::IoPath(e, path)),
} }
} }
@ -77,7 +77,7 @@ impl LocalCache {
file.write_all(json_cache.as_bytes()) file.write_all(json_cache.as_bytes())
.map_err(LocalCacheError::Io)?; .map_err(LocalCacheError::Io)?;
Ok(()) Ok(())
} },
Err(e) => Err(LocalCacheError::Serde(e)), Err(e) => Err(LocalCacheError::Serde(e)),
} }
} }

View File

@ -24,15 +24,15 @@ impl ZellijPlugin for State {
Event::Key(key) => match key { Event::Key(key) => match key {
Key::Up | Key::Char('k') => { Key::Up | Key::Char('k') => {
*self.selected_mut() = self.selected().saturating_sub(1); *self.selected_mut() = self.selected().saturating_sub(1);
} },
Key::Down | Key::Char('j') => { Key::Down | Key::Char('j') => {
let next = self.selected().saturating_add(1); let next = self.selected().saturating_add(1);
*self.selected_mut() = min(self.files.len().saturating_sub(1), next); *self.selected_mut() = min(self.files.len().saturating_sub(1), next);
} },
Key::Right | Key::Char('\n') | Key::Char('l') if !self.files.is_empty() => { Key::Right | Key::Char('\n') | Key::Char('l') if !self.files.is_empty() => {
self.traverse_dir_or_open_file(); self.traverse_dir_or_open_file();
self.ev_history.clear(); self.ev_history.clear();
} },
Key::Left | Key::Char('h') => { Key::Left | Key::Char('h') => {
if self.path.components().count() > 2 { if self.path.components().count() > 2 {
// don't descend into /host // don't descend into /host
@ -42,11 +42,11 @@ impl ZellijPlugin for State {
self.path.pop(); self.path.pop();
refresh_directory(self); refresh_directory(self);
} }
} },
Key::Char('.') => { Key::Char('.') => {
self.toggle_hidden_files(); self.toggle_hidden_files();
refresh_directory(self); refresh_directory(self);
} },
_ => (), _ => (),
}, },
@ -54,10 +54,10 @@ impl ZellijPlugin for State {
Mouse::ScrollDown(_) => { Mouse::ScrollDown(_) => {
let next = self.selected().saturating_add(1); let next = self.selected().saturating_add(1);
*self.selected_mut() = min(self.files.len().saturating_sub(1), next); *self.selected_mut() = min(self.files.len().saturating_sub(1), next);
} },
Mouse::ScrollUp(_) => { Mouse::ScrollUp(_) => {
*self.selected_mut() = self.selected().saturating_sub(1); *self.selected_mut() = self.selected().saturating_sub(1);
} },
Mouse::Release(line, _) => { Mouse::Release(line, _) => {
if line < 0 { if line < 0 {
return; return;
@ -75,12 +75,12 @@ impl ZellijPlugin for State {
if should_select && self.scroll() + (line as usize) < self.files.len() { if should_select && self.scroll() + (line as usize) < self.files.len() {
*self.selected_mut() = self.scroll() + (line as usize); *self.selected_mut() = self.scroll() + (line as usize);
} }
} },
_ => {} _ => {},
}, },
_ => { _ => {
dbg!("Unknown event {:?}", event); dbg!("Unknown event {:?}", event);
} },
} }
} }

View File

@ -39,7 +39,7 @@ impl State {
FsEntry::Dir(p, _) => { FsEntry::Dir(p, _) => {
self.path = p; self.path = p;
refresh_directory(self); refresh_directory(self);
} },
FsEntry::File(p, _) => open_file(p.strip_prefix(ROOT).unwrap()), FsEntry::File(p, _) => open_file(p.strip_prefix(ROOT).unwrap()),
} }
} }

View File

@ -49,23 +49,23 @@ impl ZellijPlugin for State {
} else { } else {
eprintln!("Could not find active tab."); eprintln!("Could not find active tab.");
} }
} },
Event::Mouse(me) => match me { Event::Mouse(me) => match me {
Mouse::LeftClick(_, col) => { Mouse::LeftClick(_, col) => {
self.mouse_click_pos = col; self.mouse_click_pos = col;
self.should_render = true; self.should_render = true;
} },
Mouse::ScrollUp(_) => { Mouse::ScrollUp(_) => {
switch_tab_to(min(self.active_tab_idx + 1, self.tabs.len()) as u32); switch_tab_to(min(self.active_tab_idx + 1, self.tabs.len()) as u32);
} },
Mouse::ScrollDown(_) => { Mouse::ScrollDown(_) => {
switch_tab_to(max(self.active_tab_idx.saturating_sub(1), 1) as u32); switch_tab_to(max(self.active_tab_idx.saturating_sub(1), 1) as u32);
} },
_ => {} _ => {},
}, },
_ => { _ => {
eprintln!("Got unrecognized event: {:?}", event); eprintln!("Got unrecognized event: {:?}", event);
} },
} }
} }
@ -129,10 +129,10 @@ impl ZellijPlugin for State {
match background { match background {
PaletteColor::Rgb((r, g, b)) => { PaletteColor::Rgb((r, g, b)) => {
println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b); println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b);
} },
PaletteColor::EightBit(color) => { PaletteColor::EightBit(color) => {
println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color); println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color);
} },
} }
self.should_render = false; self.should_render = false;
} }

View File

@ -27,7 +27,7 @@ pub(crate) fn kill_all_sessions(yes: bool) {
Ok(sessions) if sessions.is_empty() => { Ok(sessions) if sessions.is_empty() => {
eprintln!("No active zellij sessions found."); eprintln!("No active zellij sessions found.");
process::exit(1); process::exit(1);
} },
Ok(sessions) => { Ok(sessions) => {
if !yes { if !yes {
println!("WARNING: this action will kill all sessions."); println!("WARNING: this action will kill all sessions.");
@ -44,11 +44,11 @@ pub(crate) fn kill_all_sessions(yes: bool) {
kill_session_impl(session); kill_session_impl(session);
} }
process::exit(0); process::exit(0);
} },
Err(e) => { Err(e) => {
eprintln!("Error occurred: {:?}", e); eprintln!("Error occurred: {:?}", e);
process::exit(1); process::exit(1);
} },
} }
} }
@ -58,11 +58,11 @@ pub(crate) fn kill_session(target_session: &Option<String>) {
assert_session(target_session); assert_session(target_session);
kill_session_impl(target_session); kill_session_impl(target_session);
process::exit(0); process::exit(0);
} },
None => { None => {
println!("Please specify the session name to kill."); println!("Please specify the session name to kill.");
process::exit(1); process::exit(1);
} },
} }
} }
@ -74,7 +74,7 @@ fn get_os_input<OsInputOutput>(
Err(e) => { Err(e) => {
eprintln!("failed to open terminal:\n{}", e); eprintln!("failed to open terminal:\n{}", e);
process::exit(1); process::exit(1);
} },
} }
} }
@ -108,7 +108,7 @@ fn find_indexed_session(
); );
print_sessions_with_index(sessions); print_sessions_with_index(sessions);
process::exit(1); process::exit(1);
} },
} }
} }
@ -122,12 +122,12 @@ fn attach_with_session_index(config_options: Options, index: usize, create: bool
eprintln!("No active zellij sessions found."); eprintln!("No active zellij sessions found.");
process::exit(1); process::exit(1);
} }
} },
Ok(sessions) => find_indexed_session(sessions, config_options, index, create), Ok(sessions) => find_indexed_session(sessions, config_options, index, create),
Err(e) => { Err(e) => {
eprintln!("Error occurred: {:?}", e); eprintln!("Error occurred: {:?}", e);
process::exit(1); process::exit(1);
} },
} }
} }
@ -143,11 +143,11 @@ fn attach_with_session_name(
} else { } else {
ClientInfo::Attach(session_name.unwrap(), config_options) ClientInfo::Attach(session_name.unwrap(), config_options)
} }
} },
Some(prefix) => match match_session_name(prefix).unwrap() { Some(prefix) => match match_session_name(prefix).unwrap() {
SessionNameMatch::UniquePrefix(s) | SessionNameMatch::Exact(s) => { SessionNameMatch::UniquePrefix(s) | SessionNameMatch::Exact(s) => {
ClientInfo::Attach(s, config_options) ClientInfo::Attach(s, config_options)
} },
SessionNameMatch::AmbiguousPrefix(sessions) => { SessionNameMatch::AmbiguousPrefix(sessions) => {
println!( println!(
"Ambiguous selection: multiple sessions names start with '{}':", "Ambiguous selection: multiple sessions names start with '{}':",
@ -155,24 +155,24 @@ fn attach_with_session_name(
); );
print_sessions(sessions); print_sessions(sessions);
process::exit(1); process::exit(1);
} },
SessionNameMatch::None => { SessionNameMatch::None => {
eprintln!("No session with the name '{}' found!", prefix); eprintln!("No session with the name '{}' found!", prefix);
process::exit(1); process::exit(1);
} },
}, },
None => match get_active_session() { None => match get_active_session() {
ActiveSession::None if create => create_new_client(), ActiveSession::None if create => create_new_client(),
ActiveSession::None => { ActiveSession::None => {
eprintln!("No active zellij sessions found."); eprintln!("No active zellij sessions found.");
process::exit(1); process::exit(1);
} },
ActiveSession::One(session_name) => ClientInfo::Attach(session_name, config_options), ActiveSession::One(session_name) => ClientInfo::Attach(session_name, config_options),
ActiveSession::Many => { ActiveSession::Many => {
println!("Please specify the session to attach to, either by using the full name or a unique prefix.\nThe following sessions are active:"); println!("Please specify the session to attach to, either by using the full name or a unique prefix.\nThe following sessions are active:");
print_sessions(get_sessions().unwrap()); print_sessions(get_sessions().unwrap());
process::exit(1); process::exit(1);
} },
}, },
} }
} }
@ -183,7 +183,7 @@ pub(crate) fn start_client(opts: CliArgs) {
Err(e) => { Err(e) => {
eprintln!("{}", e); eprintln!("{}", e);
process::exit(1); process::exit(1);
} },
}; };
let os_input = get_os_input(get_client_os_input); let os_input = get_os_input(get_client_os_input);

View File

@ -21,7 +21,7 @@ pub(crate) fn get_sessions() -> Result<Vec<String>, io::ErrorKind> {
} }
}); });
Ok(sessions) Ok(sessions)
} },
Err(err) if io::ErrorKind::NotFound != err.kind() => Err(err.kind()), Err(err) if io::ErrorKind::NotFound != err.kind() => Err(err.kind()),
Err(_) => Ok(Vec::with_capacity(0)), Err(_) => Ok(Vec::with_capacity(0)),
} }
@ -43,7 +43,7 @@ pub(crate) fn get_sessions_sorted_by_mtime() -> anyhow::Result<Vec<String>> {
let sessions = sessions_with_mtime.iter().map(|x| x.0.clone()).collect(); let sessions = sessions_with_mtime.iter().map(|x| x.0.clone()).collect();
Ok(sessions) Ok(sessions)
} },
Err(err) if io::ErrorKind::NotFound != err.kind() => Err(err.into()), Err(err) if io::ErrorKind::NotFound != err.kind() => Err(err.into()),
Err(_) => Ok(Vec::with_capacity(0)), Err(_) => Ok(Vec::with_capacity(0)),
} }
@ -59,14 +59,14 @@ fn assert_socket(name: &str) -> bool {
match receiver.recv() { match receiver.recv() {
Some((instruction, _)) => { Some((instruction, _)) => {
matches!(instruction, ServerToClientMsg::Connected) matches!(instruction, ServerToClientMsg::Connected)
} },
None => false, None => false,
} }
} },
Err(e) if e.kind() == io::ErrorKind::ConnectionRefused => { Err(e) if e.kind() == io::ErrorKind::ConnectionRefused => {
drop(fs::remove_file(path)); drop(fs::remove_file(path));
false false
} },
Err(_) => false, Err(_) => false,
} }
} }
@ -109,7 +109,7 @@ pub(crate) fn get_active_session() -> ActiveSession {
Err(e) => { Err(e) => {
eprintln!("Error occurred: {:?}", e); eprintln!("Error occurred: {:?}", e);
process::exit(1); process::exit(1);
} },
} }
} }
@ -118,11 +118,11 @@ pub(crate) fn kill_session(name: &str) {
match LocalSocketStream::connect(path) { match LocalSocketStream::connect(path) {
Ok(stream) => { Ok(stream) => {
IpcSenderWithContext::new(stream).send(ClientToServerMsg::KillSession); IpcSenderWithContext::new(stream).send(ClientToServerMsg::KillSession);
} },
Err(e) => { Err(e) => {
eprintln!("Error occurred: {:?}", e); eprintln!("Error occurred: {:?}", e);
process::exit(1); process::exit(1);
} },
}; };
} }
@ -131,15 +131,15 @@ pub(crate) fn list_sessions() {
Ok(sessions) if !sessions.is_empty() => { Ok(sessions) if !sessions.is_empty() => {
print_sessions(sessions); print_sessions(sessions);
0 0
} },
Ok(_) => { Ok(_) => {
eprintln!("No active zellij sessions found."); eprintln!("No active zellij sessions found.");
1 1
} },
Err(e) => { Err(e) => {
eprintln!("Error occurred: {:?}", e); eprintln!("Error occurred: {:?}", e);
1 1
} },
}; };
process::exit(exit_code); process::exit(exit_code);
} }
@ -192,10 +192,10 @@ pub(crate) fn assert_session(name: &str) {
println!(" help: Did you mean `{}`?", sugg); println!(" help: Did you mean `{}`?", sugg);
} }
} }
} },
Err(e) => { Err(e) => {
eprintln!("Error occurred: {:?}", e); eprintln!("Error occurred: {:?}", e);
} },
}; };
process::exit(1); process::exit(1);
} }

View File

@ -201,7 +201,7 @@ fn read_from_channel(
terminal_output.cursor_coordinates().unwrap_or((0, 0)); terminal_output.cursor_coordinates().unwrap_or((0, 0));
*last_snapshot = current_snapshot; *last_snapshot = current_snapshot;
should_sleep = true; should_sleep = true;
} },
Ok(count) => { Ok(count) => {
for byte in buf.iter().take(count) { for byte in buf.iter().take(count) {
vte_parser.advance(&mut terminal_output.grid, *byte); vte_parser.advance(&mut terminal_output.grid, *byte);
@ -212,7 +212,7 @@ fn read_from_channel(
terminal_output.grid.cursor_coordinates().unwrap_or((0, 0)); terminal_output.grid.cursor_coordinates().unwrap_or((0, 0));
*last_snapshot = current_snapshot; *last_snapshot = current_snapshot;
should_sleep = true; should_sleep = true;
} },
Err(e) => { Err(e) => {
if e.kind() == std::io::ErrorKind::WouldBlock { if e.kind() == std::io::ErrorKind::WouldBlock {
let current_snapshot = take_snapshot(&mut terminal_output); let current_snapshot = take_snapshot(&mut terminal_output);
@ -226,7 +226,7 @@ fn read_from_channel(
} else { } else {
break; break;
} }
} },
} }
} }
} }

View File

@ -100,12 +100,12 @@ impl InputHandler {
} else { } else {
self.handle_key(&key, raw_bytes); self.handle_key(&key, raw_bytes);
} }
} },
InputEvent::Mouse(mouse_event) => { InputEvent::Mouse(mouse_event) => {
let mouse_event = let mouse_event =
zellij_utils::input::mouse::MouseEvent::from(mouse_event); zellij_utils::input::mouse::MouseEvent::from(mouse_event);
self.handle_mouse_event(&mouse_event); self.handle_mouse_event(&mouse_event);
} },
InputEvent::Paste(pasted_text) => { InputEvent::Paste(pasted_text) => {
if self.mode == InputMode::Normal || self.mode == InputMode::Locked { if self.mode == InputMode::Normal || self.mode == InputMode::Locked {
self.dispatch_action(Action::Write(bracketed_paste_start.clone())); self.dispatch_action(Action::Write(bracketed_paste_start.clone()));
@ -114,13 +114,13 @@ impl InputHandler {
)); ));
self.dispatch_action(Action::Write(bracketed_paste_end.clone())); self.dispatch_action(Action::Write(bracketed_paste_end.clone()));
} }
},
_ => {},
} }
_ => {} },
}
}
Ok((InputInstruction::SwitchToMode(input_mode), _error_context)) => { Ok((InputInstruction::SwitchToMode(input_mode), _error_context)) => {
self.mode = input_mode; self.mode = input_mode;
} },
Ok((InputInstruction::PossiblePixelRatioChange, _error_context)) => { Ok((InputInstruction::PossiblePixelRatioChange, _error_context)) => {
let _ = self let _ = self
.os_input .os_input
@ -128,7 +128,7 @@ impl InputHandler {
.write(get_cell_pixel_info.as_bytes()) .write(get_cell_pixel_info.as_bytes())
.unwrap(); .unwrap();
ansi_stdin_parser.increment_expected_ansi_instructions(4); ansi_stdin_parser.increment_expected_ansi_instructions(4);
} },
Err(err) => panic!("Encountered read error: {:?}", err), Err(err) => panic!("Encountered read error: {:?}", err),
} }
} }
@ -150,25 +150,25 @@ impl InputHandler {
Some(AnsiStdinInstructionOrKeys::PixelDimensions(pixel_dimensions)) => { Some(AnsiStdinInstructionOrKeys::PixelDimensions(pixel_dimensions)) => {
self.os_input self.os_input
.send_to_server(ClientToServerMsg::TerminalPixelDimensions(pixel_dimensions)); .send_to_server(ClientToServerMsg::TerminalPixelDimensions(pixel_dimensions));
} },
Some(AnsiStdinInstructionOrKeys::BackgroundColor(background_color_instruction)) => { Some(AnsiStdinInstructionOrKeys::BackgroundColor(background_color_instruction)) => {
self.os_input self.os_input
.send_to_server(ClientToServerMsg::BackgroundColor( .send_to_server(ClientToServerMsg::BackgroundColor(
background_color_instruction, background_color_instruction,
)); ));
} },
Some(AnsiStdinInstructionOrKeys::ForegroundColor(foreground_color_instruction)) => { Some(AnsiStdinInstructionOrKeys::ForegroundColor(foreground_color_instruction)) => {
self.os_input self.os_input
.send_to_server(ClientToServerMsg::ForegroundColor( .send_to_server(ClientToServerMsg::ForegroundColor(
foreground_color_instruction, foreground_color_instruction,
)); ));
} },
Some(AnsiStdinInstructionOrKeys::Keys(keys)) => { Some(AnsiStdinInstructionOrKeys::Keys(keys)) => {
for (key, raw_bytes) in keys { for (key, raw_bytes) in keys {
self.handle_key(&key, raw_bytes); self.handle_key(&key, raw_bytes);
} }
} },
None => {} None => {},
} }
} }
fn handle_mouse_event(&mut self, mouse_event: &MouseEvent) { fn handle_mouse_event(&mut self, mouse_event: &MouseEvent) {
@ -176,10 +176,10 @@ impl InputHandler {
MouseEvent::Press(button, point) => match button { MouseEvent::Press(button, point) => match button {
MouseButton::WheelUp => { MouseButton::WheelUp => {
self.dispatch_action(Action::ScrollUpAt(point)); self.dispatch_action(Action::ScrollUpAt(point));
} },
MouseButton::WheelDown => { MouseButton::WheelDown => {
self.dispatch_action(Action::ScrollDownAt(point)); self.dispatch_action(Action::ScrollDownAt(point));
} },
MouseButton::Left => { MouseButton::Left => {
if self.holding_mouse { if self.holding_mouse {
self.dispatch_action(Action::MouseHold(point)); self.dispatch_action(Action::MouseHold(point));
@ -187,7 +187,7 @@ impl InputHandler {
self.dispatch_action(Action::LeftClick(point)); self.dispatch_action(Action::LeftClick(point));
} }
self.holding_mouse = true; self.holding_mouse = true;
} },
MouseButton::Right => { MouseButton::Right => {
if self.holding_mouse { if self.holding_mouse {
self.dispatch_action(Action::MouseHold(point)); self.dispatch_action(Action::MouseHold(point));
@ -195,17 +195,17 @@ impl InputHandler {
self.dispatch_action(Action::RightClick(point)); self.dispatch_action(Action::RightClick(point));
} }
self.holding_mouse = true; self.holding_mouse = true;
} },
_ => {} _ => {},
}, },
MouseEvent::Release(point) => { MouseEvent::Release(point) => {
self.dispatch_action(Action::MouseRelease(point)); self.dispatch_action(Action::MouseRelease(point));
self.holding_mouse = false; self.holding_mouse = false;
} },
MouseEvent::Hold(point) => { MouseEvent::Hold(point) => {
self.dispatch_action(Action::MouseHold(point)); self.dispatch_action(Action::MouseHold(point));
self.holding_mouse = true; self.holding_mouse = true;
} },
} }
} }
@ -224,20 +224,20 @@ impl InputHandler {
let mut should_break = false; let mut should_break = false;
match action { match action {
Action::NoOp => {} 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));
self.exit(); self.exit();
should_break = true; should_break = true;
} },
Action::SwitchToMode(mode) => { Action::SwitchToMode(mode) => {
// this is an optimistic update, we should get a SwitchMode instruction from the // this is an optimistic update, we should get a SwitchMode instruction from the
// server later that atomically changes the mode as well // server later that atomically changes the mode as well
self.mode = mode; self.mode = mode;
self.os_input self.os_input
.send_to_server(ClientToServerMsg::Action(action)); .send_to_server(ClientToServerMsg::Action(action));
} },
Action::CloseFocus Action::CloseFocus
| Action::NewPane(_) | Action::NewPane(_)
| Action::ToggleFloatingPanes | Action::ToggleFloatingPanes
@ -254,7 +254,7 @@ impl InputHandler {
.send_to_server(ClientToServerMsg::Action(action)); .send_to_server(ClientToServerMsg::Action(action));
self.command_is_executing self.command_is_executing
.wait_until_input_thread_is_unblocked(); .wait_until_input_thread_is_unblocked();
} },
_ => self _ => self
.os_input .os_input
.send_to_server(ClientToServerMsg::Action(action)), .send_to_server(ClientToServerMsg::Action(action)),

View File

@ -49,7 +49,7 @@ impl From<ServerToClientMsg> for ClientInstruction {
ServerToClientMsg::UnblockInputThread => ClientInstruction::UnblockInputThread, ServerToClientMsg::UnblockInputThread => ClientInstruction::UnblockInputThread,
ServerToClientMsg::SwitchToMode(input_mode) => { ServerToClientMsg::SwitchToMode(input_mode) => {
ClientInstruction::SwitchToMode(input_mode) ClientInstruction::SwitchToMode(input_mode)
} },
ServerToClientMsg::Connected => ClientInstruction::Connected, ServerToClientMsg::Connected => ClientInstruction::Connected,
} }
} }
@ -160,7 +160,7 @@ pub fn start_client(
envs::set_session_name(name); envs::set_session_name(name);
ClientToServerMsg::AttachClient(client_attributes, config_options) ClientToServerMsg::AttachClient(client_attributes, config_options)
} },
ClientInfo::New(name) => { ClientInfo::New(name) => {
envs::set_session_name(name); envs::set_session_name(name);
@ -173,7 +173,7 @@ pub fn start_client(
Box::new(layout.unwrap()), Box::new(layout.unwrap()),
Some(config.plugins.clone()), Some(config.plugins.clone()),
) )
} },
}; };
os_input.connect_to_server(&*ZELLIJ_IPC_PIPE); os_input.connect_to_server(&*ZELLIJ_IPC_PIPE);
@ -283,13 +283,13 @@ pub fn start_client(
if should_break { if should_break {
break; break;
} }
} },
None => { None => {
send_client_instructions send_client_instructions
.send(ClientInstruction::UnblockInputThread) .send(ClientInstruction::UnblockInputThread)
.unwrap(); .unwrap();
log::error!("Received empty message from server"); log::error!("Received empty message from server");
} },
} }
} }
}) })
@ -329,27 +329,27 @@ pub fn start_client(
} }
exit_msg = reason.to_string(); exit_msg = reason.to_string();
break; break;
} },
ClientInstruction::Error(backtrace) => { ClientInstruction::Error(backtrace) => {
let _ = os_input.send_to_server(ClientToServerMsg::Action(Action::Quit)); let _ = os_input.send_to_server(ClientToServerMsg::Action(Action::Quit));
handle_error(backtrace); handle_error(backtrace);
} },
ClientInstruction::Render(output) => { ClientInstruction::Render(output) => {
let mut stdout = os_input.get_stdout_writer(); let mut stdout = os_input.get_stdout_writer();
stdout stdout
.write_all(output.as_bytes()) .write_all(output.as_bytes())
.expect("cannot write to stdout"); .expect("cannot write to stdout");
stdout.flush().expect("could not flush"); stdout.flush().expect("could not flush");
} },
ClientInstruction::UnblockInputThread => { ClientInstruction::UnblockInputThread => {
command_is_executing.unblock_input_thread(); command_is_executing.unblock_input_thread();
} },
ClientInstruction::SwitchToMode(input_mode) => { ClientInstruction::SwitchToMode(input_mode) => {
send_input_instructions send_input_instructions
.send(InputInstruction::SwitchToMode(input_mode)) .send(InputInstruction::SwitchToMode(input_mode))
.unwrap(); .unwrap();
} },
_ => {} _ => {},
} }
} }

View File

@ -27,7 +27,7 @@ fn into_raw_mode(pid: RawFd) {
let mut tio = termios::tcgetattr(pid).expect("could not get terminal attribute"); let mut tio = termios::tcgetattr(pid).expect("could not get terminal attribute");
termios::cfmakeraw(&mut tio); termios::cfmakeraw(&mut tio);
match termios::tcsetattr(pid, termios::SetArg::TCSANOW, &tio) { match termios::tcsetattr(pid, termios::SetArg::TCSANOW, &tio) {
Ok(_) => {} Ok(_) => {},
Err(e) => panic!("error {:?}", e), Err(e) => panic!("error {:?}", e),
}; };
} }
@ -161,11 +161,11 @@ impl ClientOsApi for ClientOsInputOutput {
} }
sigwinch_cb_timestamp = time::Instant::now(); sigwinch_cb_timestamp = time::Instant::now();
sigwinch_cb(); sigwinch_cb();
} },
SIGTERM | SIGINT | SIGQUIT | SIGHUP => { SIGTERM | SIGINT | SIGQUIT | SIGHUP => {
quit_cb(); quit_cb();
break; break;
} },
_ => unreachable!(), _ => unreachable!(),
} }
} }
@ -177,10 +177,10 @@ impl ClientOsApi for ClientOsInputOutput {
Ok(sock) => { Ok(sock) => {
socket = sock; socket = sock;
break; break;
} },
Err(_) => { Err(_) => {
std::thread::sleep(std::time::Duration::from_millis(50)); std::thread::sleep(std::time::Duration::from_millis(50));
} },
} }
} }
let sender = IpcSenderWithContext::new(socket); let sender = IpcSenderWithContext::new(socket);

View File

@ -43,13 +43,13 @@ impl StdinAnsiParser {
self.decrement_expected_ansi_instructions(1); self.decrement_expected_ansi_instructions(1);
self.current_buffer.clear(); self.current_buffer.clear();
Some(pixel_instruction) Some(pixel_instruction)
} },
Err(_) => { Err(_) => {
self.expected_ansi_instructions = 0; self.expected_ansi_instructions = 0;
Some(AnsiStdinInstructionOrKeys::Keys( Some(AnsiStdinInstructionOrKeys::Keys(
self.current_buffer.drain(..).collect(), self.current_buffer.drain(..).collect(),
)) ))
} },
} }
} else if let Key::Alt(CharOrArrow::Char('\\')) | Key::Ctrl('g') = key { } else if let Key::Alt(CharOrArrow::Char('\\')) | Key::Ctrl('g') = key {
match AnsiStdinInstructionOrKeys::color_sequence_from_keys(&self.current_buffer) { match AnsiStdinInstructionOrKeys::color_sequence_from_keys(&self.current_buffer) {
@ -57,13 +57,13 @@ impl StdinAnsiParser {
self.decrement_expected_ansi_instructions(1); self.decrement_expected_ansi_instructions(1);
self.current_buffer.clear(); self.current_buffer.clear();
Some(color_instruction) Some(color_instruction)
} },
Err(_) => { Err(_) => {
self.expected_ansi_instructions = 0; self.expected_ansi_instructions = 0;
Some(AnsiStdinInstructionOrKeys::Keys( Some(AnsiStdinInstructionOrKeys::Keys(
self.current_buffer.drain(..).collect(), self.current_buffer.drain(..).collect(),
)) ))
} },
} }
} else if self.key_is_valid(key) { } else if self.key_is_valid(key) {
self.current_buffer.push((key, raw_bytes)); self.current_buffer.push((key, raw_bytes));
@ -84,7 +84,7 @@ impl StdinAnsiParser {
// if they spam ESC they need to be able to get back to normal mode and not "us // if they spam ESC they need to be able to get back to normal mode and not "us
// waiting for ansi instructions" mode // waiting for ansi instructions" mode
!self.current_buffer.iter().any(|(key, _)| *key == Key::Esc) !self.current_buffer.iter().any(|(key, _)| *key == Key::Esc)
} },
Key::Char(';') Key::Char(';')
| Key::Char('[') | Key::Char('[')
| Key::Char(']') | Key::Char(']')
@ -102,7 +102,7 @@ impl StdinAnsiParser {
} else { } else {
false false
} }
} },
_ => false, _ => false,
} }
} }
@ -153,7 +153,7 @@ impl AnsiStdinInstructionOrKeys {
}), }),
}, },
)) ))
} },
Ok(6) => { Ok(6) => {
// character cell size // character cell size
Ok(AnsiStdinInstructionOrKeys::PixelDimensions( Ok(AnsiStdinInstructionOrKeys::PixelDimensions(
@ -165,7 +165,7 @@ impl AnsiStdinInstructionOrKeys {
text_area_size: None, text_area_size: None,
}, },
)) ))
} },
_ => Err("invalid sequence"), _ => Err("invalid sequence"),
} }
} else { } else {
@ -182,7 +182,7 @@ impl AnsiStdinInstructionOrKeys {
let key_string = keys.iter().fold(String::new(), |mut acc, (key, _)| { let key_string = keys.iter().fold(String::new(), |mut acc, (key, _)| {
match key { match key {
Key::Char(c) => acc.push(*c), Key::Char(c) => acc.push(*c),
_ => {} _ => {},
}; };
acc acc
}); });

View File

@ -260,10 +260,10 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
}) })
.unwrap(), .unwrap(),
); );
} },
Err(err) => { Err(err) => {
panic!("err {:?}", err); panic!("err {:?}", err);
} },
} }
} }
} }
@ -351,7 +351,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.senders .senders
.send_to_plugin(PluginInstruction::AddClient(client_id)) .send_to_plugin(PluginInstruction::AddClient(client_id))
.unwrap(); .unwrap();
} },
ServerInstruction::AttachClient(attrs, options, client_id) => { ServerInstruction::AttachClient(attrs, options, client_id) => {
let rlock = session_data.read().unwrap(); let rlock = session_data.read().unwrap();
let session_data = rlock.as_ref().unwrap(); let session_data = rlock.as_ref().unwrap();
@ -392,12 +392,12 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
)) ))
.unwrap(); .unwrap();
os_input.send_to_client(client_id, ServerToClientMsg::SwitchToMode(mode)); os_input.send_to_client(client_id, ServerToClientMsg::SwitchToMode(mode));
} },
ServerInstruction::UnblockInputThread => { ServerInstruction::UnblockInputThread => {
for client_id in session_state.read().unwrap().clients.keys() { for client_id in session_state.read().unwrap().clients.keys() {
os_input.send_to_client(*client_id, ServerToClientMsg::UnblockInputThread); os_input.send_to_client(*client_id, ServerToClientMsg::UnblockInputThread);
} }
} },
ServerInstruction::ClientExit(client_id) => { ServerInstruction::ClientExit(client_id) => {
os_input.send_to_client(client_id, ServerToClientMsg::Exit(ExitReason::Normal)); os_input.send_to_client(client_id, ServerToClientMsg::Exit(ExitReason::Normal));
remove_client!(client_id, os_input, session_state); remove_client!(client_id, os_input, session_state);
@ -431,7 +431,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
*session_data.write().unwrap() = None; *session_data.write().unwrap() = None;
break; break;
} }
} },
ServerInstruction::RemoveClient(client_id) => { ServerInstruction::RemoveClient(client_id) => {
remove_client!(client_id, os_input, session_state); remove_client!(client_id, os_input, session_state);
if let Some(min_size) = session_state.read().unwrap().min_client_terminal_size() { if let Some(min_size) = session_state.read().unwrap().min_client_terminal_size() {
@ -460,7 +460,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.senders .senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id)) .send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap(); .unwrap();
} },
ServerInstruction::KillSession => { ServerInstruction::KillSession => {
let client_ids = session_state.read().unwrap().client_ids(); let client_ids = session_state.read().unwrap().client_ids();
for client_id in client_ids { for client_id in client_ids {
@ -468,7 +468,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
remove_client!(client_id, os_input, session_state); remove_client!(client_id, os_input, session_state);
} }
break; break;
} },
ServerInstruction::DetachSession(client_id) => { ServerInstruction::DetachSession(client_id) => {
os_input.send_to_client(client_id, ServerToClientMsg::Exit(ExitReason::Normal)); os_input.send_to_client(client_id, ServerToClientMsg::Exit(ExitReason::Normal));
remove_client!(client_id, os_input, session_state); remove_client!(client_id, os_input, session_state);
@ -498,7 +498,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.senders .senders
.send_to_plugin(PluginInstruction::RemoveClient(client_id)) .send_to_plugin(PluginInstruction::RemoveClient(client_id))
.unwrap(); .unwrap();
} },
ServerInstruction::Render(serialized_output) => { ServerInstruction::Render(serialized_output) => {
let client_ids = session_state.read().unwrap().client_ids(); let client_ids = session_state.read().unwrap().client_ids();
// If `Some(_)`- unwrap it and forward it to the clients to render. // If `Some(_)`- unwrap it and forward it to the clients to render.
@ -518,7 +518,7 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
} }
break; break;
} }
} },
ServerInstruction::Error(backtrace) => { ServerInstruction::Error(backtrace) => {
let client_ids = session_state.read().unwrap().client_ids(); let client_ids = session_state.read().unwrap().client_ids();
for client_id in client_ids { for client_id in client_ids {
@ -529,11 +529,11 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
remove_client!(client_id, os_input, session_state); remove_client!(client_id, os_input, session_state);
} }
break; break;
} },
ServerInstruction::ConnStatus(client_id) => { ServerInstruction::ConnStatus(client_id) => {
os_input.send_to_client(client_id, ServerToClientMsg::Connected); os_input.send_to_client(client_id, ServerToClientMsg::Connected);
remove_client!(client_id, os_input, session_state); remove_client!(client_id, os_input, session_state);
} },
} }
} }

View File

@ -73,10 +73,10 @@ fn handle_command_exit(mut child: Child) {
// and exit this function // and exit this function
// TODO: handle errors? // TODO: handle errors?
break 'handle_exit; break 'handle_exit;
} },
Ok(None) => { Ok(None) => {
::std::thread::sleep(::std::time::Duration::from_millis(10)); ::std::thread::sleep(::std::time::Duration::from_millis(10));
} },
Err(e) => panic!("error attempting to wait: {}", e), Err(e) => panic!("error attempting to wait: {}", e),
} }
@ -157,7 +157,7 @@ fn handle_terminal(
Some(failover_cmd) => handle_terminal(failover_cmd, None, orig_termios, quit_cb), Some(failover_cmd) => handle_terminal(failover_cmd, None, orig_termios, quit_cb),
None => { None => {
panic!("failed to start pty{:?}", e); panic!("failed to start pty{:?}", e);
} },
}, },
} }
} }
@ -217,7 +217,7 @@ pub fn spawn_terminal(
args, args,
cwd: None, cwd: None,
} }
} },
TerminalAction::RunCommand(command) => command, TerminalAction::RunCommand(command) => command,
}; };
let failover_cmd = if let Some(failover_cmd_args) = failover_cmd_args { let failover_cmd = if let Some(failover_cmd_args) = failover_cmd_args {

View File

@ -311,10 +311,10 @@ impl FloatingPanesStack {
} }
} }
visible_chunks.push(c_chunk); visible_chunks.push(c_chunk);
} },
None => { None => {
break 'chunk_loop; break 'chunk_loop;
} },
} }
} }
visible_chunks visible_chunks
@ -565,7 +565,7 @@ impl OutputBuffer {
Some(row) => self.extract_characters_from_row(row, viewport_width), Some(row) => self.extract_characters_from_row(row, viewport_width),
None => { None => {
vec![EMPTY_TERMINAL_CHARACTER; viewport_width] vec![EMPTY_TERMINAL_CHARACTER; viewport_width]
} },
} }
} }
} }

View File

@ -486,7 +486,7 @@ impl FloatingPanes {
self.set_force_render(); self.set_force_render();
return true; return true;
} },
None => Some(active_pane_id), None => Some(active_pane_id),
} }
} else { } else {
@ -500,12 +500,12 @@ impl FloatingPanes {
} }
self.set_pane_active_at(updated_active_pane); self.set_pane_active_at(updated_active_pane);
self.set_force_render(); self.set_force_render();
} },
None => { None => {
// TODO: can this happen? // TODO: can this happen?
self.active_panes.clear(); self.active_panes.clear();
self.z_indices.clear(); self.z_indices.clear();
} },
} }
false false
} }
@ -557,7 +557,7 @@ impl FloatingPanes {
self.set_pane_active_at(p); self.set_pane_active_at(p);
self.set_force_render(); self.set_force_render();
return true; return true;
} },
None => Some(active_pane_id), None => Some(active_pane_id),
} }
} else { } else {
@ -571,12 +571,12 @@ impl FloatingPanes {
} }
self.set_pane_active_at(updated_active_pane); self.set_pane_active_at(updated_active_pane);
self.set_force_render(); self.set_force_render();
} },
None => { None => {
// TODO: can this happen? // TODO: can this happen?
self.active_panes.clear(); self.active_panes.clear();
self.z_indices.clear(); self.z_indices.clear();
} },
} }
false false
} }
@ -627,7 +627,7 @@ impl FloatingPanes {
self.set_force_render(); self.set_force_render();
self.set_pane_active_at(p); self.set_pane_active_at(p);
return true; return true;
} },
None => Some(active_pane_id), None => Some(active_pane_id),
} }
} else { } else {
@ -641,12 +641,12 @@ impl FloatingPanes {
} }
self.set_pane_active_at(updated_active_pane); self.set_pane_active_at(updated_active_pane);
self.set_force_render(); self.set_force_render();
} },
None => { None => {
// TODO: can this happen? // TODO: can this happen?
self.active_panes.clear(); self.active_panes.clear();
self.z_indices.clear(); self.z_indices.clear();
} },
} }
false false
} }
@ -697,7 +697,7 @@ impl FloatingPanes {
self.set_force_render(); self.set_force_render();
return true; return true;
} },
None => Some(active_pane_id), None => Some(active_pane_id),
} }
} else { } else {
@ -711,12 +711,12 @@ impl FloatingPanes {
} }
self.set_pane_active_at(updated_active_pane); self.set_pane_active_at(updated_active_pane);
self.set_force_render(); self.set_force_render();
} },
None => { None => {
// TODO: can this happen? // TODO: can this happen?
self.active_panes.clear(); self.active_panes.clear();
self.z_indices.clear(); self.z_indices.clear();
} },
} }
false false
} }
@ -789,10 +789,10 @@ impl FloatingPanes {
Some(next_active_pane) => { Some(next_active_pane) => {
self.active_panes.insert(client_id, next_active_pane); self.active_panes.insert(client_id, next_active_pane);
self.focus_pane(next_active_pane, client_id); self.focus_pane(next_active_pane, client_id);
} },
None => { None => {
self.defocus_pane(pane_id, client_id); self.defocus_pane(pane_id, client_id);
} },
} }
} }
} }

View File

@ -45,7 +45,7 @@ fn get_top_non_canonical_rows(rows: &mut Vec<Row>) -> Vec<Row> {
match index_of_last_non_canonical_row { match index_of_last_non_canonical_row {
Some(index_of_last_non_canonical_row) => { Some(index_of_last_non_canonical_row) => {
rows.drain(..=index_of_last_non_canonical_row).collect() rows.drain(..=index_of_last_non_canonical_row).collect()
} },
None => vec![], None => vec![],
} }
} }
@ -61,7 +61,7 @@ fn get_lines_above_bottom_canonical_row_and_wraps(rows: &mut VecDeque<Row>) -> V
match index_of_last_non_canonical_row { match index_of_last_non_canonical_row {
Some(index_of_last_non_canonical_row) => { Some(index_of_last_non_canonical_row) => {
rows.drain(index_of_last_non_canonical_row..).collect() rows.drain(index_of_last_non_canonical_row..).collect()
} },
None => vec![], None => vec![],
} }
} }
@ -77,7 +77,7 @@ fn get_viewport_bottom_canonical_row_and_wraps(viewport: &mut Vec<Row>) -> Vec<R
match index_of_last_non_canonical_row { match index_of_last_non_canonical_row {
Some(index_of_last_non_canonical_row) => { Some(index_of_last_non_canonical_row) => {
viewport.drain(index_of_last_non_canonical_row..).collect() viewport.drain(index_of_last_non_canonical_row..).collect()
} },
None => vec![], None => vec![],
} }
} }
@ -134,7 +134,7 @@ fn transfer_rows_from_lines_above_to_viewport(
// no more lines at lines_above, the line we popped was probably empty // no more lines at lines_above, the line we popped was probably empty
break; break;
} }
} },
None => break, // no more rows None => break, // no more rows
} }
} }
@ -407,10 +407,10 @@ impl Grid {
match next_tabstop { match next_tabstop {
Some(tabstop) => { Some(tabstop) => {
self.cursor.x = tabstop; self.cursor.x = tabstop;
} },
None => { None => {
self.cursor.x = self.width.saturating_sub(1); self.cursor.x = self.width.saturating_sub(1);
} },
} }
let mut empty_character = EMPTY_TERMINAL_CHARACTER; let mut empty_character = EMPTY_TERMINAL_CHARACTER;
empty_character.styles = styles; empty_character.styles = styles;
@ -427,10 +427,10 @@ impl Grid {
match previous_tabstop { match previous_tabstop {
Some(tabstop) => { Some(tabstop) => {
self.cursor.x = tabstop; self.cursor.x = tabstop;
} },
None => { None => {
self.cursor.x = 0; self.cursor.x = 0;
} },
} }
} }
pub fn cursor_shape(&self) -> CursorShape { pub fn cursor_shape(&self) -> CursorShape {
@ -627,14 +627,14 @@ impl Grid {
match viewport_canonical_lines.last_mut() { match viewport_canonical_lines.last_mut() {
Some(last_line) => { Some(last_line) => {
last_line.append(&mut row.columns); last_line.append(&mut row.columns);
} },
None => { None => {
// the state is corrupted somehow // the state is corrupted somehow
// this is a bug and I'm not yet sure why it happens // this is a bug and I'm not yet sure why it happens
// usually it fixes itself and is a result of some race // usually it fixes itself and is a result of some race
// TODO: investigate why this happens and solve it // TODO: investigate why this happens and solve it
return; return;
} },
} }
} }
} }
@ -701,7 +701,7 @@ impl Grid {
); );
let rows_pulled = self.viewport.len() - current_viewport_row_count; let rows_pulled = self.viewport.len() - current_viewport_row_count;
new_cursor_y += rows_pulled; new_cursor_y += rows_pulled;
} },
Ordering::Greater => { Ordering::Greater => {
let row_count_to_transfer = current_viewport_row_count - self.height; let row_count_to_transfer = current_viewport_row_count - self.height;
if row_count_to_transfer > new_cursor_y { if row_count_to_transfer > new_cursor_y {
@ -715,8 +715,8 @@ impl Grid {
row_count_to_transfer, row_count_to_transfer,
new_columns, new_columns,
); );
} },
Ordering::Equal => {} Ordering::Equal => {},
} }
self.cursor.y = new_cursor_y; self.cursor.y = new_cursor_y;
self.cursor.x = new_cursor_x; self.cursor.x = new_cursor_x;
@ -753,7 +753,7 @@ impl Grid {
self.saved_cursor_position self.saved_cursor_position
.as_mut() .as_mut()
.map(|saved_cursor_position| saved_cursor_position.y += rows_pulled); .map(|saved_cursor_position| saved_cursor_position.y += rows_pulled);
} },
Ordering::Greater => { Ordering::Greater => {
let row_count_to_transfer = current_viewport_row_count - new_rows; let row_count_to_transfer = current_viewport_row_count - new_rows;
if row_count_to_transfer > self.cursor.y { if row_count_to_transfer > self.cursor.y {
@ -780,8 +780,8 @@ impl Grid {
// in alternate screen, no scroll buffer, so just remove lines // in alternate screen, no scroll buffer, so just remove lines
self.viewport.drain(0..row_count_to_transfer); self.viewport.drain(0..row_count_to_transfer);
} }
} },
Ordering::Equal => {} Ordering::Equal => {},
} }
} }
self.height = new_rows; self.height = new_rows;
@ -1001,7 +1001,7 @@ impl Grid {
row.add_character_at(terminal_character, self.cursor.x); row.add_character_at(terminal_character, self.cursor.x);
} }
self.output_buffer.update_line(self.cursor.y); self.output_buffer.update_line(self.cursor.y);
} },
None => { None => {
// pad lines until cursor if they do not exist // pad lines until cursor if they do not exist
for _ in self.viewport.len()..self.cursor.y { for _ in self.viewport.len()..self.cursor.y {
@ -1013,7 +1013,7 @@ impl Grid {
.canonical(), .canonical(),
); );
self.output_buffer.update_line(self.cursor.y); self.output_buffer.update_line(self.cursor.y);
} },
} }
} }
pub fn add_character(&mut self, terminal_character: TerminalCharacter) { pub fn add_character(&mut self, terminal_character: TerminalCharacter) {
@ -1147,13 +1147,13 @@ impl Grid {
} }
self.pad_lines_until(self.cursor.y, pad_character); self.pad_lines_until(self.cursor.y, pad_character);
self.pad_current_line_until(self.cursor.x, pad_character); self.pad_current_line_until(self.cursor.x, pad_character);
} },
None => { None => {
self.cursor.x = std::cmp::min(self.width - 1, x); self.cursor.x = std::cmp::min(self.width - 1, x);
self.cursor.y = std::cmp::min(self.height - 1, y); self.cursor.y = std::cmp::min(self.height - 1, y);
self.pad_lines_until(self.cursor.y, pad_character); self.pad_lines_until(self.cursor.y, pad_character);
self.pad_current_line_until(self.cursor.x, pad_character); self.pad_current_line_until(self.cursor.x, pad_character);
} },
} }
} }
pub fn move_cursor_up(&mut self, count: usize) { pub fn move_cursor_up(&mut self, count: usize) {
@ -1517,32 +1517,32 @@ impl Perform for Grid {
match byte { match byte {
7 => { 7 => {
self.ring_bell = true; self.ring_bell = true;
} },
8 => { 8 => {
// backspace // backspace
self.move_cursor_back(1); self.move_cursor_back(1);
} },
9 => { 9 => {
// tab // tab
self.advance_to_next_tabstop(self.cursor.pending_styles); self.advance_to_next_tabstop(self.cursor.pending_styles);
} },
10 | 11 | 12 => { 10 | 11 | 12 => {
// 0a, newline // 0a, newline
// 0b, vertical tabulation // 0b, vertical tabulation
// 0c, form feed // 0c, form feed
self.add_newline(); self.add_newline();
} },
13 => { 13 => {
// 0d, carriage return // 0d, carriage return
self.move_cursor_to_beginning_of_line(); self.move_cursor_to_beginning_of_line();
} },
14 => { 14 => {
self.set_active_charset(CharsetIndex::G1); self.set_active_charset(CharsetIndex::G1);
} },
15 => { 15 => {
self.set_active_charset(CharsetIndex::G0); self.set_active_charset(CharsetIndex::G0);
} },
_ => {} _ => {},
} }
} }
@ -1578,7 +1578,7 @@ impl Perform for Grid {
.to_owned(); .to_owned();
self.set_title(title); self.set_title(title);
} }
} },
// Set color index. // Set color index.
b"4" => { b"4" => {
@ -1593,7 +1593,7 @@ impl Perform for Grid {
return; return;
} }
} }
} },
// define hyperlink // define hyperlink
b"8" => { b"8" => {
@ -1602,7 +1602,7 @@ impl Perform for Grid {
} }
self.cursor.pending_styles.link_anchor = self.cursor.pending_styles.link_anchor =
self.link_handler.borrow_mut().dispatch_osc8(params); self.link_handler.borrow_mut().dispatch_osc8(params);
} },
// Get/set Foreground (b"10") or background (b"11") colors // Get/set Foreground (b"10") or background (b"11") colors
b"10" | b"11" => { b"10" | b"11" => {
@ -1626,14 +1626,14 @@ impl Perform for Grid {
// dynamic_code, color.r, color.g, color.b, terminator // dynamic_code, color.r, color.g, color.b, terminator
dynamic_code, r, g, b, terminator dynamic_code, r, g, b, terminator
) )
} },
_ => { _ => {
format!( format!(
"\u{1b}]{};rgb:{1:02x}{1:02x}/{2:02x}{2:02x}/{3:02x}{3:02x}{4}", "\u{1b}]{};rgb:{1:02x}{1:02x}/{2:02x}{2:02x}/{3:02x}{3:02x}{4}",
// dynamic_code, color.r, color.g, color.b, terminator // dynamic_code, color.r, color.g, color.b, terminator
dynamic_code, 0, 0, 0, terminator dynamic_code, 0, 0, 0, terminator
) )
} },
}; };
self.pending_messages_to_pty self.pending_messages_to_pty
.push(color_response_message.as_bytes().to_vec()); .push(color_response_message.as_bytes().to_vec());
@ -1642,11 +1642,11 @@ impl Perform for Grid {
} }
} }
} }
} },
b"12" => { b"12" => {
// get/set cursor color currently unimplemented // get/set cursor color currently unimplemented
} },
// Set cursor style. // Set cursor style.
b"50" => { b"50" => {
@ -1664,7 +1664,7 @@ impl Perform for Grid {
self.cursor.change_shape(cursor_shape); self.cursor.change_shape(cursor_shape);
} }
} }
} },
// Set clipboard. // Set clipboard.
b"52" => { b"52" => {
@ -1676,12 +1676,12 @@ impl Perform for Grid {
match params[2] { match params[2] {
b"?" => { b"?" => {
// TBD: paste from own clipboard - currently unsupported // TBD: paste from own clipboard - currently unsupported
} },
_base64 => { _base64 => {
// TBD: copy to own clipboard - currently unsupported // TBD: copy to own clipboard - currently unsupported
},
} }
} },
}
// Reset color index. // Reset color index.
b"104" => { b"104" => {
@ -1712,24 +1712,24 @@ impl Perform for Grid {
// TBD - reset color index - currently unimplemented // TBD - reset color index - currently unimplemented
} }
} }
} },
// Reset foreground color. // Reset foreground color.
b"110" => { b"110" => {
// TBD - reset foreground color - currently unimplemented // TBD - reset foreground color - currently unimplemented
} },
// Reset background color. // Reset background color.
b"111" => { b"111" => {
// TBD - reset background color - currently unimplemented // TBD - reset background color - currently unimplemented
} },
// Reset text cursor color. // Reset text cursor color.
b"112" => { b"112" => {
// TBD - reset text cursor color - currently unimplemented // TBD - reset text cursor color - currently unimplemented
} },
_ => {} _ => {},
} }
} }
@ -1809,7 +1809,7 @@ impl Perform for Grid {
match params_iter.next().map(|param| param[0]) { match params_iter.next().map(|param| param[0]) {
Some(2004) => { Some(2004) => {
self.bracketed_paste_mode = false; self.bracketed_paste_mode = false;
} },
Some(1049) => { Some(1049) => {
// leave alternate buffer // leave alternate buffer
if let Some(( if let Some((
@ -1826,31 +1826,31 @@ impl Perform for Grid {
self.clear_viewport_before_rendering = true; self.clear_viewport_before_rendering = true;
self.force_change_size(self.height, self.width); // the alternative_viewport might have been of a different size... self.force_change_size(self.height, self.width); // the alternative_viewport might have been of a different size...
self.mark_for_rerender(); self.mark_for_rerender();
} },
Some(25) => { Some(25) => {
self.hide_cursor(); self.hide_cursor();
self.mark_for_rerender(); self.mark_for_rerender();
} },
Some(1) => { Some(1) => {
self.cursor_key_mode = false; self.cursor_key_mode = false;
} },
Some(3) => { Some(3) => {
// DECCOLM - only side effects // DECCOLM - only side effects
self.scroll_region = None; self.scroll_region = None;
self.clear_all(EMPTY_TERMINAL_CHARACTER); self.clear_all(EMPTY_TERMINAL_CHARACTER);
self.cursor.x = 0; self.cursor.x = 0;
self.cursor.y = 0; self.cursor.y = 0;
} },
Some(6) => { Some(6) => {
self.erasure_mode = false; self.erasure_mode = false;
} },
Some(7) => { Some(7) => {
self.disable_linewrap = true; self.disable_linewrap = true;
} },
Some(1006) => { Some(1006) => {
self.mouse_mode = false; self.mouse_mode = false;
} },
_ => {} _ => {},
}; };
} else if let Some(4) = params_iter.next().map(|param| param[0]) { } else if let Some(4) = params_iter.next().map(|param| param[0]) {
self.insert_mode = false; self.insert_mode = false;
@ -1866,10 +1866,10 @@ impl Perform for Grid {
Some(25) => { Some(25) => {
self.show_cursor(); self.show_cursor();
self.mark_for_rerender(); self.mark_for_rerender();
} },
Some(2004) => { Some(2004) => {
self.bracketed_paste_mode = true; self.bracketed_paste_mode = true;
} },
Some(1049) => { Some(1049) => {
// enter alternate buffer // enter alternate buffer
let current_lines_above = std::mem::replace( let current_lines_above = std::mem::replace(
@ -1886,27 +1886,27 @@ impl Perform for Grid {
self.clear_viewport_before_rendering = true; self.clear_viewport_before_rendering = true;
self.scrollback_buffer_lines = self.recalculate_scrollback_buffer_count(); self.scrollback_buffer_lines = self.recalculate_scrollback_buffer_count();
self.output_buffer.update_all_lines(); // make sure the screen gets cleared in the next render self.output_buffer.update_all_lines(); // make sure the screen gets cleared in the next render
} },
Some(1) => { Some(1) => {
self.cursor_key_mode = true; self.cursor_key_mode = true;
} },
Some(3) => { Some(3) => {
// DECCOLM - only side effects // DECCOLM - only side effects
self.scroll_region = None; self.scroll_region = None;
self.clear_all(EMPTY_TERMINAL_CHARACTER); self.clear_all(EMPTY_TERMINAL_CHARACTER);
self.cursor.x = 0; self.cursor.x = 0;
self.cursor.y = 0; self.cursor.y = 0;
} },
Some(6) => { Some(6) => {
self.erasure_mode = true; self.erasure_mode = true;
} },
Some(7) => { Some(7) => {
self.disable_linewrap = false; self.disable_linewrap = false;
} },
Some(1006) => { Some(1006) => {
self.mouse_mode = true; self.mouse_mode = true;
} },
_ => {} _ => {},
}; };
} else if let Some(4) = params_iter.next().map(|param| param[0]) { } else if let Some(4) = params_iter.next().map(|param| param[0]) {
self.insert_mode = true; self.insert_mode = true;
@ -2039,14 +2039,14 @@ impl Perform for Grid {
let terminal_capabilities = "\u{1b}[?6c"; let terminal_capabilities = "\u{1b}[?6c";
self.pending_messages_to_pty self.pending_messages_to_pty
.push(terminal_capabilities.as_bytes().to_vec()); .push(terminal_capabilities.as_bytes().to_vec());
} },
Some(b'>') => { Some(b'>') => {
// secondary device attributes // secondary device attributes
let version = version_number(VERSION); let version = version_number(VERSION);
let text = format!("\u{1b}[>0;{};1c", version); let text = format!("\u{1b}[>0;{};1c", version);
self.pending_messages_to_pty.push(text.as_bytes().to_vec()); self.pending_messages_to_pty.push(text.as_bytes().to_vec());
} },
_ => {} _ => {},
} }
} else if c == 'n' { } else if c == 'n' {
// DSR - device status report // DSR - device status report
@ -2057,15 +2057,15 @@ impl Perform for Grid {
let all_good = "\u{1b}[0n"; let all_good = "\u{1b}[0n";
self.pending_messages_to_pty self.pending_messages_to_pty
.push(all_good.as_bytes().to_vec()); .push(all_good.as_bytes().to_vec());
} },
6 => { 6 => {
// CPR - cursor position report // CPR - cursor position report
let position_report = let position_report =
format!("\x1b[{};{}R", self.cursor.y + 1, self.cursor.x + 1); format!("\x1b[{};{}R", self.cursor.y + 1, self.cursor.x + 1);
self.pending_messages_to_pty self.pending_messages_to_pty
.push(position_report.as_bytes().to_vec()); .push(position_report.as_bytes().to_vec());
} },
_ => {} _ => {},
} }
} else if c == 't' { } else if c == 't' {
match next_param_or(1) as usize { match next_param_or(1) as usize {
@ -2079,7 +2079,7 @@ impl Perform for Grid {
self.pending_messages_to_pty self.pending_messages_to_pty
.push(text_area_pixel_size_report.as_bytes().to_vec()); .push(text_area_pixel_size_report.as_bytes().to_vec());
} }
} },
16 => { 16 => {
if let Some(character_cell_size) = *self.character_cell_size.borrow() { if let Some(character_cell_size) = *self.character_cell_size.borrow() {
let character_cell_size_report = format!( let character_cell_size_report = format!(
@ -2089,20 +2089,20 @@ impl Perform for Grid {
self.pending_messages_to_pty self.pending_messages_to_pty
.push(character_cell_size_report.as_bytes().to_vec()); .push(character_cell_size_report.as_bytes().to_vec());
} }
} },
18 => { 18 => {
// report text area // report text area
let text_area_report = format!("\x1b[8;{};{}t", self.height, self.width); let text_area_report = format!("\x1b[8;{};{}t", self.height, self.width);
self.pending_messages_to_pty self.pending_messages_to_pty
.push(text_area_report.as_bytes().to_vec()); .push(text_area_report.as_bytes().to_vec());
} },
22 => { 22 => {
self.push_current_title_to_stack(); self.push_current_title_to_stack();
} },
23 => { 23 => {
self.pop_title_from_stack(); self.pop_title_from_stack();
} },
_ => {} _ => {},
} }
} else { } else {
log::warn!("Unhandled csi: {}->{:?}", c, params); log::warn!("Unhandled csi: {}->{:?}", c, params);
@ -2120,10 +2120,10 @@ impl Perform for Grid {
_ => { _ => {
// invalid, silently do nothing // invalid, silently do nothing
return; return;
} },
}; };
self.configure_charset(StandardCharset::Ascii, charset_index); self.configure_charset(StandardCharset::Ascii, charset_index);
} },
(b'0', charset_index_symbol) => { (b'0', charset_index_symbol) => {
let charset_index: CharsetIndex = match charset_index_symbol { let charset_index: CharsetIndex = match charset_index_symbol {
Some(b'(') => CharsetIndex::G0, Some(b'(') => CharsetIndex::G0,
@ -2133,47 +2133,47 @@ impl Perform for Grid {
_ => { _ => {
// invalid, silently do nothing // invalid, silently do nothing
return; return;
} },
}; };
self.configure_charset( self.configure_charset(
StandardCharset::SpecialCharacterAndLineDrawing, StandardCharset::SpecialCharacterAndLineDrawing,
charset_index, charset_index,
); );
} },
(b'D', None) => { (b'D', None) => {
self.add_newline(); self.add_newline();
} },
(b'E', None) => { (b'E', None) => {
self.add_newline(); self.add_newline();
self.move_cursor_to_beginning_of_line(); self.move_cursor_to_beginning_of_line();
} },
(b'M', None) => { (b'M', None) => {
// TODO: if cursor is at the top, it should go down one // TODO: if cursor is at the top, it should go down one
self.move_cursor_up_with_scrolling(1); self.move_cursor_up_with_scrolling(1);
} },
(b'c', None) => { (b'c', None) => {
self.reset_terminal_state(); self.reset_terminal_state();
} },
(b'H', None) => { (b'H', None) => {
self.set_horizontal_tabstop(); self.set_horizontal_tabstop();
} },
(b'7', None) => { (b'7', None) => {
self.save_cursor_position(); self.save_cursor_position();
} },
(b'Z', None) => { (b'Z', None) => {
let terminal_capabilities = "\u{1b}[?6c"; let terminal_capabilities = "\u{1b}[?6c";
self.pending_messages_to_pty self.pending_messages_to_pty
.push(terminal_capabilities.as_bytes().to_vec()); .push(terminal_capabilities.as_bytes().to_vec());
} },
(b'8', None) => { (b'8', None) => {
self.restore_cursor_position(); self.restore_cursor_position();
} },
(b'8', Some(b'#')) => { (b'8', Some(b'#')) => {
let mut fill_character = EMPTY_TERMINAL_CHARACTER; let mut fill_character = EMPTY_TERMINAL_CHARACTER;
fill_character.character = 'E'; fill_character.character = 'E';
self.fill_viewport(fill_character); self.fill_viewport(fill_character);
} },
_ => {} _ => {},
} }
} }
} }
@ -2303,7 +2303,7 @@ impl Row {
self.columns.push_back(terminal_character); self.columns.push_back(terminal_character);
// this is unwrapped because this always happens after self.width_cached() // this is unwrapped because this always happens after self.width_cached()
*self.width.as_mut().unwrap() += terminal_character.width; *self.width.as_mut().unwrap() += terminal_character.width;
} },
Ordering::Less => { Ordering::Less => {
// adding the character after the end of the current line // adding the character after the end of the current line
// we pad the line up to the character and then add it // we pad the line up to the character and then add it
@ -2312,7 +2312,7 @@ impl Row {
.resize(x.saturating_sub(width_offset), EMPTY_TERMINAL_CHARACTER); .resize(x.saturating_sub(width_offset), EMPTY_TERMINAL_CHARACTER);
self.columns.push_back(terminal_character); self.columns.push_back(terminal_character);
self.width = None; self.width = None;
} },
Ordering::Greater => { Ordering::Greater => {
// adding the character in the middle of the line // adding the character in the middle of the line
// we replace the character at its position // we replace the character at its position
@ -2335,7 +2335,7 @@ impl Row {
.insert(position_to_remove, EMPTY_TERMINAL_CHARACTER); .insert(position_to_remove, EMPTY_TERMINAL_CHARACTER);
} }
} }
} },
Ordering::Less => { Ordering::Less => {
// the replaced character is wider than the current character // the replaced character is wider than the current character
// (eg. we added an English character in place of a wide emoji) // (eg. we added an English character in place of a wide emoji)
@ -2349,11 +2349,11 @@ impl Row {
self.columns self.columns
.insert(absolute_x_index + 1, EMPTY_TERMINAL_CHARACTER); .insert(absolute_x_index + 1, EMPTY_TERMINAL_CHARACTER);
} }
} },
_ => {} _ => {},
} }
self.width = None; self.width = None;
} },
} }
} }
pub fn insert_character_at(&mut self, terminal_character: TerminalCharacter, x: usize) { pub fn insert_character_at(&mut self, terminal_character: TerminalCharacter, x: usize) {
@ -2364,10 +2364,10 @@ impl Row {
self.columns self.columns
.resize(insert_position, EMPTY_TERMINAL_CHARACTER); .resize(insert_position, EMPTY_TERMINAL_CHARACTER);
self.columns.push_back(terminal_character); self.columns.push_back(terminal_character);
} },
Ordering::Greater => { Ordering::Greater => {
self.columns.insert(insert_position, terminal_character); self.columns.insert(insert_position, terminal_character);
} },
} }
self.width = None; self.width = None;
} }

View File

@ -71,7 +71,7 @@ impl LinkHandler {
} }
output output
} },
LinkAnchor::End => Some(format!("\u{1b}]8;;{}", TERMINATOR)), LinkAnchor::End => Some(format!("\u{1b}]8;;{}", TERMINATOR)),
}) })
.flatten() .flatten()
@ -102,7 +102,7 @@ mod tests {
let link = link_handler.links.get(&link_id).expect("link was not some"); let link = link_handler.links.get(&link_id).expect("link was not some");
assert_eq!(link.id, Some("test".to_string())); assert_eq!(link.id, Some("test".to_string()));
assert_eq!(link.uri, uri); assert_eq!(link.uri, uri);
} },
_ => panic!("pending link handler was not start"), _ => panic!("pending link handler was not start"),
} }

View File

@ -268,14 +268,14 @@ impl Pane for PluginPane {
match name { match name {
"\0" => { "\0" => {
self.pane_name = String::new(); self.pane_name = String::new();
} },
"\u{007F}" | "\u{0008}" => { "\u{007F}" | "\u{0008}" => {
//delete and backspace keys //delete and backspace keys
self.pane_name.pop(); self.pane_name.pop();
} },
c => { c => {
self.pane_name.push_str(c); self.pane_name.push_str(c);
} },
} }
} }
fn pid(&self) -> PaneId { fn pid(&self) -> PaneId {

View File

@ -297,13 +297,13 @@ impl CharacterStyles {
[22] => { [22] => {
*self = self.bold(Some(AnsiCode::Reset)); *self = self.bold(Some(AnsiCode::Reset));
*self = self.dim(Some(AnsiCode::Reset)); *self = self.dim(Some(AnsiCode::Reset));
} },
[23] => *self = self.italic(Some(AnsiCode::Reset)), [23] => *self = self.italic(Some(AnsiCode::Reset)),
[24] => *self = self.underline(Some(AnsiCode::Reset)), [24] => *self = self.underline(Some(AnsiCode::Reset)),
[25] => { [25] => {
*self = self.blink_slow(Some(AnsiCode::Reset)); *self = self.blink_slow(Some(AnsiCode::Reset));
*self = self.blink_fast(Some(AnsiCode::Reset)); *self = self.blink_fast(Some(AnsiCode::Reset));
} },
[27] => *self = self.reverse(Some(AnsiCode::Reset)), [27] => *self = self.reverse(Some(AnsiCode::Reset)),
[28] => *self = self.hidden(Some(AnsiCode::Reset)), [28] => *self = self.hidden(Some(AnsiCode::Reset)),
[29] => *self = self.strike(Some(AnsiCode::Reset)), [29] => *self = self.strike(Some(AnsiCode::Reset)),
@ -320,7 +320,7 @@ impl CharacterStyles {
if let Some(ansi_code) = parse_sgr_color(&mut iter) { if let Some(ansi_code) = parse_sgr_color(&mut iter) {
*self = self.foreground(Some(ansi_code)); *self = self.foreground(Some(ansi_code));
} }
} },
[38, params @ ..] => { [38, params @ ..] => {
let rgb_start = if params.len() > 4 { 2 } else { 1 }; let rgb_start = if params.len() > 4 { 2 } else { 1 };
let rgb_iter = params[rgb_start..].iter().copied(); let rgb_iter = params[rgb_start..].iter().copied();
@ -328,7 +328,7 @@ impl CharacterStyles {
if let Some(ansi_code) = parse_sgr_color(&mut iter) { if let Some(ansi_code) = parse_sgr_color(&mut iter) {
*self = self.foreground(Some(ansi_code)); *self = self.foreground(Some(ansi_code));
} }
} },
[39] => *self = self.foreground(Some(AnsiCode::Reset)), [39] => *self = self.foreground(Some(AnsiCode::Reset)),
[40] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::Black))), [40] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::Black))),
[41] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::Red))), [41] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::Red))),
@ -343,7 +343,7 @@ impl CharacterStyles {
if let Some(ansi_code) = parse_sgr_color(&mut iter) { if let Some(ansi_code) = parse_sgr_color(&mut iter) {
*self = self.background(Some(ansi_code)); *self = self.background(Some(ansi_code));
} }
} },
[48, params @ ..] => { [48, params @ ..] => {
let rgb_start = if params.len() > 4 { 2 } else { 1 }; let rgb_start = if params.len() > 4 { 2 } else { 1 };
let rgb_iter = params[rgb_start..].iter().copied(); let rgb_iter = params[rgb_start..].iter().copied();
@ -351,52 +351,52 @@ impl CharacterStyles {
if let Some(ansi_code) = parse_sgr_color(&mut iter) { if let Some(ansi_code) = parse_sgr_color(&mut iter) {
*self = self.background(Some(ansi_code)); *self = self.background(Some(ansi_code));
} }
} },
[49] => *self = self.background(Some(AnsiCode::Reset)), [49] => *self = self.background(Some(AnsiCode::Reset)),
[90] => { [90] => {
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightBlack))) *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightBlack)))
} },
[91] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightRed))), [91] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightRed))),
[92] => { [92] => {
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightGreen))) *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightGreen)))
} },
[93] => { [93] => {
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightYellow))) *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightYellow)))
} },
[94] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightBlue))), [94] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightBlue))),
[95] => { [95] => {
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightMagenta))) *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightMagenta)))
} },
[96] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightCyan))), [96] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightCyan))),
[97] => { [97] => {
*self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightWhite))) *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightWhite)))
} },
[100] => { [100] => {
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightBlack))) *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightBlack)))
} },
[101] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightRed))), [101] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightRed))),
[102] => { [102] => {
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightGreen))) *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightGreen)))
} },
[103] => { [103] => {
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightYellow))) *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightYellow)))
} },
[104] => { [104] => {
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightBlue))) *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightBlue)))
} },
[105] => { [105] => {
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightMagenta))) *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightMagenta)))
} },
[106] => { [106] => {
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightCyan))) *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightCyan)))
} },
[107] => { [107] => {
*self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightWhite))) *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightWhite)))
} },
_ => { _ => {
log::warn!("unhandled csi m code {:?}", param); log::warn!("unhandled csi m code {:?}", param);
return; return;
} },
} }
} }
} }
@ -423,102 +423,102 @@ impl Display for CharacterStyles {
match ansi_code { match ansi_code {
AnsiCode::RgbCode((r, g, b)) => { AnsiCode::RgbCode((r, g, b)) => {
write!(f, "\u{1b}[38;2;{};{};{}m", r, g, b)?; write!(f, "\u{1b}[38;2;{};{};{}m", r, g, b)?;
} },
AnsiCode::ColorIndex(color_index) => { AnsiCode::ColorIndex(color_index) => {
write!(f, "\u{1b}[38;5;{}m", color_index)?; write!(f, "\u{1b}[38;5;{}m", color_index)?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[39m")?; write!(f, "\u{1b}[39m")?;
} },
AnsiCode::NamedColor(named_color) => { AnsiCode::NamedColor(named_color) => {
write!(f, "\u{1b}[{}m", named_color.to_foreground_ansi_code())?; write!(f, "\u{1b}[{}m", named_color.to_foreground_ansi_code())?;
} },
_ => {} _ => {},
} }
}; };
if let Some(ansi_code) = self.background { if let Some(ansi_code) = self.background {
match ansi_code { match ansi_code {
AnsiCode::RgbCode((r, g, b)) => { AnsiCode::RgbCode((r, g, b)) => {
write!(f, "\u{1b}[48;2;{};{};{}m", r, g, b)?; write!(f, "\u{1b}[48;2;{};{};{}m", r, g, b)?;
} },
AnsiCode::ColorIndex(color_index) => { AnsiCode::ColorIndex(color_index) => {
write!(f, "\u{1b}[48;5;{}m", color_index)?; write!(f, "\u{1b}[48;5;{}m", color_index)?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[49m")?; write!(f, "\u{1b}[49m")?;
} },
AnsiCode::NamedColor(named_color) => { AnsiCode::NamedColor(named_color) => {
write!(f, "\u{1b}[{}m", named_color.to_background_ansi_code())?; write!(f, "\u{1b}[{}m", named_color.to_background_ansi_code())?;
} },
_ => {} _ => {},
} }
} }
if let Some(ansi_code) = self.strike { if let Some(ansi_code) = self.strike {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[9m")?; write!(f, "\u{1b}[9m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[29m")?; write!(f, "\u{1b}[29m")?;
} },
_ => {} _ => {},
} }
} }
if let Some(ansi_code) = self.hidden { if let Some(ansi_code) = self.hidden {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[8m")?; write!(f, "\u{1b}[8m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[28m")?; write!(f, "\u{1b}[28m")?;
} },
_ => {} _ => {},
} }
} }
if let Some(ansi_code) = self.reverse { if let Some(ansi_code) = self.reverse {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[7m")?; write!(f, "\u{1b}[7m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[27m")?; write!(f, "\u{1b}[27m")?;
} },
_ => {} _ => {},
} }
} }
if let Some(ansi_code) = self.fast_blink { if let Some(ansi_code) = self.fast_blink {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[6m")?; write!(f, "\u{1b}[6m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[25m")?; write!(f, "\u{1b}[25m")?;
} },
_ => {} _ => {},
} }
} }
if let Some(ansi_code) = self.slow_blink { if let Some(ansi_code) = self.slow_blink {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[5m")?; write!(f, "\u{1b}[5m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[25m")?; write!(f, "\u{1b}[25m")?;
} },
_ => {} _ => {},
} }
} }
if let Some(ansi_code) = self.bold { if let Some(ansi_code) = self.bold {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[1m")?; write!(f, "\u{1b}[1m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[22m\u{1b}[24m")?; write!(f, "\u{1b}[22m\u{1b}[24m")?;
// TODO: this cancels bold + underline, if this behaviour is indeed correct, we // TODO: this cancels bold + underline, if this behaviour is indeed correct, we
// need to properly handle it in the struct methods etc like dim // need to properly handle it in the struct methods etc like dim
} },
_ => {} _ => {},
} }
} }
// notice the order is important here, bold must be before underline // notice the order is important here, bold must be before underline
@ -528,36 +528,36 @@ impl Display for CharacterStyles {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[4m")?; write!(f, "\u{1b}[4m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[24m")?; write!(f, "\u{1b}[24m")?;
} },
_ => {} _ => {},
} }
} }
if let Some(ansi_code) = self.dim { if let Some(ansi_code) = self.dim {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[2m")?; write!(f, "\u{1b}[2m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
if let Some(AnsiCode::Reset) = self.bold { if let Some(AnsiCode::Reset) = self.bold {
// we only reset dim if both dim and bold should be reset // we only reset dim if both dim and bold should be reset
write!(f, "\u{1b}[22m")?; write!(f, "\u{1b}[22m")?;
} }
} },
_ => {} _ => {},
} }
} }
if let Some(ansi_code) = self.italic { if let Some(ansi_code) = self.italic {
match ansi_code { match ansi_code {
AnsiCode::On => { AnsiCode::On => {
write!(f, "\u{1b}[3m")?; write!(f, "\u{1b}[3m")?;
} },
AnsiCode::Reset => { AnsiCode::Reset => {
write!(f, "\u{1b}[23m")?; write!(f, "\u{1b}[23m")?;
} },
_ => {} _ => {},
} }
}; };
Ok(()) Ok(())

View File

@ -123,7 +123,7 @@ impl Pane for TerminalPane {
// some editors will not show this // some editors will not show this
return "OD".as_bytes().to_vec(); return "OD".as_bytes().to_vec();
} }
} },
[27, 91, 67] => { [27, 91, 67] => {
// right arrow // right arrow
if self.grid.cursor_key_mode { if self.grid.cursor_key_mode {
@ -131,7 +131,7 @@ impl Pane for TerminalPane {
// some editors will not show this // some editors will not show this
return "OC".as_bytes().to_vec(); return "OC".as_bytes().to_vec();
} }
} },
[27, 91, 65] => { [27, 91, 65] => {
// up arrow // up arrow
if self.grid.cursor_key_mode { if self.grid.cursor_key_mode {
@ -139,20 +139,20 @@ impl Pane for TerminalPane {
// some editors will not show this // some editors will not show this
return "OA".as_bytes().to_vec(); return "OA".as_bytes().to_vec();
} }
} },
[27, 91, 72] => { [27, 91, 72] => {
// home key // home key
if self.grid.cursor_key_mode { if self.grid.cursor_key_mode {
return vec![27, 79, 72]; // ESC O H return vec![27, 79, 72]; // ESC O H
} }
} },
[27, 91, 70] => { [27, 91, 70] => {
// end key // end key
if self.grid.cursor_key_mode { if self.grid.cursor_key_mode {
return vec![27, 79, 70]; // ESC O F return vec![27, 79, 70]; // ESC O F
} }
} },
[27, 91, 66] => { [27, 91, 66] => {
// down arrow // down arrow
if self.grid.cursor_key_mode { if self.grid.cursor_key_mode {
@ -160,7 +160,7 @@ impl Pane for TerminalPane {
// some editors will not show this // some editors will not show this
return "OB".as_bytes().to_vec(); return "OB".as_bytes().to_vec();
} }
} },
[27, 91, 50, 48, 48, 126] | [27, 91, 50, 48, 49, 126] => { [27, 91, 50, 48, 48, 126] | [27, 91, 50, 48, 49, 126] => {
if !self.grid.bracketed_paste_mode { if !self.grid.bracketed_paste_mode {
// Zellij itself operates in bracketed paste mode, so the terminal sends these // Zellij itself operates in bracketed paste mode, so the terminal sends these
@ -169,8 +169,8 @@ impl Pane for TerminalPane {
// panes who do not work in this mode // panes who do not work in this mode
return vec![]; return vec![];
} }
} },
_ => {} _ => {},
}; };
input_bytes input_bytes
} }
@ -281,7 +281,7 @@ impl Pane for TerminalPane {
} else { } else {
None None
} }
} },
None => { None => {
if !self.borderless { if !self.borderless {
let frame_output = frame.render(); let frame_output = frame.render();
@ -290,7 +290,7 @@ impl Pane for TerminalPane {
} else { } else {
None None
} }
} },
} }
} }
fn render_fake_cursor( fn render_fake_cursor(
@ -333,14 +333,14 @@ impl Pane for TerminalPane {
match name { match name {
"\0" => { "\0" => {
self.pane_name = String::new(); self.pane_name = String::new();
} },
"\u{007F}" | "\u{0008}" => { "\u{007F}" | "\u{0008}" => {
//delete and backspace keys //delete and backspace keys
self.pane_name.pop(); self.pane_name.pop();
} },
c => { c => {
self.pane_name.push_str(c); self.pane_name.push_str(c);
} },
} }
} }
fn pid(&self) -> PaneId { fn pid(&self) -> PaneId {

View File

@ -219,7 +219,7 @@ impl TiledPanes {
let result = match direction { let result = match direction {
Direction::Horizontal => { Direction::Horizontal => {
pane_grid.layout(direction, (*self.display_area.borrow()).cols) pane_grid.layout(direction, (*self.display_area.borrow()).cols)
} },
Direction::Vertical => pane_grid.layout(direction, (*self.display_area.borrow()).rows), Direction::Vertical => pane_grid.layout(direction, (*self.display_area.borrow()).rows),
}; };
if let Err(e) = &result { if let Err(e) = &result {
@ -632,10 +632,10 @@ impl TiledPanes {
self.set_pane_active_at(p); self.set_pane_active_at(p);
true true
} },
None => false, None => false,
} }
} },
None => false, None => false,
} }
} }
@ -673,10 +673,10 @@ impl TiledPanes {
self.set_pane_active_at(p); self.set_pane_active_at(p);
true true
} },
None => false, None => false,
} }
} },
None => false, None => false,
} }
} }
@ -714,10 +714,10 @@ impl TiledPanes {
self.set_pane_active_at(p); self.set_pane_active_at(p);
true true
} },
None => false, None => false,
} }
} },
None => false, None => false,
} }
} }
@ -755,10 +755,10 @@ impl TiledPanes {
self.set_pane_active_at(p); self.set_pane_active_at(p);
true true
} },
None => false, None => false,
} }
} },
None => false, None => false,
} }
} }
@ -952,7 +952,7 @@ impl TiledPanes {
self.active_panes.insert(client_id, *next_active_pane); self.active_panes.insert(client_id, *next_active_pane);
} }
} }
} },
None => self.active_panes.clear(), None => self.active_panes.clear(),
} }
} }

View File

@ -1574,12 +1574,12 @@ impl<'a> TiledPaneGrid<'a> {
for pane_id in panes { for pane_id in panes {
self.increase_pane_width(pane_id, width); self.increase_pane_width(pane_id, width);
} }
} },
Direction::Vertical => { Direction::Vertical => {
for pane_id in panes { for pane_id in panes {
self.increase_pane_height(pane_id, height); self.increase_pane_height(pane_id, height);
} }
} },
}; };
} }
pub fn fill_space_over_pane(&mut self, id: PaneId) -> bool { pub fn fill_space_over_pane(&mut self, id: PaneId) -> bool {

View File

@ -96,7 +96,7 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<LayoutFromYaml>) {
client_or_tab_index, client_or_tab_index,
)) ))
.unwrap(); .unwrap();
} },
PtyInstruction::OpenInPlaceEditor(temp_file, line_number, client_id) => { PtyInstruction::OpenInPlaceEditor(temp_file, line_number, client_id) => {
match pty.spawn_terminal( match pty.spawn_terminal(
Some(TerminalAction::OpenFile(temp_file, line_number)), Some(TerminalAction::OpenFile(temp_file, line_number)),
@ -110,12 +110,12 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<LayoutFromYaml>) {
client_id, client_id,
)) ))
.unwrap(); .unwrap();
} },
Err(e) => { Err(e) => {
log::error!("Failed to open editor: {}", e); log::error!("Failed to open editor: {}", e);
},
} }
} },
}
PtyInstruction::SpawnTerminalVertically(terminal_action, client_id) => { PtyInstruction::SpawnTerminalVertically(terminal_action, client_id) => {
let pid = pty let pid = pty
.spawn_terminal(terminal_action, ClientOrTabIndex::ClientId(client_id)) .spawn_terminal(terminal_action, ClientOrTabIndex::ClientId(client_id))
@ -127,7 +127,7 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<LayoutFromYaml>) {
client_id, client_id,
)) ))
.unwrap(); .unwrap();
} },
PtyInstruction::SpawnTerminalHorizontally(terminal_action, client_id) => { PtyInstruction::SpawnTerminalHorizontally(terminal_action, client_id) => {
let pid = pty let pid = pty
.spawn_terminal(terminal_action, ClientOrTabIndex::ClientId(client_id)) .spawn_terminal(terminal_action, ClientOrTabIndex::ClientId(client_id))
@ -139,16 +139,16 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<LayoutFromYaml>) {
client_id, client_id,
)) ))
.unwrap(); .unwrap();
} },
PtyInstruction::UpdateActivePane(pane_id, client_id) => { PtyInstruction::UpdateActivePane(pane_id, client_id) => {
pty.set_active_pane(pane_id, client_id); pty.set_active_pane(pane_id, client_id);
} },
PtyInstruction::GoToTab(tab_index, client_id) => { PtyInstruction::GoToTab(tab_index, client_id) => {
pty.bus pty.bus
.senders .senders
.send_to_screen(ScreenInstruction::GoToTab(tab_index, Some(client_id))) .send_to_screen(ScreenInstruction::GoToTab(tab_index, Some(client_id)))
.unwrap(); .unwrap();
} },
PtyInstruction::NewTab(terminal_action, tab_layout, client_id) => { PtyInstruction::NewTab(terminal_action, tab_layout, client_id) => {
let tab_name = tab_layout.as_ref().and_then(|layout| { let tab_name = tab_layout.as_ref().and_then(|layout| {
if layout.name.is_empty() { if layout.name.is_empty() {
@ -178,21 +178,21 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<LayoutFromYaml>) {
)) ))
.unwrap(); .unwrap();
} }
} },
PtyInstruction::ClosePane(id) => { PtyInstruction::ClosePane(id) => {
pty.close_pane(id); pty.close_pane(id);
pty.bus pty.bus
.senders .senders
.send_to_server(ServerInstruction::UnblockInputThread) .send_to_server(ServerInstruction::UnblockInputThread)
.unwrap(); .unwrap();
} },
PtyInstruction::CloseTab(ids) => { PtyInstruction::CloseTab(ids) => {
pty.close_tab(ids); pty.close_tab(ids);
pty.bus pty.bus
.senders .senders
.send_to_server(ServerInstruction::UnblockInputThread) .send_to_server(ServerInstruction::UnblockInputThread)
.unwrap(); .unwrap();
} },
PtyInstruction::Exit => break, PtyInstruction::Exit => break,
} }
} }
@ -270,7 +270,7 @@ fn stream_terminal_bytes(
// next read does not need a deadline as we just rendered everything // next read does not need a deadline as we just rendered everything
render_deadline = None; render_deadline = None;
last_render = Instant::now(); last_render = Instant::now();
} },
ReadResult::Ok(n_bytes) => { ReadResult::Ok(n_bytes) => {
let bytes = &buf[..n_bytes]; let bytes = &buf[..n_bytes];
if debug { if debug {
@ -284,7 +284,7 @@ fn stream_terminal_bytes(
// if we already have a render_deadline we keep it, otherwise we set it // if we already have a render_deadline we keep it, otherwise we set it
// to RENDER_PAUSE since the last time we rendered. // to RENDER_PAUSE since the last time we rendered.
render_deadline.get_or_insert(last_render + RENDER_PAUSE); render_deadline.get_or_insert(last_render + RENDER_PAUSE);
} },
} }
} }
async_send_to_screen(senders.clone(), ScreenInstruction::Render).await; async_send_to_screen(senders.clone(), ScreenInstruction::Render).await;
@ -344,10 +344,10 @@ impl Pty {
terminal_action.unwrap_or_else(|| self.get_default_terminal()); terminal_action.unwrap_or_else(|| self.get_default_terminal());
self.fill_cwd(&mut terminal_action, client_id); self.fill_cwd(&mut terminal_action, client_id);
terminal_action terminal_action
} },
ClientOrTabIndex::TabIndex(_) => { ClientOrTabIndex::TabIndex(_) => {
terminal_action.unwrap_or_else(|| self.get_default_terminal()) terminal_action.unwrap_or_else(|| self.get_default_terminal())
} },
}; };
let quit_cb = Box::new({ let quit_cb = Box::new({
let senders = self.bus.senders.clone(); let senders = self.bus.senders.clone();
@ -400,7 +400,7 @@ impl Pty {
.unwrap(); // TODO: handle error here .unwrap(); // TODO: handle error here
self.id_to_child_pid.insert(pid_primary, child_fd); self.id_to_child_pid.insert(pid_primary, child_fd);
new_pane_pids.push(pid_primary); new_pane_pids.push(pid_primary);
} },
None => { None => {
let (pid_primary, child_fd): (RawFd, RawFd) = self let (pid_primary, child_fd): (RawFd, RawFd) = self
.bus .bus
@ -411,9 +411,9 @@ impl Pty {
.unwrap(); // TODO: handle error here .unwrap(); // TODO: handle error here
self.id_to_child_pid.insert(pid_primary, child_fd); self.id_to_child_pid.insert(pid_primary, child_fd);
new_pane_pids.push(pid_primary); new_pane_pids.push(pid_primary);
} },
// Investigate moving plugin loading to here. // Investigate moving plugin loading to here.
Some(Run::Plugin(_)) => {} Some(Run::Plugin(_)) => {},
} }
} }
self.bus self.bus
@ -447,7 +447,7 @@ impl Pty {
.kill(Pid::from_raw(child_fd)) .kill(Pid::from_raw(child_fd))
.unwrap(); .unwrap();
}); });
} },
PaneId::Plugin(pid) => drop( PaneId::Plugin(pid) => drop(
self.bus self.bus
.senders .senders

View File

@ -30,10 +30,10 @@ pub(crate) fn pty_writer_main(bus: Bus<PtyWriteInstruction>) {
if let Err(e) = os_input.tcdrain(terminal_id) { if let Err(e) = os_input.tcdrain(terminal_id) {
log::error!("failed to drain terminal: {}", e); log::error!("failed to drain terminal: {}", e);
}; };
} },
PtyWriteInstruction::Exit => { PtyWriteInstruction::Exit => {
break; break;
} },
} }
} }
} }

View File

@ -43,7 +43,7 @@ fn route_action(
.senders .senders
.send_to_screen(ScreenInstruction::ToggleTab(client_id)) .send_to_screen(ScreenInstruction::ToggleTab(client_id))
.unwrap(); .unwrap();
} },
Action::Write(val) => { Action::Write(val) => {
session session
.senders .senders
@ -53,7 +53,7 @@ fn route_action(
.senders .senders
.send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id))
.unwrap(); .unwrap();
} },
Action::WriteChars(val) => { Action::WriteChars(val) => {
session session
.senders .senders
@ -64,7 +64,7 @@ fn route_action(
.senders .senders
.send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id))
.unwrap(); .unwrap();
} },
Action::SwitchToMode(mode) => { Action::SwitchToMode(mode) => {
let style = session.style; let style = session.style;
// TODO: use the palette from the client and remove it from the server os api // TODO: use the palette from the client and remove it from the server os api
@ -89,7 +89,7 @@ fn route_action(
.senders .senders
.send_to_screen(ScreenInstruction::Render) .send_to_screen(ScreenInstruction::Render)
.unwrap(); .unwrap();
} },
Action::Resize(direction) => { Action::Resize(direction) => {
let screen_instr = match direction { let screen_instr = match direction {
ResizeDirection::Left => ScreenInstruction::ResizeLeft(client_id), ResizeDirection::Left => ScreenInstruction::ResizeLeft(client_id),
@ -100,25 +100,25 @@ fn route_action(
ResizeDirection::Decrease => ScreenInstruction::ResizeDecrease(client_id), ResizeDirection::Decrease => ScreenInstruction::ResizeDecrease(client_id),
}; };
session.senders.send_to_screen(screen_instr).unwrap(); session.senders.send_to_screen(screen_instr).unwrap();
} },
Action::SwitchFocus => { Action::SwitchFocus => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::SwitchFocus(client_id)) .send_to_screen(ScreenInstruction::SwitchFocus(client_id))
.unwrap(); .unwrap();
} },
Action::FocusNextPane => { Action::FocusNextPane => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::FocusNextPane(client_id)) .send_to_screen(ScreenInstruction::FocusNextPane(client_id))
.unwrap(); .unwrap();
} },
Action::FocusPreviousPane => { Action::FocusPreviousPane => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::FocusPreviousPane(client_id)) .send_to_screen(ScreenInstruction::FocusPreviousPane(client_id))
.unwrap(); .unwrap();
} },
Action::MoveFocus(direction) => { Action::MoveFocus(direction) => {
let screen_instr = match direction { let screen_instr = match direction {
Direction::Left => ScreenInstruction::MoveFocusLeft(client_id), Direction::Left => ScreenInstruction::MoveFocusLeft(client_id),
@ -127,7 +127,7 @@ fn route_action(
Direction::Down => ScreenInstruction::MoveFocusDown(client_id), Direction::Down => ScreenInstruction::MoveFocusDown(client_id),
}; };
session.senders.send_to_screen(screen_instr).unwrap(); session.senders.send_to_screen(screen_instr).unwrap();
} },
Action::MoveFocusOrTab(direction) => { Action::MoveFocusOrTab(direction) => {
let screen_instr = match direction { let screen_instr = match direction {
Direction::Left => ScreenInstruction::MoveFocusLeftOrPreviousTab(client_id), Direction::Left => ScreenInstruction::MoveFocusLeftOrPreviousTab(client_id),
@ -135,7 +135,7 @@ fn route_action(
_ => unreachable!(), _ => unreachable!(),
}; };
session.senders.send_to_screen(screen_instr).unwrap(); session.senders.send_to_screen(screen_instr).unwrap();
} },
Action::MovePane(direction) => { Action::MovePane(direction) => {
let screen_instr = match direction { let screen_instr = match direction {
Some(Direction::Left) => ScreenInstruction::MovePaneLeft(client_id), Some(Direction::Left) => ScreenInstruction::MovePaneLeft(client_id),
@ -145,85 +145,85 @@ fn route_action(
None => ScreenInstruction::MovePane(client_id), None => ScreenInstruction::MovePane(client_id),
}; };
session.senders.send_to_screen(screen_instr).unwrap(); session.senders.send_to_screen(screen_instr).unwrap();
} },
Action::DumpScreen(val) => { Action::DumpScreen(val) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::DumpScreen(val, client_id)) .send_to_screen(ScreenInstruction::DumpScreen(val, client_id))
.unwrap(); .unwrap();
} },
Action::EditScrollback => { Action::EditScrollback => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::EditScrollback(client_id)) .send_to_screen(ScreenInstruction::EditScrollback(client_id))
.unwrap(); .unwrap();
} },
Action::ScrollUp => { Action::ScrollUp => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::ScrollUp(client_id)) .send_to_screen(ScreenInstruction::ScrollUp(client_id))
.unwrap(); .unwrap();
} },
Action::ScrollUpAt(point) => { Action::ScrollUpAt(point) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::ScrollUpAt(point, client_id)) .send_to_screen(ScreenInstruction::ScrollUpAt(point, client_id))
.unwrap(); .unwrap();
} },
Action::ScrollDown => { Action::ScrollDown => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::ScrollDown(client_id)) .send_to_screen(ScreenInstruction::ScrollDown(client_id))
.unwrap(); .unwrap();
} },
Action::ScrollDownAt(point) => { Action::ScrollDownAt(point) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::ScrollDownAt(point, client_id)) .send_to_screen(ScreenInstruction::ScrollDownAt(point, client_id))
.unwrap(); .unwrap();
} },
Action::ScrollToBottom => { Action::ScrollToBottom => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::ScrollToBottom(client_id)) .send_to_screen(ScreenInstruction::ScrollToBottom(client_id))
.unwrap(); .unwrap();
} },
Action::PageScrollUp => { Action::PageScrollUp => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::PageScrollUp(client_id)) .send_to_screen(ScreenInstruction::PageScrollUp(client_id))
.unwrap(); .unwrap();
} },
Action::PageScrollDown => { Action::PageScrollDown => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::PageScrollDown(client_id)) .send_to_screen(ScreenInstruction::PageScrollDown(client_id))
.unwrap(); .unwrap();
} },
Action::HalfPageScrollUp => { Action::HalfPageScrollUp => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::HalfPageScrollUp(client_id)) .send_to_screen(ScreenInstruction::HalfPageScrollUp(client_id))
.unwrap(); .unwrap();
} },
Action::HalfPageScrollDown => { Action::HalfPageScrollDown => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::HalfPageScrollDown(client_id)) .send_to_screen(ScreenInstruction::HalfPageScrollDown(client_id))
.unwrap(); .unwrap();
} },
Action::ToggleFocusFullscreen => { Action::ToggleFocusFullscreen => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::ToggleActiveTerminalFullscreen(client_id)) .send_to_screen(ScreenInstruction::ToggleActiveTerminalFullscreen(client_id))
.unwrap(); .unwrap();
} },
Action::TogglePaneFrames => { Action::TogglePaneFrames => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::TogglePaneFrames) .send_to_screen(ScreenInstruction::TogglePaneFrames)
.unwrap(); .unwrap();
} },
Action::NewPane(direction) => { Action::NewPane(direction) => {
let shell = session.default_shell.clone(); let shell = session.default_shell.clone();
let pty_instr = match direction { let pty_instr = match direction {
@ -232,18 +232,18 @@ fn route_action(
Some(Direction::Up) => PtyInstruction::SpawnTerminalHorizontally(shell, client_id), Some(Direction::Up) => PtyInstruction::SpawnTerminalHorizontally(shell, client_id),
Some(Direction::Down) => { Some(Direction::Down) => {
PtyInstruction::SpawnTerminalHorizontally(shell, client_id) PtyInstruction::SpawnTerminalHorizontally(shell, client_id)
} },
// No direction specified - try to put it in the biggest available spot // No direction specified - try to put it in the biggest available spot
None => PtyInstruction::SpawnTerminal(shell, ClientOrTabIndex::ClientId(client_id)), None => PtyInstruction::SpawnTerminal(shell, ClientOrTabIndex::ClientId(client_id)),
}; };
session.senders.send_to_pty(pty_instr).unwrap(); session.senders.send_to_pty(pty_instr).unwrap();
} },
Action::TogglePaneEmbedOrFloating => { Action::TogglePaneEmbedOrFloating => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::TogglePaneEmbedOrFloating(client_id)) .send_to_screen(ScreenInstruction::TogglePaneEmbedOrFloating(client_id))
.unwrap(); .unwrap();
} },
Action::ToggleFloatingPanes => { Action::ToggleFloatingPanes => {
session session
.senders .senders
@ -252,139 +252,139 @@ fn route_action(
session.default_shell.clone(), session.default_shell.clone(),
)) ))
.unwrap(); .unwrap();
} },
Action::PaneNameInput(c) => { Action::PaneNameInput(c) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::UpdatePaneName(c, client_id)) .send_to_screen(ScreenInstruction::UpdatePaneName(c, client_id))
.unwrap(); .unwrap();
} },
Action::Run(command) => { Action::Run(command) => {
let run_cmd = Some(TerminalAction::RunCommand(command.clone().into())); let run_cmd = Some(TerminalAction::RunCommand(command.clone().into()));
let pty_instr = match command.direction { let pty_instr = match command.direction {
Some(Direction::Left) => { Some(Direction::Left) => {
PtyInstruction::SpawnTerminalVertically(run_cmd, client_id) PtyInstruction::SpawnTerminalVertically(run_cmd, client_id)
} },
Some(Direction::Right) => { Some(Direction::Right) => {
PtyInstruction::SpawnTerminalVertically(run_cmd, client_id) PtyInstruction::SpawnTerminalVertically(run_cmd, client_id)
} },
Some(Direction::Up) => { Some(Direction::Up) => {
PtyInstruction::SpawnTerminalHorizontally(run_cmd, client_id) PtyInstruction::SpawnTerminalHorizontally(run_cmd, client_id)
} },
Some(Direction::Down) => { Some(Direction::Down) => {
PtyInstruction::SpawnTerminalHorizontally(run_cmd, client_id) PtyInstruction::SpawnTerminalHorizontally(run_cmd, client_id)
} },
// No direction specified - try to put it in the biggest available spot // No direction specified - try to put it in the biggest available spot
None => { None => {
PtyInstruction::SpawnTerminal(run_cmd, ClientOrTabIndex::ClientId(client_id)) PtyInstruction::SpawnTerminal(run_cmd, ClientOrTabIndex::ClientId(client_id))
} },
}; };
session.senders.send_to_pty(pty_instr).unwrap(); session.senders.send_to_pty(pty_instr).unwrap();
} },
Action::CloseFocus => { Action::CloseFocus => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::CloseFocusedPane(client_id)) .send_to_screen(ScreenInstruction::CloseFocusedPane(client_id))
.unwrap(); .unwrap();
} },
Action::NewTab(tab_layout) => { Action::NewTab(tab_layout) => {
let shell = session.default_shell.clone(); let shell = session.default_shell.clone();
session session
.senders .senders
.send_to_pty(PtyInstruction::NewTab(shell, tab_layout, client_id)) .send_to_pty(PtyInstruction::NewTab(shell, tab_layout, client_id))
.unwrap(); .unwrap();
} },
Action::GoToNextTab => { Action::GoToNextTab => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::SwitchTabNext(client_id)) .send_to_screen(ScreenInstruction::SwitchTabNext(client_id))
.unwrap(); .unwrap();
} },
Action::GoToPreviousTab => { Action::GoToPreviousTab => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::SwitchTabPrev(client_id)) .send_to_screen(ScreenInstruction::SwitchTabPrev(client_id))
.unwrap(); .unwrap();
} },
Action::ToggleActiveSyncTab => { Action::ToggleActiveSyncTab => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::ToggleActiveSyncTab(client_id)) .send_to_screen(ScreenInstruction::ToggleActiveSyncTab(client_id))
.unwrap(); .unwrap();
} },
Action::CloseTab => { Action::CloseTab => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::CloseTab(client_id)) .send_to_screen(ScreenInstruction::CloseTab(client_id))
.unwrap(); .unwrap();
} },
Action::GoToTab(i) => { Action::GoToTab(i) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::GoToTab(i, Some(client_id))) .send_to_screen(ScreenInstruction::GoToTab(i, Some(client_id)))
.unwrap(); .unwrap();
} },
Action::TabNameInput(c) => { Action::TabNameInput(c) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::UpdateTabName(c, client_id)) .send_to_screen(ScreenInstruction::UpdateTabName(c, client_id))
.unwrap(); .unwrap();
} },
Action::Quit => { Action::Quit => {
to_server to_server
.send(ServerInstruction::ClientExit(client_id)) .send(ServerInstruction::ClientExit(client_id))
.unwrap(); .unwrap();
should_break = true; should_break = true;
} },
Action::Detach => { Action::Detach => {
to_server to_server
.send(ServerInstruction::DetachSession(client_id)) .send(ServerInstruction::DetachSession(client_id))
.unwrap(); .unwrap();
should_break = true; should_break = true;
} },
Action::LeftClick(point) => { Action::LeftClick(point) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::LeftClick(point, client_id)) .send_to_screen(ScreenInstruction::LeftClick(point, client_id))
.unwrap(); .unwrap();
} },
Action::RightClick(point) => { Action::RightClick(point) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::RightClick(point, client_id)) .send_to_screen(ScreenInstruction::RightClick(point, client_id))
.unwrap(); .unwrap();
} },
Action::MouseRelease(point) => { Action::MouseRelease(point) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::MouseRelease(point, client_id)) .send_to_screen(ScreenInstruction::MouseRelease(point, client_id))
.unwrap(); .unwrap();
} },
Action::MouseHold(point) => { Action::MouseHold(point) => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::MouseHold(point, client_id)) .send_to_screen(ScreenInstruction::MouseHold(point, client_id))
.unwrap(); .unwrap();
} },
Action::Copy => { Action::Copy => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::Copy(client_id)) .send_to_screen(ScreenInstruction::Copy(client_id))
.unwrap(); .unwrap();
} },
Action::Confirm => { Action::Confirm => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::ConfirmPrompt(client_id)) .send_to_screen(ScreenInstruction::ConfirmPrompt(client_id))
.unwrap(); .unwrap();
} },
Action::Deny => { Action::Deny => {
session session
.senders .senders
.send_to_screen(ScreenInstruction::DenyPrompt(client_id)) .send_to_screen(ScreenInstruction::DenyPrompt(client_id))
.unwrap(); .unwrap();
} },
#[allow(clippy::single_match)] #[allow(clippy::single_match)]
Action::SkipConfirm(action) => match *action { Action::SkipConfirm(action) => match *action {
Action::Quit => { Action::Quit => {
@ -392,10 +392,10 @@ fn route_action(
.send(ServerInstruction::ClientExit(client_id)) .send(ServerInstruction::ClientExit(client_id))
.unwrap(); .unwrap();
should_break = true; should_break = true;
}
_ => {}
}, },
Action::NoOp => {} _ => {},
},
Action::NoOp => {},
} }
should_break should_break
} }
@ -433,7 +433,7 @@ pub(crate) fn route_thread_main(
break; break;
} }
} }
} },
ClientToServerMsg::TerminalResize(new_size) => { ClientToServerMsg::TerminalResize(new_size) => {
session_state session_state
.write() .write()
@ -450,7 +450,7 @@ pub(crate) fn route_thread_main(
.senders .senders
.send_to_screen(ScreenInstruction::TerminalResize(min_size)) .send_to_screen(ScreenInstruction::TerminalResize(min_size))
.unwrap(); .unwrap();
} },
ClientToServerMsg::TerminalPixelDimensions(pixel_dimensions) => { ClientToServerMsg::TerminalPixelDimensions(pixel_dimensions) => {
rlocked_sessions rlocked_sessions
.as_ref() .as_ref()
@ -460,7 +460,7 @@ pub(crate) fn route_thread_main(
pixel_dimensions, pixel_dimensions,
)) ))
.unwrap(); .unwrap();
} },
ClientToServerMsg::BackgroundColor(background_color_instruction) => { ClientToServerMsg::BackgroundColor(background_color_instruction) => {
rlocked_sessions rlocked_sessions
.as_ref() .as_ref()
@ -470,7 +470,7 @@ pub(crate) fn route_thread_main(
background_color_instruction, background_color_instruction,
)) ))
.unwrap(); .unwrap();
} },
ClientToServerMsg::ForegroundColor(foreground_color_instruction) => { ClientToServerMsg::ForegroundColor(foreground_color_instruction) => {
rlocked_sessions rlocked_sessions
.as_ref() .as_ref()
@ -480,7 +480,7 @@ pub(crate) fn route_thread_main(
foreground_color_instruction, foreground_color_instruction,
)) ))
.unwrap(); .unwrap();
} },
ClientToServerMsg::NewClient( ClientToServerMsg::NewClient(
client_attributes, client_attributes,
cli_args, cli_args,
@ -497,27 +497,27 @@ pub(crate) fn route_thread_main(
plugin_config, plugin_config,
); );
to_server.send(new_client_instruction).unwrap(); to_server.send(new_client_instruction).unwrap();
} },
ClientToServerMsg::AttachClient(client_attributes, opts) => { ClientToServerMsg::AttachClient(client_attributes, opts) => {
let attach_client_instruction = let attach_client_instruction =
ServerInstruction::AttachClient(client_attributes, opts, client_id); ServerInstruction::AttachClient(client_attributes, opts, client_id);
to_server.send(attach_client_instruction).unwrap(); to_server.send(attach_client_instruction).unwrap();
} },
ClientToServerMsg::ClientExited => { ClientToServerMsg::ClientExited => {
// we don't unwrap this because we don't really care if there's an error here (eg. // we don't unwrap this because we don't really care if there's an error here (eg.
// if the main server thread exited before this router thread did) // if the main server thread exited before this router thread did)
let _ = to_server.send(ServerInstruction::RemoveClient(client_id)); let _ = to_server.send(ServerInstruction::RemoveClient(client_id));
break; break;
} },
ClientToServerMsg::KillSession => { ClientToServerMsg::KillSession => {
to_server.send(ServerInstruction::KillSession).unwrap(); to_server.send(ServerInstruction::KillSession).unwrap();
} },
ClientToServerMsg::ConnStatus => { ClientToServerMsg::ConnStatus => {
let _ = to_server.send(ServerInstruction::ConnStatus(client_id)); let _ = to_server.send(ServerInstruction::ConnStatus(client_id));
break; break;
},
} }
} },
}
None => { None => {
log::error!("Received empty message from client"); log::error!("Received empty message from client");
os_input.send_to_client( os_input.send_to_client(
@ -527,7 +527,7 @@ pub(crate) fn route_thread_main(
)), )),
); );
break; break;
} },
} }
} }
} }

View File

@ -120,7 +120,7 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::OpenInPlaceEditor(..) => ScreenContext::OpenInPlaceEditor, ScreenInstruction::OpenInPlaceEditor(..) => ScreenContext::OpenInPlaceEditor,
ScreenInstruction::TogglePaneEmbedOrFloating(..) => { ScreenInstruction::TogglePaneEmbedOrFloating(..) => {
ScreenContext::TogglePaneEmbedOrFloating ScreenContext::TogglePaneEmbedOrFloating
} },
ScreenInstruction::ToggleFloatingPanes(..) => ScreenContext::ToggleFloatingPanes, ScreenInstruction::ToggleFloatingPanes(..) => ScreenContext::ToggleFloatingPanes,
ScreenInstruction::HorizontalSplit(..) => ScreenContext::HorizontalSplit, ScreenInstruction::HorizontalSplit(..) => ScreenContext::HorizontalSplit,
ScreenInstruction::VerticalSplit(..) => ScreenContext::VerticalSplit, ScreenInstruction::VerticalSplit(..) => ScreenContext::VerticalSplit,
@ -137,13 +137,13 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::MoveFocusLeft(..) => ScreenContext::MoveFocusLeft, ScreenInstruction::MoveFocusLeft(..) => ScreenContext::MoveFocusLeft,
ScreenInstruction::MoveFocusLeftOrPreviousTab(..) => { ScreenInstruction::MoveFocusLeftOrPreviousTab(..) => {
ScreenContext::MoveFocusLeftOrPreviousTab ScreenContext::MoveFocusLeftOrPreviousTab
} },
ScreenInstruction::MoveFocusDown(..) => ScreenContext::MoveFocusDown, ScreenInstruction::MoveFocusDown(..) => ScreenContext::MoveFocusDown,
ScreenInstruction::MoveFocusUp(..) => ScreenContext::MoveFocusUp, ScreenInstruction::MoveFocusUp(..) => ScreenContext::MoveFocusUp,
ScreenInstruction::MoveFocusRight(..) => ScreenContext::MoveFocusRight, ScreenInstruction::MoveFocusRight(..) => ScreenContext::MoveFocusRight,
ScreenInstruction::MoveFocusRightOrNextTab(..) => { ScreenInstruction::MoveFocusRightOrNextTab(..) => {
ScreenContext::MoveFocusRightOrNextTab ScreenContext::MoveFocusRightOrNextTab
} },
ScreenInstruction::MovePane(..) => ScreenContext::MovePane, ScreenInstruction::MovePane(..) => ScreenContext::MovePane,
ScreenInstruction::MovePaneDown(..) => ScreenContext::MovePaneDown, ScreenInstruction::MovePaneDown(..) => ScreenContext::MovePaneDown,
ScreenInstruction::MovePaneUp(..) => ScreenContext::MovePaneUp, ScreenInstruction::MovePaneUp(..) => ScreenContext::MovePaneUp,
@ -163,7 +163,7 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::CloseFocusedPane(..) => ScreenContext::CloseFocusedPane, ScreenInstruction::CloseFocusedPane(..) => ScreenContext::CloseFocusedPane,
ScreenInstruction::ToggleActiveTerminalFullscreen(..) => { ScreenInstruction::ToggleActiveTerminalFullscreen(..) => {
ScreenContext::ToggleActiveTerminalFullscreen ScreenContext::ToggleActiveTerminalFullscreen
} },
ScreenInstruction::TogglePaneFrames => ScreenContext::TogglePaneFrames, ScreenInstruction::TogglePaneFrames => ScreenContext::TogglePaneFrames,
ScreenInstruction::SetSelectable(..) => ScreenContext::SetSelectable, ScreenInstruction::SetSelectable(..) => ScreenContext::SetSelectable,
ScreenInstruction::ClosePane(..) => ScreenContext::ClosePane, ScreenInstruction::ClosePane(..) => ScreenContext::ClosePane,
@ -177,13 +177,13 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::TerminalResize(..) => ScreenContext::TerminalResize, ScreenInstruction::TerminalResize(..) => ScreenContext::TerminalResize,
ScreenInstruction::TerminalPixelDimensions(..) => { ScreenInstruction::TerminalPixelDimensions(..) => {
ScreenContext::TerminalPixelDimensions ScreenContext::TerminalPixelDimensions
} },
ScreenInstruction::TerminalBackgroundColor(..) => { ScreenInstruction::TerminalBackgroundColor(..) => {
ScreenContext::TerminalBackgroundColor ScreenContext::TerminalBackgroundColor
} },
ScreenInstruction::TerminalForegroundColor(..) => { ScreenInstruction::TerminalForegroundColor(..) => {
ScreenContext::TerminalForegroundColor ScreenContext::TerminalForegroundColor
} },
ScreenInstruction::ChangeMode(..) => ScreenContext::ChangeMode, ScreenInstruction::ChangeMode(..) => ScreenContext::ChangeMode,
ScreenInstruction::ToggleActiveSyncTab(..) => ScreenContext::ToggleActiveSyncTab, ScreenInstruction::ToggleActiveSyncTab(..) => ScreenContext::ToggleActiveSyncTab,
ScreenInstruction::ScrollUpAt(..) => ScreenContext::ScrollUpAt, ScreenInstruction::ScrollUpAt(..) => ScreenContext::ScrollUpAt,
@ -359,10 +359,10 @@ impl Screen {
let client_tab_history = self.tab_history.entry(client_id).or_insert_with(Vec::new); let client_tab_history = self.tab_history.entry(client_id).or_insert_with(Vec::new);
client_tab_history.retain(|&e| e != new_tab_index); client_tab_history.retain(|&e| e != new_tab_index);
client_tab_history.push(old_active_index); client_tab_history.push(old_active_index);
} },
None => { None => {
self.active_tab_indices.insert(client_id, new_tab_index); self.active_tab_indices.insert(client_id, new_tab_index);
} },
} }
} }
/// A helper function to switch to a new tab at specified position. /// A helper function to switch to a new tab at specified position.
@ -725,17 +725,17 @@ impl Screen {
match s { match s {
"\0" => { "\0" => {
active_tab.name = String::new(); active_tab.name = String::new();
} },
"\u{007F}" | "\u{0008}" => { "\u{007F}" | "\u{0008}" => {
// delete and backspace keys // delete and backspace keys
active_tab.name.pop(); active_tab.name.pop();
} },
c => { c => {
// It only allows printable unicode // It only allows printable unicode
if buf.iter().all(|u| matches!(u, 0x20..=0x7E)) { if buf.iter().all(|u| matches!(u, 0x20..=0x7E)) {
active_tab.name.push_str(c); active_tab.name.push_str(c);
} }
} },
} }
self.update_tabs(); self.update_tabs();
} else { } else {
@ -842,10 +842,10 @@ pub(crate) fn screen_thread_main(
break; break;
} }
} }
} },
ScreenInstruction::Render => { ScreenInstruction::Render => {
screen.render(); screen.render();
} },
ScreenInstruction::NewPane(pid, client_or_tab_index) => { ScreenInstruction::NewPane(pid, client_or_tab_index) => {
match client_or_tab_index { match client_or_tab_index {
ClientOrTabIndex::ClientId(client_id) => { ClientOrTabIndex::ClientId(client_id) => {
@ -854,14 +854,14 @@ pub(crate) fn screen_thread_main(
} else { } else {
log::error!("Active tab not found for client id: {:?}", client_id); log::error!("Active tab not found for client id: {:?}", client_id);
} }
} },
ClientOrTabIndex::TabIndex(tab_index) => { ClientOrTabIndex::TabIndex(tab_index) => {
if let Some(active_tab) = screen.tabs.get_mut(&tab_index) { if let Some(active_tab) = screen.tabs.get_mut(&tab_index) {
active_tab.new_pane(pid, None); active_tab.new_pane(pid, None);
} else { } else {
log::error!("Tab index not found: {:?}", tab_index); log::error!("Tab index not found: {:?}", tab_index);
} }
} },
}; };
screen screen
.bus .bus
@ -871,7 +871,7 @@ pub(crate) fn screen_thread_main(
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::OpenInPlaceEditor(pid, client_id) => { ScreenInstruction::OpenInPlaceEditor(pid, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.suppress_active_pane(pid, client_id); active_tab.suppress_active_pane(pid, client_id);
@ -887,7 +887,7 @@ pub(crate) fn screen_thread_main(
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::TogglePaneEmbedOrFloating(client_id) => { ScreenInstruction::TogglePaneEmbedOrFloating(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.toggle_pane_embed_or_floating(client_id); active_tab.toggle_pane_embed_or_floating(client_id);
@ -901,7 +901,7 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins
screen.render(); screen.render();
} },
ScreenInstruction::ToggleFloatingPanes(client_id, default_shell) => { ScreenInstruction::ToggleFloatingPanes(client_id, default_shell) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.toggle_floating_panes(client_id, default_shell); active_tab.toggle_floating_panes(client_id, default_shell);
@ -915,7 +915,7 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins
screen.render(); screen.render();
} },
ScreenInstruction::HorizontalSplit(pid, client_id) => { ScreenInstruction::HorizontalSplit(pid, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.horizontal_split(pid, client_id); active_tab.horizontal_split(pid, client_id);
@ -930,7 +930,7 @@ pub(crate) fn screen_thread_main(
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::VerticalSplit(pid, client_id) => { ScreenInstruction::VerticalSplit(pid, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.vertical_split(pid, client_id); active_tab.vertical_split(pid, client_id);
@ -945,7 +945,7 @@ pub(crate) fn screen_thread_main(
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::WriteCharacter(bytes, client_id) => { ScreenInstruction::WriteCharacter(bytes, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
match active_tab.is_sync_panes_active() { match active_tab.is_sync_panes_active() {
@ -955,7 +955,7 @@ pub(crate) fn screen_thread_main(
} else { } else {
log::error!("Active tab not found for client id: {:?}", client_id); log::error!("Active tab not found for client id: {:?}", client_id);
} }
} },
ScreenInstruction::ResizeLeft(client_id) => { ScreenInstruction::ResizeLeft(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.resize_left(client_id); active_tab.resize_left(client_id);
@ -964,14 +964,14 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ResizeRight(client_id) => { ScreenInstruction::ResizeRight(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.resize_right(client_id); active_tab.resize_right(client_id);
} }
screen.render(); screen.render();
} },
ScreenInstruction::ResizeDown(client_id) => { ScreenInstruction::ResizeDown(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.resize_down(client_id); active_tab.resize_down(client_id);
@ -980,7 +980,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ResizeUp(client_id) => { ScreenInstruction::ResizeUp(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.resize_up(client_id); active_tab.resize_up(client_id);
@ -989,7 +989,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ResizeIncrease(client_id) => { ScreenInstruction::ResizeIncrease(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.resize_increase(client_id); active_tab.resize_increase(client_id);
@ -998,7 +998,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ResizeDecrease(client_id) => { ScreenInstruction::ResizeDecrease(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.resize_decrease(client_id); active_tab.resize_decrease(client_id);
@ -1007,7 +1007,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::SwitchFocus(client_id) => { ScreenInstruction::SwitchFocus(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.focus_next_pane(client_id); active_tab.focus_next_pane(client_id);
@ -1016,7 +1016,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::FocusNextPane(client_id) => { ScreenInstruction::FocusNextPane(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.focus_next_pane(client_id); active_tab.focus_next_pane(client_id);
@ -1025,7 +1025,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::FocusPreviousPane(client_id) => { ScreenInstruction::FocusPreviousPane(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.focus_previous_pane(client_id); active_tab.focus_previous_pane(client_id);
@ -1034,7 +1034,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MoveFocusLeft(client_id) => { ScreenInstruction::MoveFocusLeft(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_focus_left(client_id); active_tab.move_focus_left(client_id);
@ -1043,7 +1043,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MoveFocusLeftOrPreviousTab(client_id) => { ScreenInstruction::MoveFocusLeftOrPreviousTab(client_id) => {
screen.move_focus_left_or_previous_tab(client_id); screen.move_focus_left_or_previous_tab(client_id);
screen screen
@ -1053,7 +1053,7 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.render(); screen.render();
} },
ScreenInstruction::MoveFocusDown(client_id) => { ScreenInstruction::MoveFocusDown(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_focus_down(client_id); active_tab.move_focus_down(client_id);
@ -1062,7 +1062,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MoveFocusRight(client_id) => { ScreenInstruction::MoveFocusRight(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_focus_right(client_id); active_tab.move_focus_right(client_id);
@ -1071,7 +1071,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MoveFocusRightOrNextTab(client_id) => { ScreenInstruction::MoveFocusRightOrNextTab(client_id) => {
screen.move_focus_right_or_next_tab(client_id); screen.move_focus_right_or_next_tab(client_id);
screen screen
@ -1081,7 +1081,7 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.render(); screen.render();
} },
ScreenInstruction::MoveFocusUp(client_id) => { ScreenInstruction::MoveFocusUp(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_focus_up(client_id); active_tab.move_focus_up(client_id);
@ -1090,7 +1090,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::DumpScreen(file, client_id) => { ScreenInstruction::DumpScreen(file, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.dump_active_terminal_screen(Some(file.to_string()), client_id); active_tab.dump_active_terminal_screen(Some(file.to_string()), client_id);
@ -1099,7 +1099,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::EditScrollback(client_id) => { ScreenInstruction::EditScrollback(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.edit_scrollback(client_id); active_tab.edit_scrollback(client_id);
@ -1108,7 +1108,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ScrollUp(client_id) => { ScreenInstruction::ScrollUp(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_active_terminal_up(client_id); active_tab.scroll_active_terminal_up(client_id);
@ -1117,7 +1117,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MovePane(client_id) => { ScreenInstruction::MovePane(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_active_pane(client_id); active_tab.move_active_pane(client_id);
@ -1126,7 +1126,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MovePaneDown(client_id) => { ScreenInstruction::MovePaneDown(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_active_pane_down(client_id); active_tab.move_active_pane_down(client_id);
@ -1135,7 +1135,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MovePaneUp(client_id) => { ScreenInstruction::MovePaneUp(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_active_pane_up(client_id); active_tab.move_active_pane_up(client_id);
@ -1144,7 +1144,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MovePaneRight(client_id) => { ScreenInstruction::MovePaneRight(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_active_pane_right(client_id); active_tab.move_active_pane_right(client_id);
@ -1153,7 +1153,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MovePaneLeft(client_id) => { ScreenInstruction::MovePaneLeft(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.move_active_pane_left(client_id); active_tab.move_active_pane_left(client_id);
@ -1162,7 +1162,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ScrollUpAt(point, client_id) => { ScreenInstruction::ScrollUpAt(point, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_terminal_up(&point, 3, client_id); active_tab.scroll_terminal_up(&point, 3, client_id);
@ -1171,7 +1171,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ScrollDown(client_id) => { ScreenInstruction::ScrollDown(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_active_terminal_down(client_id); active_tab.scroll_active_terminal_down(client_id);
@ -1180,7 +1180,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ScrollDownAt(point, client_id) => { ScreenInstruction::ScrollDownAt(point, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_terminal_down(&point, 3, client_id); active_tab.scroll_terminal_down(&point, 3, client_id);
@ -1189,7 +1189,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ScrollToBottom(client_id) => { ScreenInstruction::ScrollToBottom(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_active_terminal_to_bottom(client_id); active_tab.scroll_active_terminal_to_bottom(client_id);
@ -1198,7 +1198,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::PageScrollUp(client_id) => { ScreenInstruction::PageScrollUp(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_active_terminal_up_page(client_id); active_tab.scroll_active_terminal_up_page(client_id);
@ -1207,7 +1207,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::PageScrollDown(client_id) => { ScreenInstruction::PageScrollDown(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_active_terminal_down_page(client_id); active_tab.scroll_active_terminal_down_page(client_id);
@ -1216,7 +1216,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::HalfPageScrollUp(client_id) => { ScreenInstruction::HalfPageScrollUp(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_active_terminal_up_half_page(client_id); active_tab.scroll_active_terminal_up_half_page(client_id);
@ -1225,7 +1225,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::HalfPageScrollDown(client_id) => { ScreenInstruction::HalfPageScrollDown(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.scroll_active_terminal_down_half_page(client_id); active_tab.scroll_active_terminal_down_half_page(client_id);
@ -1234,7 +1234,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ClearScroll(client_id) => { ScreenInstruction::ClearScroll(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.clear_active_terminal_scroll(client_id); active_tab.clear_active_terminal_scroll(client_id);
@ -1243,7 +1243,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::CloseFocusedPane(client_id) => { ScreenInstruction::CloseFocusedPane(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.close_focused_pane(client_id); active_tab.close_focused_pane(client_id);
@ -1251,7 +1251,7 @@ pub(crate) fn screen_thread_main(
log::error!("Active tab not found for client id: {:?}", client_id); log::error!("Active tab not found for client id: {:?}", client_id);
} }
screen.update_tabs(); // update_tabs eventually calls render through the plugin thread screen.update_tabs(); // update_tabs eventually calls render through the plugin thread
} },
ScreenInstruction::SetSelectable(id, selectable, tab_index) => { ScreenInstruction::SetSelectable(id, selectable, tab_index) => {
screen.get_indexed_tab_mut(tab_index).map_or_else( screen.get_indexed_tab_mut(tab_index).map_or_else(
|| { || {
@ -1265,7 +1265,7 @@ pub(crate) fn screen_thread_main(
); );
screen.render(); screen.render();
} },
ScreenInstruction::ClosePane(id, client_id) => { ScreenInstruction::ClosePane(id, client_id) => {
match client_id { match client_id {
Some(client_id) => { Some(client_id) => {
@ -1276,7 +1276,7 @@ pub(crate) fn screen_thread_main(
log::error!("Active tab not found for client id: {:?}", client_id); log::error!("Active tab not found for client id: {:?}", client_id);
None None
}); });
} },
None => { None => {
for tab in screen.tabs.values_mut() { for tab in screen.tabs.values_mut() {
if tab.get_all_pane_ids().contains(&id) { if tab.get_all_pane_ids().contains(&id) {
@ -1284,10 +1284,10 @@ pub(crate) fn screen_thread_main(
break; break;
} }
} }
} },
} }
screen.update_tabs(); screen.update_tabs();
} },
ScreenInstruction::UpdatePaneName(c, client_id) => { ScreenInstruction::UpdatePaneName(c, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.update_active_pane_name(c, client_id); active_tab.update_active_pane_name(c, client_id);
@ -1296,7 +1296,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::ToggleActiveTerminalFullscreen(client_id) => { ScreenInstruction::ToggleActiveTerminalFullscreen(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.toggle_active_pane_fullscreen(client_id); active_tab.toggle_active_pane_fullscreen(client_id);
@ -1306,14 +1306,14 @@ pub(crate) fn screen_thread_main(
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::TogglePaneFrames => { ScreenInstruction::TogglePaneFrames => {
screen.draw_pane_frames = !screen.draw_pane_frames; screen.draw_pane_frames = !screen.draw_pane_frames;
for tab in screen.tabs.values_mut() { for tab in screen.tabs.values_mut() {
tab.set_pane_frames(screen.draw_pane_frames); tab.set_pane_frames(screen.draw_pane_frames);
} }
screen.render(); screen.render();
} },
ScreenInstruction::SwitchTabNext(client_id) => { ScreenInstruction::SwitchTabNext(client_id) => {
screen.switch_tab_next(client_id); screen.switch_tab_next(client_id);
screen screen
@ -1323,7 +1323,7 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.render(); screen.render();
} },
ScreenInstruction::SwitchTabPrev(client_id) => { ScreenInstruction::SwitchTabPrev(client_id) => {
screen.switch_tab_prev(client_id); screen.switch_tab_prev(client_id);
screen screen
@ -1333,7 +1333,7 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.render(); screen.render();
} },
ScreenInstruction::CloseTab(client_id) => { ScreenInstruction::CloseTab(client_id) => {
screen.close_tab(client_id); screen.close_tab(client_id);
screen screen
@ -1343,7 +1343,7 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.render(); screen.render();
} },
ScreenInstruction::NewTab(layout, new_pane_pids, client_id) => { ScreenInstruction::NewTab(layout, new_pane_pids, client_id) => {
screen.new_tab(layout, new_pane_pids, client_id); screen.new_tab(layout, new_pane_pids, client_id);
screen screen
@ -1353,7 +1353,7 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.render(); screen.render();
} },
ScreenInstruction::GoToTab(tab_index, client_id) => { ScreenInstruction::GoToTab(tab_index, client_id) => {
if let Some(client_id) = if let Some(client_id) =
client_id.or_else(|| screen.active_tab_indices.keys().next().copied()) client_id.or_else(|| screen.active_tab_indices.keys().next().copied())
@ -1367,31 +1367,31 @@ pub(crate) fn screen_thread_main(
screen.render(); screen.render();
} }
} },
ScreenInstruction::UpdateTabName(c, client_id) => { ScreenInstruction::UpdateTabName(c, client_id) => {
screen.update_active_tab_name(c, client_id); screen.update_active_tab_name(c, client_id);
screen.render(); screen.render();
} },
ScreenInstruction::TerminalResize(new_size) => { ScreenInstruction::TerminalResize(new_size) => {
screen.resize_to_screen(new_size); screen.resize_to_screen(new_size);
screen.render(); screen.render();
} },
ScreenInstruction::TerminalPixelDimensions(pixel_dimensions) => { ScreenInstruction::TerminalPixelDimensions(pixel_dimensions) => {
screen.update_pixel_dimensions(pixel_dimensions); screen.update_pixel_dimensions(pixel_dimensions);
} },
ScreenInstruction::TerminalBackgroundColor(background_color_instruction) => { ScreenInstruction::TerminalBackgroundColor(background_color_instruction) => {
screen.update_terminal_background_color(background_color_instruction); screen.update_terminal_background_color(background_color_instruction);
} },
ScreenInstruction::TerminalForegroundColor(background_color_instruction) => { ScreenInstruction::TerminalForegroundColor(background_color_instruction) => {
screen.update_terminal_foreground_color(background_color_instruction); screen.update_terminal_foreground_color(background_color_instruction);
} },
ScreenInstruction::ChangeMode(mode_info, client_id) => { ScreenInstruction::ChangeMode(mode_info, client_id) => {
screen.change_mode(mode_info, client_id); screen.change_mode(mode_info, client_id);
screen.render(); screen.render();
} },
ScreenInstruction::ToggleActiveSyncTab(client_id) => { ScreenInstruction::ToggleActiveSyncTab(client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.toggle_sync_panes_is_active(); active_tab.toggle_sync_panes_is_active();
@ -1401,7 +1401,7 @@ pub(crate) fn screen_thread_main(
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::LeftClick(point, client_id) => { ScreenInstruction::LeftClick(point, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.handle_left_click(&point, client_id); active_tab.handle_left_click(&point, client_id);
@ -1411,7 +1411,7 @@ pub(crate) fn screen_thread_main(
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::RightClick(point, client_id) => { ScreenInstruction::RightClick(point, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.handle_right_click(&point, client_id); active_tab.handle_right_click(&point, client_id);
@ -1421,7 +1421,7 @@ pub(crate) fn screen_thread_main(
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::MouseRelease(point, client_id) => { ScreenInstruction::MouseRelease(point, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.handle_mouse_release(&point, client_id); active_tab.handle_mouse_release(&point, client_id);
@ -1430,7 +1430,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::MouseHold(point, client_id) => { ScreenInstruction::MouseHold(point, client_id) => {
if let Some(active_tab) = screen.get_active_tab_mut(client_id) { if let Some(active_tab) = screen.get_active_tab_mut(client_id) {
active_tab.handle_mouse_hold(&point, client_id); active_tab.handle_mouse_hold(&point, client_id);
@ -1439,7 +1439,7 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::Copy(client_id) => { ScreenInstruction::Copy(client_id) => {
if let Some(active_tab) = screen.get_active_tab(client_id) { if let Some(active_tab) = screen.get_active_tab(client_id) {
active_tab.copy_selection(client_id); active_tab.copy_selection(client_id);
@ -1448,10 +1448,10 @@ pub(crate) fn screen_thread_main(
} }
screen.render(); screen.render();
} },
ScreenInstruction::Exit => { ScreenInstruction::Exit => {
break; break;
} },
ScreenInstruction::ToggleTab(client_id) => { ScreenInstruction::ToggleTab(client_id) => {
screen.toggle_tab(client_id); screen.toggle_tab(client_id);
screen screen
@ -1461,18 +1461,18 @@ pub(crate) fn screen_thread_main(
.unwrap(); .unwrap();
screen.render(); screen.render();
} },
ScreenInstruction::AddClient(client_id) => { ScreenInstruction::AddClient(client_id) => {
screen.add_client(client_id); screen.add_client(client_id);
screen.update_tabs(); screen.update_tabs();
screen.render(); screen.render();
} },
ScreenInstruction::RemoveClient(client_id) => { ScreenInstruction::RemoveClient(client_id) => {
screen.remove_client(client_id); screen.remove_client(client_id);
screen.render(); screen.render();
} },
ScreenInstruction::AddOverlay(overlay, _client_id) => { ScreenInstruction::AddOverlay(overlay, _client_id) => {
screen.get_active_overlays_mut().pop(); screen.get_active_overlays_mut().pop();
screen.get_active_overlays_mut().push(overlay); screen.get_active_overlays_mut().push(overlay);
@ -1481,7 +1481,7 @@ pub(crate) fn screen_thread_main(
.senders .senders
.send_to_server(ServerInstruction::UnblockInputThread) .send_to_server(ServerInstruction::UnblockInputThread)
.unwrap(); .unwrap();
} },
ScreenInstruction::RemoveOverlay(_client_id) => { ScreenInstruction::RemoveOverlay(_client_id) => {
screen.get_active_overlays_mut().pop(); screen.get_active_overlays_mut().pop();
screen.render(); screen.render();
@ -1490,7 +1490,7 @@ pub(crate) fn screen_thread_main(
.senders .senders
.send_to_server(ServerInstruction::UnblockInputThread) .send_to_server(ServerInstruction::UnblockInputThread)
.unwrap(); .unwrap();
} },
ScreenInstruction::ConfirmPrompt(_client_id) => { ScreenInstruction::ConfirmPrompt(_client_id) => {
let overlay = screen.get_active_overlays_mut().pop(); let overlay = screen.get_active_overlays_mut().pop();
let instruction = overlay.and_then(|o| o.prompt_confirm()); let instruction = overlay.and_then(|o| o.prompt_confirm());
@ -1502,7 +1502,7 @@ pub(crate) fn screen_thread_main(
.senders .senders
.send_to_server(ServerInstruction::UnblockInputThread) .send_to_server(ServerInstruction::UnblockInputThread)
.unwrap(); .unwrap();
} },
ScreenInstruction::DenyPrompt(_client_id) => { ScreenInstruction::DenyPrompt(_client_id) => {
screen.get_active_overlays_mut().pop(); screen.get_active_overlays_mut().pop();
screen.render(); screen.render();
@ -1511,7 +1511,7 @@ pub(crate) fn screen_thread_main(
.senders .senders
.send_to_server(ServerInstruction::UnblockInputThread) .send_to_server(ServerInstruction::UnblockInputThread)
.unwrap(); .unwrap();
} },
} }
} }
} }

View File

@ -20,7 +20,7 @@ impl ClipboardProvider {
match &self { match &self {
ClipboardProvider::Command(command) => { ClipboardProvider::Command(command) => {
command.set(content.to_string())?; command.set(content.to_string())?;
} },
ClipboardProvider::Osc52(clipboard) => { ClipboardProvider::Osc52(clipboard) => {
let dest = match clipboard { let dest = match clipboard {
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]
@ -33,7 +33,7 @@ impl ClipboardProvider {
client_ids, client_ids,
&format!("\u{1b}]52;{};{}\u{1b}\\", dest, base64::encode(content)), &format!("\u{1b}]52;{};{}\u{1b}\\", dest, base64::encode(content)),
); );
} },
}; };
Ok(()) Ok(())
} }

View File

@ -474,11 +474,11 @@ impl Tab {
match next_selectable_pane_id { match next_selectable_pane_id {
Some(active_pane_id) => { Some(active_pane_id) => {
self.tiled_panes.focus_pane(active_pane_id, client_id); self.tiled_panes.focus_pane(active_pane_id, client_id);
} },
None => { None => {
// this is very likely a configuration error (layout with no selectable panes) // this is very likely a configuration error (layout with no selectable panes)
self.tiled_panes.clear_active_panes(); self.tiled_panes.clear_active_panes();
} },
} }
} }
} }
@ -628,7 +628,7 @@ impl Tab {
self.floating_panes self.floating_panes
.focus_pane(first_floating_pane_id, client_id); .focus_pane(first_floating_pane_id, client_id);
} }
} },
None => { None => {
// there aren't any floating panes, we need to open a new one // there aren't any floating panes, we need to open a new one
// //
@ -645,7 +645,7 @@ impl Tab {
ClientOrTabIndex::ClientId(client_id), ClientOrTabIndex::ClientId(client_id),
); );
self.senders.send_to_pty(instruction).unwrap(); self.senders.send_to_pty(instruction).unwrap();
} },
} }
self.floating_panes.set_force_render(); self.floating_panes.set_force_render();
} }
@ -729,15 +729,15 @@ impl Tab {
.insert(PaneId::Terminal(pid), replaced_pane); .insert(PaneId::Terminal(pid), replaced_pane);
let current_active_pane = self.get_active_pane(client_id).unwrap(); // this will be the newly replaced pane we just created let current_active_pane = self.get_active_pane(client_id).unwrap(); // this will be the newly replaced pane we just created
resize_pty!(current_active_pane, self.os_api); resize_pty!(current_active_pane, self.os_api);
} },
None => { None => {
log::error!("Could not find editor pane to replace - is no pane focused?") log::error!("Could not find editor pane to replace - is no pane focused?")
},
} }
} },
}
PaneId::Plugin(_pid) => { PaneId::Plugin(_pid) => {
// TBD, currently unsupported // TBD, currently unsupported
} },
} }
} }
pub fn horizontal_split(&mut self, pid: PaneId, client_id: ClientId) { pub fn horizontal_split(&mut self, pid: PaneId, client_id: ClientId) {
@ -944,14 +944,14 @@ impl Tab {
active_terminal_id, active_terminal_id,
)) ))
.unwrap(); .unwrap();
} },
PaneId::Plugin(pid) => { PaneId::Plugin(pid) => {
for key in parse_keys(&input_bytes) { for key in parse_keys(&input_bytes) {
self.senders self.senders
.send_to_plugin(PluginInstruction::Update(Some(pid), None, Event::Key(key))) .send_to_plugin(PluginInstruction::Update(Some(pid), None, Event::Key(key)))
.unwrap() .unwrap()
} }
} },
} }
} }
pub fn get_active_terminal_cursor_position( pub fn get_active_terminal_cursor_position(
@ -1087,11 +1087,11 @@ impl Tab {
); // goto row/col ); // goto row/col
output.add_post_vte_instruction_to_client(client_id, show_cursor); output.add_post_vte_instruction_to_client(client_id, show_cursor);
output.add_post_vte_instruction_to_client(client_id, goto_cursor_position); output.add_post_vte_instruction_to_client(client_id, goto_cursor_position);
} },
None => { None => {
let hide_cursor = "\u{1b}[?25l"; let hide_cursor = "\u{1b}[?25l";
output.add_post_vte_instruction_to_client(client_id, hide_cursor); output.add_post_vte_instruction_to_client(client_id, hide_cursor);
} },
} }
} }
} }
@ -1847,11 +1847,11 @@ impl Tab {
.send_to_server(ServerInstruction::Render(Some(serialized_output))) .send_to_server(ServerInstruction::Render(Some(serialized_output)))
.unwrap(); .unwrap();
Event::CopyToClipboard(self.clipboard_provider.as_copy_destination()) Event::CopyToClipboard(self.clipboard_provider.as_copy_destination())
} },
Err(err) => { Err(err) => {
log::error!("could not write selection to clipboard: {}", err); log::error!("could not write selection to clipboard: {}", err);
Event::SystemClipboardFailure Event::SystemClipboardFailure
} },
}; };
self.senders self.senders
.send_to_plugin(PluginInstruction::Update(None, None, clipboard_event)) .send_to_plugin(PluginInstruction::Update(None, None, clipboard_event))

View File

@ -71,10 +71,10 @@ impl Display for BoundarySymbol {
Some(color) => match color { Some(color) => match color {
PaletteColor::Rgb((r, g, b)) => { PaletteColor::Rgb((r, g, b)) => {
write!(f, "{}", RGB(r, g, b).paint(self.boundary_type)) write!(f, "{}", RGB(r, g, b).paint(self.boundary_type))
} },
PaletteColor::EightBit(color) => { PaletteColor::EightBit(color) => {
write!(f, "{}", Fixed(color).paint(self.boundary_type)) write!(f, "{}", Fixed(color).paint(self.boundary_type))
} },
}, },
None => write!(f, "{}", self.boundary_type), None => write!(f, "{}", self.boundary_type),
}, },
@ -98,7 +98,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(TOP_RIGHT, TOP_RIGHT) => { (TOP_RIGHT, TOP_RIGHT) => {
// (┐, ┐) => Some(┐) // (┐, ┐) => Some(┐)
let boundary_type = TOP_RIGHT; let boundary_type = TOP_RIGHT;
@ -107,7 +107,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(TOP_RIGHT, VERTICAL) | (TOP_RIGHT, BOTTOM_RIGHT) | (TOP_RIGHT, VERTICAL_LEFT) => { (TOP_RIGHT, VERTICAL) | (TOP_RIGHT, BOTTOM_RIGHT) | (TOP_RIGHT, VERTICAL_LEFT) => {
// (┐, │) => Some(┤) // (┐, │) => Some(┤)
// (┐, ┘) => Some(┤) // (┐, ┘) => Some(┤)
@ -118,7 +118,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(TOP_RIGHT, HORIZONTAL) | (TOP_RIGHT, TOP_LEFT) | (TOP_RIGHT, HORIZONTAL_DOWN) => { (TOP_RIGHT, HORIZONTAL) | (TOP_RIGHT, TOP_LEFT) | (TOP_RIGHT, HORIZONTAL_DOWN) => {
// (┐, ─) => Some(┬) // (┐, ─) => Some(┬)
// (┐, ┌) => Some(┬) // (┐, ┌) => Some(┬)
@ -129,7 +129,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(TOP_RIGHT, BOTTOM_LEFT) | (TOP_RIGHT, VERTICAL_RIGHT) | (TOP_RIGHT, HORIZONTAL_UP) => { (TOP_RIGHT, BOTTOM_LEFT) | (TOP_RIGHT, VERTICAL_RIGHT) | (TOP_RIGHT, HORIZONTAL_UP) => {
// (┐, └) => Some(┼) // (┐, └) => Some(┼)
// (┐, ├) => Some(┼) // (┐, ├) => Some(┼)
@ -140,7 +140,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(HORIZONTAL, HORIZONTAL) => { (HORIZONTAL, HORIZONTAL) => {
// (─, ─) => Some(─) // (─, ─) => Some(─)
let boundary_type = HORIZONTAL; let boundary_type = HORIZONTAL;
@ -149,7 +149,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(HORIZONTAL, VERTICAL) | (HORIZONTAL, VERTICAL_LEFT) | (HORIZONTAL, VERTICAL_RIGHT) => { (HORIZONTAL, VERTICAL) | (HORIZONTAL, VERTICAL_LEFT) | (HORIZONTAL, VERTICAL_RIGHT) => {
// (─, │) => Some(┼) // (─, │) => Some(┼)
// (─, ┤) => Some(┼) // (─, ┤) => Some(┼)
@ -160,7 +160,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(HORIZONTAL, TOP_LEFT) | (HORIZONTAL, HORIZONTAL_DOWN) => { (HORIZONTAL, TOP_LEFT) | (HORIZONTAL, HORIZONTAL_DOWN) => {
// (─, ┌) => Some(┬) // (─, ┌) => Some(┬)
// (─, ┬) => Some(┬) // (─, ┬) => Some(┬)
@ -170,7 +170,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(HORIZONTAL, BOTTOM_RIGHT) | (HORIZONTAL, BOTTOM_LEFT) | (HORIZONTAL, HORIZONTAL_UP) => { (HORIZONTAL, BOTTOM_RIGHT) | (HORIZONTAL, BOTTOM_LEFT) | (HORIZONTAL, HORIZONTAL_UP) => {
// (─, ┘) => Some(┴) // (─, ┘) => Some(┴)
// (─, └) => Some(┴) // (─, └) => Some(┴)
@ -181,7 +181,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(VERTICAL, VERTICAL) => { (VERTICAL, VERTICAL) => {
// (│, │) => Some(│) // (│, │) => Some(│)
let boundary_type = VERTICAL; let boundary_type = VERTICAL;
@ -190,7 +190,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(VERTICAL, TOP_LEFT) | (VERTICAL, BOTTOM_LEFT) | (VERTICAL, VERTICAL_RIGHT) => { (VERTICAL, TOP_LEFT) | (VERTICAL, BOTTOM_LEFT) | (VERTICAL, VERTICAL_RIGHT) => {
// (│, ┌) => Some(├) // (│, ┌) => Some(├)
// (│, └) => Some(├) // (│, └) => Some(├)
@ -201,7 +201,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(VERTICAL, BOTTOM_RIGHT) | (VERTICAL, VERTICAL_LEFT) => { (VERTICAL, BOTTOM_RIGHT) | (VERTICAL, VERTICAL_LEFT) => {
// (│, ┘) => Some(┤) // (│, ┘) => Some(┤)
// (│, ┤) => Some(┤) // (│, ┤) => Some(┤)
@ -211,7 +211,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(VERTICAL, HORIZONTAL_DOWN) | (VERTICAL, HORIZONTAL_UP) => { (VERTICAL, HORIZONTAL_DOWN) | (VERTICAL, HORIZONTAL_UP) => {
// (│, ┬) => Some(┼) // (│, ┬) => Some(┼)
// (│, ┴) => Some(┼) // (│, ┴) => Some(┼)
@ -221,7 +221,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(TOP_LEFT, TOP_LEFT) => { (TOP_LEFT, TOP_LEFT) => {
// (┌, ┌) => Some(┌) // (┌, ┌) => Some(┌)
let boundary_type = TOP_LEFT; let boundary_type = TOP_LEFT;
@ -230,7 +230,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(TOP_LEFT, BOTTOM_RIGHT) | (TOP_LEFT, VERTICAL_LEFT) | (TOP_LEFT, HORIZONTAL_UP) => { (TOP_LEFT, BOTTOM_RIGHT) | (TOP_LEFT, VERTICAL_LEFT) | (TOP_LEFT, HORIZONTAL_UP) => {
// (┌, ┘) => Some(┼) // (┌, ┘) => Some(┼)
// (┌, ┤) => Some(┼) // (┌, ┤) => Some(┼)
@ -241,7 +241,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(TOP_LEFT, BOTTOM_LEFT) | (TOP_LEFT, VERTICAL_RIGHT) => { (TOP_LEFT, BOTTOM_LEFT) | (TOP_LEFT, VERTICAL_RIGHT) => {
// (┌, └) => Some(├) // (┌, └) => Some(├)
// (┌, ├) => Some(├) // (┌, ├) => Some(├)
@ -251,7 +251,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(TOP_LEFT, HORIZONTAL_DOWN) => { (TOP_LEFT, HORIZONTAL_DOWN) => {
// (┌, ┬) => Some(┬) // (┌, ┬) => Some(┬)
let boundary_type = HORIZONTAL_DOWN; let boundary_type = HORIZONTAL_DOWN;
@ -260,7 +260,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(BOTTOM_RIGHT, BOTTOM_RIGHT) => { (BOTTOM_RIGHT, BOTTOM_RIGHT) => {
// (┘, ┘) => Some(┘) // (┘, ┘) => Some(┘)
let boundary_type = BOTTOM_RIGHT; let boundary_type = BOTTOM_RIGHT;
@ -269,7 +269,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(BOTTOM_RIGHT, BOTTOM_LEFT) | (BOTTOM_RIGHT, HORIZONTAL_UP) => { (BOTTOM_RIGHT, BOTTOM_LEFT) | (BOTTOM_RIGHT, HORIZONTAL_UP) => {
// (┘, └) => Some(┴) // (┘, └) => Some(┴)
// (┘, ┴) => Some(┴) // (┘, ┴) => Some(┴)
@ -279,7 +279,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(BOTTOM_RIGHT, VERTICAL_LEFT) => { (BOTTOM_RIGHT, VERTICAL_LEFT) => {
// (┘, ┤) => Some(┤) // (┘, ┤) => Some(┤)
let boundary_type = VERTICAL_LEFT; let boundary_type = VERTICAL_LEFT;
@ -288,7 +288,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(BOTTOM_RIGHT, VERTICAL_RIGHT) | (BOTTOM_RIGHT, HORIZONTAL_DOWN) => { (BOTTOM_RIGHT, VERTICAL_RIGHT) | (BOTTOM_RIGHT, HORIZONTAL_DOWN) => {
// (┘, ├) => Some(┼) // (┘, ├) => Some(┼)
// (┘, ┬) => Some(┼) // (┘, ┬) => Some(┼)
@ -298,7 +298,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(BOTTOM_LEFT, BOTTOM_LEFT) => { (BOTTOM_LEFT, BOTTOM_LEFT) => {
// (└, └) => Some(└) // (└, └) => Some(└)
let boundary_type = BOTTOM_LEFT; let boundary_type = BOTTOM_LEFT;
@ -307,7 +307,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(BOTTOM_LEFT, VERTICAL_LEFT) | (BOTTOM_LEFT, HORIZONTAL_DOWN) => { (BOTTOM_LEFT, VERTICAL_LEFT) | (BOTTOM_LEFT, HORIZONTAL_DOWN) => {
// (└, ┤) => Some(┼) // (└, ┤) => Some(┼)
// (└, ┬) => Some(┼) // (└, ┬) => Some(┼)
@ -317,7 +317,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(BOTTOM_LEFT, VERTICAL_RIGHT) => { (BOTTOM_LEFT, VERTICAL_RIGHT) => {
// (└, ├) => Some(├) // (└, ├) => Some(├)
let boundary_type = VERTICAL_RIGHT; let boundary_type = VERTICAL_RIGHT;
@ -326,7 +326,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(BOTTOM_LEFT, HORIZONTAL_UP) => { (BOTTOM_LEFT, HORIZONTAL_UP) => {
// (└, ┴) => Some(┴) // (└, ┴) => Some(┴)
let boundary_type = HORIZONTAL_UP; let boundary_type = HORIZONTAL_UP;
@ -335,7 +335,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(VERTICAL_LEFT, VERTICAL_LEFT) => { (VERTICAL_LEFT, VERTICAL_LEFT) => {
// (┤, ┤) => Some(┤) // (┤, ┤) => Some(┤)
let boundary_type = VERTICAL_LEFT; let boundary_type = VERTICAL_LEFT;
@ -344,7 +344,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(VERTICAL_LEFT, VERTICAL_RIGHT) (VERTICAL_LEFT, VERTICAL_RIGHT)
| (VERTICAL_LEFT, HORIZONTAL_DOWN) | (VERTICAL_LEFT, HORIZONTAL_DOWN)
| (VERTICAL_LEFT, HORIZONTAL_UP) => { | (VERTICAL_LEFT, HORIZONTAL_UP) => {
@ -357,7 +357,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(VERTICAL_RIGHT, VERTICAL_RIGHT) => { (VERTICAL_RIGHT, VERTICAL_RIGHT) => {
// (├, ├) => Some(├) // (├, ├) => Some(├)
let boundary_type = VERTICAL_RIGHT; let boundary_type = VERTICAL_RIGHT;
@ -366,7 +366,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(VERTICAL_RIGHT, HORIZONTAL_DOWN) | (VERTICAL_RIGHT, HORIZONTAL_UP) => { (VERTICAL_RIGHT, HORIZONTAL_DOWN) | (VERTICAL_RIGHT, HORIZONTAL_UP) => {
// (├, ┬) => Some(┼) // (├, ┬) => Some(┼)
// (├, ┴) => Some(┼) // (├, ┴) => Some(┼)
@ -376,7 +376,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(HORIZONTAL_DOWN, HORIZONTAL_DOWN) => { (HORIZONTAL_DOWN, HORIZONTAL_DOWN) => {
// (┬, ┬) => Some(┬) // (┬, ┬) => Some(┬)
let boundary_type = HORIZONTAL_DOWN; let boundary_type = HORIZONTAL_DOWN;
@ -385,7 +385,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(HORIZONTAL_DOWN, HORIZONTAL_UP) => { (HORIZONTAL_DOWN, HORIZONTAL_UP) => {
// (┬, ┴) => Some(┼) // (┬, ┴) => Some(┼)
let boundary_type = CROSS; let boundary_type = CROSS;
@ -394,7 +394,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(HORIZONTAL_UP, HORIZONTAL_UP) => { (HORIZONTAL_UP, HORIZONTAL_UP) => {
// (┴, ┴) => Some(┴) // (┴, ┴) => Some(┴)
let boundary_type = HORIZONTAL_UP; let boundary_type = HORIZONTAL_UP;
@ -403,7 +403,7 @@ fn combine_symbols(
invisible, invisible,
color, color,
}) })
} },
(_, _) => combine_symbols(next_symbol, current_symbol), (_, _) => combine_symbols(next_symbol, current_symbol),
} }
} }

View File

@ -18,12 +18,12 @@ fn foreground_color(characters: &str, color: Option<PaletteColor>) -> Vec<Termin
styles styles
.foreground(Some(AnsiCode::from(palette_color))) .foreground(Some(AnsiCode::from(palette_color)))
.bold(Some(AnsiCode::On)) .bold(Some(AnsiCode::On))
} },
None => { None => {
let mut styles = CharacterStyles::new(); let mut styles = CharacterStyles::new();
styles.reset_all(); styles.reset_all();
styles.bold(Some(AnsiCode::On)) styles.bold(Some(AnsiCode::On))
} },
}; };
let terminal_character = TerminalCharacter { let terminal_character = TerminalCharacter {
character, character,
@ -45,12 +45,12 @@ fn background_color(characters: &str, color: Option<PaletteColor>) -> Vec<Termin
styles styles
.background(Some(AnsiCode::from(palette_color))) .background(Some(AnsiCode::from(palette_color)))
.bold(Some(AnsiCode::On)) .bold(Some(AnsiCode::On))
} },
None => { None => {
let mut styles = CharacterStyles::new(); let mut styles = CharacterStyles::new();
styles.reset_all(); styles.reset_all();
styles styles
} },
}; };
let terminal_character = TerminalCharacter { let terminal_character = TerminalCharacter {
character, character,
@ -566,7 +566,7 @@ impl PaneFrame {
), ),
(Some((left_side, left_side_len)), None) => { (Some((left_side, left_side_len)), None) => {
self.left_and_middle_title_line(left_side, &left_side_len, middle, middle_len) self.left_and_middle_title_line(left_side, &left_side_len, middle, middle_len)
} },
_ => self.middle_only_title_line(middle, middle_len), _ => self.middle_only_title_line(middle, middle_len),
} }
} }
@ -580,10 +580,10 @@ impl PaneFrame {
match (left_side, right_side) { match (left_side, right_side) {
(Some((left_side, left_side_len)), Some((right_side, right_side_len))) => { (Some((left_side, left_side_len)), Some((right_side, right_side_len))) => {
self.two_part_title_line(left_side, &left_side_len, right_side, &right_side_len) self.two_part_title_line(left_side, &left_side_len, right_side, &right_side_len)
} },
(Some((left_side, left_side_len)), None) => { (Some((left_side, left_side_len)), None) => {
self.left_only_title_line(left_side, &left_side_len) self.left_only_title_line(left_side, &left_side_len)
} },
_ => self.empty_title_line(), _ => self.empty_title_line(),
} }
} }

View File

@ -202,7 +202,7 @@ impl<'a> PaneContentsAndUi<'a> {
let colors = client_id_to_colors(client_id, self.style.colors); let colors = client_id_to_colors(client_id, self.style.colors);
colors.map(|colors| colors.0) colors.map(|colors| colors.0)
} }
} },
_ => Some(self.style.colors.orange), _ => Some(self.style.colors.orange),
} }
} else { } else {

View File

@ -128,7 +128,7 @@ pub(crate) fn wasm_thread_main(
} }
pid_tx.send(plugin_id).unwrap(); pid_tx.send(plugin_id).unwrap();
plugin_id += 1; plugin_id += 1;
} },
PluginInstruction::Update(pid, cid, event) => { PluginInstruction::Update(pid, cid, event) => {
for (&(plugin_id, client_id), (instance, plugin_env)) in &plugin_map { for (&(plugin_id, client_id), (instance, plugin_env)) in &plugin_map {
let subs = plugin_env.subscriptions.lock().unwrap(); let subs = plugin_env.subscriptions.lock().unwrap();
@ -146,7 +146,7 @@ pub(crate) fn wasm_thread_main(
} }
} }
drop(bus.senders.send_to_screen(ScreenInstruction::Render)); drop(bus.senders.send_to_screen(ScreenInstruction::Render));
} },
PluginInstruction::Render(buf_tx, pid, cid, rows, cols) => { PluginInstruction::Render(buf_tx, pid, cid, rows, cols) => {
if rows == 0 || cols == 0 { if rows == 0 || cols == 0 {
buf_tx.send(String::new()).unwrap(); buf_tx.send(String::new()).unwrap();
@ -160,7 +160,7 @@ pub(crate) fn wasm_thread_main(
buf_tx.send(wasi_read_string(&plugin_env.wasi_env)).unwrap(); buf_tx.send(wasi_read_string(&plugin_env.wasi_env)).unwrap();
} }
} },
PluginInstruction::Unload(pid) => { PluginInstruction::Unload(pid) => {
info!("Bye from plugin {}", &pid); info!("Bye from plugin {}", &pid);
// TODO: remove plugin's own data directory // TODO: remove plugin's own data directory
@ -170,7 +170,7 @@ pub(crate) fn wasm_thread_main(
drop(plugin_map.remove(&(plugin_id, client_id))); drop(plugin_map.remove(&(plugin_id, client_id)));
} }
} }
} },
PluginInstruction::AddClient(client_id) => { PluginInstruction::AddClient(client_id) => {
connected_clients.push(client_id); connected_clients.push(client_id);
@ -203,10 +203,10 @@ pub(crate) fn wasm_thread_main(
plugin_id += 1; plugin_id += 1;
} }
} }
} },
PluginInstruction::RemoveClient(client_id) => { PluginInstruction::RemoveClient(client_id) => {
connected_clients.retain(|c| c != &client_id); connected_clients.retain(|c| c != &client_id);
} },
PluginInstruction::Exit => break, PluginInstruction::Exit => break,
} }
} }
@ -366,13 +366,13 @@ fn host_set_selectable(plugin_env: &PluginEnv, selectable: i32) {
tab_index, tab_index,
)) ))
.unwrap() .unwrap()
} },
_ => { _ => {
debug!( debug!(
"{} - Calling method 'host_set_selectable' does nothing for headless plugins", "{} - Calling method 'host_set_selectable' does nothing for headless plugins",
plugin_env.plugin.location plugin_env.plugin.location
) )
} },
} }
} }

View File

@ -131,7 +131,7 @@ impl Config {
return Ok(Config::default()); return Ok(Config::default());
} }
return Err(ConfigError::Serde(e)); return Err(ConfigError::Serde(e));
} },
Ok(config) => config, Ok(config) => config,
}; };
@ -149,7 +149,7 @@ impl Config {
file.read_to_string(&mut yaml_config) file.read_to_string(&mut yaml_config)
.map_err(|e| ConfigError::IoPath(e, path.to_path_buf()))?; .map_err(|e| ConfigError::IoPath(e, path.to_path_buf()))?;
Ok(Config::from_yaml(&yaml_config)?) Ok(Config::from_yaml(&yaml_config)?)
} },
Err(e) => Err(ConfigError::IoPath(e, path.into())), Err(e) => Err(ConfigError::IoPath(e, path.into())),
} }
} }

View File

@ -113,12 +113,12 @@ impl Keybinds {
match keybind { match keybind {
KeyActionUnbind::Unbind(unbind) => { KeyActionUnbind::Unbind(unbind) => {
unbind_config.insert(mode, unbind.unbind.clone()); unbind_config.insert(mode, unbind.unbind.clone());
} },
KeyActionUnbind::KeyAction(key_action_from_yaml) => { KeyActionUnbind::KeyAction(key_action_from_yaml) => {
keybind_config keybind_config
.0 .0
.insert(mode, ModeKeybinds::from(key_action_from_yaml.clone())); .insert(mode, ModeKeybinds::from(key_action_from_yaml.clone()));
} },
} }
} }
} }
@ -145,19 +145,19 @@ impl Keybinds {
for mode in InputMode::iter() { for mode in InputMode::iter() {
if let Some(unbind) = unbind.get(&mode) { if let Some(unbind) = unbind.get(&mode) {
match unbind { match unbind {
Unbind::All(true) => {} Unbind::All(true) => {},
Unbind::Keys(keys) => { Unbind::Keys(keys) => {
if let Some(defaults) = self.0.get(&mode) { if let Some(defaults) = self.0.get(&mode) {
keybinds keybinds
.0 .0
.insert(mode, defaults.clone().unbind_keys(keys.to_vec())); .insert(mode, defaults.clone().unbind_keys(keys.to_vec()));
} }
} },
Unbind::All(false) => { Unbind::All(false) => {
if let Some(defaults) = self.0.get(&mode) { if let Some(defaults) = self.0.get(&mode) {
keybinds.0.insert(mode, defaults.clone()); keybinds.0.insert(mode, defaults.clone());
} }
} },
} }
} else if let Some(defaults) = self.0.get(&mode) { } else if let Some(defaults) = self.0.get(&mode) {
keybinds.0.insert(mode, defaults.clone()); keybinds.0.insert(mode, defaults.clone());
@ -210,7 +210,7 @@ impl Keybinds {
match *mode { match *mode {
InputMode::Normal | InputMode::Locked => { InputMode::Normal | InputMode::Locked => {
mode_keybind_or_action(Action::Write(raw_bytes)) mode_keybind_or_action(Action::Write(raw_bytes))
} },
InputMode::RenameTab => mode_keybind_or_action(Action::TabNameInput(raw_bytes)), InputMode::RenameTab => mode_keybind_or_action(Action::TabNameInput(raw_bytes)),
InputMode::RenamePane => mode_keybind_or_action(Action::PaneNameInput(raw_bytes)), InputMode::RenamePane => mode_keybind_or_action(Action::PaneNameInput(raw_bytes)),
_ => mode_keybind_or_action(Action::NoOp), _ => mode_keybind_or_action(Action::NoOp),

View File

@ -201,7 +201,7 @@ impl LayoutFromYamlIntermediate {
return Ok(LayoutFromYamlIntermediate::default()); return Ok(LayoutFromYamlIntermediate::default());
} }
return Err(ConfigError::Serde(e)); return Err(ConfigError::Serde(e));
} },
Ok(config) => config, Ok(config) => config,
}; };
@ -211,7 +211,7 @@ impl LayoutFromYamlIntermediate {
tab.check()?; tab.check()?;
} }
Ok(layout) Ok(layout)
} },
None => Ok(LayoutFromYamlIntermediate::default()), None => Ok(LayoutFromYamlIntermediate::default()),
} }
} }
@ -225,7 +225,7 @@ impl LayoutFromYamlIntermediate {
return Ok(LayoutFromYamlIntermediate::default()); return Ok(LayoutFromYamlIntermediate::default());
} }
return Err(ConfigError::Serde(e)); return Err(ConfigError::Serde(e));
} },
Ok(config) => config, Ok(config) => config,
}; };
Ok(layout) Ok(layout)
@ -276,7 +276,7 @@ impl LayoutFromYamlIntermediate {
} else { } else {
LayoutFromYamlIntermediate::from_default_assets(layout) LayoutFromYamlIntermediate::from_default_assets(layout)
} }
} },
None => LayoutFromYamlIntermediate::from_default_assets(layout), None => LayoutFromYamlIntermediate::from_default_assets(layout),
} }
} }
@ -341,7 +341,7 @@ impl LayoutFromYaml {
return Ok(LayoutFromYaml::default()); return Ok(LayoutFromYaml::default());
} }
return Err(ConfigError::Serde(e)); return Err(ConfigError::Serde(e));
} },
Ok(config) => config, Ok(config) => config,
}; };
@ -351,7 +351,7 @@ impl LayoutFromYaml {
tab.check()?; tab.check()?;
} }
Ok(layout) Ok(layout)
} },
None => Ok(LayoutFromYaml::default()), None => Ok(LayoutFromYaml::default()),
} }
} }
@ -362,7 +362,7 @@ impl LayoutFromYaml {
match layout_dir { match layout_dir {
Some(dir) => { Some(dir) => {
Self::new(&dir.join(layout)).or_else(|_| Self::from_default_assets(layout)) Self::new(&dir.join(layout)).or_else(|_| Self::from_default_assets(layout))
} },
None => Self::from_default_assets(layout), None => Self::from_default_assets(layout),
} }
} }
@ -518,8 +518,8 @@ impl Layout {
match part.run { match part.run {
Some(Run::Command(_)) | None => { Some(Run::Command(_)) | None => {
total_panes += part.total_terminal_panes(); total_panes += part.total_terminal_panes();
} },
Some(Run::Plugin(_)) => {} Some(Run::Plugin(_)) => {},
} }
} }
total_panes total_panes
@ -624,7 +624,7 @@ fn split_space(space_to_split: &PaneGeom, layout: &Layout) -> Vec<(Layout, PaneG
panic!("Implicit sizing within fixed-size panes is not supported"); panic!("Implicit sizing within fixed-size panes is not supported");
}; };
Dimension::percent(free_percent / flex_parts as f64) Dimension::percent(free_percent / flex_parts as f64)
} },
}; };
inherited_dimension.set_inner( inherited_dimension.set_inner(
layout layout
@ -682,7 +682,7 @@ impl TryFrom<Url> for RunPluginLocation {
Err(_) => Err(PluginsConfigError::InvalidPluginLocation(path.to_owned())), Err(_) => Err(PluginsConfigError::InvalidPluginLocation(path.to_owned())),
}) })
.map(Self::File) .map(Self::File)
} },
_ => Err(PluginsConfigError::InvalidUrl(url)), _ => Err(PluginsConfigError::InvalidUrl(url)),
} }
} }

View File

@ -118,7 +118,7 @@ pub fn cast_termwiz_key(event: KeyEvent, raw_bytes: &[u8]) -> Key {
} else { } else {
Key::Char(c) Key::Char(c)
} }
} },
KeyCode::Backspace => Key::Backspace, KeyCode::Backspace => Key::Backspace,
KeyCode::LeftArrow | KeyCode::ApplicationLeftArrow => { KeyCode::LeftArrow | KeyCode::ApplicationLeftArrow => {
if modifiers.contains(Modifiers::ALT) { if modifiers.contains(Modifiers::ALT) {
@ -126,14 +126,14 @@ pub fn cast_termwiz_key(event: KeyEvent, raw_bytes: &[u8]) -> Key {
} else { } else {
Key::Left Key::Left
} }
} },
KeyCode::RightArrow | KeyCode::ApplicationRightArrow => { KeyCode::RightArrow | KeyCode::ApplicationRightArrow => {
if modifiers.contains(Modifiers::ALT) { if modifiers.contains(Modifiers::ALT) {
Key::Alt(CharOrArrow::Direction(Direction::Right)) Key::Alt(CharOrArrow::Direction(Direction::Right))
} else { } else {
Key::Right Key::Right
} }
} },
KeyCode::UpArrow | KeyCode::ApplicationUpArrow => { KeyCode::UpArrow | KeyCode::ApplicationUpArrow => {
if modifiers.contains(Modifiers::ALT) { if modifiers.contains(Modifiers::ALT) {
//Key::AltPlusUpArrow //Key::AltPlusUpArrow
@ -141,14 +141,14 @@ pub fn cast_termwiz_key(event: KeyEvent, raw_bytes: &[u8]) -> Key {
} else { } else {
Key::Up Key::Up
} }
} },
KeyCode::DownArrow | KeyCode::ApplicationDownArrow => { KeyCode::DownArrow | KeyCode::ApplicationDownArrow => {
if modifiers.contains(Modifiers::ALT) { if modifiers.contains(Modifiers::ALT) {
Key::Alt(CharOrArrow::Direction(Direction::Down)) Key::Alt(CharOrArrow::Direction(Direction::Down))
} else { } else {
Key::Down Key::Down
} }
} },
KeyCode::Home => Key::Home, KeyCode::Home => Key::Home,
KeyCode::End => Key::End, KeyCode::End => Key::End,
KeyCode::PageUp => Key::PageUp, KeyCode::PageUp => Key::PageUp,

View File

@ -146,8 +146,8 @@ impl PluginConfig {
match self.run { match self.run {
PluginType::Pane(..) => { PluginType::Pane(..) => {
self.run = PluginType::Pane(Some(tab_index)); self.run = PluginType::Pane(Some(tab_index));
} },
PluginType::Headless => {} PluginType::Headless => {},
} }
} }
} }

View File

@ -193,7 +193,7 @@ where
Err(e) => { Err(e) => {
warn!("Error in IpcReceiver.recv(): {:?}", e); warn!("Error in IpcReceiver.recv(): {:?}", e);
None None
} },
} }
} }

View File

@ -218,7 +218,7 @@ impl Setup {
Ok(config) => config, Ok(config) => config,
Err(e) => { Err(e) => {
return Err(e); return Err(e);
} },
} }
} else { } else {
Config::default() Config::default()
@ -241,7 +241,7 @@ impl Setup {
Some(Ok(layout)) => Some(layout), Some(Ok(layout)) => Some(layout),
Some(Err(e)) => { Some(Err(e)) => {
return Err(e); return Err(e);
} },
}; };
if let Some(Command::Setup(ref setup)) = &opts.command { if let Some(Command::Setup(ref setup)) = &opts.command {
@ -431,20 +431,20 @@ impl Setup {
_ => { _ => {
eprintln!("Unsupported shell: {}", shell); eprintln!("Unsupported shell: {}", shell);
std::process::exit(1); std::process::exit(1);
} },
}; };
let mut out = std::io::stdout(); let mut out = std::io::stdout();
clap_complete::generate(shell, &mut CliArgs::command(), "zellij", &mut out); clap_complete::generate(shell, &mut CliArgs::command(), "zellij", &mut out);
// add shell dependent extra completion // add shell dependent extra completion
match shell { match shell {
Shell::Bash => {} Shell::Bash => {},
Shell::Elvish => {} Shell::Elvish => {},
Shell::Fish => { Shell::Fish => {
let _ = out.write_all(FISH_EXTRA_COMPLETION); let _ = out.write_all(FISH_EXTRA_COMPLETION);
} },
Shell::PowerShell => {} Shell::PowerShell => {},
Shell::Zsh => {} Shell::Zsh => {},
_ => {} _ => {},
}; };
} }
@ -454,21 +454,21 @@ impl Setup {
_ => { _ => {
eprintln!("Unsupported shell: {}", shell); eprintln!("Unsupported shell: {}", shell);
std::process::exit(1); std::process::exit(1);
} },
}; };
let mut out = std::io::stdout(); let mut out = std::io::stdout();
match shell { match shell {
Shell::Bash => { Shell::Bash => {
let _ = out.write_all(BASH_AUTO_START_SCRIPT); let _ = out.write_all(BASH_AUTO_START_SCRIPT);
} },
Shell::Fish => { Shell::Fish => {
let _ = out.write_all(FISH_AUTO_START_SCRIPT); let _ = out.write_all(FISH_AUTO_START_SCRIPT);
} },
Shell::Zsh => { Shell::Zsh => {
let _ = out.write_all(ZSH_AUTO_START_SCRIPT); let _ = out.write_all(ZSH_AUTO_START_SCRIPT);
} },
_ => {} _ => {},
} }
} }
} }

View File

@ -112,7 +112,7 @@ pub fn detect_theme_hue(bg: PaletteColor) -> ThemeHue {
true => ThemeHue::Light, true => ThemeHue::Light,
false => ThemeHue::Dark, false => ThemeHue::Dark,
} }
} },
_ => ThemeHue::Dark, _ => ThemeHue::Dark,
} }
} }