Clippy compels me to cull code
This commit is contained in:
parent
e9ab81850e
commit
1dd4045e23
10 changed files with 47 additions and 63 deletions
|
|
@ -58,6 +58,6 @@ impl FsEntry {
|
|||
}
|
||||
|
||||
pub fn is_hidden_file(&self) -> bool {
|
||||
self.name().chars().nth(0).unwrap() == '.'.into()
|
||||
self.name().starts_with('.')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ fn left_more_message(tab_count_to_the_left: usize) -> LinePart {
|
|||
let more_text = if tab_count_to_the_left < 10000 {
|
||||
format!(" ← +{} ", tab_count_to_the_left)
|
||||
} else {
|
||||
format!(" ← +many ")
|
||||
" ← +many ".to_string()
|
||||
};
|
||||
let more_styled_text = format!(
|
||||
"{}{}",
|
||||
|
|
@ -79,7 +79,7 @@ fn right_more_message(tab_count_to_the_right: usize) -> LinePart {
|
|||
let more_text = if tab_count_to_the_right < 10000 {
|
||||
format!(" +{} → ", tab_count_to_the_right)
|
||||
} else {
|
||||
format!(" +many → ")
|
||||
" +many → ".to_string()
|
||||
};
|
||||
let more_styled_text = format!(
|
||||
"{}{}{}",
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ impl Default for BarMode {
|
|||
|
||||
#[derive(Default)]
|
||||
struct State {
|
||||
active_tab_index: usize,
|
||||
num_tabs: usize,
|
||||
tabs: Vec<TabInfo>,
|
||||
mode: BarMode,
|
||||
new_name: String,
|
||||
|
|
@ -42,8 +40,6 @@ impl ZellijTile for State {
|
|||
set_selectable(false);
|
||||
set_invisible_borders(true);
|
||||
set_max_height(1);
|
||||
self.active_tab_index = 0;
|
||||
self.num_tabs = 0;
|
||||
self.mode = BarMode::Normal;
|
||||
self.new_name = String::new();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue