code: def get_indices(s: Union[str, 'ChainedBase']) -> Dict[int, str]:
      
      codes = get_code_indices(s)
      if not codes:
          # This function is not for non-escape-code stuff, but okay.
          return {i: c for i, c in enumerate(s)}
  
      indices = {}
      for codeindex in sorted(codes):
          code = codes[codeindex]
          if codeindex == 0:
              indices[codeindex] = code
              continue
          # Grab characters before codeindex.
          start = max(indices or {0: ''}, key=int)
          startcode = indices.get(start, '')
          startlen = start + len(startcode)
          indices.update({i: s[i] for i in range(startlen, codeindex)})
          indices[codeindex] = code
  
      if not indices:
          return {i: c for i, c in enumerate(s)}
      lastindex = max(indices, key=int)
      lastitem = indices[lastindex]
      start = lastindex + len(lastitem)
      textlen = len(s)
      if start < (textlen - 1):
          # Grab chars after last code.
          indices.update({i: s[i] for i in range(start, textlen)})
      return indices
docs: Retrieve a dict of characters and escape codes with their real index
          into the string as the key.