mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-27 11:16:20 +03:00
chore: formatting
This commit is contained in:
parent
be9a059116
commit
354316d20c
@ -1,9 +1,6 @@
|
|||||||
pub mod boundaries;
|
pub mod boundaries;
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
pub mod tab;
|
|
||||||
pub mod panes;
|
pub mod panes;
|
||||||
|
pub mod tab;
|
||||||
|
|
||||||
|
pub fn start_client() {}
|
||||||
pub fn start_client() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#![allow(clippy::clippy::if_same_then_else)]
|
#![allow(clippy::clippy::if_same_then_else)]
|
||||||
|
|
||||||
use crate::{pty_bus::VteEvent, tab::Pane, wasm_vm::PluginInstruction, common::SenderWithContext};
|
use crate::{common::SenderWithContext, pty_bus::VteEvent, tab::Pane, wasm_vm::PluginInstruction};
|
||||||
|
|
||||||
use std::{sync::mpsc::channel, unimplemented};
|
use std::{sync::mpsc::channel, unimplemented};
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
use crate::common::{AppInstruction, SenderWithContext};
|
||||||
use crate::panes::{PaneId, PositionAndSize, TerminalPane};
|
use crate::panes::{PaneId, PositionAndSize, TerminalPane};
|
||||||
use crate::pty_bus::{PtyInstruction, VteEvent};
|
use crate::pty_bus::{PtyInstruction, VteEvent};
|
||||||
use crate::{boundaries::Boundaries, panes::PluginPane};
|
use crate::{boundaries::Boundaries, panes::PluginPane};
|
||||||
use crate::{layout::Layout, wasm_vm::PluginInstruction};
|
use crate::{layout::Layout, wasm_vm::PluginInstruction};
|
||||||
use crate::{os_input_output::OsApi, utils::shared::pad_to_size};
|
use crate::{os_input_output::OsApi, utils::shared::pad_to_size};
|
||||||
use crate::common::{AppInstruction, SenderWithContext};
|
|
||||||
use std::os::unix::io::RawFd;
|
use std::os::unix::io::RawFd;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Reverse,
|
cmp::Reverse,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
use super::{AppInstruction, OPENCALLS};
|
||||||
use crate::pty_bus::PtyInstruction;
|
use crate::pty_bus::PtyInstruction;
|
||||||
use crate::screen::ScreenInstruction;
|
use crate::screen::ScreenInstruction;
|
||||||
use super::{AppInstruction, OPENCALLS};
|
|
||||||
|
|
||||||
use std::fmt::{Display, Error, Formatter};
|
use std::fmt::{Display, Error, Formatter};
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
use super::{os_input_output::OsApi, update_state, AppState};
|
||||||
|
use super::{AppInstruction, SenderWithContext, OPENCALLS};
|
||||||
use crate::pty_bus::PtyInstruction;
|
use crate::pty_bus::PtyInstruction;
|
||||||
use crate::screen::ScreenInstruction;
|
use crate::screen::ScreenInstruction;
|
||||||
use crate::CommandIsExecuting;
|
use crate::CommandIsExecuting;
|
||||||
use crate::{errors::ContextType, wasm_vm::PluginInstruction};
|
use crate::{errors::ContextType, wasm_vm::PluginInstruction};
|
||||||
use super::{os_input_output::OsApi, update_state, AppState};
|
|
||||||
use super::{AppInstruction, SenderWithContext, OPENCALLS};
|
|
||||||
|
|
||||||
struct InputHandler {
|
struct InputHandler {
|
||||||
mode: InputMode,
|
mode: InputMode,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// IPC stuff for starting to split things into a client and server model
|
// IPC stuff for starting to split things into a client and server model
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use serde::{Serialize, Deserialize};
|
|
||||||
|
|
||||||
type SessionID = u64;
|
type SessionID = u64;
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
pub mod command_is_executing;
|
||||||
|
pub mod errors;
|
||||||
pub mod input;
|
pub mod input;
|
||||||
|
pub mod ipc;
|
||||||
pub mod os_input_output;
|
pub mod os_input_output;
|
||||||
pub mod pty_bus;
|
pub mod pty_bus;
|
||||||
pub mod screen;
|
pub mod screen;
|
||||||
pub mod ipc;
|
|
||||||
pub mod wasm_vm;
|
|
||||||
pub mod command_is_executing;
|
|
||||||
pub mod errors;
|
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
pub mod wasm_vm;
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::os::unix::net::UnixStream;
|
use std::os::unix::net::UnixStream;
|
||||||
@ -16,23 +16,21 @@ use std::thread;
|
|||||||
use std::{cell::RefCell, sync::mpsc::TrySendError};
|
use std::{cell::RefCell, sync::mpsc::TrySendError};
|
||||||
use std::{collections::HashMap, fs};
|
use std::{collections::HashMap, fs};
|
||||||
|
|
||||||
|
use crate::panes::PaneId;
|
||||||
use directories_next::ProjectDirs;
|
use directories_next::ProjectDirs;
|
||||||
use input::InputMode;
|
use input::InputMode;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use crate::panes::PaneId;
|
|
||||||
use termion::input::TermRead;
|
use termion::input::TermRead;
|
||||||
use wasm_vm::PluginEnv;
|
use wasm_vm::PluginEnv;
|
||||||
use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value};
|
use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value};
|
||||||
use wasmer_wasi::{Pipe, WasiState};
|
use wasmer_wasi::{Pipe, WasiState};
|
||||||
|
|
||||||
use crate::cli::CliArgs;
|
use crate::cli::CliArgs;
|
||||||
use command_is_executing::CommandIsExecuting;
|
|
||||||
use errors::{
|
|
||||||
AppContext, ContextType, ErrorContext, PluginContext, PtyContext, ScreenContext,
|
|
||||||
};
|
|
||||||
use input::input_loop;
|
|
||||||
use crate::layout::Layout;
|
use crate::layout::Layout;
|
||||||
|
use command_is_executing::CommandIsExecuting;
|
||||||
|
use errors::{AppContext, ContextType, ErrorContext, PluginContext, PtyContext, ScreenContext};
|
||||||
|
use input::input_loop;
|
||||||
use os_input_output::{get_os_input, OsApi};
|
use os_input_output::{get_os_input, OsApi};
|
||||||
use pty_bus::{PtyBus, PtyInstruction, VteEvent};
|
use pty_bus::{PtyBus, PtyInstruction, VteEvent};
|
||||||
use screen::{Screen, ScreenInstruction};
|
use screen::{Screen, ScreenInstruction};
|
||||||
@ -43,6 +41,14 @@ use utils::{
|
|||||||
};
|
};
|
||||||
use wasm_vm::{mosaic_imports, wasi_stdout, wasi_write_string, PluginInstruction};
|
use wasm_vm::{mosaic_imports, wasi_stdout, wasi_write_string, PluginInstruction};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub enum ApiCommand {
|
||||||
|
OpenFile(PathBuf),
|
||||||
|
SplitHorizontally,
|
||||||
|
SplitVertically,
|
||||||
|
MoveFocus,
|
||||||
|
}
|
||||||
|
// FIXME: It would be good to add some more things to this over time
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
pub input_mode: InputMode,
|
pub input_mode: InputMode,
|
||||||
@ -55,7 +61,19 @@ impl Default for AppState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// FIXME: Make this a method on the big `Communication` struct, so that app_tx can be extracted
|
||||||
|
// from self instead of being explicitly passed here
|
||||||
|
pub fn update_state(
|
||||||
|
app_tx: &SenderWithContext<AppInstruction>,
|
||||||
|
update_fn: impl FnOnce(AppState) -> AppState,
|
||||||
|
) {
|
||||||
|
let (state_tx, state_rx) = channel();
|
||||||
|
|
||||||
|
drop(app_tx.send(AppInstruction::GetState(state_tx)));
|
||||||
|
let state = state_rx.recv().unwrap();
|
||||||
|
|
||||||
|
drop(app_tx.send(AppInstruction::SetState(update_fn(state))))
|
||||||
|
}
|
||||||
|
|
||||||
pub type ChannelWithContext<T> = (Sender<(T, ErrorContext)>, Receiver<(T, ErrorContext)>);
|
pub type ChannelWithContext<T> = (Sender<(T, ErrorContext)>, Receiver<(T, ErrorContext)>);
|
||||||
pub type SyncChannelWithContext<T> = (SyncSender<(T, ErrorContext)>, Receiver<(T, ErrorContext)>);
|
pub type SyncChannelWithContext<T> = (SyncSender<(T, ErrorContext)>, Receiver<(T, ErrorContext)>);
|
||||||
@ -97,31 +115,11 @@ impl<T: Clone> SenderWithContext<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
pub enum ApiCommand {
|
|
||||||
OpenFile(PathBuf),
|
|
||||||
SplitHorizontally,
|
|
||||||
SplitVertically,
|
|
||||||
MoveFocus,
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<T: Clone> Send for SenderWithContext<T> {}
|
unsafe impl<T: Clone> Send for SenderWithContext<T> {}
|
||||||
unsafe impl<T: Clone> Sync for SenderWithContext<T> {}
|
unsafe impl<T: Clone> Sync for SenderWithContext<T> {}
|
||||||
|
|
||||||
thread_local!(static OPENCALLS: RefCell<ErrorContext> = RefCell::default());
|
thread_local!(static OPENCALLS: RefCell<ErrorContext> = RefCell::default());
|
||||||
|
|
||||||
pub fn update_state(
|
|
||||||
app_tx: &SenderWithContext<AppInstruction>,
|
|
||||||
update_fn: impl FnOnce(AppState) -> AppState,
|
|
||||||
) {
|
|
||||||
let (state_tx, state_rx) = channel();
|
|
||||||
|
|
||||||
drop(app_tx.send(AppInstruction::GetState(state_tx)));
|
|
||||||
let state = state_rx.recv().unwrap();
|
|
||||||
|
|
||||||
drop(app_tx.send(AppInstruction::SetState(update_fn(state))))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum AppInstruction {
|
pub enum AppInstruction {
|
||||||
GetState(Sender<AppState>),
|
GetState(Sender<AppState>),
|
||||||
@ -130,7 +128,6 @@ pub enum AppInstruction {
|
|||||||
Error(String),
|
Error(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||||
let take_snapshot = "\u{1b}[?1049h";
|
let take_snapshot = "\u{1b}[?1049h";
|
||||||
os_input.unset_raw_mode(0);
|
os_input.unset_raw_mode(0);
|
||||||
|
@ -9,6 +9,7 @@ use ::std::time::{Duration, Instant};
|
|||||||
use ::vte;
|
use ::vte;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use super::{ScreenInstruction, SenderWithContext, OPENCALLS};
|
||||||
use crate::os_input_output::OsApi;
|
use crate::os_input_output::OsApi;
|
||||||
use crate::utils::logging::debug_to_file;
|
use crate::utils::logging::debug_to_file;
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -16,7 +17,6 @@ use crate::{
|
|||||||
panes::PaneId,
|
panes::PaneId,
|
||||||
};
|
};
|
||||||
use crate::{layout::Layout, wasm_vm::PluginInstruction};
|
use crate::{layout::Layout, wasm_vm::PluginInstruction};
|
||||||
use super::{ScreenInstruction, SenderWithContext, OPENCALLS};
|
|
||||||
|
|
||||||
pub struct ReadFromPid {
|
pub struct ReadFromPid {
|
||||||
pid: RawFd,
|
pid: RawFd,
|
||||||
|
@ -2,13 +2,13 @@ use std::collections::BTreeMap;
|
|||||||
use std::os::unix::io::RawFd;
|
use std::os::unix::io::RawFd;
|
||||||
use std::sync::mpsc::Receiver;
|
use std::sync::mpsc::Receiver;
|
||||||
|
|
||||||
|
use super::{AppInstruction, SenderWithContext};
|
||||||
use crate::os_input_output::OsApi;
|
use crate::os_input_output::OsApi;
|
||||||
use crate::panes::PositionAndSize;
|
use crate::panes::PositionAndSize;
|
||||||
use crate::pty_bus::{PtyInstruction, VteEvent};
|
use crate::pty_bus::{PtyInstruction, VteEvent};
|
||||||
use crate::tab::Tab;
|
use crate::tab::Tab;
|
||||||
use crate::{errors::ErrorContext, wasm_vm::PluginInstruction};
|
use crate::{errors::ErrorContext, wasm_vm::PluginInstruction};
|
||||||
use crate::{layout::Layout, panes::PaneId};
|
use crate::{layout::Layout, panes::PaneId};
|
||||||
use super::{AppInstruction, SenderWithContext};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Screen
|
* Screen
|
||||||
|
@ -6,8 +6,8 @@ use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
|
|||||||
use wasmer_wasi::WasiEnv;
|
use wasmer_wasi::WasiEnv;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
input::get_help, PaneId, pty_bus::PtyInstruction, screen::ScreenInstruction,
|
input::get_help, pty_bus::PtyInstruction, screen::ScreenInstruction, AppInstruction, PaneId,
|
||||||
AppInstruction, SenderWithContext,
|
SenderWithContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -6,9 +6,11 @@ mod common;
|
|||||||
// TODO mod server;
|
// TODO mod server;
|
||||||
mod client;
|
mod client;
|
||||||
|
|
||||||
use common::{pty_bus, os_input_output, screen, ipc, wasm_vm, command_is_executing, errors, utils, start, ApiCommand};
|
use client::{boundaries, layout, panes, tab};
|
||||||
use client::{tab, layout, boundaries, panes};
|
use common::{
|
||||||
|
command_is_executing, errors, ipc, os_input_output, pty_bus, screen, start, utils, wasm_vm,
|
||||||
|
ApiCommand,
|
||||||
|
};
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::os::unix::net::UnixStream;
|
use std::os::unix::net::UnixStream;
|
||||||
@ -17,8 +19,8 @@ use structopt::StructOpt;
|
|||||||
|
|
||||||
use crate::cli::CliArgs;
|
use crate::cli::CliArgs;
|
||||||
use crate::command_is_executing::CommandIsExecuting;
|
use crate::command_is_executing::CommandIsExecuting;
|
||||||
use crate::os_input_output::{get_os_input};
|
use crate::os_input_output::get_os_input;
|
||||||
use crate::pty_bus::{VteEvent};
|
use crate::pty_bus::VteEvent;
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
consts::{MOSAIC_IPC_PIPE, MOSAIC_TMP_DIR, MOSAIC_TMP_LOG_DIR},
|
consts::{MOSAIC_IPC_PIPE, MOSAIC_TMP_DIR, MOSAIC_TMP_LOG_DIR},
|
||||||
logging::*,
|
logging::*,
|
||||||
|
Loading…
Reference in New Issue
Block a user