Fixed hanging errors in uiDrawCaret().
This commit is contained in:
parent
5f05ebbffe
commit
6acb10a4fc
|
@ -10,24 +10,21 @@ void uiDrawCaret(uiDrawContext *c, double x, double y, uiDrawTextLayout *layout,
|
||||||
uiDrawPath *path;
|
uiDrawPath *path;
|
||||||
uiDrawBrush brush;
|
uiDrawBrush brush;
|
||||||
|
|
||||||
|
if (*line < 0)
|
||||||
|
*line = 0;
|
||||||
|
if (*line > (uiDrawTextLayoutNumLines(layout) - 1))
|
||||||
|
*line = (uiDrawTextLayoutNumLines(layout) - 1);
|
||||||
|
// TODO cap pos
|
||||||
xoff = uiDrawTextLayoutByteLocationInLine(layout, pos, *line);
|
xoff = uiDrawTextLayoutByteLocationInLine(layout, pos, *line);
|
||||||
if (xoff < 0) {
|
while (xoff < 0) {
|
||||||
size_t start, end;
|
size_t start, end;
|
||||||
int incr;
|
|
||||||
|
|
||||||
if (*line > (uiDrawTextLayoutNumLines(layout) - 1)) {
|
uiDrawTextLayoutLineByteRange(layout, *line, &start, &end);
|
||||||
*line = (uiDrawTextLayoutNumLines(layout) - 1);
|
if (end < pos) // too far up
|
||||||
incr = -1;
|
(*line)++;
|
||||||
} else {
|
else
|
||||||
uiDrawTextLayoutLineByteRange(layout, *line, &start, &end);
|
(*line)--;
|
||||||
incr = 1;
|
xoff = uiDrawTextLayoutByteLocationInLine(layout, pos, *line);
|
||||||
if (end < pos)
|
|
||||||
incr = -1;
|
|
||||||
}
|
|
||||||
while (xoff < 0) {
|
|
||||||
*line += incr;
|
|
||||||
xoff = uiDrawTextLayoutByteLocationInLine(layout, pos, *line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
uiDrawTextLayoutLineGetMetrics(layout, *line, &m);
|
uiDrawTextLayoutLineGetMetrics(layout, *line, &m);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue