color-stack.rst 1.3 KB

123456789101112131415161718192021222324252627
  1. Saving and restoring colors
  2. ==============================
  3. It is often useful for a full screen application with its own color themes to
  4. set the default foreground, background, selection and cursor colors and the ANSI
  5. color table. This allows for various performance optimizations when drawing the
  6. screen. The problem is that if the user previously used the escape codes to
  7. change these colors themselves, then running the full screen application will
  8. lose those changes even after it exits. To avoid this, kitty introduces a new
  9. pair of *OSC* escape codes to push and pop the current color values from a
  10. stack::
  11. <ESC>]30001<ESC>\ # push onto stack
  12. <ESC>]30101<ESC>\ # pop from stack
  13. These escape codes save/restore the colors, default background, default
  14. foreground, selection background, selection foreground and cursor color and the
  15. 256 colors of the ANSI color table.
  16. .. note:: In July 2020, after several years, xterm copied this protocol
  17. extension, without acknowledgement, and using incompatible escape codes
  18. (XTPUSHCOLORS, XTPOPCOLORS, XTREPORTCOLORS). And they decided to save not
  19. just the dynamic colors but the entire ANSI color table. In the interests of
  20. promoting interoperability, kitty added support for xterm's escape codes as
  21. well, and changed this extension to also save/restore the entire ANSI color
  22. table.