prompt.go (504B)
1 package editor 2 3 import ( 4 "fmt" 5 6 "code.dwrz.net/src/pkg/editor/buffer/line" 7 "code.dwrz.net/src/pkg/editor/event" 8 ) 9 10 func (e *Editor) saveAs(l line.Line) error { 11 if err := e.active.SaveAs(l.String()); err != nil { 12 return fmt.Errorf("failed to save: %v", err) 13 } 14 15 return nil 16 } 17 18 func (e *Editor) quit(l line.Line) error { 19 switch l.String() { 20 case "y": 21 go func() { 22 e.events <- event.NewQuit() 23 }() 24 25 return nil 26 27 case "n": 28 return nil 29 30 default: 31 return fmt.Errorf("invalid selection") 32 } 33 }