summaryrefslogtreecommitdiffstats
path: root/zellij-client/src
diff options
context:
space:
mode:
authorhar7an <99636919+har7an@users.noreply.github.com>2022-07-06 14:06:56 +0000
committerGitHub <noreply@github.com>2022-07-06 16:06:56 +0200
commitc26a6bcf566d1a332ab795107852be004669d683 (patch)
tree3dcb45725aeedb82e37d8b0bf24801fbbd76e757 /zellij-client/src
parent5a40f42652d02145f28f04586b3f62427963417b (diff)
refactor(crates): move shared contents from zellij tile to zellij utils (#1541)
* zellij-tile: Move `data` to zellij-utils The rationale behind this is that all components of zellij access the data structures defined in this module, as they define some of the most basic types in the application. However, so far zellij-tile is treated like a separate crate from the rest of the program in that it is the only one that doesn't have access to `zellij-utils`, which contains a lot of other data structures used throughout zellij. This poses issues as discussed in https://github.com/zellij-org/zellij/pull/1242 and is one of the reasons why the keybindings in the status bar default plugin can't be updated dynamically. It is also the main reason for why the keybindings are currently passed to the plugin as strings: The plugins only have access to `zellij-tile`, but since this is a dependency of `zellij-utils`, it can't import `zellij-utils` to access the keybindings. Other weird side-effect are that in some places `server` and `client` have to access the `zellij-tile` contents "through" `zellij-utils`, as in `use zellij_utils::zellij_tile::prelude::*`. By moving these central data structures to one common shared crate (`zellij-utils`), `zellij-tile` will be enabled to import `zellij-utils` like `screen` and `client` already do. This will, next to other things, allow dropping a lot of `std::fmt::Fmt` impls needed to convert core data structures into strings and as a consequence, a lot of string parsing in the first place. * utils: Integrate new `data` module, bump rust ver Integrates the `data` module that was previously part of `zellij-tile` to allow sharing the contained data structures between all components of zellij. This allows `zellij-tile` to use `utils` as a dependency. However, since `tile` is build against the wasm target, it cannot include all of `zellij-utils`, since a lot of dependencies there cannot compile with `wasm` as target (Examples include: termwiz, log4rs, async-std). Thus we make all the dependencies that cannot compile against `wasm` optional and introduce a new feature `full` that will compile the crate with all dependencies. Along with this, modify `lib.rs` to include most of the data structures only when compiling against the `full` feature. This makes the compiles of `zellij-tile` lighter, as it doesn't include all of `utils`. As a side effect, due to the dependency notation for the optional dependencies (See https://doc.rust-lang.org/cargo/reference/features.html#optional-dependencies), we bump the rust toolchain version to 1.60.0. * tile: Import `data` from zellij-utils Add `zellij-utils` as a dependency to `zellij-tile` and allow us access to the `data` module defined there. Update the re-export in the `prelude` such that from all of the plugins points of view *absolutely nothing changes*. * utils: Fix `data` module dependency Since the `data` module has been migrated from `zellij-tile` to `zellij-utils`, we import it from `zellij-utils` directly now. Also unify the imports for the `data` module members: We import all of the through `data::` now, not through a mixture of `data::` and `prelude::`. * client: Fix `data` module dependency Since the `data` module has been migrated from `zellij-tile` to `zellij-utils`, we import it from `zellij-utils` directly now. Also unify the imports for the `data` module members: We import all of the through `data::` now, not through a mixture of `data::` and `prelude::`. Add the "full" feature flag to the `zellij-utils` dependency so it includes all the components we need. * server: Fix `data` module dependency Since the `data` module has been migrated from `zellij-tile` to `zellij-utils`, we import it from `zellij-utils` directly now. Also unify the imports for the `data` module members: We import all of the through `data::` now, not through a mixture of `data::` and `prelude::`. Add the "full" feature flag to the `zellij-utils` dependency so it includes all the components we need. * tests: Fix `data` module dependency Since the `data` module has been migrated from `zellij-tile` to `zellij-utils`, we import it from `zellij-utils` directly now. * utils: Remove "full" feature in favor of conditional compilation using `target_family`. Replace the rust 1.60 method of specifying optional dependencies based on features and optionally include the dependencies only when not building for wasm instead. (I.e. `cfg(not(target_family = "wasm"))`) * cargo: Update module dependencies since `client`, `server` and `tile` now all depend on `utils` only.
Diffstat (limited to 'zellij-client/src')
-rw-r--r--zellij-client/src/fake_client.rs4
-rw-r--r--zellij-client/src/input_handler.rs22
-rw-r--r--zellij-client/src/lib.rs3
-rw-r--r--zellij-client/src/os_input_output.rs4
-rw-r--r--zellij-client/src/stdin_ansi_parser.rs12
-rw-r--r--zellij-client/src/unit/input_handler_tests.rs5
6 files changed, 23 insertions, 27 deletions
diff --git a/zellij-client/src/fake_client.rs b/zellij-client/src/fake_client.rs
index 2199e12fb..7338d633a 100644
--- a/zellij-client/src/fake_client.rs
+++ b/zellij-client/src/fake_client.rs
@@ -3,8 +3,6 @@
//! Multiple actions at the same time can be dispatched.
use log::debug;
use std::{fs, path::PathBuf, thread};
-use zellij_tile::prelude::{ClientId, Style};
-use zellij_utils::errors::ContextType;
use crate::{
command_is_executing::CommandIsExecuting, input_handler::input_actions,
@@ -14,6 +12,8 @@ use crate::{
use zellij_utils::{
channels::{self, ChannelWithContext, SenderWithContext},
cli::CliArgs,
+ data::{ClientId, Style},
+ errors::ContextType,
input::{actions::Action, config::Config, layout::LayoutFromYaml, options::Options},
ipc::{ClientAttributes, ClientToServerMsg, ServerToClientMsg},
};
diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs
index 18ccf35b3..3f92c5376 100644
--- a/zellij-client/src/input_handler.rs
+++ b/zellij-client/src/input_handler.rs
@@ -1,13 +1,4 @@
//! Main input logic.
-use zellij_utils::{
- input::{
- mouse::{MouseButton, MouseEvent},
- options::Options,
- },
- termwiz::input::InputEvent,
- zellij_tile,
-};
-
use crate::{
os_input_output::ClientOsApi,
stdin_ansi_parser::{AnsiStdinInstructionOrKeys, StdinAnsiParser},
@@ -15,13 +6,20 @@ use crate::{
};
use zellij_utils::{
channels::{Receiver, SenderWithContext, OPENCALLS},
+ data::{InputMode, Key},
errors::{ContextType, ErrorContext},
- input::{actions::Action, cast_termwiz_key, config::Config, keybinds::Keybinds},
+ input::{
+ actions::Action,
+ cast_termwiz_key,
+ config::Config,
+ keybinds::Keybinds,
+ mouse::{MouseButton, MouseEvent},
+ options::Options,
+ },
ipc::{ClientToServerMsg, ExitReason},
+ termwiz::input::InputEvent,
};
-use zellij_tile::data::{InputMode, Key};
-
/// Handles the dispatching of [`Action`]s according to the current
/// [`InputMode`], and keep tracks of the current [`InputMode`].
struct InputHandler {
diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs
index aeb74abba..9790984ee 100644
--- a/zellij-client/src/lib.rs
+++ b/zellij-client/src/lib.rs
@@ -14,16 +14,15 @@ use std::io::{self, Write};
use std::path::Path;
use std::process::Command;
use std::thread;
-use zellij_tile::prelude::{ClientId, Style};
use crate::{
command_is_executing::CommandIsExecuting, input_handler::input_loop,
os_input_output::ClientOsApi, stdin_handler::stdin_loop,
};
-use zellij_tile::data::InputMode;
use zellij_utils::{
channels::{self, ChannelWithContext, SenderWithContext},
consts::ZELLIJ_IPC_PIPE,
+ data::{ClientId, InputMode, Style},
envs,
errors::{ClientContext, ContextType, ErrorInstruction},
input::{actions::Action, config::Config, options::Options},
diff --git a/zellij-client/src/os_input_output.rs b/zellij-client/src/os_input_output.rs
index a344f940d..60c22cc98 100644
--- a/zellij-client/src/os_input_output.rs
+++ b/zellij-client/src/os_input_output.rs
@@ -1,5 +1,5 @@
use zellij_utils::pane_size::Size;
-use zellij_utils::{interprocess, libc, nix, signal_hook, zellij_tile};
+use zellij_utils::{interprocess, libc, nix, signal_hook};
use interprocess::local_socket::LocalSocketStream;
use mio::{unix::SourceFd, Events, Interest, Poll, Token};
@@ -11,8 +11,8 @@ use std::os::unix::io::RawFd;
use std::path::Path;
use std::sync::{Arc, Mutex};
use std::{io, thread, time};
-use zellij_tile::data::Palette;
use zellij_utils::{
+ data::Palette,
errors::ErrorContext,
ipc::{ClientToServerMsg, IpcReceiverWithContext, IpcSenderWithContext, ServerToClientMsg},
shared::default_palette,
diff --git a/zellij-client/src/stdin_ansi_parser.rs b/zellij-client/src/stdin_ansi_parser.rs
index a3ab117ce..25f0e4fbb 100644
--- a/zellij-client/src/stdin_ansi_parser.rs
+++ b/zellij-client/src/stdin_ansi_parser.rs
@@ -1,8 +1,10 @@
-use zellij_utils::pane_size::SizeInPixels;
-
-use zellij_utils::{ipc::PixelDimensions, lazy_static::lazy_static, regex::Regex};
-
-use zellij_tile::data::{CharOrArrow, Key};
+use zellij_utils::{
+ data::{CharOrArrow, Key},
+ ipc::PixelDimensions,
+ lazy_static::lazy_static,
+ pane_size::SizeInPixels,
+ regex::Regex,
+};
pub struct StdinAnsiParser {
expected_ansi_instructions: usize,
diff --git a/zellij-client/src/unit/input_handler_tests.rs b/zellij-client/src/unit/input_handler_tests.rs
index 8fe4a5af9..b772eb5c4 100644
--- a/zellij-client/src/unit/input_handler_tests.rs
+++ b/zellij-client/src/unit/input_handler_tests.rs
@@ -1,11 +1,11 @@
use super::input_loop;
+use zellij_utils::data::{InputMode, Palette};
use zellij_utils::input::actions::{Action, Direction};
use zellij_utils::input::config::Config;
use zellij_utils::input::options::Options;
use zellij_utils::nix;
use zellij_utils::pane_size::{Size, SizeInPixels};
use zellij_utils::termwiz::input::{InputEvent, KeyCode, KeyEvent, Modifiers};
-use zellij_utils::zellij_tile::data::Palette;
use crate::InputInstruction;
use crate::{
@@ -15,12 +15,9 @@ use crate::{
use std::path::Path;
-use zellij_utils::zellij_tile;
-
use std::io;
use std::os::unix::io::RawFd;
use std::sync::{Arc, Mutex};
-use zellij_tile::data::InputMode;
use zellij_utils::{
errors::ErrorContext,
ipc::{ClientToServerMsg, PixelDimensions, ServerToClientMsg},