Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrispenner/eve-cli
Terminal event handlers and rendering for `eve` programs
https://github.com/chrispenner/eve-cli
cli eve haskell terminal
Last synced: 3 days ago
JSON representation
Terminal event handlers and rendering for `eve` programs
- Host: GitHub
- URL: https://github.com/chrispenner/eve-cli
- Owner: ChrisPenner
- License: other
- Created: 2018-04-02T04:19:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-05T02:47:38.000Z (over 6 years ago)
- Last Synced: 2024-04-22T23:21:59.009Z (7 months ago)
- Topics: cli, eve, haskell, terminal
- Language: Haskell
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
Eve.CLI
=======Eve.CLI provides [`eve`](https://github.com/ChrisPenner/eve) compatible helpers for building CLI apps.
It allows you to:
- Respond to Keyboard, Mouse, and Resize Events
- Render text/images to your terminalHere's what it looks like:
```haskell
module Main whereimport Eve (eve_, App, exit)
import Eve.CLI (initCLI, onKeypress_, renderImage, Keypress(..))
import qualified Data.Text.Lazy as T
import qualified Graphics.Vty as V
import Control.Monad (void)main :: IO ()
main = eve_ $ do
initCLI
onKeypress_ showKeypress
where
-- | Display the last key combination that you pressed on screen
showKeypress :: Keypress -> App ()
showKeypress (Keypress V.KEsc _) = exit
showKeypress keypress = void . renderImage $ V.text V.defAttr . T.pack . show $ keypress
```Events
------Eve.CLI is a small wrapper on top of [vty](https://github.com/jtdaugherty/vty); so you'll also need to import
`Graphics.Vty` in order to interact with most events. The following event listeners are provided:- onEvent
- onKeypress
- onMouseDown
- onMouseUp
- onResize
- onPasteSee the hackage docs for more in depth API documentation.
Rendering
---------Currently Eve.CLI supports only rendering a
[`Vty.Image`](http://hackage.haskell.org/package/vty-5.21/docs/Graphics-Vty-Image.html);
this means you can use any of `Vty`'s image building combinators, then simply
call `renderImage` with the image you've built.