mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 05:29:53 +00:00
Merge pull request #8190 from dotCooCoo/feat/actions-replace-actions
Actions: Replace Actions puts a file's set in place of every set
This commit is contained in:
@@ -1640,6 +1640,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"",
|
||||
"{path? | data?: the file's text} read an action set file (.vcactions) at path, else a picked one, and add its set after the Actions panel's sets; a set named like one in the panel gets the next free number (Print 2), and the other sets stay. Files of another version, over 8 MiB, with more than 1,000 actions or with an action of more than 10,000 steps are refused, and so is any set, .aia ones too, that Save Actions… would write larger than 8 MiB (a file with less white space, or a name that gets a number); the panel menu's Load Actions… (disabled where there is no open dialog, the web) → {set: index, name, actions: n}. An action set another app saved as text (.aia, starting /version; read with actionSet.read) comes in with its actions. A step with a label and no recorded values comes in when exactly one menu command has that label (in English or the interface language, any case, no final …), and that command is directly in a top menu, can be recorded in actions, is what its menu bar item runs with no values and opens no dialog (never a submenu's item, a file or document command, Paste, Undo, Redo or an add-on's command), with no params and excluded from playback when it is off in the file. A Set Selection step (found by its internal name, whatever its label) comes in as select.byNote {note, caseSensitive, wholeWord} when it has exactly three recorded values: text (ustring, UTF-8; 1 to 1,024 bytes once trimmed), word and case (boolean, 0 or 1); with any other values it is left out. The other steps, every other step with no label and every other step recorded with values (a recorded menu item too) among them, are left out → {set, name, actions, skipped: [{action, step: its label, else its name}] (the first 1,000), leftOut: n}, and the status bar says how many were left out; a set with no name takes the file's name, else Actions; a file actionSet.read marks truncated is refused, and text that starts /version and isn't an action set gives \"not an action set file\"",
|
||||
),
|
||||
(
|
||||
"ui.actionSet.replace",
|
||||
"Replace Actions…",
|
||||
"",
|
||||
"{path? | data?: the file's text} read an action set file at path, else a picked one, as ui.actionSet.load reads it (.vcactions and .aia, with the same limits, errors and reports of left-out steps and unknown commands), and replace every set in the Actions panel, the built-in Default Actions set included, with the file's set, which keeps its name. The set becomes current and selected, the panel's selected action and step and its expanded actions are cleared, and an open Set Options, New Action, Batch or step dialog that names a set closes; when the panel already holds only a set that saves alike, in that state, nothing changes, the set keeps its ids and changed is false. Omitted params count as {}. Params of another type, another key, a path or data that is not a string, a file that can't be read or is refused, a canceled pick, or a replace while an action records or plays (also while it waits at a stop) is an error and changes nothing. No undo step is recorded. The panel menu's Replace Actions… (disabled where there is no open dialog, the web, and while an action records or plays) → {changed, set: 0, name, actions: n, unknownCommands?, unknownCount?, skipped?, leftOut?}",
|
||||
),
|
||||
(
|
||||
"ui.actionSet.delete",
|
||||
"Delete Action Sets",
|
||||
|
||||
@@ -2590,6 +2590,7 @@ font-technology Variable Променливи
|
||||
Play Current Selection Изпълнение на текущия избор
|
||||
Save Actions… Запазване на действия…
|
||||
Load Actions… Зареждане на действия…
|
||||
Replace Actions… Замяна на действия…
|
||||
Reset Actions Нулиране на действия
|
||||
Replace the current actions with the default set? Да се заменят ли текущите действия с набора по подразбиране?
|
||||
Append adds the default set after the current sets instead. С „Добавяне“ наборът по подразбиране се добавя след текущите набори.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1523,6 +1523,7 @@ lighting Light Svjetlo
|
||||
Play Current Selection Reprodukuj trenutni odabir
|
||||
Save Actions… Sačuvaj akcije…
|
||||
Load Actions… Učitaj akcije…
|
||||
Replace Actions… Zamijeni akcije…
|
||||
Reset Actions Vrati akcije na početno
|
||||
Replace the current actions with the default set? Zamijeniti trenutne akcije zadanim skupom?
|
||||
Append adds the default set after the current sets instead. Dugme Dodaj umjesto toga dodaje zadani skup iza trenutnih skupova.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3348,6 +3348,7 @@ digits Malayalam Malaiàlam
|
||||
Play Current Selection Reprodueix la selecció actual
|
||||
Save Actions… Desa les accions…
|
||||
Load Actions… Carrega accions…
|
||||
Replace Actions… Reemplaça les accions…
|
||||
Reset Actions Restableix les accions
|
||||
Replace the current actions with the default set? Voleu reemplaçar les accions actuals pel conjunt predeterminat?
|
||||
Append adds the default set after the current sets instead. Amb Afegeix, el conjunt predeterminat s’afegeix després dels conjunts actuals.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1549,6 +1549,7 @@ lighting Light Světlo
|
||||
Play Current Selection Přehrát aktuální výběr
|
||||
Save Actions… Uložit akce…
|
||||
Load Actions… Načíst akce…
|
||||
Replace Actions… Nahradit akce…
|
||||
Reset Actions Obnovit akce
|
||||
Replace the current actions with the default set? Nahradit aktuální akce výchozí sadou?
|
||||
Append adds the default set after the current sets instead. Tlačítko Připojit místo toho přidá výchozí sadu za aktuální sady.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4152,6 +4152,7 @@ lighting Light Lys
|
||||
Play Current Selection Afspil aktuel markering
|
||||
Save Actions… Gem handlinger…
|
||||
Load Actions… Indlæs handlinger…
|
||||
Replace Actions… Erstat handlinger…
|
||||
Reset Actions Nulstil handlinger
|
||||
Replace the current actions with the default set? Vil du erstatte de aktuelle handlinger med standardsættet?
|
||||
Append adds the default set after the current sets instead. Tilføj tilføjer i stedet standardsættet efter de aktuelle sæt.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2636,6 +2636,7 @@ diagnostics ui Oberfläche
|
||||
Play Current Selection Aktuelle Auswahl abspielen
|
||||
Save Actions… Aktionen speichern…
|
||||
Load Actions… Aktionen laden…
|
||||
Replace Actions… Aktionen ersetzen…
|
||||
Reset Actions Aktionen zurücksetzen
|
||||
Replace the current actions with the default set? Aktuelle Aktionen durch den Standardsatz ersetzen?
|
||||
Append adds the default set after the current sets instead. Mit „Anhängen“ wird der Standardsatz stattdessen nach den aktuellen Sätzen hinzugefügt.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3551,6 +3551,7 @@ theme Appearance Εμφάνιση
|
||||
Play Current Selection Αναπαραγωγή τρέχουσας επιλογής
|
||||
Save Actions… Αποθήκευση ενεργειών…
|
||||
Load Actions… Φόρτωση ενεργειών…
|
||||
Replace Actions… Αντικατάσταση ενεργειών…
|
||||
Reset Actions Επαναφορά ενεργειών
|
||||
Replace the current actions with the default set? Να αντικατασταθούν οι τρέχουσες ενέργειες με το προεπιλεγμένο σύνολο;
|
||||
Append adds the default set after the current sets instead. Η Προσάρτηση προσθέτει αντί γι’ αυτό το προεπιλεγμένο σύνολο μετά τα τρέχοντα σύνολα.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2677,6 +2677,7 @@ font-technology Variable Variables
|
||||
Play Current Selection Reproducir la selección actual
|
||||
Save Actions… Guardar acciones…
|
||||
Load Actions… Cargar acciones…
|
||||
Replace Actions… Reemplazar acciones…
|
||||
Reset Actions Restablecer acciones
|
||||
Replace the current actions with the default set? ¿Reemplazar las acciones actuales por el conjunto predeterminado?
|
||||
Append adds the default set after the current sets instead. Añadir agrega en su lugar el conjunto predeterminado después de los conjuntos actuales.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1523,6 +1523,7 @@ lighting Light Valo
|
||||
Play Current Selection Toista nykyinen valinta
|
||||
Save Actions… Tallenna toiminnot…
|
||||
Load Actions… Lataa toiminnot…
|
||||
Replace Actions… Korvaa toiminnot…
|
||||
Reset Actions Palauta toiminnot
|
||||
Replace the current actions with the default set? Korvataanko nykyiset toiminnot oletussarjalla?
|
||||
Append adds the default set after the current sets instead. Lisää-painike lisää sen sijaan oletussarjan nykyisten sarjojen perään.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2665,6 +2665,7 @@ font-technology Variable Variables
|
||||
Play Current Selection Exécuter la sélection actuelle
|
||||
Save Actions… Enregistrer les scripts…
|
||||
Load Actions… Charger des scripts…
|
||||
Replace Actions… Remplacer les scripts…
|
||||
Reset Actions Réinitialiser les scripts
|
||||
Replace the current actions with the default set? Remplacer les scripts actuels par le jeu par défaut ?
|
||||
Append adds the default set after the current sets instead. Le bouton Ajouter ajoute plutôt le jeu par défaut après les jeux actuels.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2074,6 +2074,7 @@
|
||||
Live curve fitting લાઇવ કર્વ ફિટિંગ
|
||||
Live preview લાઇવ પૂર્વાવલોકન
|
||||
Load Actions… ઍક્શન લોડ કરો…
|
||||
Replace Actions… ઍક્શન બદલો…
|
||||
Reset Actions ઍક્શન રીસેટ કરો
|
||||
Replace the current actions with the default set? વર્તમાન ઍક્શનને ડિફૉલ્ટ સેટથી બદલવા છે?
|
||||
Append adds the default set after the current sets instead. ઉમેરો તેના બદલે ડિફૉલ્ટ સેટને વર્તમાન સેટ પછી ઉમેરે છે.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -2772,6 +2772,7 @@ antiAlias Sharp शार्प
|
||||
Live Shape लाइव आकार
|
||||
Live Shape Properties लाइव शेप प्रॉपर्टीज़
|
||||
Load Actions… एक्शन्स लोड करें…
|
||||
Replace Actions… एक्शन्स रिप्लेस करें…
|
||||
Reset Actions एक्शन्स रीसेट करें
|
||||
Replace the current actions with the default set? मौजूदा एक्शन्स को डिफ़ॉल्ट सेट से बदलें?
|
||||
Append adds the default set after the current sets instead. जोड़ें इसके बजाय डिफ़ॉल्ट सेट को मौजूदा सेट के बाद जोड़ता है।
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3225,6 +3225,7 @@ diagnostics ui felület
|
||||
Play Current Selection Kijelölt művelet lejátszása
|
||||
Save Actions… Műveletek mentése…
|
||||
Load Actions… Műveletek betöltése…
|
||||
Replace Actions… Műveletek cseréje…
|
||||
Reset Actions Műveletek visszaállítása
|
||||
Replace the current actions with the default set? Lecseréled az aktuális műveleteket az alapértelmezett készletre?
|
||||
Append adds the default set after the current sets instead. A Hozzáfűzés ehelyett az aktuális készletek után adja hozzá az alapértelmezett készletet.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1450,6 +1450,7 @@ lighting Light Cahaya
|
||||
Play Current Selection Putar seleksi saat ini
|
||||
Save Actions… Simpan tindakan…
|
||||
Load Actions… Muat tindakan…
|
||||
Replace Actions… Ganti tindakan…
|
||||
Reset Actions Atur ulang tindakan
|
||||
Replace the current actions with the default set? Ganti tindakan saat ini dengan set default?
|
||||
Append adds the default set after the current sets instead. Tambahkan justru menambahkan set default setelah set saat ini.
|
||||
|
||||
|
@@ -2717,6 +2717,7 @@ diagnostics ui interfaccia
|
||||
Play Current Selection Esegui selezione corrente
|
||||
Save Actions… Salva azioni…
|
||||
Load Actions… Carica azioni…
|
||||
Replace Actions… Sostituisci azioni…
|
||||
Reset Actions Ripristina azioni
|
||||
Replace the current actions with the default set? Sostituire le azioni correnti con il set predefinito?
|
||||
Append adds the default set after the current sets instead. Aggiungi aggiunge invece il set predefinito dopo i set correnti.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2806,6 +2806,7 @@ diagnostics ui UI
|
||||
Play Current Selection 選択項目を再生
|
||||
Save Actions… アクションを保存…
|
||||
Load Actions… アクションを読み込み…
|
||||
Replace Actions… アクションを置き換え…
|
||||
Reset Actions アクションをリセット
|
||||
Replace the current actions with the default set? 現在のアクションを初期設定のセットで置き換えますか?
|
||||
Append adds the default set after the current sets instead. 「追加」を選ぶと、初期設定のセットを現在のセットの後に追加します。
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3588,6 +3588,7 @@ lighting Light სინათლე
|
||||
Play Current Selection მიმდინარე მონიშნულის შესრულება
|
||||
Save Actions… მოქმედებების შენახვა…
|
||||
Load Actions… მოქმედებების ჩატვირთვა…
|
||||
Replace Actions… მოქმედებების ჩანაცვლება…
|
||||
Reset Actions მოქმედებების ჩამოყრა
|
||||
Replace the current actions with the default set? ჩანაცვლდეს მიმდინარე მოქმედებები ნაგულისხმევი ნაკრებით?
|
||||
Append adds the default set after the current sets instead. „დამატება“ ამის ნაცვლად ნაგულისხმევ ნაკრებს მიმდინარე ნაკრებების შემდეგ ამატებს.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2796,6 +2796,7 @@ diagnostics ui UI
|
||||
Play Current Selection 현재 선택 항목 재생
|
||||
Save Actions… 액션 저장…
|
||||
Load Actions… 액션 불러오기…
|
||||
Replace Actions… 액션 바꾸기…
|
||||
Reset Actions 액션 재설정
|
||||
Replace the current actions with the default set? 현재 액션을 기본 세트로 바꾸시겠습니까?
|
||||
Append adds the default set after the current sets instead. 추가를 누르면 대신 기본 세트를 현재 세트 뒤에 추가합니다.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2023,6 +2023,7 @@ lighting Light Licht
|
||||
Play Current Selection Huidige selectie afspelen
|
||||
Save Actions… Acties opslaan…
|
||||
Load Actions… Acties laden…
|
||||
Replace Actions… Acties vervangen…
|
||||
Reset Actions Acties opnieuw instellen
|
||||
Replace the current actions with the default set? De huidige acties vervangen door de standaardset?
|
||||
Append adds the default set after the current sets instead. Toevoegen voegt in plaats daarvan de standaardset toe na de huidige sets.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1462,6 +1462,7 @@ lighting Light Światło
|
||||
Play Current Selection Odtwórz bieżące zaznaczenie
|
||||
Save Actions… Zapisz operacje…
|
||||
Load Actions… Wczytaj operacje…
|
||||
Replace Actions… Zastąp operacje…
|
||||
Reset Actions Resetuj operacje
|
||||
Replace the current actions with the default set? Zastąpić bieżące operacje zestawem domyślnym?
|
||||
Append adds the default set after the current sets instead. Dołącz dodaje zamiast tego zestaw domyślny po bieżących zestawach.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2212,6 +2212,7 @@ antiAlias Sharp Nítido
|
||||
Play Current Selection Reproduzir Seleção Atual
|
||||
Save Actions… Salvar Ações…
|
||||
Load Actions… Carregar Ações…
|
||||
Replace Actions… Substituir Ações…
|
||||
Reset Actions Redefinir Ações
|
||||
Replace the current actions with the default set? Substituir as ações atuais pelo conjunto padrão?
|
||||
Append adds the default set after the current sets instead. Anexar adiciona o conjunto padrão depois dos conjuntos atuais.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2704,6 +2704,7 @@ diagnostics ui интерфейс
|
||||
Play Current Selection Воспроизвести текущее выделение
|
||||
Save Actions… Сохранить действия…
|
||||
Load Actions… Загрузить действия…
|
||||
Replace Actions… Заменить действия…
|
||||
Reset Actions Сбросить действия
|
||||
Replace the current actions with the default set? Заменить текущие действия набором по умолчанию?
|
||||
Append adds the default set after the current sets instead. Кнопка «Добавить» вместо этого добавляет набор по умолчанию после текущих наборов.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2608,6 +2608,7 @@ font-technology Variable Variabla
|
||||
Play Current Selection Spela upp aktuell markering
|
||||
Save Actions… Spara åtgärder…
|
||||
Load Actions… Läs in åtgärder…
|
||||
Replace Actions… Ersätt åtgärder…
|
||||
Reset Actions Återställ åtgärder
|
||||
Replace the current actions with the default set? Vill du ersätta de aktuella åtgärderna med standarduppsättningen?
|
||||
Append adds the default set after the current sets instead. Lägg till lägger i stället till standarduppsättningen efter de aktuella uppsättningarna.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2449,6 +2449,7 @@ shape Open Açık
|
||||
Play Current Selection Geçerli Seçimi Oynat
|
||||
Save Actions… Eylemleri Kaydet…
|
||||
Load Actions… Eylemleri Yükle…
|
||||
Replace Actions… Eylemleri Değiştir…
|
||||
Reset Actions Eylemleri Sıfırla
|
||||
Replace the current actions with the default set? Geçerli eylemler varsayılan setle değiştirilsin mi?
|
||||
Append adds the default set after the current sets instead. Ekle bunun yerine varsayılan seti geçerli setlerin sonuna ekler.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2709,6 +2709,7 @@ diagnostics ui інтерфейс
|
||||
Play Current Selection Відтворити поточне виділення
|
||||
Save Actions… Зберегти дії…
|
||||
Load Actions… Завантажити дії…
|
||||
Replace Actions… Замінити дії…
|
||||
Reset Actions Скинути дії
|
||||
Replace the current actions with the default set? Замінити поточні дії набором за умовчанням?
|
||||
Append adds the default set after the current sets instead. Кнопка «Додати» натомість додає набір за умовчанням після поточних наборів.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3027,6 +3027,7 @@ diagnostics ui giao diện
|
||||
Play Current Selection Phát vùng chọn hiện tại
|
||||
Save Actions… Lưu hành động…
|
||||
Load Actions… Tải hành động…
|
||||
Replace Actions… Thay thế hành động…
|
||||
Reset Actions Đặt lại hành động
|
||||
Replace the current actions with the default set? Thay thế các hành động hiện tại bằng bộ mặc định?
|
||||
Append adds the default set after the current sets instead. Nối thêm sẽ thêm bộ mặc định vào sau các bộ hiện tại.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 206 and column 5.
|
@@ -2570,6 +2570,7 @@ diagnostics ui 界面
|
||||
Play Current Selection 播放当前选择项目
|
||||
Save Actions… 存储动作…
|
||||
Load Actions… 载入动作…
|
||||
Replace Actions… 替换动作…
|
||||
Reset Actions 重置动作
|
||||
Replace the current actions with the default set? 要用默认动作组替换当前动作吗?
|
||||
Append adds the default set after the current sets instead. “追加”会改为将默认动作组添加到当前动作组之后。
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3855,6 +3855,7 @@ diagnostics ui 介面
|
||||
Play Current Selection 播放目前選取項目
|
||||
Save Actions… 儲存動作…
|
||||
Load Actions… 載入動作…
|
||||
Replace Actions… 取代動作…
|
||||
Reset Actions 重設動作
|
||||
Replace the current actions with the default set? 要用預設動作組取代目前的動作嗎?
|
||||
Append adds the default set after the current sets instead. 「附加」會改為將預設動作組加到目前動作組之後。
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1006,6 +1006,7 @@ fn run_ui_part11(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result
|
||||
}
|
||||
crate::panels::actions::SAVE_SET => crate::panels::actions::save_set(app, p),
|
||||
crate::panels::actions::LOAD_SET => crate::panels::actions::load_set(app, p),
|
||||
crate::panels::actions::REPLACE_SET => crate::panels::actions::replace_set(app, p),
|
||||
crate::panels::actions::DELETE_SETS => crate::panels::actions::delete_sets(app, p),
|
||||
crate::panels::actions::DUPLICATE => crate::panels::actions::duplicate(app, p),
|
||||
crate::panels::actions::RESET => crate::panels::actions::reset(app, p),
|
||||
|
||||
@@ -1641,6 +1641,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"",
|
||||
"{path? | data?: the file's text} read an action set file (.vcactions) at path, else a picked one, and add its set after the Actions panel's sets; a set named like one in the panel gets the next free number (Print 2), and the other sets stay. Files of another version, over 8 MiB, with more than 1,000 actions or with an action of more than 10,000 steps are refused, and so is any set, .aia ones too, that Save Actions… would write larger than 8 MiB (a file with less white space, or a name that gets a number); the panel menu's Load Actions… (disabled where there is no open dialog, the web) → {set: index, name, actions: n}. An action set another app saved as text (.aia, starting /version; read with actionSet.read) comes in with its actions. A step with a label and no recorded values comes in when exactly one menu command has that label (in English or the interface language, any case, no final …), and that command is directly in a top menu, can be recorded in actions, is what its menu bar item runs with no values and opens no dialog (never a submenu's item, a file or document command, Paste, Undo, Redo or an add-on's command), with no params and excluded from playback when it is off in the file. A Set Selection step (found by its internal name, whatever its label) comes in as select.byNote {note, caseSensitive, wholeWord} when it has exactly three recorded values: text (ustring, UTF-8; 1 to 1,024 bytes once trimmed), word and case (boolean, 0 or 1); with any other values it is left out. The other steps, every other step with no label and every other step recorded with values (a recorded menu item too) among them, are left out → {set, name, actions, skipped: [{action, step: its label, else its name}] (the first 1,000), leftOut: n}, and the status bar says how many were left out; a set with no name takes the file's name, else Actions; a file actionSet.read marks truncated is refused, and text that starts /version and isn't an action set gives \"not an action set file\"",
|
||||
),
|
||||
(
|
||||
crate::panels::actions::REPLACE_SET,
|
||||
"Replace Actions…",
|
||||
"",
|
||||
"{path? | data?: the file's text} read an action set file at path, else a picked one, as ui.actionSet.load reads it (.vcactions and .aia, with the same limits, errors and reports of left-out steps and unknown commands), and replace every set in the Actions panel, the built-in Default Actions set included, with the file's set, which keeps its name. The set becomes current and selected, the panel's selected action and step and its expanded actions are cleared, and an open Set Options, New Action, Batch or step dialog that names a set closes; when the panel already holds only a set that saves alike, in that state, nothing changes, the set keeps its ids and changed is false. Omitted params count as {}. Params of another type, another key, a path or data that is not a string, a file that can't be read or is refused, a canceled pick, or a replace while an action records or plays (also while it waits at a stop) is an error and changes nothing. No undo step is recorded. The panel menu's Replace Actions… (disabled where there is no open dialog, the web, and while an action records or plays) → {changed, set: 0, name, actions: n, unknownCommands?, unknownCount?, skipped?, leftOut?}",
|
||||
),
|
||||
(
|
||||
crate::panels::actions::DELETE_SETS,
|
||||
"Delete Action Sets",
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::{VectorcraftApp, icons};
|
||||
|
||||
mod files;
|
||||
pub(crate) use files::can_load;
|
||||
pub use files::{ACTIONS_EXT, LOAD_SET, SAVE_SET, load_set, save_set};
|
||||
pub use files::{ACTIONS_EXT, LOAD_SET, REPLACE_SET, SAVE_SET, load_set, replace_set, save_set};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct Action {
|
||||
@@ -2160,8 +2160,6 @@ pub const RESET: &str = "ui.actionSet.reset";
|
||||
/// plays (also while it waits at a stop); then nothing changes. No undo step is recorded.
|
||||
/// → {changed, mode, set: the index of the first built-in set}
|
||||
pub fn reset(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
const SELECTED: &str = "actions-selected";
|
||||
const EXPANDED: &str = "actions-expanded";
|
||||
let append = match p {
|
||||
Value::Null => false,
|
||||
Value::Object(m) => {
|
||||
@@ -2192,6 +2190,18 @@ pub fn reset(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
}
|
||||
return Ok(json!({ "changed": true, "mode": "append", "set": first }));
|
||||
}
|
||||
let changed = replace_sets(app, sets);
|
||||
Ok(json!({ "changed": changed, "mode": "replace", "set": 0 }))
|
||||
}
|
||||
|
||||
/// Replaces every set in the panel with `sets`, as Reset Actions and Replace Actions… do: the first
|
||||
/// becomes current and selected, the panel's selected action and step, its expanded actions and a
|
||||
/// step being dragged are cleared, and an open Set Options, New Action, Batch or step dialog that
|
||||
/// names a set closes. When the panel already holds sets that save alike, shown that way, nothing
|
||||
/// changes and the sets keep their ids → whether anything changed.
|
||||
fn replace_sets(app: &mut VectorcraftApp, sets: Vec<ActionSet>) -> bool {
|
||||
const SELECTED: &str = "actions-selected";
|
||||
const EXPANDED: &str = "actions-expanded";
|
||||
let ctx = app.ui_ctx.clone();
|
||||
let panel_clear = ctx.as_ref().is_none_or(|ctx| {
|
||||
pstate::<Option<(usize, usize)>>(ctx, SELECTED).is_none()
|
||||
@@ -2200,10 +2210,10 @@ pub fn reset(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
&& pstate::<BTreeSet<u64>>(ctx, EXPANDED).is_empty()
|
||||
});
|
||||
// The ids are not saved, so two lists that save alike hold the same sets.
|
||||
let built_in = serde_json::to_value(&app.ui.action_sets).is_ok_and(|now| serde_json::to_value(&sets).is_ok_and(|new| new == now));
|
||||
let shown_as_reset = app.ui.action_set == Some(0) && app.ui.action_sets_selected == [0] && !app.ui.dialog.as_ref().is_some_and(holds_set);
|
||||
if built_in && shown_as_reset && panel_clear {
|
||||
return Ok(json!({ "changed": false, "mode": "replace", "set": 0 }));
|
||||
let same = serde_json::to_value(&app.ui.action_sets).is_ok_and(|now| serde_json::to_value(&sets).is_ok_and(|new| new == now));
|
||||
let shown_as_replaced = app.ui.action_set == Some(0) && app.ui.action_sets_selected == [0] && !app.ui.dialog.as_ref().is_some_and(holds_set);
|
||||
if same && shown_as_replaced && panel_clear {
|
||||
return false;
|
||||
}
|
||||
app.ui.action_sets = sets;
|
||||
app.ui.action_set = Some(0);
|
||||
@@ -2217,7 +2227,7 @@ pub fn reset(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
set_pstate::<Option<DraggedStep>>(&ctx, DRAGGED_STEP, None);
|
||||
set_pstate(&ctx, EXPANDED, BTreeSet::<u64>::new());
|
||||
}
|
||||
Ok(json!({ "changed": true, "mode": "replace", "set": 0 }))
|
||||
true
|
||||
}
|
||||
|
||||
/// The panel's (≡) menu.
|
||||
@@ -2301,12 +2311,16 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
crate::dialogs::action_playback::open(app);
|
||||
}
|
||||
ui.separator();
|
||||
// As commands, so a file dialog shown off the UI thread saves or loads when it answers.
|
||||
// As commands, so a file dialog shown off the UI thread saves, loads or replaces when it answers.
|
||||
// Save Actions… names the current set by its id, so a file dialog that answers later saves that set.
|
||||
let save = json!({ "id": current.and_then(|s| app.ui.action_sets.get(s)).map(|s| s.id) });
|
||||
for (label, id, on, params) in
|
||||
[(tl!("Save Actions…"), SAVE_SET, current.is_some(), save), (tl!("Load Actions…"), LOAD_SET, can_load(app), json!({}))]
|
||||
{
|
||||
// Replace Actions… is off while an action records or plays, as Reset Actions is.
|
||||
let idle = !recording && app.ui.action_playing.is_none();
|
||||
for (label, id, on, params) in [
|
||||
(tl!("Save Actions…"), SAVE_SET, current.is_some(), save),
|
||||
(tl!("Load Actions…"), LOAD_SET, can_load(app), json!({})),
|
||||
(tl!("Replace Actions…"), REPLACE_SET, can_load(app) && idle, json!({})),
|
||||
] {
|
||||
if widgets::menu_item(ui, label, on, false)
|
||||
&& let Err(e) = app.run(id, params)
|
||||
&& e != "cancelled"
|
||||
@@ -2315,7 +2329,7 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
}
|
||||
// Asks first: OK replaces the sets with the built-in set, Append adds it after them.
|
||||
if widgets::menu_item(ui, tl!("Reset Actions"), !recording && app.ui.action_playing.is_none(), false) {
|
||||
if widgets::menu_item(ui, tl!("Reset Actions"), idle, false) {
|
||||
crate::dialogs::confirm::ask_reset_actions(app);
|
||||
}
|
||||
}
|
||||
@@ -3987,6 +4001,172 @@ mod tests {
|
||||
assert_eq!(saved_sets(&app.ui.action_sets), before, "the playing set stays");
|
||||
}
|
||||
|
||||
/// A click on the panel menu's item `label`; an item that is off takes no click.
|
||||
fn menu_click(ctx: &egui::Context, app: &mut VectorcraftApp, label: &str) {
|
||||
use super::super::tests_appearance::{click, frame_events};
|
||||
let texts = frame_events(ctx, app, vec![], menu);
|
||||
let item = texts.iter().find(|(s, _)| s.trim() == label).map(|(_, r)| *r).unwrap_or_else(|| panic!("{label} in the menu"));
|
||||
click(ctx, app, item.center(), menu);
|
||||
}
|
||||
|
||||
/// The panel menu's Replace Actions… asks no question, reads the picked file and puts its set,
|
||||
/// with its name, in place of every set, the built-in set included. A canceled pick changes
|
||||
/// nothing and says nothing, and the item does nothing where there is no open dialog and while
|
||||
/// an action records or plays, waiting at a stop included.
|
||||
#[test]
|
||||
fn the_panel_menus_replace_actions_puts_the_files_set_in_place_of_every_set() {
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = app_with_sets();
|
||||
let before = saved_sets(&app.ui.action_sets);
|
||||
menu_click(&ctx, &mut app, "Replace Actions…");
|
||||
assert_eq!(saved_sets(&app.ui.action_sets), before, "off where there is no open dialog");
|
||||
|
||||
let files = with_files(&mut app, "/sets/Mine.vcactions");
|
||||
let mine = files::write_set(&app.ui.action_sets[1]);
|
||||
files.borrow_mut().insert("/sets/Mine.vcactions".into(), mine.clone().into_bytes());
|
||||
menu_click(&ctx, &mut app, "Replace Actions…");
|
||||
assert!(app.ui.dialog.is_none(), "no question first");
|
||||
assert_eq!(set_names(&app), ["Mine"], "the built-in set and Other go, and Mine keeps its name");
|
||||
assert_eq!(files::write_set(&app.ui.action_sets[0]), mine, "the file's actions and steps");
|
||||
assert_eq!((app.ui.action_set, app.ui.action_sets_selected.clone()), (Some(0), vec![0]), "it is current and selected");
|
||||
|
||||
app.ui.action_sets.push(ActionSet::new("Extra", vec![]));
|
||||
let before = saved_sets(&app.ui.action_sets);
|
||||
app.services.pick_open = Some(Box::new(|_: &crate::FilePick| None));
|
||||
app.ui.status.clear();
|
||||
menu_click(&ctx, &mut app, "Replace Actions…");
|
||||
assert_eq!(saved_sets(&app.ui.action_sets), before, "a canceled pick changes nothing");
|
||||
assert_eq!(app.ui.status, "", "and says nothing");
|
||||
|
||||
app.services.pick_open = Some(Box::new(|_: &crate::FilePick| Some("/sets/Mine.vcactions".to_string())));
|
||||
app.run("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
app.run(START_RECORDING, json!({})).unwrap();
|
||||
menu_click(&ctx, &mut app, "Replace Actions…");
|
||||
assert_eq!(set_names(&app), ["Mine", "Extra"], "off while an action records");
|
||||
app.run(STOP_RECORDING, json!({})).unwrap();
|
||||
|
||||
let (mut app, _) = app_with_a_stop(true);
|
||||
let files = with_files(&mut app, "/sets/Mine.vcactions");
|
||||
files.borrow_mut().insert("/sets/Mine.vcactions".into(), mine.into_bytes());
|
||||
let before = saved_sets(&app.ui.action_sets);
|
||||
play(&mut app, 0, 0).unwrap();
|
||||
assert!(waiting_at_stop(&app));
|
||||
app.ui.dialog = None;
|
||||
menu_click(&ctx, &mut app, "Replace Actions…");
|
||||
assert_eq!(saved_sets(&app.ui.action_sets), before, "off while playback waits at a stop");
|
||||
}
|
||||
|
||||
/// `ui.actionSet.replace` makes the file's set current and selected, clears the panel's selected
|
||||
/// action and step, expanded actions and a dragged step, closes a dialog that holds a set index
|
||||
/// and records no undo step. The same file again changes nothing and keeps the ids. A set with
|
||||
/// no actions replaces the sets too, an `.aia` file reports its left-out steps, and a file with
|
||||
/// an unknown command reports it, as Load Actions… does; a set with no name takes the file's.
|
||||
#[test]
|
||||
fn replace_actions_clears_what_named_the_old_sets_and_reads_aia_files() {
|
||||
let mut app = app_with_sets();
|
||||
app.run("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap();
|
||||
let undo = undo_steps(&app);
|
||||
app.ui.action_set = Some(2);
|
||||
app.ui.action_sets_selected = vec![1, 2];
|
||||
let ctx = egui::Context::default();
|
||||
app.ui_ctx = Some(ctx.clone());
|
||||
let nudge = app.ui.action_sets[1].actions[1].id;
|
||||
set_pstate::<Option<(usize, usize)>>(&ctx, "actions-selected", Some((1, 1)));
|
||||
set_pstate::<Option<(u64, usize)>>(&ctx, SELECTED_STEP, Some((nudge, 0)));
|
||||
set_pstate(&ctx, "actions-expanded", BTreeSet::from([nudge]));
|
||||
let dragged: DraggedStep = (nudge, 0, std::sync::Arc::new((vec![], BTreeSet::new())));
|
||||
set_pstate::<Option<DraggedStep>>(&ctx, DRAGGED_STEP, Some(dragged));
|
||||
crate::dialogs::action_batch::open(&mut app, 1, 1).unwrap();
|
||||
|
||||
let text = files::write_set(&app.ui.action_sets[1]);
|
||||
let r = app.run(REPLACE_SET, json!({ "data": text })).unwrap();
|
||||
assert_eq!(r, json!({"changed": true, "set": 0, "name": "Mine", "actions": 2}));
|
||||
assert_eq!(set_names(&app), ["Mine"]);
|
||||
assert_eq!((app.ui.action_set, app.ui.action_sets_selected.clone()), (Some(0), vec![0]));
|
||||
assert_eq!(pstate::<Option<(usize, usize)>>(&ctx, "actions-selected"), None);
|
||||
assert_eq!(pstate::<Option<(u64, usize)>>(&ctx, SELECTED_STEP), None);
|
||||
assert!(pstate::<BTreeSet<u64>>(&ctx, "actions-expanded").is_empty());
|
||||
assert!(pstate::<Option<DraggedStep>>(&ctx, DRAGGED_STEP).is_none());
|
||||
assert!(app.ui.dialog.is_none(), "the Batch dialog of a replaced set closes");
|
||||
assert_eq!(undo_steps(&app), undo, "no undo step");
|
||||
|
||||
let ids = (app.ui.action_sets[0].id, app.ui.action_sets[0].actions.iter().map(|a| a.id).collect::<Vec<_>>());
|
||||
assert_eq!(app.run(REPLACE_SET, json!({ "data": text })).unwrap()["changed"], false, "the same set, shown that way");
|
||||
assert_eq!((app.ui.action_sets[0].id, app.ui.action_sets[0].actions.iter().map(|a| a.id).collect()), ids, "the ids stay");
|
||||
|
||||
let empty = json!({"format": "vcactions", "version": 1, "name": "Empty", "actions": []}).to_string();
|
||||
assert_eq!(app.run(REPLACE_SET, json!({ "data": empty })).unwrap(), json!({"changed": true, "set": 0, "name": "Empty", "actions": 0}));
|
||||
assert_eq!(set_names(&app), ["Empty"]);
|
||||
|
||||
let aia = aia_text("Tidy Up", &[("Group Them", &[("group", true), ("Move", true)])]);
|
||||
let r = app.run(REPLACE_SET, json!({ "data": aia })).unwrap();
|
||||
let skipped = json!([{"action": "Group Them", "step": "Move"}]);
|
||||
assert_eq!(r, json!({"changed": true, "set": 0, "name": "Tidy Up", "actions": 1, "skipped": skipped, "leftOut": 1}));
|
||||
assert_eq!(set_names(&app), ["Tidy Up"]);
|
||||
assert_eq!(app.ui.action_sets[0].actions[0].steps, [("object.group".to_string(), json!({}))]);
|
||||
assert_eq!(app.ui.status, "Loaded “Tidy Up”: 1 step was left out");
|
||||
|
||||
let files = with_files(&mut app, "/sets/unused.vcactions");
|
||||
let odd = json!({"format": "vcactions", "version": 1, "name": "", "actions": [{"name": "A", "steps": [{"command": "example.unknown"}]}]});
|
||||
files.borrow_mut().insert("/sets/Print Jobs.vcactions".into(), odd.to_string().into_bytes());
|
||||
let r = app.run(REPLACE_SET, json!({"path": "/sets/Print Jobs.vcactions"})).unwrap();
|
||||
assert_eq!((r["name"].clone(), r["unknownCount"].clone(), r["changed"].clone()), (json!("Print Jobs"), json!(1), json!(true)));
|
||||
assert_eq!(set_names(&app), ["Print Jobs"]);
|
||||
}
|
||||
|
||||
/// `ui.actionSet.replace` refuses params that are not an object, another key, a `path` or `data`
|
||||
/// that is not text, a file that can't be read or that Load Actions… refuses (an empty one too),
|
||||
/// a canceled pick, and a replace while an action records or plays, waiting at a stop included,
|
||||
/// and then changes no set and keeps the current set.
|
||||
#[test]
|
||||
fn replace_actions_refuses_bad_params_bad_files_and_a_running_action() {
|
||||
let mut app = app_with_sets();
|
||||
let files = with_files(&mut app, "/sets/missing.vcactions");
|
||||
files.borrow_mut().insert("/sets/empty.vcactions".into(), vec![]);
|
||||
app.ui.action_set = Some(1);
|
||||
let before = saved_sets(&app.ui.action_sets);
|
||||
let many = json!({"format": "vcactions", "version": 1, "name": "Many", "actions": vec![json!({"name": "A", "steps": []}); 1001]});
|
||||
let eof = "not an action set file (EOF while parsing a value at line 1 column 0)";
|
||||
for (p, error) in [
|
||||
(json!(1), "the params must be an object, not 1"),
|
||||
(json!([]), "the params must be an object, not []"),
|
||||
(json!({"set": 0}), "unknown parameter `set`; the command takes: path, data"),
|
||||
(json!({"path": 5}), "`path` must be a string"),
|
||||
(json!({"path": null}), "`path` must be a string"),
|
||||
(json!({"data": 42}), "`data` must be a string"),
|
||||
(json!({"data": ""}), eof),
|
||||
(json!({"data": "GIMP Palette"}), "not an action set file (expected value at line 1 column 1)"),
|
||||
(json!({"data": many.to_string()}), "the action set file holds more than 1,000 actions"),
|
||||
(json!({"data": " ".repeat(files::MAX_SET_FILE + 1)}), "the action set file is larger than 8 MiB"),
|
||||
(json!({"data": "/version\n"}), "not an action set file"),
|
||||
(json!({"path": "/sets/empty.vcactions"}), eof),
|
||||
(json!({"path": "/sets/nowhere.vcactions"}), "no such file"),
|
||||
(json!({}), "no such file"),
|
||||
] {
|
||||
assert_eq!(app.run(REPLACE_SET, p.clone()).unwrap_err(), error, "{p}");
|
||||
assert_eq!(saved_sets(&app.ui.action_sets), before, "{p} changes nothing");
|
||||
assert_eq!(app.ui.action_set, Some(1));
|
||||
}
|
||||
app.services.pick_open = Some(Box::new(|_: &crate::FilePick| None));
|
||||
assert_eq!(app.run(REPLACE_SET, Value::Null).unwrap_err(), "cancelled");
|
||||
assert_eq!(saved_sets(&app.ui.action_sets), before, "a canceled pick changes nothing");
|
||||
|
||||
let text = files::write_set(&app.ui.action_sets[1]);
|
||||
app.run("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
app.run(START_RECORDING, json!({})).unwrap();
|
||||
assert_eq!(app.run(REPLACE_SET, json!({ "data": text })).unwrap_err(), "an action is already recording");
|
||||
assert_eq!(saved_sets(&app.ui.action_sets), before, "a recording keeps its set");
|
||||
app.run(STOP_RECORDING, json!({})).unwrap();
|
||||
|
||||
let (mut app, _) = app_with_a_stop(true);
|
||||
let before = saved_sets(&app.ui.action_sets);
|
||||
play(&mut app, 0, 0).unwrap();
|
||||
assert!(waiting_at_stop(&app));
|
||||
assert_eq!(app.run(REPLACE_SET, json!({ "data": text })).unwrap_err(), "an action is already playing");
|
||||
assert_eq!(saved_sets(&app.ui.action_sets), before, "the playing set stays");
|
||||
}
|
||||
|
||||
/// A recording keeps its steps when a canceled undo group drops journal entries made before the
|
||||
/// recording began.
|
||||
#[test]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Action set files: the Actions panel menu's Save Actions… and Load Actions….
|
||||
//! Action set files: the Actions panel menu's Save Actions…, Load Actions… and Replace Actions….
|
||||
//!
|
||||
//! An action set file (`.vcactions`) is JSON: `{"format": "vcactions", "version": 1 to 6, "name",
|
||||
//! "actions": [{"name", "steps": [{"command", "params", "excluded"?}], "key"?, "color"?}]}`. Each step is a
|
||||
@@ -29,6 +29,9 @@ pub const SAVE_SET: &str = "ui.actionSet.save";
|
||||
/// The command that loads an action set from a file ([`load_set`]).
|
||||
pub const LOAD_SET: &str = "ui.actionSet.load";
|
||||
|
||||
/// The command that replaces every action set with the one from a file ([`replace_set`]).
|
||||
pub const REPLACE_SET: &str = "ui.actionSet.replace";
|
||||
|
||||
/// The extension of an action set file ([`write_set`]).
|
||||
pub const ACTIONS_EXT: &str = "vcactions";
|
||||
|
||||
@@ -496,33 +499,101 @@ fn aia_set(read: &Value, name: &str) -> AiaLoad {
|
||||
AiaLoad { set: ActionSet::new(if set.trim().is_empty() { name.to_string() } else { set }, actions), skipped, left_out }
|
||||
}
|
||||
|
||||
/// [`load_set`] of an action set another app saved as text, which `actionSet.read` reads with
|
||||
/// `params`.
|
||||
fn load_aia(app: &mut VectorcraftApp, params: Value) -> Result<Value, String> {
|
||||
/// The steps left out of an action set another app saved as text: the first [`MAX_SKIPPED`] as
|
||||
/// `[{action, step}]`, and how many there are. None for an action set file.
|
||||
type LeftOut = Option<(Vec<Value>, usize)>;
|
||||
|
||||
/// The set of an action set another app saved as text, which `actionSet.read` reads with `params`,
|
||||
/// with its left-out steps.
|
||||
fn read_aia(app: &mut VectorcraftApp, params: Value) -> Result<(ActionSet, LeftOut), String> {
|
||||
// Text that starts `/version` and no number is not an action set either.
|
||||
let read = app.run("actionSet.read", params).map_err(|_| "not an action set file")?;
|
||||
// A set read only in part would play actions that differ from the file's.
|
||||
if read.get("truncated").and_then(Value::as_bool).unwrap_or(false) {
|
||||
return Err("the action set file can't be read in full".into());
|
||||
}
|
||||
let AiaLoad { mut set, skipped, left_out } = aia_set(&read, "Actions");
|
||||
set.name = free_set_name(&app.ui.action_sets, &set.name);
|
||||
// The set must save as a file that Load Actions… reads, which can be larger than the file read.
|
||||
super::edit_keeps_set_loadable(app, None, &set)?;
|
||||
let AiaLoad { set, skipped, left_out } = aia_set(&read, "Actions");
|
||||
Ok((set, Some((skipped, left_out))))
|
||||
}
|
||||
|
||||
/// The set of the action set file at `p`'s `path` (else a picked one), or of the file's text
|
||||
/// `data`, as [`load_set`] reads it. The second value is the left-out steps of an action set
|
||||
/// another app saved as text (`.aia`), and None for an action set file. Nothing in `app` changes
|
||||
/// but its status, and an error leaves the sets as they are.
|
||||
fn read_file(app: &mut VectorcraftApp, p: &Value) -> Result<(ActionSet, LeftOut), String> {
|
||||
let (text, stem) = match p.get("data") {
|
||||
Some(Value::String(data)) => {
|
||||
// Checked before the copy: `read_set` checks it again.
|
||||
if data.len() > MAX_SET_FILE {
|
||||
return Err("the action set file is larger than 8 MiB".into());
|
||||
}
|
||||
if is_aia(data.as_bytes()) {
|
||||
return read_aia(app, json!({ "data": data }));
|
||||
}
|
||||
(data.clone(), String::new())
|
||||
}
|
||||
Some(_) => return Err("not an action set file".into()),
|
||||
None => {
|
||||
let path = match p.get("path").and_then(Value::as_str) {
|
||||
Some(path) => path.to_string(),
|
||||
None => {
|
||||
let exts = [&[ACTIONS_EXT], vectorcraft_engine::cmd::actionset::EXTS].concat();
|
||||
let pick = crate::FilePick { filters: vec![crate::FilePick::filter("Action sets", &exts)], ..Default::default() };
|
||||
crate::picks::open(app, &pick).ok_or("cancelled")?
|
||||
}
|
||||
};
|
||||
// One byte past the limit tells a larger file apart without reading all of it.
|
||||
let bytes = match (&app.services.read_head, &app.services.read) {
|
||||
(Some(read_head), _) => read_head(&path, MAX_SET_FILE + 1)?,
|
||||
(None, Some(read)) => read(&path)?,
|
||||
(None, None) => return Err("no file reader".into()),
|
||||
};
|
||||
if bytes.len() > MAX_SET_FILE {
|
||||
return Err("the action set file is larger than 8 MiB".into());
|
||||
}
|
||||
if is_aia(&bytes) {
|
||||
return read_aia(app, json!({ "name": path, "dataBase64": vectorcraft_format::base64_encode(&bytes) }));
|
||||
}
|
||||
let stem = std::path::Path::new(&path).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
(String::from_utf8(bytes).map_err(|_| "not an action set file")?, stem)
|
||||
}
|
||||
};
|
||||
Ok((read_set(&text, if stem.is_empty() { "Actions" } else { &stem })?, None))
|
||||
}
|
||||
|
||||
/// The answer of [`load_set`] and [`replace_set`] for `set`, which goes at index `at`, with its
|
||||
/// left-out steps `aia` ([`read_file`]); the status bar names what was left out or kept.
|
||||
fn loaded(app: &mut VectorcraftApp, set: &ActionSet, at: usize, aia: LeftOut) -> Value {
|
||||
let (name, actions) = (set.name.clone(), set.actions.len());
|
||||
app.ui.action_sets.push(set);
|
||||
if left_out > 0 {
|
||||
app.status(crate::i18n::msg_n(
|
||||
left_out as u64,
|
||||
"Loaded “{name}”: {n} step was left out",
|
||||
"Loaded “{name}”: {n} steps were left out",
|
||||
&[("name", &name)],
|
||||
));
|
||||
if let Some((skipped, left_out)) = aia {
|
||||
if left_out > 0 {
|
||||
app.status(crate::i18n::msg_n(
|
||||
left_out as u64,
|
||||
"Loaded “{name}”: {n} step was left out",
|
||||
"Loaded “{name}”: {n} steps were left out",
|
||||
&[("name", &name)],
|
||||
));
|
||||
}
|
||||
return json!({ "set": at, "name": name, "actions": actions, "skipped": skipped, "leftOut": left_out });
|
||||
}
|
||||
Ok(json!({
|
||||
"set": app.ui.action_sets.len() - 1, "name": name, "actions": actions,
|
||||
"skipped": skipped, "leftOut": left_out,
|
||||
}))
|
||||
let (unknown, unknown_count, first) = unknown_commands(set);
|
||||
let mut answer = json!({ "set": at, "name": name, "actions": actions });
|
||||
if let Some((action, step, command)) = first {
|
||||
app.status(crate::i18n::msg_n(
|
||||
unknown_count as u64,
|
||||
"Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`",
|
||||
"Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}`",
|
||||
&[
|
||||
("name", &super::shown_text(&name)),
|
||||
("action", &super::shown_text(&action)),
|
||||
("step", &step),
|
||||
("command", &super::shown_text(&command)),
|
||||
],
|
||||
));
|
||||
answer["unknownCommands"] = json!(unknown);
|
||||
answer["unknownCount"] = json!(unknown_count);
|
||||
}
|
||||
answer
|
||||
}
|
||||
|
||||
/// `ui.actionSet.load {path? | data?}`: reads the action set file at `path` (else a picked one), or
|
||||
@@ -548,66 +619,50 @@ fn load_aia(app: &mut VectorcraftApp, params: Value) -> Result<Value, String> {
|
||||
/// Such a file that `actionSet.read` marks `truncated` is refused, and so is one whose set Save
|
||||
/// Actions… would write larger than 8 MiB; then no set is added.
|
||||
pub fn load_set(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
let (text, stem) = match p.get("data") {
|
||||
Some(Value::String(data)) => {
|
||||
// Checked before the copy: `read_set` checks it again.
|
||||
if data.len() > MAX_SET_FILE {
|
||||
return Err("the action set file is larger than 8 MiB".into());
|
||||
}
|
||||
if is_aia(data.as_bytes()) {
|
||||
return load_aia(app, json!({ "data": data }));
|
||||
}
|
||||
(data.clone(), String::new())
|
||||
}
|
||||
Some(_) => return Err("not an action set file".into()),
|
||||
None => {
|
||||
let path = match p.get("path").and_then(Value::as_str) {
|
||||
Some(path) => path.to_string(),
|
||||
None => {
|
||||
let exts = [&[ACTIONS_EXT], vectorcraft_engine::cmd::actionset::EXTS].concat();
|
||||
let pick = crate::FilePick { filters: vec![crate::FilePick::filter("Action sets", &exts)], ..Default::default() };
|
||||
crate::picks::open(app, &pick).ok_or("cancelled")?
|
||||
}
|
||||
};
|
||||
// One byte past the limit tells a larger file apart without reading all of it.
|
||||
let bytes = match (&app.services.read_head, &app.services.read) {
|
||||
(Some(read_head), _) => read_head(&path, MAX_SET_FILE + 1)?,
|
||||
(None, Some(read)) => read(&path)?,
|
||||
(None, None) => return Err("no file reader".into()),
|
||||
};
|
||||
if bytes.len() > MAX_SET_FILE {
|
||||
return Err("the action set file is larger than 8 MiB".into());
|
||||
}
|
||||
if is_aia(&bytes) {
|
||||
return load_aia(app, json!({ "name": path, "dataBase64": vectorcraft_format::base64_encode(&bytes) }));
|
||||
}
|
||||
let stem = std::path::Path::new(&path).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
(String::from_utf8(bytes).map_err(|_| "not an action set file")?, stem)
|
||||
}
|
||||
};
|
||||
let mut set = read_set(&text, if stem.is_empty() { "Actions" } else { &stem })?;
|
||||
let (mut set, aia) = read_file(app, p)?;
|
||||
set.name = free_set_name(&app.ui.action_sets, &set.name);
|
||||
// A number added to the name can make a file at the limit larger than it.
|
||||
// A number added to the name can make a file at the limit larger than it, and the set of an
|
||||
// `.aia` file can save larger than the file read.
|
||||
super::edit_keeps_set_loadable(app, None, &set)?;
|
||||
let (unknown, unknown_count, first) = unknown_commands(&set);
|
||||
let (name, actions) = (set.name.clone(), set.actions.len());
|
||||
let answer = loaded(app, &set, app.ui.action_sets.len(), aia);
|
||||
app.ui.action_sets.push(set);
|
||||
let mut answer = json!({ "set": app.ui.action_sets.len() - 1, "name": name, "actions": actions });
|
||||
if let Some((action, step, command)) = first {
|
||||
app.status(crate::i18n::msg_n(
|
||||
unknown_count as u64,
|
||||
"Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`",
|
||||
"Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}`",
|
||||
&[
|
||||
("name", &super::shown_text(&name)),
|
||||
("action", &super::shown_text(&action)),
|
||||
("step", &step),
|
||||
("command", &super::shown_text(&command)),
|
||||
],
|
||||
));
|
||||
answer["unknownCommands"] = json!(unknown);
|
||||
answer["unknownCount"] = json!(unknown_count);
|
||||
Ok(answer)
|
||||
}
|
||||
|
||||
/// `ui.actionSet.replace {path? | data?}`: Replace Actions…. Reads an action set file as
|
||||
/// [`load_set`] does, from `path`, a picked file or the file's text `data`, with the same formats,
|
||||
/// limits and errors, and replaces every set in the panel with the file's set, which keeps its
|
||||
/// name. The set becomes current and selected, and the panel clears what named the old sets as
|
||||
/// [`super::reset`] does. When the panel already holds only a set that saves alike, shown that
|
||||
/// way, nothing changes and the set keeps its ids. Omitted params (`null`) count as `{}`. Params
|
||||
/// of another type, another key or a `path` or `data` that is not a string is an error, and so is a replace
|
||||
/// while an action records or plays (also while it waits at a stop). On any error, a canceled
|
||||
/// pick included, nothing changes. No undo step is recorded → `{changed, set: 0, name, actions}`,
|
||||
/// with what [`load_set`] reports of left-out steps and unknown commands.
|
||||
pub fn replace_set(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
match p {
|
||||
Value::Null => {}
|
||||
Value::Object(m) => {
|
||||
if let Some(key) = m.keys().find(|k| !matches!(k.as_str(), "path" | "data")) {
|
||||
let keys = "path, data";
|
||||
return Err(format!("unknown parameter `{key}`; the command takes: {keys}"));
|
||||
}
|
||||
if let Some(key) = ["path", "data"].into_iter().find(|k| m.get(*k).is_some_and(|v| !v.is_string())) {
|
||||
return Err(format!("`{key}` must be a string"));
|
||||
}
|
||||
}
|
||||
got => return Err(format!("the params must be an object, not {got}")),
|
||||
}
|
||||
if app.ui.recording.is_some() {
|
||||
return Err("an action is already recording".into());
|
||||
}
|
||||
if app.ui.action_playing.is_some() {
|
||||
return Err("an action is already playing".into());
|
||||
}
|
||||
let (set, aia) = read_file(app, p)?;
|
||||
super::edit_keeps_set_loadable(app, None, &set)?;
|
||||
let mut answer = loaded(app, &set, 0, aia);
|
||||
answer["changed"] = json!(super::replace_sets(app, vec![set]));
|
||||
Ok(answer)
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ const DOCUMENT_FREE: &[&str] = &[
|
||||
"ui.shortcutImportDialog",
|
||||
crate::panels::actions::SAVE_SET,
|
||||
crate::panels::actions::LOAD_SET,
|
||||
crate::panels::actions::REPLACE_SET,
|
||||
];
|
||||
|
||||
impl Entry {
|
||||
|
||||
+13
@@ -3843,6 +3843,19 @@ already walks Image Trace. Short agent entry points:
|
||||
than 8 MiB`. The Actions panel menu's Save Actions… and Load Actions… run these; Load Actions… is
|
||||
disabled where there is no open dialog (the web). `ui.actionSet.load` also reads the action sets other apps save as
|
||||
text (`.aia`); see "Action sets from other apps".
|
||||
`ui.actionSet.replace {path? | data?}` is the Actions panel menu's Replace Actions…. It reads the file at `path`, else
|
||||
a picked one, or the file's text `data`, as `ui.actionSet.load` does, with the same formats (`.vcactions` and `.aia`),
|
||||
limits, errors and reports of left-out steps and unknown commands, and replaces every set in the panel, the built-in
|
||||
Default Actions set included, with the file's set, which keeps its name. It returns `{changed, set: 0, name,
|
||||
actions}` with `unknownCommands` and `unknownCount`, or `skipped` and `leftOut`, as a load does. The set becomes
|
||||
current and selected, the panel's selected action and step and its expanded actions are cleared, and an open Set
|
||||
Options, New Action, Batch or step dialog that names a set closes; when the panel already holds only a set that saves
|
||||
alike, in that state, nothing changes, the set keeps its ids and `changed` is false. Omitted params count as `{}`.
|
||||
Params of another type, another key, a `path` or `data` that is not a string, a file that can't be read or is
|
||||
refused (an empty one too), a canceled pick (`cancelled`), or a replace while an action records or plays (also while
|
||||
it waits at a stop) is an error and changes nothing. Replace records no undo step. The menu item asks no question
|
||||
first, and it is disabled where there is no open dialog (the web) and while an action records or plays. These are
|
||||
VectorCraft's own rules.
|
||||
- Actions: `ui.action.rename {set, action, name}` renames the Actions panel's action at `action` in set `set` (0 is
|
||||
the top set) to `name` with spaces trimmed from both ends, keeps its steps, function key and color, and returns
|
||||
`{name}`. An index past the last set or action, or an empty name, is an error, and then nothing is renamed. So is a
|
||||
|
||||
@@ -881,6 +881,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- Actions panel: Delete Selection deletes the selected action set with its actions and keeps the other sets ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html); `ui.actionSet.delete`). VectorCraft's own rules, which the overview does not cover: deleting a set asks first, Shift-click on a set's name selects a range of sets to delete together, the panel menu's Delete does the same, and Default Actions and the last set can be deleted. Undo does not bring a deleted set back.
|
||||
- Actions panel: the panel menu's Duplicate copies the selected action, else the current action set with all its actions ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html); `ui.actionSet.duplicate`). VectorCraft's own rules, which the overview does not cover: the copy goes right after the original, is named after it with " copy" added and is selected.
|
||||
- Actions panel: the panel menu's Reset Actions asks first; OK replaces the sets in the panel with the default set, and Append adds the default set after them ([the help page](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/manage-a-set-of-actions.html); `ui.actionSet.reset`). VectorCraft's own rules, which the page does not cover: the default set is VectorCraft's own Default Actions set; after OK it is current and selected, and no action or step is selected; Append names its copy with the next free number (`Default Actions 2`) and keeps the current set; Cancel changes nothing; the item is off while an action records or plays, waiting at a stop included; Undo does not bring the old sets back. Tests `panels::actions::tests::{the_panel_menus_reset_actions_asks_first_and_is_off_while_an_action_runs, reset_replaces_every_set_with_the_built_in_set_and_clears_what_named_the_old_ones, reset_on_the_built_in_set_makes_it_current_then_changes_nothing, reset_append_adds_the_built_in_set_with_a_free_number_and_keeps_the_rest, reset_refuses_bad_params_and_a_running_action_and_changes_nothing}`, `dialogs::tests::reset_actions_ok_replaces_append_adds_and_cancel_keeps_the_sets`.
|
||||
- Actions panel: the panel menu's Replace Actions… opens a file and puts the set it holds in place of every set in the panel ([the help page](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html); `ui.actionSet.replace`). VectorCraft's own rules, which the page does not cover: the file is read as Load Actions… reads it (`.vcactions` and `.aia`, with the same limits and reports); the built-in Default Actions set goes too; the file's set keeps its name and becomes current and selected, and no action or step is selected; a canceled pick, a file that can't be read or is refused (an empty one too) changes nothing; the item asks no question first and is off while an action records or plays, waiting at a stop included; Undo does not bring the old sets back. Tests `panels::actions::tests::{the_panel_menus_replace_actions_puts_the_files_set_in_place_of_every_set, replace_actions_clears_what_named_the_old_sets_and_reads_aia_files, replace_actions_refuses_bad_params_bad_files_and_a_running_action}`.
|
||||
- Batch… over data sets names each file after the document and the data set (`action.batch`). It writes `/`, `\`, `:`, `<`, `>`, `"`, `|`, `?`, `*` and control characters in the data set's name as `-`, and adds `-2`, `-3`… to a name an earlier data set used.
|
||||
- Batch… offers File + Number, File + Data Set Name, and Data Set Name for a Data Sets source. The dialog defaults to File + Number; `action.batch` without `datasetFileNaming` keeps File + Data Set Name. An output already in a destination folder the batch may read and write gets the next free `-2`, `-3` suffix. [Batch options](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/batch-options.html).
|
||||
- The Batch dialog shows its data set File Name row only when Destination is Folder, and keeps the choice while another destination is picked. With None or Save and Close it does not send `datasetFileNaming`.
|
||||
|
||||
+2
-1
@@ -428,7 +428,8 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po
|
||||
| Live trace result bounds and selection highlights exclude the retained bitmap; source-image views retain it | done | All TraceView modes and rotated result bounds regression-covered; ordinary hidden group behavior retained |
|
||||
| Image Trace panel: the Preview checkbox before Trace chooses whether a setting change traces the selected Image Trace object again at once | done | Per the public documentation, Preview shows the result of the current settings and Trace traces with them (<https://web.archive.org/web/20250831090623/https://helpx.adobe.com/illustrator/using/image-trace.html>). Preview is on by default and kept with the UI preferences; Reset to Default leaves it. Off, changes wait in the panel until Trace applies them as one undo step, or until Preview is turned on again. Changes stay with the object they were made for while another object is selected, and come back when it is selected again. `imageTrace.preview {on?}`, `ui.set {imageTracePreview}`; `panels/image_trace.rs` headless tests (`with_preview_off_a_slider_change_waits_for_trace`, `turning_preview_on_traces_the_changes_that_waited`, `preview_turned_on_with_nothing_selected_traces_when_the_object_is_selected_again`, `settings_that_wait_stay_with_their_object`, `settings_that_wait_come_back_when_their_object_is_selected_again`, `settings_that_wait_are_dropped_when_their_object_changed_since`, `preview_is_kept_with_the_preferences_and_reset_to_default_leaves_it`) |
|
||||
| Toolbar without group labels by default, one or two columns; All Tools drawer by flyout group with shortcuts, its menu (Reset, Basic, Advanced) and Show section | done | #1751; a preference brings the labels back; `toolbar.show` sets the Fill/Stroke, Coloring, Draw Mode and Screen Mode controls |
|
||||
| Actions panel: ≡ › Save Actions… saves the current set with all its actions to a file and ≡ › Load Actions… adds a saved set ([Manage a set of actions](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/manage-a-set-of-actions.html)) | partial | `ui.actionSet.save`, `ui.actionSet.load`; `panels/actions.rs` tests. The file is VectorCraft's own `.vcactions` JSON; Clear and Replace Actions remain |
|
||||
| Actions panel: ≡ › Save Actions… saves the current set with all its actions to a file and ≡ › Load Actions… adds a saved set ([Manage a set of actions](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/manage-a-set-of-actions.html)) | partial | `ui.actionSet.save`, `ui.actionSet.load`; `panels/actions.rs` tests. The file is VectorCraft's own `.vcactions` JSON; Clear Actions remains |
|
||||
| Actions panel: ≡ › Replace Actions… puts the set of a saved file in place of every set in the panel ([the help page](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html)) | done | `ui.actionSet.replace`; `panels/actions.rs` tests. The file is read as Load Actions… reads it; the item asks no question first |
|
||||
| Actions panel: ≡ › Reset Actions asks first; OK replaces the sets in the panel with the default set and Append adds the default set after them ([the help page](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/manage-a-set-of-actions.html)) | done | `ui.actionSet.reset`; `panels/actions.rs` and `dialogs/tests.rs` tests. The default set is VectorCraft's own Default Actions set |
|
||||
| Actions panel: ≡ › Load Actions… also reads action sets saved as `.aia` files ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html)) | partial | `actionSet.read`, `ui.actionSet.load`; `tests/actionset.rs`, `panels/actions.rs` tests, `import_fuzz`. Steps with a label and no recorded values come in as menu commands that run with no values and open no dialog, matched by label, and Set Selection steps come in as Select Object steps; the other steps, recorded menu items included, are left out and counted |
|
||||
| Actions panel: ≡ › Action Options… renames the selected action and sets its function key and color ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html)) | partial | `ui.action.options`; `panels/actions.rs` tests (part of #1629). Button Mode shows the color |
|
||||
|
||||
Reference in New Issue
Block a user