Display draws the statusline to the screen
()
| 107 | |
| 108 | // Display draws the statusline to the screen |
| 109 | func (s *StatusLine) Display() { |
| 110 | // We'll draw the line at the lowest line in the window |
| 111 | y := s.win.Height + s.win.Y - 1 |
| 112 | |
| 113 | winX := s.win.X |
| 114 | |
| 115 | b := s.win.Buf |
| 116 | // autocomplete suggestions (for the buffer, not for the infowindow) |
| 117 | if b.HasSuggestions && len(b.Suggestions) > 1 { |
| 118 | statusLineStyle := config.DefStyle.Reverse(true) |
| 119 | if style, ok := config.Colorscheme["statusline.suggestions"]; ok { |
| 120 | statusLineStyle = style |
| 121 | } else if style, ok := config.Colorscheme["statusline"]; ok { |
| 122 | statusLineStyle = style |
| 123 | } |
| 124 | x := 0 |
| 125 | for j, sug := range b.Suggestions { |
| 126 | style := statusLineStyle |
| 127 | if b.CurSuggestion == j { |
| 128 | style = style.Reverse(true) |
| 129 | } |
| 130 | for _, r := range sug { |
| 131 | screen.SetContent(winX+x, y, r, nil, style) |
| 132 | x++ |
| 133 | if x >= s.win.Width { |
| 134 | return |
| 135 | } |
| 136 | } |
| 137 | screen.SetContent(winX+x, y, ' ', nil, statusLineStyle) |
| 138 | x++ |
| 139 | if x >= s.win.Width { |
| 140 | return |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | for x < s.win.Width { |
| 145 | screen.SetContent(winX+x, y, ' ', nil, statusLineStyle) |
| 146 | x++ |
| 147 | } |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | formatter := func(match []byte) []byte { |
| 152 | name := match[2 : len(match)-1] |
| 153 | if bytes.HasPrefix(name, []byte("opt")) { |
| 154 | option := name[4:] |
| 155 | return fmt.Append(nil, s.FindOpt(string(option))) |
| 156 | } else if bytes.HasPrefix(name, []byte("bind")) { |
| 157 | binding := string(name[5:]) |
| 158 | for k, v := range config.Bindings["buffer"] { |
| 159 | if v == binding { |
| 160 | return []byte(k) |
| 161 | } |
| 162 | } |
| 163 | return []byte("null") |
| 164 | } else { |
| 165 | if fn, ok := statusInfo[string(name)]; ok { |
| 166 | return []byte(fn(s.win.Buf)) |
nothing calls this directly
no test coverage detected