package ugh

// Key represents a keystroke as an ANSI byte sequence.
type Key struct {
	bytes []byte
}

// Bytes returns the raw ANSI byte sequence for this key.
func (k Key) Bytes() []byte {
	return k.bytes
}

// Pre-defined key constants encoded as ANSI byte sequences
// compatible with bubbletea v2's ultraviolet input parser.
var (
	Enter     = Key{bytes: []byte{'\r'}}
	Tab       = Key{bytes: []byte{'\t'}}
	ShiftTab  = Key{bytes: []byte{0x1b, '[', 'Z'}}
	Up        = Key{bytes: []byte{0x1b, '[', 'A'}}
	Down      = Key{bytes: []byte{0x1b, '[', 'B'}}
	Right     = Key{bytes: []byte{0x1b, '[', 'C'}}
	Left      = Key{bytes: []byte{0x1b, '[', 'D'}}
	Space     = Key{bytes: []byte{0x20}}
	Escape    = Key{bytes: []byte{0x1b}}
	Backspace = Key{bytes: []byte{0x7f}}
	CtrlC     = Key{bytes: []byte{0x03}}
	CtrlA     = Key{bytes: []byte{0x01}}
	CtrlE     = Key{bytes: []byte{0x05}}
	CtrlU     = Key{bytes: []byte{0x15}}
	CtrlK     = Key{bytes: []byte{0x0b}}
	CtrlW     = Key{bytes: []byte{0x17}}
	Home      = Key{bytes: []byte{0x1b, '[', 'H'}}
	End       = Key{bytes: []byte{0x1b, '[', 'F'}}
	Delete    = Key{bytes: []byte{0x1b, '[', '3', '~'}}
)
