diff --git a/dist/deletion_chooser.lua b/dist/deletion_chooser.lua index 6d9ead0b..c75dd27d 100644 --- a/dist/deletion_chooser.lua +++ b/dist/deletion_chooser.lua @@ -5876,9 +5876,9 @@ function plugindef() finaleplugin.Author = "Carl Vine" finaleplugin.AuthorURL = "https://carlvine.com/lua" finaleplugin.Copyright = "CC0 https://creativecommons.org/publicdomain/zero/1.0/" - finaleplugin.Version = "0.95" - finaleplugin.Date = "2024/04/22" - finaleplugin.MinJWLuaVersion = 0.70 + finaleplugin.Version = "0.99c" + finaleplugin.Date = "2024/05/14" + finaleplugin.MinJWLuaVersion = 0.74 finaleplugin.Notes = [[ This script presents an alphabetical list of 24 individual types of data to delete, each line beginning with a configurable _hotkey_. @@ -5898,8 +5898,6 @@ function plugindef() To delete the same data as last time without a confirmation dialog hold down [Shift] when starting the script. - The layer number is "clamped" to a single character so to change - layer just type a new number - [Delete] key not needed. __Expression Layers__ Expressions are not fixed to particular notes but can be @@ -5916,7 +5914,7 @@ function plugindef() {\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 This script presents an alphabetical list of 24 individual types of data to delete, each line beginning with a configurable {\i hotkey}. Call the script, type the {\i hotkey} and hit [Enter] or [Return]. Half of the datatypes can be filtered by layer.\par} {\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 {\b Delete Independently}:\par} {\pard \sl264 \slmult1 \ql \f0 \sa180 \li720 \fi0 Articulations\u8226? | Articulations on Rests\u8226? | Chords | Cross Staff Entries\u8226?\line Custom Lines | Dynamics\u8226? | Expressions (Not Dynamics)\u8226?\line Expressions (All)\u8226? | Expressions (Measure-Attached) | Glissandos\line Hairpins | Lyrics\u8226? | MIDI Continuous Data | MIDI Note Data\u8226?\line Note Position Offsets\u8226? | Notehead Modifications\u8226? | Notes\u8226?\line Secondary Beam Breaks\u8226? | Slurs | Smart Shapes (Note Attached)\u8226?\line Smart Shapes (Beat Attached) | Smart Shapes (All) | Staff Styles\line Tuplets\u8226? | User Selected\u8230? | (\u8226? = filter by layer)\par} - {\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 To delete the same data as last time without a confirmation dialog hold down [Shift] when starting the script. The layer number is \u8220"clamped\u8221" to a single character so to change layer just type a new number - [Delete] key not needed.\par} + {\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 To delete the same data as last time without a confirmation dialog hold down [Shift] when starting the script.\par} {\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 {\b Expression Layers}\line Expressions are not fixed to particular notes but can be \u8220"assigned\u8221" to a specific note layer. This {\i assignment} number is used for layer filtering here, and may not always correspond to the note layer you expect.\par} } ]] @@ -5934,7 +5932,7 @@ local script_name = library.calc_script_name() local refocus_document = false local clear_selected_items_menu = finenv.UI():IsOnMac() and 1296385394 or 16010 local dialog_options = { - { "entry_articulation", "A", "Articulations •" }, + { "CreateArticulations", "A", "Articulations •" }, { "rest_articulation", "R", "Articulations on Rests •" }, { "chords", "W", "Chords" }, { "cross_staff", "X", "Cross Staff Entries •" }, @@ -5947,9 +5945,9 @@ local dialog_options = { { "shape_IsHairpin", "H", "Hairpins" }, { "entry_lyrics", "L", "Lyrics •" }, { "midi_continuous", "O", "MIDI Continuous Data" }, - { "midi_entry", "I", "MIDI Note Data •" }, + { "CreatePerformanceMods", "I", "MIDI Note Data •" }, { "entry_position", "Q", "Note Position Offsets •" }, - { "notehead_mods", "J", "Notehead Modifications •" }, + { "CreateNoteheadMods", "J", "Notehead Modifications •" }, { "notes", "N", "Notes •" }, { "secondary_beam_breaks", "K", "Secondary Beam Breaks •" }, { "shape_IsSlur", "S", "Slurs" }, @@ -5957,7 +5955,7 @@ local dialog_options = { { "shape_GetBeatAttached", "B", "Smart Shapes (Beat Attached)" }, { "shape_all", "V", "Smart Shapes (All)" }, { "staff_styles", "Y", "Staff Styles (Current Score/Part)" }, - { "entry_tuplets", "T", "Tuplets •" }, + { "CreateTuplets", "T", "Tuplets •", "TupletStartFlag" }, { "user_selected", "Z", "User Selected Items ..." }, } local config = { @@ -6101,59 +6099,44 @@ local function delete_selected(delete_type) end else - for entry in eachentrysaved(rgn, layer_num) do - if delete_type:find("artic") and entry.ArticulationFlag then - if delete_type == "entry_articulation" or (entry:IsRest() and delete_type == "rest_articulation") then - for articulation in eachbackwards(entry:CreateArticulations()) do - articulation:DeleteData() - end - entry:SetArticulationFlag(false) - end + local create_flags = { + CreateArticulations = "ArticulationFlag", + CreateTuplets = "TupletStartFlag", + CreatePerformanceMods = "PerformanceDataFlag", + } + local function delete_entry_mod(entry, type) + local mod = finale[type]() + mod:SetNoteEntry(entry) + while mod:LoadFirst() do mod:DeleteData() end + end + local function delete_create_mods(entry, type) + local mods = entry[type](entry) + for m in eachbackwards(mods) do + m:DeleteData() + end + mods:ClearAll() + if create_flags[type] then entry[create_flags[type]] = false end + end - elseif delete_type == "notehead_mods" and entry:IsNote() then - local mods = entry:CreateNoteheadMods() - if mods.Count > 0 then - for mod in eachbackwards(mods) do - mod:DeleteData() - end - end + for entry in eachentrysaved(rgn, layer_num) do - elseif delete_type == "midi_entry" and entry.PerformanceDataFlag then - local perf_mods = entry:CreatePerformanceMods() - if perf_mods.Count > 0 then - for mod in eachbackwards(perf_mods) do - mod:DeleteData() - end - end - entry.PerformanceDataFlag = false + if delete_type == "entry_position" then + entry.ManualPosition = 0 + + elseif delete_type:sub(1, 6) == "Create" then + delete_create_mods(entry, delete_type) + elseif entry:IsRest() and entry.ArticulationFlag + and delete_type == "rest_articulation" then + delete_create_mods(entry, "CreateArticulations") elseif delete_type == "entry_lyrics" and entry.LyricFlag then for _, v in ipairs{"FCChorusSyllable", "FCSectionSyllable", "FCVerseSyllable"} do - local lyric = finale[v]() - lyric:SetNoteEntry(entry) - while lyric:LoadFirst() do - lyric:DeleteData() - end + delete_entry_mod(entry, v) end - elseif delete_type == "entry_tuplets" and entry.TupletStartFlag then - local tuplets = entry:CreateTuplets() - for tuplet in eachbackwards(tuplets) do - tuplet:DeleteData() - end - tuplets:ClearAll() - entry.TupletStartFlag = false - - elseif delete_type == "entry_position" then - entry.ManualPosition = 0 - elseif delete_type == "secondary_beam_breaks" then - local sbbm = finale.FCSecondaryBeamBreakMod() - sbbm:SetNoteEntry(entry) - while sbbm:LoadFirst() do - sbbm:DeleteData() - end + delete_entry_mod(entry, "FCSecondaryBeamBreakMod") elseif delete_type == "cross_staff" then entry.ManualPosition = 0 @@ -6165,17 +6148,27 @@ local function delete_selected(delete_type) entry.ReverseDownStem = false entry.FreezeBeam = false entry.FreezeStem = false - for _, type in ipairs{"FCCrossStaffMods", "FCPrimaryBeamMods"} do - local mods = finale[type](entry) - mods:LoadAll() - for m in eachbackwards(mods) do - m:DeleteData() - end + for i = entry.Count, 1, -1 do + finale.FCCrossStaffMod():EraseAt(entry:GetItemAt(i - 1)) end + delete_entry_mod(entry, "FCCrossStaffMod") if entry.StemDetailFlag then - local stem_mod = finale.FCStemMod() - stem_mod:SetNoteEntry(entry) - stem_mod:DeleteData() + delete_entry_mod(entry, "FCStemMod") + end + + local beam = finale.FCBeamMod(false) + for _, v in ipairs{true, false} do + beam:SetNoteEntry(entry) + beam:UseUpStemData(v) + if beam:LoadFirst() then + beam:SetDefaultMode() + beam.LeftVerticalOffset = 0 + beam.RightVerticalOffset = 0 + beam.LeftHorizontalOffset = 0 + beam.RightHorizontalOffset = 0 + beam.Thickness = -1 + beam:Save() + end end end entry.CrossStaff = false @@ -6253,7 +6246,7 @@ local function user_chooses() local key_list = dialog:CreateListBox(0, 20):SetWidth(box_wide):SetHeight(box_high) local function show_info() - utils.show_notes_dialog(dialog, "About " .. name, 500, 340) + utils.show_notes_dialog(dialog, "About " .. name, 500, 325) refocus_document = true end local function fill_key_list() @@ -6288,12 +6281,10 @@ local function user_chooses() if val:find("[?q]") then show_info() elseif val:find("r") then change_keys() end - self:SetText(save_layer):SetKeyboardFocus() elseif val ~= "" then - val = val:sub(-1) - self:SetText(val) - save_layer = val + save_layer = val:sub(-1) end + self:SetText(save_layer):SetKeyboardFocus() end) dialog:CreateStatic(x_off + 60, y):SetWidth(x_off):SetText("(0 = all)") y = y + y_step + 2 diff --git a/hash/deletion_chooser.hash b/hash/deletion_chooser.hash index de26c4f4..2babf567 100644 --- a/hash/deletion_chooser.hash +++ b/hash/deletion_chooser.hash @@ -1 +1 @@ -fb27447fb88a95ee74a794ff58e6b7214921f724b54268e8c2932c72470618dbf7a1f9680f2e362d1bc9b36a04f7298e2f3953fbbc2254e278764b713c05ae80 deletion_chooser.lua +5d818b80d4db1a2a7bd06d3cbadc0edf1f05d7ed6a2849ad7a2f9a441fc452fd1caf0e81eff8822b52f103f889c08fdeb2b223cda088faf7828c98700dde832b deletion_chooser.lua