Removed the NumLines and LineByteRange functions for now; I'll count them under extents.
This commit is contained in:
parent
d358e87583
commit
fa293717af
|
@ -0,0 +1,60 @@
|
|||
darwin
|
||||
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
||||
{
|
||||
return CFArrayGetCount([tl->forLines lines]);
|
||||
}
|
||||
|
||||
void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end)
|
||||
{
|
||||
CTLineRef lr;
|
||||
CFRange range;
|
||||
|
||||
lr = (CTLineRef) CFArrayGetValueAtIndex([tl->forLines lines], line);
|
||||
range = CTLineGetStringRange(lr);
|
||||
*start = tl->u16tou8[range.location];
|
||||
if (tl->empty)
|
||||
*end = *start;
|
||||
else
|
||||
*end = tl->u16tou8[range.location + range.length];
|
||||
}
|
||||
|
||||
|
||||
unix
|
||||
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
||||
{
|
||||
return pango_layout_get_line_count(tl->layout);
|
||||
}
|
||||
|
||||
void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end)
|
||||
{
|
||||
PangoLayoutLine *pll;
|
||||
|
||||
pll = pango_layout_get_line_readonly(tl->layout, line);
|
||||
*start = pll->start_index;
|
||||
*end = pll->start_index + pll->length;
|
||||
// TODO unref pll?
|
||||
}
|
||||
|
||||
|
||||
windows
|
||||
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
||||
{
|
||||
return 0;
|
||||
#if 0
|
||||
TODO
|
||||
return tl->nLines;
|
||||
#endif
|
||||
}
|
||||
|
||||
// DirectWrite doesn't provide a direct way to do this, so we have to do this manually
|
||||
// TODO does that comment still apply here or to the code at the top of this file?
|
||||
void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end)
|
||||
{
|
||||
#if 0
|
||||
TODO
|
||||
*start = tl->lineInfo[line].startPos;
|
||||
*start = tl->u16tou8[*start];
|
||||
*end = tl->lineInfo[line].endPos - tl->lineInfo[line].newlineCount;
|
||||
*end = tl->u16tou8[*end];
|
||||
#endif
|
||||
}
|
|
@ -31,6 +31,15 @@ struct uiDrawTextLayoutLineMetrics {
|
|||
// TODO trailing whitespace?
|
||||
};
|
||||
|
||||
// uiDrawTextLayoutNumLines() returns the number of lines in tl.
|
||||
// This number will always be greater than or equal to 1; a text
|
||||
// layout with no text only has one line.
|
||||
_UI_EXTERN int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl);
|
||||
|
||||
// uiDrawTextLayoutLineByteRange() returns the byte indices of the
|
||||
// text that falls into the given line of tl as [start, end).
|
||||
_UI_EXTERN void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end);
|
||||
|
||||
_UI_EXTERN void uiDrawTextLayoutLineGetMetrics(uiDrawTextLayout *tl, int line, uiDrawTextLayoutLineMetrics *m);
|
||||
|
||||
// TODO rewrite this documentation
|
|
@ -212,22 +212,3 @@ void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height
|
|||
[tl->frame returnWidth:width height:NULL];
|
||||
[tl->forLines returnWidth:NULL height:height];
|
||||
}
|
||||
|
||||
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
||||
{
|
||||
return CFArrayGetCount([tl->forLines lines]);
|
||||
}
|
||||
|
||||
void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end)
|
||||
{
|
||||
CTLineRef lr;
|
||||
CFRange range;
|
||||
|
||||
lr = (CTLineRef) CFArrayGetValueAtIndex([tl->forLines lines], line);
|
||||
range = CTLineGetStringRange(lr);
|
||||
*start = tl->u16tou8[range.location];
|
||||
if (tl->empty)
|
||||
*end = *start;
|
||||
else
|
||||
*end = tl->u16tou8[range.location + range.length];
|
||||
}
|
||||
|
|
|
@ -484,15 +484,6 @@ _UI_EXTERN void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, dou
|
|||
// function to get the actual size of the text layout.
|
||||
_UI_EXTERN void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height);
|
||||
|
||||
// uiDrawTextLayoutNumLines() returns the number of lines in tl.
|
||||
// This number will always be greater than or equal to 1; a text
|
||||
// layout with no text only has one line.
|
||||
_UI_EXTERN int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl);
|
||||
|
||||
// uiDrawTextLayoutLineByteRange() returns the byte indices of the
|
||||
// text that falls into the given line of tl as [start, end).
|
||||
_UI_EXTERN void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end);
|
||||
|
||||
// TODO metrics functions
|
||||
|
||||
// TODO number of lines visible for clipping rect, range visible for clipping rect?
|
||||
|
|
|
@ -79,18 +79,3 @@ void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height
|
|||
*width = pangoToCairo(logical.width);
|
||||
*height = pangoToCairo(logical.height);
|
||||
}
|
||||
|
||||
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
||||
{
|
||||
return pango_layout_get_line_count(tl->layout);
|
||||
}
|
||||
|
||||
void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end)
|
||||
{
|
||||
PangoLayoutLine *pll;
|
||||
|
||||
pll = pango_layout_get_line_readonly(tl->layout, line);
|
||||
*start = pll->start_index;
|
||||
*end = pll->start_index + pll->length;
|
||||
// TODO unref pll?
|
||||
}
|
||||
|
|
|
@ -534,25 +534,3 @@ void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height
|
|||
// TODO make sure the behavior of this on empty strings is the same on all platforms (ideally should be 0-width, line height-height; TODO note this in the docs too)
|
||||
*height = metrics.height;
|
||||
}
|
||||
|
||||
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
||||
{
|
||||
return 0;
|
||||
#if 0
|
||||
TODO
|
||||
return tl->nLines;
|
||||
#endif
|
||||
}
|
||||
|
||||
// DirectWrite doesn't provide a direct way to do this, so we have to do this manually
|
||||
// TODO does that comment still apply here or to the code at the top of this file?
|
||||
void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end)
|
||||
{
|
||||
#if 0
|
||||
TODO
|
||||
*start = tl->lineInfo[line].startPos;
|
||||
*start = tl->u16tou8[*start];
|
||||
*end = tl->lineInfo[line].endPos - tl->lineInfo[line].newlineCount;
|
||||
*end = tl->u16tou8[*end];
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue