Fix save as
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2021-04-06 09:58:45 -04:00
parent 52aa174091
commit 4668ba5628
2 changed files with 12 additions and 11 deletions

View File

@ -67,11 +67,11 @@ func (d *Document) Save() int {
}
if fileLen == size {
d.dirty = false
return size
}
d.dirty = false
return 0
}

View File

@ -59,9 +59,9 @@ func (e *editor) Open(filename string) {
}
func (e *editor) Save() {
//if e.document.Filename == "" {
// e.document.Filename = e.Prompt("Save as: %s")
//}
if e.document.Filename == "" {
e.document.Filename = e.Prompt("Save as: %s")
}
size := e.document.Save()
@ -88,14 +88,15 @@ func (e *editor) ProcessKeypress() bool {
func (e *editor) Prompt(prompt string) string {
buf := gilo.NewBuffer()
// Show the prompt message
e.SetStatusMessage(prompt, "")
e.RefreshScreen()
for {
if buf.Len() > 0 {
e.SetStatusMessage(prompt, buf.ToString())
} else {
e.SetStatusMessage(prompt)
}
e.RefreshScreen()
}
ch, _ := terminal.ReadKey()
if ch == key.Enter {
@ -103,9 +104,9 @@ func (e *editor) Prompt(prompt string) string {
e.SetStatusMessage("")
return buf.ToString()
} else if !key.IsCtrl(ch) && key.IsAscii(ch) {
buf.AppendRune(ch)
}
} else if key.IsAscii(ch) && !key.IsCtrl(ch) {
buf.AppendRune(ch)
}
}
}