module Chiasma.Data.Target where import Chiasma.Class.CmdArgs (CmdArgs (cmdArgs)) import Chiasma.Data.TmuxId (PaneId, SessionId, WindowId, formatId) data Target = Pane PaneId | Window WindowId | Session SessionId | Current deriving stock (Target -> Target -> Bool (Target -> Target -> Bool) -> (Target -> Target -> Bool) -> Eq Target forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Target -> Target -> Bool == :: Target -> Target -> Bool $c/= :: Target -> Target -> Bool /= :: Target -> Target -> Bool Eq, Int -> Target -> ShowS [Target] -> ShowS Target -> String (Int -> Target -> ShowS) -> (Target -> String) -> ([Target] -> ShowS) -> Show Target forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> Target -> ShowS showsPrec :: Int -> Target -> ShowS $cshow :: Target -> String show :: Target -> String $cshowList :: [Target] -> ShowS showList :: [Target] -> ShowS Show) formatTarget :: [Text] -> Target -> [Text] formatTarget :: [Text] -> Target -> [Text] formatTarget [Text] pre = \case Pane PaneId i -> [Text] pre [Text] -> [Text] -> [Text] forall a. Semigroup a => a -> a -> a <> [PaneId -> Text forall a. TmuxId a => a -> Text formatId PaneId i] Window WindowId i -> [Text] pre [Text] -> [Text] -> [Text] forall a. Semigroup a => a -> a -> a <> [WindowId -> Text forall a. TmuxId a => a -> Text formatId WindowId i] Session SessionId i -> [Text] pre [Text] -> [Text] -> [Text] forall a. Semigroup a => a -> a -> a <> [SessionId -> Text forall a. TmuxId a => a -> Text formatId SessionId i] Target Current -> [] instance CmdArgs Target where cmdArgs :: Target -> [Text] cmdArgs = \case Pane PaneId i -> [Text Item [Text] "-t", PaneId -> Text forall a. TmuxId a => a -> Text formatId PaneId i] Window WindowId i -> [Text Item [Text] "-t", WindowId -> Text forall a. TmuxId a => a -> Text formatId WindowId i] Session SessionId i -> [Text Item [Text] "-t", SessionId -> Text forall a. TmuxId a => a -> Text formatId SessionId i] Target Current -> [] instance Default Target where def :: Target def = Target Current