Setting and changing the style class of standard library text


I had an idea for a story in which I would like to set globally a style class for all text during that scene (for example, say, in a game with time travel you might want to have a modern font for the present but an old-fashioned font when you are in the past). Is this currently possible?


Right now it’s a bit tricky, because divs have to be nested. You could replace the default (program entry point) with a new version with a main loop like the following:

        *(repeat forever) (styled-read-parse-act) (fail)

and then provide wrappers:

        (currently in the future) %% this would be a global flag
        (div @future) (read-parse-act)

        (div @past) (read-parse-act)

To switch in the middle of a cutscene:

(perform [pull #lever])
        The time machine roars to life.
        (now) (currently in the future)
        (div @future) {
                People are flying around in jetpacks.
                (tick) (stop)

It’s not a perfect solution, but it might be workable. I’m thinking about adding a language feature for setting (and changing) the style of the main interpreter area. This could be used to implement styled chapters (à la Photopia). But it would change the whole screen, including old content, so in your case it would only be useful if you were going to clear the screen anyway.

1 Like