patch method

Style patch(
  1. Style other
)

Merge other into this style.

Fields set on other override those on this. Modifiers from other are added, and sub-modifiers from other are removed.

Implementation

Style patch(Style other) {
  return Style(
    fg: other.fg ?? fg,
    bg: other.bg ?? bg,
    fgRgb: other.fgRgb ?? fgRgb,
    bgRgb: other.bgRgb ?? bgRgb,
    fgIndexed: other.fgIndexed ?? fgIndexed,
    bgIndexed: other.bgIndexed ?? bgIndexed,
    addModifier: addModifier.difference(other.subModifier).union(other.addModifier),
    subModifier: subModifier.difference(other.addModifier).union(other.subModifier),
  );
}