clayers - Update 1.1.0

Wyatt via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Jul 7 12:09:03 PDT 2015


On Wednesday, 1 July 2015 at 19:16:28 UTC, Vladde Nordholm wrote:
> So today I released version 1.1.0 of my console rendering 
> library clayers!
>
> What this new update offers is support for colors, where you 
> can set the text- and background-color! This is thanks to the 
> library 'colorize' (d-colorize on GH).
>
> In case you don't know what clayers is (which you most likely 
> don't), it's a console rendering library aimed at console 
> games. It currently supports layer handling and colors.
>
> clayers on GitHub: https://github.com/vladdeSV/clayers
> clayers on dub: http://code.dlang.org/packages/clayers

I saw this when you first announced it and have been meaning to 
write you about it.  In some ways, it reminds me of a greenfield 
implementation of what I was getting into with the ncurses 
backend of my engine.

When I come back to that (Some day!  Soon!  Maybe!), I was 
thinking of pulling in Adam's terminal.d; this might make a good 
companion to that?  I certainly wouldn't lose any sleep at night 
to replace ncurses entirely and I look forward to seeing what you 
come up with.

Thoughts/ideas/suggestions:
* I think everyone working on this problem ends up making 
coordinate types. ~_~;;  I definitely recommend defining XCoord 
and YCoord as separate types so a common inversion bug is 
prevented-- that's saved me a number of times.  In my experience, 
a straight alias was vexingly insufficient so I use a struct 
(though it's still not where I want it).

* Make a no-args init that detects terminal dimensions.  It's 
just nicer that way.

* I like the two-corner constructor for ConsoleLayer.  I can't 
remember why I didn't go that route myself.  It may have been 
that I was just trying to "make it work" instead of "make it 
nice", but there could be something more.  I forget.

* Relative (percentage-based) dimensions seem like they could be 
really handy, but I've never figured out how to make them feel 
good.  Maybe you can do better.

* Simplify bordered windows.  I feel pretty strongly that that 
should be abstracted into the ConsoleLayer, honestly.  If not as 
part of the constructor, then as a property you can set. Default 
to nothing and allow setting it to a character ("#") or to a 
manifest constant that tells it to use unicode box drawing 
characters.  (Or maybe the property is an enum BORDER {NONE, 
UNICODE, CHAR}, and the character is separate?  I don't know.)

* A method to get the current layer order is probably worth 
considering. And a way to get the priority index for a layer.  
And even relative reordering; e.g. layerA.moveAbove(layerB);

* There's no way to move or resize a layer?  Is the the idea to 
just destroy and recreate the layer with the new origin/size?

* Make writing to the window automatically go inside the border.  
This is actually why my BoxWin class wraps two ncurses panels: 
one is a border pane and the other is a text pane so I get 
trivial line wrapping (I have a small familiy of functions for 
print modeled after the write() family in stdio).

-Wyatt


More information about the Digitalmars-d-announce mailing list