diff options
Diffstat (limited to 'src/scroll.c')
| -rw-r--r-- | src/scroll.c | 71 |
1 files changed, 21 insertions, 50 deletions
diff --git a/src/scroll.c b/src/scroll.c index 08ae83eeee8..ba012874460 100644 --- a/src/scroll.c +++ b/src/scroll.c | |||
| @@ -239,14 +239,16 @@ calculate_scrolling (FRAME_PTR frame, | |||
| 239 | of lines. */ | 239 | of lines. */ |
| 240 | 240 | ||
| 241 | static void | 241 | static void |
| 242 | do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, struct matrix_elt *matrix, int window_size, int unchanged_at_top) | 242 | do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, |
| 243 | struct matrix_elt *matrix, int window_size, | ||
| 244 | int unchanged_at_top) | ||
| 243 | { | 245 | { |
| 244 | struct matrix_elt *p; | 246 | struct matrix_elt *p; |
| 245 | int i, j, k; | 247 | int i, j, k; |
| 246 | 248 | ||
| 247 | /* Set to 1 if we have set a terminal window with | 249 | /* Set to 1 if we have set a terminal window with |
| 248 | set_terminal_window. */ | 250 | set_terminal_window. It's unsigned to work around GCC bug 48228. */ |
| 249 | int terminal_window_p = 0; | 251 | unsigned int terminal_window_p = 0; |
| 250 | 252 | ||
| 251 | /* A queue for line insertions to be done. */ | 253 | /* A queue for line insertions to be done. */ |
| 252 | struct queue { int count, pos; }; | 254 | struct queue { int count, pos; }; |
| @@ -262,7 +264,8 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, struct m | |||
| 262 | for (k = 0; k < window_size; ++k) | 264 | for (k = 0; k < window_size; ++k) |
| 263 | copy_from[k] = -1; | 265 | copy_from[k] = -1; |
| 264 | 266 | ||
| 265 | #define CHECK_BOUNDS \ | 267 | #if GLYPH_DEBUG |
| 268 | # define CHECK_BOUNDS \ | ||
| 266 | do \ | 269 | do \ |
| 267 | { \ | 270 | { \ |
| 268 | int k; \ | 271 | int k; \ |
| @@ -271,6 +274,7 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, struct m | |||
| 271 | || (copy_from[k] >= 0 && copy_from[k] < window_size)); \ | 274 | || (copy_from[k] >= 0 && copy_from[k] < window_size)); \ |
| 272 | } \ | 275 | } \ |
| 273 | while (0); | 276 | while (0); |
| 277 | #endif | ||
| 274 | 278 | ||
| 275 | /* When j is advanced, this corresponds to deleted lines. | 279 | /* When j is advanced, this corresponds to deleted lines. |
| 276 | When i is advanced, this corresponds to inserted lines. */ | 280 | When i is advanced, this corresponds to inserted lines. */ |
| @@ -829,7 +833,9 @@ scrolling_1 (FRAME_PTR frame, int window_size, int unchanged_at_top, | |||
| 829 | such a line will have little weight. */ | 833 | such a line will have little weight. */ |
| 830 | 834 | ||
| 831 | int | 835 | int |
| 832 | scrolling_max_lines_saved (int start, int end, int *oldhash, int *newhash, int *cost) | 836 | scrolling_max_lines_saved (int start, int end, |
| 837 | int *oldhash, int *newhash, | ||
| 838 | int *cost) | ||
| 833 | { | 839 | { |
| 834 | struct { int hash; int count; } lines[01000]; | 840 | struct { int hash; int count; } lines[01000]; |
| 835 | register int i, h; | 841 | register int i, h; |
| @@ -876,49 +882,12 @@ scrolling_max_lines_saved (int start, int end, int *oldhash, int *newhash, int * | |||
| 876 | return matchcount; | 882 | return matchcount; |
| 877 | } | 883 | } |
| 878 | 884 | ||
| 879 | /* Return a measure of the cost of moving the lines starting with vpos | ||
| 880 | FROM, up to but not including vpos TO, down by AMOUNT lines (AMOUNT | ||
| 881 | may be negative). */ | ||
| 882 | |||
| 883 | int | ||
| 884 | scroll_cost (FRAME_PTR frame, int from, int to, int amount) | ||
| 885 | { | ||
| 886 | /* Compute how many lines, at bottom of frame, | ||
| 887 | will not be involved in actual motion. */ | ||
| 888 | EMACS_INT limit = to; | ||
| 889 | EMACS_INT offset; | ||
| 890 | EMACS_INT height = FRAME_LINES (frame); | ||
| 891 | |||
| 892 | if (amount == 0) | ||
| 893 | return 0; | ||
| 894 | |||
| 895 | if (! FRAME_SCROLL_REGION_OK (frame)) | ||
| 896 | limit = height; | ||
| 897 | else if (amount > 0) | ||
| 898 | limit += amount; | ||
| 899 | |||
| 900 | if (amount < 0) | ||
| 901 | { | ||
| 902 | int temp = to; | ||
| 903 | to = from + amount; | ||
| 904 | from = temp + amount; | ||
| 905 | amount = - amount; | ||
| 906 | } | ||
| 907 | |||
| 908 | offset = height - limit; | ||
| 909 | |||
| 910 | return | ||
| 911 | (FRAME_INSERT_COST (frame)[offset + from] | ||
| 912 | + (amount - 1) * FRAME_INSERTN_COST (frame)[offset + from] | ||
| 913 | + FRAME_DELETE_COST (frame)[offset + to] | ||
| 914 | + (amount - 1) * FRAME_DELETEN_COST (frame)[offset + to]); | ||
| 915 | } | ||
| 916 | |||
| 917 | /* Calculate the line insertion/deletion | 885 | /* Calculate the line insertion/deletion |
| 918 | overhead and multiply factor values */ | 886 | overhead and multiply factor values */ |
| 919 | 887 | ||
| 920 | static void | 888 | static void |
| 921 | line_ins_del (FRAME_PTR frame, int ov1, int pf1, int ovn, int pfn, register int *ov, register int *mf) | 889 | line_ins_del (FRAME_PTR frame, int ov1, int pf1, int ovn, int pfn, |
| 890 | register int *ov, register int *mf) | ||
| 922 | { | 891 | { |
| 923 | register EMACS_INT i; | 892 | register EMACS_INT i; |
| 924 | register EMACS_INT frame_lines = FRAME_LINES (frame); | 893 | register EMACS_INT frame_lines = FRAME_LINES (frame); |
| @@ -936,8 +905,8 @@ line_ins_del (FRAME_PTR frame, int ov1, int pf1, int ovn, int pfn, register int | |||
| 936 | 905 | ||
| 937 | static void | 906 | static void |
| 938 | ins_del_costs (FRAME_PTR frame, | 907 | ins_del_costs (FRAME_PTR frame, |
| 939 | char *one_line_string, char *multi_string, | 908 | const char *one_line_string, const char *multi_string, |
| 940 | char *setup_string, char *cleanup_string, | 909 | const char *setup_string, const char *cleanup_string, |
| 941 | int *costvec, int *ncostvec, | 910 | int *costvec, int *ncostvec, |
| 942 | int coefficient) | 911 | int coefficient) |
| 943 | { | 912 | { |
| @@ -992,9 +961,12 @@ ins_del_costs (FRAME_PTR frame, | |||
| 992 | 961 | ||
| 993 | void | 962 | void |
| 994 | do_line_insertion_deletion_costs (FRAME_PTR frame, | 963 | do_line_insertion_deletion_costs (FRAME_PTR frame, |
| 995 | char *ins_line_string, char *multi_ins_string, | 964 | const char *ins_line_string, |
| 996 | char *del_line_string, char *multi_del_string, | 965 | const char *multi_ins_string, |
| 997 | char *setup_string, char *cleanup_string, | 966 | const char *del_line_string, |
| 967 | const char *multi_del_string, | ||
| 968 | const char *setup_string, | ||
| 969 | const char *cleanup_string, | ||
| 998 | int coefficient) | 970 | int coefficient) |
| 999 | { | 971 | { |
| 1000 | if (FRAME_INSERT_COST (frame) != 0) | 972 | if (FRAME_INSERT_COST (frame) != 0) |
| @@ -1035,4 +1007,3 @@ do_line_insertion_deletion_costs (FRAME_PTR frame, | |||
| 1035 | FRAME_DELETE_COST (frame), FRAME_DELETEN_COST (frame), | 1007 | FRAME_DELETE_COST (frame), FRAME_DELETEN_COST (frame), |
| 1036 | coefficient); | 1008 | coefficient); |
| 1037 | } | 1009 | } |
| 1038 | |||