-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,818 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: workflow | ||
on: push | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: awalsh128/cache-apt-pkgs-action@latest | ||
with: { packages: xdotool, version: 1.0 } | ||
- uses: actions/checkout@v4 | ||
- id: cache | ||
uses: actions/cache@v3 | ||
with: { path: tests/reaper, key: cache } | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
run: cd tests; chmod +x prepare; ./prepare | ||
- run: | | ||
export DISPLAY=:99; sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & | ||
cd tests; chmod +x copy-configs patch-settings test | ||
./copy-configs | ||
./patch-settings | ||
./test | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
internal/saved/data/* | ||
!/internal/saved/data/.gitkeep | ||
internal/gui/feedback/model_data.lua | ||
internal/state_machine/state.lua | ||
Scripts/gen | ||
reaper-keys.ReaperKeyMap | ||
|
||
tests/reaper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lint: | ||
luacheck internal/ --globals gfx reaper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,83 @@ | ||
local utils = require('command.utils') | ||
local ser = require('serpent') | ||
local string_util = require('string') | ||
local utils = require 'command.utils' | ||
local serpent = require 'serpent' | ||
local string_util = require 'string' | ||
local format = {} | ||
|
||
function pairsByKeys(t, f) | ||
local a = {} | ||
for n in pairs(t) do | ||
table.insert(a, n) | ||
end | ||
table.sort(a, f) | ||
local i = 0 | ||
local iter = function () | ||
i = i + 1 | ||
if a[i] == nil then | ||
return nil | ||
else | ||
return a[i], t[a[i]] | ||
local function pairsByKeys(t, f) | ||
local a = {} | ||
for n in pairs(t) do | ||
table.insert(a, n) | ||
end | ||
end | ||
return iter | ||
table.sort(a, f) | ||
local i = 0 | ||
local iter = function() | ||
i = i + 1 | ||
if a[i] == nil then | ||
return nil | ||
else | ||
return a[i], t[a[i]] | ||
end | ||
end | ||
return iter | ||
end | ||
|
||
function sortTableAlphabetically(table_to_sort) | ||
local t = {} | ||
for title,value in pairsByKeys(table_to_sort) do | ||
table.insert(t, { title = title, value = value }) | ||
end | ||
return t | ||
local t = {} | ||
for title, value in pairsByKeys(table_to_sort) do | ||
table.insert(t, { title = title, value = value }) | ||
end | ||
return t | ||
end | ||
|
||
function format.line(data) | ||
return ser.line(data, {comment=false}) | ||
return serpent.line(data, { comment = false }) | ||
end | ||
|
||
function format.block(data) | ||
return ser.block(data, {comment=false}) | ||
return serpent.block(data, { comment = false }) | ||
end | ||
|
||
function removeUglyBrackets(key) | ||
local pretty_key = key | ||
if string_util.sub(key, 1, 1) == "<" and string_util.sub(key, #key, #key) == ">" then | ||
pretty_key = string_util.sub(key, 2, #key - 1) | ||
end | ||
local function removeUglyBrackets(key) | ||
local pretty_key = key | ||
if string_util.sub(key, 1, 1) == "<" and string_util.sub(key, #key, #key) == ">" then | ||
pretty_key = string_util.sub(key, 2, #key - 1) | ||
end | ||
|
||
return pretty_key | ||
return pretty_key | ||
end | ||
|
||
function format.keySequence(key_sequence, spacing) | ||
local rest_of_key_seq = key_sequence | ||
local key_sequence_string = "" | ||
while #rest_of_key_seq ~= 0 do | ||
first_key, rest_of_key_seq = utils.splitFirstKey(rest_of_key_seq) | ||
if tonumber(first_key) or not spacing then | ||
key_sequence_string = key_sequence_string .. first_key | ||
else | ||
key_sequence_string = key_sequence_string .. " " .. removeUglyBrackets(first_key) | ||
local rest_of_key_seq = key_sequence | ||
local key_sequence_string = "" | ||
while #rest_of_key_seq ~= 0 do | ||
first_key, rest_of_key_seq = utils.splitFirstKey(rest_of_key_seq) | ||
if tonumber(first_key) or not spacing then | ||
key_sequence_string = key_sequence_string .. first_key | ||
else | ||
key_sequence_string = key_sequence_string .. " " .. removeUglyBrackets(first_key) | ||
end | ||
end | ||
end | ||
|
||
return key_sequence_string | ||
return key_sequence_string | ||
end | ||
|
||
---@param command Command | ||
---@return string | ||
function format.commandDescription(command) | ||
local desc = "" | ||
for _, command_part in pairs(command.action_keys) do | ||
if type(command_part) == 'table' then | ||
local name = command_part[1] | ||
desc = desc .. '[' | ||
for _,additional_args in pairs(command_part) do | ||
desc = desc .. ' ' .. additional_args | ||
end | ||
desc = desc .. ' ]' | ||
else | ||
desc = desc .. (command_part) .. " " | ||
local desc = "" | ||
for _, command_part in pairs(command.action_keys) do | ||
if type(command_part) == 'table' then | ||
local name = command_part[1] | ||
desc = desc .. '[' | ||
for _, additional_args in pairs(command_part) do | ||
desc = desc .. ' ' .. additional_args | ||
end | ||
desc = desc .. ' ]' | ||
else | ||
desc = desc .. (command_part) .. " " | ||
end | ||
end | ||
end | ||
return desc | ||
return desc | ||
end | ||
|
||
return format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
local actions = require("definitions.actions") | ||
local actions = require "definitions.actions" | ||
|
||
---@param action_name string | ||
---@param name string | ||
---@return Action | nil | ||
function getAction(action_name) | ||
return actions[action_name] | ||
end | ||
function getAction(name) return actions[name] end | ||
|
||
return getAction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,52 @@ | ||
local log = require('utils.log') | ||
local serpent = require('serpent') | ||
|
||
local serpent = require 'serpent' | ||
local project_state = {} | ||
|
||
---@param ext string | ||
---@param key string | ||
---@param lua_table table | string | ||
---@param lua_table table | string | ||
function project_state.overwrite(ext, key, lua_table) | ||
local current_project, _ = reaper.EnumProjects(-1, "") | ||
local lua_table_string = serpent.block(lua_table, { comment = false }) | ||
reaper.SetProjExtState(current_project, ext, key, lua_table_string) | ||
local current_project, _ = reaper.EnumProjects(-1, "") | ||
local lua_table_string = serpent.block(lua_table, { comment = false }) | ||
reaper.SetProjExtState(current_project, ext, key, lua_table_string) | ||
end | ||
|
||
---@param ext string | ||
function project_state.getAll(ext) | ||
local keys = {} | ||
local max_keys = 5000 | ||
local exists = false | ||
for i=0,max_keys do | ||
ok, key, val = reaper.EnumProjExtState(0, ext, i) | ||
if not ok then | ||
break | ||
end | ||
|
||
ok, lua_table = serpent.load(val) | ||
if not ok then | ||
return false, keys | ||
local keys, max_keys, exists = {}, 5000, false | ||
for i = 0, max_keys do | ||
local enum_ok, key, val = reaper.EnumProjExtState(0, ext, i) | ||
if not enum_ok then break end | ||
local serpent_ok, lua_table = serpent.load(val) | ||
if not serpent_ok then return false, keys end | ||
|
||
keys[key] = lua_table | ||
exists = true | ||
end | ||
|
||
keys[key] = lua_table | ||
exists = true | ||
end | ||
|
||
return exists, keys | ||
return exists, keys | ||
end | ||
|
||
---@param ext string | ||
---@param key string | ||
function project_state.get(ext, key) | ||
local current_project, _ = reaper.EnumProjects(-1, "") | ||
local exists, value = reaper.GetProjExtState(current_project, ext, key) | ||
if exists and value then | ||
local ok, lua_table = serpent.load(value) | ||
if not ok or not lua_table then | ||
return false, lua_table | ||
end | ||
|
||
if lua_table['deleted'] then | ||
return false, lua_table | ||
end | ||
|
||
return ok, lua_table | ||
end | ||
local current_project, _ = reaper.EnumProjects(-1, "") | ||
local exists, value = reaper.GetProjExtState(current_project, ext, key) | ||
if not exists or not value then return false, 'Does not exist' end | ||
|
||
return false, 'Does not exist' | ||
local ok, table = serpent.load(value) | ||
if not ok or not table or table.deleted then return false, table end | ||
return ok, table | ||
end | ||
|
||
---@param ext string | ||
---@param key string | ||
function project_state.delete(ext, key) | ||
-- reaper has the function 'DeleteExtState', but it dosen't work for project | ||
-- state, so I introduce a 'deleted' key to indicate deletion | ||
local ok, val = project_state.get(ext, key) | ||
if ok and not val['deleted'] then | ||
val['deleted'] = true | ||
-- reaper has the function 'DeleteExtState', but it doesn't work for project | ||
-- state, so I introduce a 'deleted' key to indicate deletion | ||
local ok, val = project_state.get(ext, key) | ||
if not ok or val.deleted then return end | ||
val.deleted = true | ||
project_state.overwrite(ext, key, val) | ||
end | ||
end | ||
|
||
return project_state |
Oops, something went wrong.
5b68d0b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is really impressive stuff