Make sure splits can't draw in other splits

This commit is contained in:
Zachary Yedidia
2016-06-27 18:41:04 -04:00
parent bcbef1c633
commit d419e65a03
2 changed files with 27 additions and 16 deletions

View File

@@ -49,6 +49,10 @@ func (sline *Statusline) Display() {
// Maybe there is a unicode filename? // Maybe there is a unicode filename?
fileRunes := []rune(file) fileRunes := []rune(file)
viewX := sline.view.x viewX := sline.view.x
if viewX != 0 {
screen.SetContent(viewX, y, ' ', nil, statusLineStyle)
viewX++
}
for x := 0; x < sline.view.width; x++ { for x := 0; x < sline.view.width; x++ {
if x < len(fileRunes) { if x < len(fileRunes) {
screen.SetContent(viewX+x, y, fileRunes[x], nil, statusLineStyle) screen.SetContent(viewX+x, y, fileRunes[x], nil, statusLineStyle)

View File

@@ -487,8 +487,15 @@ func (v *View) ClearAllGutterMessages() {
} }
} }
func (v *View) drawCell(x, y int, ch rune, combc []rune, style tcell.Style) {
if x >= v.x && x < v.x+v.width && y >= v.y && y < v.y+v.height {
screen.SetContent(x, y, ch, combc, style)
}
}
// DisplayView renders the view to the screen // DisplayView renders the view to the screen
func (v *View) DisplayView() { func (v *View) DisplayView() {
// The character number of the character in the top left of the screen // The character number of the character in the top left of the screen
charNum := Loc{0, v.Topline} charNum := Loc{0, v.Topline}
@@ -522,14 +529,14 @@ func (v *View) DisplayView() {
x := v.x x := v.x
if v.x != 0 { if v.x != 0 {
// Draw the split divider // Draw the split divider
screen.SetContent(x, lineN+v.y, ' ', nil, defStyle.Reverse(true)) v.drawCell(x, lineN+v.y, ' ', nil, defStyle.Reverse(true))
x++ x++
} }
// If the buffer is smaller than the view height // If the buffer is smaller than the view height
if lineN+v.Topline >= v.Buf.NumLines { if lineN+v.Topline >= v.Buf.NumLines {
// We have to clear all this space // We have to clear all this space
for i := x; i < v.x+v.width; i++ { for i := x; i < v.x+v.width; i++ {
screen.SetContent(i, lineN+v.y, ' ', nil, defStyle) v.drawCell(i, lineN+v.y, ' ', nil, defStyle)
} }
continue continue
@@ -557,9 +564,9 @@ func (v *View) DisplayView() {
gutterStyle = style gutterStyle = style
} }
} }
screen.SetContent(x, lineN+v.y, '>', nil, gutterStyle) v.drawCell(x, lineN+v.y, '>', nil, gutterStyle)
x++ x++
screen.SetContent(x, lineN+v.y, '>', nil, gutterStyle) v.drawCell(x, lineN+v.y, '>', nil, gutterStyle)
x++ x++
if v.Cursor.Y == lineN+v.Topline { if v.Cursor.Y == lineN+v.Topline {
messenger.Message(msg.msg) messenger.Message(msg.msg)
@@ -569,9 +576,9 @@ func (v *View) DisplayView() {
} }
} }
if !msgOnLine { if !msgOnLine {
screen.SetContent(x, lineN+v.y, ' ', nil, defStyle) v.drawCell(x, lineN+v.y, ' ', nil, defStyle)
x++ x++
screen.SetContent(x, lineN+v.y, ' ', nil, defStyle) v.drawCell(x, lineN+v.y, ' ', nil, defStyle)
x++ x++
if v.Cursor.Y == lineN+v.Topline && messenger.gutterMessage { if v.Cursor.Y == lineN+v.Topline && messenger.gutterMessage {
messenger.Reset() messenger.Reset()
@@ -590,18 +597,18 @@ func (v *View) DisplayView() {
if settings["ruler"] == true { if settings["ruler"] == true {
lineNum = strconv.Itoa(lineN + v.Topline + 1) lineNum = strconv.Itoa(lineN + v.Topline + 1)
for i := 0; i < maxLineLength-len(lineNum); i++ { for i := 0; i < maxLineLength-len(lineNum); i++ {
screen.SetContent(x, lineN+v.y, ' ', nil, lineNumStyle) v.drawCell(x, lineN+v.y, ' ', nil, lineNumStyle)
x++ x++
} }
// Write the actual line number // Write the actual line number
for _, ch := range lineNum { for _, ch := range lineNum {
screen.SetContent(x, lineN+v.y, ch, nil, lineNumStyle) v.drawCell(x, lineN+v.y, ch, nil, lineNumStyle)
x++ x++
} }
if settings["ruler"] == true { if settings["ruler"] == true {
// Write the extra space // Write the extra space
screen.SetContent(x, lineN+v.y, ' ', nil, lineNumStyle) v.drawCell(x, lineN+v.y, ' ', nil, lineNumStyle)
x++ x++
} }
} }
@@ -657,28 +664,28 @@ func (v *View) DisplayView() {
} }
indentChar := []rune(settings["indentchar"].(string)) indentChar := []rune(settings["indentchar"].(string))
if x-v.leftCol >= v.lineNumOffset { if x-v.leftCol >= v.lineNumOffset {
screen.SetContent(x-v.leftCol, lineN+v.y, indentChar[0], nil, lineIndentStyle) v.drawCell(x-v.leftCol, lineN+v.y, indentChar[0], nil, lineIndentStyle)
} }
tabSize := int(settings["tabsize"].(float64)) tabSize := int(settings["tabsize"].(float64))
for i := 0; i < tabSize-1; i++ { for i := 0; i < tabSize-1; i++ {
x++ x++
if x-v.leftCol >= v.lineNumOffset { if x-v.leftCol >= v.lineNumOffset {
screen.SetContent(x-v.leftCol, lineN+v.y, ' ', nil, lineStyle) v.drawCell(x-v.leftCol, lineN+v.y, ' ', nil, lineStyle)
} }
} }
} else if runewidth.RuneWidth(ch) > 1 { } else if runewidth.RuneWidth(ch) > 1 {
if x-v.leftCol >= v.lineNumOffset { if x-v.leftCol >= v.lineNumOffset {
screen.SetContent(x-v.leftCol, lineN+v.y, ch, nil, lineStyle) v.drawCell(x-v.leftCol, lineN+v.y, ch, nil, lineStyle)
} }
for i := 0; i < runewidth.RuneWidth(ch)-1; i++ { for i := 0; i < runewidth.RuneWidth(ch)-1; i++ {
x++ x++
if x-v.leftCol >= v.lineNumOffset { if x-v.leftCol >= v.lineNumOffset {
screen.SetContent(x-v.leftCol, lineN+v.y, ' ', nil, lineStyle) v.drawCell(x-v.leftCol, lineN+v.y, ' ', nil, lineStyle)
} }
} }
} else { } else {
if x-v.leftCol >= v.lineNumOffset { if x-v.leftCol >= v.lineNumOffset {
screen.SetContent(x-v.leftCol, lineN+v.y, ch, nil, lineStyle) v.drawCell(x-v.leftCol, lineN+v.y, ch, nil, lineStyle)
} }
} }
charNum = charNum.Move(1, v.Buf) charNum = charNum.Move(1, v.Buf)
@@ -697,7 +704,7 @@ func (v *View) DisplayView() {
if style, ok := colorscheme["selection"]; ok { if style, ok := colorscheme["selection"]; ok {
selectStyle = style selectStyle = style
} }
screen.SetContent(x-v.leftCol, lineN+v.y, ' ', nil, selectStyle) v.drawCell(x-v.leftCol, lineN+v.y, ' ', nil, selectStyle)
x++ x++
} }
@@ -712,7 +719,7 @@ func (v *View) DisplayView() {
} }
} }
if !(x-v.leftCol < v.lineNumOffset) { if !(x-v.leftCol < v.lineNumOffset) {
screen.SetContent(x+i, lineN+v.y, ' ', nil, lineStyle) v.drawCell(x+i, lineN+v.y, ' ', nil, lineStyle)
} }
} }
} }