mode.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package ansi
  2. // This file define uses multiple sequences to set (SM), reset (RM), and request
  3. // (DECRQM) different ANSI and DEC modes.
  4. //
  5. // See: https://vt100.net/docs/vt510-rm/SM.html
  6. // See: https://vt100.net/docs/vt510-rm/RM.html
  7. // See: https://vt100.net/docs/vt510-rm/DECRQM.html
  8. //
  9. // The terminal then responds to the request with a Report Mode function
  10. // (DECRPM) in the format:
  11. //
  12. // ANSI format:
  13. //
  14. // CSI Pa ; Ps ; $ y
  15. //
  16. // DEC format:
  17. //
  18. // CSI ? Pa ; Ps $ y
  19. //
  20. // Where Pa is the mode number, and Ps is the mode value.
  21. // See: https://vt100.net/docs/vt510-rm/DECRPM.html
  22. // Application Cursor Keys (DECCKM) is a mode that determines whether the
  23. // cursor keys send ANSI cursor sequences or application sequences.
  24. //
  25. // See: https://vt100.net/docs/vt510-rm/DECCKM.html
  26. const (
  27. EnableCursorKeys = "\x1b[?1h"
  28. DisableCursorKeys = "\x1b[?1l"
  29. RequestCursorKeys = "\x1b[?1$p"
  30. )
  31. // Text Cursor Enable Mode (DECTCEM) is a mode that shows/hides the cursor.
  32. //
  33. // See: https://vt100.net/docs/vt510-rm/DECTCEM.html
  34. const (
  35. ShowCursor = "\x1b[?25h"
  36. HideCursor = "\x1b[?25l"
  37. RequestCursorVisibility = "\x1b[?25$p"
  38. )
  39. // VT Mouse Tracking is a mode that determines whether the mouse reports on
  40. // button press and release.
  41. //
  42. // See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
  43. const (
  44. EnableMouse = "\x1b[?1000h"
  45. DisableMouse = "\x1b[?1000l"
  46. RequestMouse = "\x1b[?1000$p"
  47. )
  48. // VT Hilite Mouse Tracking is a mode that determines whether the mouse reports on
  49. // button presses, releases, and highlighted cells.
  50. //
  51. // See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
  52. const (
  53. EnableMouseHilite = "\x1b[?1001h"
  54. DisableMouseHilite = "\x1b[?1001l"
  55. RequestMouseHilite = "\x1b[?1001$p"
  56. )
  57. // Cell Motion Mouse Tracking is a mode that determines whether the mouse
  58. // reports on button press, release, and motion events.
  59. //
  60. // See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
  61. const (
  62. EnableMouseCellMotion = "\x1b[?1002h"
  63. DisableMouseCellMotion = "\x1b[?1002l"
  64. RequestMouseCellMotion = "\x1b[?1002$p"
  65. )
  66. // All Mouse Tracking is a mode that determines whether the mouse reports on
  67. // button press, release, motion, and highlight events.
  68. //
  69. // See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
  70. const (
  71. EnableMouseAllMotion = "\x1b[?1003h"
  72. DisableMouseAllMotion = "\x1b[?1003l"
  73. RequestMouseAllMotion = "\x1b[?1003$p"
  74. )
  75. // SGR Mouse Extension is a mode that determines whether the mouse reports events
  76. // formatted with SGR parameters.
  77. //
  78. // See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
  79. const (
  80. EnableMouseSgrExt = "\x1b[?1006h"
  81. DisableMouseSgrExt = "\x1b[?1006l"
  82. RequestMouseSgrExt = "\x1b[?1006$p"
  83. )
  84. // Alternate Screen Buffer is a mode that determines whether the alternate screen
  85. // buffer is active.
  86. //
  87. // See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
  88. const (
  89. EnableAltScreenBuffer = "\x1b[?1049h"
  90. DisableAltScreenBuffer = "\x1b[?1049l"
  91. RequestAltScreenBuffer = "\x1b[?1049$p"
  92. )
  93. // Bracketed Paste Mode is a mode that determines whether pasted text is
  94. // bracketed with escape sequences.
  95. //
  96. // See: https://cirw.in/blog/bracketed-paste
  97. // See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Bracketed-Paste-Mode
  98. const (
  99. EnableBracketedPaste = "\x1b[?2004h"
  100. DisableBracketedPaste = "\x1b[?2004l"
  101. RequestBracketedPaste = "\x1b[?2004$p"
  102. )
  103. // Synchronized Output Mode is a mode that determines whether output is
  104. // synchronized with the terminal.
  105. //
  106. // See: https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036
  107. const (
  108. EnableSyncdOutput = "\x1b[?2026h"
  109. DisableSyncdOutput = "\x1b[?2026l"
  110. RequestSyncdOutput = "\x1b[?2026$p"
  111. )
  112. // Win32Input is a mode that determines whether input is processed by the
  113. // Win32 console and Conpty.
  114. //
  115. // See: https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md
  116. const (
  117. EnableWin32Input = "\x1b[?9001h"
  118. DisableWin32Input = "\x1b[?9001l"
  119. RequestWin32Input = "\x1b[?9001$p"
  120. )