all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kime <Philip@kime.org.uk>
To: emacs-devel@gnu.org
Subject: Patch to make Emacs.app for OSX visible bell like Carbon Emacs
Date: Mon, 23 Mar 2009 17:49:57 +0100	[thread overview]
Message-ID: <05CDD769-B247-478D-AD4A-6209A710C05D@kime.org.uk> (raw)

[-- 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






             reply	other threads:[~2009-03-23 16:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-23 16:49 Philip Kime [this message]
2009-03-24  1:06 ` Patch to make Emacs.app for OSX visible bell like Carbon Emacs YAMAMOTO Mitsuharu
2009-03-24  1:38   ` YAMAMOTO Mitsuharu
2009-03-25  0:20     ` YAMAMOTO Mitsuharu
2009-03-25 16:01       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05CDD769-B247-478D-AD4A-6209A710C05D@kime.org.uk \
    --to=philip@kime.org.uk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.