comparison src/dispnew.c @ 27855:ecfe912fd73c

(flush_stdout) [GLYPH_DEBUG]: New function. (build_frame_matrix_from_leaf_window): Put code handling glyph row's not being a slice of a frame row in #if 0. (sync_window_with_frame_matrix_rows): New function. (frame_row_to_window): New function. (mirror_line_dance): Handle copies between windows.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 25 Feb 2000 13:20:36 +0000
parents 9400865ec7cf
children 7634011b93f3
comparison
equal deleted inserted replaced
27854:cc746270613e 27855:ecfe912fd73c
172 struct glyph_row *)); 172 struct glyph_row *));
173 static void adjust_frame_glyphs_for_window_redisplay P_ ((struct frame *)); 173 static void adjust_frame_glyphs_for_window_redisplay P_ ((struct frame *));
174 static void adjust_frame_glyphs_for_frame_redisplay P_ ((struct frame *)); 174 static void adjust_frame_glyphs_for_frame_redisplay P_ ((struct frame *));
175 static void reverse_rows P_ ((struct glyph_matrix *, int, int)); 175 static void reverse_rows P_ ((struct glyph_matrix *, int, int));
176 static int margin_glyphs_to_reserve P_ ((struct window *, int, Lisp_Object)); 176 static int margin_glyphs_to_reserve P_ ((struct window *, int, Lisp_Object));
177 static void sync_window_with_frame_matrix_rows P_ ((struct window *));
178 struct window *frame_row_to_window P_ ((struct window *, int));
177 179
178 180
179 181
180 /* Non-zero means don't pause redisplay for pending input. (This is 182 /* Non-zero means don't pause redisplay for pending input. (This is
181 for debugging and for a future implementation of EDT-like 183 for debugging and for a future implementation of EDT-like
1493 Debug Code 1495 Debug Code
1494 ***********************************************************************/ 1496 ***********************************************************************/
1495 1497
1496 #if GLYPH_DEBUG 1498 #if GLYPH_DEBUG
1497 1499
1500
1501 /* Flush standard output. This is sometimes useful to call from
1502 the debugger. */
1503
1504 void
1505 flush_stdout ()
1506 {
1507 fflush (stdout);
1508 }
1509
1510
1498 /* Check that no glyph pointers have been lost in MATRIX. If a 1511 /* Check that no glyph pointers have been lost in MATRIX. If a
1499 pointer has been lost, e.g. by using a structure assignment between 1512 pointer has been lost, e.g. by using a structure assignment between
1500 rows, at least one pointer must occur more than once in the rows of 1513 rows, at least one pointer must occur more than once in the rows of
1501 MATRIX. */ 1514 MATRIX. */
1502 1515
2437 { 2450 {
2438 struct glyph *border = window_row->glyphs[LAST_AREA] - 1; 2451 struct glyph *border = window_row->glyphs[LAST_AREA] - 1;
2439 SET_CHAR_GLYPH_FROM_GLYPH (*border, right_border_glyph); 2452 SET_CHAR_GLYPH_FROM_GLYPH (*border, right_border_glyph);
2440 } 2453 }
2441 2454
2455 #if 0 /* This shouldn't be necessary. Let's check it. */
2442 /* Due to hooks installed, it normally doesn't happen that 2456 /* Due to hooks installed, it normally doesn't happen that
2443 window rows and frame rows of the same matrix are out of 2457 window rows and frame rows of the same matrix are out of
2444 sync, i.e. have a different understanding of where to 2458 sync, i.e. have a different understanding of where to
2445 find glyphs for the row. The following is a safety-belt 2459 find glyphs for the row. The following is a safety-belt
2446 that doesn't cost much and makes absolutely sure that 2460 that doesn't cost much and makes absolutely sure that
2457 swap_glyphs_in_rows (window_row, slice_row); 2471 swap_glyphs_in_rows (window_row, slice_row);
2458 2472
2459 /* Exchange pointers between both rows. */ 2473 /* Exchange pointers between both rows. */
2460 swap_glyph_pointers (window_row, slice_row); 2474 swap_glyph_pointers (window_row, slice_row);
2461 } 2475 }
2462 2476 #endif
2463 /* Now, we are sure that window row window_y is a slice of 2477
2464 the frame row frame_y. But, lets check that assumption. */ 2478 /* Window row window_y must be a slice of frame row
2479 frame_y. */
2465 xassert (glyph_row_slice_p (window_row, frame_row)); 2480 xassert (glyph_row_slice_p (window_row, frame_row));
2466 2481
2467 /* If rows are in sync, we don't have to copy glyphs because 2482 /* If rows are in sync, we don't have to copy glyphs because
2468 frame and window share glyphs. */ 2483 frame and window share glyphs. */
2469 2484
2470 #if GLYPH_DEBUG 2485 #if GLYPH_DEBUG
2471 strcpy (w->current_matrix->method, w->desired_matrix->method); 2486 strcpy (w->current_matrix->method, w->desired_matrix->method);
2692 2707
2693 /* Do the same for window matrices, if MATRIX Is a frame matrix. */ 2708 /* Do the same for window matrices, if MATRIX Is a frame matrix. */
2694 if (frame_matrix_frame) 2709 if (frame_matrix_frame)
2695 mirror_line_dance (XWINDOW (frame_matrix_frame->root_window), 2710 mirror_line_dance (XWINDOW (frame_matrix_frame->root_window),
2696 unchanged_at_top, nlines, copy_from, retained_p); 2711 unchanged_at_top, nlines, copy_from, retained_p);
2712 }
2713
2714
2715 /* Synchronize glyph pointers in the current matrix of window W with
2716 the current frame matrix. W must be full-width, and be on a tty
2717 frame. */
2718
2719 static void
2720 sync_window_with_frame_matrix_rows (w)
2721 struct window *w;
2722 {
2723 struct frame *f = XFRAME (w->frame);
2724 struct glyph_row *window_row, *window_row_end, *frame_row;
2725
2726 /* Preconditions: W must be a leaf window and full-width. Its frame
2727 must have a frame matrix. */
2728 xassert (NILP (w->hchild) && NILP (w->vchild));
2729 xassert (WINDOW_FULL_WIDTH_P (w));
2730 xassert (!FRAME_WINDOW_P (f));
2731
2732 /* If W is a full-width window, glyph pointers in W's current matrix
2733 have, by definition, to be the same as glyph pointers in the
2734 corresponding frame matrix. */
2735 window_row = w->current_matrix->rows;
2736 window_row_end = window_row + w->current_matrix->nrows;
2737 frame_row = f->current_matrix->rows + XFASTINT (w->top);
2738 while (window_row < window_row_end)
2739 {
2740 int area;
2741
2742 for (area = LEFT_MARGIN_AREA; area <= LAST_AREA; ++area)
2743 window_row->glyphs[area] = frame_row->glyphs[area];
2744
2745 ++window_row, ++frame_row;
2746 }
2747 }
2748
2749
2750 /* Return the window in the window tree rooted in W containing frame
2751 row ROW. Value is null if none is found. */
2752
2753 struct window *
2754 frame_row_to_window (w, row)
2755 struct window *w;
2756 int row;
2757 {
2758 struct window *found = NULL;
2759
2760 while (w && !found)
2761 {
2762 if (!NILP (w->hchild))
2763 found = frame_row_to_window (XWINDOW (w->hchild), row);
2764 else if (!NILP (w->vchild))
2765 found = frame_row_to_window (XWINDOW (w->vchild), row);
2766 else if (row >= XFASTINT (w->top)
2767 && row < XFASTINT (w->top) + XFASTINT (w->height))
2768 found = w;
2769
2770 w = NILP (w->next) ? 0 : XWINDOW (w->next);
2771 }
2772
2773 return found;
2697 } 2774 }
2698 2775
2699 2776
2700 /* Perform a line dance in the window tree rooted at W, after 2777 /* Perform a line dance in the window tree rooted at W, after
2701 scrolling a frame matrix in mirrored_line_dance. 2778 scrolling a frame matrix in mirrored_line_dance.
2726 else 2803 else
2727 { 2804 {
2728 /* W is a leaf window, and we are working on its current 2805 /* W is a leaf window, and we are working on its current
2729 matrix m. */ 2806 matrix m. */
2730 struct glyph_matrix *m = w->current_matrix; 2807 struct glyph_matrix *m = w->current_matrix;
2731 2808 int i, sync_p = 0;
2732 int i;
2733
2734 struct glyph_row *old_rows; 2809 struct glyph_row *old_rows;
2735 2810
2736 /* Make a copy of the original rows of matrix m. */ 2811 /* Make a copy of the original rows of matrix m. */
2737 old_rows = (struct glyph_row *) alloca (m->nrows * sizeof *old_rows); 2812 old_rows = (struct glyph_row *) alloca (m->nrows * sizeof *old_rows);
2738 bcopy (m->rows, old_rows, m->nrows * sizeof *old_rows); 2813 bcopy (m->rows, old_rows, m->nrows * sizeof *old_rows);
2753 2828
2754 /* Is assigned line inside window? */ 2829 /* Is assigned line inside window? */
2755 int from_inside_window_p 2830 int from_inside_window_p
2756 = window_from >= 0 && window_from < m->matrix_h; 2831 = window_from >= 0 && window_from < m->matrix_h;
2757 2832
2758 if (from_inside_window_p) 2833 /* Is assigned to line inside window? */
2834 int to_inside_window_p
2835 = window_to >= 0 && window_to < m->matrix_h;
2836
2837 if (from_inside_window_p && to_inside_window_p)
2759 { 2838 {
2760 #if GLYPH_DEBUG
2761 /* Is assigned to line inside window? */
2762 int to_inside_window_p
2763 = window_to >= 0 && window_to < m->matrix_h;
2764 #endif
2765
2766 /* Enabled setting before assignment. */ 2839 /* Enabled setting before assignment. */
2767 int enabled_before_p; 2840 int enabled_before_p;
2768
2769 /* If not both lines inside the window, we have a
2770 serious problem. */
2771 xassert (to_inside_window_p);
2772 2841
2773 /* Do the assignment. The enabled_p flag is saved 2842 /* Do the assignment. The enabled_p flag is saved
2774 over the assignment because the old redisplay did 2843 over the assignment because the old redisplay did
2775 that. */ 2844 that. */
2776 enabled_before_p = m->rows[window_to].enabled_p; 2845 enabled_before_p = m->rows[window_to].enabled_p;
2779 2848
2780 /* If frame line is empty, window line is empty, too. */ 2849 /* If frame line is empty, window line is empty, too. */
2781 if (!retained_p[copy_from[i]]) 2850 if (!retained_p[copy_from[i]])
2782 m->rows[window_to].enabled_p = 0; 2851 m->rows[window_to].enabled_p = 0;
2783 } 2852 }
2853 else if (to_inside_window_p)
2854 {
2855 /* A copy between windows. This is an infrequent
2856 case not worth optimizing. */
2857 struct frame *f = XFRAME (w->frame);
2858 struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
2859 struct window *w2;
2860 struct glyph_matrix *m2;
2861 int m2_from;
2862
2863 w2 = frame_row_to_window (root, frame_to);
2864 m2 = w2->current_matrix;
2865 m2_from = frame_from - m2->matrix_y;
2866 copy_row_except_pointers (m->rows + window_to,
2867 m2->rows + m2_from);
2868
2869 /* If frame line is empty, window line is empty, too. */
2870 if (!retained_p[copy_from[i]])
2871 m->rows[window_to].enabled_p = 0;
2872 sync_p = 1;
2873 }
2874 else if (from_inside_window_p)
2875 sync_p = 1;
2784 } 2876 }
2877
2878 /* If there was a copy between windows, make sure glyph
2879 pointers are in sync with the frame matrix. */
2880 if (sync_p)
2881 sync_window_with_frame_matrix_rows (w);
2785 2882
2786 /* Check that no pointers are lost. */ 2883 /* Check that no pointers are lost. */
2787 CHECK_MATRIX (m); 2884 CHECK_MATRIX (m);
2788 } 2885 }
2789 2886