From 957330c3873c9ee88d44725c59a7fc51081a4025 Mon Sep 17 00:00:00 2001 From: nijynot Date: Sat, 11 May 2019 15:25:48 +0200 Subject: [PATCH] Tweak comments and use Default const in validation --- container/container.go | 2 +- container/options.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/container/container.go b/container/container.go index 89f0d16..b978d00 100644 --- a/container/container.go +++ b/container/container.go @@ -171,7 +171,7 @@ func (c *Container) split() (image.Rectangle, image.Rectangle, error) { if err != nil { return image.ZR, image.ZR, err } - if c.opts.splitFixed > -1 { + if c.opts.splitFixed > DefaultSplitFixed { if c.opts.split == splitTypeVertical { return area.VSplitCells(ar, c.opts.splitFixed) } diff --git a/container/options.go b/container/options.go index 497a6d8..ba89364 100644 --- a/container/options.go +++ b/container/options.go @@ -52,7 +52,7 @@ func validateIds(c *Container, seen map[string]bool) error { // ensure all the container only have one split modifier. func validateSplits(c *Container) error { - if c.opts.splitFixed > -1 && c.opts.splitPercent != 50 { + if c.opts.splitFixed > DefaultSplitFixed && c.opts.splitPercent != DefaultSplitPercent { return fmt.Errorf( "only one of splitFixed `%v` and splitPercent `%v` is allowed to be set per container", c.opts.splitFixed, @@ -245,13 +245,15 @@ func SplitPercent(p int) SplitOption { }) } -// SplitFixed sets the size as a fixed value of the available space. +// SplitFixed sets the size of the first container to be a fixed value +// and makes the second container take up the remaining space. // When using SplitVertical, the provided size is applied to the new left // container, the new right container gets the reminder of the size. // When using SplitHorizontal, the provided size is applied to the new top // container, the new bottom container gets the reminder of the size. // The provided value must be a positive number in the range 0 <= cells. -// If not provided, defaults to DefaultSplitFixed. +// If SplitFixed() is not specified, it defaults to SplitPercent() and its given value. +// Only one of SplitFixed() and SplitPercent() can be specified per container. func SplitFixed(cells int) SplitOption { return splitOption(func(opts *options) error { if cells < 0 {