configurable filetree split col (addresses #69)

This commit is contained in:
Alex Goodman 2018-11-24 20:20:06 -05:00
parent 30f3feda9d
commit 49baf8425a
No known key found for this signature in database
GPG Key ID: 743640FAA11698A1
2 changed files with 10 additions and 1 deletions

View File

@ -97,8 +97,11 @@ func initConfig() {
viper.SetDefault("keybinding.page-down", "pgdn")
viper.SetDefault("diff.hide", "")
viper.SetDefault("layer.show-aggregated-changes", false)
viper.SetDefault("filetree.collapse-dir", false)
viper.SetDefault("filetree.pane-width", 0.5)
viper.AutomaticEnv() // read in environment variables that match

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/fatih/color"
"github.com/jroimartin/gocui"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/wagoodman/dive/filetree"
"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
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
if debug {
debugWidth = maxX / 4