module Cmd.NoteTrackKeymap where
import qualified Ui.Key as Key
import qualified Cmd.Cmd as Cmd
import qualified Cmd.Keymap as Keymap
import qualified Cmd.ModifyEvents as ModifyEvents
import qualified Derive.ParseTitle as ParseTitle
import Global
keymap :: Cmd.Keymap Cmd.CmdId
errors :: [Text]
(Keymap CmdId
keymap, [Text]
errors) = forall (m :: * -> *). [Binding m] -> (Keymap m, [Text])
Keymap.make_keymap forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall a b. (a -> b) -> a -> b
$
forall a b. (a -> b) -> [a] -> [b]
map forall {m :: * -> *}. M m => (Char, Text) -> [Binding m]
add_transform
[(Char
'.', Text
"."), (Char
'v', Text
"v"), (Char
'6', Text
"^"), (Char
'=', Text
"+"), (Char
'-', Text
"-")]
where
add_transform :: (Char, Text) -> [Binding m]
add_transform (Char
c, Text
name) = forall (m :: * -> *).
M m =>
[SimpleMod] -> Key -> Text -> m () -> [Binding m]
Keymap.bind_key [SimpleMod
Keymap.SecondaryCommand]
(Char -> Key
Key.Char Char
c) (Text
"add " forall a. Semigroup a => a -> a -> a
<> Text
name) (forall (m :: * -> *). M m => Text -> m ()
add_transform_generator Text
name)
add_transform_generator :: Cmd.M m => Text -> m ()
add_transform_generator :: forall (m :: * -> *). M m => Text -> m ()
add_transform_generator Text
text = do
forall (m :: * -> *). M m => Track m -> m ()
ModifyEvents.selection_visible forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *). M m => (Text -> Bool) -> Track m -> Track m
ModifyEvents.tracks_named Text -> Bool
ParseTitle.is_note_track forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *). Monad m => (Text -> Text) -> Track m
ModifyEvents.text forall a b. (a -> b) -> a -> b
$ ([[Text]] -> [[Text]]) -> Text -> Text
ModifyEvents.pipeline [[Text]] -> [[Text]]
add
forall (m :: * -> *). M m => m ()
ModifyEvents.advance_if_point
where
add :: [[Text]] -> [[Text]]
add [] = [[Text
text]]
add [[Text]]
calls
| [Text
text] forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [[Text]]
calls = [[Text]]
calls
| Bool
otherwise = [Text
text] forall a. a -> [a] -> [a]
: [[Text]]
calls