| 1 |
package vt |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/charmbracelet/x/ansi" |
| 5 |
"github.com/charmbracelet/x/ansi/parser" |
| 6 |
) |
| 7 |
|
| 8 |
// handleEsc handles an escape sequence. |
| 9 |
func (e *Emulator) handleEsc(cmd ansi.Cmd) { |
| 10 |
e.flushGrapheme() // Flush any pending grapheme before handling ESC sequences. |
| 11 |
if !e.handlers.handleEsc(int(cmd)) { |
| 12 |
var str string |
| 13 |
if inter := cmd.Intermediate(); inter != 0 { |
| 14 |
str += string(inter) + " " |
| 15 |
} |
| 16 |
if final := cmd.Final(); final != 0 { |
| 17 |
str += string(final) |
| 18 |
} |
| 19 |
e.logf("unhandled sequence: ESC %q", str) |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
// fullReset performs a full terminal reset as in [ansi.RIS]. |
| 24 |
func (e *Emulator) fullReset() { |
| 25 |
e.scrs[0].Reset() |
| 26 |
e.scrs[1].Reset() |
| 27 |
e.resetTabStops() |
| 28 |
|
| 29 |
// XXX: Do we reset all modes here? Investigate. |
| 30 |
e.resetModes() |
| 31 |
|
| 32 |
e.gl, e.gr = 0, 1 |
| 33 |
e.gsingle = 0 |
| 34 |
e.charsets = [4]CharSet{} |
| 35 |
e.atPhantom = false |
| 36 |
e.grapheme = e.grapheme[:0] |
| 37 |
e.lastChar = 0 |
| 38 |
e.lastState = parser.GroundState |
| 39 |
} |