configurable filetree split col (addresses #69)
This commit is contained in:
parent
30f3feda9d
commit
49baf8425a
@ -97,8 +97,11 @@ func initConfig() {
|
|||||||
viper.SetDefault("keybinding.page-down", "pgdn")
|
viper.SetDefault("keybinding.page-down", "pgdn")
|
||||||
|
|
||||||
viper.SetDefault("diff.hide", "")
|
viper.SetDefault("diff.hide", "")
|
||||||
|
|
||||||
viper.SetDefault("layer.show-aggregated-changes", false)
|
viper.SetDefault("layer.show-aggregated-changes", false)
|
||||||
|
|
||||||
viper.SetDefault("filetree.collapse-dir", false)
|
viper.SetDefault("filetree.collapse-dir", false)
|
||||||
|
viper.SetDefault("filetree.pane-width", 0.5)
|
||||||
|
|
||||||
viper.AutomaticEnv() // read in environment variables that match
|
viper.AutomaticEnv() // read in environment variables that match
|
||||||
|
|
||||||
|
8
ui/ui.go
8
ui/ui.go
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/jroimartin/gocui"
|
"github.com/jroimartin/gocui"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/wagoodman/dive/filetree"
|
"github.com/wagoodman/dive/filetree"
|
||||||
"github.com/wagoodman/dive/image"
|
"github.com/wagoodman/dive/image"
|
||||||
@ -188,7 +189,12 @@ func layout(g *gocui.Gui) error {
|
|||||||
// TODO: this logic should be refactored into an abstraction that takes care of the math for us
|
// TODO: this logic should be refactored into an abstraction that takes care of the math for us
|
||||||
|
|
||||||
maxX, maxY := g.Size()
|
maxX, maxY := g.Size()
|
||||||
splitCols := maxX / 2
|
fileTreeSplitRatio := viper.GetFloat64("filetree.pane-width")
|
||||||
|
if fileTreeSplitRatio >= 1 || fileTreeSplitRatio <= 0 {
|
||||||
|
logrus.Errorf("invalid config value: 'filetree.pane-width' should be 0 < value < 1, given '%v'", fileTreeSplitRatio)
|
||||||
|
fileTreeSplitRatio = 0.5
|
||||||
|
}
|
||||||
|
splitCols := int(float64(maxX) * (1.0-fileTreeSplitRatio))
|
||||||
debugWidth := 0
|
debugWidth := 0
|
||||||
if debug {
|
if debug {
|
||||||
debugWidth = maxX / 4
|
debugWidth = maxX / 4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user