Add start of editor row structure

This commit is contained in:
Timothy Warren 2021-03-30 16:05:33 -04:00
parent b7e4463f01
commit 842ab0ef49
2 changed files with 20 additions and 1 deletions

View File

@ -17,13 +17,16 @@ type cursor struct {
type editor struct { type editor struct {
screen *terminal.Screen screen *terminal.Screen
cursor *cursor cursor *cursor
rows []*row
} }
func New() *editor { func New() *editor {
screen := terminal.Size() screen := terminal.Size()
cursor := &cursor { 0, 0 } cursor := &cursor { 0, 0 }
var rows []*row
rows = append(rows, NewRow())
return &editor{screen, cursor } return &editor{screen, cursor, rows }
} }
func (e *editor) ProcessKeypress() bool { func (e *editor) ProcessKeypress() bool {
@ -84,6 +87,7 @@ func (e *editor) moveCursor (key string) {
} }
} }
// Convert the raw ANSI escape sequences to the type of key input
func parseEscapeSequence () string { func parseEscapeSequence () string {
var runes []rune var runes []rune

15
editor/row.go Normal file
View File

@ -0,0 +1,15 @@
package editor
type row struct {
chars []rune
}
func NewRow() *row {
return &row {}
}
func (r *row) Size() int {
return len(r.chars)
}