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:
parent
b1b3edf810
commit
154558b790
@ -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 ""
|
||||
}
|
||||
|
||||
// ==================================================
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user