Add dirty flag
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2021-04-01 20:26:40 -04:00
parent a1f62aa8cb
commit e2f35f5e7d
3 changed files with 10 additions and 8 deletions

View File

@ -7,6 +7,7 @@ import (
) )
type document struct { type document struct {
dirty bool
filename string filename string
rows []*row rows []*row
} }
@ -15,6 +16,7 @@ func newDocument() *document {
var rows []*row var rows []*row
return &document{ return &document{
false,
"", "",
rows, rows,
} }
@ -41,7 +43,7 @@ func (d *document) save() int {
return 0 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 { if err != nil {
panic("failed to open/create file for saving") panic("failed to open/create file for saving")
} }

View File

@ -11,14 +11,14 @@ func TestNew(t *testing.T) {
} }
type moveCursor struct { type moveCursor struct {
keys []string keys []string
withFile bool withFile bool
cursor *point cursor *point
} }
var cursorTests = []moveCursor{ var cursorTests = []moveCursor{
{[]string{"\x1b"}, false, &point{0,0}}, {[]string{"\x1b"}, false, &point{0, 0}},
{[]string{keyRight}, true, &point{1,0}}, {[]string{keyRight}, true, &point{1, 0}},
{[]string{keyEnd}, true, &point{14, 0}}, {[]string{keyEnd}, true, &point{14, 0}},
{[]string{keyEnd, keyHome}, true, &point{0, 0}}, {[]string{keyEnd, keyHome}, true, &point{0, 0}},
{[]string{keyRight, keyLeft}, true, &point{0, 0}}, {[]string{keyRight, keyLeft}, true, &point{0, 0}},

View File

@ -6,8 +6,8 @@ package key
const ( const (
Backspace = 0x7f Backspace = 0x7f
Esc = 0x1b Esc = 0x1b
Enter = '\r' Enter = '\r'
) )
// Is this an ASCII character? // Is this an ASCII character?