9 "github.com/mattn/go-runewidth"
10 "github.com/mitchellh/go-homedir"
11 "github.com/zyedidia/tcell"
17 vtDefault ViewType = iota
22 // The View struct stores information about a view into a buffer.
23 // It stores information about the cursor, and the viewport
24 // that the user sees the buffer from.
26 // A pointer to the buffer's cursor for ease of access
29 // The topmost line, used for vertical scrolling
31 // The leftmost column, used for horizontal scrolling
34 // Specifies whether or not this view holds a help buffer
37 // Actual width and height
44 // Where this view is located
47 // How much to offset because of line numbers
50 // Holds the list of gutter messages
51 messages map[string][]GutterMessage
53 // This is the index of this view in the views array
55 // What tab is this view stored in
63 // Since tcell doesn't differentiate between a mouse release event
64 // and a mouse move event with no keys pressed, we need to keep
65 // track of whether or not the mouse was pressed (or not released) last event to determine
66 // mouse release events
69 // This stores when the last click was
70 // This is useful for detecting double and triple clicks
71 lastClickTime time.Time
73 // lastCutTime stores when the last ctrl+k was issued.
74 // It is used for clearing the clipboard to replace it with fresh cut lines.
77 // freshClip returns true if the clipboard has never been pasted.
80 // Was the last mouse event actually a double click?
81 // Useful for detecting triple clicks -- if a double click is detected
82 // but the last mouse event was actually a double click, it's a triple click
84 // Same here, just to keep track for mouse move events
87 // Syntax highlighting matches
93 // NewView returns a new fullscreen view
94 func NewView(buf *Buffer) *View {
95 screenW, screenH := screen.Size()
96 return NewViewWidthHeight(buf, screenW, screenH)
99 // NewViewWidthHeight returns a new view with the specified width and height
100 // Note that w and h are raw column and row values
101 func NewViewWidthHeight(buf *Buffer, w, h int) *View {
113 v.messages = make(map[string][]GutterMessage)
115 v.sline = Statusline{
119 if v.Buf.Settings["statusline"].(bool) {
123 for pl := range loadedPlugins {
124 _, err := Call(pl+".onViewOpen", v)
125 if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
134 // ToggleStatusLine creates an extra row for the statusline if necessary
135 func (v *View) ToggleStatusLine() {
136 if v.Buf.Settings["statusline"].(bool) {
143 // ToggleTabbar creates an extra row for the tabbar if necessary
144 func (v *View) ToggleTabbar() {
147 // Include one line for the tab bar at the top
159 func (v *View) paste(clip string) {
160 leadingWS := GetLeadingWhitespace(v.Buf.Line(v.Cursor.Y))
162 if v.Cursor.HasSelection() {
163 v.Cursor.DeleteSelection()
164 v.Cursor.ResetSelection()
166 clip = strings.Replace(clip, "\n", "\n"+leadingWS, -1)
167 v.Buf.Insert(v.Cursor.Loc, clip)
168 v.Cursor.Loc = v.Cursor.Loc.Move(Count(clip), v.Buf)
170 messenger.Message("Pasted clipboard")
173 // ScrollUp scrolls the view up n lines (if possible)
174 func (v *View) ScrollUp(n int) {
175 // Try to scroll by n but if it would overflow, scroll by 1
176 if v.Topline-n >= 0 {
178 } else if v.Topline > 0 {
183 // ScrollDown scrolls the view down n lines (if possible)
184 func (v *View) ScrollDown(n int) {
185 // Try to scroll by n but if it would overflow, scroll by 1
186 if v.Topline+n <= v.Buf.NumLines-v.Height {
188 } else if v.Topline < v.Buf.NumLines-v.Height {
193 // CanClose returns whether or not the view can be closed
194 // If there are unsaved changes, the user will be asked if the view can be closed
195 // causing them to lose the unsaved changes
196 func (v *View) CanClose() bool {
197 if v.Type == vtDefault && v.Buf.IsModified {
200 if v.Buf.Settings["autosave"].(bool) {
203 char, canceled = messenger.LetterPrompt("Save changes to "+v.Buf.GetName()+" before closing? (y,n,esc) ", 'y', 'n')
209 } else if char == 'n' {
219 // OpenBuffer opens a new buffer in this view.
220 // This resets the topline, event handler and cursor.
221 func (v *View) OpenBuffer(buf *Buffer) {
225 v.Cursor = &buf.Cursor
228 v.Cursor.ResetSelection()
231 v.messages = make(map[string][]GutterMessage)
235 // Set mouseReleased to true because we assume the mouse is not being pressed when
236 // the editor is opened
237 v.mouseReleased = true
238 v.lastClickTime = time.Time{}
241 // Open opens the given file in the view
242 func (v *View) Open(filename string) {
243 home, _ := homedir.Dir()
244 filename = strings.Replace(filename, "~", home, 1)
245 file, err := os.Open(filename)
250 messenger.Message(err.Error())
251 // File does not exist -- create an empty buffer with that name
252 buf = NewBuffer(strings.NewReader(""), filename)
254 buf = NewBuffer(file, filename)
259 // CloseBuffer performs any closing functions on the buffer
260 func (v *View) CloseBuffer() {
266 // ReOpen reloads the current buffer
267 func (v *View) ReOpen() {
276 // HSplit opens a horizontal split with the given buffer
277 func (v *View) HSplit(buf *Buffer) {
279 if v.Buf.Settings["splitBottom"].(bool) {
282 v.splitNode.HSplit(buf, v.Num+i)
285 // VSplit opens a vertical split with the given buffer
286 func (v *View) VSplit(buf *Buffer) {
288 if v.Buf.Settings["splitRight"].(bool) {
291 v.splitNode.VSplit(buf, v.Num+i)
294 // HSplitIndex opens a horizontal split with the given buffer at the given index
295 func (v *View) HSplitIndex(buf *Buffer, splitIndex int) {
296 v.splitNode.HSplit(buf, splitIndex)
299 // VSplitIndex opens a vertical split with the given buffer at the given index
300 func (v *View) VSplitIndex(buf *Buffer, splitIndex int) {
301 v.splitNode.VSplit(buf, splitIndex)
304 // GetSoftWrapLocation gets the location of a visual click on the screen and converts it to col,line
305 func (v *View) GetSoftWrapLocation(vx, vy int) (int, int) {
306 if !v.Buf.Settings["softwrap"].(bool) {
307 if vy >= v.Buf.NumLines {
308 vy = v.Buf.NumLines - 1
310 vx = v.Cursor.GetCharPosInLine(vy, vx)
314 screenX, screenY := 0, v.Topline
315 for lineN := v.Topline; lineN < v.Bottomline(); lineN++ {
316 line := v.Buf.Line(lineN)
317 if lineN >= v.Buf.NumLines {
318 return 0, v.Buf.NumLines - 1
322 for _, ch := range line {
323 if screenX >= v.Width-v.lineNumOffset {
328 if screenX == vx && screenY == vy {
333 screenX += int(v.Buf.Settings["tabsize"].(float64)) - 1
349 func (v *View) Bottomline() int {
350 if !v.Buf.Settings["softwrap"].(bool) {
351 return v.Topline + v.Height
354 screenX, screenY := 0, 0
356 for lineN := v.Topline; lineN < v.Topline+v.Height; lineN++ {
357 line := v.Buf.Line(lineN)
360 for _, ch := range line {
361 if screenX >= v.Width-v.lineNumOffset {
367 screenX += int(v.Buf.Settings["tabsize"].(float64)) - 1
377 if screenY >= v.Height {
381 return numLines + v.Topline
384 // Relocate moves the view window so that the cursor is in view
385 // This is useful if the user has scrolled far away, and then starts typing
386 func (v *View) Relocate() bool {
387 height := v.Bottomline() - v.Topline
390 scrollmargin := int(v.Buf.Settings["scrollmargin"].(float64))
391 if cy < v.Topline+scrollmargin && cy > scrollmargin-1 {
392 v.Topline = cy - scrollmargin
394 } else if cy < v.Topline {
398 if cy > v.Topline+height-1-scrollmargin && cy < v.Buf.NumLines-scrollmargin {
399 v.Topline = cy - height + 1 + scrollmargin
401 } else if cy >= v.Buf.NumLines-scrollmargin && cy > height {
402 v.Topline = v.Buf.NumLines - height
406 if !v.Buf.Settings["softwrap"].(bool) {
407 cx := v.Cursor.GetVisualX()
412 if cx+v.lineNumOffset+1 > v.leftCol+v.Width {
413 v.leftCol = cx - v.Width + v.lineNumOffset + 1
420 // MoveToMouseClick moves the cursor to location x, y assuming x, y were given
422 func (v *View) MoveToMouseClick(x, y int) {
423 if y-v.Topline > v.Height-1 {
425 y = v.Height + v.Topline - 1
434 x, y = v.GetSoftWrapLocation(x, y)
435 // x = v.Cursor.GetCharPosInLine(y, x)
436 if x > Count(v.Buf.Line(y)) {
437 x = Count(v.Buf.Line(y))
441 v.Cursor.LastVisualX = v.Cursor.GetVisualX()
444 // HandleEvent handles an event passed by the main loop
445 func (v *View) HandleEvent(event tcell.Event) {
446 // This bool determines whether the view is relocated at the end of the function
447 // By default it's true because most events should cause a relocate
452 switch e := event.(type) {
453 case *tcell.EventKey:
454 // Check first if input is a key binding, if it is we 'eat' the input and don't insert a rune
456 if e.Key() != tcell.KeyRune || e.Modifiers() != 0 {
457 for key, actions := range bindings {
458 if e.Key() == key.keyCode {
459 if e.Key() == tcell.KeyRune {
460 if e.Rune() != key.r {
464 if e.Modifiers() == key.modifiers {
467 for _, action := range actions {
468 relocate = action(v, true) || relocate
469 funcName := FuncName(action)
470 if funcName != "main.(*View).ToggleMacro" && funcName != "main.(*View).PlayMacro" {
472 curMacro = append(curMacro, action)
481 if !isBinding && e.Key() == tcell.KeyRune {
482 // Insert a character
483 if v.Cursor.HasSelection() {
484 v.Cursor.DeleteSelection()
485 v.Cursor.ResetSelection()
487 v.Buf.Insert(v.Cursor.Loc, string(e.Rune()))
490 for pl := range loadedPlugins {
491 _, err := Call(pl+".onRune", string(e.Rune()), v)
492 if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
498 curMacro = append(curMacro, e.Rune())
501 case *tcell.EventPaste:
502 if !PreActionCall("Paste", v) {
508 PostActionCall("Paste", v)
509 case *tcell.EventMouse:
511 x -= v.lineNumOffset - v.leftCol + v.x
513 // Don't relocate for mouse events
516 button := e.Buttons()
522 v.MoveToMouseClick(x, y)
523 if time.Since(v.lastClickTime)/time.Millisecond < doubleClickThreshold {
526 v.lastClickTime = time.Now()
529 v.doubleClick = false
531 v.Cursor.SelectLine()
532 v.Cursor.CopySelection("primary")
535 v.lastClickTime = time.Now()
538 v.tripleClick = false
540 v.Cursor.SelectWord()
541 v.Cursor.CopySelection("primary")
544 v.doubleClick = false
545 v.tripleClick = false
546 v.lastClickTime = time.Now()
548 v.Cursor.OrigSelection[0] = v.Cursor.Loc
549 v.Cursor.CurSelection[0] = v.Cursor.Loc
550 v.Cursor.CurSelection[1] = v.Cursor.Loc
552 v.mouseReleased = false
553 } else if !v.mouseReleased {
554 v.MoveToMouseClick(x, y)
556 v.Cursor.AddLineToSelection()
557 } else if v.doubleClick {
558 v.Cursor.AddWordToSelection()
560 v.Cursor.SetSelectionEnd(v.Cursor.Loc)
561 v.Cursor.CopySelection("primary")
565 // Middle mouse button was clicked,
566 // We should paste primary
568 case tcell.ButtonNone:
569 // Mouse event with no click
570 if !v.mouseReleased {
571 // Mouse was just released
573 // Relocating here isn't really necessary because the cursor will
574 // be in the right place from the last mouse event
575 // However, if we are running in a terminal that doesn't support mouse motion
576 // events, this still allows the user to make selections, except only after they
579 if !v.doubleClick && !v.tripleClick {
580 v.MoveToMouseClick(x, y)
581 v.Cursor.SetSelectionEnd(v.Cursor.Loc)
582 v.Cursor.CopySelection("primary")
584 v.mouseReleased = true
588 scrollspeed := int(v.Buf.Settings["scrollspeed"].(float64))
589 v.ScrollUp(scrollspeed)
590 case tcell.WheelDown:
592 scrollspeed := int(v.Buf.Settings["scrollspeed"].(float64))
593 v.ScrollDown(scrollspeed)
602 // GutterMessage creates a message in this view's gutter
603 func (v *View) GutterMessage(section string, lineN int, msg string, kind int) {
605 gutterMsg := GutterMessage{
610 for _, v := range v.messages {
611 for _, gmsg := range v {
612 if gmsg.lineNum == lineN {
617 messages := v.messages[section]
618 v.messages[section] = append(messages, gutterMsg)
621 // ClearGutterMessages clears all gutter messages from a given section
622 func (v *View) ClearGutterMessages(section string) {
623 v.messages[section] = []GutterMessage{}
626 // ClearAllGutterMessages clears all the gutter messages
627 func (v *View) ClearAllGutterMessages() {
628 for k := range v.messages {
629 v.messages[k] = []GutterMessage{}
633 // Opens the given help page in a new horizontal split
634 func (v *View) openHelp(helpPage string) {
635 if data, err := FindRuntimeFile(RTHelp, helpPage).Data(); err != nil {
636 TermMessage("Unable to load help text", helpPage, "\n", err)
638 helpBuffer := NewBuffer(strings.NewReader(string(data)), helpPage+".md")
639 helpBuffer.name = "Help"
641 if v.Type == vtHelp {
642 v.OpenBuffer(helpBuffer)
645 CurView().Type = vtHelp
650 func (v *View) drawCell(x, y int, ch rune, combc []rune, style tcell.Style) {
651 if x >= v.x && x < v.x+v.Width && y >= v.y && y < v.y+v.Height {
652 screen.SetContent(x, y, ch, combc, style)
656 // DisplayView renders the view to the screen
657 func (v *View) DisplayView() {
659 // Log views should always follow the cursor...
663 if v.Buf.Settings["syntax"].(bool) {
667 // The charNum we are currently displaying
668 // starts at the start of the viewport
669 charNum := Loc{0, v.Topline}
671 // Convert the length of buffer to a string, and get the length of the string
672 // We are going to have to offset by that amount
673 maxLineLength := len(strconv.Itoa(v.Buf.NumLines))
675 if v.Buf.Settings["ruler"] == true {
676 // + 1 for the little space after the line number
677 v.lineNumOffset = maxLineLength + 1
682 // We need to add to the line offset if there are gutter messages
683 var hasGutterMessages bool
684 for _, v := range v.messages {
686 hasGutterMessages = true
689 if hasGutterMessages {
694 // One space for the extra split divider
698 // These represent the current screen coordinates
699 screenX, screenY := v.x, v.y-1
701 highlightStyle := defStyle
704 // ViewLine is the current line from the top of the viewport
705 for viewLine := 0; viewLine < v.Height; viewLine++ {
709 // This is the current line number of the buffer that we are drawing
710 curLineN = viewLine + v.Topline
712 if screenY-v.y >= v.Height {
717 dividerStyle := defStyle
718 if style, ok := colorscheme["divider"]; ok {
721 // Draw the split divider
722 v.drawCell(screenX, screenY, tcell.RuneVLine, nil, dividerStyle)
726 // If the buffer is smaller than the view height we have to clear all this space
727 if curLineN >= v.Buf.NumLines {
728 for i := screenX; i < v.x+v.Width; i++ {
729 v.drawCell(i, screenY, ' ', nil, defStyle)
734 line := v.Buf.Line(curLineN)
736 // If there are gutter messages we need to display the '>>' symbol here
737 if hasGutterMessages {
738 // msgOnLine stores whether or not there is a gutter message on this line in particular
740 for k := range v.messages {
741 for _, msg := range v.messages[k] {
742 if msg.lineNum == curLineN {
744 gutterStyle := defStyle
747 if style, ok := colorscheme["gutter-info"]; ok {
751 if style, ok := colorscheme["gutter-warning"]; ok {
755 if style, ok := colorscheme["gutter-error"]; ok {
759 v.drawCell(screenX, screenY, '>', nil, gutterStyle)
761 v.drawCell(screenX, screenY, '>', nil, gutterStyle)
763 if v.Cursor.Y == curLineN && !messenger.hasPrompt {
764 messenger.Message(msg.msg)
765 messenger.gutterMessage = true
770 // If there is no message on this line we just display an empty offset
772 v.drawCell(screenX, screenY, ' ', nil, defStyle)
774 v.drawCell(screenX, screenY, ' ', nil, defStyle)
776 if v.Cursor.Y == curLineN && messenger.gutterMessage {
778 messenger.gutterMessage = false
783 lineNumStyle := defStyle
784 if v.Buf.Settings["ruler"] == true {
785 // Write the line number
786 if style, ok := colorscheme["line-number"]; ok {
789 if style, ok := colorscheme["current-line-number"]; ok {
790 if curLineN == v.Cursor.Y && tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() {
795 lineNum := strconv.Itoa(curLineN + 1)
797 // Write the spaces before the line number if necessary
798 for i := 0; i < maxLineLength-len(lineNum); i++ {
799 v.drawCell(screenX, screenY, ' ', nil, lineNumStyle)
802 // Write the actual line number
803 for _, ch := range lineNum {
804 v.drawCell(screenX, screenY, ch, nil, lineNumStyle)
808 // Write the extra space
809 v.drawCell(screenX, screenY, ' ', nil, lineNumStyle)
813 // Now we actually draw the line
816 tabSize := int(v.Buf.Settings["tabsize"].(float64))
817 for _, ch := range line {
818 if v.Buf.Settings["softwrap"].(bool) {
819 if screenX-v.x >= v.Width {
823 if hasGutterMessages {
824 v.drawCell(v.x+x, screenY, ' ', nil, defStyle)
826 v.drawCell(v.x+x, screenY, ' ', nil, defStyle)
829 for i := 0; i < v.lineNumOffset; i++ {
830 screen.SetContent(v.x+i+x, screenY, ' ', nil, lineNumStyle)
832 screenX = v.x + v.lineNumOffset
836 if tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == curLineN && colN == v.Cursor.X {
837 v.DisplayCursor(screenX-v.leftCol, screenY)
840 lineStyle := defStyle
842 if v.Buf.Settings["syntax"].(bool) {
843 // Syntax highlighting is enabled
844 highlightStyle = v.matches[viewLine][colN]
847 if v.Cursor.HasSelection() &&
848 (charNum.GreaterEqual(v.Cursor.CurSelection[0]) && charNum.LessThan(v.Cursor.CurSelection[1]) ||
849 charNum.LessThan(v.Cursor.CurSelection[0]) && charNum.GreaterEqual(v.Cursor.CurSelection[1])) {
850 // The current character is selected
851 lineStyle = defStyle.Reverse(true)
853 if style, ok := colorscheme["selection"]; ok {
857 lineStyle = highlightStyle
860 // We need to display the background of the linestyle with the correct color if cursorline is enabled
861 // and this is the current view and there is no selection on this line and the cursor is on this line
862 if v.Buf.Settings["cursorline"].(bool) && tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == curLineN {
863 if style, ok := colorscheme["cursor-line"]; ok {
864 fg, _, _ := style.Decompose()
865 lineStyle = lineStyle.Background(fg)
870 // If the character we are displaying is a tab, we need to do a bunch of special things
872 // First the user may have configured an `indent-char` to be displayed to show that this
873 // is a tab character
874 lineIndentStyle := defStyle
875 if style, ok := colorscheme["indent-char"]; ok && v.Buf.Settings["indentchar"].(string) != " " {
876 lineIndentStyle = style
878 if v.Cursor.HasSelection() &&
879 (charNum.GreaterEqual(v.Cursor.CurSelection[0]) && charNum.LessThan(v.Cursor.CurSelection[1]) ||
880 charNum.LessThan(v.Cursor.CurSelection[0]) && charNum.GreaterEqual(v.Cursor.CurSelection[1])) {
882 lineIndentStyle = defStyle.Reverse(true)
884 if style, ok := colorscheme["selection"]; ok {
885 lineIndentStyle = style
888 if v.Buf.Settings["cursorline"].(bool) && tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == curLineN {
889 if style, ok := colorscheme["cursor-line"]; ok {
890 fg, _, _ := style.Decompose()
891 lineIndentStyle = lineIndentStyle.Background(fg)
894 // Here we get the indent char
895 indentChar := []rune(v.Buf.Settings["indentchar"].(string))
896 if screenX-v.x-v.leftCol >= v.lineNumOffset {
897 v.drawCell(screenX-v.leftCol, screenY, indentChar[0], nil, lineIndentStyle)
899 // Now the tab has to be displayed as a bunch of spaces
901 remainder := tabSize - (visLoc % tabSize)
902 for i := 0; i < remainder-1; i++ {
904 if screenX-v.x-v.leftCol >= v.lineNumOffset {
905 v.drawCell(screenX-v.leftCol, screenY, ' ', nil, lineStyle)
908 strWidth += remainder
909 } else if runewidth.RuneWidth(ch) > 1 {
910 if screenX-v.x-v.leftCol >= v.lineNumOffset {
911 v.drawCell(screenX, screenY, ch, nil, lineStyle)
913 for i := 0; i < runewidth.RuneWidth(ch)-1; i++ {
915 if screenX-v.x-v.leftCol >= v.lineNumOffset {
916 v.drawCell(screenX-v.leftCol, screenY, '<', nil, lineStyle)
919 strWidth += StringWidth(string(ch), tabSize)
921 if screenX-v.x-v.leftCol >= v.lineNumOffset {
922 v.drawCell(screenX-v.leftCol, screenY, ch, nil, lineStyle)
924 strWidth += StringWidth(string(ch), tabSize)
926 charNum = charNum.Move(1, v.Buf)
930 // Here we are at a newline
932 if tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == curLineN && colN == v.Cursor.X {
933 v.DisplayCursor(screenX-v.leftCol, screenY)
936 // The newline may be selected, in which case we should draw the selection style
937 // with a space to represent it
938 if v.Cursor.HasSelection() &&
939 (charNum.GreaterEqual(v.Cursor.CurSelection[0]) && charNum.LessThan(v.Cursor.CurSelection[1]) ||
940 charNum.LessThan(v.Cursor.CurSelection[0]) && charNum.GreaterEqual(v.Cursor.CurSelection[1])) {
942 selectStyle := defStyle.Reverse(true)
944 if style, ok := colorscheme["selection"]; ok {
947 v.drawCell(screenX, screenY, ' ', nil, selectStyle)
951 charNum = charNum.Move(1, v.Buf)
953 for i := 0; i < v.Width; i++ {
954 lineStyle := defStyle
955 if v.Buf.Settings["cursorline"].(bool) && tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == curLineN {
956 if style, ok := colorscheme["cursor-line"]; ok {
957 fg, _, _ := style.Decompose()
958 lineStyle = lineStyle.Background(fg)
961 if screenX-v.x-v.leftCol+i >= v.lineNumOffset {
962 colorcolumn := int(v.Buf.Settings["colorcolumn"].(float64))
963 if colorcolumn != 0 && screenX-v.lineNumOffset+i == colorcolumn-1 {
964 if style, ok := colorscheme["color-column"]; ok {
965 fg, _, _ := style.Decompose()
966 lineStyle = lineStyle.Background(fg)
969 v.drawCell(screenX-v.leftCol+i, screenY, ' ', nil, lineStyle)
975 // DisplayCursor draws the current buffer's cursor to the screen
976 func (v *View) DisplayCursor(x, y int) {
977 // screen.ShowCursor(v.x+v.Cursor.GetVisualX()+v.lineNumOffset-v.leftCol, y)
978 screen.ShowCursor(x, y)
981 // Display renders the view, the cursor, and statusline
982 func (v *View) Display() {
984 // Don't draw the cursor if it is out of the viewport or if it has a selection
985 if (v.Cursor.Y-v.Topline < 0 || v.Cursor.Y-v.Topline > v.Height-1) || v.Cursor.HasSelection() {
988 _, screenH := screen.Size()
989 if v.Buf.Settings["statusline"].(bool) {
991 } else if (v.y + v.Height) != screenH-1 {
992 for x := 0; x < v.Width; x++ {
993 screen.SetContent(v.x+x, v.y+v.Height, '-', nil, defStyle.Reverse(true))