(nx, ny int, f EqualFunc, p1, p2 *EditScript)
| 70 | } |
| 71 | |
| 72 | func (dbg *debugger) Begin(nx, ny int, f EqualFunc, p1, p2 *EditScript) EqualFunc { |
| 73 | dbg.Lock() |
| 74 | dbg.fwdPath, dbg.revPath = p1, p2 |
| 75 | top := "┌─" + strings.Repeat("──", nx) + "┐\n" |
| 76 | row := "│ " + strings.Repeat("· ", nx) + "│\n" |
| 77 | btm := "└─" + strings.Repeat("──", nx) + "┘\n" |
| 78 | dbg.grid = []byte(top + strings.Repeat(row, ny) + btm) |
| 79 | dbg.lines = strings.Count(dbg.String(), "\n") |
| 80 | fmt.Print(dbg) |
| 81 | |
| 82 | // Wrap the EqualFunc so that we can intercept each result. |
| 83 | return func(ix, iy int) (r Result) { |
| 84 | cell := dbg.grid[len(top)+iy*len(row):][len("│ ")+len("· ")*ix:][:len("·")] |
| 85 | for i := range cell { |
| 86 | cell[i] = 0 // Zero out the multiple bytes of UTF-8 middle-dot |
| 87 | } |
| 88 | switch r = f(ix, iy); { |
| 89 | case r.Equal(): |
| 90 | cell[0] = '\\' |
| 91 | case r.Similar(): |
| 92 | cell[0] = 'X' |
| 93 | default: |
| 94 | cell[0] = '#' |
| 95 | } |
| 96 | return |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | func (dbg *debugger) Update() { |
| 101 | dbg.print(updateDelay) |
no test coverage detected