From 6f9eca99e7114aef26f37fadd9a97b231aec4b92 Mon Sep 17 00:00:00 2001 From: "sashakoshka@tebibyte.media" Date: Thu, 5 Sep 2024 16:46:49 -0400 Subject: [PATCH] Text cursor is now an I beam --- internal/system/textbox.go | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/internal/system/textbox.go b/internal/system/textbox.go index 8c36089..ca5a10d 100644 --- a/internal/system/textbox.go +++ b/internal/system/textbox.go @@ -253,20 +253,19 @@ func (this *textBox) drawDot (can canvas.Canvas) { pen := can.Pen() - bounds := this.InnerBounds() - metrics := face.Metrics() - dot := this.dot.Canon() - start := this.drawer.PositionAt(dot.Start).Add(fixPt(this.textOffset())) - end := this.drawer.PositionAt(dot.End ).Add(fixPt(this.textOffset())) - height := this.drawer.LineHeight().Round() - ascent := fixed.Point26_6 { Y: metrics.Descent } - descent := fixed.Point26_6 { Y: metrics.Ascent } + bounds := this.InnerBounds() + metrics := face.Metrics() + dot := this.dot + canonDot := dot.Canon() + start := this.drawer.PositionAt(canonDot.Start).Add(fixPt(this.textOffset())) + end := this.drawer.PositionAt(canonDot.End ).Add(fixPt(this.textOffset())) + canonEnd := this.drawer.PositionAt(dot.End ).Add(fixPt(this.textOffset())) + height := this.drawer.LineHeight().Round() + ascent := fixed.Point26_6 { Y: metrics.Descent } + descent := fixed.Point26_6 { Y: metrics.Ascent } switch { - case dot.Empty(): - pen.Stroke(textColor) - pen.StrokeWeight(1) - pen.Path(roundPt(start.Add(ascent)), roundPt(start.Sub(descent))) + case canonDot.Empty(): case start.Y == end.Y: pen.Fill(dotColor) @@ -300,6 +299,19 @@ func (this *textBox) drawDot (can canvas.Canvas) { rect.Min.X = bounds.Min.X pen.Rectangle(rect) } + + pen.Stroke(textColor) + pen.StrokeWeight(1) + beamTop := roundPt(canonEnd.Add(ascent)).Sub(image.Pt(0, 1)) + beamBottom := roundPt(canonEnd.Sub(descent)) + beamSerif := 3 + pen.Path(beamTop, beamBottom) + pen.Path ( + beamTop.Sub(image.Pt(beamSerif - 1, 0)), + beamTop.Add(image.Pt(beamSerif, 0))) + pen.Path ( + beamBottom.Sub(image.Pt(beamSerif - 1, 0)), + beamBottom.Add(image.Pt(beamSerif, 0))) } func (this *textBox) textOffset () image.Point {