Fixed uiAttributedString not putting the right position for the last character. Simple case of using the wrong variables.
This commit is contained in:
parent
49d36b340c
commit
6fa009a7dd
|
@ -207,9 +207,9 @@ void uiAttributedStringInsertAtUnattributed(uiAttributedString *s, const char *s
|
||||||
// and adjust the prior values in the conversion tables
|
// and adjust the prior values in the conversion tables
|
||||||
// use <= so the terminating 0 gets updated too
|
// use <= so the terminating 0 gets updated too
|
||||||
for (i = 0; i <= oldlen - at; i++)
|
for (i = 0; i <= oldlen - at; i++)
|
||||||
s->u8tou16[at + n8 + i] += n16;
|
s->u8tou16[at + oldlen + i] += old16len;
|
||||||
for (i = 0; i <= old16len - at16; i++)
|
for (i = 0; i <= old16len - at16; i++)
|
||||||
s->u16tou8[at16 + n16 + i] += n8;
|
s->u16tou8[at16 + old16len + i] += oldlen;
|
||||||
|
|
||||||
// and finally do the attributes
|
// and finally do the attributes
|
||||||
attrlistInsertCharactersUnattributed(s->attrs, at, n8);
|
attrlistInsertCharactersUnattributed(s->attrs, at, n8);
|
||||||
|
|
|
@ -424,15 +424,12 @@ double uiDrawTextLayoutByteLocationInLine(uiDrawTextLayout *tl, size_t pos, int
|
||||||
CTLineRef lr;
|
CTLineRef lr;
|
||||||
CFRange range;
|
CFRange range;
|
||||||
|
|
||||||
printf("= %zd %zd ", pos, tl->nUTF8);
|
|
||||||
pos = tl->u8tou16[pos];
|
pos = tl->u8tou16[pos];
|
||||||
printf("-> %zd %zd\n", pos, tl->nUTF16);
|
|
||||||
if (line < 0 || line >= tl->nLines)
|
if (line < 0 || line >= tl->nLines)
|
||||||
return -1;
|
return -1;
|
||||||
lr = (CTLineRef) CFArrayGetValueAtIndex(tl->lines, line);
|
lr = (CTLineRef) CFArrayGetValueAtIndex(tl->lines, line);
|
||||||
range = CTLineGetStringRange(lr);
|
range = CTLineGetStringRange(lr);
|
||||||
// note: >, not >=, because the position at end is valid!
|
// note: >, not >=, because the position at end is valid!
|
||||||
printf("%zd %zd\n", pos, (size_t)(range.location+range.length));
|
|
||||||
if (pos < range.location || pos > (range.location + range.length))
|
if (pos < range.location || pos > (range.location + range.length))
|
||||||
return -1;
|
return -1;
|
||||||
// no point in checking the return; we already validated everything and 0 is a valid return for the first index :/
|
// no point in checking the return; we already validated everything and 0 is a valid return for the first index :/
|
||||||
|
|
Loading…
Reference in New Issue