mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 12:38:18 +00:00
Save: a background save shows in the progress window with Cancel and Continue in Background
A save running in the background (Background Save) now shows in the progress window after 0.4 s, with the file name, a moving bar and how many more saves wait. Cancel (also Esc, file.cancelSave) stops the save before it replaces its file: the file stays as it was, and the document keeps its file and format and stays modified. Continue in Background (file.saveInBackground) leaves the save to the status bar. - The streamed native save stops writing into its temporary file once canceled, and the atomic writer checks once more after the temporary file is flushed, so a canceled write never replaces the file or enters the copy fallback. - A save of several files whose first file is in place writes the rest and is reported as saved. - Save and export jobs are told apart, so each window's Cancel acts only on its own jobs.
This commit is contained in:
@@ -258,7 +258,17 @@ pub(crate) fn write_file(path: &str, bytes: &[u8]) -> Result<()> {
|
||||
vectorcraft_doc::cancel::check()?;
|
||||
may_write(path)?;
|
||||
// Never a half-written file: see [`write_atomic`].
|
||||
write_atomic(std::path::Path::new(path), bytes).map_err(|e| EngineError::Other(format!("{path}: {e}")))
|
||||
write_atomic(std::path::Path::new(path), bytes).map_err(|e| write_error(path, e))
|
||||
}
|
||||
|
||||
/// The error writing `path` failed with: [`EngineError::Cancelled`] for work canceled before the
|
||||
/// file was put in place ([`vectorcraft_format::write_atomic_with`]), otherwise the path and the reason.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn write_error(path: &str, error: std::io::Error) -> EngineError {
|
||||
if error.get_ref().is_some_and(|e| e.is::<vectorcraft_doc::cancel::Cancelled>()) {
|
||||
return EngineError::Cancelled;
|
||||
}
|
||||
EngineError::Other(format!("{path}: {error}"))
|
||||
}
|
||||
|
||||
/// [`write_file`] with what `fill` writes into the file (a save streamed into it).
|
||||
@@ -266,7 +276,7 @@ pub(crate) fn write_file(path: &str, bytes: &[u8]) -> Result<()> {
|
||||
pub fn write_file_with(path: &str, fill: &mut dyn FnMut(&mut dyn std::io::Write) -> std::io::Result<()>) -> Result<()> {
|
||||
vectorcraft_doc::cancel::check()?;
|
||||
may_write(path)?;
|
||||
vectorcraft_format::write_atomic_with(std::path::Path::new(path), |f| fill(f)).map_err(|e| EngineError::Other(format!("{path}: {e}")))
|
||||
vectorcraft_format::write_atomic_with(std::path::Path::new(path), |f| fill(f)).map_err(|e| write_error(path, e))
|
||||
}
|
||||
|
||||
/// The save commands' writer: preserves a filesystem location refusal as a typed error. Other
|
||||
@@ -285,8 +295,10 @@ pub fn write_save_file_with(path: &str, fill: &mut dyn FnMut(&mut dyn std::io::W
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(super) fn save_write_error(path: &str, error: std::io::Error) -> EngineError {
|
||||
let reason = format!("{path}: {error}");
|
||||
if vectorcraft_format::read_only_location(&error) { EngineError::ReadOnlyLocation(reason) } else { EngineError::Other(reason) }
|
||||
if !vectorcraft_format::read_only_location(&error) {
|
||||
return write_error(path, error);
|
||||
}
|
||||
EngineError::ReadOnlyLocation(format!("{path}: {error}"))
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
||||
@@ -629,6 +629,24 @@ impl<W: std::io::Write> std::io::Write for Counted<W> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A writer that fails once the work running on this thread is canceled
|
||||
/// ([`crate::cancel::is_cancelled`]), so a streamed save stops writing into its temporary file.
|
||||
/// It sits under the stream's buffer: it is checked once per buffer written, not per write.
|
||||
struct StopsWhenCancelled<W>(W);
|
||||
|
||||
impl<W: std::io::Write> std::io::Write for StopsWhenCancelled<W> {
|
||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||
if crate::cancel::is_cancelled() {
|
||||
return Err(std::io::Error::other(crate::cancel::Cancelled));
|
||||
}
|
||||
self.0.write(buf)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
self.0.flush()
|
||||
}
|
||||
}
|
||||
|
||||
/// The artboards a native or `.ai` save also writes to files of their own: with
|
||||
/// `separateArtboards`, those `range` names (default all).
|
||||
fn separate_boards(cmd: &str, f: &Format, doc: &Document, p: &Value) -> Result<Vec<usize>> {
|
||||
@@ -1022,10 +1040,15 @@ impl SaveJob {
|
||||
}
|
||||
|
||||
/// [`SaveJob::write`], once `stop` has seen the paths of every file it writes to a path, in
|
||||
/// order: when `stop` returns a value, nothing is written and that value is returned.
|
||||
/// order: when `stop` returns a value, nothing is written and that value is returned. Work
|
||||
/// canceled ([`crate::cancel`]) before the first file is written returns
|
||||
/// [`crate::EngineError::Cancelled`] and writes nothing; once the first file is written, the
|
||||
/// others are written too.
|
||||
pub fn write_unless(&self, stop: impl FnOnce(&[&str]) -> Option<Value>, mut write: impl FnMut(&str, &[u8]) -> Result<()>) -> Result<Value> {
|
||||
let (plan, doc) = (&self.plan, &*self.doc);
|
||||
crate::cancel::check()?;
|
||||
let enc = self.encode()?;
|
||||
crate::cancel::check()?;
|
||||
let extra = json!({ "format": plan.format.id, "warnings": enc.notes() });
|
||||
let Some(path) = &plan.path else {
|
||||
let mut out = write_encoded(None, &plan.name, doc, &enc, extra)?;
|
||||
@@ -1042,8 +1065,13 @@ impl SaveJob {
|
||||
if let Some(stopped) = stop(&files.iter().map(|(p, _)| p.as_str()).collect::<Vec<_>>()) {
|
||||
return Ok(stopped);
|
||||
}
|
||||
for (p, bytes) in &files {
|
||||
write(p, bytes)?;
|
||||
for (i, (p, bytes)) in files.iter().enumerate() {
|
||||
if i == 0 {
|
||||
write(p, bytes)?;
|
||||
} else {
|
||||
// Once a file is in place, a Cancel no longer stops the save: the set is written whole.
|
||||
crate::cancel::scope(&crate::cancel::CancelToken::new(), None, || write(p, bytes))?;
|
||||
}
|
||||
}
|
||||
let bytes = files.first().map_or(0, |f| f.1.len());
|
||||
let mut out = super::merge(json!({ "path": path, "bytes": bytes }), extra);
|
||||
@@ -1066,11 +1094,15 @@ impl SaveJob {
|
||||
/// [`SaveJob::write`] through `stream`, which writes the file at a path with what the filler
|
||||
/// it is given writes (atomically, as [`vectorcraft_format::write_atomic_with`]). A native
|
||||
/// file goes into it as it is encoded ([`SaveJob::streams`]), never held whole in memory;
|
||||
/// other files are encoded first, then written into it.
|
||||
/// other files are encoded first, then written into it. Work canceled ([`crate::cancel`])
|
||||
/// while the native file is encoded, or before its filler returns, returns
|
||||
/// [`crate::EngineError::Cancelled`]: the filler fails, so `stream` keeps the file as it was
|
||||
/// (the atomic writer checks once more before it puts the file in place).
|
||||
pub fn write_streamed(&self, stream: StreamWrite) -> Result<Value> {
|
||||
let (Some(path), true) = (&self.plan.path, self.streams()) else {
|
||||
return self.write(|p, b| stream(p, &mut |w| w.write_all(b)));
|
||||
};
|
||||
crate::cancel::check()?;
|
||||
let (cmd, f) = (self.plan.mode.command(), self.plan.format);
|
||||
let doc = self.doc.without_edit_modes();
|
||||
let doc = match f.id {
|
||||
@@ -1087,16 +1119,22 @@ impl SaveJob {
|
||||
let mut failed = None;
|
||||
let mut written = 0u64;
|
||||
let mut fill = |w: &mut dyn std::io::Write| {
|
||||
let mut out = Counted { inner: std::io::BufWriter::with_capacity(STREAM_BUFFER, w), n: 0 };
|
||||
let mut out = Counted { inner: std::io::BufWriter::with_capacity(STREAM_BUFFER, StopsWhenCancelled(w)), n: 0 };
|
||||
let r = super::native::encode_to(cmd, f, &doc, &self.params, &mut out);
|
||||
written = out.n;
|
||||
match r {
|
||||
let r = match r {
|
||||
Ok(()) => out.inner.flush(),
|
||||
Err(e) => {
|
||||
failed = Some(e);
|
||||
Err(std::io::Error::other("the file couldn't be encoded"))
|
||||
}
|
||||
};
|
||||
// The last check before the file is replaced: a canceled save leaves it as it was.
|
||||
if crate::cancel::is_cancelled() {
|
||||
failed = Some(crate::EngineError::Cancelled);
|
||||
return Err(std::io::Error::other(crate::cancel::Cancelled));
|
||||
}
|
||||
r
|
||||
};
|
||||
let r = stream(path, &mut fill);
|
||||
r.map_err(|e| failed.take().unwrap_or(e))?;
|
||||
|
||||
@@ -922,6 +922,109 @@ fn a_save_that_fails_while_streaming_leaves_the_file_as_it_was() {
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
/// A save canceled (Background Save's Cancel) before it starts, while a native file streams into
|
||||
/// its temporary file, or after the last byte went into it, fails with `Cancelled` and leaves the
|
||||
/// file as it was, with no temporary file behind. A file encoded first is never written.
|
||||
#[test]
|
||||
fn a_canceled_save_leaves_the_file_as_it_was() {
|
||||
/// Passes every write on, and cancels the save after the first one.
|
||||
struct CancelAfterFirst<'a> {
|
||||
inner: &'a mut dyn std::io::Write,
|
||||
token: crate::cancel::CancelToken,
|
||||
}
|
||||
impl std::io::Write for CancelAfterFirst<'_> {
|
||||
fn write(&mut self, b: &[u8]) -> std::io::Result<usize> {
|
||||
let n = self.inner.write(b)?;
|
||||
self.token.cancel();
|
||||
Ok(n)
|
||||
}
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
self.inner.flush()
|
||||
}
|
||||
}
|
||||
let d = tmp_dir("stream-cancel");
|
||||
// A small document's file goes in one piece; a large one's in several.
|
||||
for count in [1, 1500] {
|
||||
let mut s = session(2000.0, 2000.0, 1);
|
||||
for i in 0..count {
|
||||
s.execute("shape.rectangle", &json!({"x": i % 100 * 20, "y": i / 100 * 20, "width": 10, "height": 10})).unwrap();
|
||||
}
|
||||
let path = d.join("a.vectorcraft").to_string_lossy().to_string();
|
||||
s.execute("file.saveCopy", &json!({"path": path})).unwrap();
|
||||
let before = std::fs::read(&path).unwrap();
|
||||
s.execute("shape.ellipse", &json!({"x": 0, "y": 0, "width": 50, "height": 50})).unwrap();
|
||||
let plan = save_plan(&s, SaveMode::Copy, &json!({"path": path})).unwrap();
|
||||
let job = save_job(&mut s, plan).unwrap();
|
||||
assert!(job.streams());
|
||||
let token = crate::cancel::CancelToken::new();
|
||||
let r = crate::cancel::scope(&token, None, || {
|
||||
job.write_streamed(&mut |p, fill| super::write_file_with(p, &mut |w| fill(&mut CancelAfterFirst { inner: w, token: token.clone() })))
|
||||
});
|
||||
assert!(matches!(r, Err(EngineError::Cancelled)), "{count}: {r:?}");
|
||||
assert_eq!(std::fs::read(&path).unwrap(), before, "{count} objects");
|
||||
assert_eq!(std::fs::read_dir(&d).unwrap().count(), 1, "no temporary file is left");
|
||||
// Canceled before it starts: the file isn't opened.
|
||||
let mut opened = false;
|
||||
let r = crate::cancel::scope(&token, None, || {
|
||||
job.write_streamed(&mut |_, _| {
|
||||
opened = true;
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
assert!(matches!(r, Err(EngineError::Cancelled)) && !opened, "{r:?}");
|
||||
}
|
||||
// A file encoded first (SVG): nothing reaches the writer.
|
||||
let mut s = session(200.0, 100.0, 1);
|
||||
s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 50, "height": 20})).unwrap();
|
||||
let plan = save_plan(&s, SaveMode::Copy, &json!({"path": d.join("a.svg").to_string_lossy()})).unwrap();
|
||||
let job = save_job(&mut s, plan).unwrap();
|
||||
let token = crate::cancel::CancelToken::new();
|
||||
token.cancel();
|
||||
let mut writes = 0;
|
||||
let r = crate::cancel::scope(&token, None, || {
|
||||
job.write_streamed(&mut |_, _| {
|
||||
writes += 1;
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
assert!(matches!(r, Err(EngineError::Cancelled)), "{r:?}");
|
||||
let r = crate::cancel::scope(&token, None, || {
|
||||
job.write(|_, _| {
|
||||
writes += 1;
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
assert!(matches!(r, Err(EngineError::Cancelled)) && writes == 0, "{r:?}");
|
||||
assert!(!d.join("a.svg").exists());
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
/// A save that writes several files (EPS with Use Artboards) and is canceled once its first file is
|
||||
/// in place writes the others too and succeeds: the set is never left half written.
|
||||
#[test]
|
||||
fn a_save_canceled_after_its_first_file_writes_them_all() {
|
||||
let d = tmp_dir("cancel-files");
|
||||
let mut s = session(100.0, 100.0, 2);
|
||||
s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 30, "height": 30})).unwrap();
|
||||
let path = d.join("logo.eps").to_string_lossy().to_string();
|
||||
let plan = save_plan(&s, SaveMode::Copy, &json!({"path": path, "options": {"useArtboards": true}})).unwrap();
|
||||
let job = save_job(&mut s, plan).unwrap();
|
||||
let token = crate::cancel::CancelToken::new();
|
||||
let mut written = vec![];
|
||||
let r = crate::cancel::scope(&token, None, || {
|
||||
job.write(|p, b| {
|
||||
super::write_save_file(p, b)?;
|
||||
written.push(p.to_string());
|
||||
token.cancel();
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
assert!(r.is_ok(), "{r:?}");
|
||||
assert_eq!(written.len(), 3, "{written:?}");
|
||||
assert!(written.iter().all(|p| std::path::Path::new(p).is_file()), "{written:?}");
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
/// A save that fails leaves File Info's dates and the saved state alone; one that works stamps them.
|
||||
#[test]
|
||||
fn a_failed_save_does_not_stamp_the_documents_dates() {
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
//! are on disk, and the error names them. Where that copy of the old file can't be made, the file
|
||||
//! is left as it was and the save fails.
|
||||
//!
|
||||
//! Work canceled ([`vectorcraft_doc::cancel`]) by the time the temporary file is written and flushed
|
||||
//! puts nothing in place: the temporary file is removed, the file stays as it was (or absent), and
|
||||
//! the error wraps [`vectorcraft_doc::cancel::Cancelled`].
|
||||
//!
|
||||
//! On macOS `File::sync_all` is a full flush (`F_FULLFSYNC`), which SMB shares refuse with
|
||||
//! `ENOTSUP` and virtiofs shares (folders shared into a macOS VM) with `ENOTTY`, while a plain
|
||||
//! `fsync` works: [`sync_file`] falls back to the plain one there (#1620).
|
||||
@@ -43,7 +47,8 @@ pub fn write_atomic(path: &Path, bytes: &[u8]) -> io::Result<()> {
|
||||
}
|
||||
|
||||
/// Write `path` atomically with `fill`, which writes the content into the temporary file. When
|
||||
/// `fill` or flushing fails the temporary file is removed and `path` is left untouched. When the
|
||||
/// `fill` or flushing fails, or the work was canceled meanwhile ([`vectorcraft_doc::cancel`]), the
|
||||
/// temporary file is removed and `path` is left untouched. When the
|
||||
/// folder refuses the temporary file or the rename, the content is copied into `path` instead (see
|
||||
/// the module docs).
|
||||
pub fn write_atomic_with(path: &Path, fill: impl FnOnce(&mut File) -> io::Result<()>) -> io::Result<()> {
|
||||
@@ -79,7 +84,7 @@ fn write_atomic_stepping(
|
||||
(tmp, f, Some(e))
|
||||
}
|
||||
};
|
||||
let filled = fill(&mut f).and_then(|()| sync_file(&f));
|
||||
let filled = fill(&mut f).and_then(|()| sync_file(&f)).and_then(|()| not_cancelled());
|
||||
drop(f);
|
||||
if let Err(e) = filled {
|
||||
// Best effort: the temporary file is all there is to clean up.
|
||||
@@ -176,7 +181,7 @@ fn write_new_linking(
|
||||
) -> io::Result<()> {
|
||||
let tmp = temp_path(path)?;
|
||||
let mut f = OpenOptions::new().write(true).create_new(true).open(&tmp)?;
|
||||
let filled = fill(&mut f).and_then(|()| sync_file(&f));
|
||||
let filled = fill(&mut f).and_then(|()| sync_file(&f)).and_then(|()| not_cancelled());
|
||||
drop(f);
|
||||
let placed = filled.and_then(|()| match link(&tmp, path) {
|
||||
Err(e) if e.kind() != io::ErrorKind::AlreadyExists => copy_new(&tmp, path),
|
||||
@@ -187,6 +192,12 @@ fn write_new_linking(
|
||||
placed
|
||||
}
|
||||
|
||||
/// `Err` wrapping [`vectorcraft_doc::cancel::Cancelled`] when the work running on this thread has
|
||||
/// been canceled: the last check before a written temporary file is put in place.
|
||||
fn not_cancelled() -> io::Result<()> {
|
||||
vectorcraft_doc::cancel::check().map_err(io::Error::other)
|
||||
}
|
||||
|
||||
/// Create `path` (never replacing anything) with the content of the file `from`; a failed copy
|
||||
/// removes it again.
|
||||
fn copy_new(from: &Path, path: &Path) -> io::Result<()> {
|
||||
@@ -408,6 +419,39 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
/// Work canceled by the time the temporary file is written and flushed puts nothing in place:
|
||||
/// the old file stays as it was, also where the folder refuses the rename (no copy over it), a
|
||||
/// new file is not created, and no temporary file is left.
|
||||
#[test]
|
||||
fn canceled_work_puts_nothing_in_place() {
|
||||
use vectorcraft_doc::cancel::{CancelToken, Cancelled, scope};
|
||||
fn cancelled(e: &io::Error) -> bool {
|
||||
e.get_ref().is_some_and(|e| e.is::<Cancelled>())
|
||||
}
|
||||
let d = dir("cancel");
|
||||
let path = d.join("doc.vectorcraft");
|
||||
std::fs::write(&path, b"original").unwrap();
|
||||
let token = CancelToken::new();
|
||||
let r = scope(&token, None, || {
|
||||
write_atomic_with(&path, |f| {
|
||||
f.write_all(b"new")?;
|
||||
token.cancel();
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
assert!(r.as_ref().is_err_and(cancelled), "{r:?}");
|
||||
let refused = |_: &Path, _: &Path| -> io::Result<()> { Err(io::Error::from(io::ErrorKind::PermissionDenied)) };
|
||||
let r = scope(&token, None, || write_atomic_stepping(&path, |f| f.write_all(b"new"), create_new, refused));
|
||||
assert!(r.as_ref().is_err_and(cancelled), "{r:?}");
|
||||
assert_eq!(std::fs::read(&path).unwrap(), b"original");
|
||||
let new = d.join("new.vectorcraft");
|
||||
let r = scope(&token, None, || write_new_with(&new, |f| f.write_all(b"new")));
|
||||
assert!(r.as_ref().is_err_and(cancelled), "{r:?}");
|
||||
assert!(!new.exists());
|
||||
assert!(leftovers(&d, "doc.vectorcraft").is_empty(), "{:?}", leftovers(&d, "doc.vectorcraft"));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_original_file_survives_a_failed_write() {
|
||||
let d = dir("fail");
|
||||
|
||||
@@ -1455,6 +1455,18 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"",
|
||||
"{} close the export progress dialog; the exports go on, shown in the status bar → {hidden: n}",
|
||||
),
|
||||
(
|
||||
"file.cancelSave",
|
||||
"Cancel Save",
|
||||
"",
|
||||
"{} stop every save running in the background (Background Save) before it replaces its file: the file stays as it was and the document keeps its file and stays modified; a save whose file was already being replaced finishes and is reported as saved → {cancelled: n}",
|
||||
),
|
||||
(
|
||||
"file.saveInBackground",
|
||||
"Continue in Background",
|
||||
"",
|
||||
"{} close the save progress window; the saves go on, shown in the status bar → {hidden: n}",
|
||||
),
|
||||
(
|
||||
"file.cancelOpen",
|
||||
"Cancel Opening",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
//! Background Save and Background Export (Preferences → File Handling): a save or an export encodes
|
||||
//! and writes a snapshot of the document on a worker thread while editing goes on. The status bar
|
||||
//! shows what is in progress; the result is applied on the UI thread when it arrives (a save marks
|
||||
//! the document saved as of its snapshot, so edits made meanwhile keep it modified).
|
||||
//! the document saved as of its snapshot, so edits made meanwhile keep it modified). Exports and
|
||||
//! saves show in the progress window ([`crate::export_progress`]) with Cancel and Continue in
|
||||
//! Background.
|
||||
//!
|
||||
//! It needs a thread-safe writer from the host ([`crate::Services::write_shared`], desktop);
|
||||
//! without one (the web, which downloads) the work runs at once, as with the preference off.
|
||||
@@ -44,15 +46,27 @@ struct Task {
|
||||
scope: ScopeHandle,
|
||||
}
|
||||
|
||||
/// What a job that shows in the progress window does: its Cancel and Continue in Background act on
|
||||
/// the jobs of its kind.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Kind {
|
||||
/// An export (Background Export): `file.cancelExport`, `file.exportInBackground`.
|
||||
Export,
|
||||
/// A save (Background Save): `file.cancelSave`, `file.saveInBackground`.
|
||||
Save,
|
||||
}
|
||||
|
||||
/// A job in progress.
|
||||
pub struct Job {
|
||||
id: u64,
|
||||
/// What the job does, for the progress window and its commands.
|
||||
pub kind: Kind,
|
||||
/// What the status bar and `ui.inspect` show ("Saving Poster.vectorcraft"); empty for work they
|
||||
/// don't show.
|
||||
pub label: String,
|
||||
/// The document the job reads (`DocState::uid`), if any.
|
||||
pub doc: Option<u64>,
|
||||
/// How far an export has got, and its Cancel ([`crate::export_progress`] shows it).
|
||||
/// How far an export or a save has got, and its Cancel ([`crate::export_progress`] shows it).
|
||||
pub progress: Option<Arc<Progress>>,
|
||||
/// Continue in Background: the progress dialog no longer shows this job.
|
||||
pub hidden: bool,
|
||||
@@ -119,18 +133,41 @@ impl Background {
|
||||
|
||||
/// Cancel every export in progress → how many there were.
|
||||
pub fn cancel_exports(&mut self) -> usize {
|
||||
self.cancel(Kind::Export)
|
||||
}
|
||||
|
||||
/// Hide the exports in progress from the progress dialog (they go on) → how many there were.
|
||||
pub fn hide_exports(&mut self) -> usize {
|
||||
self.hide(Kind::Export)
|
||||
}
|
||||
|
||||
/// Cancel every save in progress that the progress window can show → how many there were.
|
||||
pub fn cancel_saves(&mut self) -> usize {
|
||||
self.cancel(Kind::Save)
|
||||
}
|
||||
|
||||
/// Hide the saves in progress from the progress window (they go on) → how many there were.
|
||||
pub fn hide_saves(&mut self) -> usize {
|
||||
self.hide(Kind::Save)
|
||||
}
|
||||
|
||||
/// Is a job of `kind` in progress that can still be canceled?
|
||||
pub fn running(&self, kind: Kind) -> bool {
|
||||
self.jobs.iter().any(|j| j.kind == kind && j.progress.is_some() && !j.cancelled())
|
||||
}
|
||||
|
||||
fn cancel(&mut self, kind: Kind) -> usize {
|
||||
let mut n = 0;
|
||||
for p in self.jobs.iter().filter(|j| !j.cancelled()).filter_map(|j| j.progress.as_ref()) {
|
||||
for p in self.jobs.iter().filter(|j| j.kind == kind && !j.cancelled()).filter_map(|j| j.progress.as_ref()) {
|
||||
p.cancel();
|
||||
n += 1;
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
/// Hide the exports in progress from the progress dialog (they go on) → how many there were.
|
||||
pub fn hide_exports(&mut self) -> usize {
|
||||
fn hide(&mut self, kind: Kind) -> usize {
|
||||
let mut n = 0;
|
||||
for j in self.jobs.iter_mut().filter(|j| j.progress.is_some() && !j.hidden && !j.cancelled()) {
|
||||
for j in self.jobs.iter_mut().filter(|j| j.kind == kind && j.progress.is_some() && !j.hidden && !j.cancelled()) {
|
||||
j.hidden = true;
|
||||
n += 1;
|
||||
}
|
||||
@@ -163,6 +200,34 @@ pub fn run_with_progress(
|
||||
progress: Option<Arc<Progress>>,
|
||||
work: impl FnOnce(Writer) -> Result<Value, String> + Send + 'static,
|
||||
then: impl FnOnce(&mut VectorcraftApp, Result<Value, String>) -> Result<Value, String> + 'static,
|
||||
) -> Result<Value, String> {
|
||||
start(app, enabled, label, doc, progress, Kind::Export, work, then)
|
||||
}
|
||||
|
||||
/// [`run_with_progress`] for a save of document `doc`: the progress window shows it as a save, and
|
||||
/// its Cancel is `file.cancelSave`.
|
||||
pub fn run_saving(
|
||||
app: &mut VectorcraftApp,
|
||||
enabled: bool,
|
||||
label: String,
|
||||
doc: u64,
|
||||
progress: Arc<Progress>,
|
||||
work: impl FnOnce(Writer) -> Result<Value, String> + Send + 'static,
|
||||
then: impl FnOnce(&mut VectorcraftApp, Result<Value, String>) -> Result<Value, String> + 'static,
|
||||
) -> Result<Value, String> {
|
||||
start(app, enabled, label, Some(doc), Some(progress), Kind::Save, work, then)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn start(
|
||||
app: &mut VectorcraftApp,
|
||||
enabled: bool,
|
||||
label: String,
|
||||
doc: Option<u64>,
|
||||
progress: Option<Arc<Progress>>,
|
||||
kind: Kind,
|
||||
work: impl FnOnce(Writer) -> Result<Value, String> + Send + 'static,
|
||||
then: impl FnOnce(&mut VectorcraftApp, Result<Value, String>) -> Result<Value, String> + 'static,
|
||||
) -> Result<Value, String> {
|
||||
let mut work: Work = Box::new(work);
|
||||
let shared = app.services.write_shared.clone().filter(|_| enabled && !app.background.foreground && app.services.download.is_none());
|
||||
@@ -174,7 +239,8 @@ pub fn run_with_progress(
|
||||
let (sets, status) = (app.ui.status_sets, if label.is_empty() { String::new() } else { format!("{label}…") });
|
||||
let bg = &mut app.background;
|
||||
bg.next_id += 1;
|
||||
bg.jobs.push(Job { id, label: label.clone(), doc, progress, hidden: false, sets, line: status.clone(), then: Box::new(then) });
|
||||
let line = status.clone();
|
||||
bg.jobs.push(Job { id, kind, label: label.clone(), doc, progress, hidden: false, sets, line, then: Box::new(then) });
|
||||
if label.is_empty() {
|
||||
return Ok(json!({ "background": true }));
|
||||
}
|
||||
|
||||
@@ -7,11 +7,17 @@
|
||||
//! Cancel), Continue in Background (`file.exportInBackground`) closes the
|
||||
//! dialog and leaves the export to the status bar.
|
||||
//!
|
||||
//! A save running in the background (Background Save) shows in the same window, with a moving bar
|
||||
//! (a save counts no steps) and how many more saves wait: Cancel (`file.cancelSave`, also Esc)
|
||||
//! stops it before it replaces its file, and Continue in Background (`file.saveInBackground`)
|
||||
//! leaves it to the status bar.
|
||||
//!
|
||||
//! It opens after [`DELAY`] so a quick export doesn't flash it, and waits while another dialog is
|
||||
//! open (the overwrite question, an options dialog): never two modals at once.
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
use crate::background::Kind;
|
||||
use crate::dialogs::modal;
|
||||
use crate::theme::Tokens;
|
||||
use crate::{VectorcraftApp, widgets};
|
||||
@@ -24,11 +30,12 @@ fn seen_id() -> egui::Id {
|
||||
egui::Id::unique("export-progress-seen")
|
||||
}
|
||||
|
||||
/// What the dialog shows: (label, steps done, steps in all, share done, exports after this one,
|
||||
/// what the steps are).
|
||||
/// What the dialog shows: (label, steps done, steps in all, share done, jobs of its kind after this
|
||||
/// one, what the steps are).
|
||||
fn shown(app: &VectorcraftApp, now: f64, ctx: &egui::Context) -> Option<(String, u64, u64, f32, usize, Steps)> {
|
||||
let jobs: Vec<_> = app.background.jobs.iter().filter(|j| !j.hidden && !j.cancelled()).filter(|j| j.progress.is_some()).collect();
|
||||
let first = jobs.first()?;
|
||||
let more = jobs.iter().filter(|j| j.kind == first.kind).count() - 1;
|
||||
let since = ctx.data_mut(|m| {
|
||||
let seen = m.get_temp_mut_or_insert_with(seen_id(), || (first.id(), now));
|
||||
if seen.0 != first.id() {
|
||||
@@ -42,11 +49,12 @@ fn shown(app: &VectorcraftApp, now: f64, ctx: &egui::Context) -> Option<(String,
|
||||
let (done, total) = first.progress.as_ref().map(|p| p.counts()).unwrap_or_default();
|
||||
let frac = first.progress.as_ref().and_then(|p| p.fraction()).unwrap_or(0.0) as f32;
|
||||
let steps = match &first.progress {
|
||||
_ if first.kind == Kind::Save => Steps::Save,
|
||||
Some(p) if p.counts_share() => Steps::Share,
|
||||
Some(p) if p.counts_files() => Steps::Files,
|
||||
_ => Steps::Artboards,
|
||||
};
|
||||
Some((first.label.clone(), done, total, frac, jobs.len() - 1, steps))
|
||||
Some((first.label.clone(), done, total, frac, more, steps))
|
||||
}
|
||||
|
||||
/// What an export's steps are.
|
||||
@@ -57,6 +65,8 @@ enum Steps {
|
||||
Files,
|
||||
/// An exporter plug-in's own steps, shown as a share of the work.
|
||||
Share,
|
||||
/// A save, which counts no steps: a moving bar.
|
||||
Save,
|
||||
}
|
||||
|
||||
/// Draws the window for the first export running in the background that wasn't hidden or
|
||||
@@ -71,6 +81,15 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
let t = Tokens::get(ctx);
|
||||
let heading = format!("{}…", crate::i18n::msg(&label));
|
||||
let pressed = window(ctx, "export-progress", &heading, |ui| {
|
||||
if steps == Steps::Save {
|
||||
indeterminate(ui, tl!("Encoding and writing the file…"));
|
||||
if more > 0 {
|
||||
ui.add_space(6.0);
|
||||
let queued = crate::i18n::tn(more as u64, "{n} more save waiting", "{n} more saves waiting");
|
||||
ui.label(egui::RichText::new(queued).size(11.5).color(t.text_dim));
|
||||
}
|
||||
return;
|
||||
}
|
||||
// One step says nothing a spinner doesn't: the bar would sit at 0 % until the file is written.
|
||||
if steps == Steps::Share && total > 0 {
|
||||
share(ui, tl!("Encoding and writing the file…"), frac);
|
||||
@@ -95,10 +114,12 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
ui.label(egui::RichText::new(queued).size(11.5).color(t.text_dim));
|
||||
}
|
||||
});
|
||||
let id = match pressed {
|
||||
Some(Pressed::Cancel) => "file.cancelExport",
|
||||
Some(Pressed::Hide) => "file.exportInBackground",
|
||||
None => return,
|
||||
let id = match (pressed, steps == Steps::Save) {
|
||||
(Some(Pressed::Cancel), false) => "file.cancelExport",
|
||||
(Some(Pressed::Hide), false) => "file.exportInBackground",
|
||||
(Some(Pressed::Cancel), true) => "file.cancelSave",
|
||||
(Some(Pressed::Hide), true) => "file.saveInBackground",
|
||||
(None, _) => return,
|
||||
};
|
||||
if let Err(e) = app.run(id, json!({})) {
|
||||
app.status(e);
|
||||
@@ -298,6 +319,45 @@ mod tests {
|
||||
assert!(app.background.jobs.is_empty());
|
||||
}
|
||||
|
||||
/// A Background Save shows in the window after the delay, with a moving bar and how many more
|
||||
/// saves wait, never over another dialog; Continue in Background hides it and the saves go on.
|
||||
/// With Background Save off the save is written at once and no window shows.
|
||||
#[test]
|
||||
fn a_background_save_shows_in_the_window_and_continue_hides_it() {
|
||||
let go = Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
let mut app = app(go.clone());
|
||||
for name in ["a", "b"] {
|
||||
app.run("file.new", json!({"width": 100, "height": 100})).unwrap();
|
||||
let r = app.run("file.save", json!({"path": format!("/docs/{name}.vectorcraft")})).unwrap();
|
||||
assert_eq!(r["background"], true, "{r}");
|
||||
}
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
assert!(!frame(&mut app, &ctx, 0.0).contains("Saving a.vectorcraft"), "not before the delay");
|
||||
// Another dialog is open: the window waits.
|
||||
app.ui.dialog = Some(crate::state::Dialog::new("about", json!({})));
|
||||
frame(&mut app, &ctx, 1.0);
|
||||
assert!(!frame(&mut app, &ctx, 1.1).contains("Saving a.vectorcraft"), "never over another dialog");
|
||||
app.ui.dialog = None;
|
||||
frame(&mut app, &ctx, 1.2);
|
||||
let shown = frame(&mut app, &ctx, 1.3);
|
||||
assert!(shown.contains("Saving a.vectorcraft…") && shown.contains("1 more save waiting"), "{shown}");
|
||||
assert!(shown.contains("Cancel") && shown.contains("Continue in Background") && !shown.contains("export"), "{shown}");
|
||||
assert_eq!(app.run("file.saveInBackground", json!({})).unwrap()["hidden"], 2);
|
||||
assert!(!frame(&mut app, &ctx, 2.0).contains("Saving"), "hidden saves aren't shown");
|
||||
assert!(crate::menus::enabled(&app, "file.cancelSave"), "they can still be canceled");
|
||||
go.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
background::wait_all(&mut app);
|
||||
assert!(app.background.jobs.is_empty());
|
||||
assert_eq!(app.session.active().unwrap().path.as_deref(), Some("/docs/b.vectorcraft"));
|
||||
app.session.execute("prefs.set", &json!({"values": {"backgroundSave": false}})).unwrap();
|
||||
app.services.write = Some(Box::new(|_: &str, _: &[u8]| Ok(())));
|
||||
app.run("file.new", json!({"width": 100, "height": 100})).unwrap();
|
||||
let r = app.run("file.save", json!({"path": "/docs/c.vectorcraft"}));
|
||||
assert!(r.as_ref().is_ok_and(|r| r.get("background").is_none()), "{r:?}");
|
||||
assert!(app.background.jobs.is_empty() && !frame(&mut app, &ctx, 3.0).contains("Saving"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_export_of_files_counts_files() {
|
||||
let go = Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
|
||||
@@ -6063,6 +6063,9 @@ theme Appearance Външен вид
|
||||
Continue in Background Продължаване във фонов режим
|
||||
Cancel Export Отказ от експортирането
|
||||
@msg Export cancelled Експортирането е отказано
|
||||
Cancel Save Отказ от записването
|
||||
@plural {n} more save waiting|{n} more saves waiting Още {n} записване в изчакване|Още {n} записвания в изчакване
|
||||
@msg Save canceled Записването е отказано
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Желано
|
||||
Word Spacing: Разстояние между думите:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6084,6 +6084,9 @@ mark-style Japanese Japanski
|
||||
Continue in Background Nastavi u pozadini
|
||||
Cancel Export Otkaži izvoz
|
||||
@msg Export cancelled Izvoz otkazan
|
||||
Cancel Save Otkaži čuvanje
|
||||
@plural {n} more save waiting|{n} more saves waiting Čeka još {n} čuvanje|Čekaju još {n} čuvanja|Čeka još {n} čuvanja
|
||||
@msg Save canceled Čuvanje otkazano
|
||||
Desired Željeno
|
||||
Word Spacing: Razmak riječi:
|
||||
Letter Spacing: Razmak slova:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -5887,6 +5887,9 @@ liquify-list-end {0}, {1} {0} i {1}
|
||||
@msg Expand: no gradient fills Expandeix: no hi ha farciments de degradat
|
||||
@msg Expand: nothing to expand Expandeix: no hi ha res per expandir
|
||||
@msg Export cancelled Exportació cancel·lada
|
||||
Cancel Save Cancel·la el desament
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} desament més en espera|{n} desaments més en espera
|
||||
@msg Save canceled Desament cancel·lat
|
||||
@msg Exported {path} S’ha exportat {path}
|
||||
@msg Exported {what} S’ha exportat {what}
|
||||
@msg Exporting {_1} S’està exportant {_1}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6512,6 +6512,9 @@ mark-style Japanese Japonské
|
||||
Continue in Background Pokračovat na pozadí
|
||||
Cancel Export Zrušit export
|
||||
@msg Export cancelled Export byl zrušen
|
||||
Cancel Save Zrušit ukládání
|
||||
@plural {n} more save waiting|{n} more saves waiting Čeká ještě {n} uložení|Čekají ještě {n} uložení|Čeká ještě {n} uložení
|
||||
@msg Save canceled Ukládání bylo zrušeno
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Požadované
|
||||
Word Spacing: Mezery mezi slovy:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -8793,6 +8793,9 @@ swatch Bright Violet Kraftig violet
|
||||
Continue in Background Fortsæt i baggrunden
|
||||
Cancel Export Annullér eksport
|
||||
@msg Export cancelled Eksport annulleret
|
||||
Cancel Save Annullér gemning
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} gemning mere venter|{n} gemninger mere venter
|
||||
@msg Save canceled Gemning annulleret
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Ønsket
|
||||
Word Spacing: Ordafstand:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6094,6 +6094,9 @@ effect Soft Weich
|
||||
Continue in Background Im Hintergrund fortsetzen
|
||||
Cancel Export Export abbrechen
|
||||
@msg Export cancelled Export abgebrochen
|
||||
Cancel Save Speichern abbrechen
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} weiterer Speichervorgang wartet|{n} weitere Speichervorgänge warten
|
||||
@msg Save canceled Speichern abgebrochen
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Optimal
|
||||
Word Spacing: Wortabstand:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6492,6 +6492,9 @@ effect Points Σημεία
|
||||
Continue in Background Συνέχεια στο παρασκήνιο
|
||||
Cancel Export Ακύρωση εξαγωγής
|
||||
@msg Export cancelled Η εξαγωγή ακυρώθηκε
|
||||
Cancel Save Ακύρωση αποθήκευσης
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} ακόμη αποθήκευση σε αναμονή|{n} ακόμη αποθηκεύσεις σε αναμονή
|
||||
@msg Save canceled Η αποθήκευση ακυρώθηκε
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Επιθυμητό
|
||||
Word Spacing: Απόσταση λέξεων:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6480,6 +6480,9 @@ mark-style Japanese Japonesas
|
||||
Continue in Background Continuar en segundo plano
|
||||
Cancel Export Cancelar exportación
|
||||
@msg Export cancelled Exportación cancelada
|
||||
Cancel Save Cancelar guardado
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} guardado más en espera|{n} guardados más en espera
|
||||
@msg Save canceled Guardado cancelado
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Deseado
|
||||
Word Spacing: Espaciado entre palabras:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6502,6 +6502,9 @@ mark-style Japanese Japanilainen
|
||||
Continue in Background Jatka taustalla
|
||||
Cancel Export Peruuta vienti
|
||||
@msg Export cancelled Vienti peruutettiin
|
||||
Cancel Save Peruuta tallennus
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} tallennus odottaa|{n} tallennusta odottaa
|
||||
@msg Save canceled Tallennus peruutettiin
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Haluttu
|
||||
Word Spacing: Sanaväli:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6507,6 +6507,9 @@ theme Appearance Apparence
|
||||
Continue in Background Continuer en arrière-plan
|
||||
Cancel Export Annuler l’exportation
|
||||
@msg Export cancelled Exportation annulée
|
||||
Cancel Save Annuler l’enregistrement
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} autre enregistrement en attente|{n} autres enregistrements en attente
|
||||
@msg Save canceled Enregistrement annulé
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Optimal
|
||||
Word Spacing: Espacement des mots :
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -487,6 +487,7 @@
|
||||
Can't save “{name}”. “{name}” સાચવી શકાતી નથી.
|
||||
Cancel રદ કરો
|
||||
Cancel Export નિકાસ રદ કરો
|
||||
Cancel Save સાચવવાનું રદ કરો
|
||||
Cancel Image Trace ઇમેજ ટ્રેસ રદ કરો
|
||||
Cancel Key Object કી ઑબ્જેક્ટ રદ કરો
|
||||
Cancel Opening ખોલવાનું રદ કરો
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -7085,6 +7085,9 @@ liquify-list-end {0}, {1} {0} और {1}
|
||||
@msg expected {{"objects": [...]}} अपेक्षित: {{"objects": [...]}}
|
||||
@msg export `{name}`: {e} निर्यात `{name}`: {e}
|
||||
@msg Export cancelled निर्यात रद्द
|
||||
Cancel Save सेव रद्द करना
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} और सेव प्रतीक्षा में|{n} और सेव प्रतीक्षा में
|
||||
@msg Save canceled सेव रद्द
|
||||
@msg Export for Screens writes png, png8, jpg, webp, gif, tiff, bmp, tga, psd, svg, svgz, pdf, eps, ai or vectorcraft स्क्रीन के लिए एक्सपोर्ट png, png8, jpg, webp, gif, tiff, bmp, tga, psd, svg, svgz, pdf, eps, ai या vectorcraft लिखता है
|
||||
@msg export presets file is larger than {MAX_PRESET_FILE_BYTES} bytes निर्यात प्रीसेट फ़ाइल {MAX_PRESET_FILE_BYTES} bytes से बड़ा है
|
||||
@msg Exported {path} {path} एक्सपोर्ट किया गया
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6496,6 +6496,9 @@ liquify-list-end {0}, {1} {0} és {1}
|
||||
Continue in Background Folytatás a háttérben
|
||||
Cancel Export Exportálás megszakítása
|
||||
@msg Export cancelled Az exportálás megszakítva
|
||||
Cancel Save Mentés megszakítása
|
||||
@plural {n} more save waiting|{n} more saves waiting Még {n} mentés várakozik
|
||||
@msg Save canceled A mentés megszakítva
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Kívánt
|
||||
Word Spacing: Szóköz:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6062,6 +6062,9 @@ swatch Bright Violet Violet cerah
|
||||
Continue in Background Lanjutkan di latar belakang
|
||||
Cancel Export Batalkan ekspor
|
||||
@msg Export cancelled Ekspor dibatalkan
|
||||
Cancel Save Batalkan penyimpanan
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} penyimpanan lagi menunggu
|
||||
@msg Save canceled Penyimpanan dibatalkan
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Diinginkan
|
||||
Word Spacing: Spasi Kata:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2490 and column 5.
|
@@ -6130,6 +6130,9 @@ lighting Light Luce
|
||||
Continue in Background Continua in background
|
||||
Cancel Export Annulla esportazione
|
||||
@msg Export cancelled Esportazione annullata
|
||||
Cancel Save Annulla salvataggio
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} altro salvataggio in attesa|{n} altri salvataggi in attesa
|
||||
@msg Save canceled Salvataggio annullato
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Desiderato
|
||||
Word Spacing: Spaziatura parole:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6177,6 +6177,9 @@ lighting Light ライト
|
||||
Continue in Background バックグラウンドで続行
|
||||
Cancel Export 書き出しをキャンセル
|
||||
@msg Export cancelled 書き出しをキャンセルしました
|
||||
Cancel Save 保存をキャンセル
|
||||
@plural {n} more save waiting|{n} more saves waiting 待機中の保存: あと {n} 件
|
||||
@msg Save canceled 保存をキャンセルしました
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired 最適
|
||||
Word Spacing: 単語間隔:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -8497,6 +8497,9 @@ liquify-list-end {0}, {1} {0} და {1}
|
||||
Cancel Export ექსპორტირების გაუქმება
|
||||
@plural {n} more export waiting|{n} more exports waiting რიგში მომლოდინე სხვა ექსპორტირება: {n}
|
||||
@msg Export cancelled ექსპორტირება გაუქმდა
|
||||
Cancel Save შენახვის გაუქმება
|
||||
@plural {n} more save waiting|{n} more saves waiting რიგში მომლოდინე სხვა შენახვა: {n}
|
||||
@msg Save canceled შენახვა გაუქმდა
|
||||
Clear History ისტორიის გასუფთავება
|
||||
New Document from State ახალი დოკუმენტი მდგომარეობიდან
|
||||
Continue in Background ფონურ რეჟიმში გაგრძელება
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6094,6 +6094,9 @@ lighting Light 광원
|
||||
Continue in Background 백그라운드에서 계속
|
||||
Cancel Export 내보내기 취소
|
||||
@msg Export cancelled 내보내기를 취소했습니다
|
||||
Cancel Save 저장 취소
|
||||
@plural {n} more save waiting|{n} more saves waiting 대기 중인 저장 {n}개 더
|
||||
@msg Save canceled 저장을 취소했습니다
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired 희망
|
||||
Word Spacing: 단어 간격:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -8618,6 +8618,9 @@ swatch Bright Violet Felviolet
|
||||
Continue in Background Doorgaan op achtergrond
|
||||
Cancel Export Export annuleren
|
||||
@msg Export cancelled Export geannuleerd
|
||||
Cancel Save Opslaan annuleren
|
||||
@plural {n} more save waiting|{n} more saves waiting Nog {n} opslagactie in de wachtrij|Nog {n} opslagacties in de wachtrij
|
||||
@msg Save canceled Opslaan geannuleerd
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Gewenst
|
||||
Word Spacing: Woordafstand:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6366,6 +6366,9 @@ mark-style Japanese Japońskie
|
||||
Continue in Background Kontynuuj w tle
|
||||
Cancel Export Anuluj eksport
|
||||
@msg Export cancelled Eksport anulowany
|
||||
Cancel Save Anuluj zapisywanie
|
||||
@plural {n} more save waiting|{n} more saves waiting Czeka jeszcze {n} zapis|Czekają jeszcze {n} zapisy|Czeka jeszcze {n} zapisów
|
||||
@msg Save canceled Zapisywanie anulowane
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Optymalne
|
||||
Word Spacing: Odstępy między wyrazami:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6424,6 +6424,9 @@ mark-style Japanese Japonesas
|
||||
Continue in Background Continuar em Segundo Plano
|
||||
Cancel Export Cancelar Exportação
|
||||
@msg Export cancelled Exportação cancelada
|
||||
Cancel Save Cancelar Salvamento
|
||||
@plural {n} more save waiting|{n} more saves waiting Mais {n} salvamento aguardando|Mais {n} salvamentos aguardando
|
||||
@msg Save canceled Salvamento cancelado
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Desejado
|
||||
Word Spacing: Espaçamento entre Palavras:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6130,6 +6130,9 @@ lighting Light Свет
|
||||
Continue in Background Продолжить в фоне
|
||||
Cancel Export Отменить экспорт
|
||||
@msg Export cancelled Экспорт отменён
|
||||
Cancel Save Отменить сохранение
|
||||
@plural {n} more save waiting|{n} more saves waiting Ещё {n} сохранение в очереди|Ещё {n} сохранения в очереди|Ещё {n} сохранений в очереди
|
||||
@msg Save canceled Сохранение отменено
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Желательно
|
||||
Word Spacing: Интервал между словами:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6552,6 +6552,9 @@ swatch Yellow Green Gulgrön
|
||||
Continue in Background Fortsätt i bakgrunden
|
||||
Cancel Export Avbryt export
|
||||
@msg Export cancelled Exporten avbröts
|
||||
Cancel Save Avbryt sparande
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} sparande till väntar|{n} sparanden till väntar
|
||||
@msg Save canceled Sparandet avbröts
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Önskat
|
||||
Word Spacing: Ordavstånd:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6622,6 +6622,9 @@ theme Appearance Görünüm
|
||||
@msg Flat Logo traced the image at {_1} × {_2} pixels, averaged down from {_3} × {_4}. Düz Logo modu görüntüyü {_3} × {_4} boyutundan ortalama alarak küçültüp {_1} × {_2} pikselde izledi.
|
||||
@plural {n} more export waiting|{n} more exports waiting {n} dışa aktarma daha bekliyor|{n} dışa aktarma daha bekliyor
|
||||
@msg Export cancelled Dışa aktarma iptal edildi
|
||||
Cancel Save Kaydetmeyi İptal Et
|
||||
@plural {n} more save waiting|{n} more saves waiting {n} kaydetme daha bekliyor|{n} kaydetme daha bekliyor
|
||||
@msg Save canceled Kaydetme iptal edildi
|
||||
Add filters from the list above Yukarıdaki listeden filtre ekleyin
|
||||
Add to Stack Yığına Ekle
|
||||
Applied Filters Uygulanan Filtreler
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6112,6 +6112,9 @@ lighting Light Світло
|
||||
Continue in Background Продовжити у фоні
|
||||
Cancel Export Скасувати експорт
|
||||
@msg Export cancelled Експорт скасовано
|
||||
Cancel Save Скасувати збереження
|
||||
@plural {n} more save waiting|{n} more saves waiting Ще {n} збереження в очікуванні|Ще {n} збереження в очікуванні|Ще {n} збережень в очікуванні
|
||||
@msg Save canceled Збереження скасовано
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Бажане
|
||||
Word Spacing: Інтервал між словами:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6141,6 +6141,9 @@ liquify-list-end {0}, {1} {0} và {1}
|
||||
Continue in Background Tiếp tục trong nền
|
||||
Cancel Export Hủy xuất
|
||||
@msg Export cancelled Đã hủy xuất
|
||||
Cancel Save Hủy lưu
|
||||
@plural {n} more save waiting|{n} more saves waiting Còn {n} lượt lưu đang chờ
|
||||
@msg Save canceled Đã hủy lưu
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired Mong muốn
|
||||
Word Spacing: Khoảng cách từ:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 205 and column 5.
|
@@ -6348,6 +6348,9 @@ lighting Light 光源
|
||||
Continue in Background 在后台继续
|
||||
Cancel Export 取消导出
|
||||
@msg Export cancelled 已取消导出
|
||||
Cancel Save 取消保存
|
||||
@plural {n} more save waiting|{n} more saves waiting 另有 {n} 个保存等待中
|
||||
@msg Save canceled 已取消保存
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired 所需
|
||||
Word Spacing: 字间距:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6146,6 +6146,9 @@ lighting Light 光源
|
||||
Continue in Background 在背景繼續
|
||||
Cancel Export 取消匯出
|
||||
@msg Export cancelled 已取消匯出
|
||||
Cancel Save 取消儲存
|
||||
@plural {n} more save waiting|{n} more saves waiting 另有 {n} 個儲存等待中
|
||||
@msg Save canceled 已取消儲存
|
||||
# Paragraph panel menu › Justification…
|
||||
Desired 所需
|
||||
Word Spacing: 字間距:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -35,7 +35,9 @@ pub use open::{
|
||||
#[cfg(test)]
|
||||
pub(crate) use open::{open_file, opened_with_notes};
|
||||
pub(crate) use save::save_current;
|
||||
pub use save::{ask_format_options, ask_pdf_options, remember_active_artboard, remember_view, save, save_pdf};
|
||||
pub use save::{
|
||||
SAVE_CANCELED, ask_format_options, ask_pdf_options, cancel_saves, hide_saves, remember_active_artboard, remember_view, save, save_pdf,
|
||||
};
|
||||
pub(crate) use save::{export_path, is_web, notes_of, report_saved, show_with_notes, target_path, write_named, write_reporting, write_to};
|
||||
#[cfg(test)]
|
||||
pub(crate) use save::{report_write_error, saved_status};
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
use super::export::file_url;
|
||||
use super::open::{note_recent, open_options};
|
||||
use super::{
|
||||
EngineError, FilePick, Format, SAVE_FORMATS, SaveMode, SavePlan, SavedView, Services, TEMPLATE_FORMATS, Value, VectorcraftApp, Writer,
|
||||
background, dialogs, fileio, json, svg_options,
|
||||
EngineError, FilePick, Format, Progress, SAVE_FORMATS, SaveMode, SavePlan, SavedView, Services, TEMPLATE_FORMATS, Value, VectorcraftApp, Writer,
|
||||
background, dialogs, fileio, json, progress, svg_options,
|
||||
};
|
||||
|
||||
/// The status once a save running in the background was canceled.
|
||||
pub const SAVE_CANCELED: &str = "Save canceled";
|
||||
|
||||
/// File › Cancel Save (the progress window's Cancel): every save running in the background stops
|
||||
/// before it replaces its file. The file stays as it was, and the document keeps its file, format
|
||||
/// and modified state → `{cancelled: n}`. A save whose file was already written is reported as saved.
|
||||
pub fn cancel_saves(app: &mut VectorcraftApp) -> Value {
|
||||
let n = app.background.cancel_saves();
|
||||
if n > 0 {
|
||||
app.status(SAVE_CANCELED);
|
||||
}
|
||||
json!({ "cancelled": n })
|
||||
}
|
||||
|
||||
/// The progress window's Continue in Background for saves: they go on, shown in the status bar
|
||||
/// only → `{hidden: n}`.
|
||||
pub fn hide_saves(app: &mut VectorcraftApp) -> Value {
|
||||
json!({ "hidden": app.background.hide_saves() })
|
||||
}
|
||||
|
||||
/// A save or an export that didn't write `path`: say so in a dialog that names the file and the
|
||||
/// reason and stays until it is closed, as an editor does (#1685). The status bar's line, which
|
||||
/// the caller's error becomes, is replaced by the next message, and a document that wasn't saved
|
||||
@@ -566,7 +586,10 @@ fn write_plan(
|
||||
let stream = app.services.stream_shared.clone().filter(|_| job.streams() && !is_web(app));
|
||||
let (exists, allowed) = checks_replaced(app);
|
||||
let known: Vec<String> = allowed.iter().chain(app.picks.written_beside.get(&uid).into_iter().flatten()).cloned().collect();
|
||||
let work = move |write: Writer| {
|
||||
// The progress window's Cancel: a save canceled before it replaces its file writes nothing.
|
||||
let progress = Progress::new();
|
||||
let (reporting, asked) = (progress.clone(), progress.clone());
|
||||
let write_file = move |write: Writer| {
|
||||
let mut own_refused = false;
|
||||
let mut observed = |p: &str, r: vectorcraft_engine::Result<()>| {
|
||||
own_refused = own_path.as_deref() == Some(p) && matches!(&r, Err(EngineError::ReadOnlyLocation(_)));
|
||||
@@ -583,16 +606,21 @@ fn write_plan(
|
||||
(_, _, Some(stream)) => job.write_streamed(&mut |p, fill| stream(p, fill).map_err(EngineError::Other)),
|
||||
_ => job.write_unless(check, |p, b| write(p, b).map_err(EngineError::Other)),
|
||||
};
|
||||
r.map_err(|e| {
|
||||
if let EngineError::ReadOnlyLocation(reason) = &e {
|
||||
refused_by_work.store(own_refused, std::sync::atomic::Ordering::Relaxed);
|
||||
if !by_control {
|
||||
return reason.clone();
|
||||
match r {
|
||||
// Nothing written: the file is as it was.
|
||||
Err(EngineError::Cancelled) => Ok(json!({ "cancelled": true })),
|
||||
r => r.map_err(|e| {
|
||||
if let EngineError::ReadOnlyLocation(reason) = &e {
|
||||
refused_by_work.store(own_refused, std::sync::atomic::Ordering::Relaxed);
|
||||
if !by_control {
|
||||
return reason.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
e.to_string()
|
||||
})
|
||||
e.to_string()
|
||||
}),
|
||||
}
|
||||
};
|
||||
let work = move |write: Writer| progress::scope(&reporting, || write_file(write));
|
||||
let failed = target.clone().unwrap_or_default();
|
||||
// The status line before the save starts: on the worker, the save sets one line ("<label>…")
|
||||
// right after this; written right away, it sets none before `then` runs.
|
||||
@@ -611,6 +639,12 @@ fn write_plan(
|
||||
report_write_error(app, false, &failed, e);
|
||||
}
|
||||
})?;
|
||||
// Canceled before the file was replaced: the document keeps its file, format and modified
|
||||
// state.
|
||||
if r.get("cancelled").and_then(Value::as_bool) == Some(true) {
|
||||
app.status(SAVE_CANCELED);
|
||||
return Ok(r);
|
||||
}
|
||||
// Nothing written either: asked first.
|
||||
if let Some(files) = r.get("replaces").and_then(Value::as_array) {
|
||||
let files: Vec<String> = files.iter().filter_map(Value::as_str).map(str::to_string).collect();
|
||||
@@ -626,13 +660,14 @@ fn write_plan(
|
||||
let beside: Vec<String> = beside.filter(|p| *p != path).map(str::to_string).collect();
|
||||
app.picks.written_beside.insert(uid, beside);
|
||||
}
|
||||
// A line set while the file was written (another command's, another job's) stays.
|
||||
if background::status_unchanged(app, sets, &started_line) {
|
||||
// A line set while the file was written (another command's, another job's) stays. A Cancel
|
||||
// that came once the file was being replaced said it was canceled: the file is saved.
|
||||
if background::status_unchanged(app, sets, &started_line) || asked.cancelled() {
|
||||
report_saved(app, &path, &r);
|
||||
}
|
||||
Ok(r)
|
||||
};
|
||||
let mut r = background::run(app, enabled, label, Some(uid), work, then)?;
|
||||
let mut r = background::run_saving(app, enabled, label, uid, progress, work, then)?;
|
||||
if let Some(path) = target.filter(|_| r.get("path").is_none()) {
|
||||
r["path"] = json!(path);
|
||||
}
|
||||
|
||||
@@ -182,6 +182,8 @@ fn run_ui_part1(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
"file.reveal" => io::reveal(app),
|
||||
"file.cancelExport" => Ok(io::cancel_exports(app)),
|
||||
"file.exportInBackground" => Ok(io::hide_exports(app)),
|
||||
"file.cancelSave" => Ok(io::cancel_saves(app)),
|
||||
"file.saveInBackground" => Ok(io::hide_saves(app)),
|
||||
"file.cancelOpen" => Ok(crate::opening::cancel_all(app)),
|
||||
"file.openInBackground" => Ok(crate::opening::hide_all(app)),
|
||||
id if id.starts_with("file.openRecent") => match recent_slot(app, id).filter(|path| recent_readable(path)).cloned() {
|
||||
|
||||
@@ -226,7 +226,8 @@ pub fn enabled(app: &VectorcraftApp, id: &str) -> bool {
|
||||
"type.applyBullets" | "type.applyNumbers" | "type.convertListToText" => crate::panels::character::text_style(app).is_some(),
|
||||
id if let Some(b) = crate::panels::align::button(id) => enabled(app, b.command_now(app)),
|
||||
"file.reveal" => app.services.reveal.is_some() && app.session.active().is_some_and(|d| d.path.is_some()),
|
||||
"file.cancelExport" | "file.exportInBackground" => app.background.jobs.iter().any(|j| j.progress.is_some() && !j.cancelled()),
|
||||
"file.cancelExport" | "file.exportInBackground" => app.background.running(crate::background::Kind::Export),
|
||||
"file.cancelSave" | "file.saveInBackground" => app.background.running(crate::background::Kind::Save),
|
||||
"file.cancelOpen" => !app.opening.pending.is_empty(),
|
||||
"file.openInBackground" => crate::opening::any_shown(app),
|
||||
"plugin.cancelRuns" => crate::plugin_runs::any_running(app),
|
||||
|
||||
@@ -1456,6 +1456,18 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"",
|
||||
"{} close the export progress dialog; the exports go on, shown in the status bar → {hidden: n}",
|
||||
),
|
||||
(
|
||||
"file.cancelSave",
|
||||
"Cancel Save",
|
||||
"",
|
||||
"{} stop every save running in the background (Background Save) before it replaces its file: the file stays as it was and the document keeps its file and stays modified; a save whose file was already being replaced finishes and is reported as saved → {cancelled: n}",
|
||||
),
|
||||
(
|
||||
"file.saveInBackground",
|
||||
"Continue in Background",
|
||||
"",
|
||||
"{} close the save progress window; the saves go on, shown in the status bar → {hidden: n}",
|
||||
),
|
||||
(
|
||||
"file.cancelOpen",
|
||||
"Cancel Opening",
|
||||
|
||||
@@ -3094,10 +3094,11 @@ mod tests {
|
||||
assert_eq!(shown("file.new"), Some(("File".into(), "New…".into(), true)));
|
||||
assert_eq!(shown("text.fitHeadline"), Some(("Type".into(), "Fit Headline".into(), false)));
|
||||
assert_eq!(shown("type.fitHeadline"), Some(("Type".into(), "Fit Headline".into(), true)));
|
||||
for id in ["file.exportInBackground", "file.openInBackground"] {
|
||||
for id in ["file.exportInBackground", "file.openInBackground", "file.saveInBackground"] {
|
||||
assert_eq!(shown(id), Some(("File".into(), "Continue in Background".into(), true)), "{id}");
|
||||
}
|
||||
assert_eq!(shown("file.cancelExport"), Some(("File".into(), "Cancel Export".into(), false)));
|
||||
assert_eq!(shown("file.cancelSave"), Some(("File".into(), "Cancel Save".into(), false)));
|
||||
let e = entry("type.fitHeadline").unwrap();
|
||||
assert!(shown_name(&e).ends_with("Fit Headline (type.fitHeadline)"), "{}", shown_name(&e));
|
||||
assert!(row_matches(&e, "type.fitheadline", None));
|
||||
|
||||
@@ -196,6 +196,59 @@ fn a_cancelled_export_writes_nothing() {
|
||||
assert_eq!(app.ui.status, io::EXPORT_CANCELLED);
|
||||
}
|
||||
|
||||
/// Background Save's Cancel (`file.cancelSave`): a save canceled before it replaces its file writes
|
||||
/// nothing, and its document keeps its file, format and modified state, with no recent file noted
|
||||
/// and no error shown. A save already writing its file when Cancel came finishes and counts as
|
||||
/// saved. An export waiting with them goes on.
|
||||
#[test]
|
||||
fn a_canceled_save_writes_nothing_and_keeps_the_document_modified() {
|
||||
let (gate, writing) = (Gate::default(), Gate::default());
|
||||
let files = Files::default();
|
||||
let (f, g, w) = (files.clone(), gate.clone(), writing.clone());
|
||||
let services = Services {
|
||||
write_shared: Some(Arc::new(move |p: &str, b: &[u8]| {
|
||||
w.open();
|
||||
g.wait();
|
||||
f.lock().unwrap().push((p.to_string(), b.to_vec()));
|
||||
Ok(())
|
||||
})),
|
||||
..Default::default()
|
||||
};
|
||||
let mut app = VectorcraftApp::new(Session::new(), services);
|
||||
app.run("file.new", json!({"width": 100, "height": 100})).unwrap();
|
||||
let first = app.session.active().unwrap().uid;
|
||||
// The first save holds the worker at the gate, past its last check: it still writes.
|
||||
app.run("file.save", json!({"path": "/docs/first.vectorcraft"})).unwrap();
|
||||
writing.wait();
|
||||
assert!(!crate::menus::enabled(&app, "file.cancelExport"), "a save is not an export");
|
||||
io::export(&mut app, Some("svg"), Some("/out/c.svg".into()), &json!({})).unwrap();
|
||||
app.run("file.new", json!({"width": 100, "height": 100})).unwrap();
|
||||
app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap();
|
||||
let second = app.session.active().unwrap().uid;
|
||||
let r = app.run("file.save", json!({"path": "/docs/second.svg"})).unwrap();
|
||||
assert_eq!(r["background"], true, "{r}");
|
||||
assert!(crate::menus::enabled(&app, "file.cancelSave") && crate::menus::enabled(&app, "file.saveInBackground"));
|
||||
assert_eq!(app.run("file.cancelSave", json!({})).unwrap()["cancelled"], 2);
|
||||
assert_eq!(app.ui.status, io::SAVE_CANCELED);
|
||||
assert_eq!(app.run("file.cancelSave", json!({})).unwrap()["cancelled"], 0, "nothing left to cancel");
|
||||
assert!(!crate::menus::enabled(&app, "file.cancelSave"));
|
||||
gate.open();
|
||||
background::wait_all(&mut app);
|
||||
assert_eq!(written(&files), ["/docs/first.vectorcraft", "/out/c.svg"]);
|
||||
fn doc(app: &VectorcraftApp, uid: u64) -> &vectorcraft_engine::DocState {
|
||||
app.session.documents().iter().find(|d| d.uid == uid).unwrap()
|
||||
}
|
||||
let st = doc(&app, first);
|
||||
assert_eq!(st.path.as_deref(), Some("/docs/first.vectorcraft"), "written before the Cancel took effect");
|
||||
let st = doc(&app, second);
|
||||
assert!(st.is_dirty() && st.path.is_none(), "the canceled save left the document as it was");
|
||||
assert_eq!(st.format, "vectorcraft");
|
||||
assert!(io::recent_files(&app).iter().any(|p| p == "/docs/first.vectorcraft"));
|
||||
assert!(!io::recent_files(&app).iter().any(|p| p == "/docs/second.svg"));
|
||||
assert!(app.ui.dialog.is_none(), "no error is shown");
|
||||
assert_eq!(app.ui.status, io::SAVE_CANCELED);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quitting_waits_for_background_saves() {
|
||||
let gate = Gate::default();
|
||||
|
||||
+1
-1
@@ -490,7 +490,7 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi
|
||||
Estimate unchanged.
|
||||
- **Done (2026-10-21, #394):** General › Constrain Angle turns the arrow keys' axes (guides stay on the page's), holds Shift drags of the Selection, Direct Selection, Free Transform, Slice Selection, Reshape and Measure tools and the Pen's handles to the turned axes, and new rectangles, rounded rectangles, ellipses, grids, point and area type, Shift-drawn polygons and stars and the shape size dialogs are drawn along it with their bounding box turned; 0° and whole turns are exactly as before, quarter turns exact (<https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/rotate-objects-by-specific-angles.html>). Arcs, spirals, flares and the Pen's new paths are not turned yet. Estimate unchanged.
|
||||
- **Done (2026-10-21, #394):** General › Constrain Angle turns the arrow keys' axes (guides stay on the page's), holds Shift drags of the Selection, Direct Selection, Free Transform, Slice Selection, Reshape and Measure tools and the Pen's handles to the turned axes, and new rectangles, rounded rectangles, ellipses, grids, point and area type, Shift-drawn polygons and stars and the shape size dialogs are drawn along it with their bounding box turned; 0° and whole turns are exactly as before, quarter turns exact (<https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/rotate-objects-by-specific-angles.html>). Arcs, spirals, flares and the Pen's new paths are not turned yet. Estimate unchanged. **2026-10-24:** General › Corner Radius is the Rounded Rectangle tool's radius: the tool takes the preference when chosen and when it changes while the tool is active (or lent a selection tool for a drag), and the radius ↑/↓ set while drawing one, or a Tool Options value, becomes the preference, clamped to its 0–1296 pt range (<https://helpx.adobe.com/illustrator/using/drawing-simple-lines-shapes.html>). Estimate unchanged.
|
||||
- **Done (2026-10-17):** Background Export shows its progress in a dialog with Cancel and Continue in Background (#2564), on the shared cancel token (#2546); a cancelled export writes no file. Save As, Export for Screens and Export Selection don't show it yet. Estimate unchanged. **2026-11-06:** opening a file that takes longer than 0.4 s shows a progress window too, with a moving bar, Cancel and Continue in Background (part of #5930); Save and Place still show only the status bar's spinner. Estimate unchanged.
|
||||
- **Done (2026-10-17):** Background Export shows its progress in a dialog with Cancel and Continue in Background (#2564), on the shared cancel token (#2546); a cancelled export writes no file. Save As, Export for Screens and Export Selection don't show it yet. Estimate unchanged. **2026-11-06:** opening a file that takes longer than 0.4 s shows a progress window too, with a moving bar, Cancel and Continue in Background (part of #5930); Save and Place still show only the status bar's spinner. Estimate unchanged. **2026-11-15:** a save that runs in the background shows in that window too, with a moving bar, Cancel (the file stays as it was and the document stays modified) and Continue in Background (`file.cancelSave`, `file.saveInBackground`); Place still shows only the spinner. Estimate unchanged.
|
||||
- **Done:** quick Image Trace presets trace at once and leave the panel as it was; the Image Trace button (Control bar, Properties) opens the controls with Threshold and Advanced (Paths, Corners, Noise), as the public documentation describes (<https://helpx.adobe.com/illustrator/using/image-trace-results-optimization.html>). Other context-specific Properties gaps remain.
|
||||
- **Done (2026-10-31, #394):** Units › East Asian Type is read, and Q and Ha are units. 1 Q and 1 Ha are each a
|
||||
quarter of a millimetre (0.709 pt), the Japanese typesetting units: the [Illustrator Scripting Guide's
|
||||
|
||||
+4
-3
@@ -690,7 +690,7 @@ sampler.
|
||||
| `open_panel` | `{panel}` | Remote only. `panel` is a panel id (`layers`, `swatches`, `colorGuide`, …, as `window.panel` takes) or its display label (`"Color Guide"`), in any case. |
|
||||
| `screenshot` | `{path?, scale?, artboard?, window?, max_side?, traceViews?}` | Returns MCP image content (`image/png`, base64) plus a text block. Renders the artboard with the pixels of a PNG `export` with `background: "white"` at the same scale; `traceViews:true` draws Image Trace objects in the view set with `imageTrace.setView`, as in the app's window; `window:true` captures the app window (remote only), as `ui_screenshot` does, and `max_side` (1–4096, window captures only) scales the returned image down as described for `ui_screenshot`. With `path` the backend (the headless session or the app) writes the PNG there too; a window capture written there keeps its full size with `max_side`. An app that does not send the image back writes a window capture without `path` to a file in a new folder inside the system's temporary folder (on Unix only the user can open it); the server reads the file and then removes the folder, also when the capture or the read fails. |
|
||||
| `open_file` | `{path, importer?, params?}` | Opens any readable file as a new active document: `.vectorcraft`/`.drawcraft`, `.vctemplate`, `.svg`/`.svgz`, `.pdf`/`.ai`, `.ait`, `.eps`/`.epsf`, `.ps`, `.dxf`, `.emf`, `.wmf`, PICT (`.pct`/`.pic`/`.pict`, and a version 2 picture of any extension), HP-GL (`.plt`/`.hpgl`/`.hgl`/`.hpg`, and a file of an extension no other format reads that starts with plotter instructions), PNG (`.png`/`.pns`), JPEG, GIF, WebP, TIFF, BMP (`.bmp`/`.dib`/`.rle`), Targa (`.tga`/`.vda`/`.icb`/`.vst`), PCX, Pixar (`.pxr`), JPEG 2000 (`.jpf`/`.jpx`/`.jp2`/`.j2k`/`.j2c`/`.jpc`), HEIC/HEIF (`.heic`/`.heif`), JPEG XL (`.jxl`), PSD (`.psd`/`.pdd`)/PSB (an image opens as a document of its pixel size; a PSD or PSB file with its layers as layers, or as its merged image through `run_command document.open` with `layers: false`; a JPEG XL file as its first frame). Templates (`.vctemplate`, `.ait`) open as a new untitled document. PDF, `.ai` and SVG files saved with Preserve Editing reopen as the document they carry. The reply is `document.open`'s: its `warnings` say what didn't come in as it was (an EPS whose PostScript can't be read opens as its preview, and the warning names the PostScript error, the operator and the procedure). A file of an extension only an installed importer plug-in lists opens with that importer ([Plug-ins](#plug-ins)); `importer: "plugin.<id>"` opens the file with the importer it names, which must list the file's extension, also one a built-in format reads (in the app, as File › Open With does), and `params` gives that importer's parameters (their defaults when omitted). `run_command document.formats` lists the formats. |
|
||||
| `save_file` | `{path?, compress?, version?, preview?, precision?, options?}` | Runs `document.save`: the document's own file in its own format (native `.vectorcraft` unless it was opened from or saved as SVG, PDF or a restorable `.ai`; then `warnings` say what that format loses). A path's extension picks the format (`.vectorcraft`, `.vctemplate`, `.pdf`, `.svg`, `.svgz`, `.ai`: a PDF carrying the native document, which reopens editable; `.eps`: by default one file whose bounding box fits the visible art, the first artboard when no art shows; `options.useArtboards: true` makes the chosen artboard the page and, with two or more chosen, the file at the path is the central file of the visible art and each artboard is also written to `<name>_<artboard>.eps` beside it, listed in the reply's `files`). For a native file, `compress: true` gzips it (default: the `useCompression` preference, Preferences › File Handling › Use Compression), `version` (1 to 4) writes it for an older VectorCraft (1 and 2 are never compressed, and `version: 2` with `compress: true` is an error), `preview: true` embeds a PNG of the first artboard, and `precision` (0 to 9) rounds path anchors and handles to that many decimal places for that save only (colors, transforms and type stay exact). `options` passes the format's save options as `run_command document.formats` lists them. When `compress`, `version`, `preview` or `precision` is given both at the top level and in `options` with different values, the call is an error (`` `compress: true` and `options.compress: false` disagree: give the option once ``) and nothing is written. A key in `options` that no save format takes is an error, and nothing is written (see Parameter keys). The save drops each option the written format doesn't read. The reply's `warnings` then name each such option given (for example `` `compress` was not used: SVG files don't read it `` for an `.svg` path, and `` `options.preview` was not used: … `` for a key in `options`; a PDF-compatible `.ai` file reads `compress` but not `version`, `preview`, `precision`, `outlineText`, `hiddenObjects`, `transparentImages` or `preserveEditing`, and a legacy `.ai` file reads only its own options). For a `.ai` file, these warnings name the kind of `.ai` written: a legacy .ai (version 7) for `aiVersion: "7"`, a non-PDF-compatible .ai for `pdfCompatible: false`, and a PDF-compatible .ai otherwise, including a save that reuses the options the document was last saved with. `run_command document.save` and the other save commands refuse any option given beside the path and in `options` with different values, and give the same warnings for each key given beside the path or in `options` that the file doesn't read. The headless session and the app receive the same `app.save` params, and the app is also sent `wait: true`: the call returns once the file is written, or with the error (such as a path outside the write root), even with Background Save on. When the save asks first (the question before replacing a file that opened with losses, or on macOS and Linux the file dialog for an untitled document without `path`), the reply is `{pending}` or `"cancelled"` as before, and the save that runs after the answer uses the Background Save preference. Location refusals return `READ_ONLY_LOCATION: <reason>` without a fallback panel for automation; see [Save location errors](#save-location-errors). |
|
||||
| `save_file` | `{path?, compress?, version?, preview?, precision?, options?}` | Runs `document.save`: the document's own file in its own format (native `.vectorcraft` unless it was opened from or saved as SVG, PDF or a restorable `.ai`; then `warnings` say what that format loses). A path's extension picks the format (`.vectorcraft`, `.vctemplate`, `.pdf`, `.svg`, `.svgz`, `.ai`: a PDF carrying the native document, which reopens editable; `.eps`: by default one file whose bounding box fits the visible art, the first artboard when no art shows; `options.useArtboards: true` makes the chosen artboard the page and, with two or more chosen, the file at the path is the central file of the visible art and each artboard is also written to `<name>_<artboard>.eps` beside it, listed in the reply's `files`). For a native file, `compress: true` gzips it (default: the `useCompression` preference, Preferences › File Handling › Use Compression), `version` (1 to 4) writes it for an older VectorCraft (1 and 2 are never compressed, and `version: 2` with `compress: true` is an error), `preview: true` embeds a PNG of the first artboard, and `precision` (0 to 9) rounds path anchors and handles to that many decimal places for that save only (colors, transforms and type stay exact). `options` passes the format's save options as `run_command document.formats` lists them. When `compress`, `version`, `preview` or `precision` is given both at the top level and in `options` with different values, the call is an error (`` `compress: true` and `options.compress: false` disagree: give the option once ``) and nothing is written. A key in `options` that no save format takes is an error, and nothing is written (see Parameter keys). The save drops each option the written format doesn't read. The reply's `warnings` then name each such option given (for example `` `compress` was not used: SVG files don't read it `` for an `.svg` path, and `` `options.preview` was not used: … `` for a key in `options`; a PDF-compatible `.ai` file reads `compress` but not `version`, `preview`, `precision`, `outlineText`, `hiddenObjects`, `transparentImages` or `preserveEditing`, and a legacy `.ai` file reads only its own options). For a `.ai` file, these warnings name the kind of `.ai` written: a legacy .ai (version 7) for `aiVersion: "7"`, a non-PDF-compatible .ai for `pdfCompatible: false`, and a PDF-compatible .ai otherwise, including a save that reuses the options the document was last saved with. `run_command document.save` and the other save commands refuse any option given beside the path and in `options` with different values, and give the same warnings for each key given beside the path or in `options` that the file doesn't read. The headless session and the app receive the same `app.save` params, and the app is also sent `wait: true`: the call returns once the file is written, or with the error (such as a path outside the write root), even with Background Save on. When the save asks first (the question before replacing a file that opened with losses, or on macOS and Linux the file dialog for an untitled document without `path`), the reply is `{pending}` or `"cancelled"` as before, and the save that runs after the answer uses the Background Save preference. Location refusals return `READ_ONLY_LOCATION: <reason>` without a fallback panel for automation; see [Save location errors](#save-location-errors). In the desktop app, a save that runs in the background shows in the progress window after 0.4 s with a moving bar. `file.cancelSave` stops every such save before it replaces its file → `{cancelled: n}`: the file stays as it was, and the document keeps its file and format and stays modified. A save whose file was already being replaced finishes and is reported as saved. `file.saveInBackground` closes the window while the saves go on → `{hidden: n}`. |
|
||||
| `export` | `{path?, format?, scale?, artboard?, range?, selection?, outlineText?, options?}` | `svg`, `svgz`, `pdf`, `ai` (the PDF-compatible `.ai` that Save writes, which carries the document when every artboard is written in order), `eps`, `dxf`, `emf`, `wmf`, `hpgl` (a `.plt` plot file for plotters and cutters), `png`, `jpg`, `webp`, `gif`, `png8` (an indexed `.png`), `tiff`, `bmp`, `tga`, `psd` (layered), `txt` (the document's text), `vectorcraft` or `template` (a native template). The tool's `format` enum and `document.formats` list them, generated from the engine's format table. When `format` is omitted, it comes from the path's extension. PDF and `.ai` write one page per artboard: all of them, or `artboard` (0-based) / `range` (`"1-3, 5"`, 1-based). SVG and SVGZ write one file per chosen artboard. EPS writes one file of the visible art; with `artboard`, `range`, `options.artboards` or `options: {"useArtboards": true}` it writes one file per chosen artboard, after a central file of the visible art when there are two or more, and `useArtboards: false` keeps the one file. Rasters, DXF, EMF, WMF and HP-GL write one artboard, or one file per chosen artboard with `options: {"useArtboards": true}`. Rasters also take `options: {"rect": [x, y, width, height]}` (page points, y down): that area of the page at the given `ppi`/`scale`, without an artboard and without changing the document; it is refused with `artboard`, `artboards`, `range` or `useArtboards`, with a non-positive or non-finite size, and for non-raster formats. `options` carries more format options (e.g. `{"quality": 80}` for JPEG). `selection: true` exports the selected objects cropped to their bounds (the reply adds their `bounds`, and reports `format` and the encoder's `warnings` as a whole-document export does); `outlineText: true` writes SVG text as paths. Template layers are left out, live effects are kept, and exporting `vectorcraft` never changes the document's path. Without `path` the bytes come back as `dataBase64`. Both backends run the same `document.export` call. |
|
||||
| `add_text` | `{text, x?, y?, width?, height?, fit?, fitMinPercent?, path?, mode?, pathEffect?, size?, font?, color?, justify?, vertical?}` | Point type at (x, y) (`justify`: `left`, `center` or `right` starts, centres or ends each line on x); area type with `width`/`height` (`fit`: `none`, `autoHeight`, `shrinkText`, as `text.areaOptions`); or `path` + `mode` (`area`/`onPath`) to flow text in or along a path, with `pathEffect` (`rainbow`, `skew`, `3dRibbon`, `stairStep`, `gravity`; SVG export writes type on a path with any effect other than `rainbow` as outlines, with a warning); `justify` (also `auto`, `justifyAll`) aligns the paragraphs of every kind, as `text.setStyle` does later. `vertical: true` uses the existing vertical writing mode for every kind (default `false`, horizontal). Returns `{id}`, with `overflow: true` when the text doesn't fit its frame or path. |
|
||||
| `apply_effect` | `{effect?, params?, ids?}` | Appends a live effect. Without `effect`, returns the effect catalogue with parameters and defaults. |
|
||||
@@ -6523,8 +6523,9 @@ are named this way:
|
||||
- The other rows that still have the same name show their id in parentheses after it. The one row of them that an
|
||||
item of the menu bar runs keeps the name without its id: File › New… is `file.newDialog` and `file.new` is File ›
|
||||
New… (file.new), and Type › Fit Headline is `text.fitHeadline` and `type.fitHeadline` is Type › Fit Headline
|
||||
(type.fitHeadline). `file.exportInBackground` and `file.openInBackground` are File › Continue in Background
|
||||
(file.exportInBackground) and File › Continue in Background (file.openInBackground).
|
||||
(type.fitHeadline). `file.exportInBackground`, `file.openInBackground` and `file.saveInBackground` are File ›
|
||||
Continue in Background (file.exportInBackground), File › Continue in Background (file.openInBackground) and File ›
|
||||
Continue in Background (file.saveInBackground).
|
||||
|
||||
`shortcuts.list` gives such a row's group in `group` and the command's own label in `label`, so the rows that show
|
||||
their id have the same `group` and `label` there, and `id` tells them apart. `shortcuts.exportText` writes these
|
||||
|
||||
@@ -2016,6 +2016,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- On the desktop with Enable Background Export on (Preferences › File Handling), File › Package… collects the linked files and fonts and writes the package from the document as it was at OK on the thread that writes background saves and exports, with "Packaging" in the status bar and the busy spinner until it is written; a save of unsaved changes that Package starts is written first. `file.package` over MCP and scripts replies as before.
|
||||
- On the desktop with Enable Background Export on, Export for Screens and the Asset Export panel's Export encode and write their files (into the folder, or one ZIP in it) from the document as it was at OK on the thread that writes background saves and exports, with "Exporting" in the status bar and the export progress dialog, which counts the files and whose Cancel stops before the next file. `document.exportForScreens` and `assets.export` over MCP and scripts reply as before.
|
||||
- With Enable Background Export on, an Export for Screens with no folder of its own also writes in the background into the folder its `exportPreset` keeps, with the same progress dialog and Cancel, and the status bar names that folder. When that folder is outside an MCP client's read roots, the reply, its errors and the status bar name it by its own name, as for an export made at once (`dialogs::tests_screens::an_export_into_a_presets_folder_writes_in_the_background`, `fileio::tests_screens::a_prepared_export_into_a_presets_folder_outside_the_read_root_leaves_it_out`). Behavior reference: the help page, https://helpx.adobe.com/illustrator/using/exporting-artwork.html (exports run in the background by default).
|
||||
- On the desktop with Enable Background Save on (Preferences › File Handling), a save that is still being written after 0.4 s shows in the same progress window, with the file name, a moving bar (a save counts no steps), how many more saves wait, Cancel (also Esc) and Continue in Background; it never opens over another dialog or progress window. Cancel (`file.cancelSave`) stops the save before it replaces the file: the file stays as it was, the document keeps its file and format and stays modified, and the status bar says the save was canceled. A save whose file was already being replaced finishes and is reported as saved, and a save of several files (EPS with Use Artboards) whose first file is in place writes the rest. Continue in Background (`file.saveInBackground`) closes the window and leaves the save to the status bar (`export_progress::tests::a_background_save_shows_in_the_window_and_continue_hides_it`, `tests::background::a_canceled_save_writes_nothing_and_keeps_the_document_modified`, `fileio::tests::a_canceled_save_leaves_the_file_as_it_was`, `fileio::tests::a_save_canceled_after_its_first_file_writes_them_all`, `atomic::tests::canceled_work_puts_nothing_in_place`). Behavior reference: the help page, https://helpx.adobe.com/illustrator/using/saving-artwork.html (each background save shows its progress and can be canceled).
|
||||
- Missing linked files can be looked for in a folder and its subfolders: Find in Folder… in the Linked File Not Found dialog and in the Links panel menu lists the files with each one's name, those with the size and contents saved with the link first, and relinks the files chosen, copying an image's file into the document's folder when asked, without replacing a file there (`links.findFiles`, `links.relink {copy}`). In the Links panel it looks for the selected linked files when any are selected.
|
||||
- The Links panel's Relink… opens a Relink dialog whose Replace menu picks which links take the new file: Selected Instances (the selected images, as before), All Instances (every image linked to the same file), Missing Links from This Folder (then every other missing link whose file name is in the new file's folder) and Each Link Separately (a file for each selected link in turn). Each relinks as one undo step (`links.relink {scope}`, `ui.relinkDialog`). Relink to Folder… stays as it is.
|
||||
- The Links panel menu's Copy Info ([Links panel](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-from-other-apps/links-panel-in-illustrator.html)) copies the selected link's file name to the clipboard (`links.copyInfo`). VectorCraft's own rules: with several rows selected it copies one name per line in the order the panel shows them, an embedded image gives the name its row shows, and the item is off with no row selected.
|
||||
|
||||
+1
-1
@@ -460,7 +460,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po
|
||||
| Gradient panel: delete a stop | done | Delete Stop at the right end of the ramp deletes the selected stop, and a stop dragged down off the ramp is deleted on release, never below two stops, one undo step each; [Gradient panel options](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-gradients/gradient-tool-and-panel.html); `panels::gradient` test |
|
||||
| Gradient tool: the annotator's end handle changes the length; Alt-drag changes the length and angle together | done | A plain drag keeps the end on the bar's line, at least 10 px from the start (VectorCraft's own minimum); Alt-drag moves it freely, Shift with Alt at 45° steps; [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html); `xform::gradient` tests |
|
||||
| Workspaces (save, reset, switch); each remembers the layout changes made in it across switches and restarts until Reset <name> | done | `UiState::workspace_changes` |
|
||||
| Opening a file: after 0.4 s a progress window with the file name, a moving bar (reading counts no steps), how many more files wait, Cancel (Esc: the file doesn't open) and Continue in Background; never over another dialog or progress window | done | #5930; `opening::show`, `file.cancelOpen`, `file.openInBackground`. Save, Place and Close still show only the status bar's spinner (Place and Save run off the UI thread; Close is immediate) |
|
||||
| Opening a file: after 0.4 s a progress window with the file name, a moving bar (reading counts no steps), how many more files wait, Cancel (Esc: the file doesn't open) and Continue in Background; never over another dialog or progress window | done | #5930; `opening::show`, `file.cancelOpen`, `file.openInBackground`. A save that runs in the background shows the same window, with how many more saves wait; its Cancel (`file.cancelSave`) stops the save before it replaces the file, which stays as it was, and its Continue in Background is `file.saveInBackground` (the help page lists each background save's progress with a Cancel button: https://helpx.adobe.com/illustrator/using/saving-artwork.html). Place and Close still show only the status bar's spinner (Place runs off the UI thread; Close is immediate) |
|
||||
| Window › Help Bar shows or hides the tool-help strip apart from the status bar; kept with the preferences and in saved workspaces; Presentation Mode hides both bars | done | `window.helpBar`; `help_bar_toggle_is_independent_and_saved_in_workspaces`, `help_bar_and_status_bar_render_independently`, `legacy_help_bar_visibility_follows_each_layouts_status_bar` |
|
||||
| Status bar: a click on the info field opens a Show menu that chooses its readout: Artboard Name, Current Tool (the default), Date and Time, Number of Undos (undo and redo counts) or Document Color Profile; kept with the UI state | done | `view.statusBarShow`; [public behavior reference](https://web.archive.org/web/2014/https://helpx.adobe.com/illustrator/using/workspace-basics.html); `the_status_bar_info_field_shows_the_chosen_readout`, `a_click_on_the_info_field_opens_the_show_menu`, `the_status_bar_show_choice_is_checked_and_saved`. The menu labels are VectorCraft's own |
|
||||
| Background Export: a progress dialog with the file name, the artboard count and a bar (busy for one artboard and for formats made in one go), Cancel (Esc) and Continue in Background; it opens after 0.4 s and never over another dialog. A cancelled export writes no file | done | #2564; on the shared `vectorcraft_doc::cancel` token (#2546), so a cancelled render keeps no half-drawn pattern tile or effect raster. The bar moves between artboards, not within one. Save As, Export for Screens and Export Selection don't show it yet |
|
||||
|
||||
Reference in New Issue
Block a user