@@ -4,7 +4,7 @@ function plugindef()
44 finaleplugin .Author = " Carl Vine"
55 finaleplugin .AuthorURL = " https://carlvine.com/lua/"
66 finaleplugin .Copyright = " CC0 https://creativecommons.org/publicdomain/zero/1.0/"
7- finaleplugin .Version = " 0.06 "
7+ finaleplugin .Version = " 0.07 "
88 finaleplugin .Date = " 2024/06/04"
99 finaleplugin .MinJWLuaVersion = 0.70
1010 finaleplugin .Notes = [[
@@ -23,7 +23,7 @@ function plugindef()
2323 " Make dynamic marks in the selection louder or softer by stages"
2424end
2525
26- local hotkey = { -- customise hotkeys (upper case only)
26+ local hotkey = { -- customise hotkeys (lowercase only)
2727 direction = " z" , -- toggle Louder/Softer
2828 show_info = " q" ,
2929}
@@ -133,19 +133,17 @@ local function change_dynamics(dialog)
133133 local matches = 0 -- count successes
134134 local shift = config .levels -- how many dynamic levels to move?
135135 if config .direction == 1 then shift = - shift end -- getting softer not louder
136+ local dyn_len = library .is_font_smufl_font () and 3 or 2 -- max length of dynamic string
136137 -- match all target dynamics from existing expressions
137- local exp_defs = finale . FCTextExpressionDefs ()
138+ local exp_defs = mixin . FCMTextExpressionDefs ()
138139 exp_defs :LoadAll ()
139140 for exp_def in each (exp_defs ) do
140141 if exp_def .CategoryID == 1 and exp_def .UseCategoryFont then -- "standard" dynamic?
141142 local str = exp_def :CreateTextString ()
142143 str :TrimEnigmaTags ()
143- for i , v in ipairs (dyn_char ) do -- match all required characters
144- if not found [i ] then
145- if v == 0 then
146- found [i ] = 0 -- missing non-SMuFL char
147- matches = matches + 1
148- elseif str .LuaString == utf8.char (v ) then
144+ if str .LuaString :len () <= dyn_len then -- dynamic length
145+ for i , v in ipairs (dyn_char ) do -- match all required characters
146+ if not found [i ] and str .LuaString == utf8.char (v ) then
149147 found [i ] = exp_def .ItemNo -- matched char
150148 matches = matches + 1
151149 end
@@ -164,21 +162,23 @@ local function change_dynamics(dialog)
164162 if exp_def and exp_def .UseCategoryFont then -- "standard" dynamic?
165163 local str = exp_def :CreateTextString ()
166164 str :TrimEnigmaTags ()
167- for i , v in ipairs (dyn_char ) do -- look for matching dynamic
168- local target = math.min (math.max (1 , i + shift ), # dyn_char )
169- if str .LuaString == utf8.char (v ) then -- dynamic match
170- if found [target ] then -- replacement exists
171- e :SetID (found [target ]):Save ()
172- else -- need to create new dynamic
173- if not config .create_new then -- ask permission
174- config .create_new = create_dynamics_alert (dialog )
175- end
176- if config .create_new then -- create missing dynamic exp_def
177- found [target ] = create_exp_def (utf8.char (dyn_char [target ]))
165+ if str .LuaString :len () <= dyn_len then -- dynamic length
166+ for i , v in ipairs (dyn_char ) do -- look for matching dynamic
167+ local target = math.min (math.max (1 , i + shift ), # dyn_char )
168+ if str .LuaString == utf8.char (v ) then -- dynamic match
169+ if found [target ] then -- replacement exists
178170 e :SetID (found [target ]):Save ()
171+ else -- create new dynamic
172+ if not config .create_new then -- ask permission
173+ config .create_new = create_dynamics_alert (dialog )
174+ end
175+ if config .create_new then -- create missing dynamic exp_def
176+ found [target ] = create_exp_def (utf8.char (dyn_char [target ]))
177+ e :SetID (found [target ]):Save ()
178+ end
179179 end
180+ break
180181 end
181- break
182182 end
183183 end
184184 end
@@ -196,7 +196,7 @@ local function run_the_dialog()
196196 -- local functions
197197 local function yd (diff ) y = y + (diff or 20 ) end
198198 local function show_info ()
199- utils .show_notes_dialog (dialog , " About " .. name , 300 , 150 )
199+ utils .show_notes_dialog (dialog , " About " .. name , 300 , 200 )
200200 end
201201 local function cstat (horiz , vert , wide , str ) -- dialog static text
202202 return dialog :CreateStatic (horiz , vert ):SetWidth (wide ):SetText (str )
0 commit comments