| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Lib
Description
For the data inclined, start with AppS in Types, which holds all internal RESTman state.
For the logic inclined, start with handleEvent, which is the main entry point for state
changes over time. startUI in UI is responsible for building the App record
and wiring everything together.
Synopsis
- chooseCursor :: AppS -> [CursorLocation AppR] -> Maybe (CursorLocation AppR)
- cleanPayload :: ByteString -> Text
- draw :: AppS -> [Widget AppR]
- focusAttr :: Attr -> Attr
- focusStyle :: Style -> Style
- growWith :: (Int -> Int -> Image) -> Int -> WideAlign -> Int -> VertAlign -> Image -> Image
- handleEvent :: BrickEvent AppR Void -> EventM AppR AppS ()
- doRequest :: AppS -> IO AppS
- lbsToText :: ByteString -> Text
- moveFocusNext :: AppS -> AppS
- moveFocusPrev :: AppS -> AppS
- noSyntaxFound :: Text -> Image
- splitExtraSpace :: RangeInAlign -> Int -> (Int, Int)
- syntaxHighlightResponse :: Maybe ByteString -> Maybe ByteString -> Image
Documentation
chooseCursor :: AppS -> [CursorLocation AppR] -> Maybe (CursorLocation AppR) Source #
Where to place the cursor? If overlay present, no cursor. Otherwise determined by focus
cleanPayload :: ByteString -> Text Source #
Sanitise a lazy ByteString response body for display in Vty.
Decodes to Text with lenient UTF-8 decoding, then:
- Strips
ESC(\ESC) and vertical-tab (\v) characters which would corrupt Vty output. - Expands tab characters to four spaces.
draw :: AppS -> [Widget AppR] Source #
Render.
Widget names are all AppR.
URL editor and label, then last response body at the top of the available space. No other widgets or layers.
focusAttr :: Attr -> Attr Source #
Apply focusStyle to the style component of an Attr, setting it explicitly if it was Default or KeepCurrent.
focusStyle :: Style -> Style Source #
Toggle the reverseVideo bit in a Style to indicate keyboard focus.
Arguments
| :: (Int -> Int -> Image) | How to generate wide by vert padding image |
| -> Int | minimum width |
| -> WideAlign | width-wise ("horizontal") alignment |
| -> Int | minimum vert ("height") |
| -> VertAlign | vertical alignment |
| -> Image | original, small image |
| -> Image | resulting, grown image |
Grows an image to a minimum size by padding it, with original images being aligned as specified within the larger image.
handleEvent :: BrickEvent AppR Void -> EventM AppR AppS () Source #
State update in response to event.
Widget names are all Text. No application specific events, so event type is Void.
Global events handled here: * [Esc] (with any or no modifiers) and Ctrl+q (with any or no other modifiers) halts. * No application events are expected. * Mouse events are ignored.
Other Vty events are passed to handleEventLocal.
doRequest :: AppS -> IO AppS Source #
Construct and issue a wreq request from the application state, handle request failures that are
raised as exceptions in IO, updating the application state (lastResponse) either from the
response or the execption.
lbsToText :: ByteString -> Text Source #
Decode a lazy ByteString to strict Text using lenient UTF-8 decoding.
moveFocusNext :: AppS -> AppS Source #
App state change on [Tab] to advace the focus.
moveFocusPrev :: AppS -> AppS Source #
App state change on [S+Tab] to recede the focus
noSyntaxFound :: Text -> Image Source #
splitExtraSpace :: RangeInAlign -> Int -> (Int, Int) Source #
Second argument must be positive.
syntaxHighlightResponse :: Maybe ByteString -> Maybe ByteString -> Image Source #
Render an HTTP response body (or an empty-body signal) as a Vty Image with optional
syntax highlighting based on the Content-Type header.
The incoming payload ByteString is passed through cleanPayload before rendering to
strip characters that are incompatible with Vty's text rendering (e.g. ESC, vertical
tab). Newlines are preserved — they are the line delimiters used by Vty's vertCat.
- If the body is
Nothing, a placeholder"-- No response body --"line is returned. - If no
Content-Typeis present,noSyntaxFoundis used. - Otherwise the MIME type is looked up in the default extension map and the first matching
skylighting
Syntaxis used byhighlighted.