* nsterm.h (ns_cursor_types, ns_output.desired_cursor_color)(ns_output.current_cursor, ns_output.desired_cursor) (ns_output.last_inactive, FRAME_CURSOR, FRAME_NEW_CURSOR) (FRAME_NEW_CURSOR_COLOR,): Remove. * nsfns.m (ns_set_cursor_color): Use FRAME_CURSOR_COLOR. (ns_lisp_to_cursor_type, ns_cursor_type_to_lisp): Use core emacs enumeration (HOLLOW_BOX_CURSOR, etc.). * nsterm.m (ns_frame_rehighlight): Remove commented code. (draw_window_cursor): Simplify code. (EmacsView-windowDidBecomeKey:,-windowDidResignKey:): Don't change cursor type. In latter, call rehighlight instead of doing updates manually. (EmacsPrefsController-setPanelFromValues,-setValuesFromPanel): Use core emacs cursor types. * xdisp.c (draw_glyphs): Don't call notice_overwritten_cursor() under NS.

This commit is contained in:
Adrian Robert 2008-10-02 13:57:39 +00:00
parent 2a7bb8823c
commit c8c057ded8
5 changed files with 118 additions and 234 deletions

View file

@ -1,3 +1,25 @@
2008-10-02 Adrian Robert <Adrian.B.Robert@gmail.com>
* nsterm.h (ns_cursor_types, ns_output.desired_cursor_color)
(ns_output.current_cursor, ns_output.desired_cursor)
(ns_output.last_inactive, FRAME_CURSOR, FRAME_NEW_CURSOR)
(FRAME_NEW_CURSOR_COLOR): Remove.
* nsfns.m (ns_set_cursor_color): Use FRAME_CURSOR_COLOR.
(ns_lisp_to_cursor_type, ns_cursor_type_to_lisp): Use core emacs
enumeration (HOLLOW_BOX_CURSOR, etc.).
* nsterm.m (ns_frame_rehighlight): Remove commented code.
(draw_window_cursor): Simplify code.
(EmacsView-windowDidBecomeKey:,-windowDidResignKey:): Don't
change cursor type. In latter, call rehighlight instead of doing
updates manually.
(EmacsPrefsController-setPanelFromValues,-setValuesFromPanel): Use
core emacs cursor types.
* xdisp.c (draw_glyphs): Don't call notice_overwritten_cursor() under
NS.
2008-10-02 Martin Rudalics <rudalics@gmx.at>
* process.c (Faccept_process_output): Fix doc-string.

View file

@ -413,8 +413,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
}
/* FIXME: adapt to generics */
static void
ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
@ -426,8 +424,8 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
error ("Unknown color");
}
[f->output_data.ns->desired_cursor_color release];
f->output_data.ns->desired_cursor_color = [col retain];
[FRAME_CURSOR_COLOR (f) release];
FRAME_CURSOR_COLOR (f) = [col retain];
if (FRAME_VISIBLE_P (f))
{
@ -437,6 +435,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
update_face_from_frame_parameter (f, Qcursor_color, arg);
}
static void
ns_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
@ -906,11 +905,11 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
else if (XTYPE (arg) == Lisp_Symbol)
str = SDATA (SYMBOL_NAME (arg));
else return -1;
if (!strcmp (str, "box")) return filled_box;
if (!strcmp (str, "hollow")) return hollow_box;
if (!strcmp (str, "underscore")) return underscore;
if (!strcmp (str, "bar")) return bar;
if (!strcmp (str, "no")) return no_highlight;
if (!strcmp (str, "box")) return FILLED_BOX_CURSOR;
if (!strcmp (str, "hollow")) return HOLLOW_BOX_CURSOR;
if (!strcmp (str, "hbar")) return HBAR_CURSOR;
if (!strcmp (str, "bar")) return BAR_CURSOR;
if (!strcmp (str, "no")) return NO_CURSOR;
return -1;
}
@ -920,12 +919,12 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
{
switch (arg)
{
case filled_box: return Qbox;
case hollow_box: return intern ("hollow");
case underscore: return intern ("underscore");
case bar: return intern ("bar");
case no_highlight:
default: return intern ("no");
case FILLED_BOX_CURSOR: return Qbox;
case HOLLOW_BOX_CURSOR: return intern ("hollow");
case HBAR_CURSOR: return intern ("hbar");
case BAR_CURSOR: return intern ("bar");
case NO_CURSOR:
default: return intern ("no");
}
}

View file

@ -383,16 +383,6 @@ typedef unsigned long NSUInteger;
========================================================================== */
enum ns_cursor_types
{
no_highlight =0,
filled_box,
hollow_box,
underscore,
bar
};
/* could use list to store these, but rest of emacs has a big infrastructure
for managing a table of bitmap "records" */
struct ns_bitmap_record
@ -560,16 +550,14 @@ struct ns_output
#ifdef __OBJC__
EmacsView *view;
id miniimage;
NSColor *current_cursor_color;
NSColor *desired_cursor_color;
NSColor *cursor_color;
NSColor *foreground_color;
NSColor *background_color;
EmacsToolbar *toolbar;
#else
void *view;
void *miniimage;
void *current_cursor_color;
void *desired_cursor_color;
void *cursor_color;
void *foreground_color;
void *background_color;
void *toolbar;
@ -599,8 +587,6 @@ struct ns_output
Lisp_Object icon_top;
Lisp_Object icon_left;
enum ns_cursor_types current_cursor, desired_cursor;
unsigned char last_inactive;
/* The size of the extra width currently allotted for vertical
scroll bars, in pixels. */
@ -656,12 +642,8 @@ struct x_output
#define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
#define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
#define FRAME_CURSOR(f) ((f)->output_data.ns->current_cursor)
#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->current_cursor_color)
#define FRAME_NEW_CURSOR_COLOR(f) ((f)->output_data.ns->desired_cursor_color)
#define FRAME_NEW_CURSOR(f) ((f)->output_data.ns->desired_cursor)
#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
#define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
#define FRAME_LAST_INACTIVE(f) ((f)->output_data.ns->last_inactive)
#define FRAME_FONT(f) ((f)->output_data.ns->font)

View file

@ -547,7 +547,6 @@ Free a pool and temporary objects it refers to (callable from C)
{
NSView *view = FRAME_NS_VIEW (f);
NSTRACE (ns_update_begin);
/*fprintf (stderr, "\\%p\n", f); */
ns_updating_frame = f;
[view lockFocus];
@ -683,7 +682,7 @@ Free a pool and temporary objects it refers to (callable from C)
the entire window.
-------------------------------------------------------------------------- */
{
NSTRACE (ns_focus);
// NSTRACE (ns_focus);
#ifdef NS_IMPL_GNUSTEP
NSRect u;
if (n == 2)
@ -756,7 +755,7 @@ Free a pool and temporary objects it refers to (callable from C)
Internal: Remove focus on given frame
-------------------------------------------------------------------------- */
{
NSTRACE (ns_unfocus);
// NSTRACE (ns_unfocus);
if (gsaved)
{
@ -957,17 +956,10 @@ Free a pool and temporary objects it refers to (callable from C)
if (dpyinfo->x_highlight_frame &&
dpyinfo->x_highlight_frame != old_highlight)
{
/* as of 20080602 the lower and raise are superfluous */
if (old_highlight)
{
/*ns_lower_frame (old_highlight); */
x_update_cursor (old_highlight, 1);
}
if (dpyinfo->x_highlight_frame)
{
/*ns_raise_frame (dpyinfo->x_highlight_frame); */
x_update_cursor (dpyinfo->x_highlight_frame, 1);
}
}
}
@ -1227,12 +1219,14 @@ Free a pool and temporary objects it refers to (callable from C)
}
/* ==========================================================================
Color management
========================================================================== */
NSColor *
ns_lookup_indexed_color (unsigned long idx, struct frame *f)
{
@ -1665,7 +1659,7 @@ Free a pool and temporary objects it refers to (callable from C)
known as last_mouse_glyph.
------------------------------------------------------------------------ */
{
NSTRACE (note_mouse_movement);
// NSTRACE (note_mouse_movement);
XSETFRAME (last_mouse_motion_frame, frame);
@ -1928,6 +1922,8 @@ Free a pool and temporary objects it refers to (callable from C)
if (!view || !face)
return;
NSTRACE (ns_clear_frame_area);
r = NSIntersectionRect (r, [view frame]);
ns_focus (f, &r, 1);
[ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f) set];
@ -2262,31 +2258,22 @@ Free a pool and temporary objects it refers to (callable from C)
int on_p, int active_p)
/* --------------------------------------------------------------------------
External call (RIF): draw cursor
(modeled after x_draw_window_cursor and erase_phys_cursor.
FIXME: erase_phys_cursor is called from display_and_set_cursor,
called from update_window_cursor/x_update_window_end/...
Why do we have to duplicate this code?
(modeled after x_draw_window_cursor
FIXME: cursor_width is effectively bogus -- it sometimes gets set
in xdisp.c set_frame_cursor_types, sometimes left uninitialized;
DON'T USE IT (no other terms do)
-------------------------------------------------------------------------- */
{
NSRect r, s;
int fx, fy, h;
struct frame *f = WINDOW_XFRAME (w);
struct glyph *phys_cursor_glyph;
int overspill;
char drawGlyph = 0, cursorType, oldCursorType;
int new_cursor_type;
int new_cursor_width;
int active_cursor;
enum draw_glyphs_face hl;
struct glyph_matrix *active_glyphs = w->current_matrix;
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
int hpos = w->phys_cursor.hpos;
int vpos = w->phys_cursor.vpos;
struct glyph_row *cursor_row;
int overspill, cursorToDraw;
NSTRACE (dumpcursor);
//fprintf(stderr, "drawcursor (%d,%d) activep = %d\tonp = %d\tc_type = %d\twidth = %d\n",x,y, active_p,on_p,cursor_type,cursor_width);
if (!on_p) // check this? && !w->phys_cursor_on_p)
if (!on_p)
return;
w->phys_cursor_type = cursor_type;
@ -2294,7 +2281,6 @@ External call (RIF): draw cursor
if (cursor_type == NO_CURSOR)
{
w->phys_cursor_on_p = 0;
w->phys_cursor_width = 0;
return;
}
@ -2324,151 +2310,51 @@ External call (RIF): draw cursor
if (overspill > 0)
r.size.width -= overspill;
oldCursorType = FRAME_CURSOR (f);
cursorType = FRAME_CURSOR (f) = FRAME_NEW_CURSOR (f);
/* TODO: 23: use emacs stored cursor color instead of ns-specific */
f->output_data.ns->current_cursor_color
= f->output_data.ns->desired_cursor_color;
/* 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);
/* ns_focus (f, &r, 1); */
ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */
[FRAME_CURSOR_COLOR (f) set];
/* Why would this be needed?
if (FRAME_LAST_INACTIVE (f))
#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.
One way would be to set a global variable DRAWING_CURSOR
when making the call to draw_phys..(), don't focus in that
case, then move the ns_unfocus() here after that call. */
NSDisableScreenUpdates ();
#endif
cursorToDraw = active_p ? cursor_type : HOLLOW_BOX_CURSOR;
switch (cursorToDraw)
{
* previously hollow box; clear entire area *
[FRAME_BACKGROUND_COLOR (f) set];
case NO_CURSOR:
break;
case FILLED_BOX_CURSOR:
NSRectFill (r);
break;
case HOLLOW_BOX_CURSOR:
NSRectFill (r);
drawGlyph = 1;
FRAME_LAST_INACTIVE (f) = NO;
}
*/
/* prepare to draw */
if (cursorType == no_highlight || cursor_type == NO_CURSOR)
{
/* clearing for blink: erase the cursor itself */
/* No cursor displayed or row invalidated => nothing to do on the
screen. */
if (w->phys_cursor_type == NO_CURSOR)
return;
/* VPOS >= active_glyphs->nrows means that window has been resized.
Don't bother to erase the cursor. */
if (vpos >= active_glyphs->nrows)
return;
/* If row containing cursor is marked invalid, there is nothing we
can do. */
cursor_row = MATRIX_ROW (active_glyphs, vpos);
if (!cursor_row->enabled_p)
return;
/* If line spacing is > 0, old cursor may only be partially visible in
window after split-window. So adjust visible height. */
cursor_row->visible_height = min (cursor_row->visible_height,
window_text_bottom_y (w) - cursor_row->y);
/* If row is completely invisible, don't attempt to delete a cursor which
isn't there. This can happen if cursor is at top of a window, and
we switch to a buffer with a header line in that window. */
if (cursor_row->visible_height <= 0)
return;
/* If cursor is in the fringe, erase by drawing actual bitmap there. */
if (cursor_row->cursor_in_fringe_p)
{
cursor_row->cursor_in_fringe_p = 0;
draw_fringe_bitmap (w, cursor_row, 0);
return;
}
/* This can happen when the new row is shorter than the old one.
In this case, either draw_glyphs or clear_end_of_line
should have cleared the cursor. Note that we wouldn't be
able to erase the cursor in this case because we don't have a
cursor glyph at hand. */
if (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA])
return;
/* If the cursor is in the mouse face area, redisplay that when
we clear the cursor. */
if (! NILP (dpyinfo->mouse_face_window)
&& w == XWINDOW (dpyinfo->mouse_face_window)
&& (vpos > dpyinfo->mouse_face_beg_row
|| (vpos == dpyinfo->mouse_face_beg_row
&& hpos >= dpyinfo->mouse_face_beg_col))
&& (vpos < dpyinfo->mouse_face_end_row
|| (vpos == dpyinfo->mouse_face_end_row
&& hpos < dpyinfo->mouse_face_end_col))
/* Don't redraw the cursor's spot in mouse face if it is at the
end of a line (on a newline). The cursor appears there, but
mouse highlighting does not. */
&& cursor_row->used[TEXT_AREA] > hpos)
hl = DRAW_MOUSE_FACE;
else
hl = DRAW_NORMAL_TEXT;
drawGlyph = 1; // just draw the Glyph
[FRAME_BACKGROUND_COLOR (f) set];
#ifdef NS_IMPL_COCOA
NSDisableScreenUpdates ();
#endif
}
else
{
cursorType = cursor_type;
hl = DRAW_CURSOR;
NSRectFill (NSInsetRect (r, 1, 1));
[FRAME_CURSOR_COLOR (f) set];
if (!active_p)
{
/* inactive window: ignore what we just set and use a hollow box */
cursorType = HOLLOW_BOX_CURSOR;
}
#ifdef NS_IMPL_COCOA
NSDisableScreenUpdates ();
#endif
switch (cursorType)
{
case NO_CURSOR: // no_highlight:
break;
case FILLED_BOX_CURSOR: //filled_box:
NSRectFill (r);
drawGlyph = 1;
break;
case HOLLOW_BOX_CURSOR: //hollow_box:
NSRectFill (r);
[FRAME_BACKGROUND_COLOR (f) set];
NSRectFill (NSInsetRect (r, 1, 1));
[FRAME_CURSOR_COLOR (f) set];
drawGlyph = 1;
break;
case HBAR_CURSOR: // underscore:
s = r;
s.origin.y += lrint (0.75 * s.size.height);
s.size.height = cursor_width; //lrint (s.size.height * 0.25);
NSRectFill (s);
break;
case BAR_CURSOR: //bar:
s = r;
s.size.width = cursor_width;
NSRectFill (s);
drawGlyph = 1;
break;
}
break;
case HBAR_CURSOR:
s = r;
s.origin.y += lrint (0.75 * s.size.height);
s.size.height = lrint (s.size.height * 0.25);
NSRectFill (s);
break;
case BAR_CURSOR:
s = r;
s.size.width = min (cursor_width, 2); //FIXME(see above)
NSRectFill (s);
break;
}
ns_unfocus (f);
/* if needed, draw the character under the cursor */
if (drawGlyph)
draw_phys_cursor_glyph (w, glyph_row, hl);
/* draw the character under the cursor */
if (cursorToDraw != NO_CURSOR)
draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
#ifdef NS_IMPL_COCOA
NSEnableScreenUpdates ();
@ -2487,6 +2373,8 @@ end of a line (on a newline). The cursor appears there, but
struct face *face;
NSRect r = NSMakeRect (x, y0, 2, y1-y0);
NSTRACE (ns_draw_vertical_window_border);
face = FACE_FROM_ID (f, VERTICAL_BORDER_FACE_ID);
if (face)
[ns_lookup_indexed_color(face->foreground, f) set];
@ -2935,7 +2823,7 @@ Function modeled after x_draw_glyph_string_box ().
NSTRACE (ns_draw_glyph_string);
if (s->next && s->right_overhang && !s->for_overlaps/* && s->hl != DRAW_CURSOR*/)
if (s->next && s->right_overhang && !s->for_overlaps/*&&s->hl!=DRAW_CURSOR*/)
{
int width;
struct glyph_string *next;
@ -4376,6 +4264,8 @@ - (void)changeFont: (id)sender
if (newFont = [sender convertFont:
((struct nsfont_info *)face->font)->nsfont])
{
SET_FRAME_GARBAGED (emacsframe); /* now needed as of 2008/10 */
emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
emacs_event->modifiers = 0;
emacs_event->code = KEY_NS_CHANGE_FONT;
@ -4853,7 +4743,7 @@ - (void)mouseMoved: (NSEvent *)e
struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
Lisp_Object frame;
NSTRACE (mouseMoved);
// NSTRACE (mouseMoved);
last_mouse_movement_time = EV_TIMESTAMP (e);
last_mouse_motion_position
@ -5031,8 +4921,8 @@ - (void)windowDidResize: (NSNotification *)notification
- (void)windowDidBecomeKey: (NSNotification *)notification
/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
{
int val = ns_lisp_to_cursor_type (get_frame_param (emacsframe, Qcursor_type));
struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
struct frame *old_focus = dpyinfo->x_focus_frame;
@ -5041,14 +4931,6 @@ - (void)windowDidBecomeKey: (NSNotification *)notification
if (emacsframe != old_focus)
dpyinfo->x_focus_frame = emacsframe;
/*/last_mouse_frame = emacsframe;? */
if (val >= 0)
{
FRAME_NEW_CURSOR (emacsframe) = val;
/* x_update_cursor (emacsframe, 1); // will happen in ns_frame_rehighlight */
}
ns_frame_rehighlight (emacsframe);
if (emacs_event)
@ -5060,27 +4942,20 @@ - (void)windowDidBecomeKey: (NSNotification *)notification
- (void)windowDidResignKey: (NSNotification *)notification
/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
{
struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
NSTRACE (windowDidResignKey);
if (!windowClosing && [[self window] isVisible] == YES)
{
FRAME_NEW_CURSOR (emacsframe) = hollow_box;
x_update_cursor (emacsframe, 1);
FRAME_LAST_INACTIVE (emacsframe) = YES;
}
if (dpyinfo->x_highlight_frame == emacsframe)
dpyinfo->x_highlight_frame = 0;
if (dpyinfo->x_focus_frame == emacsframe)
dpyinfo->x_focus_frame = 0;
if (dpyinfo->mouse_face_mouse_frame == emacsframe)
{
clear_mouse_face (dpyinfo);
dpyinfo->mouse_face_mouse_frame = 0;
}
ns_frame_rehighlight (emacsframe);
/* FIXME: for some reason needed on second and subsequent clicks away
from sole-frame Emacs to get hollow box to show */
if (!windowClosing && [[self window] isVisible] == YES)
x_update_cursor (emacsframe, 1);
if (emacs_event)
{
@ -6084,9 +5959,9 @@ - (void) setPanelFromValues
#endif
[expandSpaceSlider setFloatValue: prevExpandSpace];
[cursorTypeMatrix selectCellWithTag: (cursorType == filled_box ? 1 :
(cursorType == bar ? 2 :
(cursorType == underscore ? 3 : 4)))];
[cursorTypeMatrix selectCellWithTag: (cursorType == FILLED_BOX_CURSOR ? 1 :
(cursorType == BAR_CURSOR ? 2 :
(cursorType == HBAR_CURSOR ? 3 : 4)))];
selectItemWithTag (alternateModMenu,
parse_solitary_modifier (ns_alternate_modifier));
selectItemWithTag (commandModMenu,
@ -6105,7 +5980,6 @@ - (void) setPanelFromValues
- (void) setValuesFromPanel
{
int cursorTag = [[cursorTypeMatrix selectedCell] tag];
int altTag = [[alternateModMenu selectedItem] tag];
int cmdTag = [[commandModMenu selectedItem] tag];
#ifdef NS_IMPL_COCOA
@ -6113,6 +5987,11 @@ - (void) setValuesFromPanel
int fnTag = [[functionModMenu selectedItem] tag];
#endif
float expandSpace = [expandSpaceSlider floatValue];
int cursorTag = [[cursorTypeMatrix selectedCell] tag];
Lisp_Object cursor_type = ns_cursor_type_to_lisp
( cursorTag == 1 ? FILLED_BOX_CURSOR
: cursorTag == 2 ? BAR_CURSOR
: cursorTag == 3 ? HBAR_CURSOR : HOLLOW_BOX_CURSOR);
if (expandSpace != prevExpandSpace)
{
@ -6123,12 +6002,10 @@ - (void) setValuesFromPanel
x_set_window_size (frame, 0, frame->text_cols, frame->text_lines); */
prevExpandSpace = expandSpace;
}
FRAME_NEW_CURSOR (frame)
= (cursorTag == 1 ? filled_box
: cursorTag == 2 ? bar
: cursorTag == 3 ? underscore : hollow_box);
store_frame_param (frame, Qcursor_type,
ns_cursor_type_to_lisp (FRAME_NEW_CURSOR (frame)));
store_frame_param (frame, Qcursor_type, cursor_type);
ns_set_cursor_type(frame, cursor_type, Qnil); /* FIXME: do only if changed */
ns_alternate_modifier = ns_mod_to_lisp (altTag);
ns_command_modifier = ns_mod_to_lisp (cmdTag);
#ifdef NS_IMPL_COCOA

View file

@ -20503,6 +20503,9 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
for (s = head; s; s = s->next)
FRAME_RIF (f)->draw_glyph_string (s);
#ifndef HAVE_NS
/* When focus a sole frame and move horizontally, this sets on_p to 0
causing a failure to erase prev cursor position. */
if (area == TEXT_AREA
&& !row->full_width_p
/* When drawing overlapping rows, only the glyph strings'
@ -20519,6 +20522,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
notice_overwritten_cursor (w, TEXT_AREA, x0, x1,
row->y, MATRIX_ROW_BOTTOM_Y (row));
}
#endif
/* Value is the x-position up to which drawn, relative to AREA of W.
This doesn't include parts drawn because of overhangs. */