mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
Allow divider customization with divchars option
Adds the `divchars` and `divreverse` options to customize divider styles.
This commit is contained in:
@@ -248,6 +248,8 @@ func DefaultCommonSettings() map[string]interface{} {
|
|||||||
var DefaultGlobalOnlySettings = map[string]interface{}{
|
var DefaultGlobalOnlySettings = map[string]interface{}{
|
||||||
"autosave": float64(0),
|
"autosave": float64(0),
|
||||||
"colorscheme": "default",
|
"colorscheme": "default",
|
||||||
|
"divchars": "|-",
|
||||||
|
"divreverse": true,
|
||||||
"infobar": true,
|
"infobar": true,
|
||||||
"keymenu": false,
|
"keymenu": false,
|
||||||
"mouse": true,
|
"mouse": true,
|
||||||
|
|||||||
@@ -682,8 +682,27 @@ func (w *BufWindow) displayStatusLine() {
|
|||||||
w.sline.Display()
|
w.sline.Display()
|
||||||
} else if w.Y+w.Height != infoY {
|
} else if w.Y+w.Height != infoY {
|
||||||
w.drawStatus = true
|
w.drawStatus = true
|
||||||
|
|
||||||
|
divchars := config.GetGlobalOption("divchars").(string)
|
||||||
|
if util.CharacterCountInString(divchars) != 2 {
|
||||||
|
divchars = "|-"
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, size := util.DecodeCharacterInString(divchars)
|
||||||
|
divchar, combc, _ := util.DecodeCharacterInString(divchars[size:])
|
||||||
|
|
||||||
|
dividerStyle := config.DefStyle
|
||||||
|
if style, ok := config.Colorscheme["divider"]; ok {
|
||||||
|
dividerStyle = style
|
||||||
|
}
|
||||||
|
|
||||||
|
divreverse := config.GetGlobalOption("divreverse").(bool)
|
||||||
|
if divreverse {
|
||||||
|
dividerStyle = dividerStyle.Reverse(true)
|
||||||
|
}
|
||||||
|
|
||||||
for x := w.X; x < w.X+w.Width; x++ {
|
for x := w.X; x < w.X+w.Width; x++ {
|
||||||
screen.SetContent(x, w.Y+w.Height-1, '-', nil, config.DefStyle.Reverse(true))
|
screen.SetContent(x, w.Y+w.Height-1, divchar, combc, dividerStyle)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
w.drawStatus = false
|
w.drawStatus = false
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/zyedidia/micro/v2/internal/buffer"
|
"github.com/zyedidia/micro/v2/internal/buffer"
|
||||||
"github.com/zyedidia/micro/v2/internal/config"
|
"github.com/zyedidia/micro/v2/internal/config"
|
||||||
"github.com/zyedidia/micro/v2/internal/screen"
|
"github.com/zyedidia/micro/v2/internal/screen"
|
||||||
|
"github.com/zyedidia/micro/v2/internal/util"
|
||||||
"github.com/zyedidia/micro/v2/internal/views"
|
"github.com/zyedidia/micro/v2/internal/views"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,11 +25,23 @@ func (w *UIWindow) drawNode(n *views.Node) {
|
|||||||
dividerStyle = style
|
dividerStyle = style
|
||||||
}
|
}
|
||||||
|
|
||||||
|
divchars := config.GetGlobalOption("divchars").(string)
|
||||||
|
if util.CharacterCountInString(divchars) != 2 {
|
||||||
|
divchars = "|-"
|
||||||
|
}
|
||||||
|
|
||||||
|
divchar, combc, _ := util.DecodeCharacterInString(divchars)
|
||||||
|
|
||||||
|
divreverse := config.GetGlobalOption("divreverse").(bool)
|
||||||
|
if divreverse {
|
||||||
|
dividerStyle = dividerStyle.Reverse(true)
|
||||||
|
}
|
||||||
|
|
||||||
for i, c := range cs {
|
for i, c := range cs {
|
||||||
if c.IsLeaf() && c.Kind == views.STVert {
|
if c.IsLeaf() && c.Kind == views.STVert {
|
||||||
if i != len(cs)-1 {
|
if i != len(cs)-1 {
|
||||||
for h := 0; h < c.H; h++ {
|
for h := 0; h < c.H; h++ {
|
||||||
screen.SetContent(c.X+c.W, c.Y+h, '|', nil, dividerStyle.Reverse(true))
|
screen.SetContent(c.X+c.W, c.Y+h, divchar, combc, dividerStyle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -80,6 +80,21 @@ Here are the available options:
|
|||||||
|
|
||||||
default value: `false`
|
default value: `false`
|
||||||
|
|
||||||
|
* `divchars`: specifies the "divider" characters used for the dividing line
|
||||||
|
between vertical/horizontal splits. The first character is for vertical
|
||||||
|
dividers, and the second is for horizontal dividers. By default, for
|
||||||
|
horizontal splits the statusline serves as a divider, but if the statusline
|
||||||
|
is disabled the horizontal divider character will be used.
|
||||||
|
|
||||||
|
default value: `|-`
|
||||||
|
|
||||||
|
* `divreverse`: colorschemes provide the color (foreground and background) for
|
||||||
|
the characters displayed in split dividers. With this option enabled, the
|
||||||
|
colors specified by the colorscheme will be reversed (foreground and
|
||||||
|
background colors swapped).
|
||||||
|
|
||||||
|
default value: `true`
|
||||||
|
|
||||||
* `encoding`: the encoding to open and save files with. Supported encodings
|
* `encoding`: the encoding to open and save files with. Supported encodings
|
||||||
are listed at https://www.w3.org/TR/encoding/.
|
are listed at https://www.w3.org/TR/encoding/.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user