module Ribosome.Api.Tabpage where
import Exon (exon)
import Ribosome.Host.Api.Data (Tabpage)
import Ribosome.Host.Api.Effect (nvimTabpageGetNumber, tabpageIsValid, vimCommand)
import Ribosome.Host.Effect.Rpc (Rpc)
import Ribosome.Host.Modify (silentBang)
closeTabpage ::
Member Rpc r =>
Tabpage ->
Sem r ()
closeTabpage :: forall (r :: EffectRow). Member Rpc r => Tabpage -> Sem r ()
closeTabpage Tabpage
tabpage =
Sem r Bool -> Sem r () -> Sem r ()
forall (m :: * -> *). Monad m => m Bool -> m () -> m ()
whenM (Tabpage -> Sem r Bool
forall (r :: EffectRow). Member Rpc r => Tabpage -> Sem r Bool
tabpageIsValid Tabpage
tabpage) do
Int
number <- Tabpage -> Sem r Int
forall (r :: EffectRow). Member Rpc r => Tabpage -> Sem r Int
nvimTabpageGetNumber Tabpage
tabpage
Sem r () -> Sem r ()
forall (r :: EffectRow) a. Member Rpc r => Sem r a -> Sem r a
silentBang do
Text -> Sem r ()
forall (r :: EffectRow). Member Rpc r => Text -> Sem r ()
vimCommand [exon|tabclose! #{show number}|]