Safe Haskell | Safe-Inferred |
---|
Define the protocol between the sequencer's repl port and the repl client.
Synopsis
- data Query
- data NotifySeq
- data Response
- = RSaveFile !(Maybe IO.FilePath)
- | RCommand !CmdResult
- | RCompletion ![Text]
- data CmdResult = CmdResult !Result ![Log.Msg]
- data Result
- data Editor = Editor {}
- data File
- = FileName !IO.FilePath
- | Text !FileType !Text
- data FileType
- file_type_extension :: FileType -> String
- empty_result :: Result
- error_result :: Text -> CmdResult
- raw :: Text -> CmdResult
- initialize :: IO.IO a -> IO.IO a
- query_cmd :: Network.Addr -> Text -> IO.IO CmdResult
- query_save_file :: Network.Addr -> IO.IO (Maybe (Maybe IO.FilePath))
- query_completion :: Network.Addr -> Text -> IO.IO [Text]
- notify :: Network.Addr -> NotifySeq -> IO.IO (Either Exception.IOException ())
- query_cmd_simple :: Text -> IO.IO Text
- seq_receive :: IO.Handle -> IO.IO Query
- seq_send :: IO.Handle -> Response -> IO.IO ()
- format_result :: CmdResult -> Text
- abbreviate_package_loads :: [Log.Msg] -> [Log.Msg]
types
This is a simple RPC mechanism. Query
goes to the server, which
responds with the matching Response
.
QSaveFile | |
QCommand !Text | |
QCompletion !Text | |
QNotify !NotifySeq | A notification doesn't have a corrpesponding |
NEditorOpened | These are so the sequencer knows if there are open editors, so it can refuse to quit and hence orphan them. |
NEditorClosed |
RSaveFile !(Maybe IO.FilePath) | current save file |
RCommand !CmdResult | |
RCompletion ![Text] | possible completions for the prefix |
Raw !Text | Print this text directly, without formatting it. |
Format !Text | Format and print. |
Edit !(NonEmpty Editor) | Edit one or more files. |
Open an editor locally.
How this works is that a Cmd will return the special Edit
value, which
will be specially interpreted in the repl to open an editor. The editor
will be configured such that when it saves, it will send its buffer to
the sequencer via a REPL function with a string argument (configured by
_on_save
). The text goes back separately via the send
command, since
the REPL itself will be blocked waiting for the editor to exit.
FileName !IO.FilePath | open this file |
Text !FileType !Text | open this text in a temp file |
Instances
Bounded FileType Source # | |
Enum FileType Source # | |
Show FileType Source # | |
Eq FileType Source # | |
Serialize.Serialize FileType Source # | |
file_type_extension :: FileType -> String Source #
error_result :: Text -> CmdResult Source #
repl protocol
initialize :: IO.IO a -> IO.IO a Source #
query_save_file :: Network.Addr -> IO.IO (Maybe (Maybe IO.FilePath)) Source #
Ask for the current save filename. Nothing for an error, and Just Nothing for no save file.
query_completion :: Network.Addr -> Text -> IO.IO [Text] Source #
notify :: Network.Addr -> NotifySeq -> IO.IO (Either Exception.IOException ()) Source #
Like query
, but don't expect a response.
seq protocol
format
format_result :: CmdResult -> Text Source #
Format the response and strip trailing whitespace.
abbreviate_package_loads :: [Log.Msg] -> [Log.Msg] Source #