Comments (10)
This is possible using the attribute management combinators; you can find them in the "Attribute management" section of Brick.Widgets.Core
:
http://hackage.haskell.org/package/brick-0.6.4/docs/Brick-Widgets-Core.html#g:5
But the easiest way is to use withDefAttr
, e.g.,
listWidget =
hBox [ withDefAttr fooAttr $ str "foo"
, str " "
, withDefAttr barAttr $ str "bar"
, str " "
, withDefAttr quuxAttr $ str "quux"
]
and then be sure to assign those attribute map entries in your attribute map, e.g.,
App { appAttrMap = const $ attrMap defAttr mapping
}
mapping =
[ (fooAttr, fg white)
, (barAttr, fg red)
, (quuxAttr, blue `on` green)
]
You can also see some examples of the attribute API at work in programs/AttrDemo.hs
.
If this helps, please feel free to close the issue; otherwise let me know what I can do. Thanks!
from brick.
Oh cool, I will have a look at this and report back my findings.
On Wed, May 25, 2016 at 4:50 PM, Jonathan Daugherty <
[email protected]> wrote:
This is possible using the attribute management combinators; you can find
them in the "Attribute management" section of Brick.Widgets.Core:http://hackage.haskell.org/package/brick-0.6.4/docs/Brick-Widgets-Core.html#g:5
But the easiest way is to use withDefAttr, e.g.,
listWidget =
hBox [ withDefAttr fooAttr $ str "foo"
, str " "
, withDefAttr barAttr $ str "bar"
, str " "
, withDefAttr quuxAttr $ str "quux"
]and then be sure to assign those attribute map entries in your attribute
map, e.g.,App { appAttrMap = const $ attrMap defAttr mapping
}
mapping =
[ (fooAttr, fg white)
, (barAttr, fg red)
, (quuxAttr, blueon
green)
]You can also see some examples of the attribute API at work in
programs/AttrDemo.hs.If this helps, please feel free to close the issue; otherwise let me know
what I can do. Thanks!—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#58 (comment)
from brick.
Thanks, I got it working. I don't understand why I was thinking so narrowly before. The key is that the List widget comes with the wonderful renderList
function, which allows one to supply a custom rendering function for the arbitrary element type in the List widget. My List elements are of a custom type and I used your hBox [<widgets>]
approach to populate a list of str
widgets for each element's subparts ("foo", "bar", and "quux" in my original post).
Thanks again!
from brick.
Great! I'm glad it's working out for you. Keep in mind that if you think of something about the docs that could have made this clearer, I'm interested to know what that would be.
from brick.
Hm, maybe the docs could say that we could simulate a spreadsheet by having each element in a List widget be composed of multiple 'column' subparts, optionally colored differently? Or just implement it in a new ListDemo2.hs program?
from brick.
Actually, the existing ListDemo
already does this using withAttr
(which is similar to withDefAttr
).
from brick.
Yes it does, although I think it would be clearer if visually it had something more like a spreadsheet. Shrug but then again it could be just me. Your call!
from brick.
I only hesitate to program a spreadsheet as a demo because it's such a specific application idea, and I'm concerned that having a demo app for every way to use brick would get unmanageable because it's intended to let you do whatever you want. :)
With that said, I can see how it wouldn't be obvious to do what you want to do from the outset, and it will require learning the library well enough to imagine ways to get the layout you desire. My intention is to provide enough basic building blocks that just about anything can be built from them, if they are well understood.
from brick.
I agree with your concerns. Well, in the coming month(s) I will be
releasing a project that uses all of this functionality so maybe a
screenshot of that project would be good enough. We could have a "Brick
usage examples in the wild" section either in the Github wiki or directly
in the README and have links to screenshots and such.
On Thu, May 26, 2016 at 3:22 PM, Jonathan Daugherty <
[email protected]> wrote:
I only hesitate to program a spreadsheet as a demo because it's such a
specific application idea, and I'm concerned that having a demo app for
every way to use brick would get unmanageable because it's intended to let
you do whatever you want. :)With that said, I can see how it wouldn't be obvious to do what you want
to do from the outset, and it will require learning the library well enough
to imagine ways to get the layout you desire. My intention is to provide
enough basic building blocks that just about anything can be built from
them, if they are well understood.—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#58 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAsSbQQ20_1riJoj2__ZCGGUnjF_yAYOks5qFh0xgaJpZM4Im7jE
.
from brick.
That would be fantastic! I would be happy to add it to the README.
from brick.
Related Issues (20)
- row ... now exceeds region width HOT 8
- Is there any way to wait for an input? For example, wait for confirmation. HOT 8
- There should be something like `fmapState`. HOT 10
- Consider adding `zoomOut` for saving lines when dealing with sum types. HOT 3
- Cannot install `brick` via `cabal update && cabal install brick` on NixOS HOT 9
- Add version of customMain that doesn't require a Vty handle HOT 11
- Documentation Unavailable on Hackage HOT 4
- Can you add brick-trading-journal to featured projects on README? HOT 1
- Mouse-based selection stops working after using the mouse in an app. HOT 17
- Visbility request for FormFieldState instead of FormField HOT 7
- Segmentation fault when eagerly pressing a keyboard key HOT 3
- test compilation failure with brick-2.1.1 in Nixpkgs HOT 3
- How can I get SIGTSTP (ctrl-z) to suspend the process? HOT 6
- Thread blocked indefinitely in an STM transaction HOT 35
- Provide absolute coordinates on brick mouse event HOT 5
- Progress bar usage HOT 6
- How to use dialogSelection with appHandleEvent function? HOT 7
- Pop-up overlay dialog, is it possible? HOT 23
- Keybindings config character uppercase HOT 3
- Add keybindingINIList output to Brick.Keybindings.Pretty HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brick.