mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-15 21:37:09 +09:00
Correct infobar and statusline options
This commit is contained in:
@@ -26,6 +26,7 @@ type BufWindow struct {
|
||||
|
||||
lineHeight []int
|
||||
gutterOffset int
|
||||
drawStatus bool
|
||||
}
|
||||
|
||||
// NewBufWindow creates a new window at a location in the screen with a width and height
|
||||
@@ -133,8 +134,12 @@ func (w *BufWindow) Bottomline() int {
|
||||
func (w *BufWindow) Relocate() bool {
|
||||
b := w.Buf
|
||||
height := w.Bottomline() + 1 - w.StartLine
|
||||
if b.LinesNum() < w.Height {
|
||||
height = w.Height - 1
|
||||
h := w.Height
|
||||
if w.drawStatus {
|
||||
h--
|
||||
}
|
||||
if b.LinesNum() <= h {
|
||||
height = w.Height
|
||||
}
|
||||
ret := false
|
||||
activeC := w.Buf.GetActiveCursor()
|
||||
@@ -181,7 +186,7 @@ func (w *BufWindow) GetMouseLoc(svloc buffer.Loc) buffer.Loc {
|
||||
|
||||
hasMessage := len(b.Messages) > 0
|
||||
bufHeight := w.Height
|
||||
if b.Settings["statusline"].(bool) {
|
||||
if w.drawStatus {
|
||||
bufHeight--
|
||||
}
|
||||
|
||||
@@ -353,7 +358,7 @@ func (w *BufWindow) displayBuffer() {
|
||||
|
||||
hasMessage := len(b.Messages) > 0
|
||||
bufHeight := w.Height
|
||||
if b.Settings["statusline"].(bool) {
|
||||
if w.drawStatus {
|
||||
bufHeight--
|
||||
}
|
||||
|
||||
@@ -537,11 +542,27 @@ func (w *BufWindow) displayBuffer() {
|
||||
}
|
||||
|
||||
func (w *BufWindow) displayStatusLine() {
|
||||
w.sline.Display()
|
||||
_, h := screen.Screen.Size()
|
||||
infoY := h
|
||||
if config.GetGlobalOption("infobar").(bool) {
|
||||
infoY--
|
||||
}
|
||||
|
||||
if w.Buf.Settings["statusline"].(bool) {
|
||||
w.drawStatus = true
|
||||
w.sline.Display()
|
||||
} else if w.Y+w.Height != infoY {
|
||||
w.drawStatus = true
|
||||
for x := w.X; x < w.X+w.Width; x++ {
|
||||
screen.Screen.SetContent(x, w.Y+w.Height-1, '-', nil, config.DefStyle.Reverse(true))
|
||||
}
|
||||
} else {
|
||||
w.drawStatus = false
|
||||
}
|
||||
}
|
||||
|
||||
// Display displays the buffer and the statusline
|
||||
func (w *BufWindow) Display() {
|
||||
w.displayBuffer()
|
||||
w.displayStatusLine()
|
||||
w.displayBuffer()
|
||||
}
|
||||
|
||||
@@ -57,35 +57,6 @@ func (i *InfoWindow) SetBuffer(b *buffer.Buffer) {
|
||||
i.InfoBuf.Buffer = b
|
||||
}
|
||||
|
||||
// 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) {}
|
||||
@@ -184,6 +155,7 @@ func (i *InfoWindow) Display() {
|
||||
if !i.HasPrompt && !i.HasMessage && !i.HasError {
|
||||
return
|
||||
}
|
||||
i.Clear()
|
||||
style := i.defStyle
|
||||
|
||||
if i.HasError {
|
||||
|
||||
@@ -69,11 +69,6 @@ var formatParser = regexp.MustCompile(`\$\(.+?\)`)
|
||||
|
||||
// Display draws the statusline to the screen
|
||||
func (s *StatusLine) Display() {
|
||||
// TODO: don't display if infobar off and has message
|
||||
if !config.GetGlobalOption("infobar").(bool) {
|
||||
return
|
||||
}
|
||||
|
||||
// We'll draw the line at the lowest line in the window
|
||||
y := s.win.Height + s.win.Y - 1
|
||||
|
||||
|
||||
@@ -23,14 +23,17 @@ func NewTermWindow(x, y, w, h int, term *shell.Terminal) *TermWindow {
|
||||
tw.View = new(View)
|
||||
tw.Terminal = term
|
||||
tw.X, tw.Y = x, y
|
||||
tw.Width, tw.Height = w, h-1
|
||||
tw.Resize(tw.Width, tw.Height)
|
||||
tw.Resize(w, h)
|
||||
return tw
|
||||
}
|
||||
|
||||
// Resize informs the terminal of a resize event
|
||||
func (w *TermWindow) Resize(width, height int) {
|
||||
if config.GetGlobalOption("statusline").(bool) {
|
||||
height--
|
||||
}
|
||||
w.Term.Resize(width, height)
|
||||
w.Width, w.Height = width, height
|
||||
}
|
||||
|
||||
func (w *TermWindow) SetActive(b bool) {
|
||||
|
||||
Reference in New Issue
Block a user