89 |
FRAME_PTR frame; |
FRAME_PTR frame; |
90 |
/* matrix is of size window_size + 1 on each side. */ |
/* matrix is of size window_size + 1 on each side. */ |
91 |
struct matrix_elt *matrix; |
struct matrix_elt *matrix; |
92 |
int window_size; |
int window_size, lines_below; |
93 |
int *draw_cost; |
int *draw_cost; |
94 |
int *old_hash; |
int *old_hash; |
95 |
int *new_hash; |
int *new_hash; |
232 |
/* Perform insert-lines and delete-lines operations on CURRENT_MATRIX |
/* Perform insert-lines and delete-lines operations on CURRENT_MATRIX |
233 |
according to the costs in MATRIX, using the general scrolling |
according to the costs in MATRIX, using the general scrolling |
234 |
method that is used if the terminal does not support the setting of |
method that is used if the terminal does not support the setting of |
235 |
scroll windows (scroll_region_ok == 0). |
scroll windows (scroll_region_ok == 0). |
236 |
|
|
237 |
WINDOW_SIZE is the number of lines being considered for scrolling |
WINDOW_SIZE is the number of lines being considered for scrolling |
238 |
and UNCHANGED_AT_TOP is the vpos of the first line being |
and UNCHANGED_AT_TOP is the vpos of the first line being |
239 |
considered. These two arguments can specify any contiguous range |
considered. These two arguments can specify any contiguous range |
240 |
of lines. */ |
of lines. */ |
241 |
|
|
242 |
static void |
static void |
243 |
do_scrolling (current_matrix, matrix, window_size, unchanged_at_top) |
do_scrolling (current_matrix, matrix, window_size, unchanged_at_top) |
244 |
struct glyph_matrix *current_matrix; |
struct glyph_matrix *current_matrix; |
258 |
struct queue *queue_start |
struct queue *queue_start |
259 |
= (struct queue *) alloca (current_matrix->nrows * sizeof (struct queue)); |
= (struct queue *) alloca (current_matrix->nrows * sizeof (struct queue)); |
260 |
struct queue *queue = queue_start; |
struct queue *queue = queue_start; |
261 |
|
|
262 |
char *retained_p = (char *) alloca (window_size * sizeof (char)); |
char *retained_p = (char *) alloca (window_size * sizeof (char)); |
263 |
int *copy_from = (int *) alloca (window_size * sizeof (int)); |
int *copy_from = (int *) alloca (window_size * sizeof (int)); |
264 |
|
|
283 |
while (i > 0 || j > 0) |
while (i > 0 || j > 0) |
284 |
{ |
{ |
285 |
p = matrix + i * (window_size + 1) + j; |
p = matrix + i * (window_size + 1) + j; |
286 |
|
|
287 |
if (p->insertcost < p->writecost && p->insertcost < p->deletecost) |
if (p->insertcost < p->writecost && p->insertcost < p->deletecost) |
288 |
{ |
{ |
289 |
/* Insert should be done at vpos i-1, plus maybe some before. |
/* Insert should be done at vpos i-1, plus maybe some before. |
365 |
} |
} |
366 |
} |
} |
367 |
while (queue > queue_start); |
while (queue > queue_start); |
368 |
|
|
369 |
} |
} |
370 |
|
|
371 |
for (k = 0; k < window_size; ++k) |
for (k = 0; k < window_size; ++k) |
377 |
|
|
378 |
/* Some sanity checks if GLYPH_DEBUG != 0. */ |
/* Some sanity checks if GLYPH_DEBUG != 0. */ |
379 |
CHECK_MATRIX (current_matrix); |
CHECK_MATRIX (current_matrix); |
380 |
|
|
381 |
if (terminal_window_p) |
if (terminal_window_p) |
382 |
set_terminal_window (0); |
set_terminal_window (0); |
383 |
} |
} |
430 |
FRAME_PTR frame; |
FRAME_PTR frame; |
431 |
/* matrix is of size window_size + 1 on each side. */ |
/* matrix is of size window_size + 1 on each side. */ |
432 |
struct matrix_elt *matrix; |
struct matrix_elt *matrix; |
433 |
int window_size; |
int window_size, lines_below; |
434 |
int *draw_cost; |
int *draw_cost; |
435 |
int *old_draw_cost; |
int *old_draw_cost; |
436 |
int *old_hash; |
int *old_hash; |
562 |
To reduce the cumulative effects of rounding error, we |
To reduce the cumulative effects of rounding error, we |
563 |
vary the position at which the difference is computed. */ |
vary the position at which the difference is computed. */ |
564 |
cost1 += first_insert_cost[-j] - first_insert_cost[1-j] + |
cost1 += first_insert_cost[-j] - first_insert_cost[1-j] + |
565 |
(delta-1) * (next_insert_cost[-j] - next_insert_cost[1-j]); |
(delta-1) * (next_insert_cost[-j] - next_insert_cost[1-j]); |
566 |
} |
} |
567 |
else |
else |
568 |
{ |
{ |
570 |
cost += scroll_overhead + first_delete_cost[-delta] + |
cost += scroll_overhead + first_delete_cost[-delta] + |
571 |
(delta-1) * (next_delete_cost[-delta] + extra_cost); |
(delta-1) * (next_delete_cost[-delta] + extra_cost); |
572 |
cost1 += first_delete_cost[-i] - first_delete_cost[1-i] + |
cost1 += first_delete_cost[-i] - first_delete_cost[1-i] + |
573 |
(delta-1) * ( next_delete_cost[-i] - next_delete_cost[1-i]); |
(delta-1) * ( next_delete_cost[-i] - next_delete_cost[1-i]); |
574 |
} |
} |
575 |
if (cost1 < cost) |
if (cost1 < cost) |
576 |
{ |
{ |
641 |
and UNCHANGED_AT_TOP is the vpos of the first line being |
and UNCHANGED_AT_TOP is the vpos of the first line being |
642 |
considered. These two arguments can specify any contiguous range |
considered. These two arguments can specify any contiguous range |
643 |
of lines. |
of lines. |
644 |
|
|
645 |
In the direct scrolling method, a new scroll window is selected |
In the direct scrolling method, a new scroll window is selected |
646 |
before each insertion or deletion, so that groups of lines can be |
before each insertion or deletion, so that groups of lines can be |
647 |
scrolled directly to their final vertical positions. This method |
scrolled directly to their final vertical positions. This method |
701 |
without also decrementing i, this corresponds to omitting these |
without also decrementing i, this corresponds to omitting these |
702 |
lines in the new rows, i.e. rows are deleted. */ |
lines in the new rows, i.e. rows are deleted. */ |
703 |
i = j = window_size; |
i = j = window_size; |
704 |
|
|
705 |
while (i > 0 || j > 0) |
while (i > 0 || j > 0) |
706 |
{ |
{ |
707 |
p = cost_matrix + i * (window_size + 1) + j; |
p = cost_matrix + i * (window_size + 1) + j; |
708 |
|
|
709 |
if (p->insertcost < p->writecost |
if (p->insertcost < p->writecost |
710 |
&& p->insertcost < p->deletecost |
&& p->insertcost < p->deletecost |
711 |
&& (write_follows_p || i < j)) |
&& (write_follows_p || i < j)) |
717 |
queue->window = i; |
queue->window = i; |
718 |
queue->pos = i - p->insertcount; |
queue->pos = i - p->insertcount; |
719 |
++queue; |
++queue; |
720 |
|
|
721 |
i -= p->insertcount; |
i -= p->insertcount; |
722 |
write_follows_p = 0; |
write_follows_p = 0; |
723 |
} |
} |
736 |
place they belong. */ |
place they belong. */ |
737 |
int n_to_write = p->writecount; |
int n_to_write = p->writecount; |
738 |
write_follows_p = 1; |
write_follows_p = 1; |
739 |
xassert (n_to_write > 0); |
xassert (n_to_write > 0); |
740 |
|
|
741 |
if (i > j) |
if (i > j) |
742 |
{ |
{ |
822 |
{ |
{ |
823 |
calculate_direct_scrolling (frame, matrix, window_size, |
calculate_direct_scrolling (frame, matrix, window_size, |
824 |
unchanged_at_bottom, |
unchanged_at_bottom, |
825 |
draw_cost, old_draw_cost, |
draw_cost, old_draw_cost, |
826 |
old_hash, new_hash, free_at_end); |
old_hash, new_hash, free_at_end); |
827 |
do_direct_scrolling (frame->current_matrix, |
do_direct_scrolling (frame->current_matrix, |
828 |
matrix, window_size, unchanged_at_top); |
matrix, window_size, unchanged_at_top); |
1054 |
(int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int)); |
(int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int)); |
1055 |
FRAME_INSERTN_COST (frame) = |
FRAME_INSERTN_COST (frame) = |
1056 |
(int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int)); |
(int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int)); |
1057 |
FRAME_DELETE_COST (frame) = |
FRAME_DELETE_COST (frame) = |
1058 |
(int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int)); |
(int *) xmalloc (FRAME_HEIGHT (frame) * sizeof (int)); |
1059 |
} |
} |
1060 |
|
|