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.
This commit is contained in:
har7an 2022-07-06 14:06:56 +00:00 committed by GitHub
parent 5a40f42652
commit c26a6bcf56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 108 additions and 132 deletions

5
Cargo.lock generated
View file

@ -3265,7 +3265,6 @@ dependencies = [
"insta", "insta",
"log", "log",
"mio", "mio",
"zellij-tile",
"zellij-utils", "zellij-utils",
] ]
@ -3292,7 +3291,6 @@ dependencies = [
"uuid", "uuid",
"wasmer", "wasmer",
"wasmer-wasi", "wasmer-wasi",
"zellij-tile",
"zellij-utils", "zellij-utils",
] ]
@ -3305,6 +3303,7 @@ dependencies = [
"serde_json", "serde_json",
"strum", "strum",
"strum_macros", "strum_macros",
"zellij-utils",
] ]
[[package]] [[package]]
@ -3343,13 +3342,13 @@ dependencies = [
"signal-hook 0.3.14", "signal-hook 0.3.14",
"strip-ansi-escapes", "strip-ansi-escapes",
"strum", "strum",
"strum_macros",
"tempfile", "tempfile",
"termwiz", "termwiz",
"thiserror", "thiserror",
"unicode-width", "unicode-width",
"url", "url",
"vte", "vte",
"zellij-tile",
] ]
[[package]] [[package]]

View file

@ -2,10 +2,9 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use zellij_server::panes::{LinkHandler, TerminalPane}; use zellij_server::panes::{LinkHandler, TerminalPane};
use zellij_utils::data::{Palette, Style};
use zellij_utils::pane_size::{Dimension, PaneGeom, Size}; use zellij_utils::pane_size::{Dimension, PaneGeom, Size};
use zellij_utils::vte; use zellij_utils::vte;
use zellij_utils::zellij_tile::data::Palette;
use zellij_utils::zellij_tile::prelude::Style;
use ssh2::Session; use ssh2::Session;
use std::io::prelude::*; use std::io::prelude::*;

View file

@ -11,7 +11,6 @@ license = "MIT"
[dependencies] [dependencies]
mio = { version = "0.7.11", features = ['os-ext'] } mio = { version = "0.7.11", features = ['os-ext'] }
zellij-utils = { path = "../zellij-utils/", version = "0.31.0" } zellij-utils = { path = "../zellij-utils/", version = "0.31.0" }
zellij-tile = { path = "../zellij-tile/", version = "0.31.0" }
log = "0.4.17" log = "0.4.17"
[dev-dependencies] [dev-dependencies]

View file

@ -3,8 +3,6 @@
//! Multiple actions at the same time can be dispatched. //! Multiple actions at the same time can be dispatched.
use log::debug; use log::debug;
use std::{fs, path::PathBuf, thread}; use std::{fs, path::PathBuf, thread};
use zellij_tile::prelude::{ClientId, Style};
use zellij_utils::errors::ContextType;
use crate::{ use crate::{
command_is_executing::CommandIsExecuting, input_handler::input_actions, command_is_executing::CommandIsExecuting, input_handler::input_actions,
@ -14,6 +12,8 @@ use crate::{
use zellij_utils::{ use zellij_utils::{
channels::{self, ChannelWithContext, SenderWithContext}, channels::{self, ChannelWithContext, SenderWithContext},
cli::CliArgs, cli::CliArgs,
data::{ClientId, Style},
errors::ContextType,
input::{actions::Action, config::Config, layout::LayoutFromYaml, options::Options}, input::{actions::Action, config::Config, layout::LayoutFromYaml, options::Options},
ipc::{ClientAttributes, ClientToServerMsg, ServerToClientMsg}, ipc::{ClientAttributes, ClientToServerMsg, ServerToClientMsg},
}; };

View file

@ -1,13 +1,4 @@
//! Main input logic. //! Main input logic.
use zellij_utils::{
input::{
mouse::{MouseButton, MouseEvent},
options::Options,
},
termwiz::input::InputEvent,
zellij_tile,
};
use crate::{ use crate::{
os_input_output::ClientOsApi, os_input_output::ClientOsApi,
stdin_ansi_parser::{AnsiStdinInstructionOrKeys, StdinAnsiParser}, stdin_ansi_parser::{AnsiStdinInstructionOrKeys, StdinAnsiParser},
@ -15,13 +6,20 @@ use crate::{
}; };
use zellij_utils::{ use zellij_utils::{
channels::{Receiver, SenderWithContext, OPENCALLS}, channels::{Receiver, SenderWithContext, OPENCALLS},
data::{InputMode, Key},
errors::{ContextType, ErrorContext}, 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}, ipc::{ClientToServerMsg, ExitReason},
termwiz::input::InputEvent,
}; };
use zellij_tile::data::{InputMode, Key};
/// Handles the dispatching of [`Action`]s according to the current /// Handles the dispatching of [`Action`]s according to the current
/// [`InputMode`], and keep tracks of the current [`InputMode`]. /// [`InputMode`], and keep tracks of the current [`InputMode`].
struct InputHandler { struct InputHandler {

View file

@ -14,16 +14,15 @@ use std::io::{self, Write};
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
use std::thread; use std::thread;
use zellij_tile::prelude::{ClientId, Style};
use crate::{ use crate::{
command_is_executing::CommandIsExecuting, input_handler::input_loop, command_is_executing::CommandIsExecuting, input_handler::input_loop,
os_input_output::ClientOsApi, stdin_handler::stdin_loop, os_input_output::ClientOsApi, stdin_handler::stdin_loop,
}; };
use zellij_tile::data::InputMode;
use zellij_utils::{ use zellij_utils::{
channels::{self, ChannelWithContext, SenderWithContext}, channels::{self, ChannelWithContext, SenderWithContext},
consts::ZELLIJ_IPC_PIPE, consts::ZELLIJ_IPC_PIPE,
data::{ClientId, InputMode, Style},
envs, envs,
errors::{ClientContext, ContextType, ErrorInstruction}, errors::{ClientContext, ContextType, ErrorInstruction},
input::{actions::Action, config::Config, options::Options}, input::{actions::Action, config::Config, options::Options},

View file

@ -1,5 +1,5 @@
use zellij_utils::pane_size::Size; 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 interprocess::local_socket::LocalSocketStream;
use mio::{unix::SourceFd, Events, Interest, Poll, Token}; use mio::{unix::SourceFd, Events, Interest, Poll, Token};
@ -11,8 +11,8 @@ use std::os::unix::io::RawFd;
use std::path::Path; use std::path::Path;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::{io, thread, time}; use std::{io, thread, time};
use zellij_tile::data::Palette;
use zellij_utils::{ use zellij_utils::{
data::Palette,
errors::ErrorContext, errors::ErrorContext,
ipc::{ClientToServerMsg, IpcReceiverWithContext, IpcSenderWithContext, ServerToClientMsg}, ipc::{ClientToServerMsg, IpcReceiverWithContext, IpcSenderWithContext, ServerToClientMsg},
shared::default_palette, shared::default_palette,

View file

@ -1,8 +1,10 @@
use zellij_utils::pane_size::SizeInPixels; use zellij_utils::{
data::{CharOrArrow, Key},
use zellij_utils::{ipc::PixelDimensions, lazy_static::lazy_static, regex::Regex}; ipc::PixelDimensions,
lazy_static::lazy_static,
use zellij_tile::data::{CharOrArrow, Key}; pane_size::SizeInPixels,
regex::Regex,
};
pub struct StdinAnsiParser { pub struct StdinAnsiParser {
expected_ansi_instructions: usize, expected_ansi_instructions: usize,

View file

@ -1,11 +1,11 @@
use super::input_loop; use super::input_loop;
use zellij_utils::data::{InputMode, Palette};
use zellij_utils::input::actions::{Action, Direction}; use zellij_utils::input::actions::{Action, Direction};
use zellij_utils::input::config::Config; use zellij_utils::input::config::Config;
use zellij_utils::input::options::Options; use zellij_utils::input::options::Options;
use zellij_utils::nix; use zellij_utils::nix;
use zellij_utils::pane_size::{Size, SizeInPixels}; use zellij_utils::pane_size::{Size, SizeInPixels};
use zellij_utils::termwiz::input::{InputEvent, KeyCode, KeyEvent, Modifiers}; use zellij_utils::termwiz::input::{InputEvent, KeyCode, KeyEvent, Modifiers};
use zellij_utils::zellij_tile::data::Palette;
use crate::InputInstruction; use crate::InputInstruction;
use crate::{ use crate::{
@ -15,12 +15,9 @@ use crate::{
use std::path::Path; use std::path::Path;
use zellij_utils::zellij_tile;
use std::io; use std::io;
use std::os::unix::io::RawFd; use std::os::unix::io::RawFd;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use zellij_tile::data::InputMode;
use zellij_utils::{ use zellij_utils::{
errors::ErrorContext, errors::ErrorContext,
ipc::{ClientToServerMsg, PixelDimensions, ServerToClientMsg}, ipc::{ClientToServerMsg, PixelDimensions, ServerToClientMsg},

View file

@ -22,7 +22,6 @@ wasmer = "1.0.0"
wasmer-wasi = "1.0.0" wasmer-wasi = "1.0.0"
cassowary = "0.3.0" cassowary = "0.3.0"
zellij-utils = { path = "../zellij-utils/", version = "0.31.0" } zellij-utils = { path = "../zellij-utils/", version = "0.31.0" }
zellij-tile = { path = "../zellij-tile/", version = "0.31.0" }
log = "0.4.17" log = "0.4.17"
typetag = "0.1.7" typetag = "0.1.7"
chrono = "0.4.19" chrono = "0.4.19"

View file

@ -20,14 +20,11 @@ use std::{
sync::{Arc, Mutex, RwLock}, sync::{Arc, Mutex, RwLock},
thread, thread,
}; };
use zellij_tile::prelude::Style;
use zellij_utils::envs; use zellij_utils::envs;
use zellij_utils::nix::sys::stat::{umask, Mode}; use zellij_utils::nix::sys::stat::{umask, Mode};
use zellij_utils::pane_size::Size; use zellij_utils::pane_size::Size;
use zellij_utils::zellij_tile;
use wasmer::Store; use wasmer::Store;
use zellij_tile::data::{Event, PluginCapabilities};
use crate::{ use crate::{
os_input_output::ServerOsApi, os_input_output::ServerOsApi,
@ -41,6 +38,7 @@ use zellij_utils::{
channels::{self, ChannelWithContext, SenderWithContext}, channels::{self, ChannelWithContext, SenderWithContext},
cli::CliArgs, cli::CliArgs,
consts::{DEFAULT_SCROLL_BUFFER_SIZE, SCROLL_BUFFER_SIZE}, consts::{DEFAULT_SCROLL_BUFFER_SIZE, SCROLL_BUFFER_SIZE},
data::{Event, PluginCapabilities, Style},
errors::{ContextType, ErrorInstruction, ServerContext}, errors::{ContextType, ErrorInstruction, ServerContext},
input::{ input::{
command::{RunCommand, TerminalAction}, command::{RunCommand, TerminalAction},

View file

@ -11,7 +11,7 @@ use std::path::PathBuf;
use std::process::{Child, Command}; use std::process::{Child, Command};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use zellij_utils::{async_std, interprocess, libc, nix, signal_hook, zellij_tile}; use zellij_utils::{async_std, interprocess, libc, nix, signal_hook};
use async_std::fs::File as AsyncFile; use async_std::fs::File as AsyncFile;
use async_std::os::unix::io::FromRawFd; use async_std::os::unix::io::FromRawFd;
@ -25,8 +25,8 @@ use nix::sys::termios;
use nix::unistd; use nix::unistd;
use signal_hook::consts::*; use signal_hook::consts::*;
use zellij_tile::data::Palette;
use zellij_utils::{ use zellij_utils::{
data::Palette,
input::command::{RunCommand, TerminalAction}, input::command::{RunCommand, TerminalAction},
ipc::{ClientToServerMsg, IpcReceiverWithContext, IpcSenderWithContext, ServerToClientMsg}, ipc::{ClientToServerMsg, IpcReceiverWithContext, IpcSenderWithContext, ServerToClientMsg},
shared::default_palette, shared::default_palette,

View file

@ -1,6 +1,5 @@
use zellij_tile::prelude::Style;
mod floating_pane_grid; mod floating_pane_grid;
use zellij_utils::{position::Position, zellij_tile}; use zellij_utils::position::Position;
use crate::tab::Pane; use crate::tab::Pane;
use floating_pane_grid::FloatingPaneGrid; use floating_pane_grid::FloatingPaneGrid;
@ -16,8 +15,10 @@ use std::cell::RefCell;
use std::collections::{BTreeMap, HashMap, HashSet}; use std::collections::{BTreeMap, HashMap, HashSet};
use std::rc::Rc; use std::rc::Rc;
use std::time::Instant; use std::time::Instant;
use zellij_tile::data::ModeInfo; use zellij_utils::{
use zellij_utils::pane_size::{Offset, PaneGeom, Size, Viewport}; data::{ModeInfo, Style},
pane_size::{Offset, PaneGeom, Size, Viewport},
};
macro_rules! resize_pty { macro_rules! resize_pty {
($pane:expr, $os_input:expr) => { ($pane:expr, $os_input:expr) => {

View file

@ -12,16 +12,16 @@ use std::{
use zellij_utils::{ use zellij_utils::{
consts::{DEFAULT_SCROLL_BUFFER_SIZE, SCROLL_BUFFER_SIZE}, consts::{DEFAULT_SCROLL_BUFFER_SIZE, SCROLL_BUFFER_SIZE},
data::{Palette, PaletteColor},
pane_size::SizeInPixels, pane_size::SizeInPixels,
position::Position, position::Position,
vte, zellij_tile, vte,
}; };
const TABSTOP_WIDTH: usize = 8; // TODO: is this always right? const TABSTOP_WIDTH: usize = 8; // TODO: is this always right?
pub const MAX_TITLE_STACK_SIZE: usize = 1000; pub const MAX_TITLE_STACK_SIZE: usize = 1000;
use vte::{Params, Perform}; use vte::{Params, Perform};
use zellij_tile::data::{Palette, PaletteColor};
use zellij_utils::{consts::VERSION, shared::version_number}; use zellij_utils::{consts::VERSION, shared::version_number};
use crate::output::{CharacterChunk, OutputBuffer}; use crate::output::{CharacterChunk, OutputBuffer};

View file

@ -12,9 +12,9 @@ use crate::ClientId;
use zellij_utils::pane_size::Offset; use zellij_utils::pane_size::Offset;
use zellij_utils::position::Position; use zellij_utils::position::Position;
use zellij_utils::shared::ansi_len; use zellij_utils::shared::ansi_len;
use zellij_utils::zellij_tile::prelude::{Event, InputMode, Mouse, PaletteColor};
use zellij_utils::{ use zellij_utils::{
channels::SenderWithContext, channels::SenderWithContext,
data::{Event, InputMode, Mouse, PaletteColor},
pane_size::{Dimension, PaneGeom}, pane_size::{Dimension, PaneGeom},
shared::make_terminal_title, shared::make_terminal_title,
}; };

View file

@ -3,10 +3,9 @@ use std::fmt::{self, Debug, Display, Formatter};
use std::ops::{Index, IndexMut}; use std::ops::{Index, IndexMut};
use unicode_width::UnicodeWidthChar; use unicode_width::UnicodeWidthChar;
use zellij_utils::vte::ParamsIter; use zellij_utils::{data::PaletteColor, vte::ParamsIter};
use crate::panes::alacritty_functions::parse_sgr_color; use crate::panes::alacritty_functions::parse_sgr_color;
use zellij_tile::data::PaletteColor;
pub const EMPTY_TERMINAL_CHARACTER: TerminalCharacter = TerminalCharacter { pub const EMPTY_TERMINAL_CHARACTER: TerminalCharacter = TerminalCharacter {
character: ' ', character: ' ',

View file

@ -13,15 +13,14 @@ use std::fmt::Debug;
use std::os::unix::io::RawFd; use std::os::unix::io::RawFd;
use std::rc::Rc; use std::rc::Rc;
use std::time::{self, Instant}; use std::time::{self, Instant};
use zellij_tile::prelude::Style;
use zellij_utils::pane_size::Offset; use zellij_utils::pane_size::Offset;
use zellij_utils::{ use zellij_utils::{
data::{InputMode, Palette, PaletteColor, Style},
pane_size::SizeInPixels, pane_size::SizeInPixels,
pane_size::{Dimension, PaneGeom}, pane_size::{Dimension, PaneGeom},
position::Position, position::Position,
shared::make_terminal_title, shared::make_terminal_title,
vte, vte,
zellij_tile::data::{InputMode, Palette, PaletteColor},
}; };
pub const SELECTION_SCROLL_INTERVAL_MS: u64 = 10; pub const SELECTION_SCROLL_INTERVAL_MS: u64 = 10;

View file

@ -1,9 +1,6 @@
mod pane_resizer; mod pane_resizer;
mod tiled_pane_grid; mod tiled_pane_grid;
use zellij_tile::prelude::Style;
use zellij_utils::zellij_tile;
use crate::tab::{Pane, MIN_TERMINAL_HEIGHT, MIN_TERMINAL_WIDTH}; use crate::tab::{Pane, MIN_TERMINAL_HEIGHT, MIN_TERMINAL_WIDTH};
use tiled_pane_grid::{split, TiledPaneGrid}; use tiled_pane_grid::{split, TiledPaneGrid};
@ -15,8 +12,8 @@ use std::cell::RefCell;
use std::collections::{BTreeMap, HashMap, HashSet}; use std::collections::{BTreeMap, HashMap, HashSet};
use std::rc::Rc; use std::rc::Rc;
use std::time::Instant; use std::time::Instant;
use zellij_tile::data::ModeInfo;
use zellij_utils::{ use zellij_utils::{
data::{ModeInfo, Style},
input::layout::Direction, input::layout::Direction,
pane_size::{Offset, PaneGeom, Size, SizeInPixels, Viewport}, pane_size::{Offset, PaneGeom, Size, SizeInPixels, Viewport},
}; };

View file

@ -3,7 +3,7 @@ use crate::panes::link_handler::LinkHandler;
use ::insta::assert_snapshot; use ::insta::assert_snapshot;
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
use zellij_utils::{pane_size::SizeInPixels, position::Position, vte, zellij_tile::data::Palette}; use zellij_utils::{data::Palette, pane_size::SizeInPixels, position::Position, vte};
fn read_fixture(fixture_name: &str) -> Vec<u8> { fn read_fixture(fixture_name: &str) -> Vec<u8> {
let mut path_to_file = std::path::PathBuf::new(); let mut path_to_file = std::path::PathBuf::new();

View file

@ -4,9 +4,10 @@ use crate::tab::Pane;
use ::insta::assert_snapshot; use ::insta::assert_snapshot;
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
use zellij_tile::data::Palette; use zellij_utils::{
use zellij_tile::prelude::Style; data::{Palette, Style},
use zellij_utils::pane_size::PaneGeom; pane_size::PaneGeom,
};
use std::fmt::Write; use std::fmt::Write;

View file

@ -1,7 +1,5 @@
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use zellij_utils::zellij_tile::data::Event;
use crate::{ use crate::{
os_input_output::ServerOsApi, os_input_output::ServerOsApi,
pty::{ClientOrTabIndex, PtyInstruction}, pty::{ClientOrTabIndex, PtyInstruction},
@ -11,6 +9,7 @@ use crate::{
}; };
use zellij_utils::{ use zellij_utils::{
channels::SenderWithContext, channels::SenderWithContext,
data::Event,
input::{ input::{
actions::{Action, Direction, ResizeDirection}, actions::{Action, Direction, ResizeDirection},
command::TerminalAction, command::TerminalAction,

View file

@ -6,13 +6,9 @@ use std::os::unix::io::RawFd;
use std::rc::Rc; use std::rc::Rc;
use std::str; use std::str;
use zellij_tile::data::{Palette, PaletteColor};
use zellij_tile::prelude::Style;
use zellij_utils::input::options::Clipboard; use zellij_utils::input::options::Clipboard;
use zellij_utils::pane_size::{Size, SizeInPixels}; use zellij_utils::pane_size::{Size, SizeInPixels};
use zellij_utils::{ use zellij_utils::{input::command::TerminalAction, input::layout::Layout, position::Position};
input::command::TerminalAction, input::layout::Layout, position::Position, zellij_tile,
};
use crate::panes::alacritty_functions::xparse_color; use crate::panes::alacritty_functions::xparse_color;
use crate::panes::terminal_character::AnsiCode; use crate::panes::terminal_character::AnsiCode;
@ -27,8 +23,8 @@ use crate::{
wasm_vm::PluginInstruction, wasm_vm::PluginInstruction,
ClientId, ServerInstruction, ClientId, ServerInstruction,
}; };
use zellij_tile::data::{Event, InputMode, ModeInfo, PluginCapabilities, TabInfo};
use zellij_utils::{ use zellij_utils::{
data::{Event, InputMode, ModeInfo, Palette, PaletteColor, PluginCapabilities, Style, TabInfo},
errors::{ContextType, ScreenContext}, errors::{ContextType, ScreenContext},
input::{get_mode_info, options::Options}, input::{get_mode_info, options::Options},
ipc::{ClientAttributes, PixelDimensions}, ipc::{ClientAttributes, PixelDimensions},

View file

@ -1,5 +1,4 @@
use zellij_tile::prelude::CopyDestination; use zellij_utils::{anyhow::Result, data::CopyDestination, input::options::Clipboard};
use zellij_utils::{anyhow::Result, input::options::Clipboard};
use crate::ClientId; use crate::ClientId;

View file

@ -7,9 +7,8 @@ mod copy_command;
use copy_command::CopyCommand; use copy_command::CopyCommand;
use std::env::temp_dir; use std::env::temp_dir;
use uuid::Uuid; use uuid::Uuid;
use zellij_tile::prelude::Style;
use zellij_utils::position::{Column, Line}; use zellij_utils::position::{Column, Line};
use zellij_utils::{position::Position, serde, zellij_tile}; use zellij_utils::{position::Position, serde};
use crate::pty_writer::PtyWriteInstruction; use crate::pty_writer::PtyWriteInstruction;
use crate::screen::CopyOptions; use crate::screen::CopyOptions;
@ -36,8 +35,8 @@ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
str, str,
}; };
use zellij_tile::data::{Event, InputMode, ModeInfo, Palette, PaletteColor};
use zellij_utils::{ use zellij_utils::{
data::{Event, InputMode, ModeInfo, Palette, PaletteColor, Style},
input::{ input::{
command::TerminalAction, command::TerminalAction,
layout::{Layout, Run}, layout::{Layout, Run},

View file

@ -1,6 +1,5 @@
use super::{Output, Tab}; use super::{Output, Tab};
use crate::screen::CopyOptions; use crate::screen::CopyOptions;
use crate::zellij_tile::data::{ModeInfo, Palette};
use crate::Arc; use crate::Arc;
use crate::Mutex; use crate::Mutex;
use crate::{ use crate::{
@ -11,7 +10,6 @@ use crate::{
}; };
use std::convert::TryInto; use std::convert::TryInto;
use std::path::PathBuf; use std::path::PathBuf;
use zellij_tile::prelude::Style;
use zellij_utils::envs::set_session_name; use zellij_utils::envs::set_session_name;
use zellij_utils::input::layout::LayoutTemplate; use zellij_utils::input::layout::LayoutTemplate;
use zellij_utils::ipc::IpcReceiverWithContext; use zellij_utils::ipc::IpcReceiverWithContext;
@ -27,6 +25,7 @@ use std::rc::Rc;
use zellij_utils::nix; use zellij_utils::nix;
use zellij_utils::{ use zellij_utils::{
data::{ModeInfo, Palette, Style},
input::command::TerminalAction, input::command::TerminalAction,
interprocess::local_socket::LocalSocketStream, interprocess::local_socket::LocalSocketStream,
ipc::{ClientToServerMsg, ServerToClientMsg}, ipc::{ClientToServerMsg, ServerToClientMsg},

View file

@ -1,6 +1,5 @@
use super::Tab; use super::Tab;
use crate::screen::CopyOptions; use crate::screen::CopyOptions;
use crate::zellij_tile::data::{ModeInfo, Palette};
use crate::{ use crate::{
os_input_output::{AsyncReader, Pid, ServerOsApi}, os_input_output::{AsyncReader, Pid, ServerOsApi},
panes::PaneId, panes::PaneId,
@ -9,7 +8,6 @@ use crate::{
}; };
use std::convert::TryInto; use std::convert::TryInto;
use std::path::PathBuf; use std::path::PathBuf;
use zellij_tile::prelude::Style;
use zellij_utils::input::layout::LayoutTemplate; use zellij_utils::input::layout::LayoutTemplate;
use zellij_utils::ipc::IpcReceiverWithContext; use zellij_utils::ipc::IpcReceiverWithContext;
use zellij_utils::pane_size::{Size, SizeInPixels}; use zellij_utils::pane_size::{Size, SizeInPixels};
@ -22,6 +20,7 @@ use std::rc::Rc;
use zellij_utils::nix; use zellij_utils::nix;
use zellij_utils::{ use zellij_utils::{
data::{ModeInfo, Palette, Style},
input::command::TerminalAction, input::command::TerminalAction,
interprocess::local_socket::LocalSocketStream, interprocess::local_socket::LocalSocketStream,
ipc::{ClientToServerMsg, ServerToClientMsg}, ipc::{ClientToServerMsg, ServerToClientMsg},

View file

@ -1,12 +1,11 @@
use zellij_utils::{pane_size::Viewport, zellij_tile}; use zellij_utils::pane_size::Viewport;
use crate::output::CharacterChunk; use crate::output::CharacterChunk;
use crate::panes::terminal_character::{TerminalCharacter, EMPTY_TERMINAL_CHARACTER, RESET_STYLES}; use crate::panes::terminal_character::{TerminalCharacter, EMPTY_TERMINAL_CHARACTER, RESET_STYLES};
use crate::tab::Pane; use crate::tab::Pane;
use ansi_term::Colour::{Fixed, RGB}; use ansi_term::Colour::{Fixed, RGB};
use std::collections::HashMap; use std::collections::HashMap;
use zellij_tile::data::PaletteColor; use zellij_utils::{data::PaletteColor, shared::colors};
use zellij_utils::shared::colors;
use std::fmt::{Display, Error, Formatter}; use std::fmt::{Display, Error, Formatter};
pub mod boundary_type { pub mod boundary_type {

View file

@ -2,9 +2,8 @@ use crate::output::CharacterChunk;
use crate::panes::{AnsiCode, CharacterStyles, TerminalCharacter, EMPTY_TERMINAL_CHARACTER}; use crate::panes::{AnsiCode, CharacterStyles, TerminalCharacter, EMPTY_TERMINAL_CHARACTER};
use crate::ui::boundaries::boundary_type; use crate::ui::boundaries::boundary_type;
use crate::ClientId; use crate::ClientId;
use zellij_tile::prelude::Style; use zellij_utils::data::{client_id_to_colors, PaletteColor, Style};
use zellij_utils::pane_size::Viewport; use zellij_utils::pane_size::Viewport;
use zellij_utils::zellij_tile::prelude::{client_id_to_colors, PaletteColor};
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr}; use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};

View file

@ -5,9 +5,8 @@ use crate::ui::boundaries::Boundaries;
use crate::ui::pane_boundaries_frame::FrameParams; use crate::ui::pane_boundaries_frame::FrameParams;
use crate::ClientId; use crate::ClientId;
use std::collections::HashMap; use std::collections::HashMap;
use zellij_tile::{ use zellij_utils::data::{
data::{client_id_to_colors, single_client_color, InputMode, PaletteColor}, client_id_to_colors, single_client_color, InputMode, PaletteColor, Style,
prelude::Style,
}; };
pub struct PaneContentsAndUi<'a> { pub struct PaneContentsAndUi<'a> {
pane: &'a mut Box<dyn Pane>, pane: &'a mut Box<dyn Pane>,

View file

@ -1,6 +1,5 @@
use super::{CopyOptions, Screen, ScreenInstruction}; use super::{CopyOptions, Screen, ScreenInstruction};
use crate::panes::PaneId; use crate::panes::PaneId;
use crate::zellij_tile::data::{ModeInfo, Palette};
use crate::{ use crate::{
os_input_output::{AsyncReader, Pid, ServerOsApi}, os_input_output::{AsyncReader, Pid, ServerOsApi},
thread_bus::Bus, thread_bus::Bus,
@ -19,6 +18,7 @@ use zellij_utils::ipc::{ClientAttributes, PixelDimensions};
use zellij_utils::nix; use zellij_utils::nix;
use zellij_utils::{ use zellij_utils::{
data::{ModeInfo, Palette},
interprocess::local_socket::LocalSocketStream, interprocess::local_socket::LocalSocketStream,
ipc::{ClientToServerMsg, ServerToClientMsg}, ipc::{ClientToServerMsg, ServerToClientMsg},
}; };

View file

@ -17,7 +17,6 @@ use wasmer::{
WasmerEnv, WasmerEnv,
}; };
use wasmer_wasi::{Pipe, WasiEnv, WasiState}; use wasmer_wasi::{Pipe, WasiEnv, WasiState};
use zellij_tile::data::{Event, EventType, PluginIds};
use crate::{ use crate::{
logging_pipe::LoggingPipe, logging_pipe::LoggingPipe,
@ -30,13 +29,14 @@ use crate::{
use zellij_utils::{ use zellij_utils::{
consts::{VERSION, ZELLIJ_CACHE_DIR, ZELLIJ_PROJ_DIR, ZELLIJ_TMP_DIR}, consts::{VERSION, ZELLIJ_CACHE_DIR, ZELLIJ_PROJ_DIR, ZELLIJ_TMP_DIR},
data::{Event, EventType, PluginIds},
errors::{ContextType, PluginContext}, errors::{ContextType, PluginContext},
}; };
use zellij_utils::{ use zellij_utils::{
input::command::TerminalAction, input::command::TerminalAction,
input::layout::RunPlugin, input::layout::RunPlugin,
input::plugins::{PluginConfig, PluginType, PluginsConfig}, input::plugins::{PluginConfig, PluginType, PluginsConfig},
serde, zellij_tile, serde,
}; };
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View file

@ -12,3 +12,4 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
strum = "0.20.0" strum = "0.20.0"
strum_macros = "0.20.0" strum_macros = "0.20.0"
zellij-utils = { path = "../zellij-utils/", version = "0.31.0" }

View file

@ -1,8 +1,7 @@
pub mod data;
pub mod prelude; pub mod prelude;
pub mod shim; pub mod shim;
use data::*; use zellij_utils::data::Event;
#[allow(unused_variables)] #[allow(unused_variables)]
pub trait ZellijPlugin { pub trait ZellijPlugin {

View file

@ -1,3 +1,3 @@
pub use crate::data::*;
pub use crate::shim::*; pub use crate::shim::*;
pub use crate::*; pub use crate::*;
pub use zellij_utils::data::*;

View file

@ -1,7 +1,6 @@
use serde::{de::DeserializeOwned, Serialize}; use serde::{de::DeserializeOwned, Serialize};
use std::{io, path::Path}; use std::{io, path::Path};
use zellij_utils::data::*;
use crate::data::*;
// Subscription Handling // Subscription Handling

View file

@ -18,7 +18,6 @@ colored = "2.0.0"
colorsys = "0.6.5" colorsys = "0.6.5"
crossbeam = "0.8.1" crossbeam = "0.8.1"
directories-next = "2.0" directories-next = "2.0"
interprocess = "1.1.1"
lazy_static = "1.4.0" lazy_static = "1.4.0"
libc = "0.2" libc = "0.2"
nix = "0.23.1" nix = "0.23.1"
@ -26,25 +25,25 @@ once_cell = "1.8.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8" serde_yaml = "0.8"
serde_json = "1.0" serde_json = "1.0"
signal-hook = "0.3"
strip-ansi-escapes = "0.1.0" strip-ansi-escapes = "0.1.0"
strum = "0.20.0" strum = "0.20.0"
strum_macros = "0.20.1"
thiserror = "1.0.30" thiserror = "1.0.30"
url = { version = "2.2.2", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
vte = "0.10.1" vte = "0.10.1"
zellij-tile = { path = "../zellij-tile/", version = "0.31.0" }
log = "0.4.17" log = "0.4.17"
log4rs = "1.0.0"
unicode-width = "0.1.8" unicode-width = "0.1.8"
miette = { version = "3.3.0", features = ["fancy"] } miette = { version = "3.3.0", features = ["fancy"] }
regex = "1.5.5" regex = "1.5.5"
termwiz = "0.16.0"
tempfile = "3.2.0" tempfile = "3.2.0"
#[cfg(not(target_family = "wasm"))]
[dependencies.async-std] [target.'cfg(not(target_family = "wasm"))'.dependencies]
version = "1.3.0" termwiz = "0.16.0"
features = ["unstable"] log4rs = "1.0.0"
signal-hook = "0.3"
interprocess = "1.1.1"
async-std = { version = "1.3.0", features = ["unstable"] }
[dev-dependencies] [dev-dependencies]

View file

@ -2,9 +2,9 @@
use super::command::RunCommandAction; use super::command::RunCommandAction;
use super::layout::TabLayout; use super::layout::TabLayout;
use crate::data::InputMode;
use crate::input::options::OnForceClose; use crate::input::options::OnForceClose;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zellij_tile::data::InputMode;
use crate::position::Position; use crate::position::Position;

View file

@ -3,10 +3,10 @@ use std::collections::HashMap;
use super::actions::Action; use super::actions::Action;
use super::config; use super::config;
use crate::input::{InputMode, Key};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::IntoEnumIterator; use strum::IntoEnumIterator;
use zellij_tile::data::*;
/// Used in the config struct /// Used in the config struct
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]

View file

@ -10,12 +10,12 @@ pub mod options;
pub mod plugins; pub mod plugins;
pub mod theme; pub mod theme;
use super::{
data::{CharOrArrow, Direction, Style},
data::{InputMode, Key, ModeInfo, PluginCapabilities},
};
use crate::envs; use crate::envs;
use termwiz::input::{InputEvent, InputParser, KeyCode, KeyEvent, Modifiers}; use termwiz::input::{InputEvent, InputParser, KeyCode, KeyEvent, Modifiers};
use zellij_tile::{
data::{InputMode, Key, ModeInfo, PluginCapabilities},
prelude::{CharOrArrow, Direction, Style},
};
/// Creates a [`ModeInfo`] struct indicating the current [`InputMode`] and its keybinds /// Creates a [`ModeInfo`] struct indicating the current [`InputMode`] and its keybinds
/// (as pairs of [`String`]s). /// (as pairs of [`String`]s).

View file

@ -1,10 +1,10 @@
//! Handles cli and configuration options //! Handles cli and configuration options
use crate::cli::Command; use crate::cli::Command;
use crate::data::InputMode;
use clap::{ArgEnum, Args}; use clap::{ArgEnum, Args};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use zellij_tile::data::InputMode;
#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize, ArgEnum)] #[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize, ArgEnum)]
pub enum OnForceClose { pub enum OnForceClose {

View file

@ -12,8 +12,8 @@ use url::Url;
use super::config::ConfigFromYaml; use super::config::ConfigFromYaml;
use super::layout::{RunPlugin, RunPluginLocation}; use super::layout::{RunPlugin, RunPluginLocation};
pub use crate::data::PluginTag;
use crate::setup; use crate::setup;
pub use zellij_tile::data::PluginTag;
lazy_static! { lazy_static! {
static ref DEFAULT_CONFIG_PLUGINS: PluginsConfig = { static ref DEFAULT_CONFIG_PLUGINS: PluginsConfig = {

View file

@ -5,8 +5,8 @@ use serde::{
use std::{collections::HashMap, fmt}; use std::{collections::HashMap, fmt};
use super::options::Options; use super::options::Options;
use crate::data::{Palette, PaletteColor};
use crate::shared::detect_theme_hue; use crate::shared::detect_theme_hue;
use zellij_tile::data::{Palette, PaletteColor};
/// Intermediate deserialization of themes /// Intermediate deserialization of themes
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
@ -137,6 +137,7 @@ impl ThemesFromYaml {
self.0.remove(&theme) self.0.remove(&theme)
} }
#[allow(clippy::wrong_self_convention)]
fn from_default_theme(&mut self, theme: String) -> Option<Palette> { fn from_default_theme(&mut self, theme: String) -> Option<Palette> {
self.clone() self.clone()
.get_theme(theme) .get_theme(theme)

View file

@ -1,6 +1,7 @@
use super::super::actions::*; use super::super::actions::*;
use super::super::keybinds::*; use super::super::keybinds::*;
use zellij_tile::data::Key; use crate::data::Key;
use crate::input::CharOrArrow;
#[test] #[test]
fn merge_keybinds_merges_different_keys() { fn merge_keybinds_merges_different_keys() {

View file

@ -2,6 +2,7 @@
use crate::{ use crate::{
cli::CliArgs, cli::CliArgs,
data::{ClientId, InputMode, Style},
errors::{get_current_ctx, ErrorContext}, errors::{get_current_ctx, ErrorContext},
input::{actions::Action, layout::LayoutFromYaml, options::Options, plugins::PluginsConfig}, input::{actions::Action, layout::LayoutFromYaml, options::Options, plugins::PluginsConfig},
pane_size::{Size, SizeInPixels}, pane_size::{Size, SizeInPixels},
@ -17,11 +18,6 @@ use std::{
os::unix::io::{AsRawFd, FromRawFd}, os::unix::io::{AsRawFd, FromRawFd},
}; };
use zellij_tile::{
data::InputMode,
prelude::{ClientId, Style},
};
type SessionId = u64; type SessionId = u64;
#[derive(PartialEq, Eq, Serialize, Deserialize, Hash)] #[derive(PartialEq, Eq, Serialize, Deserialize, Hash)]

View file

@ -1,28 +1,32 @@
pub mod data;
#[cfg(not(target_family = "wasm"))]
pub mod channels; pub mod channels;
#[cfg(not(target_family = "wasm"))]
pub mod cli; pub mod cli;
#[cfg(not(target_family = "wasm"))]
pub mod consts; pub mod consts;
#[cfg(not(target_family = "wasm"))]
pub mod envs; pub mod envs;
#[cfg(not(target_family = "wasm"))]
pub mod errors; pub mod errors;
#[cfg(not(target_family = "wasm"))]
pub mod input; pub mod input;
#[cfg(not(target_family = "wasm"))]
pub mod ipc; pub mod ipc;
#[cfg(not(target_family = "wasm"))]
pub mod logging; pub mod logging;
#[cfg(not(target_family = "wasm"))]
pub mod pane_size; pub mod pane_size;
#[cfg(not(target_family = "wasm"))]
pub mod position; pub mod position;
#[cfg(not(target_family = "wasm"))]
pub mod setup; pub mod setup;
#[cfg(not(target_family = "wasm"))]
pub mod shared; pub mod shared;
pub use anyhow; #[cfg(not(target_family = "wasm"))]
pub use async_std; pub use ::{
pub use clap; anyhow, async_std, clap, interprocess, lazy_static, libc, nix, regex, serde, serde_yaml,
pub use interprocess; signal_hook, tempfile, termwiz, vte,
pub use lazy_static; };
pub use libc;
pub use nix;
pub use regex;
pub use serde;
pub use serde_yaml;
pub use signal_hook;
pub use tempfile;
pub use termwiz;
pub use vte;
pub use zellij_tile;

View file

@ -476,6 +476,7 @@ impl Setup {
#[cfg(test)] #[cfg(test)]
mod setup_test { mod setup_test {
use super::Setup; use super::Setup;
use crate::data::InputMode;
use crate::input::{ use crate::input::{
config::{Config, ConfigError}, config::{Config, ConfigError},
layout::LayoutFromYamlIntermediate, layout::LayoutFromYamlIntermediate,
@ -554,7 +555,7 @@ mod setup_test {
fn nonempty_config_nonempty_layout() { fn nonempty_config_nonempty_layout() {
let mut goal = Config::default(); let mut goal = Config::default();
goal.options.default_shell = Some(std::path::PathBuf::from("bash")); goal.options.default_shell = Some(std::path::PathBuf::from("bash"));
goal.options.default_mode = Some(zellij_tile::prelude::InputMode::Locked); goal.options.default_mode = Some(InputMode::Locked);
let config = r"--- let config = r"---
default_mode: locked"; default_mode: locked";
let layout = r"--- let layout = r"---

View file

@ -2,6 +2,7 @@
use std::{iter, str::from_utf8}; use std::{iter, str::from_utf8};
use crate::data::{Palette, PaletteColor, PaletteSource, ThemeHue};
use crate::envs::get_session_name; use crate::envs::get_session_name;
use colorsys::Rgb; use colorsys::Rgb;
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
@ -9,7 +10,6 @@ use std::path::Path;
use std::{fs, io}; use std::{fs, io};
use strip_ansi_escapes::strip; use strip_ansi_escapes::strip;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use zellij_tile::data::{Palette, PaletteColor, PaletteSource, ThemeHue};
pub fn set_permissions(path: &Path, mode: u32) -> io::Result<()> { pub fn set_permissions(path: &Path, mode: u32) -> io::Result<()> {
let mut permissions = fs::metadata(path)?.permissions(); let mut permissions = fs::metadata(path)?.permissions();