git.iko.soy/rowtype-yoga/purescript-opencode
on main help sign in
85 lines 2.1 kB history raw
1module OpenCode.TUI
2 ( Context
3 , Plugin
4 , Route
5 , define
6 , renderer
7 , cwd
8 , themeMode
9 , mutedColor
10 , backgroundColor
11 , route
12 , observeRoute
13 , registerCommand
14 , mountSlot
15 , pushMode
16 , registerKeys
17 , notifyError
18 ) where
20import Data.Nullable (Nullable)
21import Effect (Effect)
22import Promise (Promise)
23import OpenTUI (Color, Renderable, Renderer)
24import Prelude (Unit)
26type Route =
27 { kind :: String
28 , sessionID :: Nullable String
29 }
31foreign import data Context :: Type
33foreign import data Plugin :: Type
35-- The host owns setup invocation and calls the cleanup effect returned by setup.
36foreign import define
37 :: { id :: String, setup :: Context -> Effect (Effect Unit) }
38 -> Plugin
40foreign import renderer :: Context -> Renderer
42foreign import cwd :: Context -> Effect String
44foreign import themeMode :: Context -> Effect String
46foreign import mutedColor :: Context -> Effect Color
48foreign import backgroundColor :: Context -> Effect Color
50foreign import route :: Context -> Effect Route
52-- The callback runs immediately and on later route changes. Run the returned cleanup
53-- to dispose its Solid root.
54foreign import observeRoute :: Context -> Effect Unit -> Effect (Effect Unit)
56foreign import registerCommand
57 :: Context
58 -> { id :: String
59 , title :: String
60 , description :: String
61 , group :: String
62 , name :: String
63 }
64 -> (Nullable String -> Effect (Promise Unit))
65 -> Effect Unit
67-- The returned cleanup unregisters the host slot claim. The slot callback creates
68-- the renderable and owns resources associated with it.
69foreign import mountSlot
70 :: Context
71 -> String
72 -> (Nullable String -> Effect (Nullable Renderable))
73 -> Effect (Effect Unit)
75-- Run the returned cleanup to pop precisely this mode stack entry.
76foreign import pushMode :: Context -> String -> Effect (Effect Unit)
78foreign import registerKeys
79 :: Context
80 -> Renderable
81 -> String
82 -> Array { id :: String, bind :: String, run :: Effect Unit }
83 -> Effect Unit
85foreign import notifyError :: Context -> String -> Effect Unit