Add colorcolumn option

Fixes #333

For example: `> set colorcolumn 80`.
This commit is contained in:
Zachary Yedidia
2016-09-07 17:17:51 -04:00
parent dc8207149b
commit 8f06e51170
13 changed files with 37 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@@ -165,6 +165,7 @@ func GetOption(name string) interface{} {
func DefaultGlobalSettings() map[string]interface{} {
return map[string]interface{}{
"autoindent": true,
"colorcolumn": float64(0),
"colorscheme": "zenburn",
"cursorline": true,
"ignorecase": false,
@@ -187,6 +188,7 @@ func DefaultGlobalSettings() map[string]interface{} {
func DefaultLocalSettings() map[string]interface{} {
return map[string]interface{}{
"autoindent": true,
"colorcolumn": float64(0),
"cursorline": true,
"filetype": "Unknown",
"ignorecase": false,

View File

@@ -806,7 +806,16 @@ func (v *View) DisplayView() {
}
}
if screenX-v.x-v.leftCol+i >= v.lineNumOffset {
v.drawCell(screenX-v.leftCol+i, screenY, ' ', nil, lineStyle)
colorcolumn := int(v.Buf.Settings["colorcolumn"].(float64))
if colorcolumn != 0 && screenX-v.leftCol+i == colorcolumn-1 {
if style, ok := colorscheme["color-column"]; ok {
fg, _, _ := style.Decompose()
lineStyle = lineStyle.Background(fg)
}
v.drawCell(screenX-v.leftCol+i, screenY, ' ', nil, lineStyle)
} else {
v.drawCell(screenX-v.leftCol+i, screenY, ' ', nil, lineStyle)
}
}
}
}