Update references in src/
This commit is contained in:
parent
30f0567d8a
commit
af95b3ff9a
11 changed files with 44 additions and 44 deletions
|
|
@ -2,17 +2,17 @@ use std::path::PathBuf;
|
|||
use structopt::StructOpt;
|
||||
|
||||
#[derive(StructOpt, Debug, Default)]
|
||||
#[structopt(name = "mosaic")]
|
||||
#[structopt(name = "zellij")]
|
||||
pub struct CliArgs {
|
||||
/// Send "split (direction h == horizontal / v == vertical)" to active mosaic session
|
||||
/// Send "split (direction h == horizontal / v == vertical)" to active zellij session
|
||||
#[structopt(short, long)]
|
||||
pub split: Option<char>,
|
||||
|
||||
/// Send "move focused pane" to active mosaic session
|
||||
/// Send "move focused pane" to active zellij session
|
||||
#[structopt(short, long)]
|
||||
pub move_focus: bool,
|
||||
|
||||
/// Send "open file in new pane" to active mosaic session
|
||||
/// Send "open file in new pane" to active zellij session
|
||||
#[structopt(short, long)]
|
||||
pub open_file: Option<PathBuf>,
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::utils::consts::MOSAIC_ROOT_LAYOUT_DIR;
|
||||
use crate::utils::consts::ZELLIJ_ROOT_LAYOUT_DIR;
|
||||
use directories_next::ProjectDirs;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
|
@ -182,9 +182,9 @@ pub struct Layout {
|
|||
|
||||
impl Layout {
|
||||
pub fn new(layout_path: PathBuf) -> Self {
|
||||
let project_dirs = ProjectDirs::from("org", "Mosaic Contributors", "Mosaic").unwrap();
|
||||
let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
|
||||
let layout_dir = project_dirs.data_dir().join("layouts/");
|
||||
let root_layout_dir = Path::new(MOSAIC_ROOT_LAYOUT_DIR);
|
||||
let root_layout_dir = Path::new(ZELLIJ_ROOT_LAYOUT_DIR);
|
||||
let mut layout_file = File::open(&layout_path)
|
||||
.or_else(|_| File::open(&layout_path.with_extension("yaml")))
|
||||
.or_else(|_| File::open(&layout_dir.join(&layout_path).with_extension("yaml")))
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub enum Direction {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub enum Action {
|
||||
/// Quit mosaic
|
||||
/// Quit Zellij
|
||||
Quit,
|
||||
/// Write to terminal
|
||||
Write(Vec<u8>),
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ impl InputHandler {
|
|||
}
|
||||
|
||||
/// Routine to be called when the input handler exits (at the moment this is the
|
||||
/// same as quitting mosaic)
|
||||
/// same as quitting zellij)
|
||||
fn exit(&mut self) {
|
||||
self.send_app_instructions
|
||||
.send(AppInstruction::Exit)
|
||||
|
|
@ -261,7 +261,7 @@ impl Default for InputState {
|
|||
/// Dictates whether we're in command mode, persistent command mode, normal mode or exiting:
|
||||
/// - Normal mode either writes characters to the terminal, or switches to command mode
|
||||
/// using a particular key control
|
||||
/// - Command mode intercepts characters to control mosaic itself, before switching immediately
|
||||
/// - Command mode intercepts characters to control zellij itself, before switching immediately
|
||||
/// back to normal mode
|
||||
/// - Persistent command mode is the same as command mode, but doesn't return automatically to
|
||||
/// normal mode
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ use input::handler::input_loop;
|
|||
use os_input_output::OsApi;
|
||||
use pty_bus::{PtyBus, PtyInstruction};
|
||||
use screen::{Screen, ScreenInstruction};
|
||||
use utils::consts::{MOSAIC_IPC_PIPE, MOSAIC_ROOT_PLUGIN_DIR};
|
||||
use wasm_vm::{mosaic_imports, wasi_stdout, wasi_write_string, PluginInstruction};
|
||||
use utils::consts::{ZELLIJ_IPC_PIPE, ZELLIJ_ROOT_PLUGIN_DIR};
|
||||
use wasm_vm::{wasi_stdout, wasi_write_string, zellij_imports, PluginInstruction};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum ApiCommand {
|
||||
|
|
@ -414,9 +414,9 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
match event {
|
||||
PluginInstruction::Load(pid_tx, path) => {
|
||||
let project_dirs =
|
||||
ProjectDirs::from("org", "Mosaic Contributors", "Mosaic").unwrap();
|
||||
ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
|
||||
let plugin_dir = project_dirs.data_dir().join("plugins/");
|
||||
let root_plugin_dir = Path::new(MOSAIC_ROOT_PLUGIN_DIR);
|
||||
let root_plugin_dir = Path::new(ZELLIJ_ROOT_PLUGIN_DIR);
|
||||
let wasm_bytes = fs::read(&path)
|
||||
.or_else(|_| fs::read(&path.with_extension("wasm")))
|
||||
.or_else(|_| fs::read(&plugin_dir.join(&path).with_extension("wasm")))
|
||||
|
|
@ -430,7 +430,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
|
||||
let output = Pipe::new();
|
||||
let input = Pipe::new();
|
||||
let mut wasi_env = WasiState::new("mosaic")
|
||||
let mut wasi_env = WasiState::new("Zellij")
|
||||
.env("CLICOLOR_FORCE", "1")
|
||||
.preopen(|p| {
|
||||
p.directory(".") // FIXME: Change this to a more meaningful dir
|
||||
|
|
@ -455,8 +455,8 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
wasi_env,
|
||||
};
|
||||
|
||||
let mosaic = mosaic_imports(&store, &plugin_env);
|
||||
let instance = Instance::new(&module, &mosaic.chain_back(wasi)).unwrap();
|
||||
let zellij = zellij_imports(&store, &plugin_env);
|
||||
let instance = Instance::new(&module, &zellij.chain_back(wasi)).unwrap();
|
||||
|
||||
let start = instance.exports.get_function("_start").unwrap();
|
||||
|
||||
|
|
@ -530,8 +530,8 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
|||
let mut send_pty_instructions = send_pty_instructions.clone();
|
||||
let mut send_screen_instructions = send_screen_instructions.clone();
|
||||
move || {
|
||||
std::fs::remove_file(MOSAIC_IPC_PIPE).ok();
|
||||
let listener = std::os::unix::net::UnixListener::bind(MOSAIC_IPC_PIPE)
|
||||
std::fs::remove_file(ZELLIJ_IPC_PIPE).ok();
|
||||
let listener = std::os::unix::net::UnixListener::bind(ZELLIJ_IPC_PIPE)
|
||||
.expect("could not listen on ipc socket");
|
||||
let mut err_ctx = OPENCALLS.with(|ctx| *ctx.borrow());
|
||||
err_ctx.add_call(ContextType::IPCServer);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
pub const MOSAIC_TMP_DIR: &str = "/tmp/mosaic";
|
||||
pub const MOSAIC_TMP_LOG_DIR: &str = "/tmp/mosaic/mosaic-log";
|
||||
pub const MOSAIC_TMP_LOG_FILE: &str = "/tmp/mosaic/mosaic-log/log.txt";
|
||||
pub const MOSAIC_IPC_PIPE: &str = "/tmp/mosaic/ipc";
|
||||
pub const MOSAIC_ROOT_PLUGIN_DIR: &str = "/usr/share/mosaic/plugins";
|
||||
pub const MOSAIC_ROOT_LAYOUT_DIR: &str = "/usr/share/mosaic/layouts";
|
||||
pub const ZELLIJ_TMP_DIR: &str = "/tmp/zellij";
|
||||
pub const ZELLIJ_TMP_LOG_DIR: &str = "/tmp/zellij/zellij-log";
|
||||
pub const ZELLIJ_TMP_LOG_FILE: &str = "/tmp/zellij/zellij-log/log.txt";
|
||||
pub const ZELLIJ_IPC_PIPE: &str = "/tmp/zellij/ipc";
|
||||
pub const ZELLIJ_ROOT_PLUGIN_DIR: &str = "/usr/share/zellij/plugins";
|
||||
pub const ZELLIJ_ROOT_LAYOUT_DIR: &str = "/usr/share/zellij/layouts";
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
path::PathBuf,
|
||||
};
|
||||
|
||||
use crate::utils::consts::{MOSAIC_TMP_LOG_DIR, MOSAIC_TMP_LOG_FILE};
|
||||
use crate::utils::consts::{ZELLIJ_TMP_LOG_DIR, ZELLIJ_TMP_LOG_FILE};
|
||||
|
||||
pub fn atomic_create_file(file_name: &str) {
|
||||
let _ = fs::OpenOptions::new().create(true).open(file_name);
|
||||
|
|
@ -29,11 +29,11 @@ pub fn debug_log_to_file(mut message: String) -> io::Result<()> {
|
|||
}
|
||||
|
||||
pub fn debug_log_to_file_without_newline(message: String) -> io::Result<()> {
|
||||
atomic_create_file(MOSAIC_TMP_LOG_FILE);
|
||||
atomic_create_file(ZELLIJ_TMP_LOG_FILE);
|
||||
let mut file = fs::OpenOptions::new()
|
||||
.append(true)
|
||||
.create(true)
|
||||
.open(MOSAIC_TMP_LOG_FILE)?;
|
||||
.open(ZELLIJ_TMP_LOG_FILE)?;
|
||||
file.write_all(message.as_bytes())
|
||||
}
|
||||
|
||||
|
|
@ -47,8 +47,8 @@ pub fn _debug_log_to_file_pid_3(message: String, pid: RawFd) -> io::Result<()> {
|
|||
|
||||
#[allow(dead_code)]
|
||||
pub fn delete_log_file() -> io::Result<()> {
|
||||
if fs::metadata(MOSAIC_TMP_LOG_FILE).is_ok() {
|
||||
fs::remove_file(MOSAIC_TMP_LOG_FILE)
|
||||
if fs::metadata(ZELLIJ_TMP_LOG_FILE).is_ok() {
|
||||
fs::remove_file(ZELLIJ_TMP_LOG_FILE)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -56,8 +56,8 @@ pub fn delete_log_file() -> io::Result<()> {
|
|||
|
||||
#[allow(dead_code)]
|
||||
pub fn delete_log_dir() -> io::Result<()> {
|
||||
if fs::metadata(MOSAIC_TMP_LOG_DIR).is_ok() {
|
||||
fs::remove_dir_all(MOSAIC_TMP_LOG_DIR)
|
||||
if fs::metadata(ZELLIJ_TMP_LOG_DIR).is_ok() {
|
||||
fs::remove_dir_all(ZELLIJ_TMP_LOG_DIR)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -65,8 +65,8 @@ pub fn delete_log_dir() -> io::Result<()> {
|
|||
|
||||
pub fn debug_to_file(message: u8, pid: RawFd) -> io::Result<()> {
|
||||
let mut path = PathBuf::new();
|
||||
path.push(MOSAIC_TMP_LOG_DIR);
|
||||
path.push(format!("mosaic-{}.log", pid.to_string()));
|
||||
path.push(ZELLIJ_TMP_LOG_DIR);
|
||||
path.push(format!("zellij-{}.log", pid.to_string()));
|
||||
|
||||
let mut file = fs::OpenOptions::new()
|
||||
.append(true)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ pub struct PluginEnv {
|
|||
|
||||
// Plugin API ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
pub fn mosaic_imports(store: &Store, plugin_env: &PluginEnv) -> ImportObject {
|
||||
pub fn zellij_imports(store: &Store, plugin_env: &PluginEnv) -> ImportObject {
|
||||
imports! {
|
||||
"zellij" => {
|
||||
"host_open_file" => Function::new_native_with_env(store, plugin_env.clone(), host_open_file),
|
||||
|
|
|
|||
14
src/main.rs
14
src/main.rs
|
|
@ -22,7 +22,7 @@ use crate::command_is_executing::CommandIsExecuting;
|
|||
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},
|
||||
consts::{ZELLIJ_IPC_PIPE, ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR},
|
||||
logging::*,
|
||||
};
|
||||
|
||||
|
|
@ -31,29 +31,29 @@ pub fn main() {
|
|||
if let Some(split_dir) = opts.split {
|
||||
match split_dir {
|
||||
'h' => {
|
||||
let mut stream = UnixStream::connect(MOSAIC_IPC_PIPE).unwrap();
|
||||
let mut stream = UnixStream::connect(ZELLIJ_IPC_PIPE).unwrap();
|
||||
let api_command = bincode::serialize(&ApiCommand::SplitHorizontally).unwrap();
|
||||
stream.write_all(&api_command).unwrap();
|
||||
}
|
||||
'v' => {
|
||||
let mut stream = UnixStream::connect(MOSAIC_IPC_PIPE).unwrap();
|
||||
let mut stream = UnixStream::connect(ZELLIJ_IPC_PIPE).unwrap();
|
||||
let api_command = bincode::serialize(&ApiCommand::SplitVertically).unwrap();
|
||||
stream.write_all(&api_command).unwrap();
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
} else if opts.move_focus {
|
||||
let mut stream = UnixStream::connect(MOSAIC_IPC_PIPE).unwrap();
|
||||
let mut stream = UnixStream::connect(ZELLIJ_IPC_PIPE).unwrap();
|
||||
let api_command = bincode::serialize(&ApiCommand::MoveFocus).unwrap();
|
||||
stream.write_all(&api_command).unwrap();
|
||||
} else if let Some(file_to_open) = opts.open_file {
|
||||
let mut stream = UnixStream::connect(MOSAIC_IPC_PIPE).unwrap();
|
||||
let mut stream = UnixStream::connect(ZELLIJ_IPC_PIPE).unwrap();
|
||||
let api_command = bincode::serialize(&ApiCommand::OpenFile(file_to_open)).unwrap();
|
||||
stream.write_all(&api_command).unwrap();
|
||||
} else {
|
||||
let os_input = get_os_input();
|
||||
atomic_create_dir(MOSAIC_TMP_DIR).unwrap();
|
||||
atomic_create_dir(MOSAIC_TMP_LOG_DIR).unwrap();
|
||||
atomic_create_dir(ZELLIJ_TMP_DIR).unwrap();
|
||||
atomic_create_dir(ZELLIJ_TMP_LOG_DIR).unwrap();
|
||||
start(Box::new(os_input), opts);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use crate::tests::utils::commands::{COMMAND_TOGGLE, QUIT};
|
|||
*
|
||||
* They work like this:
|
||||
* - receive fake TTY input containing various VTE instructions.
|
||||
* - run that output through mosaic so it interprets it and creates its state based on it
|
||||
* - run that output through zellij so it interprets it and creates its state based on it
|
||||
* - read that state into a Human-readable snapshot and compare it to the expected snapshot for
|
||||
* this scenario.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ pub fn accepts_basic_layout() {
|
|||
// created properly and that in the end it's populated properly with its content
|
||||
//
|
||||
// we read the next to last as well as the last, because the last includes the "Bye from
|
||||
// Mosaic" message, and we also want to make sure things are fine before that
|
||||
// Zellij" message, and we also want to make sure things are fine before that
|
||||
assert_snapshot!(first_snapshot);
|
||||
assert_snapshot!(next_to_last_snapshot);
|
||||
assert_snapshot!(last_snapshot);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue