Skip to content

Commit

Permalink
Update amagalma_Move edit cursor to previous visible grid line.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
amagalma authored Aug 8, 2023
1 parent fda8252 commit cb8eefc
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions Cursor/amagalma_Move edit cursor to previous visible grid line.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- @description amagalma_Move edit cursor to previous visible grid line
-- @description Move edit cursor to previous visible grid line
-- @author amagalma
-- @version 1.06
-- @version 1.07
-- @changelog
-- - Improved behavior with framerate grid and lots of frames/sec
-- - Fixed case: edit cursor a bit to the right of a grid line
-- @about
-- # Moves the edit cursor to the previous grid line that is visible

Expand All @@ -27,14 +27,19 @@ else
end

if cursorpos > 0 then
local grid = cursorpos
while (grid >= cursorpos) do
cursorpos = cursorpos - grid_duration
if cursorpos >= grid_duration then
grid = reaper.SnapToGrid(0, cursorpos)
else
grid = 0
end
local snapped, grid = reaper.SnapToGrid(0, cursorpos)
if snapped < cursorpos then
grid = snapped
else
grid = cursorpos
while (grid >= cursorpos) do
cursorpos = cursorpos - grid_duration
if cursorpos >= grid_duration then
grid = reaper.SnapToGrid(0, cursorpos)
else
grid = 0
end
end
end
reaper.SetEditCurPos(grid,1,1)
end
Expand Down

0 comments on commit cb8eefc

Please sign in to comment.