<commit_before>--- === plugins.finalcutpro.timeline.colorboard ===
---
--- Color Board Plugins.

local require = require

local log                   = require "hs.logger".new "colorBoard"

local eventtap              = require "hs.eventtap"
local timer                 = require "hs.timer"

local dialog                = require "cp.dialog"
local fcp                   = require "cp.apple.finalcutpro"
local i18n                  = require "cp.i18n"
local tools                 = require "cp.tools"

local doWhile               = timer.doWhile
local format                = string.format

local mod = {}

--- plugins.finalcutpro.timeline.colorboard.startShiftingPuck(puck, percentShift, angleShift) -> none
--- Function
--- Starts shifting the puck, repeating at the keyboard repeat rate. Runs until `stopShiftingPuck()` is called.
---
--- Parameters:
---  * puck         - The puck to shift
---  * property     - The property to shift (typically the `percent` or `angle` value for the puck)
---  * amount       - The amount to shift the property.
---
--- Returns:
---  * None
function mod.startShiftingPuck(puck, property, amount)
    if not puck:select():isShowing() then
        dialog.displayNotification(i18n("pleaseSelectSingleClipInTimeline"))
        return false
    end

    mod.puckShifting = true
    doWhile(function() return mod.puckShifting end, function()
        local value = property()
        if value ~= nil then property(value + amount) end
    end, eventtap.keyRepeatInterval())
end

-- shiftPuck(puck, percentShift, angleShift) -> none
-- Function
-- Shifts a puck.
--
-- Parameters:
--  * puck         - The puck to shift
--  * property     - The property to shift (typically the `percent` or `angle` value for the puck)
--  * amount       - The amount to shift the property.
--
-- Returns:
--  * None
local function shiftPuck(puck, property, amount)
    if not puck:select():isShowing() then
        dialog.displayNotification(i18n("pleaseSelectSingleClipInTimeline"))
        return false
    end
    local value = property()
    if value ~= nil then property(value + amount) end
end

--- plugins.finalcutpro.timeline.colorboard.stopShiftingPuck() -> none
--- Function
--- Stops the puck from shifting with the keyboard.
---
--- Parameters:
---  * None
---
--- Returns:
---  * None
function mod.stopShiftingPuck()
    mod.puckShifting = false
end

--- plugins.finalcutpro.timeline.colorboard.startMousePuck(aspect, property) -> none
--- Function
--- Color Board - Puck Control Via Mouse
---
--- Parameters:
---  * aspect - "global", "shadows", "midtones" or "highlights"
---  * property - "Color", "Saturation" or "Exposure"
---
--- Returns:
---  * None
function mod.startMousePuck(puck)
    --------------------------------------------------------------------------------
    -- Delete any pre-existing highlights:
    --------------------------------------------------------------------------------
    mod.playhead.deleteHighlight()

    if not fcp:colorBoard():isActive() then
        dialog.displayNotification(i18n("pleaseSelectSingleClipInTimeline"))
        return false<commit_msg>Mouse Puck controls now ensure that Color Board is shown<commit_after>--- === plugins.finalcutpro.timeline.colorboard ===
---
--- Color Board Plugins.

local require = require

local log                   = require "hs.logger".new "colorBoard"

local eventtap              = require "hs.eventtap"
local timer                 = require "hs.timer"

local dialog                = require "cp.dialog"
local fcp                   = require "cp.apple.finalcutpro"
local i18n                  = require "cp.i18n"
local tools                 = require "cp.tools"

local doWhile               = timer.doWhile
local format                = string.format
local playErrorSound        = tools.playErrorSound

local mod = {}

--- plugins.finalcutpro.timeline.colorboard.startShiftingPuck(puck, percentShift, angleShift) -> none
--- Function
--- Starts shifting the puck, repeating at the keyboard repeat rate. Runs until `stopShiftingPuck()` is called.
---
--- Parameters:
---  * puck         - The puck to shift
---  * property     - The property to shift (typically the `percent` or `angle` value for the puck)
---  * amount       - The amount to shift the property.
---
--- Returns:
---  * None
function mod.startShiftingPuck(puck, property, amount)
    fcp:colorBoard():show()
    if not puck:select():isShowing() then
        playErrorSound()
        return false
    end

    mod.puckShifting = true
    doWhile(function() return mod.puckShifting end, function()
        local value = property()
        if value ~= nil then property(value + amount) end
    end, eventtap.keyRepeatInterval())
end

-- shiftPuck(puck, percentShift, angleShift) -> none
-- Function
-- Shifts a puck.
--
-- Parameters:
--  * puck         - The puck to shift
--  * property     - The property to shift (typically the `percent` or `angle` value for the puck)
--  * amount       - The amount to shift the property.
--
-- Returns:
--  * None
local function shiftPuck(puck, property, amount)
    fcp:colorBoard():show()
    if not puck:select():isShowing() then
        playErrorSound()
        return false
    end
    local value = property()
    if value ~= nil then property(value + amount) end
end

--- plugins.finalcutpro.timeline.colorboard.stopShiftingPuck() -> none
--- Function
--- Stops the puck from shifting with the keyboard.
---
--- Parameters:
---  * None
---
--- Returns:
---  * None
function mod.stopShiftingPuck()
    mod.puckShifting = false
end

--- plugins.finalcutpro.timeline.colorboard.startMousePuck(aspect, property) -> none
--- Function
--- Color Board - Puck Control Via Mouse
---
--- Parameters:
---  * aspect - "global", "shadows", "midtones" or "highlights"
---  * property - "Color", "Saturation" or "Exposure"
---
--- Returns:
---  * None
function mod.startMousePuck(puck)
    --------------------------------------------------------------------------------
    -- Delete any pre-existing highlights:
    --------------------------------------------------------------------------------
    mod.playhead.deleteHighlight()

    fcp:colorBoard():show()
    if not fcp:colorBoard():isActive() then
        playErrorSound()
        return false
{'fraction_non_alphanumeric': 0.1705017577500799, 'fraction_numerical': 0.0022371364653243847, 'mean_word_length': 2.05615234375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2643671', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1687, 'n_words': 504}