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 len(kmenuBinding) > 0 {
51 if globalSettings["keymenu"].(bool) {
52 rightText += kmenuBinding + ": hide bindings"
54 rightText += kmenuBinding + ": show bindings"
57 if len(helpBinding) > 0 {
58 if len(kmenuBinding) > 0 {
61 if sline.view.Type == vtHelp {
62 rightText += helpBinding + ": close help"
64 rightText += helpBinding + ": open help"
69 statusLineStyle := defStyle.Reverse(true)
70 if style, ok := colorscheme["statusline"]; ok {
71 statusLineStyle = style
74 // Maybe there is a unicode filename?
75 fileRunes := []rune(file)
78 screen.SetContent(viewX, y, ' ', nil, statusLineStyle)
81 for x := 0; x < sline.view.Width; x++ {
82 if x < len(fileRunes) {
83 screen.SetContent(viewX+x, y, fileRunes[x], nil, statusLineStyle)
84 } else if x >= sline.view.Width-len(rightText) && x < len(rightText)+sline.view.Width-len(rightText) {
85 screen.SetContent(viewX+x, y, []rune(rightText)[x-sline.view.Width+len(rightText)], nil, statusLineStyle)
87 screen.SetContent(viewX+x, y, ' ', nil, statusLineStyle)