aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBen Key2011-02-23 15:41:43 -0500
committerChong Yidong2011-02-23 15:41:43 -0500
commit2c6584e8174f9ea276d0fae13e1a5f7d29f61d53 (patch)
tree0afb405fc8fd952bce58e78f3884ded1b580c36b /src
parent53cfe624fc93b0f8aea0747f4d3493881404e77f (diff)
downloademacs-2c6584e8174f9ea276d0fae13e1a5f7d29f61d53.tar.gz
emacs-2c6584e8174f9ea276d0fae13e1a5f7d29f61d53.zip
Fix handling of bar cursors in NS terminal.
* nsterm.m (ns_draw_window_cursor): Obey the cursor_width argument directly, for bar cursors. * xdisp.c (set_frame_cursor_types): Don't write an undefined value into the frame's cursor_width.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/nsterm.m52
-rw-r--r--src/xdisp.c2
3 files changed, 41 insertions, 23 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3d22e15c3b3..ea1510b33db 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12011-02-23 Ben Key <bkey76@gmail.com> (tiny change)
2
3 * nsterm.m (ns_draw_window_cursor): Obey the cursor_width argument
4 directly, for bar cursors.
5
62011-02-23 Chong Yidong <cyd@stupidchicken.com>
7
8 * xdisp.c (set_frame_cursor_types): Don't write an undefined value
9 into the frame's cursor_width.
10
12011-02-23 Stefan Monnier <monnier@iro.umontreal.ca> 112011-02-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 12
3 * print.c (print_object): Never print old-style backquotes. 13 * print.c (print_object): Never print old-style backquotes.
diff --git a/src/nsterm.m b/src/nsterm.m
index 038709869a9..8e77c89c3f7 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1072,7 +1072,7 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
1072 : f->left_pos; 1072 : f->left_pos;
1073 /* We use visibleFrame here to take menu bar into account. 1073 /* We use visibleFrame here to take menu bar into account.
1074 Ideally we should also adjust left/top with visibleFrame.origin. */ 1074 Ideally we should also adjust left/top with visibleFrame.origin. */
1075 1075
1076 f->top_pos = f->size_hint_flags & YNegative 1076 f->top_pos = f->size_hint_flags & YNegative
1077 ? ([screen visibleFrame].size.height + f->top_pos 1077 ? ([screen visibleFrame].size.height + f->top_pos
1078 - FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f) 1078 - FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f)
@@ -1154,7 +1154,7 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
1154 FRAME_TOOLBAR_HEIGHT (f) = 0; 1154 FRAME_TOOLBAR_HEIGHT (f) = 0;
1155 1155
1156 wr.size.width = pixelwidth + f->border_width; 1156 wr.size.width = pixelwidth + f->border_width;
1157 wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f) 1157 wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f)
1158 + FRAME_TOOLBAR_HEIGHT (f); 1158 + FRAME_TOOLBAR_HEIGHT (f);
1159 1159
1160 /* Do not try to constrain to this screen. We may have multiple 1160 /* Do not try to constrain to this screen. We may have multiple
@@ -2230,11 +2230,8 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2230 int x, int y, int cursor_type, int cursor_width, 2230 int x, int y, int cursor_type, int cursor_width,
2231 int on_p, int active_p) 2231 int on_p, int active_p)
2232/* -------------------------------------------------------------------------- 2232/* --------------------------------------------------------------------------
2233 External call (RIF): draw cursor 2233 External call (RIF): draw cursor.
2234 (modeled after x_draw_window_cursor 2234 Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
2235 FIXME: cursor_width is effectively bogus -- it sometimes gets set
2236 in xdisp.c set_frame_cursor_types, sometimes left uninitialized;
2237 DON'T USE IT (no other terms do)
2238 -------------------------------------------------------------------------- */ 2235 -------------------------------------------------------------------------- */
2239{ 2236{
2240 NSRect r, s; 2237 NSRect r, s;
@@ -2251,7 +2248,6 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2251 and mini-buffer. */ 2248 and mini-buffer. */
2252 2249
2253 NSTRACE (dumpcursor); 2250 NSTRACE (dumpcursor);
2254//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);
2255 2251
2256 if (!on_p) 2252 if (!on_p)
2257 return; 2253 return;
@@ -2276,8 +2272,22 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2276 return; 2272 return;
2277 } 2273 }
2278 2274
2275 /* We draw the cursor (with NSRectFill), then draw the glyph on top
2276 (other terminals do it the other way round). We must set
2277 w->phys_cursor_width to the cursor width. For bar cursors, that
2278 is CURSOR_WIDTH; for box cursors, it is the glyph width. */
2279 get_phys_cursor_geometry (w, glyph_row, phys_cursor_glyph, &fx, &fy, &h); 2279 get_phys_cursor_geometry (w, glyph_row, phys_cursor_glyph, &fx, &fy, &h);
2280 2280
2281 /* The above get_phys_cursor_geometry call set w->phys_cursor_width
2282 to the glyph width; replace with CURSOR_WIDTH for bar cursors. */
2283 if (cursor_type == BAR_CURSOR || cursor_type == HBAR_CURSOR)
2284 {
2285 if (cursor_width < 0)
2286 cursor_width = FRAME_CURSOR_WIDTH (f);
2287 cursor_width = min (cursor_width, 1);
2288 w->phys_cursor_width = cursor_width;
2289 }
2290
2281 r.origin.x = fx, r.origin.y = fy; 2291 r.origin.x = fx, r.origin.y = fy;
2282 r.size.height = h; 2292 r.size.height = h;
2283 r.size.width = w->phys_cursor_width; 2293 r.size.width = w->phys_cursor_width;
@@ -2285,7 +2295,7 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2285 /* FIXME: if we overwrite the internal border area, it does not get erased; 2295 /* FIXME: if we overwrite the internal border area, it does not get erased;
2286 fix by truncating cursor, but better would be to erase properly */ 2296 fix by truncating cursor, but better would be to erase properly */
2287 overspill = r.origin.x + r.size.width - 2297 overspill = r.origin.x + r.size.width -
2288 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, WINDOW_BOX_RIGHT_EDGE_X (w) 2298 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, WINDOW_BOX_RIGHT_EDGE_X (w)
2289 - WINDOW_TOTAL_FRINGE_WIDTH (w) - FRAME_INTERNAL_BORDER_WIDTH (f)); 2299 - WINDOW_TOTAL_FRINGE_WIDTH (w) - FRAME_INTERNAL_BORDER_WIDTH (f));
2290 if (overspill > 0) 2300 if (overspill > 0)
2291 r.size.width -= overspill; 2301 r.size.width -= overspill;
@@ -2335,8 +2345,6 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2335 break; 2345 break;
2336 case BAR_CURSOR: 2346 case BAR_CURSOR:
2337 s = r; 2347 s = r;
2338 s.size.width = min (cursor_width, 2); //FIXME(see above)
2339
2340 /* If the character under cursor is R2L, draw the bar cursor 2348 /* If the character under cursor is R2L, draw the bar cursor
2341 on the right of its glyph, rather than on the left. */ 2349 on the right of its glyph, rather than on the left. */
2342 cursor_glyph = get_phys_cursor_glyph (w); 2350 cursor_glyph = get_phys_cursor_glyph (w);
@@ -2984,7 +2992,7 @@ ns_draw_glyph_string (struct glyph_string *s)
2984 NS_FACE_BACKGROUND (s->face) = NS_FACE_FOREGROUND (s->face); 2992 NS_FACE_BACKGROUND (s->face) = NS_FACE_FOREGROUND (s->face);
2985 NS_FACE_FOREGROUND (s->face) = tmp; 2993 NS_FACE_FOREGROUND (s->face) = tmp;
2986 } 2994 }
2987 2995
2988 ns_tmp_font->font.driver->draw 2996 ns_tmp_font->font.driver->draw
2989 (s, 0, s->nchars, s->x, s->y, 2997 (s, 0, s->nchars, s->x, s->y,
2990 (ns_tmp_flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p) 2998 (ns_tmp_flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p)
@@ -3010,9 +3018,9 @@ ns_draw_glyph_string (struct glyph_string *s)
3010 else 3018 else
3011 ns_maybe_dumpglyphs_background 3019 ns_maybe_dumpglyphs_background
3012 (s, s->first_glyph->type == COMPOSITE_GLYPH); 3020 (s, s->first_glyph->type == COMPOSITE_GLYPH);
3013 /* ... */ 3021 /* ... */
3014 /* Not yet implemented. */ 3022 /* Not yet implemented. */
3015 /* ... */ 3023 /* ... */
3016 ns_unfocus (s->f); 3024 ns_unfocus (s->f);
3017 break; 3025 break;
3018 3026
@@ -3785,7 +3793,7 @@ ns_term_init (Lisp_Object display_name)
3785 strncpy (terminal->name, SDATA (display_name), SBYTES (display_name)); 3793 strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
3786 terminal->name[SBYTES (display_name)] = 0; 3794 terminal->name[SBYTES (display_name)] = 0;
3787 3795
3788 UNBLOCK_INPUT; 3796 UNBLOCK_INPUT;
3789 3797
3790 if (!inhibit_x_resources) 3798 if (!inhibit_x_resources)
3791 { 3799 {
@@ -3802,7 +3810,7 @@ ns_term_init (Lisp_Object display_name)
3802 stringForKey: @"AppleHighlightColor"]; 3810 stringForKey: @"AppleHighlightColor"];
3803 if (ns_selection_color == nil) 3811 if (ns_selection_color == nil)
3804 ns_selection_color = NS_SELECTION_COLOR_DEFAULT; 3812 ns_selection_color = NS_SELECTION_COLOR_DEFAULT;
3805 3813
3806 { 3814 {
3807 NSColorList *cl = [NSColorList colorListNamed: @"Emacs"]; 3815 NSColorList *cl = [NSColorList colorListNamed: @"Emacs"];
3808 3816
@@ -3898,7 +3906,7 @@ ns_term_init (Lisp_Object display_name)
3898 keyEquivalent: @"q" 3906 keyEquivalent: @"q"
3899 atIndex: 9]; 3907 atIndex: 9];
3900 3908
3901 item = [mainMenu insertItemWithTitle: ns_app_name 3909 item = [mainMenu insertItemWithTitle: ns_app_name
3902 action: @selector (menuDown:) 3910 action: @selector (menuDown:)
3903 keyEquivalent: @"" 3911 keyEquivalent: @""
3904 atIndex: 0]; 3912 atIndex: 0];
@@ -4103,7 +4111,7 @@ ns_term_shutdown (int sig)
4103 -appShouldTerminate 4111 -appShouldTerminate
4104 Cancel -> Nothing else 4112 Cancel -> Nothing else
4105 Accept -> 4113 Accept ->
4106 4114
4107 -terminate 4115 -terminate
4108 KEY_NS_POWER_OFF, (save-buffers-kill-emacs) 4116 KEY_NS_POWER_OFF, (save-buffers-kill-emacs)
4109 ns_term_shutdown() 4117 ns_term_shutdown()
@@ -4113,10 +4121,10 @@ ns_term_shutdown (int sig)
4113- (void) terminate: (id)sender 4121- (void) terminate: (id)sender
4114{ 4122{
4115 struct frame *emacsframe = SELECTED_FRAME (); 4123 struct frame *emacsframe = SELECTED_FRAME ();
4116 4124
4117 if (!emacs_event) 4125 if (!emacs_event)
4118 return; 4126 return;
4119 4127
4120 emacs_event->kind = NS_NONKEY_EVENT; 4128 emacs_event->kind = NS_NONKEY_EVENT;
4121 emacs_event->code = KEY_NS_POWER_OFF; 4129 emacs_event->code = KEY_NS_POWER_OFF;
4122 emacs_event->arg = Qt; /* mark as non-key event */ 4130 emacs_event->arg = Qt; /* mark as non-key event */
@@ -4418,7 +4426,7 @@ ns_term_shutdown (int sig)
4418 code = ([[theEvent charactersIgnoringModifiers] length] == 0) ? 4426 code = ([[theEvent charactersIgnoringModifiers] length] == 0) ?
4419 0 : [[theEvent charactersIgnoringModifiers] characterAtIndex: 0]; 4427 0 : [[theEvent charactersIgnoringModifiers] characterAtIndex: 0];
4420 /* (Carbon way: [theEvent keyCode]) */ 4428 /* (Carbon way: [theEvent keyCode]) */
4421 4429
4422 /* is it a "function key"? */ 4430 /* is it a "function key"? */
4423 fnKeysym = ns_convert_key (code); 4431 fnKeysym = ns_convert_key (code);
4424 if (fnKeysym) 4432 if (fnKeysym)
@@ -5446,7 +5454,7 @@ ns_term_shutdown (int sig)
5446 5454
5447 /* 5455 /*
5448 drawRect: may be called (at least in OS X 10.5) for invisible 5456 drawRect: may be called (at least in OS X 10.5) for invisible
5449 views as well for some reason. Thus, do not infer visibility 5457 views as well for some reason. Thus, do not infer visibility
5450 here. 5458 here.
5451 5459
5452 emacsframe->async_visible = 1; 5460 emacsframe->async_visible = 1;
diff --git a/src/xdisp.c b/src/xdisp.c
index e144237d34e..35f4859f1b3 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -23252,7 +23252,7 @@ get_specified_cursor_type (Lisp_Object arg, int *width)
23252void 23252void
23253set_frame_cursor_types (struct frame *f, Lisp_Object arg) 23253set_frame_cursor_types (struct frame *f, Lisp_Object arg)
23254{ 23254{
23255 int width; 23255 int width = 1;
23256 Lisp_Object tem; 23256 Lisp_Object tem;
23257 23257
23258 FRAME_DESIRED_CURSOR (f) = get_specified_cursor_type (arg, &width); 23258 FRAME_DESIRED_CURSOR (f) = get_specified_cursor_type (arg, &width);