mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-26 10:43:46 +03:00
chore: formatting
This commit is contained in:
parent
be9a059116
commit
354316d20c
@ -1,9 +1,6 @@
|
||||
pub mod boundaries;
|
||||
pub mod layout;
|
||||
pub mod tab;
|
||||
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)]
|
||||
|
||||
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};
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::common::{AppInstruction, SenderWithContext};
|
||||
use crate::panes::{PaneId, PositionAndSize, TerminalPane};
|
||||
use crate::pty_bus::{PtyInstruction, VteEvent};
|
||||
use crate::{boundaries::Boundaries, panes::PluginPane};
|
||||
use crate::{layout::Layout, wasm_vm::PluginInstruction};
|
||||
use crate::{os_input_output::OsApi, utils::shared::pad_to_size};
|
||||
use crate::common::{AppInstruction, SenderWithContext};
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::{AppInstruction, OPENCALLS};
|
||||
use crate::pty_bus::PtyInstruction;
|
||||
use crate::screen::ScreenInstruction;
|
||||
use super::{AppInstruction, OPENCALLS};
|
||||
|
||||
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::screen::ScreenInstruction;
|
||||
use crate::CommandIsExecuting;
|
||||
use crate::{errors::ContextType, wasm_vm::PluginInstruction};
|
||||
use super::{os_input_output::OsApi, update_state, AppState};
|
||||
use super::{AppInstruction, SenderWithContext, OPENCALLS};
|
||||
|
||||
struct InputHandler {
|
||||
mode: InputMode,
|
||||
|
@ -1,6 +1,6 @@
|
||||
// IPC stuff for starting to split things into a client and server model
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
type SessionID = u64;
|
||||
|
||||
@ -30,7 +30,7 @@ pub enum ClientToServerMsg {
|
||||
CreateSession,
|
||||
// Attach to a running session
|
||||
AttachToSession(SessionID, ClientType),
|
||||
// Force detach
|
||||
// Force detach
|
||||
DetachSession(SessionID),
|
||||
// Disconnect from the session we're connected to
|
||||
DisconnectFromSession,
|
||||
@ -43,4 +43,4 @@ pub enum ServerToClientMsg {
|
||||
SessionInfo(Session),
|
||||
// A list of sessions
|
||||
SessionList(HashSet<Session>),
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
pub mod command_is_executing;
|
||||
pub mod errors;
|
||||
pub mod input;
|
||||
pub mod ipc;
|
||||
pub mod os_input_output;
|
||||
pub mod pty_bus;
|
||||
pub mod screen;
|
||||
pub mod ipc;
|
||||
pub mod wasm_vm;
|
||||
pub mod command_is_executing;
|
||||
pub mod errors;
|
||||
pub mod utils;
|
||||
pub mod wasm_vm;
|
||||
|
||||
use std::io::Write;
|
||||
use std::os::unix::net::UnixStream;
|
||||
@ -16,23 +16,21 @@ use std::thread;
|
||||
use std::{cell::RefCell, sync::mpsc::TrySendError};
|
||||
use std::{collections::HashMap, fs};
|
||||
|
||||
use crate::panes::PaneId;
|
||||
use directories_next::ProjectDirs;
|
||||
use input::InputMode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use structopt::StructOpt;
|
||||
use crate::panes::PaneId;
|
||||
use termion::input::TermRead;
|
||||
use wasm_vm::PluginEnv;
|
||||
use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value};
|
||||
use wasmer_wasi::{Pipe, WasiState};
|
||||
|
||||
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 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 pty_bus::{PtyBus, PtyInstruction, VteEvent};
|
||||
use screen::{Screen, ScreenInstruction};
|
||||
@ -43,6 +41,14 @@ use utils::{
|
||||
};
|
||||
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)]
|
||||
pub struct AppState {
|
||||
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 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> Sync for SenderWithContext<T> {}
|
||||
|
||||
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)]
|
||||
pub enum AppInstruction {
|
||||
GetState(Sender<AppState>),
|
||||
@ -130,7 +128,6 @@ pub enum AppInstruction {
|
||||
Error(String),
|
||||
}
|
||||
|
||||
|
||||
pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||
let take_snapshot = "\u{1b}[?1049h";
|
||||
os_input.unset_raw_mode(0);
|
||||
@ -668,4 +665,4 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||
.write(goodbye_message.as_bytes())
|
||||
.unwrap();
|
||||
os_input.get_stdout_writer().flush().unwrap();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use ::std::time::{Duration, Instant};
|
||||
use ::vte;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::{ScreenInstruction, SenderWithContext, OPENCALLS};
|
||||
use crate::os_input_output::OsApi;
|
||||
use crate::utils::logging::debug_to_file;
|
||||
use crate::{
|
||||
@ -16,7 +17,6 @@ use crate::{
|
||||
panes::PaneId,
|
||||
};
|
||||
use crate::{layout::Layout, wasm_vm::PluginInstruction};
|
||||
use super::{ScreenInstruction, SenderWithContext, OPENCALLS};
|
||||
|
||||
pub struct ReadFromPid {
|
||||
pid: RawFd,
|
||||
|
@ -2,13 +2,13 @@ use std::collections::BTreeMap;
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
use super::{AppInstruction, SenderWithContext};
|
||||
use crate::os_input_output::OsApi;
|
||||
use crate::panes::PositionAndSize;
|
||||
use crate::pty_bus::{PtyInstruction, VteEvent};
|
||||
use crate::tab::Tab;
|
||||
use crate::{errors::ErrorContext, wasm_vm::PluginInstruction};
|
||||
use crate::{layout::Layout, panes::PaneId};
|
||||
use super::{AppInstruction, SenderWithContext};
|
||||
|
||||
/*
|
||||
* Screen
|
||||
|
@ -6,8 +6,8 @@ use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
|
||||
use wasmer_wasi::WasiEnv;
|
||||
|
||||
use super::{
|
||||
input::get_help, PaneId, pty_bus::PtyInstruction, screen::ScreenInstruction,
|
||||
AppInstruction, SenderWithContext,
|
||||
input::get_help, pty_bus::PtyInstruction, screen::ScreenInstruction, AppInstruction, PaneId,
|
||||
SenderWithContext,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
14
src/main.rs
14
src/main.rs
@ -6,9 +6,11 @@ mod common;
|
||||
// TODO mod server;
|
||||
mod client;
|
||||
|
||||
use common::{pty_bus, os_input_output, screen, ipc, wasm_vm, command_is_executing, errors, utils, start, ApiCommand};
|
||||
use client::{tab, layout, boundaries, panes};
|
||||
|
||||
use client::{boundaries, layout, panes, tab};
|
||||
use common::{
|
||||
command_is_executing, errors, ipc, os_input_output, pty_bus, screen, start, utils, wasm_vm,
|
||||
ApiCommand,
|
||||
};
|
||||
|
||||
use std::io::Write;
|
||||
use std::os::unix::net::UnixStream;
|
||||
@ -17,8 +19,8 @@ use structopt::StructOpt;
|
||||
|
||||
use crate::cli::CliArgs;
|
||||
use crate::command_is_executing::CommandIsExecuting;
|
||||
use crate::os_input_output::{get_os_input};
|
||||
use crate::pty_bus::{VteEvent};
|
||||
use crate::os_input_output::get_os_input;
|
||||
use crate::pty_bus::VteEvent;
|
||||
use crate::utils::{
|
||||
consts::{MOSAIC_IPC_PIPE, MOSAIC_TMP_DIR, MOSAIC_TMP_LOG_DIR},
|
||||
logging::*,
|
||||
@ -54,4 +56,4 @@ pub fn main() {
|
||||
atomic_create_dir(MOSAIC_TMP_LOG_DIR).unwrap();
|
||||
start(Box::new(os_input), opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user