2
1
Fork 0
swim/lane.go

40 lines
946 B
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) StringSlice(width int) []string {
out := make([]string, 0, len(l.Stories) * 3 + 1)
for _, story := range l.Stories {
out = append(out, fmt.Sprintf("%s%*.*s%s", style.Lane, width, width, " ", styleOff))
out = append(out, fmt.Sprintf("%s %s%-*.*s%s %s", style.Lane, style.Input, width-2, width-2, 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}
}