aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-03-09 22:20:16 +0000
committerBrooks J Rady <b.j.rady@gmail.com>2021-03-09 22:20:16 +0000
commit1dd4045e23b0c92570e6c203c43f318ad01dbd2c (patch)
treece70df2b291efbbbc35476c9aaf1edd455aa892a /src
parentAdd event subscription tracking (diff)
downloadsl0ppij-1dd4045e23b0c92570e6c203c43f318ad01dbd2c.tar.gz
sl0ppij-1dd4045e23b0c92570e6c203c43f318ad01dbd2c.tar.xz
sl0ppij-1dd4045e23b0c92570e6c203c43f318ad01dbd2c.zip
Clippy compels me to cull code
Diffstat (limited to 'src')
-rw-r--r--src/client/panes/terminal_character.rs10
-rw-r--r--src/common/errors.rs4
-rw-r--r--src/common/input/handler.rs15
-rw-r--r--src/common/input/keybinds.rs6
-rw-r--r--src/common/ipc.rs8
-rw-r--r--src/common/mod.rs44
-rw-r--r--src/common/screen.rs13
7 files changed, 44 insertions, 56 deletions
diff --git a/src/client/panes/terminal_character.rs b/src/client/panes/terminal_character.rs
index 80c3162b..053ebd3f 100644
--- a/src/client/panes/terminal_character.rs
+++ b/src/client/panes/terminal_character.rs
@@ -23,7 +23,7 @@ pub enum AnsiCode {
On,
Reset,
NamedColor(NamedColor),
- RGBCode((u8, u8, u8)),
+ RgbCode((u8, u8, u8)),
ColorIndex(u8),
}
@@ -336,7 +336,7 @@ impl CharacterStyles {
[36, ..] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::Cyan))),
[37, ..] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::White))),
[38, 2, ..] => {
- let ansi_code = AnsiCode::RGBCode((
+ let ansi_code = AnsiCode::RgbCode((
*ansi_params.get(2).unwrap() as u8,
*ansi_params.get(3).unwrap() as u8,
*ansi_params.get(4).unwrap() as u8,
@@ -364,7 +364,7 @@ impl CharacterStyles {
[46, ..] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::Cyan))),
[47, ..] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::White))),
[48, 2, ..] => {
- let ansi_code = AnsiCode::RGBCode((
+ let ansi_code = AnsiCode::RgbCode((
*ansi_params.get(2).unwrap() as u8,
*ansi_params.get(3).unwrap() as u8,
*ansi_params.get(4).unwrap() as u8,
@@ -416,7 +416,7 @@ impl Display for CharacterStyles {
}
if let Some(ansi_code) = self.foreground {
match ansi_code {
- AnsiCode::RGBCode((r, g, b)) => {
+ AnsiCode::RgbCode((r, g, b)) => {
write!(f, "\u{1b}[38;2;{};{};{}m", r, g, b)?;
}
AnsiCode::ColorIndex(color_index) => {
@@ -433,7 +433,7 @@ impl Display for CharacterStyles {
};
if let Some(ansi_code) = self.background {
match ansi_code {
- AnsiCode::RGBCode((r, g, b)) => {
+ AnsiCode::RgbCode((r, g, b)) => {
write!(f, "\u{1b}[48;2;{};{};{}m", r, g, b)?;
}
AnsiCode::ColorIndex(color_index) => {
diff --git a/src/common/errors.rs b/src/common/errors.rs
index 48a92b76..bd9907fa 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -133,7 +133,7 @@ pub enum ContextType {
Plugin(PluginContext),
/// An app-related call.
App(AppContext),
- IPCServer,
+ IpcServer,
StdinHandler,
AsyncTask,
/// An empty, placeholder call. This should be thought of as representing no call at all.
@@ -152,7 +152,7 @@ impl Display for ContextType {
ContextType::Plugin(c) => write!(f, "{}plugin_thread: {}{:?}", purple, green, c),
ContextType::App(c) => write!(f, "{}main_thread: {}{:?}", purple, green, c),
- ContextType::IPCServer => write!(f, "{}ipc_server: {}AcceptInput", purple, green),
+ ContextType::IpcServer => write!(f, "{}ipc_server: {}AcceptInput", purple, green),
ContextType::StdinHandler => {
write!(f, "{}stdin_handler_thread: {}AcceptInput", purple, green)
}
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs
index 40d53d5d..ed247830 100644
--- a/src/common/input/handler.rs
+++ b/src/common/input/handler.rs
@@ -73,15 +73,12 @@ impl InputHandler {
// framework relies on it to not create dead threads that loop
// and eat up CPUs. Do not remove until the test framework has
// been revised. Sorry about this (@categorille)
- if {
- let mut should_break = false;
- for action in
- key_to_actions(&key, raw_bytes, &self.mode, &keybinds)
- {
- should_break |= self.dispatch_action(action);
- }
- should_break
- } {
+ let mut should_break = false;
+ for action in key_to_actions(&key, raw_bytes, &self.mode, &keybinds)
+ {
+ should_break |= self.dispatch_action(action);
+ }
+ if should_break {
break 'input_loop;
}
}
diff --git a/src/common/input/keybinds.rs b/src/common/input/keybinds.rs
index da0f1c15..b5dacd70 100644
--- a/src/common/input/keybinds.rs
+++ b/src/common/input/keybinds.rs
@@ -17,14 +17,14 @@ pub fn get_default_keybinds() -> Result<Keybinds, String> {
let mut defaults = Keybinds::new();
for mode in InputMode::iter() {
- defaults.insert(mode, get_defaults_for_mode(&mode)?);
+ defaults.insert(mode, get_defaults_for_mode(&mode));
}
Ok(defaults)
}
/// Returns the default keybinds for a givent [`InputMode`].
-fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> {
+fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds {
let mut defaults = ModeKeybinds::new();
match *mode {
@@ -181,7 +181,7 @@ fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> {
}
}
- Ok(defaults)
+ defaults
}
/// Converts a [`Key`] terminal event to a sequence of [`Action`]s according to the current
diff --git a/src/common/ipc.rs b/src/common/ipc.rs
index 77d57df3..81576b86 100644
--- a/src/common/ipc.rs
+++ b/src/common/ipc.rs
@@ -3,12 +3,12 @@
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
-type SessionID = u64;
+type SessionId = u64;
#[derive(PartialEq, Eq, Serialize, Deserialize, Hash)]
pub struct Session {
// Unique ID for this session
- id: SessionID,
+ id: SessionId,
// Identifier for the underlying IPC primitive (socket, pipe)
conn_name: String,
// User configured alias for the session
@@ -30,9 +30,9 @@ pub enum ClientToServerMsg {
// Create a new session
CreateSession,
// Attach to a running session
- AttachToSession(SessionID, ClientType),
+ AttachToSession(SessionId, ClientType),
// Force detach
- DetachSession(SessionID),
+ DetachSession(SessionId),
// Disconnect from the session we're connected to
DisconnectFromSession,
}
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 411269b6..f0babeaa 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -553,14 +553,12 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let (instance, plugin_env) = plugin_map.get(&pid).unwrap();
let handle_key =
instance.exports.get_function("handle_key").unwrap();
- for key in input_bytes.keys() {
- if let Ok(key) = key {
- wasi_write_string(
- &plugin_env.wasi_env,
- &serde_json::to_string(&key).unwrap(),
- );
- handle_key.call(&[]).unwrap();
- }
+ for key in input_bytes.keys().flatten() {
+ wasi_write_string(
+ &plugin_env.wasi_env,
+ &serde_json::to_string(&key).unwrap(),
+ );
+ handle_key.call(&[]).unwrap();
}
}
PluginInputType::Event(event) => {
@@ -572,14 +570,12 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
.exports
.get_function(handler_map.get(&event).unwrap())
.unwrap();
- for key in input_bytes.keys() {
- if let Ok(key) = key {
- wasi_write_string(
- &plugin_env.wasi_env,
- &serde_json::to_string(&key).unwrap(),
- );
- handle_key.call(&[]).unwrap();
- }
+ for key in input_bytes.keys().flatten() {
+ wasi_write_string(
+ &plugin_env.wasi_env,
+ &serde_json::to_string(&key).unwrap(),
+ );
+ handle_key.call(&[]).unwrap();
}
}
}
@@ -591,14 +587,12 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
for (instance, plugin_env) in plugin_map.values() {
let handler =
instance.exports.get_function("handle_global_key").unwrap();
- for key in input_bytes.keys() {
- if let Ok(key) = key {
- wasi_write_string(
- &plugin_env.wasi_env,
- &serde_json::to_string(&key).unwrap(),
- );
- handler.call(&[]).unwrap();
- }
+ for key in input_bytes.keys().flatten() {
+ wasi_write_string(
+ &plugin_env.wasi_env,
+ &serde_json::to_string(&key).unwrap(),
+ );
+ handler.call(&[]).unwrap();
}
}
@@ -626,7 +620,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let listener = std::os::unix::net::UnixListener::bind(ZELLIJ_IPC_PIPE)
.expect("could not listen on ipc socket");
let mut err_ctx = OPENCALLS.with(|ctx| *ctx.borrow());
- err_ctx.add_call(ContextType::IPCServer);
+ err_ctx.add_call(ContextType::IpcServer);
send_pty_instructions.update(err_ctx);
send_screen_instructions.update(err_ctx);
diff --git a/src/common/screen.rs b/src/common/screen.rs
index c4c4bdd7..539eef9a 100644
--- a/src/common/screen.rs
+++ b/src/common/screen.rs
@@ -171,15 +171,12 @@ impl Screen {
pub fn go_to_tab(&mut self, mut tab_index: usize) {
tab_index -= 1;
let active_tab = self.get_active_tab().unwrap();
- match self.tabs.values().find(|t| t.position == tab_index) {
- Some(t) => {
- if t.index != active_tab.index {
- self.active_tab_index = Some(t.index);
- self.update_tabs();
- self.render();
- }
+ if let Some(t) = self.tabs.values().find(|t| t.position == tab_index) {
+ if t.index != active_tab.index {
+ self.active_tab_index = Some(t.index);
+ self.update_tabs();
+ self.render();
}
- None => {}
}
}