checkpoint: this code does not work, just want a fallback

Going to start a LARGE ai refactor of the arch of the project.
This commit is contained in:
Hayden Hargreaves 2026-03-01 23:20:37 -07:00
parent b1b3edf810
commit 154558b790
2 changed files with 55 additions and 1 deletions

View File

@ -1,5 +1,9 @@
package action
import (
"strings"
)
// TODO: No more global settings, window-wide settings
type WinOptions struct {
// Number bool
@ -83,8 +87,56 @@ func (w *Window) AdjustScroll() {
// ==================================================
// View methods
// ==================================================
func (w *Window) View() {
// Window.View ...
func (w *Window) View(m Model) string {
buf := w.Buffer
viewport := w.Height - 2 // command bar (1) + status line (1)
start := w.ScrollY
end := w.ScrollY + viewport
var view strings.Builder
for i := start; i < end; i++ {
// past the file, just draw the '~'
if i >= buf.LineCount() {
// TODO: Handle gutter and line numbers
view.WriteString("~")
view.WriteString("\n")
continue
}
line := w.drawLine(m, buf.Line(i), i)
view.WriteString(line)
// Break to next line
view.WriteString("\n")
}
return view.String()
}
// TODO: Only pass what we need from the model, not the entire model.
func (w *Window) drawLine(m Model, line string, lineNum int) string {
chars := []rune(line)
for col := 0; col <= len(chars); col++ {
// Currently on the cursor
if w.Cursor.Line == lineNum && w.Cursor.Col == col {
if col < len(chars) {
return m.Styles().CursorStyle(m.Mode()).Render(string(chars[col]))
} else {
return m.Styles().CursorStyle(m.Mode()).Render(" ")
}
}
}
return ""
}
func (w *Window) drawGutter() string {
return ""
}
// ==================================================

View File

@ -61,6 +61,8 @@ func posIsAnchor(m Model, col, line int) bool {
func (m Model) View() string {
win := m.ActiveWindow()
return win.View(m)
buf := m.ActiveBuffer()
var view strings.Builder