annotate src/scroll.c @ 107777:13c077500eb3

2010-04-04 John Wiegley <jwiegley@gmail.com> * ido.el (ido-use-virtual-buffers): New variable to indicate whether "virtual buffer" support is enabled for IDO. Essentially it works as follows: Say you are visiting a file and the buffer gets cleaned up by mignight.el. Later, you want to switch to that buffer, but find it's no longer open. With virtual buffers enabled, the buffer name stays in the buffer list (using the ido-virtual face, and always at the end), and if you select it, it opens the file back up again. This allows you to think less about whether recently opened files are still open or not. Most of the time you can quit Emacs, restart, and then switch to a file buffer that was previously open as if it still were. NOTE: This feature has been present in iswitchb for several years now, and I'm porting the same logic to IDO. (ido-virtual): Face used to indicate virtual buffers in the list. (ido-buffer-internal): If a buffer is chosen, and no such buffer exists, but a virtual buffer of that name does (which would be why it was in the list), recreate the buffer by reopening the file. (ido-make-buffer-list): If virtual buffers are being used, call `ido-add-virtual-buffers-to-list' before the make list hook. (ido-virtual-buffers): New variable which contains a copy of the current contents of the `recentf-list', albeit pared down for the sake of speed, and with proper faces applied. (ido-add-virtual-buffers-to-list): Using the `recentf-list', create a list of "virtual buffers" to present to the user in addition to the currently open set. Note that this logic could get rather slow if that list is too large. With the default `recentf-max-saved-items' of 200, there is little speed penalty.
author jwiegley@gmail.com
date Sun, 04 Apr 2010 02:55:19 -0400
parents 1d1d5d9bd884
children 2bc9a0c04c87 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Calculate what line insertion or deletion to do, and do it,
75227
e90d04cd455a Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
2 Copyright (C) 1985, 1986, 1990, 1993, 1994, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105669
diff changeset
3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 This file is part of GNU Emacs.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
7 GNU Emacs is free software: you can redistribute it and/or modify
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
10 (at your option) any later version.
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 GNU General Public License for more details.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 3356
diff changeset
21 #include <config.h>
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
22 #include <stdio.h>
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
23 #include <string.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 100951
diff changeset
24 #include <setjmp.h>
53229
33c3c7c16e13 lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents: 53226
diff changeset
25 #include "lisp.h"
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #include "termchar.h"
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #include "dispextern.h"
31102
6a0caa788013 Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents: 28407
diff changeset
28 #include "keyboard.h"
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
29 #include "frame.h"
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
30 #include "window.h"
82990
2ecd1f669db9 Fixed X support, preliminary support for X-tty combo sessions.
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
31 #include "termhooks.h"
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 /* All costs measured in characters.
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
34 So no cost can exceed the area of a frame, measured in characters.
6773
ed16e189b9a5 (struct matrix_elt): Use int, not short.
Richard M. Stallman <rms@gnu.org>
parents: 6647
diff changeset
35 Let's hope this is never more than 1000000 characters. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
6773
ed16e189b9a5 (struct matrix_elt): Use int, not short.
Richard M. Stallman <rms@gnu.org>
parents: 6647
diff changeset
37 #define INFINITY 1000000
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 struct matrix_elt
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 /* Cost of outputting through this line
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 if no insert/delete is done just above it. */
6773
ed16e189b9a5 (struct matrix_elt): Use int, not short.
Richard M. Stallman <rms@gnu.org>
parents: 6647
diff changeset
43 int writecost;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 /* Cost of outputting through this line
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 if an insert is done just above it. */
6773
ed16e189b9a5 (struct matrix_elt): Use int, not short.
Richard M. Stallman <rms@gnu.org>
parents: 6647
diff changeset
46 int insertcost;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 /* Cost of outputting through this line
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 if a delete is done just above it. */
6773
ed16e189b9a5 (struct matrix_elt): Use int, not short.
Richard M. Stallman <rms@gnu.org>
parents: 6647
diff changeset
49 int deletecost;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 /* Number of inserts so far in this run of inserts,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 for the cost in insertcost. */
6773
ed16e189b9a5 (struct matrix_elt): Use int, not short.
Richard M. Stallman <rms@gnu.org>
parents: 6647
diff changeset
52 unsigned char insertcount;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 /* Number of deletes so far in this run of deletes,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 for the cost in deletecost. */
6773
ed16e189b9a5 (struct matrix_elt): Use int, not short.
Richard M. Stallman <rms@gnu.org>
parents: 6647
diff changeset
55 unsigned char deletecount;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
56 /* Number of writes so far since the last insert
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
57 or delete for the cost in writecost. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
58 unsigned char writecount;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 };
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
61 static void do_direct_scrolling P_ ((struct frame *,
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
62 struct glyph_matrix *,
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
63 struct matrix_elt *,
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
64 int, int));
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
65 static void do_scrolling P_ ((struct frame *,
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
66 struct glyph_matrix *,
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
67 struct matrix_elt *,
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
68 int, int));
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
69
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
71 /* Determine, in matrix[i,j], the cost of updating the first j old
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
72 lines into the first i new lines using the general scrolling method.
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 This involves using insert or delete somewhere if i != j.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 For each matrix elements, three kinds of costs are recorded:
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 the smallest cost that ends with an insert, the smallest
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 cost that ends with a delete, and the smallest cost that
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 ends with neither one. These are kept separate because
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 on some terminals the cost of doing an insert varies
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 depending on whether one was just done, etc. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 /* draw_cost[VPOS] is the cost of outputting new line at VPOS.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 old_hash[VPOS] is the hash code of the old line at VPOS.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 new_hash[VPOS] is the hash code of the new line at VPOS.
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
84 Note that these are not true frame vpos's, but relative
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 to the place at which the first mismatch between old and
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 new contents appears. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 static void
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
89 calculate_scrolling (frame, matrix, window_size, lines_below,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 draw_cost, old_hash, new_hash,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 free_at_end)
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
92 FRAME_PTR frame;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 /* matrix is of size window_size + 1 on each side. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 struct matrix_elt *matrix;
48323
3aa5ba8c3ef4 (calculate_scrolling, calculate_direct_scrolling):
Dave Love <fx@gnu.org>
parents: 39682
diff changeset
95 int window_size, lines_below;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 int *draw_cost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 int *old_hash;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 int *new_hash;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 int free_at_end;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 register int i, j;
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
102 int frame_lines = FRAME_LINES (frame);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 register struct matrix_elt *p, *p1;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 register int cost, cost1;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105
53225
4250e7e26247 Add a level of indirection to terminal characteristics.
Karoly Lorentey <lorentey@elte.hu>
parents: 52401
diff changeset
106 int lines_moved = window_size
82990
2ecd1f669db9 Fixed X support, preliminary support for X-tty combo sessions.
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
107 + (FRAME_SCROLL_REGION_OK (frame) ? 0 : lines_below);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 /* first_insert_cost[I] is the cost of doing the first insert-line
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
109 at the i'th line of the lines we are considering,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 where I is origin 1 (as it is below). */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 int *first_insert_cost
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
112 = &FRAME_INSERT_COST (frame)[frame_lines - 1 - lines_moved];
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 int *first_delete_cost
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
114 = &FRAME_DELETE_COST (frame)[frame_lines - 1 - lines_moved];
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 int *next_insert_cost
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
116 = &FRAME_INSERTN_COST (frame)[frame_lines - 1 - lines_moved];
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 int *next_delete_cost
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
118 = &FRAME_DELETEN_COST (frame)[frame_lines - 1 - lines_moved];
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 /* Discourage long scrolls on fast lines.
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
121 Don't scroll nearly a full frame height unless it saves
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 at least 1/4 second. */
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
123 int extra_cost = baud_rate / (10 * 4 * FRAME_LINES (frame));
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124
3356
09759a9653c5 (calculate_scrolling): Defend against negative baud_rate.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
125 if (baud_rate <= 0)
09759a9653c5 (calculate_scrolling): Defend against negative baud_rate.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
126 extra_cost = 1;
09759a9653c5 (calculate_scrolling): Defend against negative baud_rate.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
127
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 /* initialize the top left corner of the matrix */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 matrix->writecost = 0;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 matrix->insertcost = INFINITY;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 matrix->deletecost = INFINITY;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 matrix->insertcount = 0;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 matrix->deletecount = 0;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 /* initialize the left edge of the matrix */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 cost = first_insert_cost[1] - next_insert_cost[1];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 for (i = 1; i <= window_size; i++)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 p = matrix + i * (window_size + 1);
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 cost += draw_cost[i] + next_insert_cost[i] + extra_cost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 p->insertcost = cost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 p->writecost = INFINITY;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 p->deletecost = INFINITY;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 p->insertcount = i;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 p->deletecount = 0;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 /* initialize the top edge of the matrix */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 cost = first_delete_cost[1] - next_delete_cost[1];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 for (j = 1; j <= window_size; j++)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 cost += next_delete_cost[j];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 matrix[j].deletecost = cost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 matrix[j].writecost = INFINITY;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 matrix[j].insertcost = INFINITY;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 matrix[j].deletecount = j;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 matrix[j].insertcount = 0;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
160 /* `i' represents the vpos among new frame contents.
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
161 `j' represents the vpos among the old frame contents. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 p = matrix + window_size + 2; /* matrix [1, 1] */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 for (i = 1; i <= window_size; i++, p++)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 for (j = 1; j <= window_size; j++, p++)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 /* p contains the address of matrix [i, j] */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 /* First calculate the cost assuming we do
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 not insert or delete above this line.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 That is, if we update through line i-1
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 based on old lines through j-1,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 and then just change old line j to new line i. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 p1 = p - window_size - 2; /* matrix [i-1, j-1] */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 cost = p1->writecost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 if (cost > p1->insertcost)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 cost = p1->insertcost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 if (cost > p1->deletecost)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 cost = p1->deletecost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 if (old_hash[j] != new_hash[i])
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 cost += draw_cost[i];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 p->writecost = cost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 /* Calculate the cost if we do an insert-line
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 before outputting this line.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 That is, we update through line i-1
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 based on old lines through j,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 do an insert-line on line i,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 and then output line i from scratch,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 leaving old lines starting from j for reuse below. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 p1 = p - window_size - 1; /* matrix [i-1, j] */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 /* No need to think about doing a delete followed
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 immediately by an insert. It cannot be as good
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 as not doing either of them. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 if (free_at_end == i)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 cost = p1->writecost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 cost1 = p1->insertcost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 else
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 cost = p1->writecost + first_insert_cost[i];
6888
a39caeb88721 (calculate_scrolling): Add explicit casts, to avoid compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents: 6773
diff changeset
202 if ((int) p1->insertcount > i)
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 abort ();
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 cost1 = p1->insertcost + next_insert_cost[i - p1->insertcount];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 p->insertcost = min (cost, cost1) + draw_cost[i] + extra_cost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 p->insertcount = (cost < cost1) ? 1 : p1->insertcount + 1;
6888
a39caeb88721 (calculate_scrolling): Add explicit casts, to avoid compiler warnings.
Karl Heuer <kwzh@gnu.org>
parents: 6773
diff changeset
208 if ((int) p->insertcount > i)
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 abort ();
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 /* Calculate the cost if we do a delete line after
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 outputting this line.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 That is, we update through line i
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 based on old lines through j-1,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 and throw away old line j. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 p1 = p - 1; /* matrix [i, j-1] */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 /* No need to think about doing an insert followed
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 immediately by a delete. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 if (free_at_end == i)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 cost = p1->writecost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 cost1 = p1->deletecost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 else
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 cost = p1->writecost + first_delete_cost[i];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 cost1 = p1->deletecost + next_delete_cost[i];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 p->deletecost = min (cost, cost1);
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 p->deletecount = (cost < cost1) ? 1 : p1->deletecount + 1;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 }
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
233
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
234
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
236 /* Perform insert-lines and delete-lines operations on CURRENT_MATRIX
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
237 according to the costs in MATRIX, using the general scrolling
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
238 method that is used if the terminal does not support the setting of
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
239 scroll windows (scroll_region_ok == 0).
6647
e6611521fb67 (do_scrolling): Handle charstarts like glyphs.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
240
e6611521fb67 (do_scrolling): Handle charstarts like glyphs.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
241 WINDOW_SIZE is the number of lines being considered for scrolling
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
242 and UNCHANGED_AT_TOP is the vpos of the first line being
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
243 considered. These two arguments can specify any contiguous range
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
244 of lines. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
245
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 static void
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
247 do_scrolling (frame, current_matrix, matrix, window_size, unchanged_at_top)
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
248 struct frame *frame;
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
249 struct glyph_matrix *current_matrix;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 struct matrix_elt *matrix;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 int window_size;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 int unchanged_at_top;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
254 struct matrix_elt *p;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
255 int i, j, k;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
256
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
257 /* Set to 1 if we have set a terminal window with
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
258 set_terminal_window. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
259 int terminal_window_p = 0;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
261 /* A queue for line insertions to be done. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
262 struct queue { int count, pos; };
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
263 struct queue *queue_start
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
264 = (struct queue *) alloca (current_matrix->nrows * sizeof (struct queue));
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
265 struct queue *queue = queue_start;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
266
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
267 char *retained_p = (char *) alloca (window_size * sizeof (char));
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
268 int *copy_from = (int *) alloca (window_size * sizeof (int));
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
270 /* Zero means line is empty. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
271 bzero (retained_p, window_size * sizeof (char));
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
272 for (k = 0; k < window_size; ++k)
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
273 copy_from[k] = -1;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274
28407
f15029804aba * scroll.c (CHECK_BOUNDS): Renamed from CHECK.
Ken Raeburn <raeburn@raeburn.org>
parents: 25004
diff changeset
275 #define CHECK_BOUNDS \
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
276 do \
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
277 { \
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
278 int k; \
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
279 for (k = 0; k < window_size; ++k) \
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
280 xassert (copy_from[k] == -1 \
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
281 || (copy_from[k] >= 0 && copy_from[k] < window_size)); \
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
282 } \
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
283 while (0);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
285 /* When j is advanced, this corresponds to deleted lines.
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
286 When i is advanced, this corresponds to inserted lines. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 i = j = window_size;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 while (i > 0 || j > 0)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 p = matrix + i * (window_size + 1) + j;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
291
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
292 if (p->insertcost < p->writecost && p->insertcost < p->deletecost)
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
294 /* Insert should be done at vpos i-1, plus maybe some before.
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
295 Queue the screen operation to be performed. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
296 queue->count = p->insertcount;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
297 queue->pos = i + unchanged_at_top - p->insertcount;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
298 ++queue;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
299
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
300 /* By incrementing I, we leave room in the result rows
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
301 for the empty rows opened up. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 i -= p->insertcount;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 else if (p->deletecost < p->writecost)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
306 /* Old line at vpos j-1, and maybe some before it, should be
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
307 deleted. By decrementing J, we skip some lines in the
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
308 temp_rows which is equivalent to omitting these lines in
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
309 the result rows, thus deleting them. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 j -= p->deletecount;
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
311
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
312 /* Set the terminal window, if not done already. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
313 if (! terminal_window_p)
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 {
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
315 set_terminal_window (frame, window_size + unchanged_at_top);
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
316 terminal_window_p = 1;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 }
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
318
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
319 /* Delete lines on the terminal. */
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
320 ins_del_lines (frame, j + unchanged_at_top, - p->deletecount);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 else
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
324 /* Best thing done here is no insert or delete, i.e. a write. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
325 --i, --j;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
326 xassert (i >= 0 && i < window_size);
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
327 xassert (j >= 0 && j < window_size);
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
328 copy_from[i] = j;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
329 retained_p[j] = 1;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
331 #if GLYPH_DEBUG
28407
f15029804aba * scroll.c (CHECK_BOUNDS): Renamed from CHECK.
Ken Raeburn <raeburn@raeburn.org>
parents: 25004
diff changeset
332 CHECK_BOUNDS;
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
333 #endif
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
337 /* Now do all insertions queued above. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
338 if (queue > queue_start)
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
340 int next = -1;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
341
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
342 /* Set the terminal window if not yet done. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
343 if (!terminal_window_p)
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
344 {
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
345 set_terminal_window (frame, window_size + unchanged_at_top);
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
346 terminal_window_p = 1;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
347 }
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
348
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
349 do
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
350 {
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
351 --queue;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
352
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
353 /* Do the deletion on the terminal. */
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
354 ins_del_lines (frame, queue->pos, queue->count);
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
355
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
356 /* All lines in the range deleted become empty in the glyph
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
357 matrix. Assign to them glyph rows that are not retained.
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
358 K is the starting position of the deleted range relative
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
359 to the window we are working in. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
360 k = queue->pos - unchanged_at_top;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
361 for (j = 0; j < queue->count; ++j)
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
362 {
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
363 /* Find the next row not retained. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
364 while (retained_p[++next])
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
365 ;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
366
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
367 /* Record that this row is to be used for the empty
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
368 glyph row j. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
369 copy_from[k + j] = next;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
370 }
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
371 }
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
372 while (queue > queue_start);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
373
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
376 for (k = 0; k < window_size; ++k)
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
377 xassert (copy_from[k] >= 0 && copy_from[k] < window_size);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
379 /* Perform the row swizzling. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
380 mirrored_line_dance (current_matrix, unchanged_at_top, window_size,
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
381 copy_from, retained_p);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
383 /* Some sanity checks if GLYPH_DEBUG != 0. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
384 CHECK_MATRIX (current_matrix);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
385
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
386 if (terminal_window_p)
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
387 set_terminal_window (frame, 0);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 }
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
389
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
391 /* Determine, in matrix[i,j], the cost of updating the first j
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
392 old lines into the first i new lines using the direct
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
393 scrolling method. When the old line and the new line have
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
394 different hash codes, the calculated cost of updating old
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
395 line j into new line i includes the cost of outputting new
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
396 line i, and if i != j, the cost of outputting the old line j
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
397 is also included, as a penalty for moving the line and then
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
398 erasing it. In addition, the cost of updating a sequence of
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
399 lines with constant i - j includes the cost of scrolling the
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
400 old lines into their new positions, unless i == j. Scrolling
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
401 is achieved by setting the screen window to avoid affecting
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
402 other lines below, and inserting or deleting lines at the top
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
403 of the scrolled region. The cost of scrolling a sequence of
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
404 lines includes the fixed cost of specifying a scroll region,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
405 plus a variable cost which can depend upon the number of lines
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
406 involved and the distance by which they are scrolled, and an
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
407 extra cost to discourage long scrolls.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
408
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
409 As reflected in the matrix, an insert or delete does not
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
410 correspond directly to the insertion or deletion which is
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
411 used in scrolling lines. An insert means that the value of i
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
412 has increased without a corresponding increase in the value
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
413 of j. A delete means that the value of j has increased
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
414 without a corresponding increase in the value of i. A write
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
415 means that i and j are both increased by the same amount, and
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
416 that the old lines will be moved to their new positions.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
417
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
418 An insert following a delete is allowed only if i > j.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
419 A delete following an insert is allowed only if i < j.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
420 These restrictions ensure that the new lines in an insert
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
421 will always be blank as an effect of the neighboring writes.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
422 Thus the calculated cost of an insert is simply the cost of
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
423 outputting the new line contents. The direct cost of a
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
424 delete is zero. Inserts and deletes indirectly affect the
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
425 total cost through their influence on subsequent writes. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
426
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
427 /* The vectors draw_cost, old_hash, and new_hash have the same
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
428 meanings here as in calculate_scrolling, and old_draw_cost
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
429 is the equivalent of draw_cost for the old line contents */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
430
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
431 static void
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
432 calculate_direct_scrolling (frame, matrix, window_size, lines_below,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
433 draw_cost, old_draw_cost, old_hash, new_hash,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
434 free_at_end)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
435 FRAME_PTR frame;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
436 /* matrix is of size window_size + 1 on each side. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
437 struct matrix_elt *matrix;
48323
3aa5ba8c3ef4 (calculate_scrolling, calculate_direct_scrolling):
Dave Love <fx@gnu.org>
parents: 39682
diff changeset
438 int window_size, lines_below;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
439 int *draw_cost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
440 int *old_draw_cost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
441 int *old_hash;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
442 int *new_hash;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
443 int free_at_end;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
444 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
445 register int i, j;
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
446 int frame_lines = FRAME_LINES (frame);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
447 register struct matrix_elt *p, *p1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
448 register int cost, cost1, delta;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
449
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
450 /* first_insert_cost[-I] is the cost of doing the first insert-line
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
451 at a position I lines above the bottom line in the scroll window. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
452 int *first_insert_cost
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
453 = &FRAME_INSERT_COST (frame)[frame_lines - 1];
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
454 int *first_delete_cost
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
455 = &FRAME_DELETE_COST (frame)[frame_lines - 1];
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
456 int *next_insert_cost
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
457 = &FRAME_INSERTN_COST (frame)[frame_lines - 1];
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
458 int *next_delete_cost
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
459 = &FRAME_DELETEN_COST (frame)[frame_lines - 1];
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
460
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
461 int scroll_overhead;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
462
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
463 /* Discourage long scrolls on fast lines.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
464 Don't scroll nearly a full frame height unless it saves
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
465 at least 1/4 second. */
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
466 int extra_cost = baud_rate / (10 * 4 * FRAME_LINES (frame));
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
467
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
468 if (baud_rate <= 0)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
469 extra_cost = 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
470
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
471 /* Overhead of setting the scroll window, plus the extra cost
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
472 cost of scrolling by a distance of one. The extra cost is
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
473 added once for consistency with the cost vectors */
53225
4250e7e26247 Add a level of indirection to terminal characteristics.
Karoly Lorentey <lorentey@elte.hu>
parents: 52401
diff changeset
474 scroll_overhead
82990
2ecd1f669db9 Fixed X support, preliminary support for X-tty combo sessions.
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
475 = FRAME_SCROLL_REGION_COST (frame) + extra_cost;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
476
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
477 /* initialize the top left corner of the matrix */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
478 matrix->writecost = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
479 matrix->insertcost = INFINITY;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
480 matrix->deletecost = INFINITY;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
481 matrix->writecount = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
482 matrix->insertcount = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
483 matrix->deletecount = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
484
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
485 /* initialize the left edge of the matrix */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
486 cost = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
487 for (i = 1; i <= window_size; i++)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
488 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
489 p = matrix + i * (window_size + 1);
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
490 cost += draw_cost[i];
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
491 p->insertcost = cost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
492 p->writecost = INFINITY;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
493 p->deletecost = INFINITY;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
494 p->insertcount = i;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
495 p->writecount = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
496 p->deletecount = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
497 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
498
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
499 /* initialize the top edge of the matrix */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
500 for (j = 1; j <= window_size; j++)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
501 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
502 matrix[j].deletecost = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
503 matrix[j].writecost = INFINITY;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
504 matrix[j].insertcost = INFINITY;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
505 matrix[j].deletecount = j;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
506 matrix[j].writecount = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
507 matrix[j].insertcount = 0;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
508 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
509
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
510 /* `i' represents the vpos among new frame contents.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
511 `j' represents the vpos among the old frame contents. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
512 p = matrix + window_size + 2; /* matrix [1, 1] */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
513
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
514 for (i = 1; i <= window_size; i++, p++)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
515 for (j = 1; j <= window_size; j++, p++)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
516 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
517 /* p contains the address of matrix [i, j] */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
518
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
519 /* First calculate the cost assuming we do
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
520 not insert or delete above this line.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
521 That is, if we update through line i-1
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
522 based on old lines through j-1,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
523 and then just change old line j to new line i.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
524
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
525 Depending on which choice gives the lower cost,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
526 this usually involves either scrolling a single line
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
527 or extending a sequence of scrolled lines, but
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
528 when i == j, no scrolling is required. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
529 p1 = p - window_size - 2; /* matrix [i-1, j-1] */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
530 cost = p1->insertcost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
531 if (cost > p1->deletecost)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
532 cost = p1->deletecost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
533 cost1 = p1->writecost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
534 if (i == j)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
535 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
536 if (cost > cost1)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
537 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
538 cost = cost1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
539 p->writecount = p1->writecount + 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
540 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
541 else
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
542 p->writecount = 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
543 if (old_hash[j] != new_hash[i])
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
544 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
545 cost += draw_cost[i];
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
546 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
547 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
548 else
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
549 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
550 if (i > j)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
551 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
552 delta = i - j;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
553
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
554 /* The cost added here for scrolling the first line by
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
555 a distance N includes the overhead of setting the
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
556 scroll window, the cost of inserting N lines at a
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
557 position N lines above the bottom line of the window,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
558 and an extra cost which is proportional to N. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
559 cost += scroll_overhead + first_insert_cost[-delta] +
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
560 (delta-1) * (next_insert_cost[-delta] + extra_cost);
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
561
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
562 /* In the most general case, the insertion overhead and
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
563 the multiply factor can grow linearly as the distance
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
564 from the bottom of the window increases. The incremental
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
565 cost of scrolling an additional line depends upon the
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
566 rate of change of these two parameters. Each of these
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
567 growth rates can be determined by a simple difference.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
568 To reduce the cumulative effects of rounding error, we
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
569 vary the position at which the difference is computed. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
570 cost1 += first_insert_cost[-j] - first_insert_cost[1-j] +
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
571 (delta-1) * (next_insert_cost[-j] - next_insert_cost[1-j]);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
572 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
573 else
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
574 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
575 delta = j - i;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
576 cost += scroll_overhead + first_delete_cost[-delta] +
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
577 (delta-1) * (next_delete_cost[-delta] + extra_cost);
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
578 cost1 += first_delete_cost[-i] - first_delete_cost[1-i] +
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
579 (delta-1) * ( next_delete_cost[-i] - next_delete_cost[1-i]);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
580 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
581 if (cost1 < cost)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
582 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
583 cost = cost1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
584 p->writecount = p1->writecount + 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
585 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
586 else
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
587 p->writecount = 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
588 if (old_hash[j] != new_hash[i])
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
589 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
590 cost += draw_cost[i] + old_draw_cost[j];
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
591 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
592 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
593 p->writecost = cost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
594
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
595 /* Calculate the cost if we do an insert-line
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
596 before outputting this line.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
597 That is, we update through line i-1
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
598 based on old lines through j,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
599 do an insert-line on line i,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
600 and then output line i from scratch,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
601 leaving old lines starting from j for reuse below. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
602 p1 = p - window_size - 1; /* matrix [i-1, j] */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
603 cost = p1->writecost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
604 /* If i > j, an insert is allowed after a delete. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
605 if (i > j && p1->deletecost < cost)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
606 cost = p1->deletecost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
607 if (p1->insertcost <= cost)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
608 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
609 cost = p1->insertcost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
610 p->insertcount = p1->insertcount + 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
611 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
612 else
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
613 p->insertcount = 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
614 cost += draw_cost[i];
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
615 p->insertcost = cost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
616
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
617 /* Calculate the cost if we do a delete line after
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
618 outputting this line.
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
619 That is, we update through line i
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
620 based on old lines through j-1,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
621 and throw away old line j. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
622 p1 = p - 1; /* matrix [i, j-1] */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
623 cost = p1->writecost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
624 /* If i < j, a delete is allowed after an insert. */
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
625 if (i < j && p1->insertcost < cost)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
626 cost = p1->insertcost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
627 cost1 = p1->deletecost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
628 if (p1->deletecost <= cost)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
629 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
630 cost = p1->deletecost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
631 p->deletecount = p1->deletecount + 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
632 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
633 else
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
634 p->deletecount = 1;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
635 p->deletecost = cost;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
636 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
637 }
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
638
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
639
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
640
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
641 /* Perform insert-lines and delete-lines operations on CURRENT_MATRIX
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
642 according to the costs in MATRIX, using the direct scrolling method
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
643 which is used when the terminal supports setting a scroll window
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
644 (scroll_region_ok).
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
645
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
646 WINDOW_SIZE is the number of lines being considered for scrolling
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
647 and UNCHANGED_AT_TOP is the vpos of the first line being
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
648 considered. These two arguments can specify any contiguous range
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
649 of lines.
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
650
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
651 In the direct scrolling method, a new scroll window is selected
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
652 before each insertion or deletion, so that groups of lines can be
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
653 scrolled directly to their final vertical positions. This method
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
654 is described in more detail in calculate_direct_scrolling, where
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
655 the cost matrix for this approach is constructed. */
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
656
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
657 static void
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
658 do_direct_scrolling (frame, current_matrix, cost_matrix,
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
659 window_size, unchanged_at_top)
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
660 struct frame *frame;
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
661 struct glyph_matrix *current_matrix;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
662 struct matrix_elt *cost_matrix;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
663 int window_size;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
664 int unchanged_at_top;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
665 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
666 struct matrix_elt *p;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
667 int i, j;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
668
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
669 /* A queue of deletions and insertions to be performed. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
670 struct alt_queue { int count, pos, window; };
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
671 struct alt_queue *queue_start = (struct alt_queue *)
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
672 alloca (window_size * sizeof *queue_start);
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
673 struct alt_queue *queue = queue_start;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
674
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
675 /* Set to 1 if a terminal window has been set with
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
676 set_terminal_window: */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
677 int terminal_window_p = 0;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
678
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
679 /* A nonzero value of write_follows indicates that a write has been
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
680 selected, allowing either an insert or a delete to be selected
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
681 next. When write_follows is zero, a delete cannot be selected
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
682 unless j < i, and an insert cannot be selected unless i < j.
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
683 This corresponds to a similar restriction (with the ordering
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
684 reversed) in calculate_direct_scrolling, which is intended to
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
685 ensure that lines marked as inserted will be blank. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
686 int write_follows_p = 1;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
687
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
688 /* For each row in the new matrix what row of the old matrix it is. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
689 int *copy_from = (int *) alloca (window_size * sizeof (int));
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
690
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
691 /* Non-zero for each row in the new matrix that is retained from the
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
692 old matrix. Lines not retained are empty. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
693 char *retained_p = (char *) alloca (window_size * sizeof (char));
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
694
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
695 bzero (retained_p, window_size * sizeof (char));
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
696
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
697 /* Perform some sanity checks when GLYPH_DEBUG is on. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
698 CHECK_MATRIX (current_matrix);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
699
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
700 /* We are working on the line range UNCHANGED_AT_TOP ...
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
701 UNCHANGED_AT_TOP + WINDOW_SIZE (not including) in CURRENT_MATRIX.
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
702 We step through lines in this range from the end to the start. I
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
703 is an index into new lines, j an index into old lines. The cost
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
704 matrix determines what to do for ranges of indices.
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
705
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
706 If i is decremented without also decrementing j, this corresponds
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
707 to inserting empty lines in the result. If j is decremented
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
708 without also decrementing i, this corresponds to omitting these
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
709 lines in the new rows, i.e. rows are deleted. */
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
710 i = j = window_size;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
711
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
712 while (i > 0 || j > 0)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
713 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
714 p = cost_matrix + i * (window_size + 1) + j;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
715
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
716 if (p->insertcost < p->writecost
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
717 && p->insertcost < p->deletecost
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
718 && (write_follows_p || i < j))
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
719 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
720 /* Insert is cheaper than deleting or writing lines. Leave
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
721 a hole in the result display that will be filled with
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
722 empty lines when the queue is emptied. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
723 queue->count = 0;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
724 queue->window = i;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
725 queue->pos = i - p->insertcount;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
726 ++queue;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
727
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
728 i -= p->insertcount;
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
729 write_follows_p = 0;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
730 }
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
731 else if (p->deletecost < p->writecost
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
732 && (write_follows_p || i > j))
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
733 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
734 /* Deleting lines is cheaper. By decrementing J, omit
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
735 deletecount lines from the original. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
736 write_follows_p = 0;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
737 j -= p->deletecount;
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
738 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
739 else
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
740 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
741 /* One or more lines should be written. In the direct
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
742 scrolling method we do this by scrolling the lines to the
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
743 place they belong. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
744 int n_to_write = p->writecount;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
745 write_follows_p = 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
746 xassert (n_to_write > 0);
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
747
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
748 if (i > j)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
749 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
750 /* Immediately insert lines */
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
751 set_terminal_window (frame, i + unchanged_at_top);
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
752 terminal_window_p = 1;
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
753 ins_del_lines (frame, j - n_to_write + unchanged_at_top, i - j);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
754 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
755 else if (i < j)
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
756 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
757 /* Queue the deletion of a group of lines */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
758 queue->pos = i - n_to_write + unchanged_at_top;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
759 queue->window = j + unchanged_at_top;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
760 queue->count = i - j;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
761 ++queue;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
762 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
763
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
764 while (n_to_write > 0)
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
765 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
766 --i, --j, --n_to_write;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
767 copy_from[i] = j;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
768 retained_p[j] = 1;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
769 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
770 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
771 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
772
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
773 /* Do queued operations. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
774 if (queue > queue_start)
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
775 {
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
776 int next = -1;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
777
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
778 do
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
779 {
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
780 --queue;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
781 if (queue->count)
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
782 {
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
783 set_terminal_window (frame, queue->window);
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
784 terminal_window_p = 1;
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
785 ins_del_lines (frame, queue->pos, queue->count);
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
786 }
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
787 else
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
788 {
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
789 for (j = queue->window - 1; j >= queue->pos; --j)
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
790 {
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
791 while (retained_p[++next])
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
792 ;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
793 copy_from[j] = next;
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
794 }
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
795 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
796 }
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
797 while (queue > queue_start);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
798 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
799
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
800 /* Now, for each row I in the range of rows we are working on,
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
801 copy_from[i] gives the original line to copy to I, and
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
802 retained_p[copy_from[i]] is zero if line I in the new display is
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
803 empty. */
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
804 mirrored_line_dance (current_matrix, unchanged_at_top, window_size,
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
805 copy_from, retained_p);
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
806
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
807 if (terminal_window_p)
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
808 set_terminal_window (frame, 0);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
809 }
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
810
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
811
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
812
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 void
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
814 scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom,
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
815 draw_cost, old_draw_cost, old_hash, new_hash, free_at_end)
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
816 FRAME_PTR frame;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 int window_size, unchanged_at_top, unchanged_at_bottom;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818 int *draw_cost;
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
819 int *old_draw_cost;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 int *old_hash;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821 int *new_hash;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822 int free_at_end;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
824 struct matrix_elt *matrix;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
825 matrix = ((struct matrix_elt *)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826 alloca ((window_size + 1) * (window_size + 1) * sizeof *matrix));
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827
82990
2ecd1f669db9 Fixed X support, preliminary support for X-tty combo sessions.
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
828 if (FRAME_SCROLL_REGION_OK (frame))
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
829 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
830 calculate_direct_scrolling (frame, matrix, window_size,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
831 unchanged_at_bottom,
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
832 draw_cost, old_draw_cost,
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
833 old_hash, new_hash, free_at_end);
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
834 do_direct_scrolling (frame, frame->current_matrix,
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
835 matrix, window_size, unchanged_at_top);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
836 }
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
837 else
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
838 {
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
839 calculate_scrolling (frame, matrix, window_size, unchanged_at_bottom,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
840 draw_cost, old_hash, new_hash,
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
841 free_at_end);
83100
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
842 do_scrolling (frame,
4970ad4995f5 Eliminated updating_frame.
Karoly Lorentey <lorentey@elte.hu>
parents: 83004
diff changeset
843 frame->current_matrix, matrix, window_size,
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
844 unchanged_at_top);
10262
4face60ac721 (scrolling_1): When scroll_region_ok is set, use a
Richard M. Stallman <rms@gnu.org>
parents: 10109
diff changeset
845 }
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846 }
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
847
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
848
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
850 /* Return number of lines in common between current and desired frame
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
851 contents described to us only as vectors of hash codes OLDHASH and
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
852 NEWHASH. Consider only vpos range START to END (not including
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
853 END). Ignore short lines on the assumption that avoiding redrawing
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
854 such a line will have little weight. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856 int
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 scrolling_max_lines_saved (start, end, oldhash, newhash, cost)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
858 int start, end;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859 int *oldhash, *newhash, *cost;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
860 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861 struct { int hash; int count; } lines[01000];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862 register int i, h;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
863 register int matchcount = 0;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864 int avg_length = 0;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865 int threshold;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
867 /* Compute a threshold which is 1/4 of average length of these lines. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
869 for (i = start; i < end; i++)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
870 avg_length += cost[i];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
871
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872 avg_length /= end - start;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 threshold = avg_length / 4;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
874
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
875 bzero (lines, sizeof lines);
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
876
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
877 /* Put new lines' hash codes in hash table. Ignore lines shorter
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
878 than the threshold. Thus, if the lines that are in common are
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
879 mainly the ones that are short, they won't count. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
880 for (i = start; i < end; i++)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
881 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
882 if (cost[i] > threshold)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
884 h = newhash[i] & 0777;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
885 lines[h].hash = newhash[i];
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
886 lines[h].count++;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
890 /* Look up old line hash codes in the hash table. Count number of
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
891 matches between old lines and new. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892 for (i = start; i < end; i++)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894 h = oldhash[i] & 0777;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895 if (oldhash[i] == lines[h].hash)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897 matchcount++;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
898 if (--lines[h].count == 0)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 lines[h].hash = 0;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 return matchcount;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905
25004
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
906 /* Return a measure of the cost of moving the lines starting with vpos
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
907 FROM, up to but not including vpos TO, down by AMOUNT lines (AMOUNT
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
908 may be negative). These are the same arguments that might be given
bfd115279703 Rewritten.
Gerd Moellmann <gerd@gnu.org>
parents: 21514
diff changeset
909 to scroll_frame_lines to perform this scrolling. */
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 14186
diff changeset
911 int
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
912 scroll_cost (frame, from, to, amount)
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
913 FRAME_PTR frame;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914 int from, to, amount;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915 {
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
916 /* Compute how many lines, at bottom of frame,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 will not be involved in actual motion. */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 int limit = to;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919 int offset;
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
920 int height = FRAME_LINES (frame);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921
421
1cc29824b3f1 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 320
diff changeset
922 if (amount == 0)
1cc29824b3f1 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 320
diff changeset
923 return 0;
1cc29824b3f1 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 320
diff changeset
924
82990
2ecd1f669db9 Fixed X support, preliminary support for X-tty combo sessions.
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
925 if (! FRAME_SCROLL_REGION_OK (frame))
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
926 limit = height;
421
1cc29824b3f1 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 320
diff changeset
927 else if (amount > 0)
1cc29824b3f1 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 320
diff changeset
928 limit += amount;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
930 if (amount < 0)
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 int temp = to;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933 to = from + amount;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 from = temp + amount;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 amount = - amount;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 offset = height - limit;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940 return
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
941 (FRAME_INSERT_COST (frame)[offset + from]
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
942 + (amount - 1) * FRAME_INSERTN_COST (frame)[offset + from]
10109
869e177ca872 (scroll_cost): FRAME_DELETE_COST and FRAME_DELETEN_COSTS were confused. Fixed.
Richard M. Stallman <rms@gnu.org>
parents: 9576
diff changeset
943 + FRAME_DELETE_COST (frame)[offset + to]
869e177ca872 (scroll_cost): FRAME_DELETE_COST and FRAME_DELETEN_COSTS were confused. Fixed.
Richard M. Stallman <rms@gnu.org>
parents: 9576
diff changeset
944 + (amount - 1) * FRAME_DELETEN_COST (frame)[offset + to]);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
946
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
947 /* Calculate the line insertion/deletion
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948 overhead and multiply factor values */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
950 static void
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
951 line_ins_del (frame, ov1, pf1, ovn, pfn, ov, mf)
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
952 FRAME_PTR frame;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953 int ov1, ovn;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
954 int pf1, pfn;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
955 register int *ov, *mf;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
956 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
957 register int i;
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
958 register int frame_lines = FRAME_LINES (frame);
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
959 register int insert_overhead = ov1 * 10;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960 register int next_insert_cost = ovn * 10;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
962 for (i = frame_lines-1; i >= 0; i--)
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963 {
529
413127b220ef *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 421
diff changeset
964 mf[i] = next_insert_cost / 10;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
965 next_insert_cost += pfn;
529
413127b220ef *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 421
diff changeset
966 ov[i] = (insert_overhead + next_insert_cost) / 10;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
967 insert_overhead += pf1;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
968 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
969 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 static void
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
972 ins_del_costs (frame,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973 one_line_string, multi_string,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 setup_string, cleanup_string,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
975 costvec, ncostvec, coefficient)
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
976 FRAME_PTR frame;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
977 char *one_line_string, *multi_string;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
978 char *setup_string, *cleanup_string;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
979 int *costvec, *ncostvec;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 int coefficient;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 {
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 if (multi_string)
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
983 line_ins_del (frame,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984 string_cost (multi_string) * coefficient,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
985 per_line_cost (multi_string) * coefficient,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
986 0, 0, costvec, ncostvec);
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
987 else if (one_line_string)
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
988 line_ins_del (frame,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
989 string_cost (setup_string) + string_cost (cleanup_string), 0,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
990 string_cost (one_line_string),
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
991 per_line_cost (one_line_string),
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
992 costvec, ncostvec);
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
993 else
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
994 line_ins_del (frame,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
995 9999, 0, 9999, 0,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
996 costvec, ncostvec);
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
997 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
998
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
999 /* Calculate the insert and delete line costs.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1000 Note that this is done even when running with a window system
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1001 because we want to know how long scrolling takes (and avoid it).
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1002 This must be redone whenever the frame height changes.
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1003
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004 We keep the ID costs in a precomputed array based on the position
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1005 at which the I or D is performed. Also, there are two kinds of ID
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1006 costs: the "once-only" and the "repeated". This is to handle both
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1007 those terminals that are able to insert N lines at a time (once-
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1008 only) and those that must repeatedly insert one line.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1009
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1010 The cost to insert N lines at line L is
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1011 [tt.t_ILov + (frame_lines + 1 - L) * tt.t_ILpf] +
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1012 N * [tt.t_ILnov + (frame_lines + 1 - L) * tt.t_ILnpf]
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1013
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1014 ILov represents the basic insert line overhead. ILpf is the padding
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1015 required to allow the terminal time to move a line: insertion at line
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1016 L changes (frame_lines + 1 - L) lines.
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1017
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1018 The first bracketed expression above is the overhead; the second is
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1019 the multiply factor. Both are dependent only on the position at
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1020 which the insert is performed. We store the overhead in
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1021 FRAME_INSERT_COST (frame) and the multiply factor in
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1022 FRAME_INSERTN_COST (frame). Note however that any insertion
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1023 must include at least one multiply factor. Rather than compute this
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1024 as FRAME_INSERT_COST (frame)[line]+FRAME_INSERTN_COST (frame)[line],
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1025 we add FRAME_INSERTN_COST (frame) into FRAME_INSERT_COST (frame).
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1026 This is reasonable because of the particular algorithm used in calcM.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1027
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1028 Deletion is essentially the same as insertion.
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1029 */
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1030
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 14186
diff changeset
1031 void
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1032 do_line_insertion_deletion_costs (frame,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1033 ins_line_string, multi_ins_string,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1034 del_line_string, multi_del_string,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1035 setup_string, cleanup_string, coefficient)
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1036 FRAME_PTR frame;
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1037 char *ins_line_string, *multi_ins_string;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1038 char *del_line_string, *multi_del_string;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1039 char *setup_string, *cleanup_string;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1040 int coefficient;
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1041 {
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1042 if (FRAME_INSERT_COST (frame) != 0)
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1043 {
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1044 FRAME_INSERT_COST (frame) =
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1045 (int *) xrealloc (FRAME_INSERT_COST (frame),
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1046 FRAME_LINES (frame) * sizeof (int));
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1047 FRAME_DELETEN_COST (frame) =
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1048 (int *) xrealloc (FRAME_DELETEN_COST (frame),
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1049 FRAME_LINES (frame) * sizeof (int));
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1050 FRAME_INSERTN_COST (frame) =
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1051 (int *) xrealloc (FRAME_INSERTN_COST (frame),
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1052 FRAME_LINES (frame) * sizeof (int));
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1053 FRAME_DELETE_COST (frame) =
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1054 (int *) xrealloc (FRAME_DELETE_COST (frame),
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1055 FRAME_LINES (frame) * sizeof (int));
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1056 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1057 else
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1058 {
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1059 FRAME_INSERT_COST (frame) =
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1060 (int *) xmalloc (FRAME_LINES (frame) * sizeof (int));
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1061 FRAME_DELETEN_COST (frame) =
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1062 (int *) xmalloc (FRAME_LINES (frame) * sizeof (int));
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1063 FRAME_INSERTN_COST (frame) =
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1064 (int *) xmalloc (FRAME_LINES (frame) * sizeof (int));
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48323
diff changeset
1065 FRAME_DELETE_COST (frame) =
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 49600
diff changeset
1066 (int *) xmalloc (FRAME_LINES (frame) * sizeof (int));
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1067 }
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1069 ins_del_costs (frame,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1070 ins_line_string, multi_ins_string,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1071 setup_string, cleanup_string,
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1072 FRAME_INSERT_COST (frame), FRAME_INSERTN_COST (frame),
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1073 coefficient);
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 732
diff changeset
1074 ins_del_costs (frame,
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1075 del_line_string, multi_del_string,
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1076 setup_string, cleanup_string,
9576
14cd96eda0e3 (do_line_insertion_deletion_costs): Fix argument order.
Karl Heuer <kwzh@gnu.org>
parents: 7307
diff changeset
1077 FRAME_DELETE_COST (frame), FRAME_DELETEN_COST (frame),
154
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1078 coefficient);
48df093640da Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1079 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51212
diff changeset
1080
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51212
diff changeset
1081 /* arch-tag: cdb7149c-48e7-4793-a948-2786c8e45485
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51212
diff changeset
1082 (do not change this comment) */