mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 22:50:21 +09:00
Minor infobar improvements
This commit is contained in:
@@ -48,6 +48,35 @@ func NewInfoWindow(b *info.Bar) *InfoWindow {
|
||||
return iw
|
||||
}
|
||||
|
||||
// func (i *InfoWindow) YesNoPrompt() (bool, bool) {
|
||||
// for {
|
||||
// i.Clear()
|
||||
// i.Display()
|
||||
// screen.Screen.ShowCursor(utf8.RuneCountInString(i.Msg), i.y)
|
||||
// screen.Show()
|
||||
// event := <-events
|
||||
//
|
||||
// switch e := event.(type) {
|
||||
// case *tcell.EventKey:
|
||||
// switch e.Key() {
|
||||
// case tcell.KeyRune:
|
||||
// if e.Rune() == 'y' || e.Rune() == 'Y' {
|
||||
// i.HasPrompt = false
|
||||
// return true, false
|
||||
// } else if e.Rune() == 'n' || e.Rune() == 'N' {
|
||||
// i.HasPrompt = false
|
||||
// return false, false
|
||||
// }
|
||||
// case tcell.KeyCtrlC, tcell.KeyCtrlQ, tcell.KeyEscape:
|
||||
// i.Clear()
|
||||
// i.Reset()
|
||||
// i.HasPrompt = false
|
||||
// return false, true
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
func (i *InfoWindow) Relocate() bool { return false }
|
||||
func (i *InfoWindow) GetView() *View { return i.View }
|
||||
func (i *InfoWindow) SetView(v *View) {}
|
||||
|
||||
@@ -69,6 +69,11 @@ func (i *Bar) Error(msg ...interface{}) {
|
||||
}
|
||||
|
||||
func (i *Bar) Prompt(msg string, callback func(string, bool)) {
|
||||
// If we get another prompt mid-prompt we cancel the one getting overwritten
|
||||
if i.HasPrompt {
|
||||
i.DonePrompt(true)
|
||||
}
|
||||
|
||||
i.Msg = msg
|
||||
i.HasPrompt = true
|
||||
i.HasMessage, i.HasError = false, false
|
||||
@@ -82,4 +87,11 @@ func (i *Bar) DonePrompt(canceled bool) {
|
||||
} else {
|
||||
i.PromptCallback(strings.TrimSpace(string(i.LineBytes(0))), false)
|
||||
}
|
||||
i.Replace(i.Start(), i.End(), "")
|
||||
}
|
||||
|
||||
// Reset resets the messenger's cursor, message and response
|
||||
func (i *Bar) Reset() {
|
||||
i.Msg = ""
|
||||
i.HasPrompt, i.HasMessage, i.HasError = false, false, false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user