| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834 |
- #include "core/KeyMap.h"
- #include "core/ModifierMap.h"
- #include <algorithm>
- #include <cctype>
- namespace lynx::keys
- {
- namespace
- {
- struct KeyName
- {
- int key;
- const char* name;
- };
- const KeyName keyNames[] = {
- { space, "Space" }, { enter, "Enter" }, { escape, "Esc" }, { tab, "Tab" }, { backspace, "Backspace" },
- { del, "Delete" }, { insert, "Insert" }, { up, "Up" }, { down, "Down" }, { left, "Left" },
- { right, "Right" }, { pageUp, "PageUp" }, { pageDown, "PageDown" }, { home, "Home" }, { end, "End" },
- { numpadPlus, "Numpad +" }, { numpadMinus, "Numpad -" }, { numpadMultiply, "Numpad *" }, { numpadDivide, "Numpad /" },
- { numpad0, "Numpad 0" }, { numpad1, "Numpad 1" }, { numpad2, "Numpad 2" }, { numpad3, "Numpad 3" }, { numpad4, "Numpad 4" },
- { numpad5, "Numpad 5" }, { numpad6, "Numpad 6" }, { numpad7, "Numpad 7" }, { numpad8, "Numpad 8" }, { numpad9, "Numpad 9" },
- };
- std::string lower (std::string s)
- {
- for (auto& c : s)
- c = (char) std::tolower ((unsigned char) c);
- return s;
- }
- std::string trim (const std::string& s)
- {
- const auto a = s.find_first_not_of (" \t\r\n");
- const auto b = s.find_last_not_of (" \t\r\n");
- return a == std::string::npos ? std::string() : s.substr (a, b - a + 1);
- }
- Chord chord (int key, std::uint8_t mods = none)
- {
- return { key, mods };
- }
- std::vector<Action> makeActions()
- {
- std::vector<Action> list {
- // transport and modes
- { "transport.playStop", TR_NOOP ("Play / stop (back to where playback started)"), Context::global, { chord (space) } },
- { "transport.pause", TR_NOOP ("Play / pause"), Context::global, { chord (space, ctrl) } },
- // FL 2026 (checked in FL, round 165s): Shift+Space stops and goes back to the start of the song / pattern, or
- // plays from there when stopped; the position clicked on a ruler is ignored (issue #11)
- { "transport.playFromStart", TR_NOOP ("Play, or stop at the start of the song or pattern"), Context::global, { chord (space, shift) } },
- { "transport.toggleMode", TR_NOOP ("Pattern / song mode"), Context::global, { chord ('L') }, true },
- { "transport.nextMarker", TR_NOOP ("Jump to the next song marker (Quantize song jumps while playing)"), Context::global, { chord (numpadMultiply, alt) } },
- { "transport.previousMarker", TR_NOOP ("Jump to the previous song marker"), Context::global, { chord (numpadDivide, alt) } },
- { "view.typingPiano", TR_NOOP ("Typing keyboard to piano on/off"), Context::global, { chord ('T', ctrl) } },
- { "view.toolbar", TR_NOOP ("Show or hide the toolbar panels"), Context::global, { chord (f11, ctrl) } },
- { "view.audioEditor", TR_NOOP ("Open the audio editor"), Context::global, {} },
- { "view.tempoTapper", TR_NOOP ("Tempo tapper (tap the tempo)"), Context::global, { chord (f5, ctrl) } },
- { "view.sampleBrowser", TR_NOOP ("Sample browser (separate window)"), Context::global, {} },
- // workspace panels
- { "panel.playlist", TR_NOOP ("Show, focus or hide the Playlist"), Context::global, { chord (f5) } },
- { "panel.channelRack", TR_NOOP ("Show, focus or hide the Channel Rack"), Context::global, { chord (f6) } },
- { "panel.pianoRoll", TR_NOOP ("Show, focus or hide the Piano Roll"), Context::global, { chord (f7) } },
- { "panel.browser", TR_NOOP ("Show, focus or hide the Browser"), Context::global, { chord (f8, alt) } },
- // FL's F8 (ShowPluginPickerAction, round 167o): opens the plugin picker, or closes it when it is open
- { "panel.quickAdd", TR_NOOP ("Quick-add palette: instruments and effects (press again to close)"), Context::global, { chord (f8) } },
- { "panel.mixer", TR_NOOP ("Show, focus or hide the Mixer"), Context::global, { chord (f9) } },
- // FL 2026's other window keys (its shortcut list, REA round 165a)
- { "view.pluginDatabase", TR_NOOP ("Plugin database (in the Browser)"), Context::global, { chord (f8, shift) } },
- // F10 / F11 toggle like FL's (round 167o, settingsKeyPress): Settings on another page switches to this one
- { "view.midiSettings", TR_NOOP ("MIDI settings (press again to close)"), Context::global, { chord (f10) } },
- { "view.projectInfo", TR_NOOP ("Project info (press again to close)"), Context::global, { chord (f11) } },
- { "view.closeWindows", TR_NOOP ("Close all windows (plugins, channel settings, tools)"), Context::global, { chord (f12) } },
- { "view.closePluginWindows", TR_NOOP ("Close all plugin windows"), Context::global, { chord (f12, alt) } },
- // FL's CloseAllUnfocusedWindowsAction (Ctrl+F12) and ShowTouchControllerAction (Alt+F7), round 167o
- { "view.closeUnfocusedWindows", TR_NOOP ("Close all windows except the focused one"), Context::global, { chord (f12, ctrl) } },
- { "view.touchKeyboard", TR_NOOP ("Show or hide the Touch keyboard"), Context::global, { chord (f7, alt) } },
- { "panel.maximisePlaylist", TR_NOOP ("Maximize or restore the Playlist"), Context::global, { chord (enter) } },
- // patterns
- { "pattern.next", TR_NOOP ("Next pattern"), Context::global, { chord (numpadPlus) } },
- { "pattern.previous", TR_NOOP ("Previous pattern"), Context::global, { chord (numpadMinus) } },
- { "pattern.nextEmpty", TR_NOOP ("Next empty pattern (and name it)"), Context::global, { chord (f4) } },
- { "pattern.firstEmpty", TR_NOOP ("First empty pattern (and name it)"), Context::global, { chord (f4, shift) } },
- { "pattern.nextEmptyNoName", TR_NOOP ("Next empty pattern (no naming)"), Context::global, { chord (f4, ctrl) } },
- { "pattern.rename", TR_NOOP ("Rename and color the pattern"), Context::global, { chord (f2) } },
- { "pattern.insert", TR_NOOP ("Insert an empty pattern before the current one"), Context::global, { chord (insert, ctrl | shift) } },
- { "pattern.clone", TR_NOOP ("Clone the current pattern"), Context::global, { chord ('C', ctrl | shift), chord ('C', alt) } },
- { "pattern.delete", TR_NOOP ("Delete the current pattern"), Context::global, { chord (del, ctrl | shift) } },
- { "pattern.moveUp", TR_NOOP ("Move the current pattern up"), Context::global, { chord (up, ctrl | shift) } },
- { "pattern.moveDown", TR_NOOP ("Move the current pattern down"), Context::global, { chord (down, ctrl | shift) } },
- // recording
- { "transport.record", TR_NOOP ("Recording on/off"), Context::global, { chord ('R') } },
- { "transport.metronome", TR_NOOP ("Metronome on/off"), Context::global, { chord ('M', ctrl) } },
- { "record.countIn", TR_NOOP ("Count-in before recording on/off"), Context::global, { chord ('P', ctrl) } },
- { "record.waitForInput", TR_NOOP ("Recording waits for the first note on/off"), Context::global, { chord ('I', ctrl) } },
- { "record.quickAudio", TR_NOOP ("Record audio now: arm the selected insert and record (press again to stop)"), Context::global, { chord ('R', shift) } },
- // files and history
- { "file.new", TR_NOOP ("New project"), Context::global, { chord ('N', ctrl) } },
- { "file.open", TR_NOOP ("Open project"), Context::global, { chord ('O', ctrl) } },
- { "file.save", TR_NOOP ("Save project"), Context::global, { chord ('S', ctrl) } },
- { "file.saveAs", TR_NOOP ("Save project as"), Context::global, { chord ('S', ctrl | shift) } },
- { "file.saveNewVersion", TR_NOOP ("Save new version (Song_2, Song_3...)"), Context::global, { chord ('S', ctrl | alt) } },
- { "file.export", TR_NOOP ("Export audio"), Context::global, { chord ('R', ctrl) } },
- { "file.exportMp3", TR_NOOP ("Export an MP3 file"), Context::global, { chord ('R', ctrl | shift) } },
- { "file.exportMidi", TR_NOOP ("Export a MIDI file"), Context::global, { chord ('M', ctrl | shift) } },
- // FL's File › Export › Master... (FileExportMasterAction, Ctrl+Alt+M; REA round 168e)
- { "file.exportMaster", TR_NOOP ("Export and master the project"), Context::global, { chord ('M', ctrl | alt) } },
- // FL's Tools › Consolidate playlist selection (EERenderPLSelectionLengthAction Ctrl+Alt+C, EEPLRenderSongLengthAction
- // Ctrl+Shift+Alt+C; REA round 168e)
- { "tools.consolidateSelection", TR_NOOP ("Consolidate playlist selection (from selection start)"), Context::global, { chord ('C', ctrl | alt) } },
- { "tools.consolidateSelectionSongStart", TR_NOOP ("Consolidate playlist selection (from song start)"), Context::global, { chord ('C', ctrl | shift | alt) } },
- { "edit.undo", TR_NOOP ("Undo"), Context::global, { chord ('Z', ctrl) } },
- // FL's Edit › "Undo backwards" (EditUndoBackwardsAction, Ctrl+Alt+Z; round 167k): one more step back
- { "edit.undoBackwards", TR_NOOP ("Undo backwards"), Context::global, { chord ('Z', ctrl | alt) } },
- { "edit.redo", TR_NOOP ("Redo"), Context::global, { chord ('Y', ctrl), chord ('Z', ctrl | shift) } },
- { "edit.history", TR_NOOP ("Undo history"), Context::global, { chord ('H', ctrl) } },
- { "help.shortcuts", TR_NOOP ("Shortcut sheet (press again to close)"), Context::global, { chord (f1) } },
- { "browser.search", TR_NOOP ("Search the Browser"), Context::global, { chord ('F', ctrl) } },
- // Channel Rack (focused)
- { "rack.selectPrevious", TR_NOOP ("Select the channel above"), Context::channelRack, { chord (up) } },
- { "rack.selectNext", TR_NOOP ("Select the channel below"), Context::channelRack, { chord (down) } },
- { "rack.extendUp", TR_NOOP ("Extend the selection up"), Context::channelRack, { chord (up, shift) } },
- { "rack.extendDown", TR_NOOP ("Extend the selection down"), Context::channelRack, { chord (down, shift) } },
- { "rack.moveUp", TR_NOOP ("Move the selected channels up"), Context::channelRack, { chord (up, alt) } },
- { "rack.moveDown", TR_NOOP ("Move the selected channels down"), Context::channelRack, { chord (down, alt) } },
- { "rack.selectAll", TR_NOOP ("Select all channels"), Context::channelRack, { chord ('A', ctrl) } },
- { "rack.clone", TR_NOOP ("Clone the selected channels"), Context::channelRack, { chord ('C', alt) } },
- { "rack.deleteSelected", TR_NOOP ("Delete the selected channels"), Context::channelRack, { chord (del, alt) } },
- { "rack.sendToInserts", TR_NOOP ("Send the selected channels to free mixer inserts"), Context::channelRack, { chord ('L', ctrl) } },
- { "rack.graphEditor", TR_NOOP ("Step graph lanes on/off"), Context::channelRack, { chord ('K', ctrl) } },
- { "rack.pianoRollView", TR_NOOP ("Piano-roll view of all channels on/off"), Context::channelRack, {} },
- { "rack.follow", TR_NOOP ("Follow the playhead (page along with the playing step) on/off"), Context::channelRack, {} },
- { "rack.groupSelected", TR_NOOP ("Put the selected channels in a new filter group"), Context::channelRack, { chord ('G', alt) } },
- { "rack.rotateLeft", TR_NOOP ("Rotate the selected channels' steps left"), Context::channelRack, { chord (left, ctrl | shift) } },
- { "rack.rotateRight", TR_NOOP ("Rotate the selected channels' steps right"), Context::channelRack, { chord (right, ctrl | shift) } },
- // Piano Roll (focused): tool dialogs and zoom
- { "pianoRoll.arpeggiate", TR_NOOP ("Arpeggiate..."), Context::pianoRoll, { chord ('A', alt) } },
- { "pianoRoll.strum", TR_NOOP ("Strum..."), Context::pianoRoll, { chord ('S', alt) } },
- { "pianoRoll.flip", TR_NOOP ("Flip..."), Context::pianoRoll, { chord ('Y', alt) } },
- { "pianoRoll.randomise", TR_NOOP ("Randomise..."), Context::pianoRoll, { chord ('R', alt) } },
- { "pianoRoll.scaleLevels", TR_NOOP ("Scale levels..."), Context::pianoRoll, { chord ('X', alt) } },
- { "pianoRoll.limit", TR_NOOP ("Limit to a range..."), Context::pianoRoll, { chord ('K', alt) } },
- // the other tools with FL's keys (REA round 143: the piano roll Tools menu)
- { "pianoRoll.quantize", TR_NOOP ("Quantize..."), Context::pianoRoll, { chord ('Q', alt) } },
- { "pianoRoll.chop", TR_NOOP ("Chop..."), Context::pianoRoll, { chord ('U', alt) } },
- { "pianoRoll.flam", TR_NOOP ("Flam..."), Context::pianoRoll, { chord ('F', alt) } },
- { "pianoRoll.claw", TR_NOOP ("Claw machine..."), Context::pianoRoll, { chord ('W', alt) } },
- { "pianoRoll.lfo", TR_NOOP ("LFO..."), Context::pianoRoll, { chord ('O', alt) } },
- { "pianoRoll.articulate", TR_NOOP ("Articulate..."), Context::pianoRoll, { chord ('L', alt) } },
- { "pianoRoll.riffMachine", TR_NOOP ("Riff machine..."), Context::pianoRoll, { chord ('E', alt) } },
- { "pianoRoll.chordProgression", TR_NOOP ("Generate chord progression..."), Context::pianoRoll, { chord ('P', alt) } },
- // note colours and the Select menu (REA round 153: FL's keys from its piano roll manual)
- { "pianoRoll.colourSelected", TR_NOOP ("Colour the selected notes with the note colour"), Context::pianoRoll, { chord ('C', alt) } },
- { "pianoRoll.selectByColour", TR_NOOP ("Select the notes of the same colour"), Context::pianoRoll, { chord ('C', shift) } },
- { "pianoRoll.invertSelection", TR_NOOP ("Invert the note selection"), Context::pianoRoll, { chord ('I', shift) } },
- { "pianoRoll.groupNotes", TR_NOOP ("Group the selected notes"), Context::pianoRoll, { chord ('G', shift) } },
- { "pianoRoll.ungroupNotes", TR_NOOP ("Ungroup the selected notes"), Context::pianoRoll, { chord ('G', alt) } },
- { "pianoRoll.zoomIn", TR_NOOP ("Zoom in"), Context::pianoRoll, { chord (pageUp) } },
- { "pianoRoll.zoomOut", TR_NOOP ("Zoom out"), Context::pianoRoll, { chord (pageDown) } },
- { "pianoRoll.zoom1", TR_NOOP ("Zoom: one bar"), Context::pianoRoll, { chord ('1', shift) }, true },
- { "pianoRoll.zoom2", TR_NOOP ("Zoom: four bars"), Context::pianoRoll, { chord ('2', shift) }, true },
- { "pianoRoll.zoom3", TR_NOOP ("Zoom: sixteen bars"), Context::pianoRoll, { chord ('3', shift) }, true },
- { "pianoRoll.zoomAll", TR_NOOP ("Zoom to show everything"), Context::pianoRoll, { chord ('4', shift) }, true },
- { "pianoRoll.zoomSelection", TR_NOOP ("Zoom to the selection"), Context::pianoRoll, { chord ('5', shift) }, true },
- { "pianoRoll.centrePlayhead", TR_NOOP ("Centre the view on the playhead"), Context::pianoRoll, { chord ('0', shift) }, true },
- // quick quantize (round 162, issue #9): FL's Ctrl+Q / Shift+Q, plus a 50% one to give a key of your own
- { "pianoRoll.quickQuantize", TR_NOOP ("Quick quantize (starts and lengths)"), Context::pianoRoll, { chord ('Q', ctrl) } },
- { "pianoRoll.quantizeStarts", TR_NOOP ("Quantize starts"), Context::pianoRoll, { chord ('Q', shift) }, true },
- { "pianoRoll.quantizeHalf", TR_NOOP ("Quantize starts 50% (halfway to the grid)"), Context::pianoRoll, {} },
- { "pianoRoll.follow", TR_NOOP ("Follow the playhead (auto scrolling) on/off"), Context::pianoRoll, {} },
- // FL's Piano roll menu (round 168g, REA_rodada168g.md: the ShortcutsModule / EEMenu keys): View, Select, Stamp,
- // Edit and File items
- { "pianoRoll.gridHighlights", TR_NOOP ("Note grid highlights on/off"), Context::pianoRoll, { chord ('B', alt) } },
- { "pianoRoll.backgroundWave", TR_NOOP ("Background waveform on/off"), Context::pianoRoll, { chord ('N', alt) } },
- { "pianoRoll.showChordName", TR_NOOP ("Show chord name for selection on/off"), Context::pianoRoll, {} },
- { "pianoRoll.selectRandomOne", TR_NOOP ("Select one at random"), Context::pianoRoll, { chord ('R', shift) }, true },
- { "pianoRoll.selectRandomMore", TR_NOOP ("Select more at random"), Context::pianoRoll, { chord ('M', shift) }, true },
- { "pianoRoll.selectOddSteps", TR_NOOP ("Select odd (swung) notes"), Context::pianoRoll, { chord ('O', shift) }, true },
- { "pianoRoll.stampNone", TR_NOOP ("Stamp: none (single notes)"), Context::pianoRoll, { chord ('N', shift) }, true },
- { "pianoRoll.insertSpace", TR_NOOP ("Insert space (the time selection)"), Context::pianoRoll, { chord (insert, ctrl) } },
- { "pianoRoll.sliceInsertSpace", TR_NOOP ("Slice & insert space"), Context::pianoRoll, { chord (insert, ctrl | alt) } },
- { "pianoRoll.deleteSpace", TR_NOOP ("Delete space (the time selection)"), Context::pianoRoll, { chord (del, ctrl) } },
- { "pianoRoll.trimSpace", TR_NOOP ("Trim to the time selection"), Context::pianoRoll, {} },
- { "pianoRoll.deleteAll", TR_NOOP ("Delete all the channel's notes"), Context::pianoRoll, {} },
- { "pianoRoll.insertControllerValue", TR_NOOP ("Insert current controller value"), Context::pianoRoll, { chord ('I', ctrl) } },
- { "pianoRoll.importMidi", TR_NOOP ("Import MIDI file..."), Context::pianoRoll, { chord ('M', ctrl) } },
- { "pianoRoll.exportMidi", TR_NOOP ("Export as MIDI file..."), Context::pianoRoll, { chord ('M', ctrl | shift) } },
- { "pianoRoll.pasteMidiClipboard", TR_NOOP ("Paste from MIDI clipboard..."), Context::pianoRoll, { chord ('V', ctrl | shift) } },
- { "pianoRoll.copyMidiClipboard", TR_NOOP ("Copy to MIDI clipboard"), Context::pianoRoll, {} },
- { "pianoRoll.openScore", TR_NOOP ("Open score..."), Context::pianoRoll, {} },
- { "pianoRoll.saveScore", TR_NOOP ("Save score as..."), Context::pianoRoll, {} },
- { "pianoRoll.browseScores", TR_NOOP ("Browse scores"), Context::pianoRoll, {} },
- // FL's Piano roll › Time markers: the same EEMarker* items as the Playlist's, on the pattern's markers (round 168g)
- { "pianoRoll.markerAdd", TR_NOOP ("Pattern time markers: Add one..."), Context::pianoRoll, { chord ('T', alt) } },
- { "pianoRoll.markerAuto", TR_NOOP ("Pattern time markers: Add auto"), Context::pianoRoll, { chord ('T', ctrl) } },
- { "pianoRoll.markerSignature", TR_NOOP ("Pattern time markers: Add time signature change..."), Context::pianoRoll, { chord ('T', shift | alt) } },
- // the tools and the other single letters (FL's keys; issue #12: they were fixed in the editor and won over a
- // global shortcut given the same key)
- { "pianoRoll.tool.pencil", TR_NOOP ("Tool: Pencil"), Context::pianoRoll, { chord ('P') } },
- { "pianoRoll.tool.brush", TR_NOOP ("Tool: Brush"), Context::pianoRoll, { chord ('B') } },
- { "pianoRoll.tool.drumPaint", TR_NOOP ("Tool: Drum brush"), Context::pianoRoll, { chord ('N') } },
- { "pianoRoll.tool.eraser", TR_NOOP ("Tool: Eraser"), Context::pianoRoll, { chord ('D') } },
- { "pianoRoll.tool.mute", TR_NOOP ("Tool: Mute"), Context::pianoRoll, { chord ('T') } },
- { "pianoRoll.tool.knife", TR_NOOP ("Tool: Knife"), Context::pianoRoll, { chord ('C') } },
- { "pianoRoll.tool.lasso", TR_NOOP ("Tool: Lasso (select)"), Context::pianoRoll, { chord ('E') } },
- { "pianoRoll.tool.zoom", TR_NOOP ("Tool: Zoom"), Context::pianoRoll, { chord ('Z') } },
- { "pianoRoll.tool.listen", TR_NOOP ("Tool: Listen"), Context::pianoRoll, { chord ('Y') } },
- { "pianoRoll.slide", TR_NOOP ("Slide notes on/off (new notes)"), Context::pianoRoll, { chord ('S') } },
- { "pianoRoll.previousChannel", TR_NOOP ("Previous channel"), Context::pianoRoll, { chord ('G') } },
- { "pianoRoll.nextChannel", TR_NOOP ("Next channel"), Context::pianoRoll, { chord ('K') } },
- { "pianoRoll.previousChannelWithNotes", TR_NOOP ("Previous channel with notes"), Context::pianoRoll, { chord ('H') } },
- { "pianoRoll.nextChannelWithNotes", TR_NOOP ("Next channel with notes"), Context::pianoRoll, { chord ('J') } },
- // Playlist (focused)
- { "playlist.zoomIn", TR_NOOP ("Zoom in"), Context::playlist, { chord (pageUp) } },
- { "playlist.zoomOut", TR_NOOP ("Zoom out"), Context::playlist, { chord (pageDown) } },
- { "playlist.zoom1", TR_NOOP ("Zoom: one bar"), Context::playlist, { chord ('1', shift) }, true },
- { "playlist.zoom2", TR_NOOP ("Zoom: four bars"), Context::playlist, { chord ('2', shift) }, true },
- { "playlist.zoom3", TR_NOOP ("Zoom: sixteen bars"), Context::playlist, { chord ('3', shift) }, true },
- { "playlist.zoomAll", TR_NOOP ("Zoom to show everything"), Context::playlist, { chord ('4', shift) }, true },
- { "playlist.zoomSelection", TR_NOOP ("Zoom to the selection"), Context::playlist, { chord ('5', shift) }, true },
- { "playlist.centrePlayhead", TR_NOOP ("Centre the view on the playhead"), Context::playlist, { chord ('0', shift) }, true },
- { "playlist.rippleDelete", TR_NOOP ("Delete the selected clips and close the gaps"), Context::playlist, { chord (del, shift) } },
- { "playlist.ripple", TR_NOOP ("Ripple editing on/off"), Context::playlist, { chord ('S', shift) } },
- // FL's Playlist › Edit › "Automatic crossfades (current project)" (round 166e)
- { "playlist.autoCrossfades", TR_NOOP ("Automatic crossfades (current project) on/off"), Context::playlist, {} },
- // FL's Select › time (round 167k: EESelAroundSelAction, EESelPrevAction / EESelNextAction, Playlist focused)
- { "playlist.selectTimeAround", TR_NOOP ("Select time around selection"), Context::playlist, { chord (enter, ctrl) } },
- { "playlist.timePrevious", TR_NOOP ("Select previous time"), Context::playlist, { chord (left, ctrl) } },
- { "playlist.timeNext", TR_NOOP ("Select next time"), Context::playlist, { chord (right, ctrl) } },
- // FL 2026's Playlist › Time markers (round 167k: EEMarkerAdd2Menu 32852, EEMarkerAddAutoMenu 16468,
- // EEMarkerAddTSChangeMenu 41044, EEMarkerAddSongLoopMenu 8276); Ctrl+T stays the typing piano elsewhere
- { "playlist.markerAdd", TR_NOOP ("Time markers: Add one..."), Context::playlist, { chord ('T', alt) } },
- { "playlist.markerAuto", TR_NOOP ("Time markers: Add auto"), Context::playlist, { chord ('T', ctrl) } },
- { "playlist.markerSignature", TR_NOOP ("Time markers: Add time signature change..."), Context::playlist, { chord ('T', shift | alt) } },
- { "playlist.markerLoop", TR_NOOP ("Time markers: Place loop"), Context::playlist, { chord ('T', shift) } },
- // FL 2026's Playlist › Edit (round 167k: EEPitchSelectedAudioClipsDown/UpAction, EEReverseSelectedAudioClipsAction)
- { "playlist.pitchClipsDown", TR_NOOP ("Pitch selected audio clips one semitone down"), Context::playlist, { chord ('7') } },
- { "playlist.pitchClipsUp", TR_NOOP ("Pitch selected audio clips one semitone up"), Context::playlist, { chord ('8') } },
- { "playlist.reverseClips", TR_NOOP ("Reverse selected audio clips"), Context::playlist, { chord ('9') } },
- { "playlist.quantizeStarts", TR_NOOP ("Quantize the clips' starts"), Context::playlist, { chord ('Q', ctrl) } },
- { "playlist.quantizeHalf", TR_NOOP ("Quantize the clips' starts 50% (halfway to the grid)"), Context::playlist, {} },
- { "playlist.follow", TR_NOOP ("Follow the playhead (auto scrolling) on/off"), Context::playlist, {} },
- { "playlist.tool.pencil", TR_NOOP ("Tool: Pencil"), Context::playlist, { chord ('P') } },
- { "playlist.tool.brush", TR_NOOP ("Tool: Brush"), Context::playlist, { chord ('B') } },
- { "playlist.tool.eraser", TR_NOOP ("Tool: Eraser"), Context::playlist, { chord ('D') } },
- { "playlist.tool.mute", TR_NOOP ("Tool: Mute"), Context::playlist, { chord ('T') } },
- { "playlist.tool.knife", TR_NOOP ("Tool: Knife"), Context::playlist, { chord ('C') } },
- { "playlist.tool.lasso", TR_NOOP ("Tool: Lasso (select)"), Context::playlist, { chord ('E') } },
- { "playlist.tool.zoom", TR_NOOP ("Tool: Zoom"), Context::playlist, { chord ('Z') } },
- { "playlist.tool.listen", TR_NOOP ("Tool: Listen"), Context::playlist, { chord ('Y') } },
- { "playlist.tool.slip", TR_NOOP ("Tool: Slip"), Context::playlist, { chord ('S') } },
- // FL's Performance mode (round 165m; Ctrl+P on FL's Playlist menu [DFM])
- { "playlist.performanceMode", TR_NOOP ("Performance mode on/off (launch the clips before the Start marker)"), Context::playlist, { chord ('P', ctrl) } },
- { "playlist.zoomPerformance", TR_NOOP ("Zoom on the performance clips"), Context::playlist, { chord ('6', shift) }, true },
- { "playlist.perfClipProgress", TR_NOOP ("Show the performance clips' progress"), Context::playlist, {} },
- { "playlist.perfTrackProgress", TR_NOOP ("Show the performance tracks' progress"), Context::playlist, {} },
- // round 168f: FL's Playlist keys and menu items ([DFM ShortcutsModule] EEMergeAction Ctrl+G, EEClonePLTracksAction
- // Ctrl+Shift+B, EEMakeUniqueAction Ctrl+Shift+V; the STRETCH button's hint "Shift+M")
- { "playlist.mergePatternClips", TR_NOOP ("Merge pattern clips"), Context::playlist, { chord ('G', ctrl) } },
- { "playlist.cloneTracks", TR_NOOP ("Clone selected playlist track(s)"), Context::playlist, { chord ('B', ctrl | shift) } },
- { "playlist.makeUnique", TR_NOOP ("Make the selected clips unique"), Context::playlist, { chord ('V', ctrl | shift) } },
- // FL's Alt+M / Shift+Alt+M (EEMuteAction / EEUnmuteAction, issue #53): the selected clips, or all of them
- { "playlist.muteClips", TR_NOOP ("Mute the selected clips (all when none is selected)"), Context::playlist, { chord ('M', alt) } },
- { "playlist.unmuteClips", TR_NOOP ("Unmute the selected clips (all when none is selected)"), Context::playlist, { chord ('M', shift | alt) } },
- { "playlist.stretchMode", TR_NOOP ("Stretch audio when resizing audio clips on/off"), Context::playlist, { chord ('M', shift) } },
- { "playlist.createVariants", TR_NOOP ("Create variants when stretching audio clips on/off"), Context::playlist, {} },
- { "playlist.lockAllToContent", TR_NOOP ("Lock all playlist tracks to content"), Context::playlist, {} },
- { "playlist.unlockAllFromContent", TR_NOOP ("Unlock all playlist tracks from content"), Context::playlist, {} },
- { "playlist.resetEmptyTracks", TR_NOOP ("Reset empty playlist tracks"), Context::playlist, {} },
- { "playlist.collapseAllGroups", TR_NOOP ("Collapse all grouped tracks"), Context::playlist, {} },
- { "playlist.expandAllGroups", TR_NOOP ("Expand all grouped tracks"), Context::playlist, {} },
- { "playlist.purgeUnusedAudio", TR_NOOP ("Purge unused audio clips"), Context::playlist, {} },
- // Browser (focused)
- { "browser.previous", TR_NOOP ("Previous file (preview)"), Context::browser, { chord (up) } },
- { "browser.next", TR_NOOP ("Next file (preview)"), Context::browser, { chord (down) } },
- { "browser.swapPrevious", TR_NOOP ("Previous file into the selected channel"), Context::browser, { chord (up, shift) } },
- { "browser.swapNext", TR_NOOP ("Next file into the selected channel"), Context::browser, { chord (down, shift) } },
- { "browser.load", TR_NOOP ("Load the file into the selected channel"), Context::browser, { chord (enter) } },
- { "browser.closeFolder", TR_NOOP ("Close the folder (or go to the parent folder)"), Context::browser, { chord (left) } },
- { "browser.openFolder", TR_NOOP ("Open the folder"), Context::browser, { chord (right) } },
- { "browser.rename", TR_NOOP ("Rename the selected plugin (Plugin database)"), Context::browser, { chord (f2) } },
- // Mixer (focused)
- { "mixer.moveLeft", TR_NOOP ("Move the selected inserts left"), Context::mixer, { chord (left, alt) } },
- { "mixer.moveRight", TR_NOOP ("Move the selected inserts right"), Context::mixer, { chord (right, alt) } },
- { "mixer.linkChannels", TR_NOOP ("Link the selected channels to the selected insert"), Context::mixer, { chord ('L', ctrl) } },
- { "mixer.linkChannelsFrom", TR_NOOP ("Link the selected channels to inserts starting from the selected one"), Context::mixer, { chord ('L', ctrl | shift) } },
- { "mixer.selectLinkedChannels", TR_NOOP ("Select the channels linked to the selected insert"), Context::mixer, { chord ('L', alt) } },
- // FL's mixer track menu keys (round 167k, the DFM's ShortCut values: F2, S, Alt+R, Shift+Alt+R)
- { "mixer.rename", TR_NOOP ("Rename and color the selected mixer track"), Context::mixer, { chord (f2) } },
- { "mixer.soloSelected", TR_NOOP ("Solo the selected mixer track(s)"), Context::mixer, { chord ('S') } },
- { "mixer.altSoloSelected", TR_NOOP ("Alt solo the selected mixer track(s) (with the tracks that feed them)"), Context::mixer, { chord ('S', alt) } },
- { "mixer.renderArmed", TR_NOOP ("Disk recording: render the armed tracks to wave file(s)"), Context::mixer, { chord ('R', alt) } },
- { "mixer.renderSelected", TR_NOOP ("Disk recording: render the selected tracks to wave file(s)"), Context::mixer, { chord ('R', shift | alt) } },
- { "mixer.deleteEffect", TR_NOOP ("Delete the selected effect slot's plugin"), Context::mixer, { chord (del) } },
- };
- // numeric keypad 1-9: select patterns 1-9
- static const char* patternIds[] = { "pattern.select1", "pattern.select2", "pattern.select3", "pattern.select4", "pattern.select5",
- "pattern.select6", "pattern.select7", "pattern.select8", "pattern.select9" };
- for (int i = 0; i < 9; ++i)
- list.push_back ({ patternIds[i], TR_NOOP ("Select pattern {0}"), Context::global, { chord (numpad1 + i) } });
- // number keys: mute (plain) / solo (Ctrl) channels 1-10 while the rack has focus
- static const char* muteIds[] = { "rack.mute1", "rack.mute2", "rack.mute3", "rack.mute4", "rack.mute5",
- "rack.mute6", "rack.mute7", "rack.mute8", "rack.mute9", "rack.mute10" };
- static const char* soloIds[] = { "rack.solo1", "rack.solo2", "rack.solo3", "rack.solo4", "rack.solo5",
- "rack.solo6", "rack.solo7", "rack.solo8", "rack.solo9", "rack.solo10" };
- for (int i = 0; i < 10; ++i)
- {
- const auto digit = i == 9 ? '0' : (char) ('1' + i);
- list.push_back ({ muteIds[i], TR_NOOP ("Mute or unmute channel {0}"), Context::channelRack, { chord (digit) } });
- list.push_back ({ soloIds[i], TR_NOOP ("Solo channel {0}"), Context::channelRack, { chord (digit, ctrl) } });
- }
- return list;
- }
- bool contextsOverlap (Context a, Context b)
- {
- return a == b;
- }
- // --- tiny JSON reader for {"id": "chord" | ["chord", ...], ...} ---------------------------------
- struct Json
- {
- const std::string& s;
- std::size_t i = 0;
- void skip()
- {
- while (i < s.size() && std::isspace ((unsigned char) s[i]))
- ++i;
- }
- bool eat (char c)
- {
- skip();
- if (i < s.size() && s[i] == c)
- {
- ++i;
- return true;
- }
- return false;
- }
- std::optional<std::string> string()
- {
- skip();
- if (i >= s.size() || s[i] != '"')
- return std::nullopt;
- std::string out;
- for (++i; i < s.size(); ++i)
- {
- const auto c = s[i];
- if (c == '"')
- {
- ++i;
- return out;
- }
- if (c == '\\' && i + 1 < s.size())
- {
- const auto n = s[++i];
- out += n == 'n' ? '\n' : n == 't' ? '\t' : n;
- }
- else
- out += c;
- }
- return std::nullopt;
- }
- };
- } // namespace
- bool Chord::isPrintable() const noexcept
- {
- return key > ' ' && key < 0x7f;
- }
- std::string displayString (const Chord& c)
- {
- return modmap::keyNames (toString (c), modmap::hostOs());
- }
- std::string toString (const Chord& c)
- {
- std::string out;
- if (c.mods & ctrl)
- out += "Ctrl+";
- if (c.mods & shift)
- out += "Shift+";
- if (c.mods & alt)
- out += "Alt+";
- if (c.key >= f1 && c.key <= f12)
- return out + "F" + std::to_string (c.key - f1 + 1);
- for (const auto& k : keyNames)
- if (k.key == c.key)
- return out + k.name;
- if (c.isPrintable())
- return out + std::string (1, (char) c.key);
- return out + "?";
- }
- std::optional<Chord> parseChord (const std::string& text)
- {
- auto rest = trim (text);
- Chord c;
- // modifiers first ("+" alone, or "Numpad +", is a key, so only split on "+" followed by more text)
- for (;;)
- {
- const auto l = lower (rest);
- auto take = [&] (const char* prefix, std::uint8_t mod) {
- const std::string p (prefix);
- if (l.size() > p.size() && l.compare (0, p.size(), p) == 0)
- {
- c.mods |= mod;
- rest = trim (rest.substr (p.size()));
- return true;
- }
- return false;
- };
- if (! (take ("ctrl+", ctrl) || take ("shift+", shift) || take ("alt+", alt)))
- break;
- }
- const auto name = lower (rest);
- if (name.empty())
- return std::nullopt;
- if (name.size() >= 2 && name[0] == 'f' && std::all_of (name.begin() + 1, name.end(), [] (char ch) { return std::isdigit ((unsigned char) ch); }))
- {
- const auto n = std::stoi (name.substr (1));
- if (n < 1 || n > 12)
- return std::nullopt;
- c.key = f1 + n - 1;
- return c;
- }
- for (const auto& k : keyNames)
- if (lower (k.name) == name)
- {
- c.key = k.key;
- return c;
- }
- if (name == "del")
- c.key = del;
- else if (name == "ins")
- c.key = insert;
- else if (name == "escape")
- c.key = escape;
- else if (name == "return")
- c.key = enter;
- else if (rest.size() == 1 && rest[0] > ' ' && rest[0] < 0x7f)
- c.key = std::toupper ((unsigned char) rest[0]);
- else
- return std::nullopt;
- return c;
- }
- const std::vector<Action>& actions()
- {
- static const auto list = makeActions();
- return list;
- }
- const Action* findAction (const std::string& id)
- {
- for (const auto& a : actions())
- if (id == a.id)
- return &a;
- return nullptr;
- }
- int typingPianoNote (int key, int octave, int root) noexcept
- {
- const auto base = 12 * typingpiano::clampOctave (octave) + typingpiano::clampRoot (root); // octave 4 -> 48
- const auto inRange = [] (int n) { return n >= 0 && n <= 127 ? n : -1; };
- static const char lowerRow[] = "ZSXDCVGBHNJM";
- static const char upperRow[] = "Q2W3ER5T6Y7UI9O0P";
- const auto c = key >= 'a' && key <= 'z' ? key - 'a' + 'A' : key;
- for (int i = 0; lowerRow[i] != 0; ++i)
- if (lowerRow[i] == c)
- return inRange (base + i);
- for (int i = 0; upperRow[i] != 0; ++i)
- if (upperRow[i] == c)
- return inRange (base + 12 + i);
- return -1;
- }
- KeyMap::KeyMap()
- {
- resetToDefaults();
- }
- void KeyMap::resetToDefaults()
- {
- chords.clear();
- for (const auto& a : actions())
- chords.push_back (a.defaults);
- }
- bool KeyMap::playsNote (const Chord& c, bool typingPiano) noexcept
- {
- return typingPiano && (c.mods & (ctrl | alt | shift)) == 0 && typingPianoNote (c.key) >= 0;
- }
- std::string KeyMap::findFromSecondaryWindow (const Chord& c, bool typingIntoText, bool typingPiano) const
- {
- if (! c.isValid() || c.key == escape) // (Esc closes the window)
- return {};
- const auto editingKey = c.isPrintable() || c.key == space || c.key == enter || c.key == tab || c.key == backspace || c.key == del
- || c.key == insert || (c.key >= up && c.key <= end);
- if (typingIntoText && editingKey && (c.mods & (ctrl | alt)) == 0)
- return {};
- if (auto own = findUserBound (c, Context::global, typingPiano); ! own.empty())
- return own;
- return find (c, Context::global, typingPiano);
- }
- std::string KeyMap::findUserBound (const Chord& c, Context focus, bool typingPiano) const
- {
- if (! c.isValid() || playsNote (c, typingPiano))
- return {};
- const auto plainPrintable = c.isPrintable() && (c.mods & (ctrl | alt)) == 0;
- const auto& list = actions();
- const Action* globalMatch = nullptr;
- for (std::size_t i = 0; i < list.size(); ++i)
- {
- const auto& a = list[i];
- if ((a.context != Context::global && a.context != focus) || chords[i] == a.defaults)
- continue;
- if (std::find (chords[i].begin(), chords[i].end(), c) == chords[i].end()
- || std::find (a.defaults.begin(), a.defaults.end(), c) != a.defaults.end())
- continue; // (a default key keeps its usual priority)
- if (typingPiano && plainPrintable && ! a.whilePiano)
- continue;
- if (a.context == focus && focus != Context::global)
- return a.id;
- if (globalMatch == nullptr)
- globalMatch = &a;
- }
- return globalMatch != nullptr ? globalMatch->id : std::string();
- }
- std::vector<std::string> KeyMap::shadowedBy (const Chord& c, const std::string& actionId) const
- {
- std::vector<std::string> out;
- const auto* owner = findAction (actionId);
- if (owner == nullptr || ! c.isValid())
- return out;
- const auto& list = actions();
- for (std::size_t i = 0; i < list.size(); ++i)
- {
- const auto& a = list[i];
- if (actionId == a.id || a.context == owner->context)
- continue;
- if (owner->context != Context::global && a.context != Context::global)
- continue; // two different panels never meet
- if (std::find (chords[i].begin(), chords[i].end(), c) != chords[i].end())
- out.push_back (a.id);
- }
- return out;
- }
- std::string KeyMap::find (const Chord& c, Context focus, bool typingPiano) const
- {
- if (! c.isValid() || playsNote (c, typingPiano))
- return {};
- const auto plainPrintable = c.isPrintable() && (c.mods & (ctrl | alt)) == 0;
- const auto& list = actions();
- const Action* globalMatch = nullptr;
- for (std::size_t i = 0; i < list.size(); ++i)
- {
- const auto& a = list[i];
- if (a.context != Context::global && a.context != focus)
- continue;
- if (std::find (chords[i].begin(), chords[i].end(), c) == chords[i].end())
- continue;
- if (typingPiano && plainPrintable && ! a.whilePiano)
- continue;
- if (a.context == focus && focus != Context::global)
- return a.id; // the focused panel wins
- if (globalMatch == nullptr)
- globalMatch = &a;
- }
- return globalMatch != nullptr ? globalMatch->id : std::string();
- }
- const std::vector<Chord>& KeyMap::chordsFor (const std::string& actionId) const
- {
- static const std::vector<Chord> empty;
- const auto& list = actions();
- for (std::size_t i = 0; i < list.size(); ++i)
- if (actionId == list[i].id)
- return chords[i];
- return empty;
- }
- void KeyMap::setChords (const std::string& actionId, std::vector<Chord> newChords)
- {
- const auto& list = actions();
- for (std::size_t i = 0; i < list.size(); ++i)
- if (actionId == list[i].id)
- chords[i] = std::move (newChords);
- }
- bool KeyMap::loadJson (const std::string& json, std::vector<std::string>* errors)
- {
- Json p { json };
- auto fail = [&] (const std::string& message) {
- if (errors != nullptr)
- errors->push_back (message);
- };
- if (! p.eat ('{'))
- return false;
- if (p.eat ('}'))
- return true;
- for (;;)
- {
- const auto id = p.string();
- if (! id || ! p.eat (':'))
- return false;
- std::vector<std::string> values;
- if (p.eat ('['))
- {
- if (! p.eat (']'))
- for (;;)
- {
- const auto v = p.string();
- if (! v)
- return false;
- values.push_back (*v);
- if (p.eat (']'))
- break;
- if (! p.eat (','))
- return false;
- }
- }
- else if (const auto v = p.string())
- {
- if (! trim (*v).empty())
- values.push_back (*v);
- }
- else
- return false;
- if (findAction (*id) == nullptr)
- fail ("unknown action: " + *id);
- else
- {
- std::vector<Chord> parsed;
- for (const auto& v : values)
- if (const auto c = parseChord (v))
- parsed.push_back (*c);
- else
- fail ("unreadable key for " + *id + ": " + v);
- setChords (*id, parsed);
- }
- if (p.eat ('}'))
- return true;
- if (! p.eat (','))
- return false;
- }
- }
- std::string KeyMap::toJson() const
- {
- std::string out = "{\n";
- const auto& list = actions();
- for (std::size_t i = 0; i < list.size(); ++i)
- {
- out += " \"" + std::string (list[i].id) + "\": [";
- for (std::size_t k = 0; k < chords[i].size(); ++k)
- out += (k > 0 ? ", \"" : "\"") + toString (chords[i][k]) + "\"";
- out += i + 1 < list.size() ? "],\n" : "]\n";
- }
- return out + "}\n";
- }
- std::vector<KeyMap::Binding> KeyMap::functionKeyBindings() const
- {
- std::vector<Binding> out;
- const auto& list = actions();
- for (std::size_t i = 0; i < list.size(); ++i)
- for (const auto& c : chords[i])
- if (c.key >= f1 && c.key <= f12)
- out.push_back ({ c, list[i].id, list[i].context });
- // plain, Shift, Ctrl, Alt, then the combinations; global before a panel's own
- auto modRank = [] (std::uint8_t m) {
- switch (m)
- {
- case none: return 0;
- case shift: return 1;
- case ctrl: return 2;
- case alt: return 3;
- default: return 4 + (int) m;
- }
- };
- std::stable_sort (out.begin(), out.end(), [&] (const Binding& a, const Binding& b) {
- if (a.chord.key != b.chord.key)
- return a.chord.key < b.chord.key;
- if (a.chord.mods != b.chord.mods)
- return modRank (a.chord.mods) < modRank (b.chord.mods);
- return (int) a.context < (int) b.context;
- });
- return out;
- }
- std::vector<std::pair<std::string, std::string>> KeyMap::conflicts() const
- {
- std::vector<std::pair<std::string, std::string>> out;
- const auto& list = actions();
- for (std::size_t a = 0; a < list.size(); ++a)
- for (std::size_t b = a + 1; b < list.size(); ++b)
- {
- if (! contextsOverlap (list[a].context, list[b].context))
- continue;
- for (const auto& c : chords[a])
- if (std::find (chords[b].begin(), chords[b].end(), c) != chords[b].end())
- {
- out.push_back ({ list[a].id, list[b].id });
- break;
- }
- }
- return out;
- }
- std::vector<std::string> KeyMap::actionsWith (const Chord& chord, Context context, const std::string& except) const
- {
- std::vector<std::string> out;
- const auto& list = actions();
- for (std::size_t i = 0; i < list.size(); ++i)
- if (list[i].context == context && except != list[i].id
- && std::find (chords[i].begin(), chords[i].end(), chord) != chords[i].end())
- out.push_back (list[i].id);
- return out;
- }
- bool KeyMap::isDefault (const std::string& actionId) const
- {
- const auto& list = actions();
- for (std::size_t i = 0; i < list.size(); ++i)
- if (actionId == list[i].id)
- return chords[i] == list[i].defaults;
- return true;
- }
- std::string KeyMap::overridesJson() const
- {
- std::string out = "{\n";
- const auto& list = actions();
- bool first = true;
- for (std::size_t i = 0; i < list.size(); ++i)
- {
- if (chords[i] == list[i].defaults)
- continue;
- out += first ? "" : ",\n";
- first = false;
- out += " \"" + std::string (list[i].id) + "\": [";
- for (std::size_t k = 0; k < chords[i].size(); ++k)
- out += (k > 0 ? ", \"" : "\"") + toString (chords[i][k]) + "\"";
- out += "]";
- }
- return out + (first ? "}\n" : "\n}\n");
- }
- } // namespace lynx::keys
|