]> git.lizzy.rs Git - micro.git/blob - statusline.go
Really improve syntax file compatibility with nano
[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         filetype := sl.v.buf.filetype
27         file += " " + filetype
28
29         statusLineStyle := tcell.StyleDefault.Reverse(true)
30
31         for x := 0; x < sl.v.width; x++ {
32                 if x < Count(file) {
33                         sl.v.s.SetContent(x, y, []rune(file)[x], nil, statusLineStyle)
34                         // } else if x > sl.v.width-Count(filetype)-1 {
35                         //      sl.v.s.SetContent(x, y, []rune(filetype)[Count(filetype)-(sl.v.width-1-x)-1], nil, statusLineStyle)
36                 } else {
37                         sl.v.s.SetContent(x, y, ' ', nil, statusLineStyle)
38                 }
39         }
40 }