Toggle

terminus.effect.Toggle
final class Toggle(set: String, reset: String)

A Toggle stores state for Terminal effects that involve turning on some state within a block of code and turning it off when that block exits. A typical example is text styling: we have a block where we want invert styling enabled, and when the block finishes we want inverted styling turned off. A complication arises when we can nest blocks. An inverted block might be nested inside another inverted block. It's only when the outer block exits that the styling should be turned off. A Toggle handles this with a counter. Only when the counter hits zero do we emit the reset escape code.

Value parameters

`reset`:

The escape code to emit when exiting a block.

`set`:

The escape code to emit when entering a block.

Attributes

Source
Toggle.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

Toggle off the effect, indicating we're exiting a block.

Toggle off the effect, indicating we're exiting a block.

Attributes

Source
Toggle.scala
def on(writer: Writer): Unit

Toggle on the effect, indicating we're entering a block.

Toggle on the effect, indicating we're entering a block.

Attributes

Source
Toggle.scala