パッチ ファイルのシンタックス ハイライトを実行できるアプリを開発する必要があります。これは、iOS6 で追加された NSMutableAttributedString に大きく依存しているため、ハイライト属性を追加するプロセッサ クラスを使用して、ファイルを表示するマスター/詳細ビューを作成します。テキストの各行ですが、このattributeStringをUITextView.attributeStringに割り当てると、失われたすべての属性が見つかりました.
私のコードは次のようなものです:
- (IBAction)ColorIconClicked:(id)sender {
NSMutableAttributedString *str = [[NSMutableAttributedString alloc
] initWithAttributedString:self.textView.attributedText];
self.textView.text = nil;
[self.textView setEditable:YES];
[[processor processPatchText:str withTheme:COLOR_TEXT_THEME_DAY suggestFormat:@"diffu"] attributedSubstringFromRange:NSMakeRange(0, str.length)];
self.textView.attributedText = str;
NSLog(@"|||||||||||||||||||||||||||||||||");
NSLog(@"STD: %@", str);
NSLog(@"-----------------------------");
NSLog(@"%@", self.textView.attributedText);
[self.textView setEditable:NO];
}
私がキャプチャしたログは次のとおりです。
これは、割り当て前の「str」のダンプです。
2012-10-19 01:12:42.863 ColorDiff[354:907] |||||||||||||||||||||||||||||||||
2012-10-19 01:12:42.883 ColorDiff[354:907] STD: diff --git a/ColorDiff/CDTextProcessor.m b/ColorDiff/CDTextProcessor.m{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}index 3e554fa..18723b2 100644{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}--- a/ColorDiff/CDTextProcessor.m{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+++ b/ColorDiff/CDTextProcessor.m{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}@@ -15,9 +15,19 @@{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
} // git format-patch or something like svn or raw diff output.{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
} //{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
} // then it should call the different render to do the actually render job.{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}-- (NSMutableAttributedString *) processPatchText:(NSMutableAttributedString*) attstring withTheme: (int) theme suggestFormat:(NSString *) format{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+- (NSMutableAttributedString *) processPatchText:(NSMutableAttributedString *) attstring{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+ withTheme:(int) theme{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+ * This function return the patch format for the input text.{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+ * return type should be like: diffu, diffc, etc, aligh with colordiff.pl{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+ */{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+- (NSString *) detechPatchFormatForText:(NSMutableAttributedString *) attstring{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+{{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+ {
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}+}{
NSColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
しかし、割り当てた後:
このようなtextViewの属性のダンプ
"NSLog(@"%@", self.textView.attributedText);" is become:
2012-10-19 01:12:42.924 ColorDiff[354:907] -----------------------------
2012-10-19 01:12:42.991 ColorDiff[354:907] diff --git a/ColorDiff/CDTextProcessor.m b/ColorDiff/CDTextProcessor.m
index 3e554fa..18723b2 100644
--- a/ColorDiff/CDTextProcessor.m
+++ b/ColorDiff/CDTextProcessor.m
@@ -15,9 +15,19 @@
// git format-patch or something like svn or raw diff output.
//
// then it should call the different render to do the actually render job.
-- (NSMutableAttributedString *) processPatchText:(NSMutableAttributedString*) attstring withTheme: (int) theme suggestFormat:(NSString *) format
+- (NSMutableAttributedString *) processPatchText:(NSMutableAttributedString *) attstring
+ withTheme:(int) theme
+ suggestFormat:(NSString *) format
{
}
+/*
+ * This function return the patch format for the input text.
+ * return type should be like: diffu, diffc, etc, aligh with colordiff.pl
+ */
+- (NSString *) detechPatchFormatForText:(NSMutableAttributedString *) attstring
+{
+
+}
{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICFFont: 0x210595f0> font-family: \".Helvetica NeueUI\"; font-weight: normal; font-style: normal; font-size: 14px";
NSKern = 0;
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (null), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
NSStrokeColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSStrokeWidth = 0;
}
textView の self.textView.attributedText を代入すると、str の属性が失われます。
なんで ?
これはバグですか?
の属性文字列を textView に割り当てるにはどうすればよいですか?