brick/README.md

165 lines
5.9 KiB
Markdown
Raw Normal View History

2015-07-08 07:06:43 +03:00
brick
-----
[![Build Status](https://travis-ci.org/jtdaugherty/brick.svg?branch=master)](https://travis-ci.org/jtdaugherty/brick)
2015-07-09 21:02:24 +03:00
2017-03-12 06:35:57 +03:00
`brick` is a Haskell terminal user interface programming library in the
style of [gloss](http://hackage.haskell.org/package/gloss). This means
you write a function that describes how your user interface should look,
but the library takes care of a lot of the book-keeping that so commonly
goes into writing such programs.
2015-07-08 07:06:43 +03:00
2015-07-22 05:45:17 +03:00
`brick` exposes a declarative API. Unlike most GUI toolkits which
require you to write a long and tedious sequence of "create a widget,
2017-03-12 06:35:57 +03:00
now bind an event handler", `brick` just requires you to describe your
interface using a set of declarative combinators. Then you provide a
function to transform your application state when input or other kinds
of events arrive.
2015-07-08 07:06:43 +03:00
2017-03-12 06:35:57 +03:00
Under the hood, this library builds upon
[vty](http://hackage.haskell.org/package/vty), so some knowledge of Vty
will be helpful in using this library.
2015-07-08 07:49:01 +03:00
2015-07-08 07:38:54 +03:00
This library deprecates [vty-ui](https://github.com/jtdaugherty/vty-ui).
Example
-------
2017-03-12 19:05:05 +03:00
Here's an example interface (see `programs/ReadmeDemo.hs`):
```
withBorderStyle unicode $
borderWithLabel (str "Hello!") $
(center (str "Left") <+> vBorder <+> center (str "Right"))
```
Result:
```
┌─────────Hello!─────────┐
│ │ │
│ │ │
│ Left │ Right │
│ │ │
│ │ │
└────────────────────────┘
```
2017-08-03 01:53:09 +03:00
Featured Projects
-----------------
2017-09-30 20:23:22 +03:00
To get an idea of what some people have done with `brick`, take a look
at these projects:
2017-08-03 01:53:09 +03:00
* `tetris`: https://github.com/SamTay/tetris
* `gotta-go-fast`, a typing tutor: https://github.com/hot-leaf-juice/gotta-go-fast
* `haskell-player`, an `afplay` frontend: https://github.com/potomak/haskell-player
* `mushu`, an `MPD` client: https://github.com/elaye/mushu
* `matterhorn`, a client for [Mattermost](https://about.mattermost.com/): https://github.com/matterhorn-chat/matterhorn
* `viewprof`, a GHC profile viewer: https://github.com/maoe/viewprof
2017-08-10 18:58:10 +03:00
* `tart`, a mouse-driven ASCII art drawing program: https://github.com/jtdaugherty/tart
2017-09-03 04:33:22 +03:00
* `silly-joy`, an interpreter for Joy in Haskell: https://github.com/rootmos/silly-joy
* `herms`, a command-line tool for managing kitchen recipes: https://github.com/jackkiefer/herms
2017-10-25 17:25:44 +03:00
* `purebred`, a mail user agent: https://github.com/purebred-mua/purebred
2017-08-03 01:53:09 +03:00
2017-03-12 06:35:57 +03:00
Getting Started
---------------
TLDR:
```
$ cabal sandbox init
$ cabal install -j -f demos
$ .cabal-sandbox/bin/brick-???-demo
```
2017-08-28 06:03:20 +03:00
To get started, see the [user guide](https://github.com/jtdaugherty/brick/blob/master/docs/guide.rst).
Documentation
-------------
Documentation for `brick` comes in a variety of forms:
* [The brick user guide](https://github.com/jtdaugherty/brick/blob/master/docs/guide.rst)
* [Samuel Tay's brick tutorial](https://github.com/jtdaugherty/brick/blob/master/docs/samtay-tutorial.md)
* Haddock (all modules)
* [Demo programs](https://github.com/jtdaugherty/brick/blob/master/programs)
* [FAQ](https://github.com/jtdaugherty/brick/blob/master/FAQ.md)
2017-03-12 06:35:57 +03:00
2015-07-21 05:02:53 +03:00
Feature Overview
----------------
2015-07-21 05:07:33 +03:00
`brick` comes with a bunch of widget types to get you started:
2015-07-21 05:02:53 +03:00
* Vertical and horizontal box layout widgets
* Basic single- and multi-line text editor widgets
* List widget
* Progress bar widget
* Simple dialog box widget
* Border-drawing widgets (put borders around or in between things)
2015-07-21 23:08:19 +03:00
* Generic scrollable viewports
2015-07-22 04:30:33 +03:00
* Extensible widget-building API
2017-11-05 21:50:20 +03:00
* User-customizable attribute themes
2015-07-22 05:37:55 +03:00
* (And many more general-purpose layout control combinators)
2015-07-21 05:02:53 +03:00
In addition, some of `brick`'s more powerful features may not be obvious
right away:
* All widgets can be arranged in predictable layouts so you don't have
to worry about terminal resizes.
* Attribute management is flexible and can be customized at runtime on
a per-widget basis.
2015-07-21 05:02:53 +03:00
2016-03-12 23:17:51 +03:00
Brick-Users Discussion
----------------------
The `brick-users` Google Group / e-mail list is a place to discuss
library changes, give feedback, and ask questions. You can subscribe at:
[https://groups.google.com/group/brick-users](https://groups.google.com/group/brick-users)
2015-07-08 07:56:28 +03:00
Status
------
2017-08-28 04:33:25 +03:00
There are some places were I have deliberately chosen to worry about
performance later for the sake of spending more time on the design (and
to wait on performance issues to arise first). `brick` is also something
of an experimental project of mine and some aspects of the design
involve trade-offs that may are not entirely settled. In addition you
can expect this library to follow a principle of fearless improvement:
new versions will make (sometimes substantial) API changes if those
changes really do make the library better. I will place more importance
on getting the API right than on maintaining backwards compatibility.
2017-03-12 06:35:57 +03:00
`brick` exports an extension API that makes it possible to make your own
packages and widgets. If you use that, you'll also be helping to test
whether the exported interface is usable and complete!
2015-07-08 07:56:28 +03:00
2015-07-09 21:15:21 +03:00
Reporting bugs
--------------
Please file bug reports as GitHub issues. For best results:
- Include the versions of relevant software packages: your terminal
emulator, `brick`, `ghc`, and `vty` will be the most important
2017-03-12 06:35:57 +03:00
ones.
2015-07-09 21:15:21 +03:00
- Clearly describe the behavior you expected ...
2015-12-08 23:48:10 +03:00
- ... and include a minimal demonstration program that exhibits the
2015-07-09 21:15:21 +03:00
behavior you actually observed.
2015-07-08 07:56:28 +03:00
Contributing
------------
If you decide to contribute, that's great! Here are some guidelines you
should consider to make submitting patches easier for all concerned:
- If you want to take on big things, talk to me first; let's have a
2015-07-08 07:57:29 +03:00
design/vision discussion before you start coding. Create a GitHub
issue and we can use that as the place to hash things out.
2017-03-12 06:48:14 +03:00
- Please make changes consistent with the conventions I've used in the
codebase.
- Please adjust or provide Haddock and/or user guide documentation
relevant to any changes you make.