Skip to content

Commit

Permalink
fmt and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalmohan committed May 16, 2021
1 parent 62d0901 commit a872362
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/tests/integration/basic.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion src/tests/integration/resize_down.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/tests/integration/resize_right.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 1 addition & 5 deletions zellij-client/src/input_handler.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 4 additions & 1 deletion zellij-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions zellij-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod os_input_output;
pub mod panes;
pub mod tab;
pub mod os_input_output;

mod pty;
mod route;
Expand All @@ -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::{
Expand Down
13 changes: 11 additions & 2 deletions zellij-server/src/panes/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 9 additions & 3 deletions zellij-server/src/panes/terminal_character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion zellij-server/src/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
5 changes: 2 additions & 3 deletions zellij-server/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions zellij-server/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand Down
7 changes: 3 additions & 4 deletions zellij-server/src/thread_bus.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions zellij-server/src/ui/pane_resizer.rs
Original file line number Diff line number Diff line change
@@ -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>>,
Expand Down
2 changes: 1 addition & 1 deletion zellij-utils/src/errors.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions zellij-utils/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a872362

Please sign in to comment.