Created
February 25, 2012 10:47
-
-
Save joaotavora/1907807 to your computer and use it in GitHub Desktop.
Nicer visual bell for cocoa emacs. See http://old.nabble.com/visible-bell-patch-for-Mac-OS-X-td27389547.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bazaar merge directive format 2 (Bazaar 0.90) | |
# revision_id: [email protected] | |
# target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk | |
# testament_sha1: 27c8026494ef46e68ad79f8263f479ed22874804 | |
# timestamp: 2010-01-30 13:33:01 +0000 | |
# base_revision_id: [email protected]\ | |
# 0m0lt5sbqqqhuufz | |
# | |
# Begin patch | |
=== modified file 'src/nsterm.m' | |
--- old/src/nsterm.m 2010-01-15 01:46:53 +0000 | |
+++ new/src/nsterm.m 2010-01-30 13:31:39 +0000 | |
@@ -808,23 +808,58 @@ | |
view = FRAME_NS_VIEW (frame); | |
if (view != nil) | |
{ | |
- NSRect r, surr; | |
- NSPoint dim = NSMakePoint (128, 128); | |
- | |
- r = [view bounds]; | |
- r.origin.x += (r.size.width - dim.x) / 2; | |
- r.origin.y += (r.size.height - dim.y) / 2; | |
- r.size.width = dim.x; | |
- r.size.height = dim.y; | |
- surr = NSInsetRect (r, -2, -2); | |
- ns_focus (frame, &surr, 1); | |
- [[view window] cacheImageInRect: [view convertRect: surr toView:nil]]; | |
- [ns_lookup_indexed_color (NS_FACE_FOREGROUND | |
- (FRAME_DEFAULT_FACE (frame)), frame) set]; | |
- NSRectFill (r); | |
+ /* Get the bounds of our NSView */ | |
+ NSRect viewBounds = [view bounds]; | |
+ | |
+ /* Height of each line to flash. */ | |
+ int flash_height = FRAME_LINE_HEIGHT (frame); | |
+ int width = FRAME_PIXEL_WIDTH (frame) | |
+ - NS_SCROLL_BAR_WIDTH (frame); | |
+ | |
+ /* Get the GraphicsContext */ | |
+ CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort]; | |
+ CGRect lowerLine, upperLine; | |
+ lowerLine = | |
+ CGRectMake(viewBounds.origin.x, viewBounds.origin.y, | |
+ width + NS_SCROLL_BAR_WIDTH(frame), | |
+ flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)); | |
+ upperLine = | |
+ CGRectMake(viewBounds.origin.x, | |
+ viewBounds.origin.y + viewBounds.size.height | |
+ - (flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)), | |
+ width, | |
+ flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)); | |
+ | |
+ /* Invert the colors using a difference blend. */ | |
+ CGContextSetBlendMode(ctxt, kCGBlendModeDifference); | |
+ CGContextSetGrayFillColor(ctxt, 1, 1); | |
+ | |
+ /* If window is tall, flash top and bottom line. */ | |
+ if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame)) | |
+ { | |
+ CGContextFillRect(ctxt, upperLine); | |
+ CGContextFillRect(ctxt, lowerLine); | |
+ } | |
+ else | |
+ /* If it is short, flash it all. */ | |
+ CGContextFillRect(ctxt, NSRectToCGRect([view bounds])); | |
+ | |
+ /* Bounce Dock icon. Maybe we can allow some configuration here. */ | |
+ [NSApp requestUserAttention: NSInformationalRequest]; | |
+ | |
[[view window] flushWindow]; | |
ns_timeout (150000); | |
- [[view window] restoreCachedImage]; | |
+ | |
+ /* If window is tall, flash top and bottom line. */ | |
+ if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame)) | |
+ { | |
+ CGContextFillRect(ctxt, upperLine); | |
+ CGContextFillRect(ctxt, lowerLine); | |
+ } | |
+ else | |
+ /* If it is short, flash it all. */ | |
+ CGContextFillRect(ctxt, NSRectToCGRect([view bounds])); | |
+ | |
[[view window] flushWindow]; | |
ns_unfocus (frame); | |
} | |
# Begin bundle | |
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWfDfJK8AAp9/gAFQYABQf/// | |
f+ffyr////pQBh52i3A53eu6rb07iEumgkkTVPNU9IzSn6aUbap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Hkc7c8gatVhHSf7pSsvhr946A9HxhVLzGP5azFVQTldKY1l6sEYwgvhlHEX9mz1RS6SrK | |
VXw5KaEsi07F6URojUP+DmqFrOsTktZwQPl0L23xp6g4z65od3tSNc5bIVhKXaA6BlJvftyb7tdh | |
JZdE6fYSWgHnUPDEYjI5d0xSSUQjhVhAjw7Gbqa6t/HLTj6iUCLQRNa40J9rrhsFWbs78d6eneNG | |
J/BECGeTZ8QJm897etO+JJhqe6qwnzrU1N/8qLvIMt0CwKYZXrLWnBhyUQssrTDNTkJILfhbg0Dd | |
BzmEIApklBxiz6hmPoPzq4VJ5MarTEm+FnWbBubcXeUV+0dMyrGmiD0T3qmhGYF70ro5jgeZkRCG | |
wt01osvo+4GIThcqDcB0LGGqkui1fGFLLHWrwOwKj/ciR4i5dN8CsLs6XI4R1AUmLCZQ2hgPj0m5 | |
kMNnn0Yi7vWxrkMw1FYZkMGGYIcory5RRyDw1BFGxLcFwSgGlWfMg/4UAfQzjH3mCna5hqklHYdx | |
hzZFGQ9Sih8iYjpU1wlv4pUCWAi6mZbqUmfNuKk6SGWCYRJhn0UKp1BjUgTSIpVyszyZl3dzyUGr | |
AmENNW3fEXLvOHZ7PYbMSVMg0ji8BtG90wKURr2h4aAeD9p89kVj2GwZkmWDaUIaYlbTG1mTzDME | |
bVaE0Pk9EvItAucV9cRTKkc8EwZ0FPrPHaPFbnZdvYY8nZBTtzhCYbpa806NNhdyigFnBUTcUMb+ | |
U7kUH+xsIGajDEXpgoGwstNzeG0DnWUPpB/V1eDWhwyuclEGydxyytWALKY0S1qlZTFFSEzbDtSR | |
nJxoIUwUy7QoWXmu5CVnQuGUBAIstd+gmCpBnVlWszLWToVYbb6phrvQyrm4lrxDvVfSfbBA+cDB | |
MCDNIIo2z5/Ip7F0mTFsBoUc7ZnNQPeto26+4P/F3JFOFCQ8N8krwA== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment