gim: draw the text of the edge

This commit is contained in:
Brian Picciano 2018-06-02 04:35:12 +00:00
parent 65933a004d
commit 1dc53518af
3 changed files with 17 additions and 0 deletions

View File

@ -42,6 +42,7 @@ var arrows = map[geo.XY]string{
type line struct {
from, to *box
fromI, toI int
body string
}
// given the "primary" direction the line should be headed, picks a possible
@ -68,6 +69,7 @@ func (l line) draw(term *terminal.Terminal, flowDir, secFlowDir geo.XY) {
return xy[1]
}
// collect the points along the line into an array
var pts []geo.XY
midPrim := along(mid, flowDir)
endSec := along(end, dirSec)
@ -82,6 +84,7 @@ func (l line) draw(term *terminal.Terminal, flowDir, secFlowDir geo.XY) {
curr = curr.Add(flowDir)
}
// draw each point
for i, pt := range pts {
var str string
switch {
@ -100,4 +103,11 @@ func (l line) draw(term *terminal.Terminal, flowDir, secFlowDir geo.XY) {
term.MoveCursorTo(pt)
term.Printf(str)
}
// draw the body
if l.body != "" {
bodyPos := mid.Add(geo.Left.Scale(len(l.body) / 2))
term.MoveCursorTo(bodyPos)
term.Printf(l.body)
}
}

View File

@ -63,6 +63,12 @@ func mkGraph() (*gg.Graph, gg.Value) {
gg.ValueOut(b3, empty),
}, gg.NewValue("jE"))
g = g.AddValueIn(jE, c)
// TODO this really fucks it up
//d := gg.NewValue("d")
//deE := gg.ValueOut(d, gg.NewValue("deE"))
//g = g.AddValueIn(deE, gg.NewValue("e"))
return g, c
}

View File

@ -181,6 +181,7 @@ func (view *view) draw(term *terminal.Terminal) {
fromI: fromI,
to: b,
toI: i,
body: e.Value.V.(string),
})
}
}