(pos0 int, line0, line1 int)
| 298 | var vbar = []byte{'|'} |
| 299 | |
| 300 | func (b *Writer) writeLines(pos0 int, line0, line1 int) (pos int) { |
| 301 | pos = pos0 |
| 302 | for i := line0; i < line1; i++ { |
| 303 | line := b.lines[i] |
| 304 | |
| 305 | // if TabIndent is set, use tabs to pad leading empty cells |
| 306 | useTabs := b.flags&TabIndent != 0 |
| 307 | |
| 308 | for j, c := range line { |
| 309 | if j > 0 && b.flags&Debug != 0 { |
| 310 | // indicate column break |
| 311 | b.write0(vbar) |
| 312 | } |
| 313 | |
| 314 | if c.size == 0 { |
| 315 | // empty cell |
| 316 | if j < len(b.widths) { |
| 317 | b.writePadding(c.width, b.widths[j], useTabs) |
| 318 | } |
| 319 | } else { |
| 320 | // non-empty cell |
| 321 | useTabs = false |
| 322 | if b.flags&AlignRight == 0 { // align left |
| 323 | b.write0(b.buf[pos : pos+c.size]) |
| 324 | pos += c.size |
| 325 | if j < len(b.widths) { |
| 326 | b.writePadding(c.width, b.widths[j], false) |
| 327 | } |
| 328 | } else { // align right |
| 329 | if j < len(b.widths) { |
| 330 | b.writePadding(c.width, b.widths[j], false) |
| 331 | } |
| 332 | b.write0(b.buf[pos : pos+c.size]) |
| 333 | pos += c.size |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | if i+1 == len(b.lines) { |
| 339 | // last buffered line - we don't have a newline, so just write |
| 340 | // any outstanding buffered data |
| 341 | b.write0(b.buf[pos : pos+b.cell.size]) |
| 342 | pos += b.cell.size |
| 343 | } else { |
| 344 | // not the last line - write newline |
| 345 | b.write0(newline) |
| 346 | } |
| 347 | } |
| 348 | return |
| 349 | } |
| 350 | |
| 351 | // Format the text between line0 and line1 (excluding line1); pos |
| 352 | // is the buffer position corresponding to the beginning of line0. |
no test coverage detected