8 // Statusline represents the information line at the bottom
10 // It gives information such as filename, whether the file has been
11 // modified, filetype, cursor location
12 type Statusline struct {
16 // Display draws the statusline to the screen
17 func (sline *Statusline) Display() {
18 if messenger.hasPrompt && !GetGlobalOption("infobar").(bool) {
22 // We'll draw the line at the lowest line in the view
23 y := sline.view.Height + sline.view.y
25 file := sline.view.Buf.GetName()
26 if sline.view.Buf.Settings["basename"].(bool) {
27 file = path.Base(file)
30 // If the buffer is dirty (has been modified) write a little '+'
31 if sline.view.Buf.Modified() {
35 // Add one to cursor.x and cursor.y because (0,0) is the top left,
36 // but users will be used to (1,1) (first line,first column)
37 // We use GetVisualX() here because otherwise we get the column number in runes
38 // so a '\t' is only 1, when it should be tabSize
39 columnNum := strconv.Itoa(sline.view.Cursor.GetVisualX() + 1)
40 lineNum := strconv.Itoa(sline.view.Cursor.Y + 1)
42 file += " (" + lineNum + "," + columnNum + ")"
45 file += " " + sline.view.Buf.FileType()
47 file += " " + sline.view.Buf.Settings["fileformat"].(string)
50 if !sline.view.Buf.Settings["hidehelp"].(bool) {
51 if len(kmenuBinding) > 0 {
52 if globalSettings["keymenu"].(bool) {
53 rightText += kmenuBinding + ": hide bindings"
55 rightText += kmenuBinding + ": show bindings"
58 if len(helpBinding) > 0 {
59 if len(kmenuBinding) > 0 {
62 if sline.view.Type == vtHelp {
63 rightText += helpBinding + ": close help"
65 rightText += helpBinding + ": open help"
71 statusLineStyle := defStyle.Reverse(true)
72 if style, ok := colorscheme["statusline"]; ok {
73 statusLineStyle = style
76 // Maybe there is a unicode filename?
77 fileRunes := []rune(file)
79 if sline.view.Type == vtTerm {
80 fileRunes = []rune(sline.view.term.title)
86 screen.SetContent(viewX, y, ' ', nil, statusLineStyle)
89 for x := 0; x < sline.view.Width; x++ {
90 if x < len(fileRunes) {
91 screen.SetContent(viewX+x, y, fileRunes[x], nil, statusLineStyle)
92 } else if x >= sline.view.Width-len(rightText) && x < len(rightText)+sline.view.Width-len(rightText) {
93 screen.SetContent(viewX+x, y, []rune(rightText)[x-sline.view.Width+len(rightText)], nil, statusLineStyle)
95 screen.SetContent(viewX+x, y, ' ', nil, statusLineStyle)