Set default background for asciimatics

351 Views Asked by At

I understand that it is not possible to tell asciimatics to use the terminal's current color scheme (because asciimatics has no way of querying the terminal). But I would like at least to have some control and be able to select the color scheme myself.

I can not find anywhere in the documentation how to change the default foreground / background color.

I am using the standard demo:

from asciimatics.screen import Screen
from asciimatics.scene import Scene
from asciimatics.effects import Cycle, Stars
from asciimatics.renderers import FigletText

def demo(screen):
    effects = [
        Cycle(
            screen,
            FigletText("ASCIIMATICS", font='big'),
            screen.height // 2 - 8),
        Cycle(
            screen,
            FigletText("ROCKS!", font='big'),
            screen.height // 2 + 3),
        Stars(screen, (screen.width + screen.height) // 2)
    ]
    screen.play([Scene(effects, 500)])

Screen.wrapper(demo)

I want the background to be yellow. Not the background of the text elements, but the whole background (the Screen's background I would say)

How do I do that?

1

There are 1 best solutions below

0
On

The short answer to your question is to add the Background effect to your Scene. As documented here, you can set any background colour.

However, some effects are older than others and predate backvround colour support. Sadly, Cycle and Stars are in this list and so don't have an equivalent bg setting, so will need updating to work as expected with that change. I suspect that they will also need to be tweaked to expect the full refresh that Background will enforce. Drop in on the asciimatics gitter channel if you need to make that work.