]> git.lizzy.rs Git - micro.git/blob - statusline.go
Add todolist
[micro.git] / statusline.go
1 package main
2
3 import (
4         "github.com/gdamore/tcell"
5         "strconv"
6 )
7
8 // Statusline represents the blue line at the bottom of the
9 // editor that gives information about the buffer
10 type Statusline struct {
11         v *View
12 }
13
14 // Display draws the statusline to the screen
15 func (sl *Statusline) Display() {
16         y := sl.v.height
17
18         file := sl.v.buf.name
19         if file == "" {
20                 file = "Untitled"
21         }
22         if sl.v.buf.text != sl.v.buf.savedText {
23                 file += " +"
24         }
25         file += " (" + strconv.Itoa(sl.v.cursor.y+1) + "," + strconv.Itoa(sl.v.cursor.GetVisualX()+1) + ")"
26
27         statusLineStyle := tcell.StyleDefault.Background(tcell.ColorNavy).Foreground(tcell.ColorBlack)
28
29         for x := 0; x < sl.v.width; x++ {
30                 if x < Count(file) {
31                         sl.v.s.SetContent(x, y, []rune(file)[x], nil, statusLineStyle)
32                 } else {
33                         sl.v.s.SetContent(x, y, ' ', nil, statusLineStyle)
34                 }
35         }
36 }