diff --git a/editor/editor.go b/editor/editor.go index a43cabc..a0f5d8c 100644 --- a/editor/editor.go +++ b/editor/editor.go @@ -17,13 +17,16 @@ type cursor struct { type editor struct { screen *terminal.Screen cursor *cursor + rows []*row } func New() *editor { screen := terminal.Size() 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 { @@ -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 { var runes []rune diff --git a/editor/row.go b/editor/row.go new file mode 100644 index 0000000..d00b0c8 --- /dev/null +++ b/editor/row.go @@ -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) +} + +