diff --git a/editor/document.go b/editor/document.go index a1a80c2..258852a 100644 --- a/editor/document.go +++ b/editor/document.go @@ -7,6 +7,7 @@ import ( ) type document struct { + dirty bool filename string rows []*row } @@ -15,6 +16,7 @@ func newDocument() *document { var rows []*row return &document{ + false, "", rows, } @@ -41,7 +43,7 @@ func (d *document) save() int { return 0 } - file, err := os.OpenFile(d.filename, os.O_RDWR | os.O_CREATE, 0644) + file, err := os.OpenFile(d.filename, os.O_RDWR|os.O_CREATE, 0644) if err != nil { panic("failed to open/create file for saving") } diff --git a/editor/editor_test.go b/editor/editor_test.go index 3f03b40..ee7e869 100644 --- a/editor/editor_test.go +++ b/editor/editor_test.go @@ -11,14 +11,14 @@ func TestNew(t *testing.T) { } type moveCursor struct { - keys []string + keys []string withFile bool - cursor *point + cursor *point } var cursorTests = []moveCursor{ - {[]string{"\x1b"}, false, &point{0,0}}, - {[]string{keyRight}, true, &point{1,0}}, + {[]string{"\x1b"}, false, &point{0, 0}}, + {[]string{keyRight}, true, &point{1, 0}}, {[]string{keyEnd}, true, &point{14, 0}}, {[]string{keyEnd, keyHome}, true, &point{0, 0}}, {[]string{keyRight, keyLeft}, true, &point{0, 0}}, @@ -58,4 +58,4 @@ func TestInsertChar(t *testing.T) { if row.size() != 1 { t.Errorf("Failed to add character to row. Row: %v", row) } -} \ No newline at end of file +} diff --git a/key/key.go b/key/key.go index 4456986..566107d 100644 --- a/key/key.go +++ b/key/key.go @@ -6,8 +6,8 @@ package key const ( Backspace = 0x7f - Esc = 0x1b - Enter = '\r' + Esc = 0x1b + Enter = '\r' ) // Is this an ASCII character?