package action

type RegisterType int

const (
	CharwiseRegister RegisterType = iota
	LinewiseRegister
	BlockwiseRegister
)

type Register struct {
	Type    RegisterType
	Content []string
}

func DefaultRegisters() map[rune]Register {
	reg := make(map[rune]Register)

	addSpecialRegisters(reg)
	addNamedRegisters(reg)
	addNumberedRegisters(reg)

	return reg
}

func addNamedRegisters(reg map[rune]Register) {
	name := 'a'

	for name <= 'z' {
		reg[name] = emptyRegister()
		name++
	}
}

func addNumberedRegisters(reg map[rune]Register) {
	name := '0'

	for name <= '9' {
		reg[name] = emptyRegister()
		name++
	}

}

func addSpecialRegisters(reg map[rune]Register) {
	// Unnamed (default)
	reg['"'] = emptyRegister()

	// Black hole (readonly)
	reg['_'] = emptyRegister()

	// System clipboard
	reg['*'] = emptyRegister()

	// Small delete? Expression?

	// Last inserted text (readonly)
	reg['.'] = emptyRegister()

	// Current file name (readonly)
	reg['%'] = emptyRegister()

	// Last executed command (readonly)
	reg[':'] = emptyRegister()

	// Alternate (previous) file (readonly)
	reg['#'] = emptyRegister()
}

func emptyRegister() Register {
	return Register{
		Type:    CharwiseRegister,
		Content: []string{},
	}
}
