This commit is contained in:
Zachary Yedidia 2017-05-14 10:27:37 -04:00
commit dcee63771a
3 changed files with 16 additions and 8 deletions

View file

@ -67,7 +67,12 @@ type CellView struct {
func (c *CellView) Draw(buf *Buffer, top, height, left, width int) {
tabsize := int(buf.Settings["tabsize"].(float64))
softwrap := buf.Settings["softwrap"].(bool)
indentchar := []rune(buf.Settings["indentchar"].(string))[0]
indentrunes := []rune(buf.Settings["indentchar"].(string))
// if empty indentchar settings, use space
if indentrunes == nil || len(indentrunes) == 0 {
indentrunes = []rune(" ")
}
indentchar := indentrunes[0]
start := buf.Cursor.Y
if buf.Settings["syntax"].(bool) && buf.syntaxDef != nil {

View file

@ -161,17 +161,19 @@ func (m *Messenger) YesNoPrompt(prompt string) (bool, bool) {
case *tcell.EventKey:
switch e.Key() {
case tcell.KeyRune:
if e.Rune() == 'y' {
if e.Rune() == 'y' || e.Rune() == 'Y' {
m.AddLog("\t--> y")
m.hasPrompt = false
return true, false
} else if e.Rune() == 'n' {
} else if e.Rune() == 'n' || e.Rune() == 'N' {
m.AddLog("\t--> n")
m.hasPrompt = false
return false, false
}
case tcell.KeyCtrlC, tcell.KeyCtrlQ, tcell.KeyEscape:
m.AddLog("\t--> (cancel)")
m.Clear()
m.Reset()
m.hasPrompt = false
return false, true
}

View file

@ -199,18 +199,19 @@ func (v *View) ScrollDown(n int) {
// causing them to lose the unsaved changes
func (v *View) CanClose() bool {
if v.Type == vtDefault && v.Buf.IsModified {
var char rune
var choice bool
var canceled bool
if v.Buf.Settings["autosave"].(bool) {
char = 'y'
choice = true
} else {
char, canceled = messenger.LetterPrompt("Save changes to "+v.Buf.GetName()+" before closing? (y,n,esc) ", 'y', 'n', 'Y', 'N')
choice, canceled = messenger.YesNoPrompt("Save changes to " + v.Buf.GetName() + " before closing? (y,n,esc) ")
}
if !canceled {
if char == 'y' || char == 'Y' {
//if char == 'y' {
if choice {
v.Save(true)
return true
} else if char == 'n' || char == 'N' {
} else {
return true
}
}