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 {
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")
}

View File

@ -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)
}
}
}

View File

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