Skip to content

Commit

Permalink
Parse seek 0.1|-0.1|+0.1 and display tooltip correctly (#5)
Browse files Browse the repository at this point in the history
The pattern can have a few false positives, but the shortcut wouldn't
work anyway in such cases.
  • Loading branch information
Zren committed May 27, 2022
1 parent fe63f54 commit 245737f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions osc_tethys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,13 @@ function formatBinds(binds)
return str
end
function formatSeekBind(bind)
local seekBy = bind.cmd:match("^seek%s+(%-?%d+)")
seekBy = tonumber(seekBy)
local seekBy = bind.cmd:match("^seek%s+([%+%-]?[%d%.]+)")
seekBy = tonumber(seekBy) -- Note: +0.1 is parsed okay
local label
if seekBy < 0 then
return ("Back %ds %s"):format(-seekBy, formatBindKey(bind.key))
return ("Back %ss %s"):format(-seekBy, formatBindKey(bind.key))
else
return ("Forward %ds %s"):format(seekBy, formatBindKey(bind.key))
return ("Forward %ss %s"):format(seekBy, formatBindKey(bind.key))
end
end
function formatSeekBinds(binds)
Expand All @@ -425,8 +425,8 @@ end
-- %d+ = One or more digits from 0 to 9
-- (%-?%d+) = Positive or negative integer
local pauseBinds = grepBindByCmd("^cycle(%s+)pause", {"p", "PLAYPAUSE", "MBTN_RIGHT", "PLAY", "PAUSE"})
local seekBackBinds = grepBindByCmd("^seek(%s+)(%-%d+)", {"REWIND", "Shift+PGDWN"})
local seekFrwdBinds = grepBindByCmd("^seek(%s+)(%d+)", {"FORWARD", "Shift+PGUP"})
local seekBackBinds = grepBindByCmd("^seek(%s+)(%-[%d%.]+)", {"REWIND", "Shift+PGDWN"})
local seekFrwdBinds = grepBindByCmd("^seek(%s+)(%+?[%d%.]+)", {"FORWARD", "Shift+PGUP"})
local muteBinds = grepBindByCmd("^cycle(%s+)mute", {"MUTE"})
local volDnBinds = grepBindByCmd("^add(%s+)volume(%s+)(%-%d+)", {"VOLUME_DOWN", "WHEEL_LEFT"})
local volUpBinds = grepBindByCmd("^add(%s+)volume(%s+)(%d+)", {"VOLUME_UP", "WHEEL_RIGHT"})
Expand Down

0 comments on commit 245737f

Please sign in to comment.