aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2004-03-01 23:55:52 +0000
committerKim F. Storm2004-03-01 23:55:52 +0000
commit351b5434f9c4a242fdc5494ee8d0128f5baa4120 (patch)
treeb1c57b36ff707b8dcc9d90b766904f5af8d93e05 /src
parentc1464661891126fccf9e5b6a0e962e05fc4c254f (diff)
downloademacs-351b5434f9c4a242fdc5494ee8d0128f5baa4120.tar.gz
emacs-351b5434f9c4a242fdc5494ee8d0128f5baa4120.zip
(Voverlay_arrow_variable_list): New variable to properly
implement and integrate multiple overlay arrows with redisplay. (syms_of_xdisp): DEFVAR_LISP and initialize it. (last_arrow_position, last_arrow_string): Replace by properties. (Qlast_arrow_position, Qlast_arrow_string) (Qoverlay_arrow_string, Qoverlay_arrow_bitmap): New variables. (syms_of_xdisp): Intern and staticpro them. (overlay_arrow_string_or_property, update_overlay_arrows) (overlay_arrow_in_current_buffer_p, overlay_arrows_changed_p) (overlay_arrow_at_row): New functions for multiple overlay arrows. (redisplay_internal): Use them instead of directly accessing Voverlay_arrow_position etc. for multiple overlay arrows. (mark_window_display_accurate): Use update_overlay_arrows. (try_cursor_movement): Use overlay_arrow_in_current_buffer_p. (try_window_id): Use overlay_arrows_changed_p. (get_overlay_arrow_glyph_row): Add overlay_arrow_string arg. (display_line): Use overlay_arrow_at_row to check multiple overlay arrows, and get relevant overlay-arrow-string and overlay-arrow-bitmap. Set w->overlay_arrow_bitmap accordingly. (produce_image_glyph): Set pixel_width = 0 for fringe bitmap. (syms_of_xdisp): Remove last_arrow_position and last_arrow_string.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c245
1 files changed, 208 insertions, 37 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index a1bd50001c4..7fbe6c1b930 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -403,6 +403,13 @@ int multiple_frames;
403 403
404Lisp_Object Vglobal_mode_string; 404Lisp_Object Vglobal_mode_string;
405 405
406
407/* List of variables (symbols) which hold markers for overlay arrows.
408 The symbols on this list are examined during redisplay to determine
409 where to display overlay arrows. */
410
411Lisp_Object Voverlay_arrow_variable_list;
412
406/* Marker for where to display an arrow on top of the buffer text. */ 413/* Marker for where to display an arrow on top of the buffer text. */
407 414
408Lisp_Object Voverlay_arrow_position; 415Lisp_Object Voverlay_arrow_position;
@@ -411,11 +418,17 @@ Lisp_Object Voverlay_arrow_position;
411 418
412Lisp_Object Voverlay_arrow_string; 419Lisp_Object Voverlay_arrow_string;
413 420
414/* Values of those variables at last redisplay. However, if 421/* Values of those variables at last redisplay are stored as
415 Voverlay_arrow_position is a marker, last_arrow_position is its 422 properties on `overlay-arrow-position' symbol. However, if
423 Voverlay_arrow_position is a marker, last-arrow-position is its
416 numerical position. */ 424 numerical position. */
417 425
418static Lisp_Object last_arrow_position, last_arrow_string; 426Lisp_Object Qlast_arrow_position, Qlast_arrow_string;
427
428/* Alternative overlay-arrow-string and overlay-arrow-bitmap
429 properties on a symbol in overlay-arrow-variable-list. */
430
431Lisp_Object Qoverlay_arrow_string, Qoverlay_arrow_bitmap;
419 432
420/* Like mode-line-format, but for the title bar on a visible frame. */ 433/* Like mode-line-format, but for the title bar on a visible frame. */
421 434
@@ -832,7 +845,8 @@ static struct text_pos display_prop_end P_ ((struct it *, Lisp_Object,
832static int compute_window_start_on_continuation_line P_ ((struct window *)); 845static int compute_window_start_on_continuation_line P_ ((struct window *));
833static Lisp_Object safe_eval_handler P_ ((Lisp_Object)); 846static Lisp_Object safe_eval_handler P_ ((Lisp_Object));
834static void insert_left_trunc_glyphs P_ ((struct it *)); 847static void insert_left_trunc_glyphs P_ ((struct it *));
835static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *)); 848static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *,
849 Lisp_Object));
836static void extend_face_to_end_of_line P_ ((struct it *)); 850static void extend_face_to_end_of_line P_ ((struct it *));
837static int append_space P_ ((struct it *, int)); 851static int append_space P_ ((struct it *, int));
838static int make_cursor_line_fully_visible P_ ((struct window *)); 852static int make_cursor_line_fully_visible P_ ((struct window *));
@@ -9320,6 +9334,153 @@ redisplay ()
9320} 9334}
9321 9335
9322 9336
9337static Lisp_Object
9338overlay_arrow_string_or_property (var, pbitmap)
9339 Lisp_Object var;
9340 int *pbitmap;
9341{
9342 Lisp_Object pstr = Fget (var, Qoverlay_arrow_string);
9343 Lisp_Object bitmap;
9344
9345 if (pbitmap)
9346 {
9347 *pbitmap = 0;
9348 if (bitmap = Fget (var, Qoverlay_arrow_bitmap), INTEGERP (bitmap))
9349 *pbitmap = XINT (bitmap);
9350 }
9351
9352 if (!NILP (pstr))
9353 return pstr;
9354 return Voverlay_arrow_string;
9355}
9356
9357/* Return 1 if there are any overlay-arrows in current_buffer. */
9358static int
9359overlay_arrow_in_current_buffer_p ()
9360{
9361 Lisp_Object vlist;
9362
9363 for (vlist = Voverlay_arrow_variable_list;
9364 CONSP (vlist);
9365 vlist = XCDR (vlist))
9366 {
9367 Lisp_Object var = XCAR (vlist);
9368 Lisp_Object val;
9369
9370 if (!SYMBOLP (var))
9371 continue;
9372 val = find_symbol_value (var);
9373 if (MARKERP (val)
9374 && current_buffer == XMARKER (val)->buffer)
9375 return 1;
9376 }
9377 return 0;
9378}
9379
9380
9381/* Return 1 if any overlay_arrows have moved or overlay-arrow-string
9382 has changed. */
9383
9384static int
9385overlay_arrows_changed_p ()
9386{
9387 Lisp_Object vlist;
9388
9389 for (vlist = Voverlay_arrow_variable_list;
9390 CONSP (vlist);
9391 vlist = XCDR (vlist))
9392 {
9393 Lisp_Object var = XCAR (vlist);
9394 Lisp_Object val, pstr;
9395
9396 if (!SYMBOLP (var))
9397 continue;
9398 val = find_symbol_value (var);
9399 if (!MARKERP (val))
9400 continue;
9401 if (! EQ (COERCE_MARKER (val),
9402 Fget (var, Qlast_arrow_position))
9403 || ! (pstr = overlay_arrow_string_or_property (var, 0),
9404 EQ (pstr, Fget (var, Qlast_arrow_string))))
9405 return 1;
9406 }
9407 return 0;
9408}
9409
9410/* Mark overlay arrows to be updated on next redisplay. */
9411
9412static void
9413update_overlay_arrows (up_to_date)
9414 int up_to_date;
9415{
9416 Lisp_Object vlist;
9417
9418 for (vlist = Voverlay_arrow_variable_list;
9419 CONSP (vlist);
9420 vlist = XCDR (vlist))
9421 {
9422 Lisp_Object var = XCAR (vlist);
9423 Lisp_Object val;
9424
9425 if (!SYMBOLP (var))
9426 continue;
9427
9428 if (up_to_date)
9429 {
9430 Fput (var, Qlast_arrow_position,
9431 COERCE_MARKER (find_symbol_value (var)));
9432 Fput (var, Qlast_arrow_string,
9433 overlay_arrow_string_or_property (var, 0));
9434 }
9435 else if (up_to_date < 0
9436 || !NILP (Fget (var, Qlast_arrow_position)))
9437 {
9438 Fput (var, Qlast_arrow_position, Qt);
9439 Fput (var, Qlast_arrow_string, Qt);
9440 }
9441 }
9442}
9443
9444
9445/* Return overlay arrow string at row, or nil. */
9446
9447static Lisp_Object
9448overlay_arrow_at_row (f, row, pbitmap)
9449 struct frame *f;
9450 struct glyph_row *row;
9451 int *pbitmap;
9452{
9453 Lisp_Object vlist;
9454
9455 for (vlist = Voverlay_arrow_variable_list;
9456 CONSP (vlist);
9457 vlist = XCDR (vlist))
9458 {
9459 Lisp_Object var = XCAR (vlist);
9460 Lisp_Object val;
9461
9462 if (!SYMBOLP (var))
9463 continue;
9464
9465 val = find_symbol_value (var);
9466
9467 if (MARKERP (val)
9468 && current_buffer == XMARKER (val)->buffer
9469 && (MATRIX_ROW_START_CHARPOS (row) == marker_position (val)))
9470 {
9471 val = overlay_arrow_string_or_property (var, pbitmap);
9472 if (FRAME_WINDOW_P (f))
9473 return Qt;
9474 else if (STRINGP (val))
9475 return val;
9476 break;
9477 }
9478 }
9479
9480 *pbitmap = 0;
9481 return Qnil;
9482}
9483
9323/* Return 1 if point moved out of or into a composition. Otherwise 9484/* Return 1 if point moved out of or into a composition. Otherwise
9324 return 0. PREV_BUF and PREV_PT are the last point buffer and 9485 return 0. PREV_BUF and PREV_PT are the last point buffer and
9325 position. BUF and PT are the current point buffer and position. */ 9486 position. BUF and PT are the current point buffer and position. */
@@ -9599,8 +9760,7 @@ redisplay_internal (preserve_echo_area)
9599 9760
9600 /* If specs for an arrow have changed, do thorough redisplay 9761 /* If specs for an arrow have changed, do thorough redisplay
9601 to ensure we remove any arrow that should no longer exist. */ 9762 to ensure we remove any arrow that should no longer exist. */
9602 if (! EQ (COERCE_MARKER (Voverlay_arrow_position), last_arrow_position) 9763 if (overlay_arrows_changed_p ())
9603 || ! EQ (Voverlay_arrow_string, last_arrow_string))
9604 consider_all_windows_p = windows_or_buffers_changed = 1; 9764 consider_all_windows_p = windows_or_buffers_changed = 1;
9605 9765
9606 /* Normally the message* functions will have already displayed and 9766 /* Normally the message* functions will have already displayed and
@@ -10060,11 +10220,7 @@ redisplay_internal (preserve_echo_area)
10060 CHARPOS (this_line_start_pos) = 0; 10220 CHARPOS (this_line_start_pos) = 0;
10061 10221
10062 /* Let the overlay arrow be updated the next time. */ 10222 /* Let the overlay arrow be updated the next time. */
10063 if (!NILP (last_arrow_position)) 10223 update_overlay_arrows (0);
10064 {
10065 last_arrow_position = Qt;
10066 last_arrow_string = Qt;
10067 }
10068 10224
10069 /* If we pause after scrolling, some rows in the current 10225 /* If we pause after scrolling, some rows in the current
10070 matrices of some windows are not valid. */ 10226 matrices of some windows are not valid. */
@@ -10080,8 +10236,8 @@ redisplay_internal (preserve_echo_area)
10080 consider_all_windows_p is set. */ 10236 consider_all_windows_p is set. */
10081 mark_window_display_accurate_1 (w, 1); 10237 mark_window_display_accurate_1 (w, 1);
10082 10238
10083 last_arrow_position = COERCE_MARKER (Voverlay_arrow_position); 10239 /* Say overlay arrows are up to date. */
10084 last_arrow_string = Voverlay_arrow_string; 10240 update_overlay_arrows (1);
10085 10241
10086 if (frame_up_to_date_hook != 0) 10242 if (frame_up_to_date_hook != 0)
10087 frame_up_to_date_hook (sf); 10243 frame_up_to_date_hook (sf);
@@ -10277,16 +10433,14 @@ mark_window_display_accurate (window, accurate_p)
10277 10433
10278 if (accurate_p) 10434 if (accurate_p)
10279 { 10435 {
10280 last_arrow_position = COERCE_MARKER (Voverlay_arrow_position); 10436 update_overlay_arrows (1);
10281 last_arrow_string = Voverlay_arrow_string;
10282 } 10437 }
10283 else 10438 else
10284 { 10439 {
10285 /* Force a thorough redisplay the next time by setting 10440 /* Force a thorough redisplay the next time by setting
10286 last_arrow_position and last_arrow_string to t, which is 10441 last_arrow_position and last_arrow_string to t, which is
10287 unequal to any useful value of Voverlay_arrow_... */ 10442 unequal to any useful value of Voverlay_arrow_... */
10288 last_arrow_position = Qt; 10443 update_overlay_arrows (-1);
10289 last_arrow_string = Qt;
10290 } 10444 }
10291} 10445}
10292 10446
@@ -11037,8 +11191,7 @@ try_cursor_movement (window, startp, scroll_step)
11037 && INTEGERP (w->window_end_vpos) 11191 && INTEGERP (w->window_end_vpos)
11038 && XFASTINT (w->window_end_vpos) < w->current_matrix->nrows 11192 && XFASTINT (w->window_end_vpos) < w->current_matrix->nrows
11039 && (FRAME_WINDOW_P (f) 11193 && (FRAME_WINDOW_P (f)
11040 || !MARKERP (Voverlay_arrow_position) 11194 || !overlay_arrow_in_current_buffer_p ()))
11041 || current_buffer != XMARKER (Voverlay_arrow_position)->buffer))
11042 { 11195 {
11043 int this_scroll_margin; 11196 int this_scroll_margin;
11044 struct glyph_row *row = NULL; 11197 struct glyph_row *row = NULL;
@@ -12787,8 +12940,7 @@ try_window_id (w)
12787 GIVE_UP (10); 12940 GIVE_UP (10);
12788 12941
12789 /* Can use this if overlay arrow position and or string have changed. */ 12942 /* Can use this if overlay arrow position and or string have changed. */
12790 if (!EQ (last_arrow_position, COERCE_MARKER (Voverlay_arrow_position)) 12943 if (overlay_arrows_changed_p ())
12791 || !EQ (last_arrow_string, Voverlay_arrow_string))
12792 GIVE_UP (12); 12944 GIVE_UP (12);
12793 12945
12794 12946
@@ -13725,14 +13877,15 @@ usage: (trace-to-stderr STRING &rest OBJECTS) */)
13725 arrow. Only used for non-window-redisplay windows. */ 13877 arrow. Only used for non-window-redisplay windows. */
13726 13878
13727static struct glyph_row * 13879static struct glyph_row *
13728get_overlay_arrow_glyph_row (w) 13880get_overlay_arrow_glyph_row (w, overlay_arrow_string)
13729 struct window *w; 13881 struct window *w;
13882 Lisp_Object overlay_arrow_string;
13730{ 13883{
13731 struct frame *f = XFRAME (WINDOW_FRAME (w)); 13884 struct frame *f = XFRAME (WINDOW_FRAME (w));
13732 struct buffer *buffer = XBUFFER (w->buffer); 13885 struct buffer *buffer = XBUFFER (w->buffer);
13733 struct buffer *old = current_buffer; 13886 struct buffer *old = current_buffer;
13734 const unsigned char *arrow_string = SDATA (Voverlay_arrow_string); 13887 const unsigned char *arrow_string = SDATA (overlay_arrow_string);
13735 int arrow_len = SCHARS (Voverlay_arrow_string); 13888 int arrow_len = SCHARS (overlay_arrow_string);
13736 const unsigned char *arrow_end = arrow_string + arrow_len; 13889 const unsigned char *arrow_end = arrow_string + arrow_len;
13737 const unsigned char *p; 13890 const unsigned char *p;
13738 struct it it; 13891 struct it it;
@@ -13759,7 +13912,7 @@ get_overlay_arrow_glyph_row (w)
13759 13912
13760 /* Get its face. */ 13913 /* Get its face. */
13761 ilisp = make_number (p - arrow_string); 13914 ilisp = make_number (p - arrow_string);
13762 face = Fget_text_property (ilisp, Qface, Voverlay_arrow_string); 13915 face = Fget_text_property (ilisp, Qface, overlay_arrow_string);
13763 it.face_id = compute_char_face (f, it.c, face); 13916 it.face_id = compute_char_face (f, it.c, face);
13764 13917
13765 /* Compute its width, get its glyphs. */ 13918 /* Compute its width, get its glyphs. */
@@ -14198,6 +14351,8 @@ display_line (it)
14198 struct it *it; 14351 struct it *it;
14199{ 14352{
14200 struct glyph_row *row = it->glyph_row; 14353 struct glyph_row *row = it->glyph_row;
14354 int overlay_arrow_bitmap;
14355 Lisp_Object overlay_arrow_string;
14201 14356
14202 /* We always start displaying at hpos zero even if hscrolled. */ 14357 /* We always start displaying at hpos zero even if hscrolled. */
14203 xassert (it->hpos == 0 && it->current_x == 0); 14358 xassert (it->hpos == 0 && it->current_x == 0);
@@ -14593,17 +14748,16 @@ display_line (it)
14593 mark this glyph row as the one containing the overlay arrow. 14748 mark this glyph row as the one containing the overlay arrow.
14594 This is clearly a mess with variable size fonts. It would be 14749 This is clearly a mess with variable size fonts. It would be
14595 better to let it be displayed like cursors under X. */ 14750 better to let it be displayed like cursors under X. */
14596 if (MARKERP (Voverlay_arrow_position) 14751 if (! overlay_arrow_seen
14597 && current_buffer == XMARKER (Voverlay_arrow_position)->buffer 14752 && (overlay_arrow_string = overlay_arrow_at_row (it->f, row,
14598 && (MATRIX_ROW_START_CHARPOS (row) 14753 &overlay_arrow_bitmap),
14599 == marker_position (Voverlay_arrow_position)) 14754 !NILP (overlay_arrow_string)))
14600 && STRINGP (Voverlay_arrow_string)
14601 && ! overlay_arrow_seen)
14602 { 14755 {
14603 /* Overlay arrow in window redisplay is a fringe bitmap. */ 14756 /* Overlay arrow in window redisplay is a fringe bitmap. */
14604 if (!FRAME_WINDOW_P (it->f)) 14757 if (!FRAME_WINDOW_P (it->f))
14605 { 14758 {
14606 struct glyph_row *arrow_row = get_overlay_arrow_glyph_row (it->w); 14759 struct glyph_row *arrow_row
14760 = get_overlay_arrow_glyph_row (it->w, overlay_arrow_bitmap);
14607 struct glyph *glyph = arrow_row->glyphs[TEXT_AREA]; 14761 struct glyph *glyph = arrow_row->glyphs[TEXT_AREA];
14608 struct glyph *arrow_end = glyph + arrow_row->used[TEXT_AREA]; 14762 struct glyph *arrow_end = glyph + arrow_row->used[TEXT_AREA];
14609 struct glyph *p = row->glyphs[TEXT_AREA]; 14763 struct glyph *p = row->glyphs[TEXT_AREA];
@@ -14627,6 +14781,7 @@ display_line (it)
14627 } 14781 }
14628 14782
14629 overlay_arrow_seen = 1; 14783 overlay_arrow_seen = 1;
14784 it->w->overlay_arrow_bitmap = overlay_arrow_bitmap;
14630 row->overlay_arrow_p = 1; 14785 row->overlay_arrow_p = 1;
14631 } 14786 }
14632 14787
@@ -17708,6 +17863,9 @@ produce_image_glyph (it)
17708 if (it->image_id < 0) 17863 if (it->image_id < 0)
17709 { 17864 {
17710 /* Fringe bitmap. */ 17865 /* Fringe bitmap. */
17866 it->ascent = it->phys_ascent = 0;
17867 it->descent = it->phys_descent = 0;
17868 it->pixel_width = 0;
17711 it->nglyphs = 0; 17869 it->nglyphs = 0;
17712 return; 17870 return;
17713 } 17871 }
@@ -21433,10 +21591,15 @@ syms_of_xdisp ()
21433 list_of_error = Fcons (intern ("error"), Qnil); 21591 list_of_error = Fcons (intern ("error"), Qnil);
21434 staticpro (&list_of_error); 21592 staticpro (&list_of_error);
21435 21593
21436 last_arrow_position = Qnil; 21594 Qlast_arrow_position = intern ("last-arrow-position");
21437 last_arrow_string = Qnil; 21595 staticpro (&Qlast_arrow_position);
21438 staticpro (&last_arrow_position); 21596 Qlast_arrow_string = intern ("last-arrow-string");
21439 staticpro (&last_arrow_string); 21597 staticpro (&Qlast_arrow_string);
21598
21599 Qoverlay_arrow_string = intern ("overlay-arrow-string");
21600 staticpro (&Qoverlay_arrow_string);
21601 Qoverlay_arrow_bitmap = intern ("overlay-arrow-bitmap");
21602 staticpro (&Qoverlay_arrow_bitmap);
21440 21603
21441 echo_buffer[0] = echo_buffer[1] = Qnil; 21604 echo_buffer[0] = echo_buffer[1] = Qnil;
21442 staticpro (&echo_buffer[0]); 21605 staticpro (&echo_buffer[0]);
@@ -21500,9 +21663,17 @@ See also `overlay-arrow-string'. */);
21500 Voverlay_arrow_position = Qnil; 21663 Voverlay_arrow_position = Qnil;
21501 21664
21502 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string, 21665 DEFVAR_LISP ("overlay-arrow-string", &Voverlay_arrow_string,
21503 doc: /* String to display as an arrow. See also `overlay-arrow-position'. */); 21666 doc: /* String to display as an arrow in non-window frames.
21667See also `overlay-arrow-position'. */);
21504 Voverlay_arrow_string = Qnil; 21668 Voverlay_arrow_string = Qnil;
21505 21669
21670 DEFVAR_LISP ("overlay-arrow-variable-list", &Voverlay_arrow_variable_list,
21671 doc: /* List of variables (symbols) which hold markers for overlay arrows.
21672The symbols on this list are examined during redisplay to determine
21673where to display overlay arrows. */);
21674 Voverlay_arrow_variable_list
21675 = Fcons (intern ("overlay-arrow-position"), Qnil);
21676
21506 DEFVAR_INT ("scroll-step", &scroll_step, 21677 DEFVAR_INT ("scroll-step", &scroll_step,
21507 doc: /* *The number of lines to try scrolling a window by when point moves out. 21678 doc: /* *The number of lines to try scrolling a window by when point moves out.
21508If that fails to bring point back on frame, point is centered instead. 21679If that fails to bring point back on frame, point is centered instead.