62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type Lane struct {
|
|
Title string
|
|
Stories []Story
|
|
Current int // Index of current story
|
|
}
|
|
|
|
func (l *Lane) CreateStory(b *Board) {
|
|
storyTitle, err := GetAndConfirmCommandLine("Story Title: ")
|
|
if err != nil {
|
|
b.SetMessage(err.Error(), true)
|
|
return
|
|
}
|
|
l.Stories = append(l.Stories, MakeStory(storyTitle))
|
|
if l.Current < 0 {
|
|
l.Current = 0
|
|
}
|
|
}
|
|
|
|
func (l Lane) Header(width int, selected bool) string {
|
|
marker := " "
|
|
color := style.Lane
|
|
if selected {
|
|
marker = "*"
|
|
color = style.LaneSelected
|
|
}
|
|
if len(l.Title) > width {
|
|
return fmt.Sprintf("%s\033[1;7m%*.*s%s%s", style.Lane, width, width, l.Title[:width-1], marker, styleOff)
|
|
} else {
|
|
width := width - 2
|
|
leftPad := (width - len(l.Title)) / 2
|
|
rightPad := width - len(l.Title) - leftPad
|
|
return fmt.Sprintf("%s %s\033[1;7m%*.*s%s%s%*.*s\033[27m%s %s", style.Lane, color, leftPad-1, leftPad-1, "", l.Title, marker, rightPad, rightPad, "", style.Lane, styleOff)
|
|
}
|
|
}
|
|
|
|
|
|
func (l Lane) StringSlice(width int, selected bool) []string {
|
|
out := make([]string, 0, len(l.Stories) * 3 + 1)
|
|
for i, story := range l.Stories {
|
|
leadIn := " "
|
|
if selected && l.Current == i {
|
|
leadIn = "\033[1m➜\033[21m "
|
|
}
|
|
out = append(out, fmt.Sprintf("%s%*.*s%s", style.Lane, width, width, " ", styleOff))
|
|
out = append(out, fmt.Sprintf("%s %s%s%-*.*s%s %s", style.Lane, style.Input, leadIn, width-4, width-4, story.Title, style.Lane, styleOff))
|
|
}
|
|
if len(out) > 0 {
|
|
out = append(out, fmt.Sprintf("%s%*.*s%s", style.Lane, width, width, " ", styleOff))
|
|
}
|
|
return out
|
|
}
|
|
|
|
func MakeLane(title string) Lane {
|
|
return Lane{title, make([]Story,0,5), -1}
|
|
}
|