Skip to content

Commit a713471

Browse files
chore: autopublish 2024-08-12T12:54:38Z
1 parent 176f6ac commit a713471

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

dist/cross_staff_offset.lua

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5295,13 +5295,13 @@ package.preload["library.general_library"] = package.preload["library.general_li
52955295
return library
52965296
end
52975297
function plugindef()
5298-
finaleplugin.RequireSelection = true
5298+
finaleplugin.RequireSelection = false
52995299
finaleplugin.HandlesUndo = true
53005300
finaleplugin.Author = "Carl Vine"
53015301
finaleplugin.AuthorURL = "http://carlvine.com/lua/"
53025302
finaleplugin.Copyright = "https://creativecommons.org/licenses/by/4.0/"
5303-
finaleplugin.Version = "v1.64" -- Modeless option
5304-
finaleplugin.Date = "2024/04/13"
5303+
finaleplugin.Version = "v1.66" -- with Modeless option
5304+
finaleplugin.Date = "2024/07/28"
53055305
finaleplugin.MinJWLuaVersion = 0.62
53065306
finaleplugin.Notes = [[
53075307
When crossing notes to adjacent staves the stems of _crossed_ notes
@@ -5318,6 +5318,7 @@ function plugindef()
53185318
53195319
> - __u__: reset default __up__ values
53205320
> - __d__: reset default __down__ values
5321+
> - __m__: toggle __Modeless__
53215322
> - __q__: display these notes
53225323
> - __0 - 4__: layer number (delete key not needed)
53235324
> - To change measurement units:
@@ -5335,6 +5336,7 @@ function plugindef()
53355336
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li720 \fi0 {\b Key Commands}:\par}
53365337
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b u}: reset default {\b up} values\par}
53375338
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b d}: reset default {\b down} values\par}
5339+
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b m}: toggle {\b Modeless}\par}
53385340
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b q}: display these notes\par}
53395341
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab {\b 0 - 4}: layer number (delete key not needed)\line \par}
53405342
{\pard \sl264 \slmult1 \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab To change measurement units:\par}
@@ -5384,15 +5386,27 @@ local function get_staff_name(staff_num)
53845386
staff:Load(staff_num)
53855387
local staff_name = staff:CreateDisplayAbbreviatedNameString().LuaString
53865388
if not staff_name or staff_name == "" then
5387-
staff_name = "Staff " .. staff_num
5389+
staff_name = "Staff" .. staff_num
53885390
end
53895391
return staff_name
53905392
end
5391-
local function change_offsets()
5393+
local function nil_region_error(dialog)
5394+
if finenv.Region():IsEmpty() then
5395+
local ui = dialog and dialog:CreateChildUI() or finenv.UI()
5396+
ui:AlertError(
5397+
"Please select some music\nbefore running this script.",
5398+
finaleplugin.ScriptGroupName
5399+
)
5400+
return true
5401+
end
5402+
return false
5403+
end
5404+
local function change_offsets(dialog)
5405+
if nil_region_error(dialog) then return end
53925406
local rgn = finenv.Region()
53935407
finenv.StartNewUndoBlock(
53945408
string.format("%s %s m.%d-%d",
5395-
name, get_staff_name(rgn.StartStaff), rgn.StartMeasure, rgn.EndMeasure
5409+
name:gsub(" ", ""), get_staff_name(rgn.StartStaff),rgn.StartMeasure, rgn.EndMeasure
53965410
)
53975411
)
53985412
for entry in eachentrysaved(rgn, config.layer_num) do
@@ -5449,8 +5463,9 @@ local function run_the_dialog()
54495463
or (id == 3 and s:find("[^0-" .. max .. "]"))
54505464
then
54515465
if s:find("[?q]") then show_info()
5452-
elseif s:find("u") then set_defaults( 1)
5453-
elseif s:find("d") then set_defaults(-1)
5466+
elseif s:find("[ud]") then
5467+
box[id]:SetText(save_value[id])
5468+
set_defaults(s:find("u") and 1 or -1)
54545469
elseif s:find("m") then
54555470
box[modeless]:SetCheck((box[modeless]:GetCheck() + 1) % 2)
54565471
elseif s:find("[eicoas]") then
@@ -5464,8 +5479,7 @@ local function run_the_dialog()
54645479
end
54655480
end
54665481
end
5467-
box[id]:SetText(save_value[id])
5468-
elseif s ~= "" then
5482+
else
54695483
if id == 3 then
54705484
s = s:sub(-1)
54715485
else
@@ -5474,9 +5488,9 @@ local function run_the_dialog()
54745488
end
54755489
s = s:sub(1, 8)
54765490
end
5477-
box[id]:SetText(s)
5478-
save_value[id] = s
5491+
save_value[id] = (s == "") and "0" or s
54795492
end
5493+
box[id]:SetText(save_value[id])
54805494
end
54815495
local function submission_error()
54825496
local values = { 576, config.cross_staff_offset, config.non_cross_offset }
@@ -5533,7 +5547,7 @@ local function run_the_dialog()
55335547
if submission_error() then
55345548
user_error = true
55355549
else
5536-
change_offsets()
5550+
change_offsets(dialog)
55375551
end
55385552
end)
55395553
dialog:RegisterCloseWindow(function(self)
@@ -5546,17 +5560,18 @@ local function run_the_dialog()
55465560
dialog:RunModeless()
55475561
else
55485562
dialog:ExecuteModal()
5549-
if refocus_document then finenv.UI():ActivateDocumentWindow() end
55505563
end
55515564
return change_mode or user_error
55525565
end
55535566
local function cross_staff_offset()
5567+
if not config.modeless and nil_region_error() then return end
55545568
local qim = finenv.QueryInvokedModifierKeys
55555569
local shift_key = qim and (qim(finale.CMDMODKEY_ALT) or qim(finale.CMDMODKEY_SHIFT))
5556-
if shift_key then
5570+
if shift_key then
55575571
change_offsets()
55585572
else
55595573
while run_the_dialog() do end
5574+
if refocus_document then finenv.UI():ActivateDocumentWindow() end
55605575
end
55615576
end
55625577
cross_staff_offset()

hash/cross_staff_offset.hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8129e4d6acb23401bef10b225337632f9009e600877fd9f8c3328c73a9e54c120efd096fe082495091ce084bdb6c9c540c5dad4659d27b3811097429a3bb3155 cross_staff_offset.lua
1+
514ec67d566ca28c9c22522f3367f1a31d1fefa293a377e489e11fe3a89f79a646bcf4a320ba1e444ddc043962f720d346e0dff687d71b4dcfa052ab7d1e7172 cross_staff_offset.lua

0 commit comments

Comments
 (0)