Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#76 selection fixes #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/definitions/actions.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local lib = require 'library.library' -- functions specific to reaper-keys i.e. macros
local lib = require 'library.library' -- TODO rename to impl
local movements = require 'movements'

-- Here are some predefined commands that you can use in bindings.lua e.g to map
Expand Down Expand Up @@ -47,6 +47,7 @@ return {
InsertTrackAbove = { "_SWS_INSRTTRKABOVE", prefixRepetitionCount = true },
InsertTrackBelow = { 40001, prefixRepetitionCount = true },
Insert4EnvelopePointsAtTimeSelection = 40726,
-- TODO Could not find action in reaper or action list for: _S&M_ADD_TRTEMPLATE
InsertTrackFromTemplateSlot1 = "_S&M_ADD_TRTEMPLATE1",
InsertTrackFromTemplateSlot2 = "_S&M_ADD_TRTEMPLATE2",
InsertTrackFromTemplateSlot3 = "_S&M_ADD_TRTEMPLATE3",
Expand Down Expand Up @@ -344,7 +345,8 @@ return {
PasteAbove = { "PrevTrack", "Paste", prefixRepetitionCount = true },
PasteFxChain = { "_S&M_SMART_PST_FXCHAIN", prefixRepetitionCount = true },
PasteItem = { 40058, prefixRepetitionCount = true },
Paste = { "_SWS_AWPASTE", prefixRepetitionCount = true },
PasteImpl = lib.paste,
Paste = {"PasteImpl", prefixRepetitionCount = true },
Pause = 1008,
PitchDown = { 40050, midiCommand = true, prefixRepetitionCount = true },
PitchDown7 = { "PitchDown", repetitions = 7, prefixRepetitionCount = true },
Expand Down
52 changes: 33 additions & 19 deletions internal/definitions/bindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ local global = { -- applies both to main and midi
["<M-T>"] = "PlayFromMouseAndSoloTrack",
["<C-t>"] = "PlayFromEditCursorAndSoloTrackUnderMouse",
["F"] = "Pause",

["<C-<SPC>>"] = "ShowMixer", -- possibly remove in 2.1

["<C-<SPC>>"] = "ShowMixer", -- TODO remove in 2.1, replace by <SPC>vm
["."] = "RepeatLastCommand",
["<C-.>"] = "RepeatPenultimateAction",
["@"] = "PlayMacro",
Expand Down Expand Up @@ -103,7 +101,7 @@ local global = { -- applies both to main and midi
["j"] = "RecallNextSnapshot",
["k"] = "RecallPreviousSnapshot",
["D"] = "DeleteAllSnapshots",
["t"] = "ShowSnapshotsWindow", -- remove in 2.1
["t"] = "ShowSnapshotsWindow", -- TODO remove in 2.1, replaced by <SPC>v"
["y"] = "CopyCurrentSnapshot",
["p"] = "PasteSnapshot",
["r"] = "RecallCurrentSnapshot",
Expand Down Expand Up @@ -320,7 +318,7 @@ local global = { -- applies both to main and midi
["y"] = "CopyEnvelope",
["t"] = "ToggleShowSelectedEnvelope",
["b"] = "ToggleEnvelopeBypass",
["s"] = { "+shape", {
["s"] = { "+shape", { -- TODO remove in 2.1, replaced by <SPC>eS
["b"] = "SetEnvelopeShapeBezier",
["e"] = "SetEnvelopeShapeFastEnd",
["f"] = "SetEnvelopeShapeFastStart",
Expand All @@ -329,6 +327,14 @@ local global = { -- applies both to main and midi
["S"] = "SetEnvelopeShapeSquare",
} },
} },
S = { "+shape", {
b = "SetEnvelopeShapeBezier",
e = "SetEnvelopeShapeFastEnd",
f = "SetEnvelopeShapeFastStart",
l = "SetEnvelopeShapeLinear",
s = "SetEnvelopeShapeSlowStart",
S = "SetEnvelopeShapeSquare"
}},
} },
["f"] = { "+fx", {
["a"] = "AddFx",
Expand All @@ -341,7 +347,7 @@ local global = { -- applies both to main and midi
["s"] = "ToggleShowInputFxChain",
["d"] = "CutInputFxChain",
} },
["s"] = { "+show", {
["s"] = { "+show", { --TODO remove in 2.1, replaced by <SPC>f{1-8}
["1"] = "ToggleShowFx1",
["2"] = "ToggleShowFx2",
["3"] = "ToggleShowFx3",
Expand All @@ -351,30 +357,38 @@ local global = { -- applies both to main and midi
["7"] = "ToggleShowFx7",
["8"] = "ToggleShowFx8"
} },
["1"] = "ToggleShowFx1",
["2"] = "ToggleShowFx2",
["3"] = "ToggleShowFx3",
["4"] = "ToggleShowFx4",
["5"] = "ToggleShowFx5",
["6"] = "ToggleShowFx6",
["7"] = "ToggleShowFx7",
["8"] = "ToggleShowFx8"
} },
["T"] = { "+timeline", {
["a"] = "AddTimeSignatureMarker",
["e"] = "EditTimeSignatureMarker",
["d"] = "DeleteTimeSignatureMarker",
["s"] = "ShowTempoEnvelope" -- remove in 2.1
["s"] = "ShowTempoEnvelope" -- TODO remove in 2.1, replaced by <SPC>ve
} },
["g"] = { "+global", {
["g"] = "SetGridDivision",
["r"] = "ResetControlDevices",
[","] = "ShowPreferences", -- remove in 2.1
[","] = "ShowPreferences", -- TODO remove in 2.1, replaced by <SPC>v,
["S"] = "UnsoloAllTracks",
["s"] = { "+show/hide", { -- remove in 2.1
["x"] = "ShowRoutingMatrix", -- remove in 2.1
["w"] = "ShowWiringDiagram", -- remove in 2.1
["t"] = "ShowTrackManager", -- remove in 2.1
["f"] = "ShowMonitoringFx", -- remove in 2.1
["m"] = "ToggleShowMasterTrack", -- remove in 2.1
["M"] = "ToggleMasterMonoStereo", -- remove in 2.1
["r"] = "ShowRegionMarkerManager", -- remove in 2.1
["s"] = { "+show/hide", { -- TODO remove in 2.1, replaced by <SPC>v
["x"] = "ShowRoutingMatrix",
["w"] = "ShowWiringDiagram",
["t"] = "ShowTrackManager",
["f"] = "ShowMonitoringFx",
["m"] = "ToggleShowMasterTrack",
["M"] = "ToggleMasterMonoStereo",
["r"] = "ShowRegionMarkerManager",
} },
["f"] = { "+fx", {
["x"] = "CloseAllFxChainsAndWindows",
["c"] = "ShowMasterFxChain", -- remove in 2.1
["c"] = "ShowMasterFxChain", --TODO remove in 2.1, replaced by <SPC>vF
} },
["e"] = "ToggleShowAllEnvelopeGlobal",
["a"] = { "+automation", {
Expand Down Expand Up @@ -526,8 +540,8 @@ local main = {
["aa"] = "ArmTracks",
["O"] = "EnterTrackAbove",
["o"] = "EnterTrackBelow",
["p"] = "Paste",
["<C-v>"] = "Paste",
p = "Paste",
["<C-v>"] = "Paste", -- TODO remove in v2.1
["yy"] = "CopyTrack",
["zz"] = "ScrollToSelectedTracks",
["%"] = "SplitItemsAtEditCursor",
Expand Down
21 changes: 21 additions & 0 deletions internal/library/library.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local state_interface = require('state_machine.state_interface')
local reaper_state = require('utils.reaper_state')
local feedback = require('gui.feedback.controller')
-- TODO merge with movements to internal/actions_impl.lua

local function getMatchedTrack(search_name, forward)
if not search_name then return nil end
Expand Down Expand Up @@ -92,4 +93,24 @@ function library.ResetFeedbackWindow()
reaper_state.setKeys("feedback", {open = false})
end

-- No time selection?
---@type integer
local paste = reaper.NamedCommandLookup("_SWS_AWPASTE")
-- When multiple tracks are selected, paste pastes on last touched track but we
-- want to paste selected track-wise, skipping empty tracks
function library.paste()
local num = reaper.CountSelectedTracks()
if num < 2 then return reaper.Main_OnCommand(paste, 0) end
local sel = {}
local first = nil
for i = 0, num - 1 do
local track = reaper.GetSelectedTrack(0, i)
if not first and reaper.GetTrackNumMediaItems(track) > 0 then first = track end
sel[i + 1] = track
end
reaper.SetOnlyTrackSelected(first)
reaper.Main_OnCommand(paste, 0)
for _, track in ipairs(sel) do reaper.SetTrackSelected(track, true) end
end

return library
7 changes: 7 additions & 0 deletions tests/paste-multiple-selection.rks
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
,a o &Return 0 im l im , "macro a that inserts 2 midi items on start
o &Return "create empty track
2@a &Return "replay macro 2 times, last enter to defocus bottom track rename
V 2k "select tracks 2-4
v 4l "create time selection for first track' items, ve should also work but doesn't, as well as v$ doesn't, maybe edit cursor issue
sY "select and copy items inside time and track selection
6l p "jump forward 6 divisions and paste items
Loading