]> git.lizzy.rs Git - micro.git/blob - internal/display/bufwindow.go
Don't block when redraw channel becomes full
[micro.git] / internal / display / bufwindow.go
1 package display
2
3 import (
4         "strconv"
5         "unicode/utf8"
6
7         runewidth "github.com/mattn/go-runewidth"
8         "github.com/zyedidia/micro/internal/buffer"
9         "github.com/zyedidia/micro/internal/config"
10         "github.com/zyedidia/micro/internal/screen"
11         "github.com/zyedidia/micro/internal/util"
12         "github.com/zyedidia/tcell"
13 )
14
15 // The BufWindow provides a way of displaying a certain section
16 // of a buffer
17 type BufWindow struct {
18         *View
19
20         // Buffer being shown in this window
21         Buf *buffer.Buffer
22
23         active bool
24
25         sline *StatusLine
26
27         gutterOffset int
28         drawStatus   bool
29 }
30
31 // NewBufWindow creates a new window at a location in the screen with a width and height
32 func NewBufWindow(x, y, width, height int, buf *buffer.Buffer) *BufWindow {
33         w := new(BufWindow)
34         w.View = new(View)
35         w.X, w.Y, w.Width, w.Height, w.Buf = x, y, width, height, buf
36         w.active = true
37
38         w.sline = NewStatusLine(w)
39
40         return w
41 }
42
43 func (w *BufWindow) SetBuffer(b *buffer.Buffer) {
44         w.Buf = b
45 }
46
47 func (w *BufWindow) GetView() *View {
48         return w.View
49 }
50
51 func (w *BufWindow) SetView(view *View) {
52         w.View = view
53 }
54
55 func (w *BufWindow) Resize(width, height int) {
56         w.Width, w.Height = width, height
57         w.Relocate()
58 }
59
60 func (w *BufWindow) SetActive(b bool) {
61         w.active = b
62 }
63
64 func (w *BufWindow) IsActive() bool {
65         return w.active
66 }
67
68 func (w *BufWindow) getStartInfo(n, lineN int) ([]byte, int, int, *tcell.Style) {
69         tabsize := util.IntOpt(w.Buf.Settings["tabsize"])
70         width := 0
71         bloc := buffer.Loc{0, lineN}
72         b := w.Buf.LineBytes(lineN)
73         curStyle := config.DefStyle
74         var s *tcell.Style
75         for len(b) > 0 {
76                 r, size := utf8.DecodeRune(b)
77
78                 curStyle, found := w.getStyle(curStyle, bloc, r)
79                 if found {
80                         s = &curStyle
81                 }
82
83                 w := 0
84                 switch r {
85                 case '\t':
86                         ts := tabsize - (width % tabsize)
87                         w = ts
88                 default:
89                         w = runewidth.RuneWidth(r)
90                 }
91                 if width+w > n {
92                         return b, n - width, bloc.X, s
93                 }
94                 width += w
95                 b = b[size:]
96                 bloc.X++
97         }
98         return b, n - width, bloc.X, s
99 }
100
101 // Clear resets all cells in this window to the default style
102 func (w *BufWindow) Clear() {
103         for y := 0; y < w.Height; y++ {
104                 for x := 0; x < w.Width; x++ {
105                         screen.SetContent(w.X+x, w.Y+y, ' ', nil, config.DefStyle)
106                 }
107         }
108 }
109
110 // Bottomline returns the line number of the lowest line in the view
111 // You might think that this is obviously just v.StartLine + v.Height
112 // but if softwrap is enabled things get complicated since one buffer
113 // line can take up multiple lines in the view
114 func (w *BufWindow) Bottomline() int {
115         if !w.Buf.Settings["softwrap"].(bool) {
116                 h := w.StartLine + w.Height - 1
117                 if w.drawStatus {
118                         h--
119                 }
120                 return h
121         }
122
123         l := w.LocFromVisual(buffer.Loc{0, w.Y + w.Height})
124
125         return l.Y
126 }
127
128 // Relocate moves the view window so that the cursor is in view
129 // This is useful if the user has scrolled far away, and then starts typing
130 // Returns true if the window location is moved
131 func (w *BufWindow) Relocate() bool {
132         b := w.Buf
133         // how many buffer lines are in the view
134         height := w.Bottomline() + 1 - w.StartLine
135         h := w.Height
136         if w.drawStatus {
137                 h--
138         }
139         if b.LinesNum() <= h {
140                 height = w.Height
141         }
142         ret := false
143         activeC := w.Buf.GetActiveCursor()
144         cy := activeC.Y
145         scrollmargin := int(b.Settings["scrollmargin"].(float64))
146         if cy < w.StartLine+scrollmargin && cy > scrollmargin-1 {
147                 w.StartLine = cy - scrollmargin
148                 ret = true
149         } else if cy < w.StartLine {
150                 w.StartLine = cy
151                 ret = true
152         }
153         if cy > w.StartLine+height-1-scrollmargin && cy < b.LinesNum()-scrollmargin {
154                 w.StartLine = cy - height + 1 + scrollmargin
155                 ret = true
156         } else if cy >= b.LinesNum()-scrollmargin && cy >= height {
157                 w.StartLine = b.LinesNum() - height
158                 ret = true
159         }
160
161         // horizontal relocation (scrolling)
162         if !b.Settings["softwrap"].(bool) {
163                 cx := activeC.GetVisualX()
164                 if cx < w.StartCol {
165                         w.StartCol = cx
166                         ret = true
167                 }
168                 if cx+w.gutterOffset+1 > w.StartCol+w.Width {
169                         w.StartCol = cx - w.Width + w.gutterOffset + 1
170                         ret = true
171                 }
172         }
173         return ret
174 }
175
176 // LocFromVisual takes a visual location (x and y position) and returns the
177 // position in the buffer corresponding to the visual location
178 // Computing the buffer location requires essentially drawing the entire screen
179 // to account for complications like softwrap, wide characters, and horizontal scrolling
180 // If the requested position does not correspond to a buffer location it returns
181 // the nearest position
182 func (w *BufWindow) LocFromVisual(svloc buffer.Loc) buffer.Loc {
183         b := w.Buf
184
185         hasMessage := len(b.Messages) > 0
186         bufHeight := w.Height
187         if w.drawStatus {
188                 bufHeight--
189         }
190
191         bufWidth := w.Width
192         if w.Buf.Settings["scrollbar"].(bool) && w.Buf.LinesNum() > w.Height {
193                 bufWidth--
194         }
195
196         // We need to know the string length of the largest line number
197         // so we can pad appropriately when displaying line numbers
198         maxLineNumLength := len(strconv.Itoa(b.LinesNum()))
199
200         tabsize := int(b.Settings["tabsize"].(float64))
201         softwrap := b.Settings["softwrap"].(bool)
202
203         // this represents the current draw position
204         // within the current window
205         vloc := buffer.Loc{X: 0, Y: 0}
206
207         // this represents the current draw position in the buffer (char positions)
208         bloc := buffer.Loc{X: -1, Y: w.StartLine}
209
210         for vloc.Y = 0; vloc.Y < bufHeight; vloc.Y++ {
211                 vloc.X = 0
212                 if hasMessage {
213                         vloc.X += 2
214                 }
215                 if b.Settings["diffgutter"].(bool) {
216                         vloc.X++
217                 }
218                 if b.Settings["ruler"].(bool) {
219                         vloc.X += maxLineNumLength + 1
220                 }
221
222                 line := b.LineBytes(bloc.Y)
223                 line, nColsBeforeStart, bslice := util.SliceVisualEnd(line, w.StartCol, tabsize)
224                 bloc.X = bslice
225
226                 draw := func() {
227                         if nColsBeforeStart <= 0 {
228                                 vloc.X++
229                         }
230                         nColsBeforeStart--
231                 }
232
233                 totalwidth := w.StartCol - nColsBeforeStart
234
235                 if svloc.X <= vloc.X+w.X && vloc.Y+w.Y == svloc.Y {
236                         return bloc
237                 }
238                 for len(line) > 0 {
239                         if vloc.X+w.X == svloc.X && vloc.Y+w.Y == svloc.Y {
240                                 return bloc
241                         }
242
243                         r, size := utf8.DecodeRune(line)
244                         draw()
245                         width := 0
246
247                         switch r {
248                         case '\t':
249                                 ts := tabsize - (totalwidth % tabsize)
250                                 width = ts
251                         default:
252                                 width = runewidth.RuneWidth(r)
253                         }
254
255                         // Draw any extra characters either spaces for tabs or @ for incomplete wide runes
256                         if width > 1 {
257                                 for i := 1; i < width; i++ {
258                                         if vloc.X+w.X == svloc.X && vloc.Y+w.Y == svloc.Y {
259                                                 return bloc
260                                         }
261                                         draw()
262                                 }
263                         }
264                         bloc.X++
265                         line = line[size:]
266
267                         totalwidth += width
268
269                         // If we reach the end of the window then we either stop or we wrap for softwrap
270                         if vloc.X >= bufWidth {
271                                 if !softwrap {
272                                         break
273                                 } else {
274                                         vloc.Y++
275                                         if vloc.Y >= bufHeight {
276                                                 break
277                                         }
278                                         vloc.X = 0
279                                         if b.Settings["diffgutter"].(bool) {
280                                                 vloc.X++
281                                         }
282                                         // This will draw an empty line number because the current line is wrapped
283                                         if b.Settings["ruler"].(bool) {
284                                                 vloc.X += maxLineNumLength + 1
285                                         }
286                                 }
287                         }
288                 }
289                 if vloc.Y+w.Y == svloc.Y {
290                         return bloc
291                 }
292
293                 if bloc.Y+1 >= b.LinesNum() || vloc.Y+1 >= bufHeight {
294                         return bloc
295                 }
296
297                 bloc.X = w.StartCol
298                 bloc.Y++
299         }
300
301         return buffer.Loc{}
302 }
303
304 func (w *BufWindow) drawGutter(vloc *buffer.Loc, bloc *buffer.Loc) {
305         char := ' '
306         s := config.DefStyle
307         for _, m := range w.Buf.Messages {
308                 if m.Start.Y == bloc.Y || m.End.Y == bloc.Y {
309                         s = m.Style()
310                         char = '>'
311                         break
312                 }
313         }
314         screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, char, nil, s)
315         vloc.X++
316         screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, char, nil, s)
317         vloc.X++
318 }
319
320 func (w *BufWindow) drawDiffGutter(backgroundStyle tcell.Style, softwrapped bool, vloc *buffer.Loc, bloc *buffer.Loc) {
321         symbol := ' '
322         styleName := ""
323
324         switch w.Buf.DiffStatus(bloc.Y) {
325         case buffer.DSAdded:
326                 symbol = '\u258C' // Left half block
327                 styleName = "diff-added"
328         case buffer.DSModified:
329                 symbol = '\u258C' // Left half block
330                 styleName = "diff-modified"
331         case buffer.DSDeletedAbove:
332                 if !softwrapped {
333                         symbol = '\u2594' // Upper one eighth block
334                         styleName = "diff-deleted"
335                 }
336         }
337
338         style := backgroundStyle
339         if s, ok := config.Colorscheme[styleName]; ok {
340                 foreground, _, _ := s.Decompose()
341                 style = style.Foreground(foreground)
342         }
343
344         screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, symbol, nil, style)
345         vloc.X++
346 }
347
348 func (w *BufWindow) drawLineNum(lineNumStyle tcell.Style, softwrapped bool, maxLineNumLength int, vloc *buffer.Loc, bloc *buffer.Loc) {
349         lineNum := strconv.Itoa(bloc.Y + 1)
350
351         // Write the spaces before the line number if necessary
352         for i := 0; i < maxLineNumLength-len(lineNum); i++ {
353                 screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, ' ', nil, lineNumStyle)
354                 vloc.X++
355         }
356         // Write the actual line number
357         for _, ch := range lineNum {
358                 if softwrapped {
359                         screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, ' ', nil, lineNumStyle)
360                 } else {
361                         screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, ch, nil, lineNumStyle)
362                 }
363                 vloc.X++
364         }
365
366         // Write the extra space
367         screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, ' ', nil, lineNumStyle)
368         vloc.X++
369 }
370
371 // getStyle returns the highlight style for the given character position
372 // If there is no change to the current highlight style it just returns that
373 func (w *BufWindow) getStyle(style tcell.Style, bloc buffer.Loc, r rune) (tcell.Style, bool) {
374         if group, ok := w.Buf.Match(bloc.Y)[bloc.X]; ok {
375                 s := config.GetColor(group.String())
376                 return s, true
377         }
378         return style, false
379 }
380
381 func (w *BufWindow) showCursor(x, y int, main bool) {
382         if w.active {
383                 if main {
384                         screen.ShowCursor(x, y)
385                 } else {
386                         screen.ShowFakeCursorMulti(x, y)
387                 }
388         }
389 }
390
391 // displayBuffer draws the buffer being shown in this window on the screen.Screen
392 func (w *BufWindow) displayBuffer() {
393         b := w.Buf
394
395         if w.Height <= 0 || w.Width <= 0 {
396                 return
397         }
398
399         hasMessage := len(b.Messages) > 0
400         bufHeight := w.Height
401         if w.drawStatus {
402                 bufHeight--
403         }
404
405         bufWidth := w.Width
406         if w.Buf.Settings["scrollbar"].(bool) && w.Buf.LinesNum() > w.Height {
407                 bufWidth--
408         }
409
410         if len(b.Modifications) > 0 {
411                 if b.Settings["syntax"].(bool) && b.SyntaxDef != nil {
412                         for _, r := range b.Modifications {
413                                 final := -1
414                                 for i := r.X; i <= r.Y; i++ {
415                                         final = util.Max(b.Highlighter.ReHighlightStates(b, i), final)
416                                 }
417                                 b.Highlighter.HighlightMatches(b, r.X, final+1)
418                         }
419                 }
420
421                 b.ClearModifications()
422
423                 if b.Settings["diffgutter"].(bool) {
424                         b.UpdateDiff(func(synchronous bool) {
425                                 // If the diff was updated asynchronously, the outer call to
426                                 // displayBuffer might already be completed and we need to
427                                 // schedule a redraw in order to display the new diff.
428                                 // Note that this cannot lead to an infinite recursion
429                                 // because the modifications were cleared above so there won't
430                                 // be another call to UpdateDiff when displayBuffer is called
431                                 // during the redraw.
432                                 if !synchronous {
433                                         screen.Redraw()
434                                 }
435                         })
436                 }
437         }
438
439         var matchingBraces []buffer.Loc
440         // bracePairs is defined in buffer.go
441         if b.Settings["matchbrace"].(bool) {
442                 for _, bp := range buffer.BracePairs {
443                         for _, c := range b.GetCursors() {
444                                 if c.HasSelection() {
445                                         continue
446                                 }
447                                 curX := c.X
448                                 curLoc := c.Loc
449
450                                 r := c.RuneUnder(curX)
451                                 rl := c.RuneUnder(curX - 1)
452                                 if r == bp[0] || r == bp[1] || rl == bp[0] || rl == bp[1] {
453                                         mb, left := b.FindMatchingBrace(bp, curLoc)
454                                         matchingBraces = append(matchingBraces, mb)
455                                         if !left {
456                                                 matchingBraces = append(matchingBraces, curLoc)
457                                         } else {
458                                                 matchingBraces = append(matchingBraces, curLoc.Move(-1, b))
459                                         }
460                                 }
461                         }
462                 }
463         }
464
465         lineNumStyle := config.DefStyle
466         if style, ok := config.Colorscheme["line-number"]; ok {
467                 lineNumStyle = style
468         }
469         curNumStyle := config.DefStyle
470         if style, ok := config.Colorscheme["current-line-number"]; ok {
471                 if !b.Settings["cursorline"].(bool) {
472                         curNumStyle = lineNumStyle
473                 } else {
474                         curNumStyle = style
475                 }
476         }
477
478         // We need to know the string length of the largest line number
479         // so we can pad appropriately when displaying line numbers
480         maxLineNumLength := len(strconv.Itoa(b.LinesNum()))
481
482         softwrap := b.Settings["softwrap"].(bool)
483         tabsize := util.IntOpt(b.Settings["tabsize"])
484         colorcolumn := util.IntOpt(b.Settings["colorcolumn"])
485
486         // this represents the current draw position
487         // within the current window
488         vloc := buffer.Loc{X: 0, Y: 0}
489
490         // this represents the current draw position in the buffer (char positions)
491         bloc := buffer.Loc{X: -1, Y: w.StartLine}
492
493         cursors := b.GetCursors()
494
495         curStyle := config.DefStyle
496         for vloc.Y = 0; vloc.Y < bufHeight; vloc.Y++ {
497                 vloc.X = 0
498
499                 currentLine := false
500                 for _, c := range cursors {
501                         if bloc.Y == c.Y && w.active {
502                                 currentLine = true
503                                 break
504                         }
505                 }
506
507                 s := lineNumStyle
508                 if currentLine {
509                         s = curNumStyle
510                 }
511
512                 if hasMessage {
513                         w.drawGutter(&vloc, &bloc)
514                 }
515
516                 if b.Settings["diffgutter"].(bool) {
517                         w.drawDiffGutter(s, false, &vloc, &bloc)
518                 }
519
520                 if b.Settings["ruler"].(bool) {
521                         w.drawLineNum(s, false, maxLineNumLength, &vloc, &bloc)
522                 }
523
524                 w.gutterOffset = vloc.X
525
526                 line, nColsBeforeStart, bslice, startStyle := w.getStartInfo(w.StartCol, bloc.Y)
527                 if startStyle != nil {
528                         curStyle = *startStyle
529                 }
530                 bloc.X = bslice
531
532                 draw := func(r rune, style tcell.Style, showcursor bool) {
533                         if nColsBeforeStart <= 0 {
534                                 for _, c := range cursors {
535                                         if c.HasSelection() &&
536                                                 (bloc.GreaterEqual(c.CurSelection[0]) && bloc.LessThan(c.CurSelection[1]) ||
537                                                         bloc.LessThan(c.CurSelection[0]) && bloc.GreaterEqual(c.CurSelection[1])) {
538                                                 // The current character is selected
539                                                 style = config.DefStyle.Reverse(true)
540
541                                                 if s, ok := config.Colorscheme["selection"]; ok {
542                                                         style = s
543                                                 }
544                                         }
545
546                                         if b.Settings["cursorline"].(bool) && w.active &&
547                                                 !c.HasSelection() && c.Y == bloc.Y {
548                                                 if s, ok := config.Colorscheme["cursor-line"]; ok {
549                                                         fg, _, _ := s.Decompose()
550                                                         style = style.Background(fg)
551                                                 }
552                                         }
553                                 }
554
555                                 for _, m := range b.Messages {
556                                         if bloc.GreaterEqual(m.Start) && bloc.LessThan(m.End) ||
557                                                 bloc.LessThan(m.End) && bloc.GreaterEqual(m.Start) {
558                                                 style = style.Underline(true)
559                                                 break
560                                         }
561                                 }
562
563                                 if r == '\t' {
564                                         indentrunes := []rune(b.Settings["indentchar"].(string))
565                                         // if empty indentchar settings, use space
566                                         if indentrunes == nil || len(indentrunes) == 0 {
567                                                 indentrunes = []rune{' '}
568                                         }
569
570                                         r = indentrunes[0]
571                                         if s, ok := config.Colorscheme["indent-char"]; ok && r != ' ' {
572                                                 fg, _, _ := s.Decompose()
573                                                 style = style.Foreground(fg)
574                                         }
575                                 }
576
577                                 if s, ok := config.Colorscheme["color-column"]; ok {
578                                         if colorcolumn != 0 && vloc.X-w.gutterOffset == colorcolumn {
579                                                 fg, _, _ := s.Decompose()
580                                                 style = style.Background(fg)
581                                         }
582                                 }
583
584                                 for _, mb := range matchingBraces {
585                                         if mb.X == bloc.X && mb.Y == bloc.Y {
586                                                 style = style.Underline(true)
587                                         }
588                                 }
589
590                                 screen.SetContent(w.X+vloc.X, w.Y+vloc.Y, r, nil, style)
591
592                                 if showcursor {
593                                         for _, c := range cursors {
594                                                 if c.X == bloc.X && c.Y == bloc.Y && !c.HasSelection() {
595                                                         w.showCursor(w.X+vloc.X, w.Y+vloc.Y, c.Num == 0)
596                                                 }
597                                         }
598                                 }
599                                 vloc.X++
600                         }
601                         nColsBeforeStart--
602                 }
603
604                 totalwidth := w.StartCol - nColsBeforeStart
605                 for len(line) > 0 {
606                         r, size := utf8.DecodeRune(line)
607                         curStyle, _ = w.getStyle(curStyle, bloc, r)
608
609                         draw(r, curStyle, true)
610
611                         width := 0
612
613                         char := ' '
614                         switch r {
615                         case '\t':
616                                 ts := tabsize - (totalwidth % tabsize)
617                                 width = ts
618                         default:
619                                 width = runewidth.RuneWidth(r)
620                                 char = '@'
621                         }
622
623                         // Draw any extra characters either spaces for tabs or @ for incomplete wide runes
624                         if width > 1 {
625                                 for i := 1; i < width; i++ {
626                                         draw(char, curStyle, false)
627                                 }
628                         }
629                         bloc.X++
630                         line = line[size:]
631
632                         totalwidth += width
633
634                         // If we reach the end of the window then we either stop or we wrap for softwrap
635                         if vloc.X >= bufWidth {
636                                 if !softwrap {
637                                         break
638                                 } else {
639                                         vloc.Y++
640                                         if vloc.Y >= bufHeight {
641                                                 break
642                                         }
643                                         vloc.X = 0
644                                         if b.Settings["diffgutter"].(bool) {
645                                                 w.drawDiffGutter(lineNumStyle, true, &vloc, &bloc)
646                                         }
647                                         // This will draw an empty line number because the current line is wrapped
648                                         if b.Settings["ruler"].(bool) {
649                                                 w.drawLineNum(lineNumStyle, true, maxLineNumLength, &vloc, &bloc)
650                                         }
651                                 }
652                         }
653                 }
654
655                 style := config.DefStyle
656                 for _, c := range cursors {
657                         if b.Settings["cursorline"].(bool) && w.active &&
658                                 !c.HasSelection() && c.Y == bloc.Y {
659                                 if s, ok := config.Colorscheme["cursor-line"]; ok {
660                                         fg, _, _ := s.Decompose()
661                                         style = style.Background(fg)
662                                 }
663                         }
664                 }
665                 for i := vloc.X; i < bufWidth; i++ {
666                         curStyle := style
667                         if s, ok := config.Colorscheme["color-column"]; ok {
668                                 if colorcolumn != 0 && i-w.gutterOffset == colorcolumn {
669                                         fg, _, _ := s.Decompose()
670                                         curStyle = style.Background(fg)
671                                 }
672                         }
673                         screen.SetContent(i+w.X, vloc.Y+w.Y, ' ', nil, curStyle)
674                 }
675
676                 if vloc.X != bufWidth {
677                         draw(' ', curStyle, true)
678                 }
679
680                 bloc.X = w.StartCol
681                 bloc.Y++
682                 if bloc.Y >= b.LinesNum() {
683                         break
684                 }
685         }
686 }
687
688 func (w *BufWindow) displayStatusLine() {
689         _, h := screen.Screen.Size()
690         infoY := h
691         if config.GetGlobalOption("infobar").(bool) {
692                 infoY--
693         }
694
695         if w.Buf.Settings["statusline"].(bool) {
696                 w.drawStatus = true
697                 w.sline.Display()
698         } else if w.Y+w.Height != infoY {
699                 w.drawStatus = true
700                 for x := w.X; x < w.X+w.Width; x++ {
701                         screen.SetContent(x, w.Y+w.Height-1, '-', nil, config.DefStyle.Reverse(true))
702                 }
703         } else {
704                 w.drawStatus = false
705         }
706 }
707
708 func (w *BufWindow) displayScrollBar() {
709         if w.Buf.Settings["scrollbar"].(bool) && w.Buf.LinesNum() > w.Height {
710                 scrollX := w.X + w.Width - 1
711                 bufHeight := w.Height
712                 if w.drawStatus {
713                         bufHeight--
714                 }
715                 barsize := int(float64(w.Height) / float64(w.Buf.LinesNum()) * float64(w.Height))
716                 if barsize < 1 {
717                         barsize = 1
718                 }
719                 barstart := w.Y + int(float64(w.StartLine)/float64(w.Buf.LinesNum())*float64(w.Height))
720                 for y := barstart; y < util.Min(barstart+barsize, w.Y+bufHeight); y++ {
721                         screen.SetContent(scrollX, y, '|', nil, config.DefStyle.Reverse(true))
722                 }
723         }
724 }
725
726 // Display displays the buffer and the statusline
727 func (w *BufWindow) Display() {
728         w.displayStatusLine()
729         w.displayScrollBar()
730         w.displayBuffer()
731 }