Add 'dirty' flag to document
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
This commit is contained in:
parent
e2f35f5e7d
commit
799af21a24
@ -36,6 +36,8 @@ func (d *document) open(filename string) {
|
|||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
d.appendRow(scanner.Text())
|
d.appendRow(scanner.Text())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.dirty = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *document) save() int {
|
func (d *document) save() int {
|
||||||
@ -67,6 +69,8 @@ func (d *document) save() int {
|
|||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.dirty = false
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +78,8 @@ func (d *document) appendRow(s string) {
|
|||||||
newRow := newRow(s)
|
newRow := newRow(s)
|
||||||
newRow.update()
|
newRow.update()
|
||||||
d.rows = append(d.rows, newRow)
|
d.rows = append(d.rows, newRow)
|
||||||
|
|
||||||
|
d.dirty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *document) toString() string {
|
func (d *document) toString() string {
|
||||||
|
@ -114,8 +114,12 @@ func (e *editor) drawStatusBar(ab *buffer) {
|
|||||||
if e.document.filename != "" {
|
if e.document.filename != "" {
|
||||||
fileName = e.document.filename
|
fileName = e.document.filename
|
||||||
}
|
}
|
||||||
|
modified := ""
|
||||||
|
if e.document.dirty {
|
||||||
|
modified = "(modified)"
|
||||||
|
}
|
||||||
|
|
||||||
leftStatus := fmt.Sprintf("%.20s - %d lines", fileName, e.document.rowCount())
|
leftStatus := fmt.Sprintf("%.20s - %d lines %s", fileName, e.document.rowCount(), modified)
|
||||||
length := len(leftStatus)
|
length := len(leftStatus)
|
||||||
if length > cols {
|
if length > cols {
|
||||||
leftStatus = truncate(leftStatus, cols)
|
leftStatus = truncate(leftStatus, cols)
|
||||||
|
@ -193,6 +193,7 @@ func (e *editor) insertChar(ch rune) {
|
|||||||
|
|
||||||
e.document.rows[e.cursor.y].insertRune(ch, e.cursor.x)
|
e.document.rows[e.cursor.y].insertRune(ch, e.cursor.x)
|
||||||
e.cursor.x += 1
|
e.cursor.x += 1
|
||||||
|
e.document.dirty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the raw ANSI escape sequences to the type of key input
|
// Convert the raw ANSI escape sequences to the type of key input
|
||||||
|
Loading…
Reference in New Issue
Block a user