Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/agenor/enums/curve-kind-en-auto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions src/agenor/enums/curve-kind-en.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package enums

import "fmt"

//go:generate stringer -type=CurveKind -linecomment -trimprefix=CurveKind -output curve-kind-en-auto.go

// CurveKind controls the shape of the interpolation path between the
// Hi and Lo gradient endpoints. The zero value is treated as CurveKindLinear.
type CurveKind uint

const (
// CurveKindLinear interpolates each channel at a constant rate.
// This is the default and matches pre-issue behaviour exactly.
CurveKindLinear CurveKind = iota // linear

// CurveKindSine applies a sine-wave shape to the interpolation.
CurveKindSine // sine

// CurveKindQuadraticIn accelerates toward the Lo endpoint.
CurveKindQuadraticIn // quadratic-in

// CurveKindQuadraticOut decelerates toward the Lo endpoint.
CurveKindQuadraticOut // quadratic-out

// CurveKindCubic applies a cubic (S-curve) shape.
CurveKindCubic // cubic
)

// UnmarshalText implements encoding.TextUnmarshaler so that CurveKind
// can be decoded from YAML/mapstructure string values.
func (k *CurveKind) UnmarshalText(data []byte) error {
switch string(data) {
case "linear":
*k = CurveKindLinear
case "sine":
*k = CurveKindSine
case "quadratic-in":
*k = CurveKindQuadraticIn
case "quadratic-out":
*k = CurveKindQuadraticOut
case "cubic":
*k = CurveKindCubic
default:
return fmt.Errorf("unknown curve kind %q: valid values are linear, sine, quadratic-in, quadratic-out, cubic", string(data))
}
return nil
}
27 changes: 27 additions & 0 deletions src/agenor/enums/easing-kind-en-auto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions src/agenor/enums/easing-kind-en.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package enums

import "fmt"

//go:generate stringer -type=EasingKind -linecomment -trimprefix=EasingKind -output easing-kind-en-auto.go

// EasingKind controls the distribution of steps along the curve.
// The zero value is treated as EasingKindUniform.
type EasingKind uint

const (
// EasingKindUniform distributes steps evenly. Default; matches
// pre-issue behaviour exactly.
EasingKindUniform EasingKind = iota // uniform

// EasingKindEaseIn clusters steps toward the start of the gradient.
EasingKindEaseIn // ease-in

// EasingKindEaseOut clusters steps toward the end of the gradient.
EasingKindEaseOut // ease-out

// EasingKindEaseInOut clusters steps toward both ends.
EasingKindEaseInOut // ease-in-out
)

// UnmarshalText implements encoding.TextUnmarshaler so that EasingKind
// can be decoded from YAML/mapstructure string values.
func (k *EasingKind) UnmarshalText(data []byte) error {
switch string(data) {
case "uniform":
*k = EasingKindUniform
case "ease-in":
*k = EasingKindEaseIn
case "ease-out":
*k = EasingKindEaseOut
case "ease-in-out":
*k = EasingKindEaseInOut
default:
return fmt.Errorf("unknown easing kind %q: valid values are uniform, ease-in, ease-out, ease-in-out", string(data))
}
return nil
}
25 changes: 25 additions & 0 deletions src/agenor/enums/navigation-kind-en-auto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/agenor/enums/navigation-kind-en.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package enums

import "fmt"

//go:generate stringer -type=NavigationKind -linecomment -trimprefix=NavigationKind -output navigation-kind-en-auto.go

// NavigationKind identifies whether a traversal is fresh or a
// continuation from a checkpoint.
type NavigationKind uint

const (
// NavigationKindPrime is a fresh traversal from the root.
NavigationKindPrime NavigationKind = iota // prime

// NavigationKindResume is a continuation from a saved checkpoint.
NavigationKindResume // resume
)

// UnmarshalText implements encoding.TextUnmarshaler so that NavigationKind
// can be decoded from string values.
func (k *NavigationKind) UnmarshalText(data []byte) error {
switch string(data) {
case "prime":
*k = NavigationKindPrime
case "resume":
*k = NavigationKindResume
default:
return fmt.Errorf("unknown navigation kind %q: valid values are prime, resume", string(data))
}
return nil
}
26 changes: 26 additions & 0 deletions src/agenor/enums/view-kind-en-auto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions src/agenor/enums/view-kind-en.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package enums

import "fmt"

//go:generate stringer -type=ViewKind -linecomment -trimprefix=ViewKind -output view-kind-en-auto.go

// ViewKind identifies the rendering view to use.
type ViewKind uint

const (
// ViewKindLinear is a linear scrolling output view rendered with lipgloss.
ViewKindLinear ViewKind = iota // linear

// ViewKindPorthole is a bubbletea view with a static header and footer
// and vertically scrolling content between them.
ViewKindPorthole // porthole

// ViewKindHighway is a bubbletea view showing parallel lanes of activity,
// suited to concurrent worker output.
ViewKindHighway // highway
)

// UnmarshalText implements encoding.TextUnmarshaler so that ViewKind
// can be decoded from string values.
func (k *ViewKind) UnmarshalText(data []byte) error {
switch string(data) {
case "linear":
*k = ViewKindLinear
case "porthole":
*k = ViewKindPorthole
case "highway":
*k = ViewKindHighway
default:
return fmt.Errorf("unknown view kind %q: valid values are linear, porthole, highway", string(data))
}
return nil
}
14 changes: 14 additions & 0 deletions src/app/bedrock/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package bedrock

import (
"time"

"github.com/snivilised/jaywalk/src/agenor/enums"
)

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -207,6 +209,18 @@ type BannerSubConfig struct {
// colour sweep on the banner only, without redefining the shared
// gradient. Zero or omitted means "use the gradient's own steps".
Steps int `mapstructure:"steps,omitempty" yaml:"steps,omitempty"`

// Curve overrides the gradient's interpolation shape for the banner
// widget only. Omit to inherit the bound gradient's curve.
Curve enums.CurveKind `mapstructure:"curve,omitempty" yaml:"curve,omitempty"`

// Easing overrides the gradient's step distribution for the banner
// widget only. Omit to inherit the bound gradient's easing.
Easing enums.EasingKind `mapstructure:"easing,omitempty" yaml:"easing,omitempty"`

// Animate overrides the gradient's animate flag for the banner
// widget only. Omit to inherit the bound gradient's animate value.
Animate *bool `mapstructure:"animate,omitempty" yaml:"animate,omitempty"`
}

// HighwayAnimationConfig holds animation data configuration for Highway view.
Expand Down
13 changes: 12 additions & 1 deletion src/app/ui/highway.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,18 @@ func (h *highwayPresenter) buildBannerInfo() banner.Info {
if h.cfg.Banner.StepsOverride > 0 {
steps = h.cfg.Banner.StepsOverride
}
grad = &contract.ResolvedGradient{Steps: steps, Hi: g.Hi, Lo: g.Lo}
curve := g.Curve
if h.cfg.Banner.CurveOverride != 0 {
curve = h.cfg.Banner.CurveOverride
}
easing := g.Easing
if h.cfg.Banner.EasingOverride != 0 {
easing = h.cfg.Banner.EasingOverride
}
grad = &contract.ResolvedGradient{
Steps: steps, Hi: g.Hi, Lo: g.Lo,
Curve: curve, Easing: easing,
}
}
info.Gradient = grad

Expand Down
19 changes: 15 additions & 4 deletions src/app/ui/linear.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
type linearPresenter struct {
mux sync.Mutex
renderer contract.Renderer
kind contract.NavigationKind // remembered from OnBegin for use in OnComplete
kind enums.NavigationKind // remembered from OnBegin for use in OnComplete
subscription enums.Subscription
lastParent string
peerInfo map[string]*core.PeerInfo
Expand All @@ -44,8 +44,8 @@ func (l *linearPresenter) OnBegin(e *report.BeginEvent) {
defer l.mux.Unlock()

kind := lo.Ternary(e.IsPrime,
contract.PrimeNavigation,
contract.ResumeNavigation,
enums.NavigationKindPrime,
enums.NavigationKindResume,
)

l.kind = kind
Expand Down Expand Up @@ -261,7 +261,18 @@ func (l *linearPresenter) buildBannerInfo() *contract.BannerInfo {
if l.cfg.Banner.StepsOverride > 0 {
steps = l.cfg.Banner.StepsOverride
}
grad = &contract.ResolvedGradient{Steps: steps, Hi: g.Hi, Lo: g.Lo}
curve := g.Curve
if l.cfg.Banner.CurveOverride != 0 {
curve = l.cfg.Banner.CurveOverride
}
easing := g.Easing
if l.cfg.Banner.EasingOverride != 0 {
easing = l.cfg.Banner.EasingOverride
}
grad = &contract.ResolvedGradient{
Steps: steps, Hi: g.Hi, Lo: g.Lo,
Curve: curve, Easing: easing,
}
}
info.Gradient = grad

Expand Down
8 changes: 4 additions & 4 deletions src/app/ui/linear_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var _ = Describe("linear", Ordered, func() {
Expect(spy.overture.Root).To(Equal("/home/user/docs"))
Expect(spy.overture.Caption).To(Equal("files and folders"))
Expect(spy.overture.StartedAt).To(Equal(now))
Expect(spy.overture.Kind).To(Equal(contract.PrimeNavigation))
Expect(spy.overture.Kind).To(Equal(enums.NavigationKindPrime))
Expect(spy.overture.ResumeFrom).To(BeEmpty())
})
})
Expand All @@ -131,7 +131,7 @@ var _ = Describe("linear", Ordered, func() {
DateFormat: "Mon, 02 Jan 2006 15:04:05 MST",
})

Expect(spy.overture.Kind).To(Equal(contract.ResumeNavigation))
Expect(spy.overture.Kind).To(Equal(enums.NavigationKindResume))
Expect(spy.overture.ResumeFrom).To(Equal("/home/user/docs/subdir"))
})
})
Expand Down Expand Up @@ -376,7 +376,7 @@ var _ = Describe("linear", Ordered, func() {
Expect(s.DirsVisited).To(Equal(core.MetricValue(7)))
Expect(s.Elapsed).To(Equal(3 * time.Second))
Expect(s.Errors).To(BeEmpty())
Expect(s.Kind).To(Equal(contract.PrimeNavigation))
Expect(s.Kind).To(Equal(enums.NavigationKindPrime))
})
})

Expand Down Expand Up @@ -411,7 +411,7 @@ var _ = Describe("linear", Ordered, func() {

presenter.OnComplete(&report.Traversal{})

Expect(spy.summary.Kind).To(Equal(contract.ResumeNavigation))
Expect(spy.summary.Kind).To(Equal(enums.NavigationKindResume))
})
})
})
Expand Down
Loading
Loading