The playground becomes app::App, and `cumulus` runs it: the main loop with terminal setup and a panic hook, and the startup rules (./ideas.cum, else ~/ideas.cum, made the first time; files and folders by name; `cumulus new`; --paths). The documents' files: - autosave a second after the latest change (`:set noautosave` for vim-style :w), [+] in the document bar for unsaved changes; quitting saves first; without autosave :q refuses, :q! drops, ZZ saves first; - a file changed outside cumulus is read again as an undo step; with unsaved changes here too, cumulus asks which to keep; a file with a mistake in it holds autosave until it's fixed or :w saves over it; a deleted one waits for :w; nothing is reloaded under an edit; - the day's first save backs the file up to the data folder (30 days); - a document open in another cumulus is read-only ([RO]) until that one lets go: OS file locks in the data folder, so a crash leaves none; - where you left off (cursor, zoom, scroll), the recent documents (now in the documents picker) and the command history, in memory.ron; - :e (alone: read it again; ! drops changes), :new, :bd, :w, :wa, :x, :qa, <Space>i for :in, and :set for every setting. glyphs=ascii now reaches the frames and bars too, not just the canvas and outline. Stage 8 comes in four parts with a commit each (the user's choice); 8b is the settings files. The example is now a playground running the app on copies of the sample documents in a temporary folder, and the end-to-end tests moved to src/app/tests.rs, with tests for the files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
38 lines
1.7 KiB
Rust
38 lines
1.7 KiB
Rust
//! The playground: cumulus itself, on copies of two sample documents (a
|
|
//! garden, and the kitchen its portal leads to), in a fresh temporary
|
|
//! folder. Trying things never changes the files in the repository, and
|
|
//! cumulus's own folders (where you left off, backups, locks) are in there
|
|
//! too, apart from your real ones.
|
|
//!
|
|
//! Run it with `cargo run --example canvas`. Everything works as in
|
|
//! `cumulus`, files included: the copies are saved as you go, and the folder
|
|
//! is printed when you quit, to look at them (or to change one while the
|
|
//! playground runs, and watch it reload).
|
|
|
|
use std::fs;
|
|
use std::io;
|
|
|
|
use cumulus::app::action::Message;
|
|
use cumulus::app::startup::Opening;
|
|
use cumulus::app::{App, load, run};
|
|
use cumulus::config::paths::Paths;
|
|
use cumulus::config::settings::Settings;
|
|
use cumulus::input::keymap::{DEFAULT_LEADER, Keymap};
|
|
|
|
fn main() -> io::Result<()> {
|
|
let folder = std::env::temp_dir().join(format!("cumulus-playground-{}", std::process::id()));
|
|
fs::create_dir_all(&folder)?;
|
|
let (garden, kitchen) = (folder.join("garden.cum"), folder.join("kitchen.cum"));
|
|
fs::write(&garden, include_str!("garden.cum"))?;
|
|
fs::write(&kitchen, include_str!("kitchen.cum"))?;
|
|
let opening = Opening {
|
|
first: load(&garden).map_err(io::Error::other)?,
|
|
others: vec![load(&kitchen).map_err(io::Error::other)?],
|
|
message: Some(Message::info("the playground: copies of the samples, in a temporary folder")),
|
|
};
|
|
let paths = Paths::inside(&folder.join("cumulus"));
|
|
run(App::new(paths, Settings::default(), Keymap::new(DEFAULT_LEADER), opening))?;
|
|
println!("The playground's files are in {}", folder.display());
|
|
Ok(())
|
|
}
|