aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-05-16 22:25:32 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-16 22:25:32 +0530
commita872362328e89d1a2cb43642751486a52aed124c (patch)
treed5beba48fdb4369256d92b6437ee015c262e8bf0
parentRevert changes to Makefile.toml and build without --all-features (diff)
downloadsl0ppij-a872362328e89d1a2cb43642751486a52aed124c.tar.gz
sl0ppij-a872362328e89d1a2cb43642751486a52aed124c.tar.xz
sl0ppij-a872362328e89d1a2cb43642751486a52aed124c.zip
fmt and clippy
-rw-r--r--src/tests/integration/basic.rs4
-rw-r--r--src/tests/integration/resize_down.rs2
-rw-r--r--src/tests/integration/resize_right.rs2
-rw-r--r--zellij-client/src/input_handler.rs6
-rw-r--r--zellij-client/src/lib.rs5
-rw-r--r--zellij-server/src/lib.rs4
-rw-r--r--zellij-server/src/panes/grid.rs13
-rw-r--r--zellij-server/src/panes/terminal_character.rs12
-rw-r--r--zellij-server/src/pty.rs2
-rw-r--r--zellij-server/src/route.rs5
-rw-r--r--zellij-server/src/tab.rs7
-rw-r--r--zellij-server/src/thread_bus.rs7
-rw-r--r--zellij-server/src/ui/pane_resizer.rs4
-rw-r--r--zellij-utils/src/errors.rs2
-rw-r--r--zellij-utils/src/shared.rs6
15 files changed, 45 insertions, 36 deletions
diff --git a/src/tests/integration/basic.rs b/src/tests/integration/basic.rs
index 1329c5b8..640b1c55 100644
--- a/src/tests/integration/basic.rs
+++ b/src/tests/integration/basic.rs
@@ -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())
diff --git a/src/tests/integration/resize_down.rs b/src/tests/integration/resize_down.rs
index dd9976cd..4ef45a06 100644
--- a/src/tests/integration/resize_down.rs
+++ b/src/tests/integration/resize_down.rs
@@ -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,
diff --git a/src/tests/integration/resize_right.rs b/src/tests/integration/resize_right.rs
index 7c3fdd85..44601f2c 100644
--- a/src/tests/integration/resize_right.rs
+++ b/src/tests/integration/resize_right.rs
@@ -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,
diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs
index 6c6a6b0b..e67bdf82 100644
--- a/zellij-client/src/input_handler.rs
+++ b/zellij-client/src/input_handler.rs
@@ -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,
diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs
index 7cc2aa21..8ffcf72b 100644
--- a/zellij-client/src/lib.rs
+++ b/zellij-client/src/lib.rs
@@ -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},
diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs
index b92b931f..606bf1b0 100644
--- a/zellij-server/src/lib.rs
+++ b/zellij-server/src/lib.rs
@@ -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::{
diff --git a/zellij-server/src/panes/grid.rs b/zellij-server/src/panes/grid.rs
index b2ec365a..83e8c70f 100644
--- a/zellij-server/src/panes/grid.rs
+++ b/zellij-server/src/panes/grid.rs
@@ -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);
diff --git a/zellij-server/src/panes/terminal_character.rs b/zellij-server/src/panes/terminal_character.rs
index c9497ac2..c55569f0 100644
--- a/zellij-server/src/panes/terminal_character.rs
+++ b/zellij-server/src/panes/terminal_character.rs
@@ -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
diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs
index 03605003..373b5f0b 100644
--- a/zellij-server/src/pty.rs
+++ b/zellij-server/src/pty.rs
@@ -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},
diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs
index e161a534..1d25ae77 100644
--- a/zellij-server/src/route.rs
+++ b/zellij-server/src/route.rs
@@ -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,
diff --git a/zellij-server/src/tab.rs b/zellij-server/src/tab.rs
index ade9e182..e41cb530 100644
--- a/zellij-server/src/tab.rs
+++ b/zellij-server/src/tab.rs
@@ -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
diff --git a/zellij-server/src/thread_bus.rs b/zellij-server/src/thread_bus.rs
index ff2fcb20..afc1d875 100644
--- a/zellij-server/src/thread_bus.rs
+++ b/zellij-server/src/thread_bus.rs
@@ -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)]
diff --git a/zellij-server/src/ui/pane_resizer.rs b/zellij-server/src/ui/pane_resizer.rs
index 9f8b4d04..b2001945 100644
--- a/zellij-server/src/ui/pane_resizer.rs
+++ b/zellij-server/src/ui/pane_resizer.rs
@@ -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>>,
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index 9d26986c..94a894c4 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -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;
diff --git a/zellij-utils/src/shared.rs b/zellij-utils/src/shared.rs
index 94ef9fa2..bc8b6771 100644
--- a/zellij-utils/src/shared.rs
+++ b/zellij-utils/src/shared.rs
@@ -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;