Skip to content

Commit 89e330b

Browse files
committed
drawing stuff
1 parent 4e703d2 commit 89e330b

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

pkg/cmd/project/project.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ func projectRun(opts *ProjectOptions) error {
123123
}
124124
}()
125125

126+
colWidth := 30
127+
colHeight := 40
128+
colsToShow := 7
129+
130+
cardWidth := colWidth - 2
131+
cardHeight := 5
132+
cardsToShow := 7
133+
126134
loop:
127135
for {
128136
select {
@@ -132,6 +140,28 @@ loop:
132140
}
133141
s.Clear()
134142
drawStr(s, 0, 0, style, project.Name)
143+
for ix, col := range project.Columns {
144+
if ix == colsToShow {
145+
break
146+
}
147+
colX := colWidth * ix
148+
colY := 1
149+
drawRect(s, style, colX, colY, colWidth, colHeight)
150+
drawStr(s, colX+1, colY+1, style, col.Name)
151+
for ic, card := range col.Cards {
152+
if ic == cardsToShow {
153+
break
154+
}
155+
drawRect(s, style, colX+1, (ic*cardHeight)+colY+2, cardWidth, cardHeight)
156+
cardNote := card.Note
157+
if len(card.Note) > cardWidth-2 {
158+
cardNote = cardNote[0 : cardWidth-2]
159+
} else if cardNote == "" {
160+
cardNote = "TODO ISSUE"
161+
}
162+
drawStr(s, colX+2, (ic*cardHeight)+colY+3, style, cardNote)
163+
}
164+
}
135165
s.Show()
136166
}
137167

@@ -153,3 +183,43 @@ func drawStr(s tcell.Screen, x, y int, style tcell.Style, str string) {
153183
x += w
154184
}
155185
}
186+
187+
func drawRect(s tcell.Screen, style tcell.Style, x, y, w, h int) {
188+
// TODO could consolidate these now that I have the correct unicode characters
189+
topLeftCorner := '┌'
190+
botLeftCorner := '└'
191+
topRightCorner := '┐'
192+
botRightCorner := '┘'
193+
leftLine := '│'
194+
rightLine := '│'
195+
topLine := '─'
196+
botLine := '─'
197+
198+
for ix := x; ix < x+w; ix++ {
199+
for iy := y; iy < y+h; iy++ {
200+
var c rune
201+
if ix == x && iy == y {
202+
c = topLeftCorner
203+
} else if ix == x && iy == y+h-1 {
204+
c = botLeftCorner
205+
} else if ix == x {
206+
c = leftLine
207+
} else if ix == x+w-1 && iy == y {
208+
c = topRightCorner
209+
} else if ix == x+w-1 && iy == y+h-1 {
210+
c = botRightCorner
211+
} else if ix == x+w-1 {
212+
c = rightLine
213+
} else if iy == y {
214+
c = topLine
215+
} else if iy == y+h-1 {
216+
c = botLine
217+
} else {
218+
continue
219+
}
220+
221+
s.SetContent(ix, iy, c, nil, style)
222+
}
223+
}
224+
225+
}

0 commit comments

Comments
 (0)