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

Defocus docked feedback window automatically #70

Merged
merged 11 commits into from
Jul 12, 2024
Merged
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
12 changes: 1 addition & 11 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
# These are supported funding model platforms

github: myrrc
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
github: [myrrc]
ko_fi: michaelmuszynski
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
5 changes: 3 additions & 2 deletions .github/workflows/wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ jobs:
- if: steps.cache.outputs.cache-hit != 'true'
run: cd tests; chmod +x prepare; ./prepare
- run: |
# We can run local tests with feedback window, but in CI something goes wrong
sed -i 's/show_feedback_window = true/show_feedback_window = false/g' internal/definitions/config.lua
export DISPLAY=:99; sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
cd tests; chmod +x copy-configs patch-settings test
cd tests; chmod +x copy-configs test
./copy-configs
./patch-settings
./test
exit $?
9 changes: 0 additions & 9 deletions .releaserc.yml

This file was deleted.

2 changes: 0 additions & 2 deletions Makefile

This file was deleted.

8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ to [examples](#some-ideas-to-start-with).
## Installation

- Add `https://raw.githubusercontent.com/gwatcha/reaper-keys/master/index.xml` to Reapack.
- Optionally, install [SWS](https://sws-extension.org/) (by hand or from ReaTeam
Extensions). Although this extension _may_ work without SWS, the experience will be
worse.
- Install [SWS](https://sws-extension.org/) by hand or from ReaTeam Extensions.

## Features
### Bind key sequences
Expand Down Expand Up @@ -152,16 +150,16 @@ For running tests locally you'd need some Linux distribution with X11 and `xdoto

```sh
cd tests;
chmod +x prepare copy-configs patch-settings test
chmod +x prepare copy-configs test

./prepare # This will create a local Reaper installation
./copy-configs # This will make current instance of reaper-keys testable
./patch-settings # Or change test to true in internal/definitions/config.lua
./test # This will run every test and compare with reference projects
```

If you don't use X11 you can have a look at `.github/workflows/wf.yml` to see how x11 is
emulated with Xvfb.
Use `./test -s` to skip first invocation which bypasses "Still evaluating" window.

### Writing tests

Expand Down
3 changes: 1 addition & 2 deletions Scripts/install-reaper-keys.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- @description reaper-keys: map keystroke combinations to actions like in vim
-- @version 2.0.0-a2
-- @version 2.0.0-a3
-- @author gwatcha
-- @links
-- GitHub repository https://github.com/gwatcha/reaper-keys
Expand Down Expand Up @@ -123,7 +123,6 @@ local command_path = concat_path(parent_dir, "internal", "rk.lua")
local sections = { midi = 32060, main = 0 }
for section_name, section_id in pairs(sections) do
local command_id = "_reaper_keys__" .. section_name
-- 260 focuses window on every key press so 516 is only option
keymap:write(('SCR 516 %d %s "reaper-keys" "%s"\n'):format(section_id, command_id, command_path))

for group_name, group in pairs(key_groups) do
Expand Down
2 changes: 2 additions & 0 deletions internal/definitions/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ return {
FitSelectedItemsByStretching = 41206,
FitNotes = { 40754, midiCommand = true },
FocusMain = "_S&M_WNMAIN",
FocusTracks = "_BR_FOCUS_TRACKS",
FocusMidiEditor = "_SN_FOCUS_MIDI_EDITOR",
FolderChildren = { "SelectFolderChildren", "ScrollToSelectedTracks" },
FolderParent = { "SelectFolderParent", "ScrollToSelectedTracks" },
Folder = { "SelectFolder", "ScrollToSelectedTracks" },
Expand Down
5 changes: 3 additions & 2 deletions internal/definitions/bindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ local global = { -- applies both to main and midi
["c"] = "CycleRippleEditMode",
f = "SoloInFront",
F = "ResetFeedbackWindow",
M = "ToggleMasterMonoStereo",
} },
["i"] = { "+insert", {
["f"] = "InsertMediaFile",
Expand Down Expand Up @@ -357,13 +358,13 @@ local global = { -- applies both to main and midi
["r"] = "ResetControlDevices",
[","] = "ShowPreferences", -- remove in 2.1
["S"] = "UnsoloAllTracks",
["s"] = { "+show/hide", {
["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",
["M"] = "ToggleMasterMonoStereo", -- remove in 2.1
["r"] = "ShowRegionMarkerManager", -- remove in 2.1
} },
["f"] = { "+fx", {
Expand Down
3 changes: 1 addition & 2 deletions internal/definitions/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ local gui = {

local general = {
show_start_up_message = true,
dock_feedback_window = false,
dock_feedback_window = true,
show_feedback_window = true,
search_for_custom_config = false,
profile = false,
test = false,
-- should operators in visual modes reset the selection or have it persist?
persist_visual_timeline_selection = true,
persist_visual_track_selection = false,
Expand Down
53 changes: 25 additions & 28 deletions internal/gui/feedback/controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,49 +53,46 @@ end
local startup_msg =
"Hello from inside Reaper Keys! I see the feedback window just opened... " ..
"Here are some things I have been told to tell you:\n" ..
"- If the feedback window is focused, I can't hear keys being pressed, be sure to unfocus it.\n" ..
"- If the feedback window is focused and not docked, I can't hear keys being pressed, be sure to unfocus it.\n" ..
"- Press <CM-x> (Ctrl + Alt + x) to open up a keybinding menu.\n" ..
"- Everything you need to configure reaper-keys is in REAPER/Scripts/reaper-keys/internal/definitions/\n" ..
"- If you would like to hide this message, set the option in internal/definitions/config.lua\n" ..
"- If you set that option there will be no one to protect you from the focus stealing of the " ..
"feedback window.\n" ..
"\t Your mother loves you"
local feedback_view = nil

function feedback.update()
local feedback_view_open = model.getKey("open")
local just_opened = reaper_state.clearJustOpenedFlag()

if not feedback_view_open or just_opened then
feedback_view = FeedbackView:new()
feedback_view:open()
if feedback_view_open and not just_opened then
local update_number = tonumber(model.getKey("update_number") or 0)
if update_number > 20 then update_number = 0 end
model.setKeys({ update_number = update_number + 1 })
return
end

if config.show_start_up_message and not config.test then
reaper.ShowMessageBox(startup_msg, "Reaper Keys Open Message", 1)
end
feedback_view = FeedbackView:new()
feedback_view:open()

model.setKeys({ open = true })
if config.show_start_up_message then
reaper.ShowMessageBox(startup_msg, "Reaper Keys Open Message", 1)
end

if config.profile then
local path = '/Scripts/ReaTeam Scripts/Development/cfillion_Lua profiler.lua'
Profiler = dofile(reaper.GetResourcePath() .. path)
Profiler.attachToWorld()
Profiler.start()
Profiler.run()
end
model.setKeys({ open = true })

reaper.atexit(function()
model.setKeys({ open = false })
local window_settings = feedback_view:getWindowSettings()
model.setKeys({ window_settings = window_settings })
end)
else
local update_number = model.getKey("update_number")
if not update_number or update_number > 20 then
update_number = 0
end
model.setKeys({ update_number = update_number + 1 })
if config.profile then
local path = '/Scripts/ReaTeam Scripts/Development/cfillion_Lua profiler.lua'
Profiler = dofile(reaper.GetResourcePath() .. path)
Profiler.attachToWorld()
Profiler.start()
Profiler.run()
end

reaper.atexit(function()
model.setKeys({ open = false })
local window_settings = feedback_view:getWindowSettings()
model.setKeys({ window_settings = window_settings })
end)
end

function feedback.displayMessage(message)
Expand Down
13 changes: 11 additions & 2 deletions internal/state_machine/state_machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local buildCommand = require('command.builder')
local handleCommand = require('command.handler')
local getPossibleFutureEntries = require('command.completer')
local config = require 'definitions.config'.general
local actions = require 'definitions.actions'
local log = require('utils.log')
local format = require('utils.format')
local feedback = require('gui.feedback.controller')
Expand Down Expand Up @@ -127,17 +128,25 @@ local function input()
local hotkey = { context = section_id == 0 and "main" or "midi", key = ctxToState(ctx) }

log.info("Input: " .. format.line(hotkey))
if config.show_feedback_window and not config.test then feedback.clear() end
if config.show_feedback_window then feedback.clear() end

local state = state_interface.get()
local new_state = step(state, hotkey)
state_interface.set(new_state)

log.info("New state: " .. format.block(new_state))
if config.test or not config.show_feedback_window then return end
if not config.show_feedback_window then return end

feedback.displayState(new_state)
feedback.update()

-- This works only when window is docked, nothing we can do otherwise
local defocus_window = section_id == 0
and actions.FocusTracks or actions.FocusMidiEditor
reaper.Main_OnCommand(reaper.NamedCommandLookup(defocus_window), 0)

-- When we insert track with feedback window closed, it steals focus and track is not renamed
if hotkey.key:lower() == "o" then reaper.Main_OnCommand(actions.RenameTrack, 0) end
end

return input
6 changes: 1 addition & 5 deletions tests/compare
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ from pathlib import Path
from sys import argv
left_file, right_file = Path(argv[1]).read_text(), Path(argv[2]).read_text()
out = 0
ignored_keys = ["<TRACK", "TRACKID", "EGUID"]

if len(left_file) != len(right_file):
print("Different sizes")
out = 1
ignored_keys = ["<TRACK", "TRACKID", "EGUID", "FIXEDLANES"]

# skip project declaration
for left, right in zip(left_file.split("\n")[1:], right_file.split("\n")[1:]):
Expand Down
2 changes: 0 additions & 2 deletions tests/patch-settings

This file was deleted.

2 changes: 1 addition & 1 deletion tests/prepare
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
wget -qO- http://reaper.fm/files/7.x/reaper715_linux_x86_64.tar.xz | tar xfJ -
wget -qO- http://reaper.fm/files/7.x/reaper718_linux_x86_64.tar.xz | tar xfJ -
mv reaper_linux_x86_64/REAPER reaper
wget -q https://github.com/reaper-oss/sws/releases/download/v2.14.0.1/reaper_sws-x86_64.so -P reaper/UserPlugins
rm -fr reaper_linux_x86_64 \
Expand Down
2 changes: 1 addition & 1 deletion tests/test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
ret=0
timeout 5 ./reaper/reaper -new -nosplash &>/dev/null # still evaluating
[ $# -eq 0 ] && timeout 6 ./reaper/reaper -new -nosplash &>/dev/null # still evaluating

for test in *.rks; do
echo "Running $test"
Expand Down
Loading