diff options
39 files changed, 412 insertions, 401 deletions
| diff --git a/cocoa/InfoBar.h b/cocoa/InfoBar.h index efde17944..1ce139530 100644 --- a/cocoa/InfoBar.h +++ b/cocoa/InfoBar.h @@ -28,15 +28,15 @@  @private    NSImage* mBackground;    IBDisplay mDisplayMask; -   +    float mScaleFactor;    NSPopUpButton* mZoomPopup; -   +    int mCurrentCaretX;    int mCurrentCaretY;    NSTextField* mCaretPositionLabel;    NSTextField* mStatusTextLabel; -   +    id <InfoBarCommunicator> mCallback;  } diff --git a/cocoa/InfoBar.mm b/cocoa/InfoBar.mm index 45093911d..a4bc52731 100644 --- a/cocoa/InfoBar.mm +++ b/cocoa/InfoBar.mm @@ -22,7 +22,7 @@  {  	// Get the parent's idea of where we should draw  	NSRect newRect = [super drawingRectForBounds: theRect]; -   +  	// When the text field is being edited or selected, we have to turn off the magic because it    // screws up the configuration of the field editor. We sneak around this by intercepting    // selectWithFrame and editWithFrame and sneaking a reduced, centered rect in at the last minute. @@ -30,26 +30,26 @@  	{  		// Get our ideal size for current text  		NSSize textSize = [self cellSizeForBounds: theRect]; -     +  		// Center that in the proposed rect -		float heightDelta = newRect.size.height - textSize.height;	 +		float heightDelta = newRect.size.height - textSize.height;  		if (heightDelta > 0)  		{  			newRect.size.height -= heightDelta;  			newRect.origin.y += ceil(heightDelta / 2);  		}  	} -	 +  	return newRect;  }  //-------------------------------------------------------------------------------------------------- -- (void) selectWithFrame: (NSRect) aRect inView: (NSView*) controlView editor: (NSText*) textObj  +- (void) selectWithFrame: (NSRect) aRect inView: (NSView*) controlView editor: (NSText*) textObj                  delegate:(id) anObject start: (NSInteger) selStart length: (NSInteger) selLength  {  	aRect = [self drawingRectForBounds: aRect]; -	mIsEditingOrSelecting = YES;	 +	mIsEditingOrSelecting = YES;  	[super selectWithFrame: aRect                    inView: controlView                    editor: textObj @@ -63,7 +63,7 @@  - (void) editWithFrame: (NSRect) aRect inView: (NSView*) controlView editor: (NSText*) textObj                delegate: (id) anObject event: (NSEvent*) theEvent -{	 +{  	aRect = [self drawingRectForBounds: aRect];  	mIsEditingOrSelecting = YES;  	[super editWithFrame: aRect @@ -86,7 +86,7 @@    if (self)    {      NSBundle* bundle = [NSBundle bundleForClass: [InfoBar class]]; -     +      NSString* path = [bundle pathForResource: @"info_bar_bg" ofType: @"tiff" inDirectory: nil];      mBackground = [[NSImage alloc] initWithContentsOfFile: path];      if (![mBackground isValid]) @@ -152,14 +152,14 @@ static float BarFontSize = 10.0;  {    // 1) The zoom popup.    unsigned numberOfDefaultItems = sizeof(DefaultScaleMenuLabels) / sizeof(NSString *); -   +    // Create the popup button.    mZoomPopup = [[NSPopUpButton allocWithZone:[self zone]] initWithFrame: NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown: NO]; -   +    // No border or background please.    [[mZoomPopup cell] setBordered: NO];    [[mZoomPopup cell] setArrowPosition: NSPopUpArrowAtBottom]; -   +    // Fill it.    for (unsigned count = 0; count < numberOfDefaultItems; count++)    { @@ -169,28 +169,28 @@ static float BarFontSize = 10.0;        [currentItem setRepresentedObject: [NSNumber numberWithFloat: DefaultScaleMenuFactors[count]]];    }    [mZoomPopup selectItemAtIndex: DefaultScaleMenuSelectedItemIndex]; -   +    // Hook it up.    [mZoomPopup setTarget: self];    [mZoomPopup setAction: @selector(zoomItemAction:)]; -   +    // Set a suitable font.    [mZoomPopup setFont: [NSFont menuBarFontOfSize: BarFontSize]]; -   +    // Make sure the popup is big enough to fit the cells.    [mZoomPopup sizeToFit]; -   +    // Don't let it become first responder    [mZoomPopup setRefusesFirstResponder: YES]; -   +    // put it in the scrollview.    [self addSubview: mZoomPopup];    [mZoomPopup release]; -   +    // 2) The caret position label.    Class oldCellClass = [NSTextField cellClass];    [NSTextField setCellClass: [VerticallyCenteredTextFieldCell class]]; -   +    mCaretPositionLabel = [[NSTextField alloc] initWithFrame: NSMakeRect(0.0, 0.0, 50.0, 1.0)];    [mCaretPositionLabel setBezeled: NO];    [mCaretPositionLabel setBordered: NO]; @@ -205,7 +205,7 @@ static float BarFontSize = 10.0;    [self addSubview: mCaretPositionLabel];    [mCaretPositionLabel release]; -   +    // 3) The status text.    mStatusTextLabel = [[NSTextField alloc] initWithFrame: NSMakeRect(0.0, 0.0, 1.0, 1.0)];    [mStatusTextLabel setBezeled: NO]; @@ -220,7 +220,7 @@ static float BarFontSize = 10.0;    [self addSubview: mStatusTextLabel];    [mStatusTextLabel release]; -   +    // Restore original cell class so that everything else doesn't get broken    [NSTextField setCellClass: oldCellClass];  } @@ -248,12 +248,12 @@ static float BarFontSize = 10.0;      [mBackground drawAtPoint: target fromRect: NSZeroRect operation: NSCompositeCopy fraction: 1];      target.x += mBackground.size.width;    } -   +    // Draw separator lines between items.    NSRect verticalLineRect;    float component = 190.0 / 255.0;    NSColor* lineColor = [NSColor colorWithDeviceRed: component green: component blue: component alpha: 1]; -   +    if (mDisplayMask & IBShowZoom)    {      verticalLineRect = [mZoomPopup frame]; @@ -265,7 +265,7 @@ static float BarFontSize = 10.0;        NSRectFill(verticalLineRect);      }    } -   +    if (mDisplayMask & IBShowCaretPosition)    {      verticalLineRect = [mCaretPositionLabel frame]; @@ -347,7 +347,7 @@ static float BarFontSize = 10.0;      mDisplayMask = display;      [self positionSubViews];      [self needsDisplay]; -  }   +  }  }  //-------------------------------------------------------------------------------------------------- @@ -358,7 +358,7 @@ static float BarFontSize = 10.0;  - (void) zoomItemAction: (id) sender  {    NSNumber* selectedFactorObject = [[sender selectedCell] representedObject]; -   +    if (selectedFactorObject == nil)    {      NSLog(@"Scale popup action: setting arbitrary zoom factors is not yet supported."); @@ -369,9 +369,9 @@ static float BarFontSize = 10.0;      [self setScaleFactor: [selectedFactorObject floatValue] adjustPopup: NO];    }  } -     +  //-------------------------------------------------------------------------------------------------- -     +  - (void) setScaleFactor: (float) newScaleFactor adjustPopup: (BOOL) flag  {    if (mScaleFactor != newScaleFactor) @@ -381,7 +381,7 @@ static float BarFontSize = 10.0;      {        unsigned count = 0;        unsigned numberOfDefaultItems = sizeof(DefaultScaleMenuFactors) / sizeof(float); -       +        // We only work with some preset zoom values. If the given value does not correspond        // to one then show no selection.        while (count < numberOfDefaultItems && (fabs(newScaleFactor - DefaultScaleMenuFactors[count]) > 0.07)) @@ -391,7 +391,7 @@ static float BarFontSize = 10.0;        else        {          [mZoomPopup selectItemAtIndex: count]; -         +          // Set scale factor to found preset value if it comes close.          mScaleFactor = DefaultScaleMenuFactors[count];        } @@ -400,7 +400,7 @@ static float BarFontSize = 10.0;      {        // Internally set. Notify owner.        [mCallback notify: IBNZoomChanged message: nil location: NSZeroPoint value: newScaleFactor]; -    }     +    }    }  } @@ -414,12 +414,12 @@ static float BarFontSize = 10.0;    // Make the position one-based.    int newX = (int) position.x + 1;    int newY = (int) position.y + 1; -   +    if (mCurrentCaretX != newX || mCurrentCaretY != newY)    {      mCurrentCaretX = newX;      mCurrentCaretY = newY; -     +      [mCaretPositionLabel setStringValue: [NSString stringWithFormat: @"%d:%d", newX, newY]];    }  } @@ -435,13 +435,13 @@ static float BarFontSize = 10.0;    frame.size.width = 0;    if (mDisplayMask & IBShowZoom)      frame.size.width += [mZoomPopup frame].size.width; -   +    if (mDisplayMask & IBShowCaretPosition)      frame.size.width += [mCaretPositionLabel frame].size.width; -   +    if (mDisplayMask & IBShowStatusText)      frame.size.width += [mStatusTextLabel frame].size.width; -   +    [self setFrame: frame];  } diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index 58017706d..06b7a1f5b 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -50,7 +50,7 @@ private:    QuartzTextLayout*	textLayout;    int codePage;    int verticalDeviceResolution; -	 +    /** If the surface is a bitmap context, contains a reference to the bitmap data. */    uint8_t* bitmapData;    /** If the surface is a bitmap context, stores the dimensions of the bitmap. */ @@ -98,7 +98,7 @@ public:    void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource);    void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore,                       ColourDesired back); -  void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore,  +  void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore,                        ColourDesired back);    void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore);    void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); @@ -117,7 +117,7 @@ public:    void SetUnicodeMode(bool unicodeMode_);    void SetDBCSMode(int codePage_);  }; // SurfaceImpl class -   +  } // Scintilla namespace  #endif diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 6bd5d676d..3d3417b82 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -178,7 +178,7 @@ void SurfaceImpl::Release()    }    bitmapData = NULL;    gc = NULL; -   +    bitmapWidth = 0;    bitmapHeight = 0;    x = 0; @@ -202,7 +202,7 @@ void SurfaceImpl::Init(WindowID)    // XXX Docs on QDBeginCGContext are light, a better way to do this would be good.    // AFAIK we should not hold onto a context retrieved this way, thus the need for    // acquire/release of the context. -   +    Release();  } @@ -221,19 +221,19 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID)  void SurfaceImpl::InitPixMap(int width, int height, Surface* /* surface_ */, WindowID /* wid */)  {    Release(); -   +    // Create a new bitmap context, along with the RAM for the bitmap itself    bitmapWidth = width;    bitmapHeight = height; -   +    const int bitmapBytesPerRow = (width * BYTES_PER_PIXEL);    const int bitmapByteCount = (bitmapBytesPerRow * height); -   +    // Create an RGB color space.    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();    if (colorSpace == NULL)      return; -   +    // Create the bitmap.    bitmapData = new uint8_t[bitmapByteCount];    // create the context @@ -244,7 +244,7 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface* /* surface_ */, Win                               bitmapBytesPerRow,                               colorSpace,                               kCGImageAlphaPremultipliedLast); -     +    if (gc == NULL)    {      // the context couldn't be created for some reason, @@ -253,10 +253,10 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface* /* surface_ */, Win      bitmapData = NULL;    }    textLayout->setContext (gc); -   +    // the context retains the color space, so we can release it    CGColorSpaceRelease(colorSpace); -   +    if (gc != NULL && bitmapData != NULL)    {      // "Erase" to white. @@ -273,9 +273,9 @@ void SurfaceImpl::PenColour(ColourDesired fore)    if (gc)    {      ColourDesired colour(fore.AsLong()); -     +      // Set the Stroke color to match -    CGContextSetRGBStrokeColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0,  +    CGContextSetRGBStrokeColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0,                                 colour.GetBlue() / 255.0, 1.0 );    }  } @@ -287,9 +287,9 @@ void SurfaceImpl::FillColour(const ColourDesired& back)    if (gc)    {      ColourDesired colour(back.AsLong()); -     +      // Set the Fill color to match -    CGContextSetRGBFillColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0,  +    CGContextSetRGBFillColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0,                               colour.GetBlue() / 255.0, 1.0 );    }  } @@ -301,17 +301,17 @@ CGImageRef SurfaceImpl::GetImage()    // For now, assume that GetImage can only be called on PixMap surfaces.    if (bitmapData == NULL)      return NULL; -   +    CGContextFlush(gc); -   +    // Create an RGB color space.    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();    if( colorSpace == NULL )      return NULL; -   +    const int bitmapBytesPerRow = ((int) bitmapWidth * BYTES_PER_PIXEL);    const int bitmapByteCount = (bitmapBytesPerRow * (int) bitmapHeight); -   +    // Make a copy of the bitmap data for the image creation and divorce it    // From the SurfaceImpl lifetime    CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, bitmapData, bitmapByteCount); @@ -335,18 +335,18 @@ CGImageRef SurfaceImpl::GetImage()                            0,                            kCGRenderingIntentDefault);    } -   +    // The image retains the color space, so we can release it.    CGColorSpaceRelease(colorSpace);    colorSpace = NULL; -   +    // Done with the data provider.    CGDataProviderRelease(dataProvider);    dataProvider = NULL; -   +    // Done with the data provider.    CFRelease(dataRef); -     +    return image;  } @@ -386,7 +386,7 @@ void SurfaceImpl::MoveTo(int x_, int y_)  void SurfaceImpl::LineTo(int x_, int y_)  {    CGContextBeginPath( gc ); -   +    // Because Quartz is based on floating point, lines are drawn with half their colour    // on each side of the line. Integer coordinates specify the INTERSECTION of the pixel    // division lines. If you specify exact pixel values, you get a line that @@ -406,23 +406,23 @@ void SurfaceImpl::Polygon(Scintilla::Point *pts, int npts, ColourDesired fore,  {    // Allocate memory for the array of points.    std::vector<CGPoint> points(npts); -   +    for (int i = 0;i < npts;i++)    {      // Quartz floating point issues: plot the MIDDLE of the pixels      points[i].x = pts[i].x + 0.5;      points[i].y = pts[i].y + 0.5;    } -   +    CGContextBeginPath(gc); -   +    // Set colours    FillColour(back);    PenColour(fore); -   +    // Draw the polygon    CGContextAddLines(gc, points.data(), npts); -   +    // Explicitly close the path, so it is closed for stroking AND filling (implicit close = filling only)    CGContextClosePath( gc );    CGContextDrawPath( gc, kCGPathFillStroke ); @@ -437,7 +437,7 @@ void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired      CGContextBeginPath( gc );      FillColour(back);      PenColour(fore); -     +      // Quartz integer -> float point conversion fun (see comment in SurfaceImpl::LineTo)      // We subtract 1 from the Width() and Height() so that all our drawing is within the area defined      // by the PRectangle. Otherwise, we draw one pixel too far to the right and bottom. @@ -480,7 +480,7 @@ void releaseImageRefCallback(CGImageRef pattern)  void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern)  {    SurfaceImpl& patternSurface = static_cast<SurfaceImpl &>(surfacePattern); -   +    // For now, assume that copy can only be called on PixMap surfaces. Shows up black.    CGImageRef image = patternSurface.GetImage();    if (image == NULL) @@ -488,11 +488,11 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern)      FillRectangle(rc, ColourDesired(0));      return;    } -   +    const CGPatternCallbacks drawImageCallbacks = { 0,      reinterpret_cast<CGPatternDrawPatternCallback>(drawImageRefCallback),      reinterpret_cast<CGPatternReleaseInfoCallback>(releaseImageRefCallback) }; -   +    CGPatternRef pattern = CGPatternCreate(image,                                           CGRectMake(0, 0, patternSurface.bitmapWidth, patternSurface.bitmapHeight),                                           CGAffineTransformIdentity, @@ -507,10 +507,10 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern)      // Create a pattern color space      CGColorSpaceRef colorSpace = CGColorSpaceCreatePattern( NULL );      if( colorSpace != NULL ) { -       +        CGContextSaveGState( gc );        CGContextSetFillColorSpace( gc, colorSpace ); -       +        // Unlike the documentation, you MUST pass in a "components" parameter:        // For coloured patterns it is the alpha value.        const CGFloat alpha = 1.0; @@ -533,12 +533,12 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi    // which is a rectangle with rounded corners each having a radius of 4 pixels.    // It would be almost as good just cutting off the corners with lines at    // 45 degrees as is done on GTK+. -   +    // Create a rectangle with semicircles at the corners    const int MAX_RADIUS = 4;    int radius = Platform::Minimum( MAX_RADIUS, rc.Height()/2 );    radius = Platform::Minimum( radius, rc.Width()/2 ); -   +    // Points go clockwise, starting from just below the top left    // Corners are kept together, so we can easily create arcs to connect them    CGPoint corners[4][3] = @@ -564,7 +564,7 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi        { rc.left, rc.bottom - radius - 1 },      },    }; -   +    // Align the points in the middle of the pixels    for( int i = 0; i < 4; ++ i )    { @@ -574,20 +574,20 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi        corners[i][j].y += 0.5;      }    } -   +    PenColour( fore );    FillColour( back ); -   +    // Move to the last point to begin the path    CGContextBeginPath( gc );    CGContextMoveToPoint( gc, corners[3][2].x, corners[3][2].y ); -   +    for ( int i = 0; i < 4; ++ i )    {      CGContextAddLineToPoint( gc, corners[i][0].x, corners[i][0].y );      CGContextAddArcToPoint( gc, corners[i][1].x, corners[i][1].y, corners[i][2].x, corners[i][2].y, radius );    } -   +    // Close the path to enclose it for stroking and for filling, then draw it    CGContextClosePath( gc );    CGContextDrawPath( gc, kCGPathFillStroke ); @@ -616,7 +616,7 @@ static void DrawChamferedRectangle(CGContextRef gc, PRectangle rc, int cornerSiz        { rc.left, rc.bottom - cornerSize - 1 },      },    }; -   +    // Align the points in the middle of the pixels    for( int i = 0; i < 4; ++ i )    { @@ -630,13 +630,13 @@ static void DrawChamferedRectangle(CGContextRef gc, PRectangle rc, int cornerSiz    // Move to the last point to begin the path    CGContextBeginPath( gc );    CGContextMoveToPoint( gc, corners[3][1].x, corners[3][1].y ); -   +    for ( int i = 0; i < 4; ++ i )    {      CGContextAddLineToPoint( gc, corners[i][0].x, corners[i][0].y );      CGContextAddLineToPoint( gc, corners[i][1].x, corners[i][1].y );    } -   +    // Close the path to enclose it for stroking and for filling, then draw it    CGContextClosePath( gc );    CGContextDrawPath( gc, mode ); @@ -704,25 +704,25 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char  	if (colorSpace) {  		const int bitmapBytesPerRow = ((int) width * 4);  		const int bitmapByteCount = (bitmapBytesPerRow * (int) height); -		 +  		// Create a data provider.  		CGDataProviderRef dataProvider = 0;  		if (invert) {  			unsigned char *pixelsUpsideDown = new unsigned char[bitmapByteCount]; -		 +  			for (int y=0; y<height; y++) {  				int yInverse = height - y - 1;  				memcpy(pixelsUpsideDown + y * bitmapBytesPerRow,  				       pixelsImage + yInverse * bitmapBytesPerRow,  				       bitmapBytesPerRow);  			} -			 +  			dataProvider = CGDataProviderCreateWithData(  								NULL, pixelsUpsideDown, bitmapByteCount, ProviderReleaseData);  		} else {  			dataProvider = CGDataProviderCreateWithData(  								NULL, pixelsImage, bitmapByteCount, NULL); -			 +  		}  		if (dataProvider) {  			// Create the CGImage. @@ -740,7 +740,7 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char  			CGDataProviderRelease(dataProvider);  		} -		 +  		// The image retains the color space, so we can release it.  		CGColorSpaceRelease(colorSpace);  	} @@ -761,13 +761,13 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)    // http://www.codeguru.com/gdi/ellipse.shtml    // MAGICAL CONSTANT to map ellipse to beziers 2/3*(sqrt(2)-1)    const double EToBConst = 0.2761423749154; -   +    CGSize offset = CGSizeMake((int)(rc.Width() * EToBConst), (int)(rc.Height() * EToBConst));    CGPoint centre = CGPointMake((rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2); -   +    // The control point array    CGPoint cCtlPt[13]; -   +    // Assign values to all the control points    cCtlPt[0].x  =    cCtlPt[1].x  = @@ -782,7 +782,7 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)    cCtlPt[8].x  = centre.x + offset.width + 0.5;    cCtlPt[3].x  =    cCtlPt[9].x  = centre.x + 0.5; -   +    cCtlPt[2].y  =    cCtlPt[3].y  =    cCtlPt[4].y  = rc.top + 0.5; @@ -796,18 +796,18 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)    cCtlPt[0].y =    cCtlPt[12].y =    cCtlPt[6].y  = centre.y + 0.5; -   +    FillColour(back);    PenColour(fore); -   +    CGContextBeginPath( gc );    CGContextMoveToPoint( gc, cCtlPt[0].x, cCtlPt[0].y ); -   +    for ( int i = 1; i < 13; i += 3 )    {      CGContextAddCurveToPoint( gc, cCtlPt[i].x, cCtlPt[i].y, cCtlPt[i+1].x, cCtlPt[i+1].y, cCtlPt[i+2].x, cCtlPt[i+2].y );    } -   +    // Close the path to enclose it for stroking and for filling, then draw it    CGContextClosePath( gc );    CGContextDrawPath( gc, kCGPathFillStroke ); @@ -817,10 +817,10 @@ void SurfaceImpl::CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect,  {    SurfaceImpl& source = static_cast<SurfaceImpl &>(surfaceSource);    CGImageRef image = source.GetImage(); -   +    CGRect src = PRectangleToCGRect(srcRect);    CGRect dst = PRectangleToCGRect(dstRect); -   +    /* source from QuickDrawToQuartz2D.pdf on developer.apple.com */    float w = (float) CGImageGetWidth(image);    float h = (float) CGImageGetHeight(image); @@ -844,10 +844,10 @@ void SurfaceImpl::Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSou    // Maybe we have to make the Surface two contexts:    // a bitmap context which we do all the drawing on, and then a "real" context    // which we copy the output to when we call "Synchronize". Ugh! Gross and slow! -   +    // For now, assume that copy can only be called on PixMap surfaces    SurfaceImpl& source = static_cast<SurfaceImpl &>(surfaceSource); -   +    // Get the CGImageRef    CGImageRef image = source.GetImage();    // If we could not get an image reference, fill the rectangle black @@ -856,19 +856,19 @@ void SurfaceImpl::Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSou      FillRectangle( rc, ColourDesired( 0 ) );      return;    } -   +    // Now draw the image on the surface -   +    // Some fancy clipping work is required here: draw only inside of rc    CGContextSaveGState( gc );    CGContextClipToRect( gc, PRectangleToCGRect( rc ) ); -   +    //Platform::DebugPrintf(stderr, "Copy: CGContextDrawImage: (%d, %d) - (%d X %d)\n", rc.left - from.x, rc.top - from.y, source.bitmapWidth, source.bitmapHeight );    CGContextDrawImage( gc, CGRectMake( rc.left - from.x, rc.top - from.y, source.bitmapWidth, source.bitmapHeight ), image ); -   +    // Undo the clipping fun    CGContextRestoreGState( gc ); -   +    // Done with the image    CGImageRelease( image );    image = NULL; @@ -953,7 +953,7 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet)    }  } -void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,  +void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,                                        ColourDesired fore)  {  	CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); @@ -962,7 +962,7 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION yba  	QuartzTextStyle* style = reinterpret_cast<QuartzTextStyle*>(font_.GetID());  	style->setCTStyleColor(color); -	 +  	CGColorRelease(color);  	textLayout->setText (reinterpret_cast<const UInt8*>(s), len, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); @@ -987,10 +987,10 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION  {  	CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_));  	textLayout->setText (reinterpret_cast<const UInt8*>(s), len, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); -	 +  	CTLineRef mLine = textLayout->getCTLine();  	assert(mLine != NULL); -	 +  	if (unicodeMode) {  		// Map the widths given for UTF-16 characters back onto the UTF-8 input string  		CFIndex fit = textLayout->getStringLength(); @@ -1036,7 +1036,7 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) {    {      CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_));      textLayout->setText (reinterpret_cast<const UInt8*>(s), len, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); -     +  	return textLayout->MeasureStringWidth();    }    return 1; @@ -1048,7 +1048,7 @@ XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) {    {      CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_));      textLayout->setText (reinterpret_cast<const UInt8*>(str), 1, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); -     +      return textLayout->MeasureStringWidth();    }    else @@ -1062,7 +1062,7 @@ const char sizeString[] = "`~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890"  XYPOSITION SurfaceImpl::Ascent(Font &font_) {    if (!font_.GetID())      return 1; -   +  	float ascent = reinterpret_cast<QuartzTextStyle*>( font_.GetID() )->getAscent();  	return ascent + 0.5; @@ -1071,7 +1071,7 @@ XYPOSITION SurfaceImpl::Ascent(Font &font_) {  XYPOSITION SurfaceImpl::Descent(Font &font_) {    if (!font_.GetID())      return 1; -   +  	float descent = reinterpret_cast<QuartzTextStyle*>( font_.GetID() )->getDescent();  	return descent + 0.5; @@ -1084,7 +1084,7 @@ XYPOSITION SurfaceImpl::InternalLeading(Font &) {  XYPOSITION SurfaceImpl::ExternalLeading(Font &font_) {    if (!font_.GetID())      return 1; -   +  	float leading = reinterpret_cast<QuartzTextStyle*>( font_.GetID() )->getLeading();  	return leading + 0.5; @@ -1097,13 +1097,13 @@ XYPOSITION SurfaceImpl::Height(Font &font_) {  }  XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) { -   +    if (!font_.GetID())      return 1; -   +    const int sizeStringLength = (sizeof( sizeString ) / sizeof( sizeString[0] ) - 1);    int width = WidthText( font_, sizeString, sizeStringLength  ); -   +    return (int) ((width / (float) sizeStringLength) + 0.5);  } @@ -1578,7 +1578,7 @@ private:    NSTableColumn* colIcon;    NSTableColumn* colText;    AutoCompletionDataSource* ds; -	 +    LinesData ld;    CallBackAction doubleClickAction;    void* doubleClickActionData; @@ -2009,7 +2009,7 @@ void Menu::Show(Point, Window &)  ElapsedTime::ElapsedTime() {    struct timeval curTime;    gettimeofday( &curTime, NULL ); -   +    bigBit = curTime.tv_sec;    littleBit = curTime.tv_usec;  } @@ -2075,7 +2075,7 @@ int Platform::DefaultFontSize()   */  unsigned int Platform::DoubleClickTime()  { -  float threshold = [[NSUserDefaults standardUserDefaults] floatForKey:  +  float threshold = [[NSUserDefaults standardUserDefaults] floatForKey:                       @"com.apple.mouse.doubleClickThreshold"];    if (threshold == 0)      threshold = 0.5; @@ -2094,7 +2094,7 @@ bool Platform::MouseButtonBounce()  /**   * Helper method for the backend to reach through to the scintilla window.   */ -long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam)  +long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam)  {    return scintilla_send_message(w, msg, wParam, lParam);  } @@ -2121,7 +2121,7 @@ bool Platform::IsDBCSLeadByte(int codePage, char ch)      // Shift_jis      return ((uch >= 0x81) && (uch <= 0x9F)) ||          ((uch >= 0xE0) && (uch <= 0xFC)); -        // Lead bytes F0 to FC may be a Microsoft addition.  +        // Lead bytes F0 to FC may be a Microsoft addition.    case 936:      // GBK      return (uch >= 0x81) && (uch <= 0xFE); @@ -2185,7 +2185,7 @@ void Platform::DebugPrintf(const char *format, ...)  {    const int BUF_SIZE = 2000;    char buffer[BUF_SIZE]; -   +    va_list pArguments;    va_start(pArguments, format);    vsnprintf(buffer, BUF_SIZE, format, pArguments); @@ -2220,7 +2220,7 @@ void Platform::Assert(const char *c, const char *file, int line)    sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);    strcat(buffer, "\r\n");    Platform::DebugDisplay(buffer); -#ifdef DEBUG  +#ifdef DEBUG    // Jump into debugger in assert on Mac (CL269835)    ::Debugger();  #endif @@ -2241,7 +2241,7 @@ int Platform::Clamp(int val, int minVal, int maxVal)  /**   * Implements the platform specific part of library loading. - *  + *   * @param modulePath The path to the module to load.   * @return A library instance or NULL if the module could not be found or another problem occurred.   */ diff --git a/cocoa/QuartzTextLayout.h b/cocoa/QuartzTextLayout.h index c789ed10f..edf357682 100644 --- a/cocoa/QuartzTextLayout.h +++ b/cocoa/QuartzTextLayout.h @@ -39,7 +39,7 @@ public:  		{  			CFRelease(mLine);  			mLine = NULL; -		}	 +		}      }      inline void setText( const UInt8* buffer, size_t byteLength, CFStringEncoding encoding, const QuartzTextStyle& r ) @@ -47,19 +47,19 @@ public:  		CFStringRef str = CFStringCreateWithBytes( NULL, buffer, byteLength, encoding, false );          if (!str)              return; -		 +  	        stringLength = CFStringGetLength(str);  		CFMutableDictionaryRef stringAttribs = r.getCTStyle(); -		 +  		if (mString != NULL)  			CFRelease(mString);  		mString = ::CFAttributedStringCreate(NULL, str, stringAttribs); -		 +  		if (mLine != NULL)  			CFRelease(mLine);  		mLine = ::CTLineCreateWithAttributedString(mString); -		 +  		CFRelease( str );      } @@ -70,28 +70,28 @@ public:      {  		if (mLine == NULL)  			return; -		 +  		::CGContextSetTextMatrix(gc, CGAffineTransformMakeScale(1.0, -1.0)); -		 +  		// Set the text drawing position.  		::CGContextSetTextPosition(gc, x, y); -		 +  		// And finally, draw!  		::CTLineDraw(mLine, gc);      } -	 +  	float MeasureStringWidth() -	{		 +	{  		if (mLine == NULL)  			return 0.0f; -		 +  		return ::CTLineGetTypographicBounds(mLine, NULL, NULL, NULL);  	} -	 +      CTLineRef getCTLine() {          return mLine;      } -	 +      CFIndex getStringLength() {  	    return stringLength;      } diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 358019b46..9098d2000 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -85,7 +85,7 @@ class ScintillaCocoa : public ScintillaBase  private:    TimerTarget* timerTarget;    NSEvent* lastMouseEvent; -   +    id<ScintillaNotificationProtocol> delegate;    SciNotifyFunc	notifyProc; @@ -101,13 +101,13 @@ private:    bool GetPasteboardData(NSPasteboard* board, SelectionText* selectedText);    void SetPasteboardData(NSPasteboard* board, const SelectionText& selectedText); -   +    int scrollSpeed;    int scrollTicks;    NSTimer* tickTimer;    NSTimer* idleTimer;    CFRunLoopObserverRef observer; -	 +    FindHighlightLayer *layerFindIndicator;  protected: @@ -116,7 +116,7 @@ protected:    Point ConvertPoint(NSPoint point);    virtual void RedrawRect(PRectangle rc);    virtual void Redraw(); -   +    virtual void Initialise();    virtual void Finalise();    virtual CaseFolder *CaseFolderForEncoding(); @@ -173,7 +173,7 @@ public:    virtual void ClaimSelection();    NSPoint GetCaretPosition(); -   +    static sptr_t DirectFunction(ScintillaCocoa *sciThis, unsigned int iMessage, uptr_t wParam, sptr_t lParam);    void TimerFired(NSTimer* timer); @@ -203,14 +203,14 @@ public:    void DraggingExited(id <NSDraggingInfo> info);    bool PerformDragOperation(id <NSDraggingInfo> info);    void DragScroll(); -   +    // Promote some methods needed for NSResponder actions.    virtual void SelectAll();    void DeleteBackward();    virtual void Cut();    virtual void Undo();    virtual void Redo(); -   +    virtual NSMenu* CreateContextMenu(NSEvent* event);    void HandleCommand(NSInteger command); diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 53403e698..aaaf63c16 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -2,7 +2,7 @@  /**   * Scintilla source code edit control   * ScintillaCocoa.mm - Cocoa subclass of ScintillaBase - *  + *   * Written by Mike Lischke <mlischke@sun.com>   *   * Loosely based on ScintillaMacOSX.cxx. @@ -195,7 +195,7 @@ static const KeyToCommand macMapDefault[] =  		self.anchorPoint = CGPointMake(0.5, 0.5);  	}  	return self; -	 +  }  const CGFloat paddingHighlightX = 4; @@ -204,23 +204,23 @@ const CGFloat paddingHighlightY = 2;  -(void) drawInContext:(CGContextRef)context {  	if (!sFind || !sFont)  		return; -	 +  	CFStringRef str = CFStringRef(sFind); -	 +  	CFMutableDictionaryRef styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, -								     &kCFTypeDictionaryKeyCallBacks,  +								     &kCFTypeDictionaryKeyCallBacks,  								     &kCFTypeDictionaryValueCallBacks);  	CGColorRef color = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0);  	CFDictionarySetValue(styleDict, kCTForegroundColorAttributeName, color);  	CTFontRef fontRef = ::CTFontCreateWithName((CFStringRef)sFont, fontSize, NULL);  	CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef); -	 +  	CFAttributedStringRef attrString = ::CFAttributedStringCreate(NULL, str, styleDict);  	CTLineRef textLine = ::CTLineCreateWithAttributedString(attrString);  	// Indent from corner of bounds  	CGContextSetTextPosition(context, paddingHighlightX, 3 + paddingHighlightY);  	CTLineDraw(textLine, context); -	 +  	CFRelease(textLine);  	CFRelease(attrString);  	CFRelease(fontRef); @@ -258,7 +258,7 @@ const CGFloat paddingHighlightY = 2;  	}  	[self setNeedsDisplay];  	[CATransaction commit]; -	 +  	if (bounce) {  		CABasicAnimation *animBounce = [CABasicAnimation animationWithKeyPath:@"transform.scale"];  		animBounce.duration = 0.15; @@ -266,26 +266,26 @@ const CGFloat paddingHighlightY = 2;  		animBounce.removedOnCompletion = NO;  		animBounce.fromValue = [NSNumber numberWithFloat: 1.0];  		animBounce.toValue = [NSNumber numberWithFloat: 1.25]; -		 +  		if (self.retaining) { -			 +  			[self addAnimation: animBounce forKey:@"animateFound"]; -			 +  		} else { -			 +  			CABasicAnimation *animFade = [CABasicAnimation animationWithKeyPath:@"opacity"];  			animFade.duration = 0.1;  			animFade.beginTime = 0.4;  			animFade.removedOnCompletion = NO;  			animFade.fromValue = [NSNumber numberWithFloat: 1.0];  			animFade.toValue = [NSNumber numberWithFloat: 0.0]; -			 +  			CAAnimationGroup *group = [CAAnimationGroup animation];  			[group setDuration:0.5];  			group.removedOnCompletion = NO;  			group.fillMode = kCAFillModeForwards;  			[group setAnimations:[NSArray arrayWithObjects:animBounce, animFade, nil]]; -			 +  			[self addAnimation:group forKey:@"animateFound"];  		}  	} @@ -314,9 +314,9 @@ const CGFloat paddingHighlightY = 2;      // Get the default notification queue for the thread which created the instance (usually the      // main thread). We need that later for idle event processing. -    NSNotificationCenter* center = [NSNotificationCenter defaultCenter];  +    NSNotificationCenter* center = [NSNotificationCenter defaultCenter];      notificationQueue = [[NSNotificationQueue alloc] initWithNotificationCenter: center]; -    [center addObserver: self selector: @selector(idleTriggered:) name: @"Idle" object: nil];  +    [center addObserver: self selector: @selector(idleTriggered:) name: @"Idle" object: nil];    }    return self;  } @@ -354,11 +354,11 @@ const CGFloat paddingHighlightY = 2;    // Post a new idle notification, which gets executed when the run loop is idle.    // Since we are coalescing on name and sender there will always be only one actual notification    // even for multiple requests. -  NSNotification *notification = [NSNotification notificationWithName: @"Idle" object: self];  +  NSNotification *notification = [NSNotification notificationWithName: @"Idle" object: self];    [notificationQueue enqueueNotification: notification                              postingStyle: NSPostWhenIdle                              coalesceMask: (NSNotificationCoalescingOnName | NSNotificationCoalescingOnSender) -                                forModes: nil];  +                                forModes: nil];  }  //-------------------------------------------------------------------------------------------------- @@ -411,20 +411,20 @@ ScintillaCocoa::~ScintillaCocoa()  /**   * Core initialization of the control. Everything that needs to be set up happens here.   */ -void ScintillaCocoa::Initialise()  +void ScintillaCocoa::Initialise()  {    Scintilla_LinkLexers(); -   +    // Tell Scintilla not to buffer: Quartz buffers drawing for us.    WndProc(SCI_SETBUFFEREDDRAW, 0, 0); -   +    // We are working with Unicode exclusively.    WndProc(SCI_SETCODEPAGE, SC_CP_UTF8, 0);    // Add Mac specific key bindings. -  for (int i = 0; macMapDefault[i].key; i++)  +  for (int i = 0; macMapDefault[i].key; i++)      kmap.AssignCmdKey(macMapDefault[i].key, macMapDefault[i].modifiers, macMapDefault[i].msg); -   +  }  //-------------------------------------------------------------------------------------------------- @@ -507,7 +507,7 @@ static char *EncodedBytes(CFStringRef cfsRef, CFStringEncoding encoding) {      CFIndex usedLen = 0;      CFStringGetBytes(cfsRef, rangeAll, encoding, '?',                       false, NULL, 0, &usedLen); -     +      char *buffer = new char[usedLen+1];      CFStringGetBytes(cfsRef, rangeAll, encoding, '?',                       false, (UInt8 *)buffer,usedLen, NULL); @@ -533,12 +533,12 @@ public:  			return 1;  		} else {              CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, -                                                         reinterpret_cast<const UInt8 *>(mixed),  +                                                         reinterpret_cast<const UInt8 *>(mixed),                                                           lenMixed, encoding, false);              NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch                                                                          locale:[NSLocale currentLocale]]; -             +              char *encoded = EncodedBytes((CFStringRef)sMapped, encoding);  			size_t lenMapped = strlen(encoded); @@ -572,20 +572,20 @@ CaseFolder *ScintillaCocoa::CaseFolderForEncoding() {                  char sCharacter[2] = "A";                  sCharacter[0] = i;                  CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, -                                                             reinterpret_cast<const UInt8 *>(sCharacter),  +                                                             reinterpret_cast<const UInt8 *>(sCharacter),                                                               1, encoding, false);                  if (!cfsVal)                          continue; -                 +                  NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch                                                                              locale:[NSLocale currentLocale]]; -                 +                  char *encoded = EncodedBytes((CFStringRef)sMapped, encoding); -                 +                  if (strlen(encoded) == 1) {                      pcf->SetTranslation(sCharacter[0], encoded[0]);                  } -                 +                  delete []encoded;                  CFRelease(cfsVal);              } @@ -607,10 +607,10 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping)  {    if ((s.size() == 0) || (caseMapping == cmSame))      return s; -   +    if (IsUnicodeMode()) {      std::string retMapped(s.length() * maxExpansionCaseConversion, 0); -    size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),  +    size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),        (caseMapping == cmUpper) ? CaseConversionUpper : CaseConversionLower);      retMapped.resize(lenMapped);      return retMapped; @@ -619,7 +619,7 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping)    CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),                                                         vs.styles[STYLE_DEFAULT].characterSet);    CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, -                                               reinterpret_cast<const UInt8 *>(s.c_str()),  +                                               reinterpret_cast<const UInt8 *>(s.c_str()),                                                 s.length(), encoding, false);    NSString *sMapped; @@ -716,7 +716,7 @@ PRectangle ScintillaCocoa::GetClientRectangle()  /**   * Converts the given point from base coordinates to local coordinates and at the same time into   * a native Point structure. Base coordinates are used for the top window used in the view hierarchy. - * Returned value is in view coordinates.  + * Returned value is in view coordinates.   */  Scintilla::Point ScintillaCocoa::ConvertPoint(NSPoint point)  { @@ -757,11 +757,11 @@ void ScintillaCocoa::Redraw()   *   * @param sciThis The target which is to be called.   * @param iMessage A code that indicates which message was sent. - * @param wParam One of the two free parameters for the message. Traditionally a word sized parameter  + * @param wParam One of the two free parameters for the message. Traditionally a word sized parameter   *               (hence the w prefix).   * @param lParam The other of the two free parameters. A signed long.   */ -sptr_t ScintillaCocoa::DirectFunction(ScintillaCocoa *sciThis, unsigned int iMessage, uptr_t wParam,  +sptr_t ScintillaCocoa::DirectFunction(ScintillaCocoa *sciThis, unsigned int iMessage, uptr_t wParam,                                        sptr_t lParam)  {    return sciThis->WndProc(iMessage, wParam, lParam); @@ -796,34 +796,34 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar    {      case SCI_GETDIRECTFUNCTION:        return reinterpret_cast<sptr_t>(DirectFunction); -       +      case SCI_GETDIRECTPOINTER:        return reinterpret_cast<sptr_t>(this); -       +      case SCI_GRABFOCUS:        [[ContentView() window] makeFirstResponder:ContentView()];        break; -       +      case SCI_SETBUFFEREDDRAW:        // Buffered drawing not supported on Cocoa        bufferedDraw = false;        break; -       +      case SCI_FINDINDICATORSHOW:        ShowFindIndicatorForRange(NSMakeRange(wParam, lParam-wParam), YES);        return 0; -       +      case SCI_FINDINDICATORFLASH:        ShowFindIndicatorForRange(NSMakeRange(wParam, lParam-wParam), NO);        return 0; -       +      case SCI_FINDINDICATORHIDE:        HideFindIndicator();        return 0; -       +      default:        sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam); -       +        return r;    }    return 0l; @@ -832,7 +832,7 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar  //--------------------------------------------------------------------------------------------------  /** - * In Windows lingo this is the handler which handles anything that wasn't handled in the normal  + * In Windows lingo this is the handler which handles anything that wasn't handled in the normal   * window proc which would usually send the message back to generic window proc that Windows uses.   */  sptr_t ScintillaCocoa::DefWndProc(unsigned int, uptr_t, sptr_t) @@ -923,7 +923,7 @@ bool ScintillaCocoa::CanPaste()  {    if (!Editor::CanPaste())      return false; -   +    return GetPasteboardData([NSPasteboard generalPasteboard], NULL);  } @@ -945,11 +945,11 @@ void ScintillaCocoa::Paste(bool forceRectangular)    bool ok = GetPasteboardData([NSPasteboard generalPasteboard], &selectedText);    if (forceRectangular)      selectedText.rectangular = forceRectangular; -   +    if (!ok || selectedText.Empty())      // No data or no flavor we support.      return; -   +    pdoc->BeginUndoAction();    ClearSelection(false);    int length = selectedText.Length(); @@ -963,7 +963,7 @@ void ScintillaCocoa::Paste(bool forceRectangular)      InsertPaste(selStart, selectedText.Data(), length);    }    pdoc->EndUndoAction(); -   +    Redraw();    EnsureCaretVisible();  } @@ -997,7 +997,7 @@ void ScintillaCocoa::CTPaint(void* gc, NSRect rc) {  	if (self) {          sci = NULL;  	} -	 +  	return self;  } @@ -1045,7 +1045,7 @@ void ScintillaCocoa::CallTipMouseDown(NSPoint pt) {  void ScintillaCocoa::CreateCallTipWindow(PRectangle rc) {      if (!ct.wCallTip.Created()) {          NSRect ctRect = NSMakeRect(rc.top,rc.bottom, rc.Width(), rc.Height()); -        NSWindow *callTip = [[NSWindow alloc] initWithContentRect: ctRect  +        NSWindow *callTip = [[NSWindow alloc] initWithContentRect: ctRect                                                          styleMask: NSBorderlessWindowMask                                                            backing: NSBackingStoreBuffered                                                              defer: NO]; @@ -1068,7 +1068,7 @@ void ScintillaCocoa::AddToPopUp(const char *label, int cmd, bool enabled)    ScintillaContextMenu *menu= reinterpret_cast<ScintillaContextMenu*>(popup.GetID());    [menu setOwner: this];    [menu setAutoenablesItems: NO]; -   +    if (cmd == 0) {      item = [NSMenuItem separatorItem];    } else { @@ -1079,7 +1079,7 @@ void ScintillaCocoa::AddToPopUp(const char *label, int cmd, bool enabled)    [item setAction: @selector(handleCommand:)];    [item setTag: cmd];    [item setEnabled: enabled]; -   +    [menu addItem: item];  } @@ -1125,7 +1125,7 @@ void ScintillaCocoa::DragScroll()    int line = pdoc->LineFromPosition(posDrag.Position());    int currentVisibleLine = cs.DisplayFromDoc(line);    int lastVisibleLine = Platform::Minimum(topLine + LinesOnScreen(), cs.LinesDisplayed()) - 2; -     +    if (currentVisibleLine <= topLine && topLine > 0)      ScrollTo(topLine - scrollSpeed);    else @@ -1137,9 +1137,9 @@ void ScintillaCocoa::DragScroll()        scrollTicks = 2000;        return;      } -   +    // TODO: also handle horizontal scrolling. -   +    if (scrollSpeed == 1)    {      scrollTicks -= timer.tickSize; @@ -1149,7 +1149,7 @@ void ScintillaCocoa::DragScroll()        scrollTicks = 2000;      }    } -   +  }  //-------------------------------------------------------------------------------------------------- @@ -1169,7 +1169,7 @@ void ScintillaCocoa::StartDrag()    NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName: NSDragPboard];    CopySelectionRange(&selectedText);    SetPasteboardData(pasteboard, selectedText); -   +    // calculate the bounds of the selection    PRectangle client = GetTextRectangle();    int selStart = sel.RangeMain().Start().Position(); @@ -1179,13 +1179,13 @@ void ScintillaCocoa::StartDrag()    Point pt;    long startPos, endPos, ep;    PRectangle rcSel; -   +    if (startLine==endLine && WndProc(SCI_GETWRAPMODE, 0, 0) != SC_WRAP_NONE) {      // Komodo bug http://bugs.activestate.com/show_bug.cgi?id=87571      // Scintilla bug https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3040200&group_id=2439      // If the width on a wrapped-line selection is negative,      // find a better bounding rectangle. -     +      Point ptStart, ptEnd;      startPos = WndProc(SCI_GETLINESELSTARTPOSITION, startLine, 0);      endPos =   WndProc(SCI_GETLINESELENDPOSITION,   startLine, 0); @@ -1239,16 +1239,16 @@ void ScintillaCocoa::StartDrag()    }    // must convert to global coordinates for drag regions, but also save the    // image rectangle for further calculations and copy operations -     +    // Prepare drag image.    NSRect selectionRectangle = PRectangleToNSRect(rcSel); -   +    NSView* content = ContentView(); -     +    // To get a bitmap of the text we're dragging, we just use Paint on a pixmap surface.    SurfaceImpl *sw = new SurfaceImpl();    SurfaceImpl *pixmap = NULL; -   +    bool lastHideSelection = hideSelection;    hideSelection = true;    if (sw) @@ -1260,23 +1260,23 @@ void ScintillaCocoa::StartDrag()        paintState = painting;        sw->InitPixMap(client.Width(), client.Height(), NULL, NULL);        paintingAllText = true; -      // Have to create a new context and make current as text drawing goes  +      // Have to create a new context and make current as text drawing goes        // to the current context, not a passed context. -      CGContextRef gcsw = sw->GetContext();  -      NSGraphicsContext *nsgc = [NSGraphicsContext graphicsContextWithGraphicsPort: gcsw  +      CGContextRef gcsw = sw->GetContext(); +      NSGraphicsContext *nsgc = [NSGraphicsContext graphicsContextWithGraphicsPort: gcsw                                                                             flipped: YES];        [NSGraphicsContext setCurrentContext:nsgc];        CGContextTranslateCTM(gcsw, -client.left, -client.top);        Paint(sw, client);        paintState = notPainting; -       +        pixmap->InitPixMap(imageRect.Width(), imageRect.Height(), NULL, NULL); -       -      CGContextRef gc = pixmap->GetContext();  + +      CGContextRef gc = pixmap->GetContext();        // To make Paint() work on a bitmap, we have to flip our coordinates and translate the origin        CGContextTranslateCTM(gc, 0, imageRect.Height());        CGContextScaleCTM(gc, 1.0, -1.0); -       +        pixmap->CopyImageRectangle(*sw, imageRect, PRectangle(0, 0, imageRect.Width(), imageRect.Height()));        // XXX TODO: overwrite any part of the image that is not part of the        //           selection to make it transparent.  right now we just use @@ -1286,7 +1286,7 @@ void ScintillaCocoa::StartDrag()      delete sw;    }    hideSelection = lastHideSelection; -   +    NSBitmapImageRep* bitmap = NULL;    if (pixmap)    { @@ -1296,20 +1296,20 @@ void ScintillaCocoa::StartDrag()      pixmap->Release();      delete pixmap;    } -   +    NSImage* image = [[[NSImage alloc] initWithSize: selectionRectangle.size] autorelease];    [image addRepresentation: bitmap]; -   +    NSImage* dragImage = [[[NSImage alloc] initWithSize: selectionRectangle.size] autorelease];    [dragImage setBackgroundColor: [NSColor clearColor]];    [dragImage lockFocus];    [image drawAtPoint: NSZeroPoint fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 0.5];    [dragImage unlockFocus]; -   +    NSPoint startPoint;    startPoint.x = selectionRectangle.origin.x + client.left;    startPoint.y = selectionRectangle.origin.y + selectionRectangle.size.height + client.top; -  [content dragImage: dragImage  +  [content dragImage: dragImage                    at: startPoint                offset: NSZeroSize                 event: lastMouseEvent // Set in MouseMove. @@ -1337,22 +1337,22 @@ NSDragOperation ScintillaCocoa::DraggingEntered(id <NSDraggingInfo> info)   */  NSDragOperation ScintillaCocoa::DraggingUpdated(id <NSDraggingInfo> info)  { -  // Convert the drag location from window coordinates to view coordinates and  +  // Convert the drag location from window coordinates to view coordinates and    // from there to a text position to finally set the drag position.    Point location = ConvertPoint([info draggingLocation]);    SetDragPosition(SPositionFromLocation(location)); -   +    NSDragOperation sourceDragMask = [info draggingSourceOperationMask];    if (sourceDragMask == NSDragOperationNone)      return sourceDragMask; -   +    NSPasteboard* pasteboard = [info draggingPasteboard]; -   +    // Return what type of operation we will perform. Prefer move over copy.    if ([[pasteboard types] containsObject: NSStringPboardType] ||        [[pasteboard types] containsObject: ScintillaRecPboardType])      return (sourceDragMask & NSDragOperationMove) ? NSDragOperationMove : NSDragOperationCopy; -   +    if ([[pasteboard types] containsObject: NSFilenamesPboardType])      return (sourceDragMask & NSDragOperationGeneric);    return NSDragOperationNone; @@ -1378,7 +1378,7 @@ void ScintillaCocoa::DraggingExited(id <NSDraggingInfo> info)  bool ScintillaCocoa::PerformDragOperation(id <NSDraggingInfo> info)  {    NSPasteboard* pasteboard = [info draggingPasteboard]; -   +    if ([[pasteboard types] containsObject: NSFilenamesPboardType])    {      NSArray* files = [pasteboard propertyListForType: NSFilenamesPboardType]; @@ -1389,12 +1389,12 @@ bool ScintillaCocoa::PerformDragOperation(id <NSDraggingInfo> info)    {      SelectionText text;      GetPasteboardData(pasteboard, &text); -     +      if (text.Length() > 0)      {        NSDragOperation operation = [info draggingSourceOperationMask];        bool moving = (operation & NSDragOperationMove) != 0; -       +        DropAt(posDrag, text.Data(), text.Length(), moving, text.rectangular);      };    } @@ -1419,13 +1419,13 @@ void ScintillaCocoa::SetPasteboardData(NSPasteboard* board, const SelectionText      [NSArray arrayWithObjects: NSStringPboardType, ScintillaRecPboardType, nil] :      [NSArray arrayWithObjects: NSStringPboardType, nil];    [board declareTypes:pbTypes owner:nil]; -   +    if (selectedText.rectangular)    {      // This is specific to scintilla, allows us to drag rectangular selections around the document.      [board setString: (NSString *)cfsVal forType: ScintillaRecPboardType];    } -   +    [board setString: (NSString *)cfsVal forType: NSStringPboardType];    if (cfsVal) @@ -1439,12 +1439,12 @@ void ScintillaCocoa::SetPasteboardData(NSPasteboard* board, const SelectionText   */  bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selectedText)  { -  NSArray* supportedTypes = [NSArray arrayWithObjects: ScintillaRecPboardType,  -                             NSStringPboardType,  +  NSArray* supportedTypes = [NSArray arrayWithObjects: ScintillaRecPboardType, +                             NSStringPboardType,                               nil];    NSString *bestType = [board availableTypeFromArray: supportedTypes];    NSString* data = [board stringForType: bestType]; -   +    if (data != nil)    {      if (selectedText != nil) @@ -1457,7 +1457,7 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selec                         false, NULL, 0, &usedLen);        std::vector<UInt8> buffer(usedLen); -     +        CFStringGetBytes((CFStringRef)data, rangeAll, encoding, '?',                         false, buffer.data(),usedLen, NULL); @@ -1471,7 +1471,7 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selec      }      return true;    } -   +    return false;  } @@ -1744,7 +1744,7 @@ void ScintillaCocoa::NotifyFocus(bool focus)   * @param scn The notification to send.   */  void ScintillaCocoa::NotifyParent(SCNotification scn) -{  +{    scn.nmhdr.hwndFrom = (void*) this;    scn.nmhdr.idFrom = GetCtrlID();    if (notifyProc != NULL) @@ -1760,7 +1760,7 @@ void ScintillaCocoa::NotifyURIDropped(const char *uri)    SCNotification scn;    scn.nmhdr.code = SCN_URIDROPPED;    scn.text = uri; -   +    NotifyParent(scn);  } @@ -1817,7 +1817,7 @@ bool ScintillaCocoa::Draw(NSRect rect, CGContextRef gc)  }  //-------------------------------------------------------------------------------------------------- -     +  /**   * Helper function to translate OS X key codes to Scintilla key codes.   */ @@ -1863,7 +1863,7 @@ static inline UniChar KeyTranslate(UniChar unicodeChar)  //--------------------------------------------------------------------------------------------------  /** - * Translate NSEvent modifier flags into SCI_* modifier flags.  + * Translate NSEvent modifier flags into SCI_* modifier flags.   *   * @param modifiers An integer bit set of NSSEvent modifier flags.   * @return A set of SCI_* modifier flags. @@ -1882,7 +1882,7 @@ static int TranslateModifierFlags(NSUInteger modifiers)  /**   * Main keyboard input handling method. It is called for any key down event, including function keys, - * numeric keypad input and whatnot.  + * numeric keypad input and whatnot.   *   * @param event The event instance associated with the key down event.   * @return True if the input was handled, false otherwise. @@ -1891,23 +1891,23 @@ bool ScintillaCocoa::KeyboardInput(NSEvent* event)  {    // For now filter out function keys.    NSString* input = [event characters]; -   +    bool handled = false; -   +    // Handle each entry individually. Usually we only have one entry anyway.    for (size_t i = 0; i < input.length; i++)    {      const UniChar originalKey = [input characterAtIndex: i];      UniChar key = KeyTranslate(originalKey); -     +      bool consumed = false; // Consumed as command? -     +      if (KeyDownWithModifiers(key, TranslateModifierFlags([event modifierFlags]), &consumed))        handled = true;      if (consumed)        handled = true;    } -   +    return handled;  } @@ -1924,12 +1924,12 @@ int ScintillaCocoa::InsertText(NSString* input)    CFIndex usedLen = 0;    CFStringGetBytes((CFStringRef)input, rangeAll, encoding, '?',                     false, NULL, 0, &usedLen); -     +    std::vector<UInt8> buffer(usedLen); -     +    CFStringGetBytes((CFStringRef)input, rangeAll, encoding, '?',                       false, buffer.data(),usedLen, NULL); -     +    AddCharUTF((char*) buffer.data(), static_cast<unsigned int>(usedLen), false);    return static_cast<int>(usedLen);  } @@ -1974,7 +1974,7 @@ void ScintillaCocoa::MouseEntered(NSEvent* event)    if (!HaveMouseCapture())    {      WndProc(SCI_SETCURSOR, (long int)SC_CURSORNORMAL, 0); -     +      // Mouse location is given in screen coordinates and might also be outside of our bounds.      Point location = ConvertPoint([event locationInWindow]);      ButtonMove(location); @@ -1997,7 +1997,7 @@ void ScintillaCocoa::MouseDown(NSEvent* event)    bool command = ([event modifierFlags] & NSCommandKeyMask) != 0;    bool shift = ([event modifierFlags] & NSShiftKeyMask) != 0;    bool alt = ([event modifierFlags] & NSAlternateKeyMask) != 0; -     +    ButtonDown(Point(location.x, location.y), (int) (time * 1000), shift, command, alt);  } @@ -2027,13 +2027,13 @@ void ScintillaCocoa::MouseWheel(NSEvent* event)    bool command = ([event modifierFlags] & NSCommandKeyMask) != 0;    int dY = 0; -    // In order to make scrolling with larger offset smoother we scroll less lines the larger the  +    // In order to make scrolling with larger offset smoother we scroll less lines the larger the      // delta value is.      if ([event deltaY] < 0)      dY = -(int) sqrt(-10.0 * [event deltaY]);      else      dY = (int) sqrt(10.0 * [event deltaY]); -   +    if (command)    {      // Zoom! We play with the font sizes in the styles. @@ -2086,7 +2086,7 @@ NSMenu* ScintillaCocoa::CreateContextMenu(NSEvent* /* event */)  {    // Call ScintillaBase to create the context menu.    ContextMenu(Point(0, 0)); -   +    return reinterpret_cast<NSMenu*>(popup.GetID());  } @@ -2139,16 +2139,16 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining      [[content layer] addSublayer:layerFindIndicator];    }    [layerFindIndicator removeAnimationForKey:@"animateFound"]; -   +    if (charRange.length)    {      CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),  							 vs.styles[STYLE_DEFAULT].characterSet);      std::vector<char> buffer(charRange.length);      pdoc->GetCharRange(&buffer[0], charRange.location, charRange.length); -     +      CFStringRef cfsFind = CFStringCreateWithBytes(kCFAllocatorDefault, -						  reinterpret_cast<const UInt8 *>(&buffer[0]),  +						  reinterpret_cast<const UInt8 *>(&buffer[0]),  						  charRange.length, encoding, false);      layerFindIndicator.sFind = (NSString *)cfsFind;      if (cfsFind) @@ -2159,8 +2159,8 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining      std::vector<char> bufferFontName(WndProc(SCI_STYLEGETFONT, style, 0) + 1);      WndProc(SCI_STYLEGETFONT, style, (sptr_t)&bufferFontName[0]);      layerFindIndicator.sFont = [NSString stringWithUTF8String: &bufferFontName[0]]; -     -    layerFindIndicator.fontSize = WndProc(SCI_STYLEGETSIZEFRACTIONAL, style, 0) /  + +    layerFindIndicator.fontSize = WndProc(SCI_STYLEGETSIZEFRACTIONAL, style, 0) /        (float)SC_FONT_SIZE_MULTIPLIER;      layerFindIndicator.widthText = WndProc(SCI_POINTXFROMPOSITION, 0, charRange.location + charRange.length) -        WndProc(SCI_POINTXFROMPOSITION, 0, charRange.location); diff --git a/cocoa/ScintillaView.h b/cocoa/ScintillaView.h index 39c008a61..51d60e9d5 100644 --- a/cocoa/ScintillaView.h +++ b/cocoa/ScintillaView.h @@ -98,15 +98,15 @@ extern NSString *const SCIUpdateUINotification;    // The back end is kind of a controller and model in one.    // It uses the content view for display.    Scintilla::ScintillaCocoa* mBackend; -   +    // This is the actual content to which the backend renders itself.    SCIContentView* mContent; -   +    NSScrollView *scrollView;    SCIMarginView *marginView; -   +    CGFloat zoomDelta; -   +    // Area to display additional controls (e.g. zoom info, caret position, status info).    NSView <InfoBarCommunicator>* mInfoBar;    BOOL mInfoBarAtTop; diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 9bc0a5d1c..2db8fae12 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -80,7 +80,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (void) setFrame: (NSRect) frame  {    [super setFrame: frame]; -   +    [[self window] invalidateCursorRectsForView: self];  } @@ -131,7 +131,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (void) resetCursorRects  {    [super resetCursorRects]; -   +    int x = 0;    NSRect marginRect = [self bounds];    size_t co = [currentCursors count]; @@ -160,18 +160,18 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (NSView*) initWithFrame: (NSRect) frame  {    self = [super initWithFrame: frame]; -   +    if (self != nil)    {      // Some initialization for our view.      mCurrentCursor = [[NSCursor arrowCursor] retain];      mCurrentTrackingRect = 0;      mMarkedTextRange = NSMakeRange(NSNotFound, 0); -     +      [self registerForDraggedTypes: [NSArray arrayWithObjects:                                     NSStringPboardType, ScintillaRecPboardType, NSFilenamesPboardType, nil]];    } -   +    return self;  } @@ -219,7 +219,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (void) resetCursorRects  {    [super resetCursorRects]; -   +    // We only have one cursor rect: our bounds.    [self addCursorRect: [self bounds] cursor: mCurrentCursor];    [mCurrentCursor setOnMouseEntered: YES]; @@ -233,7 +233,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (void) drawRect: (NSRect) rect  {    CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; -   +    if (!mOwner.backend->Draw(rect, context)) {      dispatch_async(dispatch_get_main_queue(), ^{        [self setNeedsDisplay:YES]; @@ -245,7 +245,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  /**   * Windows uses a client coordinate system where the upper left corner is the origin in a window - * (and so does Scintilla). We have to adjust for that. However by returning YES here, we are  + * (and so does Scintilla). We have to adjust for that. However by returning YES here, we are   * already done with that.   * Note that because of returning YES here most coordinates we use now (e.g. for painting,   * invalidating rectangles etc.) are given with +Y pointing down! @@ -396,7 +396,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  		newText = (NSString*) aString;  	else if ([aString isKindOfClass:[NSAttributedString class]])  		newText = (NSString*) [aString string]; -	 +  	mOwner.backend->InsertText(newText);  } @@ -435,7 +435,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    else      if ([aString isKindOfClass:[NSAttributedString class]])        newText = (NSString*) [aString string]; -   +    long currentPosition = [mOwner getGeneralProperty: SCI_GETCURRENTPOS parameter: 0];    // Replace marked text if there is one. @@ -443,7 +443,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    {      [mOwner setGeneralProperty: SCI_SETSELECTIONSTART                           value: mMarkedTextRange.location]; -    [mOwner setGeneralProperty: SCI_SETSELECTIONEND  +    [mOwner setGeneralProperty: SCI_SETSELECTIONEND                           value: mMarkedTextRange.location + mMarkedTextRange.length];      currentPosition = mMarkedTextRange.location;    } @@ -474,7 +474,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    mMarkedTextRange.location = currentPosition;    mMarkedTextRange.length = lengthInserted; -     +    if (lengthInserted > 0)    {      // Mark the just inserted text. Keep the marked range for later reset. @@ -516,7 +516,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)                           value: mMarkedTextRange.length];      mMarkedTextRange = NSMakeRange(NSNotFound, 0); -    // Reenable undo action collection, after we are done with text composition.     +    // Reenable undo action collection, after we are done with text composition.      if (undoCollectionWasActive)        [mOwner setGeneralProperty: SCI_SETUNDOCOLLECTION value: 1];    } @@ -534,12 +534,12 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)      // We have already marked text. Replace that.      [mOwner setGeneralProperty: SCI_SETSELECTIONSTART                       value: mMarkedTextRange.location]; -    [mOwner setGeneralProperty: SCI_SETSELECTIONEND  +    [mOwner setGeneralProperty: SCI_SETSELECTIONEND                       value: mMarkedTextRange.location + mMarkedTextRange.length];      mOwner.backend->InsertText(@"");      mMarkedTextRange = NSMakeRange(NSNotFound, 0); -    // Reenable undo action collection, after we are done with text composition.     +    // Reenable undo action collection, after we are done with text composition.      if (undoCollectionWasActive)        [mOwner setGeneralProperty: SCI_SETUNDOCOLLECTION value: 1];    } @@ -571,7 +571,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  //-------------------------------------------------------------------------------------------------- -- (void) mouseDown: (NSEvent *) theEvent   +- (void) mouseDown: (NSEvent *) theEvent  {    mOwner.backend->MouseDown(theEvent);  } @@ -674,7 +674,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  //--------------------------------------------------------------------------------------------------  /** - * Called when an external drag operation enters the view.  + * Called when an external drag operation enters the view.   */  - (NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender  { @@ -713,7 +713,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (BOOL) performDragOperation: (id <NSDraggingInfo>) sender  { -  return mOwner.backend->PerformDragOperation(sender);   +  return mOwner.backend->PerformDragOperation(sender);  }  //-------------------------------------------------------------------------------------------------- @@ -867,11 +867,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    if (self == [ScintillaView class])    {      NSBundle* bundle = [NSBundle bundleForClass: [ScintillaView class]]; -     +      NSString* path = [bundle pathForResource: @"mac_cursor_busy" ofType: @"tiff" inDirectory: nil];      NSImage* image = [[[NSImage alloc] initWithContentsOfFile: path] autorelease];      waitCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(2, 2)]; -     +      path = [bundle pathForResource: @"mac_cursor_flipped" ofType: @"tiff" inDirectory: nil];      image = [[[NSImage alloc] initWithContentsOfFile: path] autorelease];      reverseArrowCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(12, 2)]; @@ -903,7 +903,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)      long zoomFactor = [self getGeneralProperty: SCI_GETZOOM] + zoomDelta;      [self setGeneralProperty: SCI_SETZOOM parameter: zoomFactor value:0];      zoomDelta = 0.0; -  }      +  }  #endif  } @@ -983,14 +983,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (void) notification: (Scintilla::SCNotification*)scn  {    // Parent notification. Details are passed as SCNotification structure. -   +    if (mDelegate != nil)    {      [mDelegate notification: scn];      if (scn->nmhdr.code != SCN_ZOOM && scn->nmhdr.code != SCN_UPDATEUI)        return;    } -   +    switch (scn->nmhdr.code)    {      case SCN_MARGINCLICK: @@ -1075,26 +1075,26 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)      [scrollView setHasHorizontalRuler:NO];      [scrollView setHasVerticalRuler:YES];      [scrollView setRulersVisible:YES]; -     +      mBackend = new ScintillaCocoa(mContent, marginView);      // Establish a connection from the back end to this container so we can handle situations      // which require our attention.      mBackend->SetDelegate(self); -     -    // Setup a special indicator used in the editor to provide visual feedback for  + +    // Setup a special indicator used in the editor to provide visual feedback for      // input composition, depending on language, keyboard etc.      [self setColorProperty: SCI_INDICSETFORE parameter: INPUT_INDICATOR fromHTML: @"#FF0000"];      [self setGeneralProperty: SCI_INDICSETUNDER parameter: INPUT_INDICATOR value: 1];      [self setGeneralProperty: SCI_INDICSETSTYLE parameter: INPUT_INDICATOR value: INDIC_PLAIN];      [self setGeneralProperty: SCI_INDICSETALPHA parameter: INPUT_INDICATOR value: 100]; -       +      NSNotificationCenter *center = [NSNotificationCenter defaultCenter];      [center addObserver:self                 selector:@selector(applicationDidResignActive:)                     name:NSApplicationDidResignActiveNotification                   object:nil]; -       +      [center addObserver:self                 selector:@selector(applicationDidBecomeActive:)                     name:NSApplicationDidBecomeActiveNotification @@ -1138,9 +1138,9 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (void) viewDidMoveToWindow  {    [super viewDidMoveToWindow]; -   +    [self positionSubViews]; -   +    // Enable also mouse move events for our window (and so this view).    [[self window] setAcceptsMouseMovedEvents: YES];  } @@ -1232,7 +1232,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (NSString*) selectedString  {    NSString *result = @""; -   +    const long length = mBackend->WndProc(SCI_GETSELTEXT, 0, 0);    if (length > 0)    { @@ -1240,14 +1240,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)      try      {        mBackend->WndProc(SCI_GETSELTEXT, length + 1, (sptr_t) &buffer[0]); -       +        result = [NSString stringWithUTF8String: buffer.c_str()];      }      catch (...)      {      }    } -   +    return result;  } @@ -1260,7 +1260,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)  - (NSString*) string  {    NSString *result = @""; -   +    const long length = mBackend->WndProc(SCI_GETLENGTH, 0, 0);    if (length > 0)    { @@ -1268,14 +1268,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)      try      {        mBackend->WndProc(SCI_GETTEXT, length + 1, (sptr_t) &buffer[0]); -       +        result = [NSString stringWithUTF8String: buffer.c_str()];      }      catch (...)      {      }    } -   +    return result;  } @@ -1422,7 +1422,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)   */  - (long) getGeneralProperty: (int) property ref: (const void*) ref  { -  return mBackend->WndProc(property, 0, (sptr_t) ref);   +  return mBackend->WndProc(property, 0, (sptr_t) ref);  }  //-------------------------------------------------------------------------------------------------- @@ -1437,7 +1437,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    long red = [value redComponent] * 255;    long green = [value greenComponent] * 255;    long blue = [value blueComponent] * 255; -   +    long color = (blue << 16) + (green << 8) + red;    mBackend->WndProc(property, parameter, color);  } @@ -1454,7 +1454,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    {      bool longVersion = [fromHTML length] > 6;      int index = 1; -     +      char value[3] = {0, 0, 0};      value[0] = [fromHTML characterAtIndex: index++];      if (longVersion) @@ -1470,7 +1470,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)        value[1] = [fromHTML characterAtIndex: index++];      else        value[1] = value[0]; -     +      unsigned rawGreen;      [[NSScanner scannerWithString: [NSString stringWithUTF8String: value]] scanHexInt: &rawGreen]; @@ -1479,7 +1479,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)        value[1] = [fromHTML characterAtIndex: index++];      else        value[1] = value[0]; -     +      unsigned rawBlue;      [[NSScanner scannerWithString: [NSString stringWithUTF8String: value]] scanHexInt: &rawBlue]; @@ -1593,7 +1593,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    if (mInfoBar != newBar)    {      [mInfoBar removeFromSuperview]; -     +      mInfoBar = newBar;      mInfoBarAtTop = top;      if (mInfoBar != nil) @@ -1601,7 +1601,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)        [self addSubview: mInfoBar];        [mInfoBar setCallback: self];      } -     +      [self positionSubViews];    }  } @@ -1672,7 +1672,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    int selectionStart = [self getGeneralProperty: SCI_GETSELECTIONSTART parameter: 0];    int selectionEnd = [self getGeneralProperty: SCI_GETSELECTIONEND parameter: 0]; -   +    // Sets the start point for the coming search to the beginning of the current selection.    // For forward searches we have therefore to set the selection start to the current selection end    // for proper incremental search. This does not harm as we either get a new selection if something @@ -1772,7 +1772,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)    const char* replacement = [newText UTF8String];    int targetLength = strlen(replacement);  // Length in bytes.    sptr_t result; -   +    int replaceCount = 0;    if (doAll)    { @@ -1818,7 +1818,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor)      [self setGeneralProperty: SCI_SETSELECTIONEND value: [self getGeneralProperty: SCI_GETTARGETEND]];      }    } -   +    return replaceCount;  } diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 427f08ec3..f3a75466e 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -48,7 +48,7 @@  static const double kPi = 3.14159265358979323846; -// The Pango version guard for pango_units_from_double and pango_units_to_double  +// The Pango version guard for pango_units_from_double and pango_units_to_double  // is more complex than simply implementing these here.  static int pangoUnitsFromDouble(double d) { @@ -339,7 +339,7 @@ void FontCached::ReleaseAll() {  FontID FontCached::CreateNewFont(const FontParameters &fp) {  	PangoFontDescription *pfd = pango_font_description_new();  	if (pfd) { -		pango_font_description_set_family(pfd,  +		pango_font_description_set_family(pfd,  			(fp.faceName[0] == '!') ? fp.faceName+1 : fp.faceName);  		pango_font_description_set_size(pfd, pangoUnitsFromDouble(fp.size));  		pango_font_description_set_weight(pfd, static_cast<PangoWeight>(fp.weight)); @@ -666,7 +666,7 @@ void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore,                            ColourDesired back) {  	PenColour(back);  	cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5); -	for (int i = 1;i < npts;i++) { +	for (int i = 1; i < npts; i++) {  		cairo_line_to(context, pts[i].x + 0.5, pts[i].y + 0.5);  	}  	cairo_close_path(context); @@ -842,7 +842,7 @@ void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {  std::string UTF8FromLatin1(const char *s, int len) {  	std::string utfForm(len*2 + 1, '\0');  	size_t lenU = 0; -	for (int i=0;i<len;i++) { +	for (int i=0; i<len; i++) {  		unsigned int uch = static_cast<unsigned char>(s[i]);  		if (uch < 0x80) {  			utfForm[lenU++] = uch; @@ -936,7 +936,7 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase,  void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,                                    ColourDesired fore) {  	// Avoid drawing spaces in transparent mode -	for (int i=0;i<len;i++) { +	for (int i=0; i<len; i++) {  		if (s[i] != ' ') {  			DrawTextBase(rc, font_, ybase, s, len, fore);  			return; @@ -1064,7 +1064,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION  							int widthLayout = 0;  							pango_layout_get_size(layout, &widthLayout, NULL);  							XYPOSITION widthTotal = doubleFromPangoUnits(widthLayout); -							for (int bytePos=0;bytePos<lenPositions; bytePos++) { +							for (int bytePos=0; bytePos<lenPositions; bytePos++) {  								positions[bytePos] = widthTotal / lenPositions * (bytePos + 1);  							}  							return; @@ -1598,7 +1598,7 @@ PRectangle ListBoxX::GetDesiredRect() {  		GtkRequisition req;  #if GTK_CHECK_VERSION(3,0,0)  		// This, apparently unnecessary call, ensures gtk_tree_view_column_cell_get_size -		// returns reasonable values.  +		// returns reasonable values.  		gtk_widget_get_preferred_size(GTK_WIDGET(scroller), NULL, &req);  #endif  		int height; @@ -1981,8 +1981,9 @@ public:  				return static_cast<Function>(fn_address);  			else  				return NULL; -		} else +		} else {  			return NULL; +		}  	}  	virtual bool IsValid() { diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index d4eaf93a5..91d308217 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -376,7 +376,7 @@ public:  	int SCI_METHOD LineEndTypesSupported() {  		return SC_LINE_END_TYPE_UNICODE; -	}; +	}  	int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) {  		return subStyles.Allocate(styleBase, numberStyles); diff --git a/lexers/LexCoffeeScript.cxx b/lexers/LexCoffeeScript.cxx index c0faea386..9da531adb 100644 --- a/lexers/LexCoffeeScript.cxx +++ b/lexers/LexCoffeeScript.cxx @@ -397,7 +397,7 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init  					sc.SetState(SCE_COFFEESCRIPT_COMMENTBLOCK);  					sc.Forward();  					sc.Forward(); -					 +  				} else {  					sc.SetState(SCE_COFFEESCRIPT_COMMENTLINE);  				} diff --git a/lexers/LexHTML.cxx b/lexers/LexHTML.cxx index 58862b4c8..bb70fd45b 100644 --- a/lexers/LexHTML.cxx +++ b/lexers/LexHTML.cxx @@ -339,9 +339,9 @@ static void classifyWordHTJS(unsigned int start, unsigned int end,  static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, script_mode inScriptType) {  	char chAttr = SCE_HB_IDENTIFIER;  	bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.'); -	if (wordIsNumber) +	if (wordIsNumber) {  		chAttr = SCE_HB_NUMBER; -	else { +	} else {  		char s[100];  		GetTextSegment(styler, start, end, s, sizeof(s));  		if (keywords.InList(s)) { @@ -385,9 +385,9 @@ static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &key  static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {  	char chAttr = SCE_HPHP_DEFAULT;  	bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.' && start+1 <= end && IsADigit(styler[start+1])); -	if (wordIsNumber) +	if (wordIsNumber) {  		chAttr = SCE_HPHP_NUMBER; -	else { +	} else {  		char s[100];  		GetTextSegment(styler, start, end, s, sizeof(s));  		if (keywords.InList(s)) @@ -823,14 +823,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  		if (isMako && ch == '#' && chNext == '#') {  			makoComment = 1;  		} -		 +  		// handle end of Mako comment line  		else if (isMako && makoComment && (ch == '\r' || ch == '\n')) {  			makoComment = 0;  			styler.ColourTo(i, SCE_HP_COMMENTLINE);  			state = SCE_HP_DEFAULT;  		} -		 +  		// Allow falling through to mako handling code if newline is going to end a block  		if (((ch == '\r' && chNext != '\n') || (ch == '\n')) &&  			(!isMako || (0 != strcmp(makoBlockType, "%")))) { diff --git a/lexers/LexOthers.cxx b/lexers/LexOthers.cxx index f87e79275..f1e828dc8 100644 --- a/lexers/LexOthers.cxx +++ b/lexers/LexOthers.cxx @@ -1037,8 +1037,9 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin  						!CompareCaseInsensitive(word, "fatal") || !CompareCaseInsensitive(word, "catastrophic") ||  						!CompareCaseInsensitive(word, "note") || !CompareCaseInsensitive(word, "remark")) {  						state = stMsVc; -					} else +					} else {  						state = stUnrecognized; +					}  				} else {  					state = stUnrecognized;  				} diff --git a/lexers/LexPerl.cxx b/lexers/LexPerl.cxx index d6fa7446c..5a7447af3 100644 --- a/lexers/LexPerl.cxx +++ b/lexers/LexPerl.cxx @@ -1185,7 +1185,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,  				}  				switch (HereDoc.Quote) {  				case '\'': -					st_new = SCE_PL_HERE_Q ; +					st_new = SCE_PL_HERE_Q;  					break;  				case '"' :  					st_new = SCE_PL_HERE_QQ; diff --git a/lexers/LexSQL.cxx b/lexers/LexSQL.cxx index 4d895352f..fa22f8e63 100644 --- a/lexers/LexSQL.cxx +++ b/lexers/LexSQL.cxx @@ -643,7 +643,7 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,  			break;  		}  	} -	 +  	int levelNext = levelCurrent;  	char chNext = styler[startPos];  	int styleNext = styler.StyleAt(startPos); diff --git a/lexlib/Accessor.h b/lexlib/Accessor.h index 9789f2b4a..1bb86c53b 100644 --- a/lexlib/Accessor.h +++ b/lexlib/Accessor.h @@ -12,7 +12,7 @@  namespace Scintilla {  #endif -enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8}; +enum { wsSpace=1, wsTab=2, wsSpaceTab=4, wsInconsistent=8 };  class Accessor;  class WordList; diff --git a/lexlib/LexAccessor.h b/lexlib/LexAccessor.h index ae0af74e9..59e73cf6e 100644 --- a/lexlib/LexAccessor.h +++ b/lexlib/LexAccessor.h @@ -55,11 +55,11 @@ private:  public:  	LexAccessor(IDocument *pAccess_) :  		pAccess(pAccess_), startPos(extremePosition), endPos(0), -		codePage(pAccess->CodePage()),  +		codePage(pAccess->CodePage()),  		encodingType(enc8bit),  		lenDoc(pAccess->Length()),  		mask(127), validLen(0), chFlags(0), chWhile(0), -		startSeg(0), startPosStyling(0),  +		startSeg(0), startPosStyling(0),  		documentVersion(pAccess->Version()) {  		switch (codePage) {  		case 65001: diff --git a/lexlib/LexerModule.cxx b/lexlib/LexerModule.cxx index 532d09626..c77b31775 100644 --- a/lexlib/LexerModule.cxx +++ b/lexlib/LexerModule.cxx @@ -79,7 +79,7 @@ const char *LexerModule::GetWordListDescription(int index) const {  		return "";  	} else {  		return wordListDescriptions[index]; - 	} +	}  }  int LexerModule::GetStyleBitsNeeded() const { diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx index 9197fb642..6792eea15 100644 --- a/lexlib/PropSetSimple.cxx +++ b/lexlib/PropSetSimple.cxx @@ -61,7 +61,7 @@ void PropSetSimple::Set(const char *keyVal) {  		endVal++;  	const char *eqAt = strchr(keyVal, '=');  	if (eqAt) { -		Set(keyVal, eqAt + 1, static_cast<int>(eqAt-keyVal),  +		Set(keyVal, eqAt + 1, static_cast<int>(eqAt-keyVal),  			static_cast<int>(endVal - eqAt - 1));  	} else if (*keyVal) {	// No '=' so assume '=1'  		Set(keyVal, "1", static_cast<int>(endVal-keyVal), 1); diff --git a/lexlib/StyleContext.h b/lexlib/StyleContext.h index 12d69d8f2..9b5ce5dff 100644 --- a/lexlib/StyleContext.h +++ b/lexlib/StyleContext.h @@ -28,7 +28,7 @@ class StyleContext {  	IDocumentWithLineEnd *multiByteAccess;  	unsigned int endPos;  	unsigned int lengthDocument; -	 +  	// Used for optimizing GetRelativeCharacter  	unsigned int posRelative;  	unsigned int currentPosLastRelative; @@ -43,7 +43,7 @@ class StyleContext {  			chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+width, 0));  			widthNext = 1;  		} -		// End of line determined from line end position, allowing CR, LF,  +		// End of line determined from line end position, allowing CR, LF,  		// CRLF and Unicode line ends as set by document.  		if (currentLine < lineDocEnd)  			atLineEnd = static_cast<int>(currentPos) >= (lineStartNext-1); diff --git a/lexlib/WordList.cxx b/lexlib/WordList.cxx index a325833d4..1f7127999 100644 --- a/lexlib/WordList.cxx +++ b/lexlib/WordList.cxx @@ -70,7 +70,7 @@ WordList::WordList(bool onlyLineEnds_) :  	words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_) {  } -WordList::~WordList() {  +WordList::~WordList() {  	Clear();  } diff --git a/src/AutoComplete.h b/src/AutoComplete.h index 9977196a2..f7a0c3f1e 100644 --- a/src/AutoComplete.h +++ b/src/AutoComplete.h @@ -71,7 +71,7 @@ public:  	/// The list string contains a sequence of words separated by the separator character  	void SetList(const char *list); -	 +  	/// Return the position of the currently selected list item  	int GetSelection() const; diff --git a/src/CaseConvert.cxx b/src/CaseConvert.cxx index 59819bcf6..f983458c0 100644 --- a/src/CaseConvert.cxx +++ b/src/CaseConvert.cxx @@ -510,7 +510,7 @@ void SetupConversions(enum CaseConversion conversion) {  		int upper = symmetricCaseConversionRanges[i++];  		int length = symmetricCaseConversionRanges[i++];  		int pitch = symmetricCaseConversionRanges[i++]; -		for (int j=0;j<length*pitch;j+=pitch) { +		for (int j=0; j<length*pitch; j+=pitch) {  			AddSymmetric(conversion, lower+j, upper+j);  		}  	} diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 82179ac9a..6b719de27 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -17,8 +17,8 @@ class PerLine {  public:  	virtual ~PerLine() {}  	virtual void Init()=0; -	virtual void InsertLine(int)=0; -	virtual void RemoveLine(int)=0; +	virtual void InsertLine(int line)=0; +	virtual void RemoveLine(int line)=0;  };  /** diff --git a/src/Document.cxx b/src/Document.cxx index 78aa22794..acf4d9755 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -955,7 +955,7 @@ bool Document::InsertString(int position, const char *s, int insertLength) {  int SCI_METHOD Document::AddData(char *data, int length) {  	try {  		int position = Length(); -		InsertString(position,data, length); +		InsertString(position, data, length);  	} catch (std::bad_alloc &) {  		return SC_STATUS_BADALLOC;  	} catch (...) { @@ -1892,7 +1892,7 @@ void SCI_METHOD Document::DecorationFillRange(int position, int value, int fillL  bool Document::AddWatcher(DocWatcher *watcher, void *userData) {  	WatcherWithUserData wwud(watcher, userData); -	std::vector<WatcherWithUserData>::iterator it =  +	std::vector<WatcherWithUserData>::iterator it =  		std::find(watchers.begin(), watchers.end(), wwud);  	if (it != watchers.end())  		return false; @@ -1901,7 +1901,7 @@ bool Document::AddWatcher(DocWatcher *watcher, void *userData) {  }  bool Document::RemoveWatcher(DocWatcher *watcher, void *userData) { -	std::vector<WatcherWithUserData>::iterator it =  +	std::vector<WatcherWithUserData>::iterator it =  		std::find(watchers.begin(), watchers.end(), WatcherWithUserData(watcher, userData));  	if (it != watchers.end()) {  		watchers.erase(it); diff --git a/src/Document.h b/src/Document.h index d02025cb5..1e43076ca 100644 --- a/src/Document.h +++ b/src/Document.h @@ -443,12 +443,12 @@ public:   */  class DocModification {  public: -  	int modificationType; +	int modificationType;  	int position; - 	int length; - 	int linesAdded;	/**< Negative if lines deleted. */ - 	const char *text;	/**< Only valid for changes to text, not for changes to style. */ - 	int line; +	int length; +	int linesAdded;	/**< Negative if lines deleted. */ +	const char *text;	/**< Only valid for changes to text, not for changes to style. */ +	int line;  	int foldLevelNow;  	int foldLevelPrev;  	int annotationLinesAdded; diff --git a/src/Editor.cxx b/src/Editor.cxx index 074668059..764e00dce 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1988,7 +1988,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {  								}  							} else if (levelNum > SC_FOLDLEVELBASE) {  								marks |= 1 << SC_MARKNUM_FOLDERSUB; - 							} +							}  						} else {  							if (levelNum < levelNextNum) {  								if (cs.GetExpanded(lineDoc)) { @@ -1998,7 +1998,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {  								}  							} else if (levelNum > SC_FOLDLEVELBASE) {  								marks |= 1 << SC_MARKNUM_FOLDERSUB; - 							} +							}  						}  						needWhiteClosure = false;  						int firstFollowupLine = cs.DocFromDisplay(cs.DisplayFromDoc(lineDoc + 1)); @@ -2300,7 +2300,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou  							posCache.MeasureWidths(surface, vstyle, STYLE_CONTROLCHAR, ts.representation->stringRep.c_str(),  								static_cast<unsigned int>(ts.representation->stringRep.length()), positionsRepr, pdoc);  							representationWidth = positionsRepr[ts.representation->stringRep.length()-1] + vstyle.ctrlCharPadding; - 						} +						}  					}  					for (int ii=0; ii < ts.length; ii++)  						ll->positions[ts.start + 1 + ii] = representationWidth; @@ -3464,7 +3464,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS  				int caretWidthOffset = 0;  				PRectangle rcCaret = rcLine; -				if (posCaret.Position() == pdoc->Length())	{   // At end of document +				if (posCaret.Position() == pdoc->Length()) {   // At end of document  					caretAtEOF = true;  					widthOverstrikeCaret = vsDraw.aveCharWidth;  				} else if ((posCaret.Position() - posLineStart) >= ll->numCharsInLine) {	// At end of line @@ -4960,7 +4960,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar  	case SCI_NEWLINE:  	default:  		//		printf("Filtered out %ld of macro recording\n", iMessage); -		return ; +		return;  	}  	// Send notification @@ -7018,7 +7018,7 @@ void Editor::SetFoldExpanded(int lineDoc, bool expanded) {  void Editor::FoldLine(int line, int action) {  	if (line >= 0) {  		if (action == SC_FOLDACTION_TOGGLE) { - 			if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) { +			if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) {  				line = pdoc->GetFoldParent(line);  				if (line < 0)  					return; @@ -8445,7 +8445,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		if (wParam <= MARKER_MAX) {  			vs.markers[wParam].SetXPM(CharPtrFromSPtr(lParam));  			vs.CalcLargestMarkerHeight(); -		}; +		}  		InvalidateStyleData();  		RedrawSelMargin();  		break; @@ -8466,7 +8466,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		if (wParam <= MARKER_MAX) {  			vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0, reinterpret_cast<unsigned char *>(lParam));  			vs.CalcLargestMarkerHeight(); -		}; +		}  		InvalidateStyleData();  		RedrawSelMargin();  		break; diff --git a/src/Editor.h b/src/Editor.h index da4787b0a..7a8f1eb1d 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -119,7 +119,7 @@ public:  	}  private:  	void FixSelectionForClipboard() { -		// To avoid truncating the contents of the clipboard when pasted where the  +		// To avoid truncating the contents of the clipboard when pasted where the  		// clipboard contains NUL characters, replace NUL characters by spaces.  		std::replace(s.begin(), s.end(), '\0', ' ');  	} diff --git a/src/PerLine.cxx b/src/PerLine.cxx index a066bd647..7bf892240 100644 --- a/src/PerLine.cxx +++ b/src/PerLine.cxx @@ -98,7 +98,7 @@ bool MarkerHandleSet::RemoveNumber(int markerNum, bool all) {  			delete mhn;  			performedDeletion = true;  			if (!all) -				break;  +				break;  		} else {  			pmhn = &((*pmhn)->next);  		} diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 7201ff548..413796f85 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -454,7 +454,7 @@ BreakFinder::~BreakFinder() {  TextSegment BreakFinder::Next() {  	if (subBreak == -1) {  		int prev = nextBreak; - 		while (nextBreak < lineEnd) { +		while (nextBreak < lineEnd) {  			int charWidth = 1;  			if (encodingFamily == efUnicode)  				charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(ll->chars) + nextBreak, lineEnd - nextBreak); diff --git a/src/RESearch.cxx b/src/RESearch.cxx index efa23eb84..81eddf013 100644 --- a/src/RESearch.cxx +++ b/src/RESearch.cxx @@ -333,16 +333,18 @@ static int GetHexaChar(unsigned char hd1, unsigned char hd2) {  		hexValue += 16 * (hd1 - 'A' + 10);  	} else if (hd1 >= 'a' && hd1 <= 'f') {  		hexValue += 16 * (hd1 - 'a' + 10); -	} else +	} else {  		return -1; +	}  	if (hd2 >= '0' && hd2 <= '9') {  		hexValue += hd2 - '0';  	} else if (hd2 >= 'A' && hd2 <= 'F') {  		hexValue += hd2 - 'A' + 10;  	} else if (hd2 >= 'a' && hd2 <= 'f') {  		hexValue += hd2 - 'a' + 10; -	} else +	} else {  		return -1; +	}  	return hexValue;  } @@ -472,18 +474,18 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv  			break;  		case '^':               /* match beginning */ -			if (p == pattern) +			if (p == pattern) {  				*mp++ = BOL; -			else { +			} else {  				*mp++ = CHR;  				*mp++ = *p;  			}  			break;  		case '$':               /* match endofline */ -			if (!*(p+1)) +			if (!*(p+1)) {  				*mp++ = EOL; -			else { +			} else {  				*mp++ = CHR;  				*mp++ = *p;  			} @@ -498,8 +500,9 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv  				mask = '\377';  				i++;  				p++; -			} else +			} else {  				mask = 0; +			}  			if (*p == '-') {	/* real dash */  				i++; @@ -523,9 +526,9 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv  							i++;  							c2 = static_cast<unsigned char>(*++p);  							if (c2 == '\\') { -								if (!*(p+1))	// End of RE +								if (!*(p+1)) {	// End of RE  									return badpat("Missing ]"); -								else { +								} else {  									i++;  									p++;  									int incr; @@ -654,8 +657,9 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv  				if (tagc > n) {  					*mp++ = static_cast<char>(REF);  					*mp++ = static_cast<char>(n); -				} else +				} else {  					return badpat("Undetermined reference"); +				}  				break;  			default:  				if (!posix && *p == '(') { @@ -663,16 +667,18 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv  						tagstk[++tagi] = tagc;  						*mp++ = BOT;  						*mp++ = static_cast<char>(tagc++); -					} else +					} else {  						return badpat("Too many \\(\\) pairs"); +					}  				} else if (!posix && *p == ')') {  					if (*sp == BOT)  						return badpat("Null pattern inside \\(\\)");  					if (tagi > 0) {  						*mp++ = static_cast<char>(EOT);  						*mp++ = static_cast<char>(tagstk[tagi--]); -					} else +					} else {  						return badpat("Unmatched \\)"); +					}  				} else {  					int incr;  					int c = GetBackslashExpression(p, incr); @@ -697,16 +703,18 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv  					tagstk[++tagi] = tagc;  					*mp++ = BOT;  					*mp++ = static_cast<char>(tagc++); -				} else +				} else {  					return badpat("Too many () pairs"); +				}  			} else if (posix && *p == ')') {  				if (*sp == BOT)  					return badpat("Null pattern inside ()");  				if (tagi > 0) {  					*mp++ = static_cast<char>(EOT);  					*mp++ = static_cast<char>(tagstk[tagi--]); -				} else +				} else {  					return badpat("Unmatched )"); +				}  			} else {  				unsigned char c = *p;  				if (!c)	// End of RE diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 9190cd6d5..1fb4d6f27 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -209,7 +209,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {  	if (ac.chooseSingle && (listType == 0)) {  		if (list && !strchr(list, ac.GetSeparator())) {  			const char *typeSep = strchr(list, ac.GetTypesep()); -			int lenInsert = typeSep ?  +			int lenInsert = typeSep ?  				static_cast<int>(typeSep-list) : static_cast<int>(strlen(list));  			if (ac.ignoreCase) {  				// May need to convert the case before invocation, so remove lenEntered characters diff --git a/src/SplitVector.h b/src/SplitVector.h index 0c6e350cb..288c9e39f 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -272,7 +272,7 @@ public:  				GapTo(position);  				return body + position + gapLength;  			} else { -				return body + position ; +				return body + position;  			}  		} else {  			return body + position + gapLength; @@ -280,7 +280,7 @@ public:  	}  	int GapPosition() const { -		return part1Length;  +		return part1Length;  	}  }; diff --git a/src/UniConversion.cxx b/src/UniConversion.cxx index b769250c8..2286e047d 100644 --- a/src/UniConversion.cxx +++ b/src/UniConversion.cxx @@ -159,7 +159,7 @@ static int BytesFromLead(int leadByte) {  void UTF8BytesOfLeadInitialise() {  	if (!initialisedBytesOfLead) { -		for (int i=0;i<256;i++) { +		for (int i=0; i<256; i++) {  			UTF8BytesOfLead[i] = BytesFromLead(i);  		}  		initialisedBytesOfLead = true; diff --git a/src/XPM.cxx b/src/XPM.cxx index 915636de9..4191e1e92 100644 --- a/src/XPM.cxx +++ b/src/XPM.cxx @@ -120,7 +120,7 @@ void XPM::Init(const char *const *linesForm) {  	for (int y=0; y<height; y++) {  		const char *lform = linesForm[y+nColours+1];  		size_t len = MeasureLength(lform); -		for (size_t x = 0; x<len; x++)  +		for (size_t x = 0; x<len; x++)  			pixels[y * width + x] = static_cast<unsigned char>(lform[x]);  	}  } @@ -244,7 +244,7 @@ void RGBAImage::SetPixel(int x, int y, ColourDesired colour, int alpha) {  	pixel[3] = static_cast<unsigned char>(alpha);  } -RGBAImageSet::RGBAImageSet() : height(-1), width(-1){ +RGBAImageSet::RGBAImageSet() : height(-1), width(-1) {  }  RGBAImageSet::~RGBAImageSet() { @@ -62,7 +62,7 @@ public:  	float GetScaledWidth() const { return width / scale; }  	int CountBytes() const;  	const unsigned char *Pixels() const; -	void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff);  +	void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff);  };  /** diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index da642bc67..89e3f9c97 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -172,7 +172,7 @@ bool LoadD2D() {  				else  					gamma = defaultRenderingParams->GetGamma(); -				pIDWriteFactory->CreateCustomRenderingParams(gamma, defaultRenderingParams->GetEnhancedContrast(), defaultRenderingParams->GetClearTypeLevel(),  +				pIDWriteFactory->CreateCustomRenderingParams(gamma, defaultRenderingParams->GetEnhancedContrast(), defaultRenderingParams->GetClearTypeLevel(),  					defaultRenderingParams->GetPixelGeometry(), defaultRenderingParams->GetRenderingMode(), &customClearTypeRenderingParams);  			}  		} @@ -729,7 +729,7 @@ void SurfaceGDI::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired  	PenColour(fore);  	BrushColor(back);  	std::vector<POINT> outline; -	for (int i=0;i<npts;i++) { +	for (int i=0; i<npts; i++) {  		POINT pt = {static_cast<LONG>(pts[i].x), static_cast<LONG>(pts[i].y)};  		outline.push_back(pt);  	} @@ -834,12 +834,12 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil  					}  				}  			} -			for (int c=0;c<cornerSize; c++) { -				for (int x=0;x<c+1; x++) { +			for (int c=0; c<cornerSize; c++) { +				for (int x=0; x<c+1; x++) {  					AllFour(pixels, width, height, x, c-x, valEmpty);  				}  			} -			for (int x=1;x<cornerSize; x++) { +			for (int x=1; x<cornerSize; x++) {  				AllFour(pixels, width, height, x, cornerSize-x, valOutline);  			} @@ -974,7 +974,7 @@ void SurfaceGDI::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, c  void SurfaceGDI::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,  	ColourDesired fore) {  	// Avoid drawing spaces in transparent mode -	for (int i=0;i<len;i++) { +	for (int i=0; i<len; i++) {  		if (s[i] != ' ') {  			::SetTextColor(hdc, fore.AsLong());  			::SetBkMode(hdc, TRANSPARENT); @@ -1056,10 +1056,10 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *  				// Not all the positions are filled in so make them equal to end.  				if (fit == 0)  					poses.buffer[fit++] = 0; -				for (int i = fit;i<lenBlock;i++) +				for (int i = fit; i<lenBlock; i++)  					poses.buffer[i] = poses.buffer[fit-1];  			} -			for (int i=0;i<lenBlock;i++) +			for (int i=0; i<lenBlock; i++)  				positions[i] = poses.buffer[i] + startOffset;  			startOffset = poses.buffer[lenBlock-1];  			len -= lenBlock; @@ -1076,7 +1076,7 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *  		}  		int ui = 0; -		for (int i=0;i<len;) { +		for (int i=0; i<len;) {  			if (Platform::IsDBCSLeadByte(codePage, s[i])) {  				positions[i] = poses.buffer[ui];  				positions[i+1] = poses.buffer[ui]; @@ -1669,7 +1669,7 @@ void SurfaceD2D::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, c  void SurfaceD2D::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,  	ColourDesired fore) {  	// Avoid drawing spaces in transparent mode -	for (int i=0;i<len;i++) { +	for (int i=0; i<len; i++) {  		if (s[i] != ' ') {  			if (pRenderTarget) {  				D2DPenColour(fore); @@ -1719,7 +1719,7 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *  			return;  		FLOAT position = 0.0f;  		size_t ti=0; -		for (size_t ci=0;ci<count;ci++) { +		for (size_t ci=0; ci<count; ci++) {  			position += clusterMetrics[ci].width;  			for (size_t inCluster=0; inCluster<clusterMetrics[ci].length; inCluster++) {  				//poses.buffer[ti++] = int(position + 0.5); @@ -1760,7 +1760,7 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *  		// One character per position  		PLATFORM_ASSERT(len == tbuf.tlen); -		for (size_t kk=0;kk<static_cast<size_t>(len);kk++) { +		for (size_t kk=0; kk<static_cast<size_t>(len); kk++) {  			positions[kk] = poses.buffer[kk];  		} @@ -1769,7 +1769,7 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *  		// May be more than one byte per position  		unsigned int ui = 0;  		FLOAT position = 0.0f; -		for (int i=0;i<len;) { +		for (int i=0; i<len;) {  			if (ui < count)  				position = poses.buffer[ui];  			if (Platform::IsDBCSLeadByte(codePageText, s[i])) { @@ -2175,7 +2175,7 @@ class ListBoxX : public ListBox {  	void ResizeToCursor();  	void StartResize(WPARAM);  	int NcHitTest(WPARAM, LPARAM) const; -	void CentreItem(int); +	void CentreItem(int n);  	void Paint(HDC);  	static LRESULT PASCAL ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam); @@ -3077,8 +3077,9 @@ public:  			} fnConv;  			fnConv.fp = ::GetProcAddress(h, name);  			return fnConv.f; -		} else +		} else {  			return NULL; +		}  	}  	virtual bool IsValid() { diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 7bc05eec8..465d74d85 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -1492,9 +1492,9 @@ public:  					// Maximum length of a case conversion is 6 bytes, 3 characters  					wchar_t wFolded[20];  					unsigned int charsConverted = UTF16FromUTF8(foldedUTF8, -							static_cast<unsigned int>(strlen(foldedUTF8)),  +							static_cast<unsigned int>(strlen(foldedUTF8)),  							wFolded, sizeof(wFolded)/sizeof(wFolded[0])); -					for (size_t j=0;j<charsConverted;j++) +					for (size_t j=0; j<charsConverted; j++)  						utf16Folded[lenFlat++] = wFolded[j];  				} else {  					utf16Folded[lenFlat++] = utf16Mixed[mixIndex]; @@ -1538,7 +1538,7 @@ CaseFolder *ScintillaWin::CaseFolderForEncoding() {  					if (caseFolded) {  						wchar_t wLower[20];  						unsigned int charsConverted = UTF16FromUTF8(caseFolded, -							static_cast<unsigned int>(strlen(caseFolded)),  +							static_cast<unsigned int>(strlen(caseFolded)),  							wLower, sizeof(wLower)/sizeof(wLower[0]));  						if (charsConverted == 1) {  							char sCharacterLowered[20]; @@ -1566,7 +1566,7 @@ std::string ScintillaWin::CaseMapString(const std::string &s, int caseMapping) {  	UINT cpDoc = CodePageOfDocument();  	if (cpDoc == SC_CP_UTF8) {  		std::string retMapped(s.length() * maxExpansionCaseConversion, 0); -		size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),  +		size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),  			(caseMapping == cmUpper) ? CaseConversionUpper : CaseConversionLower);  		retMapped.resize(lenMapped);  		return retMapped; | 
