fmt and clippy

This commit is contained in:
Kunal Mohan 2021-05-16 22:25:32 +05:30
parent 62d0901bbd
commit a872362328
15 changed files with 45 additions and 36 deletions

View File

@ -1,7 +1,6 @@
use zellij_utils::pane_size::PositionAndSize;
use ::insta::assert_snapshot;
use zellij_utils::pane_size::PositionAndSize;
use zellij_utils::input::config::Config;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::commands::{
@ -12,6 +11,7 @@ use crate::tests::utils::commands::{
};
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::CliArgs;
use zellij_utils::input::config::Config;
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
FakeInputOutput::new(fake_win_size.clone())

View File

@ -1,10 +1,10 @@
use insta::assert_snapshot;
use zellij_utils::pane_size::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::CliArgs;
use zellij_utils::pane_size::PositionAndSize;
use crate::tests::utils::commands::{
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE,

View File

@ -1,10 +1,10 @@
use ::insta::assert_snapshot;
use zellij_utils::pane_size::PositionAndSize;
use crate::tests::fakes::FakeInputOutput;
use crate::tests::start;
use crate::tests::utils::{get_next_to_last_snapshot, get_output_frame_snapshots};
use crate::CliArgs;
use zellij_utils::pane_size::PositionAndSize;
use crate::tests::utils::commands::{
MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_MODE, RESIZE_RIGHT_IN_RESIZE_MODE,

View File

@ -1,10 +1,6 @@
//! Main input logic.
use crate::{
ClientInstruction,
CommandIsExecuting,
os_input_output::ClientOsApi,
};
use crate::{os_input_output::ClientOsApi, ClientInstruction, CommandIsExecuting};
use zellij_utils::{
channels::{SenderWithContext, OPENCALLS},
errors::ContextType,

View File

@ -10,7 +10,10 @@ use std::process::Command;
use std::sync::mpsc;
use std::thread;
use crate::{command_is_executing::CommandIsExecuting, input_handler::input_loop, os_input_output::ClientOsApi};
use crate::{
command_is_executing::CommandIsExecuting, input_handler::input_loop,
os_input_output::ClientOsApi,
};
use zellij_utils::cli::CliArgs;
use zellij_utils::{
channels::{SenderType, SenderWithContext, SyncChannelWithContext},

View File

@ -1,6 +1,6 @@
pub mod os_input_output;
pub mod panes;
pub mod tab;
pub mod os_input_output;
mod pty;
mod route;
@ -16,12 +16,12 @@ use wasmer::Store;
use zellij_tile::data::PluginCapabilities;
use crate::{
os_input_output::ServerOsApi,
pty::{pty_thread_main, Pty, PtyInstruction},
screen::{screen_thread_main, ScreenInstruction},
thread_bus::{Bus, ThreadSenders},
ui::layout::Layout,
wasm_vm::{wasm_thread_main, PluginInstruction},
os_input_output::ServerOsApi,
};
use route::route_thread_main;
use zellij_utils::{

View File

@ -1434,13 +1434,19 @@ impl Debug for Row {
}
}
impl Row {
pub fn new() -> Self {
impl Default for Row {
fn default() -> Self {
Row {
columns: vec![],
is_canonical: false,
}
}
}
impl Row {
pub fn new() -> Self {
Self::default()
}
pub fn from_columns(columns: Vec<TerminalCharacter>) -> Self {
Row {
columns,
@ -1526,6 +1532,9 @@ impl Row {
pub fn len(&self) -> usize {
self.columns.len()
}
pub fn is_empty(&self) -> bool {
self.columns.is_empty()
}
pub fn delete_character(&mut self, x: usize) {
if x < self.columns.len() {
self.columns.remove(x);

View File

@ -110,9 +110,9 @@ pub struct CharacterStyles {
pub italic: Option<AnsiCode>,
}
impl CharacterStyles {
pub fn new() -> Self {
CharacterStyles {
impl Default for CharacterStyles {
fn default() -> Self {
Self {
foreground: None,
background: None,
strike: None,
@ -126,6 +126,12 @@ impl CharacterStyles {
italic: None,
}
}
}
impl CharacterStyles {
pub fn new() -> Self {
Self::default()
}
pub fn foreground(mut self, foreground_code: Option<AnsiCode>) -> Self {
self.foreground = foreground_code;
self

View File

@ -8,13 +8,13 @@ use std::pin::*;
use std::time::{Duration, Instant};
use crate::{
os_input_output::ServerOsApi,
panes::PaneId,
screen::ScreenInstruction,
thread_bus::{Bus, ThreadSenders},
ui::layout::Layout,
wasm_vm::PluginInstruction,
ServerInstruction,
os_input_output::ServerOsApi,
};
use zellij_utils::{
errors::{get_current_ctx, ContextType, PtyContext},

View File

@ -3,9 +3,8 @@ use std::sync::{Arc, RwLock};
use zellij_tile::data::Event;
use crate::{
pty::PtyInstruction, screen::ScreenInstruction, wasm_vm::PluginInstruction, ServerInstruction,
SessionMetaData,
os_input_output::ServerOsApi,
os_input_output::ServerOsApi, pty::PtyInstruction, screen::ScreenInstruction,
wasm_vm::PluginInstruction, ServerInstruction, SessionMetaData,
};
use zellij_utils::{
channels::SenderWithContext,

View File

@ -2,13 +2,13 @@
//! as well as how they should be resized
use crate::{
os_input_output::ServerOsApi,
panes::{PaneId, PluginPane, TerminalPane},
pty::{PtyInstruction, VteBytes},
thread_bus::ThreadSenders,
ui::{boundaries::Boundaries, layout::Layout, pane_resizer::PaneResizer},
wasm_vm::PluginInstruction,
ServerInstruction,
os_input_output::ServerOsApi,
};
use serde::{Deserialize, Serialize};
use std::os::unix::io::RawFd;
@ -19,10 +19,7 @@ use std::{
collections::{BTreeMap, HashSet},
};
use zellij_tile::data::{Event, InputMode, ModeInfo, Palette};
use zellij_utils::{
input::parse_keys, pane_size::PositionAndSize,
shared::adjust_to_size,
};
use zellij_utils::{input::parse_keys, pane_size::PositionAndSize, shared::adjust_to_size};
const CURSOR_HEIGHT_WIDTH_RATIO: usize = 4; // this is not accurate and kind of a magic number, TODO: look into this

View File

@ -1,12 +1,11 @@
//! Definitions and helpers for sending and receiving messages between threads.
use crate::{
pty::PtyInstruction, screen::ScreenInstruction, wasm_vm::PluginInstruction, ServerInstruction, os_input_output::ServerOsApi
os_input_output::ServerOsApi, pty::PtyInstruction, screen::ScreenInstruction,
wasm_vm::PluginInstruction, ServerInstruction,
};
use std::sync::mpsc;
use zellij_utils::{
channels::SenderWithContext, errors::ErrorContext,
};
use zellij_utils::{channels::SenderWithContext, errors::ErrorContext};
/// A container for senders to the different threads in zellij on the server side
#[derive(Clone)]

View File

@ -1,9 +1,9 @@
use crate::{panes::PaneId, os_input_output::ServerOsApi, tab::Pane};
use crate::{os_input_output::ServerOsApi, panes::PaneId, tab::Pane};
use std::{
cmp::Ordering,
collections::{BTreeMap, HashSet},
};
use zellij_utils::{pane_size::PositionAndSize};
use zellij_utils::pane_size::PositionAndSize;
pub(crate) struct PaneResizer<'a> {
panes: &'a mut BTreeMap<PaneId, Box<dyn Pane>>,

View File

@ -1,7 +1,7 @@
//! Error context system based on a thread-local representation of the call stack, itself based on
//! the instructions that are sent between threads.
use crate::channels::{ASYNCOPENCALLS, OPENCALLS, SenderWithContext};
use crate::channels::{SenderWithContext, ASYNCOPENCALLS, OPENCALLS};
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Error, Formatter};
use std::panic::PanicInfo;

View File

@ -5,10 +5,10 @@ use std::{iter, str::from_utf8};
use strip_ansi_escapes::strip;
use colors_transform::{Color, Rgb};
use zellij_tile::data::{Palette, PaletteColor, PaletteSource, Theme};
use std::os::unix::{fs::PermissionsExt};
use std::path::{Path};
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
use std::{fs, io};
use zellij_tile::data::{Palette, PaletteColor, PaletteSource, Theme};
const UNIX_PERMISSIONS: u32 = 0o700;