From 842ab0ef49ced2181a373c8a3528f739023786b6 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Tue, 30 Mar 2021 16:05:33 -0400 Subject: [PATCH] Add start of editor row structure --- editor/editor.go | 6 +++++- editor/row.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 editor/row.go 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) +} + +