unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* patch: bug #4831 part 2
@ 2010-07-23 18:45 Will Roberts
  0 siblings, 0 replies; only message in thread
From: Will Roberts @ 2010-07-23 18:45 UTC (permalink / raw)
  To: emacs-devel

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

Hello:

This is my first patch submission to Emacs.  I'd be happy to learn how to do it better in the future, if you have any comments or criticism.  The patch was made against the bazaar repository.

Thanks,
Will

== Description: ==

A first draft at patching bug #4831 (23.1.50; cursor problems on Mac OS X), specifically part 2, where characters under the cursor are not seen.

Modified the drawing routines: 
* the cursor will be drawn with the frame foreground color if the cursor color is the same as the current face background color or the frame background color.
* the text over the cursor will be drawn with the frame background color if the cursor is a filled box, and the cursor color is the same as the text color

== Copyright ==

I happily assign copyright for this code to the FSF.  Please do with it what you like.

== src/ChangeLog: ==

2010-07-23  Will Roberts  <wildwilhelm@gmail.com>

        * nsfont.m (nsfont_draw): Change the text color if needed to be
        distinct from the cursor color

        * nsterm.m (ns_draw_window_cursor): Change the cursor color to be
        distinct from the text color


[-- Attachment #2: ns-cursor.patch --]
[-- Type: application/octet-stream, Size: 3498 bytes --]

=== modified file 'src/nsfont.m'
*** src/nsfont.m	2010-07-07 22:18:28 +0000
--- src/nsfont.m	2010-07-23 18:20:12 +0000
*************** nsfont_draw (struct glyph_string *s, int
*** 1168,1173 ****
--- 1168,1205 ----
                ? ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), s->f)
                : FRAME_BACKGROUND_COLOR (s->f)));
  
+   // change character color if we're drawing the cursor, the cursor
+   // covers the text, and the cursor is the same color as the text
+   if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR)
+     {
+       // maybe the cursor itself is modified because of the face
+       // background?
+       if (ns_index_color (FRAME_CURSOR_COLOR (s->f), s->f) ==
+           ns_index_color (FRAME_BACKGROUND_COLOR (s->f), s->f) ||
+           ns_index_color (FRAME_CURSOR_COLOR (s->f), s->f) ==
+           NS_FACE_BACKGROUND (face))
+         {
+           // cursor is set to frame foreground color, set the text to
+           // frame background
+           col = FRAME_BACKGROUND_COLOR(s->f);
+         }
+       else
+         {
+           // otherwise, if the text foreground color is the same as
+           // the cursor color,
+           unsigned faceFgId = (NS_FACE_FOREGROUND (face) != 0 ?
+                                NS_FACE_FOREGROUND (face) :
+                                ns_index_color (FRAME_FOREGROUND_COLOR (s->f),
+                                                s->f));
+           if (ns_index_color (FRAME_CURSOR_COLOR (s->f), s->f) == faceFgId)
+             {
+               // cursor is the same as the face foreground, set the
+               // text to frame background
+               col = FRAME_BACKGROUND_COLOR(s->f);
+             }
+         }
+     }
+ 
    /* render under GNUstep using DPS */
  #ifdef NS_IMPL_GNUSTEP
    {

=== modified file 'src/nsterm.m'
*** src/nsterm.m	2010-07-10 18:52:53 +0000
--- src/nsterm.m	2010-07-23 18:21:20 +0000
*************** ns_draw_window_cursor (struct window *w,
*** 2288,2295 ****
    /* TODO: only needed in rare cases with last-resort font in HELLO..
       should we do this more efficiently? */
    ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */
!   [FRAME_CURSOR_COLOR (f) set];
! 
  #ifdef NS_IMPL_COCOA
    /* TODO: This makes drawing of cursor plus that of phys_cursor_glyph
             atomic.  Cleaner ways of doing this should be investigated.
--- 2288,2315 ----
    /* TODO: only needed in rare cases with last-resort font in HELLO..
       should we do this more efficiently? */
    ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */
!     
!   /* make sure the cursor is distinct from the text background */
!   struct face *textFace;
!   textFace = FACE_FROM_ID (f, phys_cursor_glyph->face_id);
!   if (ns_index_color (FRAME_CURSOR_COLOR (f), f) ==
! 	  ns_index_color (FRAME_BACKGROUND_COLOR (f), f) ||
! 	  (textFace != NULL && ns_index_color (FRAME_CURSOR_COLOR (f), f) ==
! 	   NS_FACE_BACKGROUND (textFace)))
! 	{
! 	  NSColor *alternateCursorColor;
! 	  {
! 		alternateCursorColor = FRAME_FOREGROUND_COLOR(f);
! 	  }
! 	  if (!alternateCursorColor)
! 		alternateCursorColor = FRAME_CURSOR_COLOR (f);
! 	  [alternateCursorColor set];
! 	}
!   else
! 	{
! 	  [FRAME_CURSOR_COLOR (f) set];
! 	}
!       
  #ifdef NS_IMPL_COCOA
    /* TODO: This makes drawing of cursor plus that of phys_cursor_glyph
             atomic.  Cleaner ways of doing this should be investigated.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-23 18:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-23 18:45 patch: bug #4831 part 2 Will Roberts

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).