mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
widget: use reliable text direction checks, not heuristics
This commit switches the way in which the editor and helper functions check for RTL text from a heuristic to using the actual text direction. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -794,9 +794,6 @@ func (e *Editor) PaintText(gtx layout.Context) {
|
|||||||
start, end := clipLine(e.lines, e.Alignment, e.viewSize.X, cl, pos)
|
start, end := clipLine(e.lines, e.Alignment, e.viewSize.X, cl, pos)
|
||||||
line := e.lines[start.lineCol.Y]
|
line := e.lines[start.lineCol.Y]
|
||||||
off := image.Point{X: start.x.Floor(), Y: start.y}.Sub(scroll)
|
off := image.Point{X: start.x.Floor(), Y: start.y}.Sub(scroll)
|
||||||
if start.lineCol.X > end.lineCol.X {
|
|
||||||
start, end = end, start
|
|
||||||
}
|
|
||||||
l := subLayout(line, start, end)
|
l := subLayout(line, start, end)
|
||||||
|
|
||||||
t := op.Offset(off).Push(gtx.Ops)
|
t := op.Offset(off).Push(gtx.Ops)
|
||||||
|
|||||||
+1
-5
@@ -68,13 +68,9 @@ func clipLine(lines []text.Line, alignment text.Alignment, width int, clip image
|
|||||||
}
|
}
|
||||||
|
|
||||||
func subLayout(line text.Line, start, end combinedPos) text.Layout {
|
func subLayout(line text.Line, start, end combinedPos) text.Layout {
|
||||||
if start.lineCol.X == line.Layout.Runes.Count {
|
|
||||||
return text.Layout{}
|
|
||||||
}
|
|
||||||
|
|
||||||
startCluster := clusterIndexFor(line, start.lineCol.X, start.clusterIndex)
|
startCluster := clusterIndexFor(line, start.lineCol.X, start.clusterIndex)
|
||||||
endCluster := clusterIndexFor(line, end.lineCol.X, end.clusterIndex)
|
endCluster := clusterIndexFor(line, end.lineCol.X, end.clusterIndex)
|
||||||
if startCluster > endCluster {
|
if line.Layout.Direction.Progression() == system.TowardOrigin {
|
||||||
startCluster, endCluster = endCluster, startCluster
|
startCluster, endCluster = endCluster, startCluster
|
||||||
}
|
}
|
||||||
return line.Layout.Slice(startCluster, endCluster)
|
return line.Layout.Slice(startCluster, endCluster)
|
||||||
|
|||||||
Reference in New Issue
Block a user