all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Patch to make Emacs.app for OSX visible bell like Carbon Emacs
@ 2009-03-23 16:49 Philip Kime
  2009-03-24  1:06 ` YAMAMOTO Mitsuharu
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Kime @ 2009-03-23 16:49 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

Patch attached to nsterm.m (1.67) to make the visible bell behaviour  
nicer and like Carbon emacs. I also neatened it to stop the flashing  
across the fringe/scrollbar.


[-- Attachment #2: nsterm.diff --]
[-- Type: application/octet-stream, Size: 3134 bytes --]

Index: src/nsterm.m
===================================================================
RCS file: /sources/emacs/emacs/src/nsterm.m,v
retrieving revision 1.67
diff -u -p -r1.67 nsterm.m
--- src/nsterm.m	14 Mar 2009 21:20:09 -0000	1.67
+++ src/nsterm.m	20 Mar 2009 15:26:16 -0000
@@ -809,12 +809,88 @@ ns_clip_to_row (struct window *w, struct
 static void
 ns_ring_bell ()
 /* --------------------------------------------------------------------------
-     "Beep" routine
+	 "Beep" routine
    -------------------------------------------------------------------------- */
 {
   NSTRACE (ns_ring_bell);
   if (visible_bell)
-    {
+		{
+#ifdef NS_IMPL_COCOA
+      NSAutoreleasePool *pool;
+      struct frame *frame = SELECTED_FRAME ();
+      NSView *view;
+      /* Get the height not including a menu bar widget.  */
+      int height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (frame, FRAME_LINES (frame));
+      /* Height of each line to flash.  */
+      int flash_height = FRAME_LINE_HEIGHT (frame);
+      /* Left and right margins of the rectangles. */
+      int flash_left = FRAME_INTERNAL_BORDER_WIDTH (frame);
+      int flash_right = FRAME_PIXEL_WIDTH (frame) - FRAME_INTERNAL_BORDER_WIDTH (frame);
+			
+      int width;
+
+      /* Don't flash over the scroll bar, it's ugly */
+      switch (FRAME_VERTICAL_SCROLL_BAR_TYPE (frame))
+				{
+				case vertical_scroll_bar_left:
+					flash_left += NS_SCROLL_BAR_WIDTH (frame);
+					break;
+
+				case vertical_scroll_bar_right:
+					flash_right -= NS_SCROLL_BAR_WIDTH (frame);
+					break;
+
+				default:
+					break;
+				}
+
+      /* Don't flash over the fringe, it's ugly */
+      if (FRAME_TOTAL_FRINGE_WIDTH (frame))
+				{
+					flash_left += FRAME_LEFT_FRINGE_WIDTH (frame);
+					flash_right -= FRAME_RIGHT_FRINGE_WIDTH (frame);
+        }
+
+      width = flash_right - flash_left;
+
+      BLOCK_INPUT;
+      pool = [[NSAutoreleasePool alloc] init];
+
+      view = FRAME_NS_VIEW (frame);
+      if (view != nil)
+        {
+					CGRect r[2];
+					
+					r[0].origin.x = flash_left;
+					r[0].origin.y = (FRAME_INTERNAL_BORDER_WIDTH (frame)
+													 + FRAME_TOOL_BAR_LINES (frame) * FRAME_LINE_HEIGHT (frame));
+					r[0].size.width = width;
+					r[0].size.height = flash_height;
+
+					r[1].origin.x = flash_left;
+					r[1].origin.y = (height - flash_height);
+					r[1].size.width = width;
+					r[1].size.height = flash_height;
+
+					CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort];
+					CGContextSetBlendMode(ctxt, kCGBlendModeDifference);
+
+					CGContextSetGrayFillColor(ctxt, 1, 1);
+					CGContextFillRects(ctxt, r, 2);
+
+					[[view window] flushWindow];
+					ns_timeout (150000);
+
+					CGContextSetGrayFillColor(ctxt, 1, 1);
+					CGContextFillRects(ctxt, r, 2);
+
+					[[view window] flushWindow];
+
+					ns_unfocus (frame);
+				}
+      [pool release];
+      UNBLOCK_INPUT;
+#else
       NSAutoreleasePool *pool;
       struct frame *frame = SELECTED_FRAME ();
       NSView *view;
@@ -847,6 +923,7 @@ ns_ring_bell ()
         }
       [pool release];
       UNBLOCK_INPUT;
+#endif
     }
   else
     {

[-- Attachment #3: Type: text/plain, Size: 29 bytes --]




PK
--
Dr Philip Kime






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-25 16:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-23 16:49 Patch to make Emacs.app for OSX visible bell like Carbon Emacs Philip Kime
2009-03-24  1:06 ` YAMAMOTO Mitsuharu
2009-03-24  1:38   ` YAMAMOTO Mitsuharu
2009-03-25  0:20     ` YAMAMOTO Mitsuharu
2009-03-25 16:01       ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.