More compiler error fixes. Oops, I forgot to finish attrstr.m!
This commit is contained in:
parent
e9a62461c2
commit
82d3de7c31
|
@ -4,7 +4,7 @@
|
||||||
#include "attrstr.h"
|
#include "attrstr.h"
|
||||||
|
|
||||||
struct uiAttribute {
|
struct uiAttribute {
|
||||||
int owned;
|
int ownedByUser;
|
||||||
size_t refcount;
|
size_t refcount;
|
||||||
uiAttributeType type;
|
uiAttributeType type;
|
||||||
union {
|
union {
|
||||||
|
@ -174,7 +174,7 @@ uiAttribute *uiNewBackgroundAttribute(double r, double g, double b, double a)
|
||||||
{
|
{
|
||||||
uiAttribute *at;
|
uiAttribute *at;
|
||||||
|
|
||||||
at = newAttribute(uiAttributeTypeBackgroundColor);
|
at = newAttribute(uiAttributeTypeBackground);
|
||||||
at->u.color.r = r;
|
at->u.color.r = r;
|
||||||
at->u.color.g = g;
|
at->u.color.g = g;
|
||||||
at->u.color.b = b;
|
at->u.color.b = b;
|
||||||
|
|
|
@ -279,9 +279,9 @@ void uiAttributedStringDelete(uiAttributedString *s, size_t start, size_t end)
|
||||||
resize(s, start + count, start16 + count16);
|
resize(s, start + count, start16 + count16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t start, size_t end)
|
void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttribute *a, size_t start, size_t end)
|
||||||
{
|
{
|
||||||
uiprivAttrListInsertAttribute(s->attrs, spec, start, end);
|
uiprivAttrListInsertAttribute(s->attrs, a, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LONGTERM introduce an iterator object instead?
|
// LONGTERM introduce an iterator object instead?
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// TODO remove when done migrating these functions
|
// TODO remove when done migrating these functions
|
||||||
#define uiprivNew(x) uiNew(x)
|
#define uiprivNew(x) uiNew(x)
|
||||||
#define uiprivAlloc(x, y) uiAlloc(x, y)
|
#define uiprivAlloc(x, y) uiAlloc(x, y)
|
||||||
#define uiprivRealloc(x, y) uiRealloc(x, y)
|
#define uiprivRealloc(x, y, z) uiRealloc(x, y, z)
|
||||||
#define uiprivFree(x) uiFree(x)
|
#define uiprivFree(x) uiFree(x)
|
||||||
|
|
||||||
// attribute.c
|
// attribute.c
|
||||||
|
@ -21,7 +21,7 @@ extern void uiprivFreeAttrList(uiprivAttrList *alist);
|
||||||
extern void uiprivAttrListInsertAttribute(uiprivAttrList *alist, uiAttribute *val, size_t start, size_t end);
|
extern void uiprivAttrListInsertAttribute(uiprivAttrList *alist, uiAttribute *val, size_t start, size_t end);
|
||||||
extern void uiprivAttrListInsertCharactersUnattributed(uiprivAttrList *alist, size_t start, size_t count);
|
extern void uiprivAttrListInsertCharactersUnattributed(uiprivAttrList *alist, size_t start, size_t count);
|
||||||
extern void uiprivAttrListInsertCharactersExtendingAttributes(uiprivAttrList *alist, size_t start, size_t count);
|
extern void uiprivAttrListInsertCharactersExtendingAttributes(uiprivAttrList *alist, size_t start, size_t count);
|
||||||
extern void uiprivAttrListRemoveAttribute(uiprivAttrList *alist, uiAttribute type, size_t start, size_t end);
|
extern void uiprivAttrListRemoveAttribute(uiprivAttrList *alist, uiAttributeType type, size_t start, size_t end);
|
||||||
extern void uiprivAttrListRemoveAttributes(uiprivAttrList *alist, size_t start, size_t end);
|
extern void uiprivAttrListRemoveAttributes(uiprivAttrList *alist, size_t start, size_t end);
|
||||||
extern void uiprivAttrListRemoveCharacters(uiprivAttrList *alist, size_t start, size_t end);
|
extern void uiprivAttrListRemoveCharacters(uiprivAttrList *alist, size_t start, size_t end);
|
||||||
extern void uiprivAttrListForEach(const uiprivAttrList *alist, const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data);
|
extern void uiprivAttrListForEach(const uiprivAttrList *alist, const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data);
|
||||||
|
|
|
@ -53,7 +53,7 @@ void uiprivUninitUnderlineColors(void)
|
||||||
[auxiliaryColor release];
|
[auxiliaryColor release];
|
||||||
auxiliaryColor = nil;
|
auxiliaryColor = nil;
|
||||||
[grammarColor release];
|
[grammarColor release];
|
||||||
grammarColors = nil;
|
grammarColor = nil;
|
||||||
[spellingColor release];
|
[spellingColor release];
|
||||||
spellingColor = nil;
|
spellingColor = nil;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ static void addFontAttributeToRange(struct foreachParams *p, size_t start, size_
|
||||||
range.length = end - range.location;
|
range.length = end - range.location;
|
||||||
CFAttributedStringSetAttribute(p->mas, range, combinedFontAttrName, cfa);
|
CFAttributedStringSetAttribute(p->mas, range, combinedFontAttrName, cfa);
|
||||||
[cfa release];
|
[cfa release];
|
||||||
start += effectiveRange.length;
|
start += range.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ static backgroundBlock mkBackgroundBlock(size_t start, size_t end, double r, dou
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static CGColorRef mkcolor(uiAttributeSpec *spec)
|
static CGColorRef mkcolor(double r, double g, double b, double a)
|
||||||
{
|
{
|
||||||
CGColorSpaceRef colorspace;
|
CGColorSpaceRef colorspace;
|
||||||
CGColorRef color;
|
CGColorRef color;
|
||||||
|
@ -296,10 +296,10 @@ static CGColorRef mkcolor(uiAttributeSpec *spec)
|
||||||
if (colorspace == NULL) {
|
if (colorspace == NULL) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
components[0] = spec->R;
|
components[0] = r;
|
||||||
components[1] = spec->G;
|
components[1] = g;
|
||||||
components[2] = spec->B;
|
components[2] = b;
|
||||||
components[3] = spec->A;
|
components[3] = a;
|
||||||
color = CGColorCreate(colorspace, components);
|
color = CGColorCreate(colorspace, components);
|
||||||
CFRelease(colorspace);
|
CFRelease(colorspace);
|
||||||
return color;
|
return color;
|
||||||
|
@ -314,6 +314,8 @@ static uiForEach processAttribute(const uiAttributedString *s, const uiAttribute
|
||||||
backgroundBlock block;
|
backgroundBlock block;
|
||||||
int32_t us;
|
int32_t us;
|
||||||
CFNumberRef num;
|
CFNumberRef num;
|
||||||
|
double r, g, b, a;
|
||||||
|
uiUnderlineColor colorType;
|
||||||
|
|
||||||
ostart = start;
|
ostart = start;
|
||||||
oend = end;
|
oend = end;
|
||||||
|
@ -330,31 +332,31 @@ static uiForEach processAttribute(const uiAttributedString *s, const uiAttribute
|
||||||
case uiAttributeTypeFeatures:
|
case uiAttributeTypeFeatures:
|
||||||
addFontAttributeToRange(p, start, end, attr);
|
addFontAttributeToRange(p, start, end, attr);
|
||||||
break;
|
break;
|
||||||
$$TODO_CONTINUE_HERE
|
case uiAttributeTypeColor:
|
||||||
case uiAttributeColor:
|
uiAttributeColor(attr, &r, &g, &b, &a);
|
||||||
color = mkcolor(spec);
|
color = mkcolor(r, g, b, a);
|
||||||
CFAttributedStringSetAttribute(p->mas, range, kCTForegroundColorAttributeName, color);
|
CFAttributedStringSetAttribute(p->mas, range, kCTForegroundColorAttributeName, color);
|
||||||
CFRelease(color);
|
CFRelease(color);
|
||||||
break;
|
break;
|
||||||
case uiAttributeBackground:
|
case uiAttributeTypeBackground:
|
||||||
block = mkBackgroundBlock(ostart, oend,
|
uiAttributeColor(attr, &r, &g, &b, &a);
|
||||||
spec->R, spec->G, spec->B, spec->A);
|
block = mkBackgroundBlock(ostart, oend, r, g, b, a);
|
||||||
[p->backgroundBlocks addObject:block];
|
[p->backgroundBlocks addObject:block];
|
||||||
Block_release(block);
|
Block_release(block);
|
||||||
break;
|
break;
|
||||||
// TODO turn into a class, like we did with the font attributes, or even integrate *into* the font attributes
|
// TODO turn into a class, like we did with the font attributes, or even integrate *into* the font attributes
|
||||||
case uiAttributeUnderline:
|
case uiAttributeTypeUnderline:
|
||||||
switch (spec->Value) {
|
switch (uiAttributeUnderline(attr)) {
|
||||||
case uiDrawUnderlineStyleNone:
|
case uiUnderlineNone:
|
||||||
us = kCTUnderlineStyleNone;
|
us = kCTUnderlineStyleNone;
|
||||||
break;
|
break;
|
||||||
case uiDrawUnderlineStyleSingle:
|
case uiUnderlineSingle:
|
||||||
us = kCTUnderlineStyleSingle;
|
us = kCTUnderlineStyleSingle;
|
||||||
break;
|
break;
|
||||||
case uiDrawUnderlineStyleDouble:
|
case uiUnderlineDouble:
|
||||||
us = kCTUnderlineStyleDouble;
|
us = kCTUnderlineStyleDouble;
|
||||||
break;
|
break;
|
||||||
case uiDrawUnderlineStyleSuggestion:
|
case uiUnderlineSuggestion:
|
||||||
// TODO incorrect if a solid color
|
// TODO incorrect if a solid color
|
||||||
us = kCTUnderlineStyleThick;
|
us = kCTUnderlineStyleThick;
|
||||||
break;
|
break;
|
||||||
|
@ -363,23 +365,24 @@ $$TODO_CONTINUE_HERE
|
||||||
CFAttributedStringSetAttribute(p->mas, range, kCTUnderlineStyleAttributeName, num);
|
CFAttributedStringSetAttribute(p->mas, range, kCTUnderlineStyleAttributeName, num);
|
||||||
CFRelease(num);
|
CFRelease(num);
|
||||||
break;
|
break;
|
||||||
case uiAttributeUnderlineColor:
|
case uiAttributeTypeUnderlineColor:
|
||||||
switch (spec->Value) {
|
uiAttributeUnderlineColor(attr, &colorType, &r, &g, &b, &a);
|
||||||
case uiDrawUnderlineColorCustom:
|
switch (colorType) {
|
||||||
color = mkcolor(spec);
|
case uiUnderlineColorCustom:
|
||||||
|
color = mkcolor(r, g, b, a);
|
||||||
break;
|
break;
|
||||||
case uiDrawUnderlineColorSpelling:
|
case uiUnderlineColorSpelling:
|
||||||
color = [spellingColor CGColor];
|
color = [spellingColor CGColor];
|
||||||
break;
|
break;
|
||||||
case uiDrawUnderlineColorGrammar:
|
case uiUnderlineColorGrammar:
|
||||||
color = [grammarColor CGColor];
|
color = [grammarColor CGColor];
|
||||||
break;
|
break;
|
||||||
case uiDrawUnderlineColorAuxiliary:
|
case uiUnderlineColorAuxiliary:
|
||||||
color = [auxiliaryColor CGColor];
|
color = [auxiliaryColor CGColor];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CFAttributedStringSetAttribute(p->mas, range, kCTUnderlineColorAttributeName, color);
|
CFAttributedStringSetAttribute(p->mas, range, kCTUnderlineColorAttributeName, color);
|
||||||
if (spec->Value == uiDrawUnderlineColorCustom)
|
if (colorType == uiUnderlineColorCustom)
|
||||||
CFRelease(color);
|
CFRelease(color);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +413,7 @@ static void applyFontAttributes(CFMutableAttributedStringRef mas, uiFontDescript
|
||||||
range.location = 0;
|
range.location = 0;
|
||||||
while (range.location < n) {
|
while (range.location < n) {
|
||||||
// TODO consider seeing if CFAttributedStringGetAttributeAndLongestEffectiveRange() can make things faster by reducing the number of potential iterations, either here or above
|
// TODO consider seeing if CFAttributedStringGetAttributeAndLongestEffectiveRange() can make things faster by reducing the number of potential iterations, either here or above
|
||||||
cfa = (uiprivCombinedFontAttr *) CFAttributedStringSetAttribute(mas, range.location, combinedFontAttrName, &range);
|
cfa = (uiprivCombinedFontAttr *) CFAttributedStringGetAttribute(mas, range.location, combinedFontAttrName, &range);
|
||||||
if (cfa != nil) {
|
if (cfa != nil) {
|
||||||
font = [cfa toCTFontWithDefaultFont:defaultFont];
|
font = [cfa toCTFontWithDefaultFont:defaultFont];
|
||||||
CFAttributedStringSetAttribute(mas, range, kCTFontAttributeName, font);
|
CFAttributedStringSetAttribute(mas, range, kCTFontAttributeName, font);
|
||||||
|
|
Loading…
Reference in New Issue