Comments (4)
The hSize
field of a Widget
just describes the behavior of that widget rather than configuring its behavior, so setting it will only change how containers behave when rendering that widget. To actually get the behavior you want, you need to compose your string with a fill
or pad
operation so that extra spaces are rendered. You're on the right track with hLimit
, though - that (in effect) takes a greedy widget and makes it fixed, both by setting the hSize
and by cropping the resulting limited widget. Does that make sense?
Here is a way to do what you described. Assuming you have a list with element type (Int, String)
as depicted above, here is what your list item draw function would look like (without logic for handling the selection since I'm only trying to illustrate the widget composition):
drawElem :: Bool -> (Int, String) -> Widget
drawElem _sel (i, s) =
-- The integer portion
let intPart = str $ show i
-- The integer portion, padded (so it is now "greedy")
intPartGreedy = padRight Max intPart
-- The width-limited integer portion
intPartFixed = hLimit 10 intPartGreedy
-- The string portion
strPart = str s
-- The whole thing
final = intPartFixed <+> strPart
-- Finally, we right-pad the whole thing so as to make the cursor
-- attribute go all the way to the right hand side of the list.
in padRight Max final
from brick.
Thanks, I missed the Max
Constructor for Padding
. How does Pad Int
work, though? It looks to me like it simply adds spaces to the end.
from brick.
Yes, you have it right. The integer argument specifies the number of rows or columns to pad.
On Nov 29, 2015, at 8:58 AM, Profpatsch [email protected] wrote:
Thanks, I missed the Max Constructor for Padding. How does Pad Int work, though? It looks to me like it simply adds spaces to the end.
ā
Reply to this email directly or view it on GitHub.
from brick.
If you decide that this approach works for you, please close the issue (or let me know what else I can do to help).
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.