Skip to content

Commit

Permalink
add AppTrigger modifiers for prompt control
Browse files Browse the repository at this point in the history
  • Loading branch information
tek committed Oct 6, 2023
1 parent 67529f6 commit 45e77a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/menu/lib/Ribosome/Menu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ module Ribosome.Menu (
import Ribosome.Menu.Action (
MenuSem,
MenuWidget,
menuAttachPrompt,
menuCycle,
menuDetachPrompt,
menuIgnore,
menuOk,
menuQuit,
Expand All @@ -42,10 +44,18 @@ import Ribosome.Menu.Action (
menuToggleAll,
menuUpdatePrompt,
menuUpdatePromptState,
menuAttachPrompt,
menuDetachPrompt,
)
import Ribosome.Menu.App (MenuApp, PromptApp, builtinHandlers, defaultHandlers, insert, promptControl, withInsert)
import Ribosome.Menu.App (
MenuApp,
PromptApp,
builtinHandlers,
defaultHandlers,
insert,
notPrompt,
onlyPrompt,
promptControl,
withInsert,
)
import Ribosome.Menu.Data.Entry (Entries, Entry)
import Ribosome.Menu.Data.Filter
import Ribosome.Menu.Data.MenuAction
Expand Down
9 changes: 9 additions & 0 deletions packages/menu/lib/Ribosome/Menu/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ domain = #_AppMapping . _2
modesLens :: Traversal' AppTrigger (NonEmpty MapMode)
modesLens = domain . #modes

controlLens :: Traversal' AppTrigger (Maybe PromptControl)
controlLens = domain . #prompt

modifyModes :: (NonEmpty MapMode -> NonEmpty MapMode) -> AppTrigger -> AppTrigger
modifyModes f = modesLens %~ f

Expand All @@ -58,6 +61,12 @@ withInsert = withMode MapInsert
insert :: AppTrigger -> AppTrigger
insert = modesLens .~ [MapInsert]

onlyPrompt :: AppTrigger -> AppTrigger
onlyPrompt = controlLens ?~ PromptControlApp

notPrompt :: AppTrigger -> AppTrigger
notPrompt = controlLens ?~ PromptControlItems

type MenuApp s r result =
Map AppTrigger (MenuWidget s r result)

Expand Down

0 comments on commit 45e77a4

Please sign in to comment.