How to query for default background color?

30 views
Skip to first unread message

Samuel Tay

unread,
Jun 18, 2017, 4:55:23 PM6/18/17
to Brick Users
I've searched through Brick and Vty packages.. this seems like something that should be simple, since we already have things like V.defAttr.

Without this, I'm forced to create a lot of extra attribute names for certain situations, instead of allowing a custom attribute map for most of the application, and then overriding to the default background color in one place.

Jonathan Daugherty

unread,
Jun 18, 2017, 6:33:53 PM6/18/17
to Samuel Tay, Brick Users
It's true that right now, brick and Vty do not provide terminal
interrogation for this feature.

Can you be more specific about what you are trying to accomplish? It'd
also be helpful if you had example code you could refer to.

Thanks!

--
Jonathan Daugherty

Samuel Tay

unread,
Jun 18, 2017, 9:52:10 PM6/18/17
to Brick Users
Okay, no big deal. The code is here. You can see all the lines of code I had to add in functions like tToAttr, tToAttrH and all of the associated attributes (two for each of the seven tetrimino types). Ideally, there would only be 7 attributes to keep track of, which tie the tetrimino pieces to their colors and default to "V.color `on` V.color". (This is so that nonempty cells show a solid square.) Then, if I'm drawing the hard drop preview, instead of using a set of separate attributes, I would just use the single attribute for that tetrimino, but force a "bg defaultColor" on it (so that it does NOT show up as a solid square, like the actual board cells). Sorry if that was confusing. Regardless, it works as is, and it's not *that* much code, but it just seems odd that if the work has already been done to determine the default background color, why not expose it? I suppose that's a question for the vty author.

Jonathan Daugherty

unread,
Jun 19, 2017, 12:27:51 AM6/19/17
to Samuel Tay, Brick Users
> Regardless, it works as is, and it's not *that* much code, but it
> just seems odd that if the work has already been done to determine
> the default background color, why not expose it? I suppose that's a
> question for the vty author.

I'll look at your code in depth later, but for now, I wanted to point
out that, in fact, no work at all has been done to determine the default
color. The "default attribute" (defAttr) simply means "do not emit
an explicit control sequence for any given color" leading to let the
terminal use its default.

--
Jonathan Daugherty

Samuel Tay

unread,
Jun 19, 2017, 12:30:24 AM6/19/17
to Jonathan Daugherty, Brick Users
Ah okay, not sure why I assumed that. Thanks for the clarification. 
Reply all
Reply to author
Forward
0 new messages