Gim/model.go
Hayden Hargreaves 6c0c289b52 Initial commit
2026-02-08 23:05:59 -07:00

66 lines
929 B
Go

package main
import tea "github.com/charmbracelet/bubbletea"
type mode int
const (
NormalMode mode = iota
InsertMode
CommandMode
)
type cursor struct {
x int
y int
}
type model struct {
lines []string
cursor cursor
s_gutter int
mode mode
win_h int
win_w int
command string
input *InputHandler
}
func newModel() model {
return model{
lines: []string{
"Hello world",
"line 2",
"line 3",
"line 4",
"line 5",
"line 6",
},
cursor: cursor{
x: 0,
y: 0,
},
s_gutter: 5,
mode: NormalMode,
command: "",
input: NewInputHandler(),
}
}
func (m model) Init() tea.Cmd {
return nil
}
func (m *model) clampCursorX() {
lineLen := len(m.lines[m.cursor.y])
if lineLen == 0 {
m.cursor.x = 0
} else if m.cursor.x >= lineLen {
m.cursor.x = lineLen
}
}
func (m model) getCursorPosition() Position {
return Position{Line: m.cursor.y, Col: m.cursor.x}
}