From 49baf8425a286cd58d1e6563b855a230399dcc25 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Sat, 24 Nov 2018 20:20:06 -0500 Subject: [PATCH] configurable filetree split col (addresses #69) --- cmd/root.go | 3 +++ ui/ui.go | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 23d1537..3cf10bb 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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 diff --git a/ui/ui.go b/ui/ui.go index 13fb299..8948516 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -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