mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-10 22:52:51 +09:00
41 lines
1001 B
Go
41 lines
1001 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gdamore/tcell"
|
|
"strconv"
|
|
)
|
|
|
|
// Statusline represents the blue line at the bottom of the
|
|
// editor that gives information about the buffer
|
|
type Statusline struct {
|
|
v *View
|
|
}
|
|
|
|
// Display draws the statusline to the screen
|
|
func (sl *Statusline) Display() {
|
|
y := sl.v.height
|
|
|
|
file := sl.v.buf.name
|
|
if file == "" {
|
|
file = "Untitled"
|
|
}
|
|
if sl.v.buf.text != sl.v.buf.savedText {
|
|
file += " +"
|
|
}
|
|
file += " (" + strconv.Itoa(sl.v.cursor.y+1) + "," + strconv.Itoa(sl.v.cursor.GetVisualX()+1) + ")"
|
|
filetype := sl.v.buf.filetype
|
|
file += " " + filetype
|
|
|
|
statusLineStyle := tcell.StyleDefault.Reverse(true)
|
|
|
|
for x := 0; x < sl.v.width; x++ {
|
|
if x < Count(file) {
|
|
sl.v.s.SetContent(x, y, []rune(file)[x], nil, statusLineStyle)
|
|
// } else if x > sl.v.width-Count(filetype)-1 {
|
|
// sl.v.s.SetContent(x, y, []rune(filetype)[Count(filetype)-(sl.v.width-1-x)-1], nil, statusLineStyle)
|
|
} else {
|
|
sl.v.s.SetContent(x, y, ' ', nil, statusLineStyle)
|
|
}
|
|
}
|
|
}
|