From fa1f6644d283be2dea99fc246fb2c4ddd5ca35bd Mon Sep 17 00:00:00 2001 From: Mikhail Kot Date: Sun, 11 Aug 2024 20:06:09 +0100 Subject: [PATCH] Bind window test and improvements (#77) * test for running action from bind window * wrong action picked in bind win * bump version --- Scripts/install-reaper-keys.lua | 2 +- internal/command/meta_command.lua | 10 +- internal/gui/binding_list/controller.lua | 4 - internal/gui/feedback/controller.lua | 4 +- internal/state_machine/state_machine.lua | 6 +- tests/run-action-from-binding-win.RPP | 156 +++++++++++++++++++++++ tests/run-action-from-binding-win.rks | 3 + tests/test | 10 +- 8 files changed, 171 insertions(+), 24 deletions(-) create mode 100644 tests/run-action-from-binding-win.RPP create mode 100644 tests/run-action-from-binding-win.rks diff --git a/Scripts/install-reaper-keys.lua b/Scripts/install-reaper-keys.lua index 0500c6bb..a6fb4d76 100644 --- a/Scripts/install-reaper-keys.lua +++ b/Scripts/install-reaper-keys.lua @@ -1,5 +1,5 @@ -- @description reaper-keys: map keystroke combinations to actions like in vim --- @version 2.0.0-a5 +-- @version 2.0.0-a6 -- @author gwatcha -- @links -- GitHub repository https://github.com/gwatcha/reaper-keys diff --git a/internal/command/meta_command.lua b/internal/command/meta_command.lua index 9bbc508c..955ae325 100644 --- a/internal/command/meta_command.lua +++ b/internal/command/meta_command.lua @@ -93,12 +93,10 @@ local meta_commands = { new_state['key_sequence'] = "" return new_state end, - -- TODO make me accessible from any state - ["ShowBindingList"] = function(state, command) - local new_state = state - new_state['key_sequence'] = "" - local list = binding_list.open(new_state) - return new_state + ShowBindingList = function(state, _) + state.key_sequence = "" + binding_list.open(state) + return state end } diff --git a/internal/gui/binding_list/controller.lua b/internal/gui/binding_list/controller.lua index 55b85888..7b008a24 100644 --- a/internal/gui/binding_list/controller.lua +++ b/internal/gui/binding_list/controller.lua @@ -1,6 +1,3 @@ -local log = require('utils.log') -local format = require('utils.format') - local definitions = require('utils.definitions') local BindingListView = require('gui.binding_list.View') local getPossibleFutureEntries = require('command.completer') @@ -62,7 +59,6 @@ function getElementValues(view) local action_type_i, action_type = view.elements.action_type_filter:val() return { binding_list_box = view.elements.binding_list_box:val(), - query = view.elements.query:val(), state_filter_active = view.elements.state_filter_active:val(nil, true), context_filter_active = view.elements.context_filter_active:val(nil, true), context = context, diff --git a/internal/gui/feedback/controller.lua b/internal/gui/feedback/controller.lua index e843e25c..4a79d525 100644 --- a/internal/gui/feedback/controller.lua +++ b/internal/gui/feedback/controller.lua @@ -100,9 +100,7 @@ function feedback.displayMessage(message) end function feedback.displayState(state) - local right_text = state.macro_recording - and string_util.format("(rec %s..)", state['macro_register']) - or "" + local right_text = state.macro_recording and ("(rec %s..)"):format(state.macro_register) or "" model.setKeys({ right_text = right_text, mode = state['mode'] }) feedback.update() end diff --git a/internal/state_machine/state_machine.lua b/internal/state_machine/state_machine.lua index a9c2b0a4..9f271b70 100644 --- a/internal/state_machine/state_machine.lua +++ b/internal/state_machine/state_machine.lua @@ -4,7 +4,7 @@ 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 log = require 'utils.log' local format = require('utils.format') local feedback = require('gui.feedback.controller') @@ -45,10 +45,10 @@ local function step(state, key_press) return new_state end - log.info("New key sequence: " .. new_state.key_sequence) + log.info("New key sequence: ", new_state.key_sequence) local command = buildCommand(new_state) if command then - log.trace("Command built: " .. format.block(command)) + log.trace("Command built: ", format.block(command)) new_state, message = handleCommand(new_state, command) feedback.displayMessage(message) return new_state diff --git a/tests/run-action-from-binding-win.RPP b/tests/run-action-from-binding-win.RPP new file mode 100644 index 00000000..23bbcbe8 --- /dev/null +++ b/tests/run-action-from-binding-win.RPP @@ -0,0 +1,156 @@ + + RIPPLE 0 + GROUPOVERRIDE 0 0 0 + AUTOXFADE 1 + ENVATTACH 3 + POOLEDENVATTACH 0 + MIXERUIFLAGS 11 48 + ENVFADESZ10 40 + PEAKGAIN 1 + FEEDBACK 0 + PANLAW 1 + PROJOFFS 0 0 0 + MAXPROJLEN 0 0 + GRID 3199 8 1 8 1 0 0 0 + TIMEMODE 1 5 -1 30 0 0 -1 + VIDEO_CONFIG 0 0 256 + PANMODE 3 + PANLAWFLAGS 3 + CURSOR 2 + ZOOM 100 0 0 + VZOOMEX 6 0 + USE_REC_CFG 0 + RECMODE 1 + SMPTESYNC 0 30 100 40 1000 300 0 0 1 0 0 + LOOP 0 + LOOPGRAN 0 4 + RECORD_PATH "Media" "" + + + RENDER_FILE "" + RENDER_PATTERN "" + RENDER_FMT 0 2 0 + RENDER_1X 0 + RENDER_RANGE 1 0 0 18 1000 + RENDER_RESAMPLE 3 0 1 + RENDER_ADDTOPROJ 0 + RENDER_STEMS 0 + RENDER_DITHER 0 + TIMELOCKMODE 1 + TEMPOENVLOCKMODE 1 + ITEMMIX 1 + DEFPITCHMODE 589824 0 + TAKELANE 1 + SAMPLERATE 44100 0 0 + + LOCK 1 + + GLOBAL_AUTO -1 + TEMPO 120 4 4 + PLAYRATE 1 0 0.25 4 + SELECTION 0 0 + SELECTION2 0 0 + MASTERAUTOMODE 0 + MASTERTRACKHEIGHT 0 0 + MASTERPEAKCOL 16576 + MASTERMUTESOLO 0 + MASTERTRACKVIEW 0 0.6667 0.5 0.5 0 0 0 0 0 0 0 0 0 0 + MASTERHWOUT 0 0 1 0 0 0 0 -1 + MASTER_NCH 2 2 + MASTER_VOLUME 1 0 -1 -1 1 + MASTER_PANMODE 3 + MASTER_PANLAWFLAGS 3 + MASTER_FX 1 + MASTER_SEL 0 + + + + + > + > + +> diff --git a/tests/run-action-from-binding-win.rks b/tests/run-action-from-binding-win.rks new file mode 100644 index 00000000..87f302b8 --- /dev/null +++ b/tests/run-action-from-binding-win.rks @@ -0,0 +1,3 @@ +otest &Return "limitation of tester - feedback must be opened before bind win +&ctrl+alt+x "open bindings window +insertmi &Down &Return "run insert-midi-item action diff --git a/tests/test b/tests/test index 4a5df94a..83cbdcd3 100755 --- a/tests/test +++ b/tests/test @@ -1,12 +1,8 @@ #!/bin/sh -ret=0; out=out.RPP; reaper="./reaper/reaper -new -nosplash" -if [ $# -eq 0 ]; then - tests="*.rks"; timeout 6 $reaper 1>/dev/null 2>&1 # still evaluating -else - tests=$@ -fi +ret=0; out="out.RPP"; reaper="./reaper/reaper -new -nosplash" +[ $# -eq 0 ] && timeout 6 $reaper 1>/dev/null 2>&1 # still evaluating -for test in $tests; do +for test in ${@:-*.rks}; do echo "Running $test" $reaper -saveas $out 1>/dev/null 2>&1 &