mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 13:40:54 +00:00
Tidied indentation
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10573 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
949f20149f
commit
56ca810cfa
1 changed files with 109 additions and 81 deletions
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
} StringContext;
|
||||
|
||||
static void
|
||||
initStringContext(StringContext *ctxt, NSString *string)
|
||||
initStringContext (StringContext *ctxt, NSString *string)
|
||||
{
|
||||
ctxt->string = string;
|
||||
ctxt->position = 0;
|
||||
|
@ -46,7 +46,7 @@ initStringContext(StringContext *ctxt, NSString *string)
|
|||
}
|
||||
|
||||
static int
|
||||
readNSString(StringContext *ctxt)
|
||||
readNSString (StringContext *ctxt)
|
||||
{
|
||||
return (ctxt->position < ctxt->length )
|
||||
? [ctxt->string characterAtIndex:ctxt->position++]: EOF;
|
||||
|
@ -74,7 +74,7 @@ readNSString(StringContext *ctxt)
|
|||
- (NSNumber*) underline;
|
||||
- (void) resetParagraphStyle;
|
||||
- (void) resetFont;
|
||||
- (void) addTab: (float) location type: (NSTextTabType) type;
|
||||
- (void) addTab: (float)location type: (NSTextTabType)type;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -200,7 +200,9 @@ readNSString(StringContext *ctxt)
|
|||
tabChanged = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
[paragraph addTabStop: tab];
|
||||
}
|
||||
|
||||
changed = YES;
|
||||
RELEASE(tab);
|
||||
|
@ -230,8 +232,10 @@ readNSString(StringContext *ctxt)
|
|||
NSAttributedString *text = nil;
|
||||
|
||||
if ([wrapper isRegularFile])
|
||||
{
|
||||
text = [consumer parseRTF: [wrapper regularFileContents]
|
||||
documentAttributes: dict];
|
||||
}
|
||||
else if ([wrapper isDirectory])
|
||||
{
|
||||
NSDictionary *files = [wrapper fileWrappers];
|
||||
|
@ -240,9 +244,11 @@ readNSString(StringContext *ctxt)
|
|||
//FIXME: We should store the files in the consumer
|
||||
// We try to read the main file in the directory
|
||||
if ((contents = [files objectForKey: @"TXT.rtf"]) != nil)
|
||||
{
|
||||
text = [consumer parseRTF: [contents regularFileContents]
|
||||
documentAttributes: dict];
|
||||
}
|
||||
}
|
||||
|
||||
RELEASE(consumer);
|
||||
|
||||
|
@ -274,7 +280,7 @@ readNSString(StringContext *ctxt)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(fonts);
|
||||
RELEASE(attrs);
|
||||
|
@ -340,7 +346,8 @@ readNSString(StringContext *ctxt)
|
|||
CREATE_AUTORELEASE_POOL(pool);
|
||||
RTFscannerCtxt scanner;
|
||||
StringContext stringCtxt;
|
||||
// We should read in the first few characters to find out which encoding we have
|
||||
// We should read in the first few characters to find out which
|
||||
// encoding we have
|
||||
NSString *rtfString = [[NSString alloc]
|
||||
initWithData: rtfData
|
||||
encoding: NSASCIIStringEncoding];
|
||||
|
@ -362,7 +369,9 @@ readNSString(StringContext *ctxt)
|
|||
RELEASE(pool);
|
||||
// document attributes
|
||||
if (dict)
|
||||
{
|
||||
*dict = [self documentAttributes];
|
||||
}
|
||||
|
||||
return [self result];
|
||||
}
|
||||
|
@ -399,13 +408,13 @@ readNSString(StringContext *ctxt)
|
|||
*/
|
||||
|
||||
/* handle errors (this is the yacc error mech) */
|
||||
void GSRTFerror(const char *msg)
|
||||
void GSRTFerror (const char *msg)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Syntax error in RTF: %s", msg];
|
||||
}
|
||||
|
||||
void GSRTFgenericRTFcommand(void *ctxt, RTFcmd cmd)
|
||||
void GSRTFgenericRTFcommand (void *ctxt, RTFcmd cmd)
|
||||
{
|
||||
NSDebugLLog(@"RTFParser", @"encountered rtf cmd:%s", cmd.name);
|
||||
if (!cmd.isEmpty)
|
||||
|
@ -413,40 +422,46 @@ void GSRTFgenericRTFcommand(void *ctxt, RTFcmd cmd)
|
|||
}
|
||||
|
||||
//Start: we're doing some initialization
|
||||
void GSRTFstart(void *ctxt)
|
||||
void GSRTFstart (void *ctxt)
|
||||
{
|
||||
NSDebugLLog(@"RTFParser", @"Start RTF parsing");
|
||||
[RESULT beginEditing];
|
||||
}
|
||||
|
||||
// Finished to parse one piece of RTF.
|
||||
void GSRTFstop(void *ctxt)
|
||||
void GSRTFstop (void *ctxt)
|
||||
{
|
||||
//<!> close all open bolds et al.
|
||||
[RESULT endEditing];
|
||||
NSDebugLLog(@"RTFParser", @"End RTF parsing");
|
||||
}
|
||||
|
||||
void GSRTFopenBlock(void *ctxt, BOOL ignore)
|
||||
void GSRTFopenBlock (void *ctxt, BOOL ignore)
|
||||
{
|
||||
if (!IGNORE)
|
||||
{
|
||||
[(RTFConsumer *)ctxt push];
|
||||
}
|
||||
// Switch off any output for ignored block statements
|
||||
if (ignore)
|
||||
{
|
||||
IGNORE++;
|
||||
}
|
||||
}
|
||||
|
||||
void GSRTFcloseBlock(void *ctxt, BOOL ignore)
|
||||
void GSRTFcloseBlock (void *ctxt, BOOL ignore)
|
||||
{
|
||||
if (ignore)
|
||||
{
|
||||
IGNORE--;
|
||||
}
|
||||
if (!IGNORE)
|
||||
{
|
||||
[(RTFConsumer *)ctxt pop];
|
||||
}
|
||||
}
|
||||
|
||||
void GSRTFmangleText(void *ctxt, const char *text)
|
||||
void GSRTFmangleText (void *ctxt, const char *text)
|
||||
{
|
||||
int oldPosition = TEXTPOSITION;
|
||||
int textlen = strlen(text);
|
||||
|
@ -460,31 +475,40 @@ void GSRTFmangleText(void *ctxt, const char *text)
|
|||
|
||||
if (CHANGED)
|
||||
{
|
||||
attributes = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
attributes = [NSMutableDictionary
|
||||
dictionaryWithObjectsAndKeys:
|
||||
[CTXT currentFont], NSFontAttributeName,
|
||||
PARAGRAPH, NSParagraphStyleAttributeName,
|
||||
nil];
|
||||
if (UNDERLINE)
|
||||
{
|
||||
[attributes setObject: [CTXT underline]
|
||||
forKey: NSUnderlineStyleAttributeName];
|
||||
}
|
||||
if (SCRIPT)
|
||||
{
|
||||
[attributes setObject: [CTXT script]
|
||||
forKey: NSSuperscriptAttributeName];
|
||||
}
|
||||
if (FGCOLOUR != nil)
|
||||
{
|
||||
[attributes setObject: FGCOLOUR
|
||||
forKey: NSForegroundColorAttributeName];
|
||||
}
|
||||
if (BGCOLOUR != nil)
|
||||
{
|
||||
[attributes setObject: BGCOLOUR
|
||||
forKey: NSBackgroundColorAttributeName];
|
||||
}
|
||||
|
||||
[RESULT setAttributes: attributes range:
|
||||
NSMakeRange(oldPosition, textlen)];
|
||||
[RESULT setAttributes: attributes
|
||||
range: NSMakeRange(oldPosition, textlen)];
|
||||
CHANGED = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GSRTFregisterFont(void *ctxt, const char *fontName,
|
||||
void GSRTFregisterFont (void *ctxt, const char *fontName,
|
||||
RTFfontFamily family, int fontNumber)
|
||||
{
|
||||
NSString *fontNameString;
|
||||
|
@ -502,7 +526,7 @@ void GSRTFregisterFont(void *ctxt, const char *fontName,
|
|||
[FONTS setObject: fontNameString forKey: fontId];
|
||||
}
|
||||
|
||||
void GSRTFfontNumber(void *ctxt, int fontNumber)
|
||||
void GSRTFfontNumber (void *ctxt, int fontNumber)
|
||||
{
|
||||
NSNumber *fontId = [NSNumber numberWithInt: fontNumber];
|
||||
NSString *fontName = [FONTS objectForKey: fontId];
|
||||
|
@ -526,7 +550,7 @@ void GSRTFfontNumber(void *ctxt, int fontNumber)
|
|||
}
|
||||
|
||||
// <N> fontSize is in halfpoints according to spec
|
||||
void GSRTFfontSize(void *ctxt, int fontSize)
|
||||
void GSRTFfontSize (void *ctxt, int fontSize)
|
||||
{
|
||||
float size = halfpoints2points(fontSize);
|
||||
|
||||
|
@ -537,7 +561,7 @@ void GSRTFfontSize(void *ctxt, int fontSize)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFpaperWidth(void *ctxt, int width)
|
||||
void GSRTFpaperWidth (void *ctxt, int width)
|
||||
{
|
||||
float fwidth = twips2points(width);
|
||||
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
||||
|
@ -545,7 +569,9 @@ void GSRTFpaperWidth(void *ctxt, int width)
|
|||
NSSize size;
|
||||
|
||||
if (val == nil)
|
||||
{
|
||||
size = NSMakeSize(fwidth, 792);
|
||||
}
|
||||
else
|
||||
{
|
||||
size = [val sizeValue];
|
||||
|
@ -554,7 +580,7 @@ void GSRTFpaperWidth(void *ctxt, int width)
|
|||
[dict setObject: [NSValue valueWithSize: size] forKey: PAPERSIZE];
|
||||
}
|
||||
|
||||
void GSRTFpaperHeight(void *ctxt, int height)
|
||||
void GSRTFpaperHeight (void *ctxt, int height)
|
||||
{
|
||||
float fheight = twips2points(height);
|
||||
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
||||
|
@ -562,7 +588,9 @@ void GSRTFpaperHeight(void *ctxt, int height)
|
|||
NSSize size;
|
||||
|
||||
if (val == nil)
|
||||
{
|
||||
size = NSMakeSize(612, fheight);
|
||||
}
|
||||
else
|
||||
{
|
||||
size = [val sizeValue];
|
||||
|
@ -571,7 +599,7 @@ void GSRTFpaperHeight(void *ctxt, int height)
|
|||
[dict setObject: [NSValue valueWithSize: size] forKey: PAPERSIZE];
|
||||
}
|
||||
|
||||
void GSRTFmarginLeft(void *ctxt, int margin)
|
||||
void GSRTFmarginLeft (void *ctxt, int margin)
|
||||
{
|
||||
float fmargin = twips2points(margin);
|
||||
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
||||
|
@ -579,7 +607,7 @@ void GSRTFmarginLeft(void *ctxt, int margin)
|
|||
[dict setObject: [NSNumber numberWithFloat: fmargin] forKey: LEFTMARGIN];
|
||||
}
|
||||
|
||||
void GSRTFmarginRight(void *ctxt, int margin)
|
||||
void GSRTFmarginRight (void *ctxt, int margin)
|
||||
{
|
||||
float fmargin = twips2points(margin);
|
||||
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
||||
|
@ -587,7 +615,7 @@ void GSRTFmarginRight(void *ctxt, int margin)
|
|||
[dict setObject: [NSNumber numberWithFloat: fmargin] forKey: RIGHTMARGIN];
|
||||
}
|
||||
|
||||
void GSRTFmarginTop(void *ctxt, int margin)
|
||||
void GSRTFmarginTop (void *ctxt, int margin)
|
||||
{
|
||||
float fmargin = twips2points(margin);
|
||||
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
||||
|
@ -595,7 +623,7 @@ void GSRTFmarginTop(void *ctxt, int margin)
|
|||
[dict setObject: [NSNumber numberWithFloat: fmargin] forKey: TOPMARGIN];
|
||||
}
|
||||
|
||||
void GSRTFmarginButtom(void *ctxt, int margin)
|
||||
void GSRTFmarginButtom (void *ctxt, int margin)
|
||||
{
|
||||
float fmargin = twips2points(margin);
|
||||
NSMutableDictionary *dict = DOCUMENTATTRIBUTES;
|
||||
|
@ -603,7 +631,7 @@ void GSRTFmarginButtom(void *ctxt, int margin)
|
|||
[dict setObject: [NSNumber numberWithFloat: fmargin] forKey: BUTTOMMARGIN];
|
||||
}
|
||||
|
||||
void GSRTFfirstLineIndent(void *ctxt, int indent)
|
||||
void GSRTFfirstLineIndent (void *ctxt, int indent)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
float findent = twips2points(indent);
|
||||
|
@ -617,7 +645,7 @@ void GSRTFfirstLineIndent(void *ctxt, int indent)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFleftIndent(void *ctxt, int indent)
|
||||
void GSRTFleftIndent (void *ctxt, int indent)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
float findent = twips2points(indent);
|
||||
|
@ -630,7 +658,7 @@ void GSRTFleftIndent(void *ctxt, int indent)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFrightIndent(void *ctxt, int indent)
|
||||
void GSRTFrightIndent (void *ctxt, int indent)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
float findent = twips2points(indent);
|
||||
|
@ -643,7 +671,7 @@ void GSRTFrightIndent(void *ctxt, int indent)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFtabstop(void *ctxt, int location)
|
||||
void GSRTFtabstop (void *ctxt, int location)
|
||||
{
|
||||
float flocation = twips2points(location);
|
||||
|
||||
|
@ -653,7 +681,7 @@ void GSRTFtabstop(void *ctxt, int location)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFalignCenter(void *ctxt)
|
||||
void GSRTFalignCenter (void *ctxt)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
|
||||
|
@ -664,7 +692,7 @@ void GSRTFalignCenter(void *ctxt)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFalignJustified(void *ctxt)
|
||||
void GSRTFalignJustified (void *ctxt)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
|
||||
|
@ -675,7 +703,7 @@ void GSRTFalignJustified(void *ctxt)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFalignLeft(void *ctxt)
|
||||
void GSRTFalignLeft (void *ctxt)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
|
||||
|
@ -686,7 +714,7 @@ void GSRTFalignLeft(void *ctxt)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFalignRight(void *ctxt)
|
||||
void GSRTFalignRight (void *ctxt)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
|
||||
|
@ -697,7 +725,7 @@ void GSRTFalignRight(void *ctxt)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFspaceAbove(void *ctxt, int space)
|
||||
void GSRTFspaceAbove (void *ctxt, int space)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
float fspace = twips2points(space);
|
||||
|
@ -708,7 +736,7 @@ void GSRTFspaceAbove(void *ctxt, int space)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFlineSpace(void *ctxt, int space)
|
||||
void GSRTFlineSpace (void *ctxt, int space)
|
||||
{
|
||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||
float fspace = twips2points(space);
|
||||
|
@ -728,21 +756,21 @@ void GSRTFlineSpace(void *ctxt, int space)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFdefaultParagraph(void *ctxt)
|
||||
void GSRTFdefaultParagraph (void *ctxt)
|
||||
{
|
||||
[CTXT resetParagraphStyle];
|
||||
}
|
||||
|
||||
void GSRTFstyle(void *ctxt, int style)
|
||||
void GSRTFstyle (void *ctxt, int style)
|
||||
{
|
||||
}
|
||||
|
||||
void GSRTFdefaultCharacterStyle(void *ctxt)
|
||||
void GSRTFdefaultCharacterStyle (void *ctxt)
|
||||
{
|
||||
[CTXT resetFont];
|
||||
}
|
||||
|
||||
void GSRTFaddColor(void *ctxt, int red, int green, int blue)
|
||||
void GSRTFaddColor (void *ctxt, int red, int green, int blue)
|
||||
{
|
||||
NSColor *colour = [NSColor colorWithCalibratedRed: red/255.0
|
||||
green: green/255.0
|
||||
|
@ -752,22 +780,22 @@ void GSRTFaddColor(void *ctxt, int red, int green, int blue)
|
|||
[COLOURS addObject: colour];
|
||||
}
|
||||
|
||||
void GSRTFaddDefaultColor(void *ctxt)
|
||||
void GSRTFaddDefaultColor (void *ctxt)
|
||||
{
|
||||
[COLOURS addObject: [NSColor textColor]];
|
||||
}
|
||||
|
||||
void GSRTFcolorbg(void *ctxt, int color)
|
||||
void GSRTFcolorbg (void *ctxt, int color)
|
||||
{
|
||||
ASSIGN(BGCOLOUR, [COLOURS objectAtIndex: color]);
|
||||
}
|
||||
|
||||
void GSRTFcolorfg(void *ctxt, int color)
|
||||
void GSRTFcolorfg (void *ctxt, int color)
|
||||
{
|
||||
ASSIGN(FGCOLOUR, [COLOURS objectAtIndex: color]);
|
||||
}
|
||||
|
||||
void GSRTFsubscript(void *ctxt, int script)
|
||||
void GSRTFsubscript (void *ctxt, int script)
|
||||
{
|
||||
script = (int) (-halfpoints2points(script) / 3.0);
|
||||
|
||||
|
@ -778,7 +806,7 @@ void GSRTFsubscript(void *ctxt, int script)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFsuperscript(void *ctxt, int script)
|
||||
void GSRTFsuperscript (void *ctxt, int script)
|
||||
{
|
||||
script = (int) (halfpoints2points(script) / 3.0);
|
||||
|
||||
|
@ -789,7 +817,7 @@ void GSRTFsuperscript(void *ctxt, int script)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFitalic(void *ctxt, BOOL state)
|
||||
void GSRTFitalic (void *ctxt, BOOL state)
|
||||
{
|
||||
if (state != ITALIC)
|
||||
{
|
||||
|
@ -798,7 +826,7 @@ void GSRTFitalic(void *ctxt, BOOL state)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFbold(void *ctxt, BOOL state)
|
||||
void GSRTFbold (void *ctxt, BOOL state)
|
||||
{
|
||||
if (state != BOLD)
|
||||
{
|
||||
|
@ -807,7 +835,7 @@ void GSRTFbold(void *ctxt, BOOL state)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFunderline(void *ctxt, BOOL state)
|
||||
void GSRTFunderline (void *ctxt, BOOL state)
|
||||
{
|
||||
if (state != UNDERLINE)
|
||||
{
|
||||
|
@ -816,7 +844,7 @@ void GSRTFunderline(void *ctxt, BOOL state)
|
|||
}
|
||||
}
|
||||
|
||||
void GSRTFparagraph(void *ctxt)
|
||||
void GSRTFparagraph (void *ctxt)
|
||||
{
|
||||
GSRTFmangleText(ctxt, "\n");
|
||||
CTXT->tabChanged = NO;
|
||||
|
|
Loading…
Reference in a new issue