class_docstr: Cache which maps (r, g, b) tuples to 256 colors.
class_docstr_tok: ["Cache","which","maps","(","r",",","g",",","b",")","tuples","to","256","colors","."]
code: def __init__(self) -> None:
      # Build color table.
      colors: list[tuple[int, int, int]] = []
  
      # colors 0..15: 16 basic colors
      colors.append((0x00, 0x00, 0x00))  # 0
      colors.append((0xCD, 0x00, 0x00))  # 1
      colors.append((0x00, 0xCD, 0x00))  # 2
      colors.append((0xCD, 0xCD, 0x00))  # 3
      colors.append((0x00, 0x00, 0xEE))  # 4
      colors.append((0xCD, 0x00, 0xCD))  # 5
      colors.append((0x00, 0xCD, 0xCD))  # 6
      colors.append((0xE5, 0xE5, 0xE5))  # 7
      colors.append((0x7F, 0x7F, 0x7F))  # 8
      colors.append((0xFF, 0x00, 0x00))  # 9
      colors.append((0x00, 0xFF, 0x00))  # 10
      colors.append((0xFF, 0xFF, 0x00))  # 11
      colors.append((0x5C, 0x5C, 0xFF))  # 12
      colors.append((0xFF, 0x00, 0xFF))  # 13
      colors.append((0x00, 0xFF, 0xFF))  # 14
      colors.append((0xFF, 0xFF, 0xFF))  # 15
  
      # colors 16..232: the 6x6x6 color cube
      valuerange = (0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF)
  
      for i in range(217):
          r = valuerange[(i // 36) % 6]
          g = valuerange[(i // 6) % 6]
          b = valuerange[i % 6]
          colors.append((r, g, b))
  
      # colors 233..253: grayscale
      for i in range(1, 22):
          v = 8 + i * 10
          colors.append((v, v, v))
  
      self.colors = colors
  
imports: from __future__ import annotations
  import io
  import os
  import sys
  from typing import Callable, Dict, Hashable, Iterable, Sequence, TextIO, Tuple
  from prompt_toolkit.cursor_shapes import CursorShape
  from prompt_toolkit.data_structures import Size
  from prompt_toolkit.output import Output
  from prompt_toolkit.styles import ANSI_COLOR_NAMES, Attrs
  from prompt_toolkit.utils import is_dumb_terminal
  from .color_depth import ColorDepth
  from .flush_stdout import flush_stdout
label_desc: Use image node_id 1 to create a new _256ColorCache object from inherited base classes: Dict with example: obj = _256ColorCache()