terminal.odin 852 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Interaction with the command line interface (`CLI`) of the system.
  2. package terminal
  3. import "core:os"
  4. /*
  5. This describes the range of colors that a terminal is capable of supporting.
  6. */
  7. Color_Depth :: enum {
  8. None, // No color support
  9. Three_Bit, // 8 colors
  10. Four_Bit, // 16 colors
  11. Eight_Bit, // 256 colors
  12. True_Color, // 24-bit true color
  13. }
  14. /*
  15. Returns true if the file `handle` is attached to a terminal.
  16. This is normally true for `os.stdout` and `os.stderr` unless they are
  17. redirected to a file.
  18. */
  19. @(require_results)
  20. is_terminal :: proc(handle: os.Handle) -> bool {
  21. return _is_terminal(handle)
  22. }
  23. /*
  24. This is true if the terminal is accepting any form of colored text output.
  25. */
  26. color_enabled: bool
  27. /*
  28. This value reports the color depth support as reported by the terminal at the
  29. start of the program.
  30. */
  31. color_depth: Color_Depth