Layer design
kelsey-sorrels opened this issue · comments
I'm interested in feedback on an interface for terminal layers. Layer order would be a required make-terminal
param ex: (:layer-order [:text :ui :fx]
) going from bottommost to topmost layer.
I have two options prepared. One adds a requirement that characters include a :layer-id
value. The other adds a layer-id parameter to put-chars!
.
They look like this:
Option 1:
(put-chars! terminal [{:c \a :x 0 :y 0 :layer-id :ui}
{:c \a :x 1 :y 0 :layer-id :ui}
{:c \a :x 0 :y 0 :layer-id :base}
{:c \a :x 1 :y 0 :layer-id :base}])
With a helper macro
(with-layer :ui
(put-chars! terminal [{:c \a :x 0 :y 0}
{:c \a :x 1 :y 0}]))
(with-layer :text
(put-chars! terminal [{:c \a :x 1 :y 0}
{:c \a :x 1 :y 0}]))
Option 2:
(put-chars! terminal :ui [{:c \a :x 0 :y 0}
{:c \a :x 1 :y 0}])
(put-chars! terminal :text [{:c \a :x 0 :y 0}
{:c \a :x 1 :y 0}])
Or multiple layers
(put-chars! terminal :ui [{:c \a :x 0 :y 0}
{:c \a :x 1 :y 0}])
:text [{:c \a :x 0 :y 0}
{:c \a :x 1 :y 0}])
Other changes
clear!
, set-fg!
, set-bg-!
, set-fx-fg!
, set-fx-bg!
, and set-fx-char!
will require the addition of a layer-id
parameter.
Add
(clear! terminal layer-id)
(clear-fx! terminal layer-id)
Repurpose
(clear! terminal)
to clear all layers
(clear-fx! terminal)
to clear fx on all layers
Implemented option 2 but without & kvs on put-chars! as Clojure does not support variable arguments on protocols.