Mercurial > emacs
comparison src/indent.c @ 84951:55a892948dea
* indent.h:
* indent.c: Use EMACS_INT for ints coming from Elisp data.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 27 Sep 2007 18:49:57 +0000 |
parents | 07824eca67a8 |
children | fd8f746ce48f |
comparison
equal
deleted
inserted
replaced
84950:07824eca67a8 | 84951:55a892948dea |
---|---|
51 | 51 |
52 double last_known_column; | 52 double last_known_column; |
53 | 53 |
54 /* Value of point when current_column was called. */ | 54 /* Value of point when current_column was called. */ |
55 | 55 |
56 int last_known_column_point; | 56 EMACS_INT last_known_column_point; |
57 | 57 |
58 /* Value of MODIFF when current_column was called. */ | 58 /* Value of MODIFF when current_column was called. */ |
59 | 59 |
60 int last_known_column_modified; | 60 int last_known_column_modified; |
61 | 61 |
63 static double position_indentation P_ ((int)); | 63 static double position_indentation P_ ((int)); |
64 | 64 |
65 /* Cache of beginning of line found by the last call of | 65 /* Cache of beginning of line found by the last call of |
66 current_column. */ | 66 current_column. */ |
67 | 67 |
68 int current_column_bol_cache; | 68 static EMACS_INT current_column_bol_cache; |
69 | 69 |
70 /* Get the display table to use for the current buffer. */ | 70 /* Get the display table to use for the current buffer. */ |
71 | 71 |
72 struct Lisp_Char_Table * | 72 struct Lisp_Char_Table * |
73 buffer_display_table () | 73 buffer_display_table () |
212 because that could take a long time. We skip a reasonable number | 212 because that could take a long time. We skip a reasonable number |
213 which can be skipped quickly. If there might be more invisible | 213 which can be skipped quickly. If there might be more invisible |
214 characters immediately following, then *NEXT_BOUNDARY_P | 214 characters immediately following, then *NEXT_BOUNDARY_P |
215 will equal the return value. */ | 215 will equal the return value. */ |
216 | 216 |
217 int | 217 EMACS_INT |
218 skip_invisible (pos, next_boundary_p, to, window) | 218 skip_invisible (pos, next_boundary_p, to, window) |
219 int pos; | 219 EMACS_INT pos; |
220 int *next_boundary_p; | 220 EMACS_INT *next_boundary_p; |
221 int to; | 221 EMACS_INT to; |
222 Lisp_Object window; | 222 Lisp_Object window; |
223 { | 223 { |
224 Lisp_Object prop, position, overlay_limit, proplimit; | 224 Lisp_Object prop, position, overlay_limit, proplimit; |
225 Lisp_Object buffer, tmp; | 225 Lisp_Object buffer, tmp; |
226 int end, inv_p; | 226 EMACS_INT end; |
227 int inv_p; | |
227 | 228 |
228 XSETFASTINT (position, pos); | 229 XSETFASTINT (position, pos); |
229 XSETBUFFER (buffer, current_buffer); | 230 XSETBUFFER (buffer, current_buffer); |
230 | 231 |
231 /* Give faster response for overlay lookup near POS. */ | 232 /* Give faster response for overlay lookup near POS. */ |
508 due to text properties or overlays. */ | 509 due to text properties or overlays. */ |
509 | 510 |
510 static double | 511 static double |
511 current_column_1 () | 512 current_column_1 () |
512 { | 513 { |
513 register int tab_width = XINT (current_buffer->tab_width); | 514 register EMACS_INT tab_width = XINT (current_buffer->tab_width); |
514 register int ctl_arrow = !NILP (current_buffer->ctl_arrow); | 515 register int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
515 register struct Lisp_Char_Table *dp = buffer_display_table (); | 516 register struct Lisp_Char_Table *dp = buffer_display_table (); |
516 int multibyte = !NILP (current_buffer->enable_multibyte_characters); | 517 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
517 | 518 |
518 /* Start the scan at the beginning of this line with column number 0. */ | 519 /* Start the scan at the beginning of this line with column number 0. */ |
519 register int col = 0; | 520 register EMACS_INT col = 0; |
520 int scan, scan_byte; | 521 EMACS_INT scan, scan_byte; |
521 int next_boundary; | 522 EMACS_INT next_boundary; |
522 int opoint = PT, opoint_byte = PT_BYTE; | 523 EMACS_INT opoint = PT, opoint_byte = PT_BYTE; |
523 | 524 |
524 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); | 525 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1); |
525 current_column_bol_cache = PT; | 526 current_column_bol_cache = PT; |
526 scan = PT, scan_byte = PT_BYTE; | 527 scan = PT, scan_byte = PT_BYTE; |
527 SET_PT_BOTH (opoint, opoint_byte); | 528 SET_PT_BOTH (opoint, opoint_byte); |
806 | 807 |
807 static double | 808 static double |
808 position_indentation (pos_byte) | 809 position_indentation (pos_byte) |
809 register int pos_byte; | 810 register int pos_byte; |
810 { | 811 { |
811 register int column = 0; | 812 register EMACS_INT column = 0; |
812 register int tab_width = XINT (current_buffer->tab_width); | 813 register EMACS_INT tab_width = XINT (current_buffer->tab_width); |
813 register unsigned char *p; | 814 register unsigned char *p; |
814 register unsigned char *stop; | 815 register unsigned char *stop; |
815 unsigned char *start; | 816 unsigned char *start; |
816 int next_boundary_byte = pos_byte; | 817 EMACS_INT next_boundary_byte = pos_byte; |
817 int ceiling = next_boundary_byte; | 818 EMACS_INT ceiling = next_boundary_byte; |
818 | 819 |
819 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; | 820 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
820 | 821 |
821 p = BYTE_POS_ADDR (pos_byte); | 822 p = BYTE_POS_ADDR (pos_byte); |
822 /* STOP records the value of P at which we will need | 823 /* STOP records the value of P at which we will need |
827 start = p; | 828 start = p; |
828 while (1) | 829 while (1) |
829 { | 830 { |
830 while (p == stop) | 831 while (p == stop) |
831 { | 832 { |
832 int stop_pos_byte; | 833 EMACS_INT stop_pos_byte; |
833 | 834 |
834 /* If we have updated P, set POS_BYTE to match. | 835 /* If we have updated P, set POS_BYTE to match. |
835 The first time we enter the loop, POS_BYTE is already right. */ | 836 The first time we enter the loop, POS_BYTE is already right. */ |
836 if (p != start) | 837 if (p != start) |
837 pos_byte = PTR_BYTE_POS (p); | 838 pos_byte = PTR_BYTE_POS (p); |
838 /* Consider the various reasons STOP might have been set here. */ | 839 /* Consider the various reasons STOP might have been set here. */ |
839 if (pos_byte == ZV_BYTE) | 840 if (pos_byte == ZV_BYTE) |
840 return column; | 841 return column; |
841 if (pos_byte == next_boundary_byte) | 842 if (pos_byte == next_boundary_byte) |
842 { | 843 { |
843 int next_boundary; | 844 EMACS_INT next_boundary; |
844 int pos = BYTE_TO_CHAR (pos_byte); | 845 EMACS_INT pos = BYTE_TO_CHAR (pos_byte); |
845 pos = skip_invisible (pos, &next_boundary, ZV, Qnil); | 846 pos = skip_invisible (pos, &next_boundary, ZV, Qnil); |
846 pos_byte = CHAR_TO_BYTE (pos); | 847 pos_byte = CHAR_TO_BYTE (pos); |
847 next_boundary_byte = CHAR_TO_BYTE (next_boundary); | 848 next_boundary_byte = CHAR_TO_BYTE (next_boundary); |
848 } | 849 } |
849 if (pos_byte >= ceiling) | 850 if (pos_byte >= ceiling) |
1188 accounts for window borders if the window is split horizontally, and | 1189 accounts for window borders if the window is split horizontally, and |
1189 the scroll bars if they are turned on. */ | 1190 the scroll bars if they are turned on. */ |
1190 | 1191 |
1191 struct position * | 1192 struct position * |
1192 compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, hscroll, tab_offset, win) | 1193 compute_motion (from, fromvpos, fromhpos, did_motion, to, tovpos, tohpos, width, hscroll, tab_offset, win) |
1193 int from, fromvpos, fromhpos, to, tovpos, tohpos; | 1194 EMACS_INT from, fromvpos, fromhpos, to, tovpos, tohpos; |
1194 int did_motion; | 1195 EMACS_INT did_motion; |
1195 register int width; | 1196 EMACS_INT width; |
1196 int hscroll, tab_offset; | 1197 EMACS_INT hscroll, tab_offset; |
1197 struct window *win; | 1198 struct window *win; |
1198 { | 1199 { |
1199 register int hpos = fromhpos; | 1200 register EMACS_INT hpos = fromhpos; |
1200 register int vpos = fromvpos; | 1201 register EMACS_INT vpos = fromvpos; |
1201 | 1202 |
1202 register int pos; | 1203 register EMACS_INT pos; |
1203 int pos_byte; | 1204 EMACS_INT pos_byte; |
1204 register int c = 0; | 1205 register int c = 0; |
1205 register int tab_width = XFASTINT (current_buffer->tab_width); | 1206 register EMACS_INT tab_width = XFASTINT (current_buffer->tab_width); |
1206 register int ctl_arrow = !NILP (current_buffer->ctl_arrow); | 1207 register int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
1207 register struct Lisp_Char_Table *dp = window_display_table (win); | 1208 register struct Lisp_Char_Table *dp = window_display_table (win); |
1208 int selective | 1209 int selective |
1209 = (INTEGERP (current_buffer->selective_display) | 1210 = (INTEGERP (current_buffer->selective_display) |
1210 ? XINT (current_buffer->selective_display) | 1211 ? XINT (current_buffer->selective_display) |
1212 int selective_rlen | 1213 int selective_rlen |
1213 = (selective && dp && VECTORP (DISP_INVIS_VECTOR (dp)) | 1214 = (selective && dp && VECTORP (DISP_INVIS_VECTOR (dp)) |
1214 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0); | 1215 ? XVECTOR (DISP_INVIS_VECTOR (dp))->size : 0); |
1215 /* The next location where the `invisible' property changes, or an | 1216 /* The next location where the `invisible' property changes, or an |
1216 overlay starts or ends. */ | 1217 overlay starts or ends. */ |
1217 int next_boundary = from; | 1218 EMACS_INT next_boundary = from; |
1218 | 1219 |
1219 /* For computing runs of characters with similar widths. | 1220 /* For computing runs of characters with similar widths. |
1220 Invariant: width_run_width is zero, or all the characters | 1221 Invariant: width_run_width is zero, or all the characters |
1221 from width_run_start to width_run_end have a fixed width of | 1222 from width_run_start to width_run_end have a fixed width of |
1222 width_run_width. */ | 1223 width_run_width. */ |
1223 int width_run_start = from; | 1224 EMACS_INT width_run_start = from; |
1224 int width_run_end = from; | 1225 EMACS_INT width_run_end = from; |
1225 int width_run_width = 0; | 1226 EMACS_INT width_run_width = 0; |
1226 Lisp_Object *width_table; | 1227 Lisp_Object *width_table; |
1227 Lisp_Object buffer; | 1228 Lisp_Object buffer; |
1228 | 1229 |
1229 /* The next buffer pos where we should consult the width run cache. */ | 1230 /* The next buffer pos where we should consult the width run cache. */ |
1230 int next_width_run = from; | 1231 EMACS_INT next_width_run = from; |
1231 Lisp_Object window; | 1232 Lisp_Object window; |
1232 | 1233 |
1233 int multibyte = !NILP (current_buffer->enable_multibyte_characters); | 1234 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
1234 /* If previous char scanned was a wide character, | 1235 /* If previous char scanned was a wide character, |
1235 this is the column where it ended. Otherwise, this is 0. */ | 1236 this is the column where it ended. Otherwise, this is 0. */ |
1236 int wide_column_end_hpos = 0; | 1237 EMACS_INT wide_column_end_hpos = 0; |
1237 int prev_pos; /* Previous buffer position. */ | 1238 EMACS_INT prev_pos; /* Previous buffer position. */ |
1238 int prev_pos_byte; /* Previous buffer position. */ | 1239 EMACS_INT prev_pos_byte; /* Previous buffer position. */ |
1239 int prev_hpos = 0; | 1240 EMACS_INT prev_hpos = 0; |
1240 int prev_vpos = 0; | 1241 EMACS_INT prev_vpos = 0; |
1241 int contin_hpos; /* HPOS of last column of continued line. */ | 1242 EMACS_INT contin_hpos; /* HPOS of last column of continued line. */ |
1242 int prev_tab_offset; /* Previous tab offset. */ | 1243 EMACS_INT prev_tab_offset; /* Previous tab offset. */ |
1243 int continuation_glyph_width; | 1244 EMACS_INT continuation_glyph_width; |
1244 | 1245 |
1245 XSETBUFFER (buffer, current_buffer); | 1246 XSETBUFFER (buffer, current_buffer); |
1246 XSETWINDOW (window, win); | 1247 XSETWINDOW (window, win); |
1247 | 1248 |
1248 width_run_cache_on_off (); | 1249 width_run_cache_on_off (); |
1284 prev_tab_offset = tab_offset; | 1285 prev_tab_offset = tab_offset; |
1285 while (1) | 1286 while (1) |
1286 { | 1287 { |
1287 while (pos == next_boundary) | 1288 while (pos == next_boundary) |
1288 { | 1289 { |
1289 int pos_here = pos; | 1290 EMACS_INT pos_here = pos; |
1290 int newpos; | 1291 EMACS_INT newpos; |
1291 | 1292 |
1292 /* Don't skip invisible if we are already at the margin. */ | 1293 /* Don't skip invisible if we are already at the margin. */ |
1293 if (vpos > tovpos || (vpos == tovpos && hpos >= tohpos)) | 1294 if (vpos > tovpos || (vpos == tovpos && hpos >= tohpos)) |
1294 { | 1295 { |
1295 if (contin_hpos && prev_hpos == 0 | 1296 if (contin_hpos && prev_hpos == 0 |
1883 | 1884 |
1884 struct position val_vmotion; | 1885 struct position val_vmotion; |
1885 | 1886 |
1886 struct position * | 1887 struct position * |
1887 vmotion (from, vtarget, w) | 1888 vmotion (from, vtarget, w) |
1888 register int from, vtarget; | 1889 register EMACS_INT from, vtarget; |
1889 struct window *w; | 1890 struct window *w; |
1890 { | 1891 { |
1891 int hscroll = XINT (w->hscroll); | 1892 EMACS_INT hscroll = XINT (w->hscroll); |
1892 struct position pos; | 1893 struct position pos; |
1893 /* vpos is cumulative vertical position, changed as from is changed */ | 1894 /* vpos is cumulative vertical position, changed as from is changed */ |
1894 register int vpos = 0; | 1895 register int vpos = 0; |
1895 int prevline; | 1896 EMACS_INT prevline; |
1896 register int first; | 1897 register EMACS_INT first; |
1897 int from_byte; | 1898 EMACS_INT from_byte; |
1898 int lmargin = hscroll > 0 ? 1 - hscroll : 0; | 1899 EMACS_INT lmargin = hscroll > 0 ? 1 - hscroll : 0; |
1899 int selective | 1900 int selective |
1900 = (INTEGERP (current_buffer->selective_display) | 1901 = (INTEGERP (current_buffer->selective_display) |
1901 ? XINT (current_buffer->selective_display) | 1902 ? XINT (current_buffer->selective_display) |
1902 : !NILP (current_buffer->selective_display) ? -1 : 0); | 1903 : !NILP (current_buffer->selective_display) ? -1 : 0); |
1903 Lisp_Object window; | 1904 Lisp_Object window; |
1904 int start_hpos = 0; | 1905 EMACS_INT start_hpos = 0; |
1905 int did_motion; | 1906 int did_motion; |
1906 /* This is the object we use for fetching character properties. */ | 1907 /* This is the object we use for fetching character properties. */ |
1907 Lisp_Object text_prop_object; | 1908 Lisp_Object text_prop_object; |
1908 | 1909 |
1909 XSETWINDOW (window, w); | 1910 XSETWINDOW (window, w); |