github.com/jmigpin/editor@v1.6.0/util/drawutil/drawer4/line.go (about) 1 package drawer4 2 3 type Line struct { 4 d *Drawer 5 } 6 7 func (l *Line) Init() {} 8 9 func (l *Line) Iter() { 10 l.d.st.line.lineStart = false 11 if l.d.st.runeR.prevRu == '\n' || l.d.st.runeR.ri == l.d.st.runeR.startRi { 12 l.d.st.line.lineStart = true 13 } 14 15 if !l.d.iterNext() { 16 return 17 } 18 if l.d.st.runeR.ru == '\n' { 19 l.newLine() 20 } 21 } 22 23 func (l *Line) End() {} 24 25 //---------- 26 27 func (l *Line) newLine() { 28 l.newLineKeepAdv() 29 l.d.st.runeR.advance = 0 30 } 31 32 func (l *Line) newLineKeepAdv() { 33 st := &l.d.st.runeR 34 st.pen.X = l.d.iters.runeR.startingPen().X 35 st.pen.Y += l.d.lineHeight 36 st.prevRu = 0 37 st.kern = 0 38 // don't reset advance (keeps rune adv calc needed by linewrap) 39 }