11function plugindef ()
2- finaleplugin .RequireSelection = true
2+ finaleplugin .RequireSelection = false
33 finaleplugin .HandlesUndo = true
44 finaleplugin .Author = " Carl Vine"
55 finaleplugin .AuthorURL = " http://carlvine.com/lua/"
66 finaleplugin .Copyright = " https://creativecommons.org/licenses/by/4.0/"
7- finaleplugin .Version = " v1.64 " -- Modeless option
8- finaleplugin .Date = " 2024/04/13 "
7+ finaleplugin .Version = " v1.65 " -- with Modeless option
8+ finaleplugin .Date = " 2024/07/28 "
99 finaleplugin .MinJWLuaVersion = 0.62
1010 finaleplugin .Notes = [[
1111 When crossing notes to adjacent staves the stems of _crossed_ notes
@@ -22,6 +22,7 @@ function plugindef()
2222
2323 > - __u__: reset default __up__ values
2424 > - __d__: reset default __down__ values
25+ > - __m__: toggle __Modeless__
2526 > - __q__: display these notes
2627 > - __0 - 4__: layer number (delete key not needed)
2728 > - To change measurement units:
@@ -74,7 +75,7 @@ local function get_staff_name(staff_num)
7475 staff :Load (staff_num )
7576 local staff_name = staff :CreateDisplayAbbreviatedNameString ().LuaString
7677 if not staff_name or staff_name == " " then
77- staff_name = " Staff " .. staff_num
78+ staff_name = " Staff" .. staff_num
7879 end
7980 return staff_name
8081end
@@ -83,7 +84,7 @@ local function change_offsets()
8384 local rgn = finenv .Region ()
8485 finenv .StartNewUndoBlock (
8586 string.format (" %s %s m.%d-%d" ,
86- name , get_staff_name (rgn .StartStaff ), rgn .StartMeasure , rgn .EndMeasure
87+ name : gsub ( " " , " " ), get_staff_name (rgn .StartStaff ),rgn .StartMeasure , rgn .EndMeasure
8788 )
8889 )
8990 for entry in eachentrysaved (rgn , config .layer_num ) do
9899local function run_the_dialog ()
99100 local x_grid = { 0 , 113 , 184 }
100101 local y , y_step = 3 , 23
101- local default_value = 24
102+ local default_value = 24 -- assumed staff line spacing in EVPUs
102103 local e_width = 64
103104 local box , save_value = {}, {}
104105 local max = layer .max_layers ()
@@ -142,8 +143,9 @@ local function run_the_dialog()
142143 or (id == 3 and s :find (" [^0-" .. max .. " ]" ))
143144 then
144145 if s :find (" [?q]" ) then show_info ()
145- elseif s :find (" u" ) then set_defaults ( 1 ) -- up
146- elseif s :find (" d" ) then set_defaults (- 1 ) -- down
146+ elseif s :find (" [ud]" ) then -- toggle up/down
147+ box [id ]:SetText (save_value [id ]) -- pre-save old value
148+ set_defaults (s :find (" u" ) and 1 or - 1 )
147149 elseif s :find (" m" ) then -- toggle modeless
148150 box [modeless ]:SetCheck ((box [modeless ]:GetCheck () + 1 ) % 2 )
149151 elseif s :find (" [eicoas]" ) then -- change measurement unit
@@ -157,19 +159,18 @@ local function run_the_dialog()
157159 end
158160 end
159161 end
160- box [id ]:SetText (save_value [id ])
161- elseif s ~= " " then -- save new "clean" numnber
162- if id == 3 then
163- s = s :sub (- 1 ) -- 1-char layer number
162+ else
163+ if id == 3 then -- layer number
164+ s = s :sub (- 1 ) -- 1-char max
164165 else
165166 if s == " ." then s = " 0." -- offsets, leading zero
166167 elseif s == " -." then s = " -0."
167168 end
168169 s = s :sub (1 , 8 )
169170 end
170- box [id ]:SetText (s )
171- save_value [id ] = s
171+ save_value [id ] = (s == " " ) and " 0" or s
172172 end
173+ box [id ]:SetText (save_value [id ])
173174 end
174175 local function submission_error ()
175176 local values = { 576 , config .cross_staff_offset , config .non_cross_offset }
@@ -239,7 +240,6 @@ local function run_the_dialog()
239240 dialog :RunModeless ()
240241 else
241242 dialog :ExecuteModal () -- "modal"
242- if refocus_document then finenv .UI ():ActivateDocumentWindow () end
243243 end
244244 return change_mode or user_error
245245end
@@ -252,6 +252,7 @@ local function cross_staff_offset()
252252 change_offsets ()
253253 else
254254 while run_the_dialog () do end
255+ if refocus_document then finenv .UI ():ActivateDocumentWindow () end
255256 end
256257end
257258
0 commit comments