charset.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package ansi
  2. // SelectCharacterSet sets the G-set character designator to the specified
  3. // character set.
  4. //
  5. // ESC Ps Pd
  6. //
  7. // Where Ps is the G-set character designator, and Pd is the identifier.
  8. // For 94-character sets, the designator can be one of:
  9. // - ( G0
  10. // - ) G1
  11. // - * G2
  12. // - + G3
  13. //
  14. // For 96-character sets, the designator can be one of:
  15. // - - G1
  16. // - . G2
  17. // - / G3
  18. //
  19. // Some common 94-character sets are:
  20. // - 0 DEC Special Drawing Set
  21. // - A United Kingdom (UK)
  22. // - B United States (USASCII)
  23. //
  24. // Examples:
  25. //
  26. // ESC ( B Select character set G0 = United States (USASCII)
  27. // ESC ( 0 Select character set G0 = Special Character and Line Drawing Set
  28. // ESC ) 0 Select character set G1 = Special Character and Line Drawing Set
  29. // ESC * A Select character set G2 = United Kingdom (UK)
  30. //
  31. // See: https://vt100.net/docs/vt510-rm/SCS.html
  32. func SelectCharacterSet(gset byte, charset byte) string {
  33. return "\x1b" + string(gset) + string(charset)
  34. }
  35. // SCS is an alias for SelectCharacterSet.
  36. func SCS(gset byte, charset byte) string {
  37. return SelectCharacterSet(gset, charset)
  38. }
  39. // Locking Shift 1 Right (LS1R) shifts G1 into GR character set.
  40. const LS1R = "\x1b~"
  41. // Locking Shift 2 (LS2) shifts G2 into GL character set.
  42. const LS2 = "\x1bn"
  43. // Locking Shift 2 Right (LS2R) shifts G2 into GR character set.
  44. const LS2R = "\x1b}"
  45. // Locking Shift 3 (LS3) shifts G3 into GL character set.
  46. const LS3 = "\x1bo"
  47. // Locking Shift 3 Right (LS3R) shifts G3 into GR character set.
  48. const LS3R = "\x1b|"