Mercurial > hg > xemacs-beta
comparison src/redisplay.c @ 826:6728e641994e
[xemacs-hg @ 2002-05-05 11:30:15 by ben]
syntax cache, 8-bit-format, lots of code cleanup
README.packages: Update info about --package-path.
i.c: Create an inheritable event and pass it on to XEmacs, so that ^C
can be handled properly. Intercept ^C and signal the event.
"Stop Build" in VC++ now works.
bytecomp-runtime.el: Doc string changes.
compat.el: Some attempts to redo this to
make it truly useful and fix the "multiple versions interacting
with each other" problem. Not yet done. Currently doesn't work.
files.el: Use with-obsolete-variable to avoid warnings in new revert-buffer code.
xemacs.mak: Split up CFLAGS into a version without flags specifying the C
library. The problem seems to be that minitar depends on zlib,
which depends specifically on libc.lib, not on any of the other C
libraries. Unless you compile with libc.lib, you get errors --
specifically, no _errno in the other libraries, which must make it
something other than an int. (#### But this doesn't seem to obtain
in XEmacs, which also uses zlib, and can be linked with any of the
C libraries. Maybe zlib is used differently and doesn't need
errno, or maybe XEmacs provides an int errno; ... I don't
understand.
Makefile.in.in: Fix so that packages are around when testing.
abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, cmds.c, console-msw.h, console-stream.c, console-x.c, console.c, console.h, data.c, device-msw.c, device.c, device.h, dialog-msw.c, dialog-x.c, dired-msw.c, dired.c, doc.c, doprnt.c, dumper.c, editfns.c, elhash.c, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, events.h, extents.c, extents.h, faces.c, file-coding.c, file-coding.h, fileio.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, frame.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-msw.h, glyphs-x.c, glyphs.c, glyphs.h, gui-msw.c, gui-x.c, gui.h, gutter.h, hash.h, indent.c, insdel.c, intl-win32.c, intl.c, keymap.c, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, marker.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, nas.c, objects-msw.c, objects-x.c, opaque.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, process.h, profile.c, rangetab.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, regex.h, scrollbar-msw.c, search.c, select-x.c, specifier.c, specifier.h, symbols.c, symsinit.h, syntax.c, syntax.h, syswindows.h, tests.c, text.c, text.h, tooltalk.c, ui-byhand.c, ui-gtk.c, unicode.c, win32.c, window.c: Another big Ben patch.
-- FUNCTIONALITY CHANGES:
add partial support for 8-bit-fixed, 16-bit-fixed, and
32-bit-fixed formats. not quite done yet. (in particular, needs
functions to actually convert the buffer.) NOTE: lots of changes
to regex.c here. also, many new *_fmt() inline funs that take an
Internal_Format argument.
redo syntax cache code. make the cache per-buffer; keep the cache
valid across calls to functions that use it. also keep it valid
across insertions/deletions and extent changes, as much as is
possible. eliminate the junky regex-reentrancy code by passing in
the relevant lisp info to the regex routines as local vars.
add general mechanism in extents code for signalling extent changes.
fix numerous problems with the case-table implementation; yoshiki
never properly transferred many algorithms from old-style to
new-style case tables.
redo char tables to support a default argument, so that mapping
only occurs over changed args. change many chartab functions to
accept Lisp_Object instead of Lisp_Char_Table *.
comment out the code in font-lock.c by default, because
font-lock.el no longer uses it. we should consider eliminating it
entirely.
Don't output bell as ^G in console-stream when not a TTY.
add -mswindows-termination-handle to interface with i.c, so we can
properly kill a build.
add more error-checking to buffer/string macros.
add some additional buffer_or_string_() funs.
-- INTERFACE CHANGES AFFECTING MORE CODE:
switch the arguments of write_c_string and friends to be
consistent with write_fmt_string, which must have printcharfun
first.
change BI_* macros to BYTE_* for increased clarity; similarly for
bi_* local vars.
change VOID_TO_LISP to be a one-argument function. eliminate
no-longer-needed CVOID_TO_LISP.
-- char/string macro changes:
rename MAKE_CHAR() to make_emchar() for slightly less confusion
with make_char(). (The former generates an Emchar, the latter a
Lisp object. Conceivably we should rename make_char() -> wrap_char()
and similarly for make_int(), make_float().)
Similar changes for other *CHAR* macros -- we now consistently use
names with `emchar' whenever we are working with Emchars. Any
remaining name with just `char' always refers to a Lisp object.
rename macros with XSTRING_* to string_* except for those that
reference actual fields in the Lisp_String object, following
conventions used elsewhere.
rename set_string_{data,length} macros (the only ones to work with
a Lisp_String_* instead of a Lisp_Object) to set_lispstringp_*
to make the difference clear.
try to be consistent about caps vs. lowercase in macro/inline-fun
names for chars and such, which wasn't the case before. we now
reserve caps either for XFOO_ macros that reference object fields
(e.g. XSTRING_DATA) or for things that have non-function semantics,
e.g. directly modifying an arg (BREAKUP_EMCHAR) or evaluating an
arg (any arg) more than once. otherwise, use lowercase.
here is a summary of most of the macros/inline funs changed by all
of the above changes:
BYTE_*_P -> byte_*_p
XSTRING_BYTE -> string_byte
set_string_data/length -> set_lispstringp_data/length
XSTRING_CHAR_LENGTH -> string_char_length
XSTRING_CHAR -> string_emchar
INTBYTE_FIRST_BYTE_P -> intbyte_first_byte_p
INTBYTE_LEADING_BYTE_P -> intbyte_leading_byte_p
charptr_copy_char -> charptr_copy_emchar
LEADING_BYTE_* -> leading_byte_*
CHAR_* -> EMCHAR_*
*_CHAR_* -> *_EMCHAR_*
*_CHAR -> *_EMCHAR
CHARSET_BY_ -> charset_by_*
BYTE_SHIFT_JIS* -> byte_shift_jis*
BYTE_BIG5* -> byte_big5*
REP_BYTES_BY_FIRST_BYTE -> rep_bytes_by_first_byte
char_to_unicode -> emchar_to_unicode
valid_char_p -> valid_emchar_p
Change intbyte_strcmp -> qxestrcmp_c (duplicated functionality).
-- INTERFACE CHANGES AFFECTING LESS CODE:
use DECLARE_INLINE_HEADER in various places.
remove '#ifdef emacs' from XEmacs-only files.
eliminate CHAR_TABLE_VALUE(), which duplicated the functionality
of get_char_table().
add BUFFER_TEXT_LOOP to simplify iterations over buffer text.
define typedefs for signed and unsigned types of fixed sizes
(INT_32_BIT, UINT_32_BIT, etc.).
create ALIGN_FOR_TYPE as a higher-level interface onto ALIGN_SIZE;
fix code to use it.
add charptr_emchar_len to return the text length of the character
pointed to by a ptr; use it in place of
charcount_to_bytecount(..., 1). add emchar_len to return the text
length of a given character.
add types Bytexpos and Charxpos to generalize Bytebpos/Bytecount
and Charbpos/Charcount, in code (particularly, the extents code
and redisplay code) that works with either kind of index. rename
redisplay struct params with names such as `charbpos' to
e.g. `charpos' when they are e.g. a Charxpos, not a Charbpos.
eliminate xxDEFUN in place of DEFUN; no longer necessary with
changes awhile back to doc.c.
split up big ugly combined list of EXFUNs in lisp.h on a
file-by-file basis, since other prototypes are similarly split.
rewrite some "*_UNSAFE" macros as inline funs and eliminate the
_UNSAFE suffix.
move most string code from lisp.h to text.h; the string code and
text.h code is now intertwined in such a fashion that they need
to be in the same place and partially interleaved. (you can't
create forward references for inline funs)
automated/lisp-tests.el, automated/symbol-tests.el, automated/test-harness.el: Fix test harness to output FAIL messages to stderr when in
batch mode.
Fix up some problems in lisp-tests/symbol-tests that were
causing spurious failures.
author | ben |
---|---|
date | Sun, 05 May 2002 11:33:57 +0000 |
parents | 6504113e7c2d |
children | e7ee5f8bde58 |
comparison
equal
deleted
inserted
replaced
825:eb3bc15a6e0f | 826:6728e641994e |
---|---|
89 : vertical_clip) | 89 : vertical_clip) |
90 | 90 |
91 /* The following structures are completely private to redisplay.c so | 91 /* The following structures are completely private to redisplay.c so |
92 we put them here instead of in a header file, for modularity. */ | 92 we put them here instead of in a header file, for modularity. */ |
93 | 93 |
94 /* NOTE: Bytebpos's not Charbpos's in this structure. */ | 94 /* NOTE: Bytexpos's not Charxpos's in this structure. */ |
95 | 95 |
96 typedef struct position_redisplay_data_type | 96 typedef struct position_redisplay_data_type |
97 { | 97 { |
98 /* This information is normally filled in by the create_*_block | 98 /* This information is normally filled in by the create_*_block |
99 routines and is used by the add_*_rune routines. */ | 99 routines and is used by the add_*_rune routines. */ |
117 | 117 |
118 int last_char_width; /* The width of the previous character. */ | 118 int last_char_width; /* The width of the previous character. */ |
119 int font_is_bogus; /* If true, it means we couldn't instantiate | 119 int font_is_bogus; /* If true, it means we couldn't instantiate |
120 the font for this charset, so we substitute | 120 the font for this charset, so we substitute |
121 ~'s from the ASCII charset. */ | 121 ~'s from the ASCII charset. */ |
122 Bytebpos bi_charbpos; | 122 Bytexpos byte_charpos; /* Position of character we are processing. This |
123 Bytebpos bi_endpos; | 123 is a Bytexpos, meaning it refers to bytes (not |
124 chars) and can refer to either buffers (1-based) | |
125 or strings (0-based). We need to be careful | |
126 when doing anything that references the text in | |
127 the buffer or string. */ | |
128 Bytexpos byte_endpos; /* ????? Unknown, under-used. */ | |
124 int pixpos; | 129 int pixpos; |
125 int max_pixpos; | 130 int max_pixpos; |
126 int blank_width; /* Width of the blank that is to be added. | 131 int blank_width; /* Width of the blank that is to be added. |
127 This is used to communicate this information | 132 This is used to communicate this information |
128 to add_blank_rune(). | 133 to add_blank_rune(). |
132 blank that exists at the end of the line. | 137 blank that exists at the end of the line. |
133 add_emchar_rune() is called cheesily with | 138 add_emchar_rune() is called cheesily with |
134 the non-printing char '\n', which is stuck | 139 the non-printing char '\n', which is stuck |
135 in the output routines with its width being | 140 in the output routines with its width being |
136 BLANK_WIDTH. */ | 141 BLANK_WIDTH. */ |
137 Bytebpos bi_cursor_charbpos;/* This stores the buffer position of the cursor. */ | 142 Bytexpos byte_cursor_charpos; /* This stores the buffer position of the |
143 cursor. */ | |
138 unsigned int cursor_type :3; | 144 unsigned int cursor_type :3; |
139 int cursor_x; /* rune block cursor is at */ | 145 int cursor_x; /* rune block cursor is at */ |
140 int start_col; /* Number of character columns (each column has | 146 int start_col; /* Number of character columns (each column has |
141 a width of the default char width) that still | 147 a width of the default char width) that still |
142 need to be skipped. This is used for horizontal | 148 need to be skipped. This is used for horizontal |
143 scrolling, where a certain number of columns | 149 scrolling, where a certain number of columns |
144 (those off the left side of the screen) need | 150 (those off the left side of the screen) need |
145 to be skipped before anything is displayed. */ | 151 to be skipped before anything is displayed. */ |
146 Bytebpos bi_start_col_enabled; | 152 Bytexpos byte_start_col_enabled; |
147 int start_col_xoffset; /* Number of pixels that still need to | 153 int start_col_xoffset; /* Number of pixels that still need to |
148 be skipped. This is used for | 154 be skipped. This is used for |
149 horizontal scrolling of glyphs, where we want | 155 horizontal scrolling of glyphs, where we want |
150 to be able to scroll over part of the glyph. */ | 156 to be able to scroll over part of the glyph. */ |
151 | 157 |
227 } p_string; | 233 } p_string; |
228 | 234 |
229 struct | 235 struct |
230 { | 236 { |
231 Emchar ch; | 237 Emchar ch; |
232 Bytebpos bi_cursor_charbpos; /* NOTE: is in Bytebposs */ | 238 Bytebpos byte_cursor_charpos; /* NOTE: is in Bytebpos's */ |
233 unsigned int cursor_type :3; | 239 unsigned int cursor_type :3; |
234 } p_char; | 240 } p_char; |
235 | 241 |
236 struct | 242 struct |
237 { | 243 { |
265 static prop_block_dynarr *add_glyph_rune (pos_data *data, | 271 static prop_block_dynarr *add_glyph_rune (pos_data *data, |
266 struct glyph_block *gb, | 272 struct glyph_block *gb, |
267 int pos_type, int allow_cursor, | 273 int pos_type, int allow_cursor, |
268 struct glyph_cachel *cachel); | 274 struct glyph_cachel *cachel); |
269 static Bytebpos create_text_block (struct window *w, struct display_line *dl, | 275 static Bytebpos create_text_block (struct window *w, struct display_line *dl, |
270 Bytebpos bi_start_pos, prop_block_dynarr **prop, | 276 Bytebpos byte_start_pos, |
271 int type); | 277 prop_block_dynarr **prop, |
278 int type); | |
272 static int create_overlay_glyph_block (struct window *w, | 279 static int create_overlay_glyph_block (struct window *w, |
273 struct display_line *dl); | 280 struct display_line *dl); |
274 static void create_left_glyph_block (struct window *w, | 281 static void create_left_glyph_block (struct window *w, |
275 struct display_line *dl, | 282 struct display_line *dl, |
276 int overlay_width); | 283 int overlay_width); |
277 static void create_right_glyph_block (struct window *w, | 284 static void create_right_glyph_block (struct window *w, |
278 struct display_line *dl); | 285 struct display_line *dl); |
279 static void redisplay_windows (Lisp_Object window, int skip_selected); | 286 static void redisplay_windows (Lisp_Object window, int skip_selected); |
280 static void decode_mode_spec (struct window *w, Emchar spec, int type); | 287 static void decode_mode_spec (struct window *w, Emchar spec, int type); |
281 static void free_display_line (struct display_line *dl); | 288 static void free_display_line (struct display_line *dl); |
282 static void update_line_start_cache (struct window *w, Charbpos from, Charbpos to, | 289 static void update_line_start_cache (struct window *w, Charbpos from, |
283 Charbpos point, int no_regen); | 290 Charbpos to, Charbpos point, |
291 int no_regen); | |
284 static int point_visible (struct window *w, Charbpos point, int type); | 292 static int point_visible (struct window *w, Charbpos point, int type); |
285 static void calculate_yoffset (struct display_line *dl, | 293 static void calculate_yoffset (struct display_line *dl, |
286 struct display_block *fixup); | 294 struct display_block *fixup); |
287 static void calculate_baseline (pos_data *data); | 295 static void calculate_baseline (pos_data *data); |
288 | 296 |
814 static Charbpos | 822 static Charbpos |
815 generate_display_line (struct window *w, struct display_line *dl, int bounds, | 823 generate_display_line (struct window *w, struct display_line *dl, int bounds, |
816 Charbpos start_pos, prop_block_dynarr **prop, | 824 Charbpos start_pos, prop_block_dynarr **prop, |
817 int type) | 825 int type) |
818 { | 826 { |
819 Charbpos ret_charbpos; | 827 Charbpos ret_charpos; |
820 int overlay_width; | 828 int overlay_width; |
821 struct buffer *b = XBUFFER (WINDOW_BUFFER (w)); | 829 struct buffer *b = XBUFFER (WINDOW_BUFFER (w)); |
822 | 830 |
823 /* If our caller hasn't already set the boundaries, then do so now. */ | 831 /* If our caller hasn't already set the boundaries, then do so now. */ |
824 if (!bounds) | 832 if (!bounds) |
845 { | 853 { |
846 /* #### urk urk urk!!! Chuck fix this shit! */ | 854 /* #### urk urk urk!!! Chuck fix this shit! */ |
847 Bytebpos hacked_up_bytebpos = | 855 Bytebpos hacked_up_bytebpos = |
848 create_text_block (w, dl, charbpos_to_bytebpos (b, start_pos), | 856 create_text_block (w, dl, charbpos_to_bytebpos (b, start_pos), |
849 prop, type); | 857 prop, type); |
850 if (hacked_up_bytebpos > BI_BUF_ZV (b)) | 858 if (hacked_up_bytebpos > BYTE_BUF_ZV (b)) |
851 ret_charbpos = BUF_ZV (b) + 1; | 859 ret_charpos = BUF_ZV (b) + 1; |
852 else | 860 else |
853 ret_charbpos = bytebpos_to_charbpos (b, hacked_up_bytebpos); | 861 ret_charpos = bytebpos_to_charbpos (b, hacked_up_bytebpos); |
854 } | 862 } |
855 dl->charbpos = start_pos; | 863 dl->charpos = start_pos; |
856 if (dl->end_charbpos < dl->charbpos) | 864 if (dl->end_charpos < dl->charpos) |
857 dl->end_charbpos = dl->charbpos; | 865 dl->end_charpos = dl->charpos; |
858 | 866 |
859 if (MARKERP (Voverlay_arrow_position) | 867 if (MARKERP (Voverlay_arrow_position) |
860 && EQ (w->buffer, Fmarker_buffer (Voverlay_arrow_position)) | 868 && EQ (w->buffer, Fmarker_buffer (Voverlay_arrow_position)) |
861 && start_pos == marker_position (Voverlay_arrow_position) | 869 && start_pos == marker_position (Voverlay_arrow_position) |
862 && (STRINGP (Voverlay_arrow_string) | 870 && (STRINGP (Voverlay_arrow_string) |
878 create_right_glyph_block (w, dl); | 886 create_right_glyph_block (w, dl); |
879 | 887 |
880 /* In the future additional types of display blocks may be generated | 888 /* In the future additional types of display blocks may be generated |
881 here. */ | 889 here. */ |
882 | 890 |
883 w->last_redisplay_pos = ret_charbpos; | 891 w->last_redisplay_pos = ret_charpos; |
884 | 892 |
885 return ret_charbpos; | 893 return ret_charpos; |
886 } | 894 } |
887 | 895 |
888 /* Adds an hscroll glyph to a display block. If this is called, then | 896 /* Adds an hscroll glyph to a display block. If this is called, then |
889 the block had better be empty. | 897 the block had better be empty. |
890 | 898 |
891 Yes, there are multiple places where this function is called but | 899 Yes, there are multiple places where this function is called but |
892 that is the way it has to be. Each calling function has to deal | 900 that is the way it has to be. Each calling function has to deal |
893 with bi_start_col_enabled a little differently depending on the | 901 with byte_start_col_enabled a little differently depending on the |
894 object being worked with. */ | 902 object being worked with. */ |
895 | 903 |
896 static prop_block_dynarr * | 904 static prop_block_dynarr * |
897 add_hscroll_rune (pos_data *data) | 905 add_hscroll_rune (pos_data *data) |
898 { | 906 { |
899 struct glyph_block gb; | 907 struct glyph_block gb; |
900 prop_block_dynarr *retval; | 908 prop_block_dynarr *retval; |
901 Bytebpos bi_old_cursor_charbpos = data->bi_cursor_charbpos; | 909 Bytebpos byte_old_cursor_charpos = data->byte_cursor_charpos; |
902 int old_cursor_type = data->cursor_type; | 910 int old_cursor_type = data->cursor_type; |
903 Bytebpos bi_old_charbpos = data->bi_charbpos; | 911 Bytebpos byte_old_charpos = data->byte_charpos; |
904 | 912 |
905 if (data->cursor_type == CURSOR_ON | 913 if (data->cursor_type == CURSOR_ON |
906 && data->bi_cursor_charbpos >= data->bi_start_col_enabled | 914 && data->byte_cursor_charpos >= data->byte_start_col_enabled |
907 && data->bi_cursor_charbpos <= data->bi_charbpos) | 915 && data->byte_cursor_charpos <= data->byte_charpos) |
908 { | 916 { |
909 data->bi_cursor_charbpos = data->bi_start_col_enabled; | 917 data->byte_cursor_charpos = data->byte_start_col_enabled; |
910 } | 918 } |
911 else | 919 else |
912 { | 920 { |
913 data->cursor_type = NO_CURSOR; | 921 data->cursor_type = NO_CURSOR; |
914 } | 922 } |
915 | 923 |
916 data->bi_endpos = data->bi_charbpos; | 924 data->byte_endpos = data->byte_charpos; |
917 data->bi_charbpos = data->bi_start_col_enabled; | 925 data->byte_charpos = data->byte_start_col_enabled; |
918 | 926 |
919 gb.extent = Qnil; | 927 gb.extent = Qnil; |
920 gb.glyph = Vhscroll_glyph; | 928 gb.glyph = Vhscroll_glyph; |
921 { | 929 { |
922 int oldpixpos = data->pixpos; | 930 int oldpixpos = data->pixpos; |
924 GLYPH_CACHEL (XWINDOW (data->window), | 932 GLYPH_CACHEL (XWINDOW (data->window), |
925 HSCROLL_GLYPH_INDEX)); | 933 HSCROLL_GLYPH_INDEX)); |
926 data->hscroll_glyph_width_adjust = | 934 data->hscroll_glyph_width_adjust = |
927 data->pixpos - oldpixpos - space_width (XWINDOW (data->window)); | 935 data->pixpos - oldpixpos - space_width (XWINDOW (data->window)); |
928 } | 936 } |
929 data->bi_endpos = 0; | 937 data->byte_endpos = 0; |
930 data->bi_cursor_charbpos = bi_old_cursor_charbpos; | 938 data->byte_cursor_charpos = byte_old_cursor_charpos; |
931 data->cursor_type = old_cursor_type; | 939 data->cursor_type = old_cursor_type; |
932 data->bi_charbpos = bi_old_charbpos; | 940 data->byte_charpos = byte_old_charpos; |
933 | 941 |
934 data->bi_start_col_enabled = 0; | 942 data->byte_start_col_enabled = 0; |
935 return retval; | 943 return retval; |
936 } | 944 } |
937 | 945 |
938 /* Adds a character rune to a display block. If there is not enough room | 946 /* Adds a character rune to a display block. If there is not enough room |
939 to fit the rune on the display block (as determined by the MAX_PIXPOS) | 947 to fit the rune on the display block (as determined by the MAX_PIXPOS) |
953 | 961 |
954 if (data->start_col) | 962 if (data->start_col) |
955 return NULL; | 963 return NULL; |
956 } | 964 } |
957 | 965 |
958 if (data->bi_start_col_enabled) | 966 if (data->byte_start_col_enabled) |
959 { | 967 { |
960 return add_hscroll_rune (data); | 968 return add_hscroll_rune (data); |
961 } | 969 } |
962 | 970 |
963 if (data->ch == '\n') | 971 if (data->ch == '\n') |
966 /* Cheesy end-of-line pseudo-character. */ | 974 /* Cheesy end-of-line pseudo-character. */ |
967 width = data->blank_width; | 975 width = data->blank_width; |
968 } | 976 } |
969 else | 977 else |
970 { | 978 { |
971 Lisp_Object charset = CHAR_CHARSET (data->ch); | 979 Lisp_Object charset = emchar_charset (data->ch); |
972 if (!EQ (charset, data->last_charset) || | 980 if (!EQ (charset, data->last_charset) || |
973 data->findex != data->last_findex) | 981 data->findex != data->last_findex) |
974 { | 982 { |
975 /* OK, we need to do things the hard way. */ | 983 /* OK, we need to do things the hard way. */ |
976 struct window *w = XWINDOW (data->window); | 984 struct window *w = XWINDOW (data->window); |
1034 } | 1042 } |
1035 | 1043 |
1036 crb->findex = data->findex; | 1044 crb->findex = data->findex; |
1037 crb->xpos = data->pixpos; | 1045 crb->xpos = data->pixpos; |
1038 crb->width = width; | 1046 crb->width = width; |
1039 if (data->bi_charbpos) | 1047 if (data->byte_charpos) |
1040 { | 1048 { |
1041 if (NILP (data->string)) | 1049 if (NILP (data->string)) |
1042 crb->charbpos = | 1050 crb->charpos = |
1043 bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER | 1051 bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER |
1044 (XWINDOW (data->window))), | 1052 (XWINDOW (data->window))), |
1045 data->bi_charbpos); | 1053 data->byte_charpos); |
1046 else | 1054 else |
1047 crb->charbpos = | 1055 crb->charpos = |
1048 string_index_byte_to_char (data->string, data->bi_charbpos); | 1056 string_index_byte_to_char (data->string, data->byte_charpos); |
1049 } | 1057 } |
1050 else if (data->is_modeline) | 1058 else if (data->is_modeline) |
1051 crb->charbpos = data->modeline_charpos; | 1059 crb->charpos = data->modeline_charpos; |
1052 else | 1060 else |
1053 /* Text but not in buffer */ | 1061 /* Text but not in buffer */ |
1054 crb->charbpos = 0; | 1062 crb->charpos = 0; |
1055 crb->type = RUNE_CHAR; | 1063 crb->type = RUNE_CHAR; |
1056 crb->object.chr.ch = data->font_is_bogus ? '~' : data->ch; | 1064 crb->object.chr.ch = data->font_is_bogus ? '~' : data->ch; |
1057 crb->endpos = 0; | 1065 crb->endpos = 0; |
1058 | 1066 |
1059 if (data->cursor_type == CURSOR_ON) | 1067 if (data->cursor_type == CURSOR_ON) |
1060 { | 1068 { |
1061 if (data->bi_charbpos == data->bi_cursor_charbpos) | 1069 if (data->byte_charpos == data->byte_cursor_charpos) |
1062 { | 1070 { |
1063 crb->cursor_type = CURSOR_ON; | 1071 crb->cursor_type = CURSOR_ON; |
1064 data->cursor_x = Dynarr_length (data->db->runes); | 1072 data->cursor_x = Dynarr_length (data->db->runes); |
1065 } | 1073 } |
1066 else | 1074 else |
1199 assert (data->pixpos + data->blank_width <= data->max_pixpos); | 1207 assert (data->pixpos + data->blank_width <= data->max_pixpos); |
1200 | 1208 |
1201 rb.findex = data->findex; | 1209 rb.findex = data->findex; |
1202 rb.xpos = data->pixpos; | 1210 rb.xpos = data->pixpos; |
1203 rb.width = data->blank_width; | 1211 rb.width = data->blank_width; |
1204 if (data->bi_charbpos) | 1212 if (data->byte_charpos) |
1205 rb.charbpos = | 1213 rb.charpos = |
1206 bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER (XWINDOW (data->window))), | 1214 bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER (XWINDOW (data->window))), |
1207 data->bi_charbpos); | 1215 data->byte_charpos); |
1208 else | 1216 else |
1209 /* #### and this is really correct too? */ | 1217 /* #### and this is really correct too? */ |
1210 rb.charbpos = 0; | 1218 rb.charpos = 0; |
1211 rb.endpos = 0; | 1219 rb.endpos = 0; |
1212 rb.type = RUNE_BLANK; | 1220 rb.type = RUNE_BLANK; |
1213 | 1221 |
1214 if (data->cursor_type == CURSOR_ON) | 1222 if (data->cursor_type == CURSOR_ON) |
1215 { | 1223 { |
1216 if (data->bi_charbpos == data->bi_cursor_charbpos) | 1224 if (data->byte_charpos == data->byte_cursor_charpos) |
1217 { | 1225 { |
1218 rb.cursor_type = CURSOR_ON; | 1226 rb.cursor_type = CURSOR_ON; |
1219 data->cursor_x = Dynarr_length (data->db->runes); | 1227 data->cursor_x = Dynarr_length (data->db->runes); |
1220 } | 1228 } |
1221 else | 1229 else |
1266 if (data->start_col) | 1274 if (data->start_col) |
1267 data->start_col--; | 1275 data->start_col--; |
1268 | 1276 |
1269 if (!data->start_col) | 1277 if (!data->start_col) |
1270 { | 1278 { |
1271 if (data->bi_start_col_enabled) | 1279 if (data->byte_start_col_enabled) |
1272 { | 1280 { |
1273 add_failed = add_hscroll_rune (data); | 1281 add_failed = add_hscroll_rune (data); |
1274 } | 1282 } |
1275 else | 1283 else |
1276 { | 1284 { |
1342 if (data->start_col) | 1350 if (data->start_col) |
1343 data->start_col--; | 1351 data->start_col--; |
1344 | 1352 |
1345 if (!data->start_col) | 1353 if (!data->start_col) |
1346 { | 1354 { |
1347 if (data->bi_start_col_enabled) | 1355 if (data->byte_start_col_enabled) |
1348 { | 1356 { |
1349 prop_block_dynarr *retval; | 1357 prop_block_dynarr *retval; |
1350 | 1358 |
1351 retval = add_hscroll_rune (data); | 1359 retval = add_hscroll_rune (data); |
1352 if (retval) | 1360 if (retval) |
1410 else if (GLYPHP (entry)) | 1418 else if (GLYPHP (entry)) |
1411 { | 1419 { |
1412 if (data->start_col) | 1420 if (data->start_col) |
1413 data->start_col--; | 1421 data->start_col--; |
1414 | 1422 |
1415 if (!data->start_col && data->bi_start_col_enabled) | 1423 if (!data->start_col && data->byte_start_col_enabled) |
1416 { | 1424 { |
1417 prop = add_hscroll_rune (data); | 1425 prop = add_hscroll_rune (data); |
1418 } | 1426 } |
1419 else | 1427 else |
1420 { | 1428 { |
1523 /* #### This function also doesn't even pay attention to ADD_FAILED! | 1531 /* #### This function also doesn't even pay attention to ADD_FAILED! |
1524 This is seriously fucked! Seven ####'s in 130 lines -- is that a | 1532 This is seriously fucked! Seven ####'s in 130 lines -- is that a |
1525 record? */ | 1533 record? */ |
1526 int elt; | 1534 int elt; |
1527 prop_block_dynarr *add_failed; | 1535 prop_block_dynarr *add_failed; |
1528 Bytebpos bi_old_cursor_charbpos = data->bi_cursor_charbpos; | 1536 Bytebpos byte_old_cursor_charpos = data->byte_cursor_charpos; |
1529 int old_cursor_type = data->cursor_type; | 1537 int old_cursor_type = data->cursor_type; |
1530 | 1538 |
1531 for (elt = 0; elt < Dynarr_length (*prop); elt++) | 1539 for (elt = 0; elt < Dynarr_length (*prop); elt++) |
1532 { | 1540 { |
1533 struct prop_block *pb = Dynarr_atp (*prop, elt); | 1541 struct prop_block *pb = Dynarr_atp (*prop, elt); |
1534 | 1542 |
1535 switch (pb->type) | 1543 switch (pb->type) |
1536 { | 1544 { |
1537 case PROP_CHAR: | 1545 case PROP_CHAR: |
1538 data->ch = pb->data.p_char.ch; | 1546 data->ch = pb->data.p_char.ch; |
1539 data->bi_cursor_charbpos = pb->data.p_char.bi_cursor_charbpos; | 1547 data->byte_cursor_charpos = pb->data.p_char.byte_cursor_charpos; |
1540 data->cursor_type = pb->data.p_char.cursor_type; | 1548 data->cursor_type = pb->data.p_char.cursor_type; |
1541 add_failed = add_emchar_rune (data); | 1549 add_failed = add_emchar_rune (data); |
1542 | 1550 |
1543 if (add_failed) | 1551 if (add_failed) |
1544 goto oops_no_more_space; | 1552 goto oops_no_more_space; |
1551 once that function is fixed. */ | 1559 once that function is fixed. */ |
1552 break; | 1560 break; |
1553 case PROP_MINIBUF_PROMPT: | 1561 case PROP_MINIBUF_PROMPT: |
1554 { | 1562 { |
1555 face_index old_findex = data->findex; | 1563 face_index old_findex = data->findex; |
1556 Bytebpos bi_old_charbpos = data->bi_charbpos; | 1564 Bytebpos byte_old_charpos = data->byte_charpos; |
1557 | 1565 |
1558 data->findex = DEFAULT_INDEX; | 1566 data->findex = DEFAULT_INDEX; |
1559 data->bi_charbpos = 0; | 1567 data->byte_charpos = 0; |
1560 data->cursor_type = NO_CURSOR; | 1568 data->cursor_type = NO_CURSOR; |
1561 | 1569 |
1562 while (pb->data.p_string.len > 0) | 1570 while (pb->data.p_string.len > 0) |
1563 { | 1571 { |
1564 data->ch = charptr_emchar (pb->data.p_string.str); | 1572 data->ch = charptr_emchar (pb->data.p_string.str); |
1565 add_failed = add_emchar_rune (data); | 1573 add_failed = add_emchar_rune (data); |
1566 | 1574 |
1567 if (add_failed) | 1575 if (add_failed) |
1568 { | 1576 { |
1569 data->findex = old_findex; | 1577 data->findex = old_findex; |
1570 data->bi_charbpos = bi_old_charbpos; | 1578 data->byte_charpos = byte_old_charpos; |
1571 goto oops_no_more_space; | 1579 goto oops_no_more_space; |
1572 } | 1580 } |
1573 else | 1581 else |
1574 { | 1582 { |
1575 /* Complicated equivalent of ptr++, len-- */ | 1583 /* Complicated equivalent of ptr++, len-- */ |
1579 } | 1587 } |
1580 } | 1588 } |
1581 | 1589 |
1582 data->findex = old_findex; | 1590 data->findex = old_findex; |
1583 /* ##### FIXME FIXME FIXME -- Upon successful return from | 1591 /* ##### FIXME FIXME FIXME -- Upon successful return from |
1584 this function, data->bi_charbpos is automatically incremented. | 1592 this function, data->byte_charpos is automatically incremented. |
1585 However, we don't want that to happen if we were adding | 1593 However, we don't want that to happen if we were adding |
1586 the minibuffer prompt. */ | 1594 the minibuffer prompt. */ |
1587 { | 1595 { |
1588 struct buffer *buf = | 1596 struct buffer *buf = |
1589 XBUFFER (WINDOW_BUFFER (XWINDOW (data->window))); | 1597 XBUFFER (WINDOW_BUFFER (XWINDOW (data->window))); |
1590 /* #### Chuck fix this shit or I'm gonna scream! */ | 1598 /* #### Chuck fix this shit or I'm gonna scream! */ |
1591 if (bi_old_charbpos > BI_BUF_BEGV (buf)) | 1599 if (byte_old_charpos > BYTE_BUF_BEGV (buf)) |
1592 data->bi_charbpos = prev_bytebpos (buf, bi_old_charbpos); | 1600 data->byte_charpos = prev_bytebpos (buf, byte_old_charpos); |
1593 else | 1601 else |
1594 /* #### is this correct? Does anyone know? | 1602 /* #### is this correct? Does anyone know? |
1595 Does anyone care? Is this a cheesy hack or what? */ | 1603 Does anyone care? Is this a cheesy hack or what? */ |
1596 data->bi_charbpos = BI_BUF_BEGV (buf) - 1; | 1604 data->byte_charpos = BYTE_BUF_BEGV (buf) - 1; |
1597 } | 1605 } |
1598 } | 1606 } |
1599 break; | 1607 break; |
1600 case PROP_BLANK: | 1608 case PROP_BLANK: |
1601 { | 1609 { |
1605 int old_width = data->blank_width; | 1613 int old_width = data->blank_width; |
1606 face_index old_findex = data->findex; | 1614 face_index old_findex = data->findex; |
1607 | 1615 |
1608 data->findex = pb->data.p_blank.findex; | 1616 data->findex = pb->data.p_blank.findex; |
1609 data->blank_width = pb->data.p_blank.width; | 1617 data->blank_width = pb->data.p_blank.width; |
1610 data->bi_cursor_charbpos = 0; | 1618 data->byte_cursor_charpos = 0; |
1611 data->cursor_type = IGNORE_CURSOR; | 1619 data->cursor_type = IGNORE_CURSOR; |
1612 | 1620 |
1613 if (data->pixpos + data->blank_width > data->max_pixpos) | 1621 if (data->pixpos + data->blank_width > data->max_pixpos) |
1614 data->blank_width = data->max_pixpos - data->pixpos; | 1622 data->blank_width = data->max_pixpos - data->pixpos; |
1615 | 1623 |
1638 } | 1646 } |
1639 } | 1647 } |
1640 | 1648 |
1641 oops_no_more_space: | 1649 oops_no_more_space: |
1642 | 1650 |
1643 data->bi_cursor_charbpos = bi_old_cursor_charbpos; | 1651 data->byte_cursor_charpos = byte_old_cursor_charpos; |
1644 data->cursor_type = old_cursor_type; | 1652 data->cursor_type = old_cursor_type; |
1645 if (elt < Dynarr_length (*prop)) | 1653 if (elt < Dynarr_length (*prop)) |
1646 { | 1654 { |
1647 Dynarr_delete_many (*prop, 0, elt); | 1655 Dynarr_delete_many (*prop, 0, elt); |
1648 return *prop; | 1656 return *prop; |
1842 ERROR_ME_DEBUG_WARN, 1); | 1850 ERROR_ME_DEBUG_WARN, 1); |
1843 if (TEXT_IMAGE_INSTANCEP (instance)) | 1851 if (TEXT_IMAGE_INSTANCEP (instance)) |
1844 { | 1852 { |
1845 Lisp_Object string = XIMAGE_INSTANCE_TEXT_STRING (instance); | 1853 Lisp_Object string = XIMAGE_INSTANCE_TEXT_STRING (instance); |
1846 face_index orig_findex = data->findex; | 1854 face_index orig_findex = data->findex; |
1847 Bytebpos orig_charbpos = data->bi_charbpos; | 1855 Bytebpos orig_charpos = data->byte_charpos; |
1848 Bytebpos orig_start_col_enabled = data->bi_start_col_enabled; | 1856 Bytebpos orig_start_col_enabled = data->byte_start_col_enabled; |
1849 | 1857 |
1850 data->findex = findex; | 1858 data->findex = findex; |
1851 data->bi_start_col_enabled = 0; | 1859 data->byte_start_col_enabled = 0; |
1852 if (!allow_cursor) | 1860 if (!allow_cursor) |
1853 data->bi_charbpos = 0; | 1861 data->byte_charpos = 0; |
1854 add_intbyte_string_runes (data, XSTRING_DATA (string), | 1862 add_intbyte_string_runes (data, XSTRING_DATA (string), |
1855 XSTRING_LENGTH (string), 0, 1); | 1863 XSTRING_LENGTH (string), 0, 1); |
1856 data->findex = orig_findex; | 1864 data->findex = orig_findex; |
1857 data->bi_charbpos = orig_charbpos; | 1865 data->byte_charpos = orig_charpos; |
1858 data->bi_start_col_enabled = orig_start_col_enabled; | 1866 data->byte_start_col_enabled = orig_start_col_enabled; |
1859 return retval; | 1867 return retval; |
1860 } | 1868 } |
1861 | 1869 |
1862 rb.findex = findex; | 1870 rb.findex = findex; |
1863 rb.xpos = data->pixpos; | 1871 rb.xpos = data->pixpos; |
1864 rb.width = width; | 1872 rb.width = width; |
1865 rb.charbpos = 0; /* glyphs are never "at" anywhere */ | 1873 rb.charpos = 0; /* glyphs are never "at" anywhere */ |
1866 if (data->bi_endpos) | 1874 if (data->byte_endpos) |
1867 /* #### is this necessary at all? */ | 1875 /* #### is this necessary at all? */ |
1868 rb.endpos = bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER (w)), | 1876 rb.endpos = bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER (w)), |
1869 data->bi_endpos); | 1877 data->byte_endpos); |
1870 else | 1878 else |
1871 rb.endpos = 0; | 1879 rb.endpos = 0; |
1872 rb.type = RUNE_DGLYPH; | 1880 rb.type = RUNE_DGLYPH; |
1873 rb.object.dglyph.glyph = gb->glyph; | 1881 rb.object.dglyph.glyph = gb->glyph; |
1874 rb.object.dglyph.extent = gb->extent; | 1882 rb.object.dglyph.extent = gb->extent; |
1877 rb.object.dglyph.yoffset = 0; /* Until we know better, assume that it has | 1885 rb.object.dglyph.yoffset = 0; /* Until we know better, assume that it has |
1878 a normal (textual) baseline. */ | 1886 a normal (textual) baseline. */ |
1879 | 1887 |
1880 if (allow_cursor) | 1888 if (allow_cursor) |
1881 { | 1889 { |
1882 rb.charbpos = bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER (w)), | 1890 rb.charpos = bytebpos_to_charbpos (XBUFFER (WINDOW_BUFFER (w)), |
1883 data->bi_charbpos); | 1891 data->byte_charpos); |
1884 | 1892 |
1885 if (data->cursor_type == CURSOR_ON) | 1893 if (data->cursor_type == CURSOR_ON) |
1886 { | 1894 { |
1887 if (data->bi_charbpos == data->bi_cursor_charbpos) | 1895 if (data->byte_charpos == data->byte_cursor_charpos) |
1888 { | 1896 { |
1889 rb.cursor_type = CURSOR_ON; | 1897 rb.cursor_type = CURSOR_ON; |
1890 data->cursor_x = Dynarr_length (data->db->runes); | 1898 data->cursor_x = Dynarr_length (data->db->runes); |
1891 } | 1899 } |
1892 else | 1900 else |
1976 | 1984 |
1977 /* Given a position for a buffer in a window, ensure that the given | 1985 /* Given a position for a buffer in a window, ensure that the given |
1978 display line DL accurately represents the text on a line starting | 1986 display line DL accurately represents the text on a line starting |
1979 at the given position. | 1987 at the given position. |
1980 | 1988 |
1981 NOTE NOTE NOTE NOTE: This function works with and returns Bytebposs. | 1989 NOTE NOTE NOTE NOTE: This function works with and returns Bytebpos's. |
1982 You must do appropriate conversion. */ | 1990 You must do appropriate conversion. */ |
1983 | 1991 |
1984 static Bytebpos | 1992 static Bytebpos |
1985 create_text_block (struct window *w, struct display_line *dl, | 1993 create_text_block (struct window *w, struct display_line *dl, |
1986 Bytebpos bi_start_pos, prop_block_dynarr **prop, | 1994 Bytebpos byte_start_pos, prop_block_dynarr **prop, |
1987 int type) | 1995 int type) |
1988 { | 1996 { |
1989 struct frame *f = XFRAME (w->frame); | 1997 struct frame *f = XFRAME (w->frame); |
1990 struct buffer *b = XBUFFER (w->buffer); | 1998 struct buffer *b = XBUFFER (w->buffer); |
1991 struct device *d = XDEVICE (f->device); | 1999 struct device *d = XDEVICE (f->device); |
2085 data.window = wrap_window (w); | 2093 data.window = wrap_window (w); |
2086 data.string = Qnil; | 2094 data.string = Qnil; |
2087 data.db = db; | 2095 data.db = db; |
2088 data.dl = dl; | 2096 data.dl = dl; |
2089 | 2097 |
2090 data.bi_charbpos = bi_start_pos; | 2098 data.byte_charpos = byte_start_pos; |
2091 data.pixpos = dl->bounds.left_in; | 2099 data.pixpos = dl->bounds.left_in; |
2092 data.last_charset = Qunbound; | 2100 data.last_charset = Qunbound; |
2093 data.last_findex = DEFAULT_INDEX; | 2101 data.last_findex = DEFAULT_INDEX; |
2094 data.result_str = Qnil; | 2102 data.result_str = Qnil; |
2095 | 2103 |
2102 data.end_glyph_width = GLYPH_CACHEL_WIDTH (w, CONT_GLYPH_INDEX); | 2110 data.end_glyph_width = GLYPH_CACHEL_WIDTH (w, CONT_GLYPH_INDEX); |
2103 data.max_pixpos -= data.end_glyph_width; | 2111 data.max_pixpos -= data.end_glyph_width; |
2104 | 2112 |
2105 if (cursor_in_echo_area && MINI_WINDOW_P (w) && echo_area_active (f)) | 2113 if (cursor_in_echo_area && MINI_WINDOW_P (w) && echo_area_active (f)) |
2106 { | 2114 { |
2107 data.bi_cursor_charbpos = BI_BUF_ZV (b); | 2115 data.byte_cursor_charpos = BYTE_BUF_ZV (b); |
2108 data.cursor_type = CURSOR_ON; | 2116 data.cursor_type = CURSOR_ON; |
2109 } | 2117 } |
2110 else if (MINI_WINDOW_P (w) && !active_minibuffer) | 2118 else if (MINI_WINDOW_P (w) && !active_minibuffer) |
2111 data.cursor_type = NO_CURSOR; | 2119 data.cursor_type = NO_CURSOR; |
2112 else if (w == XWINDOW (FRAME_SELECTED_WINDOW (f)) && | 2120 else if (w == XWINDOW (FRAME_SELECTED_WINDOW (f)) && |
2113 EQ(DEVICE_CONSOLE(d), Vselected_console) && | 2121 EQ(DEVICE_CONSOLE(d), Vselected_console) && |
2114 d == XDEVICE(CONSOLE_SELECTED_DEVICE(XCONSOLE(DEVICE_CONSOLE(d))))&& | 2122 d == XDEVICE(CONSOLE_SELECTED_DEVICE(XCONSOLE(DEVICE_CONSOLE(d))))&& |
2115 f == XFRAME(DEVICE_SELECTED_FRAME(d))) | 2123 f == XFRAME(DEVICE_SELECTED_FRAME(d))) |
2116 { | 2124 { |
2117 data.bi_cursor_charbpos = BI_BUF_PT (b); | 2125 data.byte_cursor_charpos = BYTE_BUF_PT (b); |
2118 data.cursor_type = CURSOR_ON; | 2126 data.cursor_type = CURSOR_ON; |
2119 } | 2127 } |
2120 else if (w == XWINDOW (FRAME_SELECTED_WINDOW (f))) | 2128 else if (w == XWINDOW (FRAME_SELECTED_WINDOW (f))) |
2121 { | 2129 { |
2122 data.bi_cursor_charbpos = bi_marker_position (w->pointm[type]); | 2130 data.byte_cursor_charpos = byte_marker_position (w->pointm[type]); |
2123 data.cursor_type = CURSOR_ON; | 2131 data.cursor_type = CURSOR_ON; |
2124 } | 2132 } |
2125 else | 2133 else |
2126 data.cursor_type = NO_CURSOR; | 2134 data.cursor_type = NO_CURSOR; |
2127 data.cursor_x = -1; | 2135 data.cursor_x = -1; |
2128 | 2136 |
2129 data.start_col = w->hscroll; | 2137 data.start_col = w->hscroll; |
2130 data.start_col_xoffset = w->left_xoffset; | 2138 data.start_col_xoffset = w->left_xoffset; |
2131 data.bi_start_col_enabled = (w->hscroll ? bi_start_pos : 0); | 2139 data.byte_start_col_enabled = (w->hscroll ? byte_start_pos : 0); |
2132 data.hscroll_glyph_width_adjust = 0; | 2140 data.hscroll_glyph_width_adjust = 0; |
2133 | 2141 |
2134 /* We regenerate the line from the very beginning. */ | 2142 /* We regenerate the line from the very beginning. */ |
2135 Dynarr_reset (db->runes); | 2143 Dynarr_reset (db->runes); |
2136 | 2144 |
2162 */ | 2170 */ |
2163 while (data.pixpos <= data.max_pixpos | 2171 while (data.pixpos <= data.max_pixpos |
2164 && (active_minibuffer || !NILP (synch_minibuffers_value))) | 2172 && (active_minibuffer || !NILP (synch_minibuffers_value))) |
2165 { | 2173 { |
2166 /* #### This check probably should not be necessary. */ | 2174 /* #### This check probably should not be necessary. */ |
2167 if (data.bi_charbpos > BI_BUF_ZV (b)) | 2175 if (data.byte_charpos > BYTE_BUF_ZV (b)) |
2168 { | 2176 { |
2169 /* #### urk! More of this lossage! */ | 2177 /* #### urk! More of this lossage! */ |
2170 data.bi_charbpos--; | 2178 data.byte_charpos--; |
2171 goto done; | 2179 goto done; |
2172 } | 2180 } |
2173 | 2181 |
2174 /* If selective display was an integer and we aren't working on | 2182 /* If selective display was an integer and we aren't working on |
2175 a continuation line then find the next line we are actually | 2183 a continuation line then find the next line we are actually |
2176 supposed to display. */ | 2184 supposed to display. */ |
2177 if (selective > 0 | 2185 if (selective > 0 |
2178 && (data.bi_charbpos == BI_BUF_BEGV (b) | 2186 && (data.byte_charpos == BYTE_BUF_BEGV (b) |
2179 || BUF_FETCH_CHAR (b, prev_bytebpos (b, data.bi_charbpos)) == '\n')) | 2187 || BUF_FETCH_CHAR (b, prev_bytebpos (b, data.byte_charpos)) == '\n')) |
2180 { | 2188 { |
2181 while (bi_spaces_at_point (b, data.bi_charbpos) >= selective) | 2189 while (byte_spaces_at_point (b, data.byte_charpos) >= selective) |
2182 { | 2190 { |
2183 data.bi_charbpos = | 2191 data.byte_charpos = |
2184 bi_find_next_newline_no_quit (b, data.bi_charbpos, 1); | 2192 byte_find_next_newline_no_quit (b, data.byte_charpos, 1); |
2185 if (data.bi_charbpos >= BI_BUF_ZV (b)) | 2193 if (data.byte_charpos >= BYTE_BUF_ZV (b)) |
2186 { | 2194 { |
2187 data.bi_charbpos = BI_BUF_ZV (b); | 2195 data.byte_charpos = BYTE_BUF_ZV (b); |
2188 goto done; | 2196 goto done; |
2189 } | 2197 } |
2190 } | 2198 } |
2191 } | 2199 } |
2192 | 2200 |
2193 /* Check for face changes. */ | 2201 /* Check for face changes. */ |
2194 if (initial || (!no_more_frags && data.bi_charbpos == data.ef->end)) | 2202 if (initial || (!no_more_frags && data.byte_charpos == data.ef->end)) |
2195 { | 2203 { |
2196 Lisp_Object last_glyph = Qnil; | 2204 Lisp_Object last_glyph = Qnil; |
2197 | 2205 |
2198 /* Deal with glyphs that we have already displayed. The | 2206 /* Deal with glyphs that we have already displayed. The |
2199 theory is that if we end up with a PROP_GLYPH in the | 2207 theory is that if we end up with a PROP_GLYPH in the |
2209 *prop = 0; | 2217 *prop = 0; |
2210 } | 2218 } |
2211 /* Now compute the face and begin/end-glyph information. */ | 2219 /* Now compute the face and begin/end-glyph information. */ |
2212 data.findex = | 2220 data.findex = |
2213 /* Remember that the extent-fragment routines deal in Bytebpos's. */ | 2221 /* Remember that the extent-fragment routines deal in Bytebpos's. */ |
2214 extent_fragment_update (w, data.ef, data.bi_charbpos, last_glyph); | 2222 extent_fragment_update (w, data.ef, data.byte_charpos, last_glyph); |
2215 | 2223 |
2216 get_display_tables (w, data.findex, &face_dt, &window_dt); | 2224 get_display_tables (w, data.findex, &face_dt, &window_dt); |
2217 | 2225 |
2218 if (data.bi_charbpos == data.ef->end) | 2226 if (data.byte_charpos == data.ef->end) |
2219 no_more_frags = 1; | 2227 no_more_frags = 1; |
2220 } | 2228 } |
2221 initial = 0; | 2229 initial = 0; |
2222 | 2230 |
2223 /* Determine what is next to be displayed. We first handle any | 2231 /* Determine what is next to be displayed. We first handle any |
2263 } | 2271 } |
2264 | 2272 |
2265 /* If point is in an invisible region we place it on the | 2273 /* If point is in an invisible region we place it on the |
2266 next visible character. */ | 2274 next visible character. */ |
2267 if (data.cursor_type == CURSOR_ON | 2275 if (data.cursor_type == CURSOR_ON |
2268 && data.bi_charbpos == data.bi_cursor_charbpos) | 2276 && data.byte_charpos == data.byte_cursor_charpos) |
2269 { | 2277 { |
2270 data.cursor_type = NEXT_CURSOR; | 2278 data.cursor_type = NEXT_CURSOR; |
2271 } | 2279 } |
2272 | 2280 |
2273 /* #### What if we we're dealing with a display table? */ | 2281 /* #### What if we we're dealing with a display table? */ |
2274 if (data.start_col) | 2282 if (data.start_col) |
2275 data.start_col--; | 2283 data.start_col--; |
2276 | 2284 |
2277 if (data.bi_charbpos == BI_BUF_ZV (b)) | 2285 if (data.byte_charpos == BYTE_BUF_ZV (b)) |
2278 goto done; | 2286 goto done; |
2279 else | 2287 else |
2280 INC_BYTEBPOS (b, data.bi_charbpos); | 2288 INC_BYTEBPOS (b, data.byte_charpos); |
2281 } | 2289 } |
2282 | 2290 |
2283 /* If there is propagation data, then it represents the current | 2291 /* If there is propagation data, then it represents the current |
2284 buffer position being displayed. Add them and advance the | 2292 buffer position being displayed. Add them and advance the |
2285 position counter. This might also add the minibuffer | 2293 position counter. This might also add the minibuffer |
2289 dl->used_prop_data = 1; | 2297 dl->used_prop_data = 1; |
2290 *prop = add_propagation_runes (prop, &data); | 2298 *prop = add_propagation_runes (prop, &data); |
2291 | 2299 |
2292 if (*prop) | 2300 if (*prop) |
2293 goto done; /* gee, a really narrow window */ | 2301 goto done; /* gee, a really narrow window */ |
2294 else if (data.bi_charbpos == BI_BUF_ZV (b)) | 2302 else if (data.byte_charpos == BYTE_BUF_ZV (b)) |
2295 goto done; | 2303 goto done; |
2296 else if (data.bi_charbpos < BI_BUF_BEGV (b)) | 2304 else if (data.byte_charpos < BYTE_BUF_BEGV (b)) |
2297 /* #### urk urk urk! Aborts are not very fun! Fix this please! */ | 2305 /* #### urk urk urk! Aborts are not very fun! Fix this please! */ |
2298 data.bi_charbpos = BI_BUF_BEGV (b); | 2306 data.byte_charpos = BYTE_BUF_BEGV (b); |
2299 else | 2307 else |
2300 INC_BYTEBPOS (b, data.bi_charbpos); | 2308 INC_BYTEBPOS (b, data.byte_charpos); |
2301 } | 2309 } |
2302 | 2310 |
2303 /* If there are end glyphs, add them to the line. These are | 2311 /* If there are end glyphs, add them to the line. These are |
2304 the end glyphs for the previous run of text. We add them | 2312 the end glyphs for the previous run of text. We add them |
2305 here rather than doing them at the end of handling the | 2313 here rather than doing them at the end of handling the |
2308 else if (Dynarr_length (data.ef->end_glyphs) > 0 | 2316 else if (Dynarr_length (data.ef->end_glyphs) > 0 |
2309 || Dynarr_length (data.ef->begin_glyphs) > 0) | 2317 || Dynarr_length (data.ef->begin_glyphs) > 0) |
2310 { | 2318 { |
2311 glyph_block_dynarr* tmpglyphs = 0; | 2319 glyph_block_dynarr* tmpglyphs = 0; |
2312 /* #### I think this is safe, but could be wrong. */ | 2320 /* #### I think this is safe, but could be wrong. */ |
2313 data.ch = BI_BUF_FETCH_CHAR (b, data.bi_charbpos); | 2321 data.ch = BYTE_BUF_FETCH_CHAR (b, data.byte_charpos); |
2314 | 2322 |
2315 if (Dynarr_length (data.ef->end_glyphs) > 0) | 2323 if (Dynarr_length (data.ef->end_glyphs) > 0) |
2316 { | 2324 { |
2317 *prop = add_glyph_runes (&data, END_GLYPHS); | 2325 *prop = add_glyph_runes (&data, END_GLYPHS); |
2318 tmpglyphs = data.ef->end_glyphs; | 2326 tmpglyphs = data.ef->end_glyphs; |
2361 } | 2369 } |
2362 | 2370 |
2363 /* If at end-of-buffer, we've already processed begin and | 2371 /* If at end-of-buffer, we've already processed begin and |
2364 end-glyphs at this point and there's no text to process, | 2372 end-glyphs at this point and there's no text to process, |
2365 so we're done. */ | 2373 so we're done. */ |
2366 else if (data.bi_charbpos == BI_BUF_ZV (b)) | 2374 else if (data.byte_charpos == BYTE_BUF_ZV (b)) |
2367 goto done; | 2375 goto done; |
2368 | 2376 |
2369 else | 2377 else |
2370 { | 2378 { |
2371 Lisp_Object entry = Qnil; | 2379 Lisp_Object entry = Qnil; |
2372 /* Get the character at the current buffer position. */ | 2380 /* Get the character at the current buffer position. */ |
2373 data.ch = BI_BUF_FETCH_CHAR (b, data.bi_charbpos); | 2381 data.ch = BYTE_BUF_FETCH_CHAR (b, data.byte_charpos); |
2374 if (!NILP (face_dt) || !NILP (window_dt)) | 2382 if (!NILP (face_dt) || !NILP (window_dt)) |
2375 entry = display_table_entry (data.ch, face_dt, window_dt); | 2383 entry = display_table_entry (data.ch, face_dt, window_dt); |
2376 | 2384 |
2377 /* If there is a display table entry for it, hand it off to | 2385 /* If there is a display table entry for it, hand it off to |
2378 add_disp_table_entry_runes and let it worry about it. */ | 2386 add_disp_table_entry_runes and let it worry about it. */ |
2392 space back in order to make sure that the cursor can | 2400 space back in order to make sure that the cursor can |
2393 fit. */ | 2401 fit. */ |
2394 data.max_pixpos += data.end_glyph_width; | 2402 data.max_pixpos += data.end_glyph_width; |
2395 | 2403 |
2396 if (selective > 0 | 2404 if (selective > 0 |
2397 && (bi_spaces_at_point | 2405 && (byte_spaces_at_point |
2398 (b, next_bytebpos (b, data.bi_charbpos)) | 2406 (b, next_bytebpos (b, data.byte_charpos)) |
2399 >= selective)) | 2407 >= selective)) |
2400 { | 2408 { |
2401 if (!NILP (b->selective_display_ellipses)) | 2409 if (!NILP (b->selective_display_ellipses)) |
2402 { | 2410 { |
2403 struct glyph_block gb; | 2411 struct glyph_block gb; |
2415 the non-printing character '\n'. */ | 2423 the non-printing character '\n'. */ |
2416 data.blank_width = DEVMETH (d, eol_cursor_width, ()); | 2424 data.blank_width = DEVMETH (d, eol_cursor_width, ()); |
2417 *prop = add_emchar_rune (&data); | 2425 *prop = add_emchar_rune (&data); |
2418 } | 2426 } |
2419 | 2427 |
2420 /* We need to set data.bi_charbpos to the start of the | 2428 /* We need to set data.byte_charpos to the start of the |
2421 next visible region in order to make this line | 2429 next visible region in order to make this line |
2422 appear to contain all of the invisible area. | 2430 appear to contain all of the invisible area. |
2423 Otherwise, the line cache won't work | 2431 Otherwise, the line cache won't work |
2424 correctly. */ | 2432 correctly. */ |
2425 INC_BYTEBPOS (b, data.bi_charbpos); | 2433 INC_BYTEBPOS (b, data.byte_charpos); |
2426 while (bi_spaces_at_point (b, data.bi_charbpos) >= selective) | 2434 while (byte_spaces_at_point (b, data.byte_charpos) >= selective) |
2427 { | 2435 { |
2428 data.bi_charbpos = | 2436 data.byte_charpos = |
2429 bi_find_next_newline_no_quit (b, data.bi_charbpos, 1); | 2437 byte_find_next_newline_no_quit (b, data.byte_charpos, 1); |
2430 if (data.bi_charbpos >= BI_BUF_ZV (b)) | 2438 if (data.byte_charpos >= BYTE_BUF_ZV (b)) |
2431 { | 2439 { |
2432 data.bi_charbpos = BI_BUF_ZV (b); | 2440 data.byte_charpos = BYTE_BUF_ZV (b); |
2433 break; | 2441 break; |
2434 } | 2442 } |
2435 } | 2443 } |
2436 if (BI_BUF_FETCH_CHAR | 2444 if (BYTE_BUF_FETCH_CHAR |
2437 (b, prev_bytebpos (b, data.bi_charbpos)) == '\n') | 2445 (b, prev_bytebpos (b, data.byte_charpos)) == '\n') |
2438 DEC_BYTEBPOS (b, data.bi_charbpos); | 2446 DEC_BYTEBPOS (b, data.byte_charpos); |
2439 } | 2447 } |
2440 else | 2448 else |
2441 { | 2449 { |
2442 data.blank_width = DEVMETH (d, eol_cursor_width, ()); | 2450 data.blank_width = DEVMETH (d, eol_cursor_width, ()); |
2443 *prop = add_emchar_rune (&data); | 2451 *prop = add_emchar_rune (&data); |
2450 enabled, then add the invisible-text-glyph if | 2458 enabled, then add the invisible-text-glyph if |
2451 selective-display-ellipses is set. In any case, this | 2459 selective-display-ellipses is set. In any case, this |
2452 line is done. */ | 2460 line is done. */ |
2453 else if (data.ch == (('M' & 037)) && selective == -1) | 2461 else if (data.ch == (('M' & 037)) && selective == -1) |
2454 { | 2462 { |
2455 Bytebpos bi_next_charbpos; | 2463 Bytebpos byte_next_charpos; |
2456 | 2464 |
2457 /* Find the buffer position at the end of the line. */ | 2465 /* Find the buffer position at the end of the line. */ |
2458 bi_next_charbpos = | 2466 byte_next_charpos = |
2459 bi_find_next_newline_no_quit (b, data.bi_charbpos, 1); | 2467 byte_find_next_newline_no_quit (b, data.byte_charpos, 1); |
2460 if (BI_BUF_FETCH_CHAR (b, prev_bytebpos (b, bi_next_charbpos)) | 2468 if (BYTE_BUF_FETCH_CHAR (b, prev_bytebpos (b, byte_next_charpos)) |
2461 == '\n') | 2469 == '\n') |
2462 DEC_BYTEBPOS (b, bi_next_charbpos); | 2470 DEC_BYTEBPOS (b, byte_next_charpos); |
2463 | 2471 |
2464 /* If the cursor is somewhere in the elided text make | 2472 /* If the cursor is somewhere in the elided text make |
2465 sure that the cursor gets drawn appropriately. */ | 2473 sure that the cursor gets drawn appropriately. */ |
2466 if (data.cursor_type == CURSOR_ON | 2474 if (data.cursor_type == CURSOR_ON |
2467 && (data.bi_cursor_charbpos >= data.bi_charbpos && | 2475 && (data.byte_cursor_charpos >= data.byte_charpos && |
2468 data.bi_cursor_charbpos < bi_next_charbpos)) | 2476 data.byte_cursor_charpos < byte_next_charpos)) |
2469 { | 2477 { |
2470 data.cursor_type = NEXT_CURSOR; | 2478 data.cursor_type = NEXT_CURSOR; |
2471 } | 2479 } |
2472 | 2480 |
2473 /* We won't be adding a truncation or continuation glyph | 2481 /* We won't be adding a truncation or continuation glyph |
2489 | 2497 |
2490 /* Set the buffer position to the end of the line. We | 2498 /* Set the buffer position to the end of the line. We |
2491 need to do this before potentially adding a newline | 2499 need to do this before potentially adding a newline |
2492 so that the cursor flag will get set correctly (if | 2500 so that the cursor flag will get set correctly (if |
2493 needed). */ | 2501 needed). */ |
2494 data.bi_charbpos = bi_next_charbpos; | 2502 data.byte_charpos = byte_next_charpos; |
2495 | 2503 |
2496 if (NILP (b->selective_display_ellipses) | 2504 if (NILP (b->selective_display_ellipses) |
2497 || data.bi_cursor_charbpos == bi_next_charbpos) | 2505 || data.byte_cursor_charpos == byte_next_charpos) |
2498 { | 2506 { |
2499 /* We have to at least add a newline character so | 2507 /* We have to at least add a newline character so |
2500 that the cursor shows up properly. */ | 2508 that the cursor shows up properly. */ |
2501 data.ch = '\n'; | 2509 data.ch = '\n'; |
2502 data.blank_width = DEVMETH (d, eol_cursor_width, ()); | 2510 data.blank_width = DEVMETH (d, eol_cursor_width, ()); |
2503 data.findex = DEFAULT_INDEX; | 2511 data.findex = DEFAULT_INDEX; |
2504 data.start_col = 0; | 2512 data.start_col = 0; |
2505 data.start_col_xoffset = 0; | 2513 data.start_col_xoffset = 0; |
2506 data.bi_start_col_enabled = 0; | 2514 data.byte_start_col_enabled = 0; |
2507 | 2515 |
2508 add_emchar_rune (&data); | 2516 add_emchar_rune (&data); |
2509 } | 2517 } |
2510 | 2518 |
2511 /* This had better be a newline but doing it this way | 2519 /* This had better be a newline but doing it this way |
2512 we'll see obvious incorrect results if it isn't. No | 2520 we'll see obvious incorrect results if it isn't. No |
2513 need to abort here. */ | 2521 need to abort here. */ |
2514 data.ch = BI_BUF_FETCH_CHAR (b, data.bi_charbpos); | 2522 data.ch = BYTE_BUF_FETCH_CHAR (b, data.byte_charpos); |
2515 | 2523 |
2516 goto done; | 2524 goto done; |
2517 } | 2525 } |
2518 | 2526 |
2519 /* If the current character is considered to be printable, then | 2527 /* If the current character is considered to be printable, then |
2605 *prop = add_emchar_rune (&data); | 2613 *prop = add_emchar_rune (&data); |
2606 if (*prop) | 2614 if (*prop) |
2607 goto done; | 2615 goto done; |
2608 } | 2616 } |
2609 | 2617 |
2610 INC_BYTEBPOS (b, data.bi_charbpos); | 2618 INC_BYTEBPOS (b, data.byte_charpos); |
2611 } | 2619 } |
2612 } | 2620 } |
2613 | 2621 |
2614 done: | 2622 done: |
2615 | 2623 |
2616 /* Determine the starting point of the next line if we did not hit the | 2624 /* Determine the starting point of the next line if we did not hit the |
2617 end of the buffer. */ | 2625 end of the buffer. */ |
2618 if (data.bi_charbpos < BI_BUF_ZV (b) | 2626 if (data.byte_charpos < BYTE_BUF_ZV (b) |
2619 && (active_minibuffer || !NILP (synch_minibuffers_value))) | 2627 && (active_minibuffer || !NILP (synch_minibuffers_value))) |
2620 { | 2628 { |
2621 /* #### This check is not correct. If the line terminated | 2629 /* #### This check is not correct. If the line terminated |
2622 due to a begin-glyph or end-glyph hitting window-end, then | 2630 due to a begin-glyph or end-glyph hitting window-end, then |
2623 data.ch will not point to the character at data.bi_charbpos. If | 2631 data.ch will not point to the character at data.byte_charpos. If |
2624 you make the two changes mentioned at the top of this loop, | 2632 you make the two changes mentioned at the top of this loop, |
2625 you should be able to say '(if (*prop))'. That should also | 2633 you should be able to say '(if (*prop))'. That should also |
2626 make it possible to eliminate the data.bi_charbpos < BI_BUF_ZV (b) | 2634 make it possible to eliminate the data.byte_charpos < BYTE_BUF_ZV (b) |
2627 check. */ | 2635 check. */ |
2628 | 2636 |
2629 /* The common case is that the line ended because we hit a newline. | 2637 /* The common case is that the line ended because we hit a newline. |
2630 In that case, the next character is just the next buffer | 2638 In that case, the next character is just the next buffer |
2631 position. */ | 2639 position. */ |
2633 { | 2641 { |
2634 /* If data.start_col_enabled is still true, then the window is | 2642 /* If data.start_col_enabled is still true, then the window is |
2635 scrolled far enough so that nothing on this line is visible. | 2643 scrolled far enough so that nothing on this line is visible. |
2636 We need to stick a truncation glyph at the beginning of the | 2644 We need to stick a truncation glyph at the beginning of the |
2637 line in that case unless the line is completely blank. */ | 2645 line in that case unless the line is completely blank. */ |
2638 if (data.bi_start_col_enabled) | 2646 if (data.byte_start_col_enabled) |
2639 { | 2647 { |
2640 if (data.cursor_type == CURSOR_ON) | 2648 if (data.cursor_type == CURSOR_ON) |
2641 { | 2649 { |
2642 if (data.bi_cursor_charbpos >= bi_start_pos | 2650 if (data.byte_cursor_charpos >= byte_start_pos |
2643 && data.bi_cursor_charbpos <= data.bi_charbpos) | 2651 && data.byte_cursor_charpos <= data.byte_charpos) |
2644 data.bi_cursor_charbpos = data.bi_charbpos; | 2652 data.byte_cursor_charpos = data.byte_charpos; |
2645 } | 2653 } |
2646 data.findex = DEFAULT_INDEX; | 2654 data.findex = DEFAULT_INDEX; |
2647 data.start_col = 0; | 2655 data.start_col = 0; |
2648 data.bi_start_col_enabled = 0; | 2656 data.byte_start_col_enabled = 0; |
2649 | 2657 |
2650 if (data.bi_charbpos != bi_start_pos) | 2658 if (data.byte_charpos != byte_start_pos) |
2651 { | 2659 { |
2652 struct glyph_block gb; | 2660 struct glyph_block gb; |
2653 | 2661 |
2654 gb.extent = Qnil; | 2662 gb.extent = Qnil; |
2655 gb.glyph = Vhscroll_glyph; | 2663 gb.glyph = Vhscroll_glyph; |
2665 | 2673 |
2666 add_emchar_rune (&data); | 2674 add_emchar_rune (&data); |
2667 } | 2675 } |
2668 } | 2676 } |
2669 | 2677 |
2670 INC_BYTEBPOS (b, data.bi_charbpos); | 2678 INC_BYTEBPOS (b, data.byte_charpos); |
2671 } | 2679 } |
2672 | 2680 |
2673 /* Otherwise we have a buffer line which cannot fit on one display | 2681 /* Otherwise we have a buffer line which cannot fit on one display |
2674 line. */ | 2682 line. */ |
2675 else | 2683 else |
2685 data.findex = DEFAULT_INDEX; | 2693 data.findex = DEFAULT_INDEX; |
2686 gb.extent = Qnil; | 2694 gb.extent = Qnil; |
2687 | 2695 |
2688 if (truncate_win) | 2696 if (truncate_win) |
2689 { | 2697 { |
2690 Bytebpos bi_pos; | 2698 Bytebpos byte_pos; |
2691 | 2699 |
2692 /* Now find the start of the next line. */ | 2700 /* Now find the start of the next line. */ |
2693 bi_pos = bi_find_next_newline_no_quit (b, data.bi_charbpos, 1); | 2701 byte_pos = byte_find_next_newline_no_quit (b, data.byte_charpos, 1); |
2694 | 2702 |
2695 /* If the cursor is past the truncation line then we | 2703 /* If the cursor is past the truncation line then we |
2696 make it appear on the truncation glyph. If we've hit | 2704 make it appear on the truncation glyph. If we've hit |
2697 the end of the buffer then we also make the cursor | 2705 the end of the buffer then we also make the cursor |
2698 appear unless eob is immediately preceded by a | 2706 appear unless eob is immediately preceded by a |
2699 newline. In that case the cursor should actually | 2707 newline. In that case the cursor should actually |
2700 appear on the next line. */ | 2708 appear on the next line. */ |
2701 if (data.cursor_type == CURSOR_ON | 2709 if (data.cursor_type == CURSOR_ON |
2702 && data.bi_cursor_charbpos >= data.bi_charbpos | 2710 && data.byte_cursor_charpos >= data.byte_charpos |
2703 && (data.bi_cursor_charbpos < bi_pos || | 2711 && (data.byte_cursor_charpos < byte_pos || |
2704 (bi_pos == BI_BUF_ZV (b) | 2712 (byte_pos == BYTE_BUF_ZV (b) |
2705 && (bi_pos == BI_BUF_BEGV (b) | 2713 && (byte_pos == BYTE_BUF_BEGV (b) |
2706 || (BI_BUF_FETCH_CHAR (b, prev_bytebpos (b, bi_pos)) | 2714 || (BYTE_BUF_FETCH_CHAR (b, prev_bytebpos (b, byte_pos)) |
2707 != '\n'))))) | 2715 != '\n'))))) |
2708 data.bi_cursor_charbpos = bi_pos; | 2716 data.byte_cursor_charpos = byte_pos; |
2709 else | 2717 else |
2710 data.cursor_type = NO_CURSOR; | 2718 data.cursor_type = NO_CURSOR; |
2711 | 2719 |
2712 data.bi_charbpos = bi_pos; | 2720 data.byte_charpos = byte_pos; |
2713 gb.glyph = Vtruncation_glyph; | 2721 gb.glyph = Vtruncation_glyph; |
2714 cachel = GLYPH_CACHEL (w, TRUN_GLYPH_INDEX); | 2722 cachel = GLYPH_CACHEL (w, TRUN_GLYPH_INDEX); |
2715 } | 2723 } |
2716 else | 2724 else |
2717 { | 2725 { |
2718 /* The cursor can never be on the continuation glyph. */ | 2726 /* The cursor can never be on the continuation glyph. */ |
2719 data.cursor_type = NO_CURSOR; | 2727 data.cursor_type = NO_CURSOR; |
2720 | 2728 |
2721 /* data.bi_charbpos is already at the start of the next line. */ | 2729 /* data.byte_charpos is already at the start of the next line. */ |
2722 | 2730 |
2723 dl->line_continuation = 1; | 2731 dl->line_continuation = 1; |
2724 gb.glyph = Vcontinuation_glyph; | 2732 gb.glyph = Vcontinuation_glyph; |
2725 cachel = GLYPH_CACHEL (w, CONT_GLYPH_INDEX); | 2733 cachel = GLYPH_CACHEL (w, CONT_GLYPH_INDEX); |
2726 } | 2734 } |
2727 | 2735 |
2728 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 0, cachel); | 2736 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 0, cachel); |
2729 | 2737 |
2730 if (truncate_win && data.bi_charbpos == BI_BUF_ZV (b) | 2738 if (truncate_win && data.byte_charpos == BYTE_BUF_ZV (b) |
2731 && BI_BUF_FETCH_CHAR (b, prev_bytebpos (b, BI_BUF_ZV (b))) != '\n') | 2739 && BYTE_BUF_FETCH_CHAR (b, prev_bytebpos (b, BYTE_BUF_ZV (b))) != '\n') |
2732 /* #### Damn this losing shit. */ | 2740 /* #### Damn this losing shit. */ |
2733 data.bi_charbpos++; | 2741 data.byte_charpos++; |
2734 } | 2742 } |
2735 } | 2743 } |
2736 else if ((active_minibuffer || !NILP (synch_minibuffers_value)) | 2744 else if ((active_minibuffer || !NILP (synch_minibuffers_value)) |
2737 && (!echo_area_active (f) || data.bi_charbpos == BI_BUF_ZV (b))) | 2745 && (!echo_area_active (f) || data.byte_charpos == BYTE_BUF_ZV (b))) |
2738 { | 2746 { |
2739 /* We need to add a marker to the end of the line since there is no | 2747 /* We need to add a marker to the end of the line since there is no |
2740 newline character in order for the cursor to get drawn. We label | 2748 newline character in order for the cursor to get drawn. We label |
2741 it as a newline so that it gets handled correctly by the | 2749 it as a newline so that it gets handled correctly by the |
2742 whitespace routines below. */ | 2750 whitespace routines below. */ |
2744 data.ch = '\n'; | 2752 data.ch = '\n'; |
2745 data.blank_width = DEVMETH (d, eol_cursor_width, ()); | 2753 data.blank_width = DEVMETH (d, eol_cursor_width, ()); |
2746 data.findex = DEFAULT_INDEX; | 2754 data.findex = DEFAULT_INDEX; |
2747 data.start_col = 0; | 2755 data.start_col = 0; |
2748 data.start_col_xoffset = 0; | 2756 data.start_col_xoffset = 0; |
2749 data.bi_start_col_enabled = 0; | 2757 data.byte_start_col_enabled = 0; |
2750 | 2758 |
2751 data.max_pixpos += data.blank_width; | 2759 data.max_pixpos += data.blank_width; |
2752 add_emchar_rune (&data); | 2760 add_emchar_rune (&data); |
2753 data.max_pixpos -= data.blank_width; | 2761 data.max_pixpos -= data.blank_width; |
2754 | 2762 |
2755 /* #### urk! Chuck, this shit is bad news. Going around | 2763 /* #### urk! Chuck, this shit is bad news. Going around |
2756 manipulating invalid positions is guaranteed to result in | 2764 manipulating invalid positions is guaranteed to result in |
2757 trouble sooner or later. */ | 2765 trouble sooner or later. */ |
2758 data.bi_charbpos = BI_BUF_ZV (b) + 1; | 2766 data.byte_charpos = BYTE_BUF_ZV (b) + 1; |
2759 } | 2767 } |
2760 | 2768 |
2761 /* Calculate left whitespace boundary. */ | 2769 /* Calculate left whitespace boundary. */ |
2762 { | 2770 { |
2763 int elt = 0; | 2771 int elt = 0; |
2836 | 2844 |
2837 calculate_yoffset (dl, db); | 2845 calculate_yoffset (dl, db); |
2838 | 2846 |
2839 dl->cursor_elt = data.cursor_x; | 2847 dl->cursor_elt = data.cursor_x; |
2840 /* #### lossage lossage lossage! Fix this shit! */ | 2848 /* #### lossage lossage lossage! Fix this shit! */ |
2841 if (data.bi_charbpos > BI_BUF_ZV (b)) | 2849 if (data.byte_charpos > BYTE_BUF_ZV (b)) |
2842 dl->end_charbpos = BUF_ZV (b); | 2850 dl->end_charpos = BUF_ZV (b); |
2843 else | 2851 else |
2844 dl->end_charbpos = bytebpos_to_charbpos (b, data.bi_charbpos) - 1; | 2852 dl->end_charpos = bytebpos_to_charbpos (b, data.byte_charpos) - 1; |
2845 if (truncate_win) | 2853 if (truncate_win) |
2846 data.dl->num_chars = column_at_point (b, dl->end_charbpos, 0); | 2854 data.dl->num_chars = column_at_point (b, dl->end_charpos, 0); |
2847 else | 2855 else |
2848 /* This doesn't correctly take into account tabs and control | 2856 /* This doesn't correctly take into account tabs and control |
2849 characters but if the window isn't being truncated then this | 2857 characters but if the window isn't being truncated then this |
2850 value isn't going to end up being used anyhow. */ | 2858 value isn't going to end up being used anyhow. */ |
2851 data.dl->num_chars = dl->end_charbpos - dl->charbpos; | 2859 data.dl->num_chars = dl->end_charpos - dl->charpos; |
2852 | 2860 |
2853 /* #### handle horizontally scrolled line with text none of which | 2861 /* #### handle horizontally scrolled line with text none of which |
2854 was actually laid out. */ | 2862 was actually laid out. */ |
2855 | 2863 |
2856 /* #### handle any remainder of overlay arrow */ | 2864 /* #### handle any remainder of overlay arrow */ |
2869 /* #### If we started at EOB, then make sure we return a value past | 2877 /* #### If we started at EOB, then make sure we return a value past |
2870 it so that regenerate_window will exit properly. This is bogus. | 2878 it so that regenerate_window will exit properly. This is bogus. |
2871 The main loop should get fixed so that it isn't necessary to call | 2879 The main loop should get fixed so that it isn't necessary to call |
2872 this function if we are already at EOB. */ | 2880 this function if we are already at EOB. */ |
2873 | 2881 |
2874 if (data.bi_charbpos == BI_BUF_ZV (b) && bi_start_pos == BI_BUF_ZV (b)) | 2882 if (data.byte_charpos == BYTE_BUF_ZV (b) && byte_start_pos == BYTE_BUF_ZV (b)) |
2875 return data.bi_charbpos + 1; /* Yuck! */ | 2883 return data.byte_charpos + 1; /* Yuck! */ |
2876 else | 2884 else |
2877 return data.bi_charbpos; | 2885 return data.byte_charpos; |
2878 } | 2886 } |
2879 | 2887 |
2880 /* Display the overlay arrow at the beginning of the given line. */ | 2888 /* Display the overlay arrow at the beginning of the given line. */ |
2881 | 2889 |
2882 static int | 2890 static int |
3038 rb.findex = (side == LEFT_GLYPHS | 3046 rb.findex = (side == LEFT_GLYPHS |
3039 ? get_builtin_face_cache_index (w, Vleft_margin_face) | 3047 ? get_builtin_face_cache_index (w, Vleft_margin_face) |
3040 : get_builtin_face_cache_index (w, Vright_margin_face)); | 3048 : get_builtin_face_cache_index (w, Vright_margin_face)); |
3041 rb.xpos = xpos; | 3049 rb.xpos = xpos; |
3042 rb.width = width; | 3050 rb.width = width; |
3043 rb.charbpos = -1; | 3051 rb.charpos = -1; |
3044 rb.endpos = 0; | 3052 rb.endpos = 0; |
3045 rb.type = RUNE_BLANK; | 3053 rb.type = RUNE_BLANK; |
3046 rb.cursor_type = CURSOR_OFF; | 3054 rb.cursor_type = CURSOR_OFF; |
3047 | 3055 |
3048 Dynarr_add (db->runes, rb); | 3056 Dynarr_add (db->runes, rb); |
3841 dl->ypos = WINDOW_BOTTOM (w); | 3849 dl->ypos = WINDOW_BOTTOM (w); |
3842 | 3850 |
3843 rb.findex = MODELINE_INDEX; | 3851 rb.findex = MODELINE_INDEX; |
3844 rb.xpos = dl->bounds.left_out; | 3852 rb.xpos = dl->bounds.left_out; |
3845 rb.width = dl->bounds.right_out - dl->bounds.left_out; | 3853 rb.width = dl->bounds.right_out - dl->bounds.left_out; |
3846 rb.charbpos = 0; | 3854 rb.charpos = 0; |
3847 rb.endpos = 0; | 3855 rb.endpos = 0; |
3848 rb.type = RUNE_HLINE; | 3856 rb.type = RUNE_HLINE; |
3849 rb.object.hline.thickness = 1; | 3857 rb.object.hline.thickness = 1; |
3850 rb.object.hline.yoffset = 0; | 3858 rb.object.hline.yoffset = 0; |
3851 rb.cursor_type = NO_CURSOR; | 3859 rb.cursor_type = NO_CURSOR; |
4142 /* If value is a string, output that string literally: | 4150 /* If value is a string, output that string literally: |
4143 don't check for % within it. */ | 4151 don't check for % within it. */ |
4144 if (STRINGP (tem)) | 4152 if (STRINGP (tem)) |
4145 { | 4153 { |
4146 Intbyte *str = XSTRING_DATA (tem); | 4154 Intbyte *str = XSTRING_DATA (tem); |
4147 Charcount size = XSTRING_CHAR_LENGTH (tem); | 4155 Charcount size = string_char_length (tem); |
4148 | 4156 |
4149 if (size <= *offset) | 4157 if (size <= *offset) |
4150 *offset -= size; | 4158 *offset -= size; |
4151 else | 4159 else |
4152 { | 4160 { |
4459 } | 4467 } |
4460 | 4468 |
4461 | 4469 |
4462 /***************************************************************************/ | 4470 /***************************************************************************/ |
4463 /* */ | 4471 /* */ |
4464 /* displayable string routines */ | 4472 /* displayable string routines */ |
4465 /* */ | 4473 /* */ |
4466 /***************************************************************************/ | 4474 /***************************************************************************/ |
4467 | 4475 |
4468 /* Given a position for a string in a window, ensure that the given | 4476 /* Given a position for a string in a window, ensure that the given |
4469 display line DL accurately represents the text on a line starting | 4477 display line DL accurately represents the text on a line starting |
4480 with many more types of display situation. */ | 4488 with many more types of display situation. */ |
4481 | 4489 |
4482 static Charbpos | 4490 static Charbpos |
4483 create_string_text_block (struct window *w, Lisp_Object disp_string, | 4491 create_string_text_block (struct window *w, Lisp_Object disp_string, |
4484 struct display_line *dl, | 4492 struct display_line *dl, |
4485 Charbpos start_pos, | 4493 Charcount start_pos, |
4486 prop_block_dynarr **prop, | 4494 prop_block_dynarr **prop, |
4487 face_index default_face) | 4495 face_index default_face) |
4488 { | 4496 { |
4489 struct frame *f = XFRAME (w->frame); | 4497 struct frame *f = XFRAME (w->frame); |
4490 /* Note that a lot of the buffer controlled stuff has been left in | 4498 /* Note that a lot of the buffer controlled stuff has been left in |
4495 struct buffer *b = BUFFERP (w->buffer) ? XBUFFER (w->buffer) : 0; | 4503 struct buffer *b = BUFFERP (w->buffer) ? XBUFFER (w->buffer) : 0; |
4496 struct device *d = XDEVICE (f->device); | 4504 struct device *d = XDEVICE (f->device); |
4497 | 4505 |
4498 /* we're working with these a lot so precalculate them */ | 4506 /* we're working with these a lot so precalculate them */ |
4499 Bytecount slen = XSTRING_LENGTH (disp_string); | 4507 Bytecount slen = XSTRING_LENGTH (disp_string); |
4500 Bytecount bi_string_zv = slen; | 4508 Bytecount byte_string_zv = slen; |
4501 Bytebpos bi_start_pos = string_index_char_to_byte (disp_string, start_pos); | 4509 Bytecount byte_start_pos = string_index_char_to_byte (disp_string, start_pos); |
4502 | 4510 |
4503 pos_data data; | 4511 pos_data data; |
4504 | 4512 |
4505 int truncate_win = b ? window_truncation_on (w) : 0; | 4513 int truncate_win = b ? window_truncation_on (w) : 0; |
4506 | 4514 |
4598 data.d = d; | 4606 data.d = d; |
4599 data.window = wrap_window (w); | 4607 data.window = wrap_window (w); |
4600 data.db = db; | 4608 data.db = db; |
4601 data.dl = dl; | 4609 data.dl = dl; |
4602 | 4610 |
4603 data.bi_charbpos = bi_start_pos; | 4611 data.byte_charpos = byte_start_pos; |
4604 data.pixpos = dl->bounds.left_in; | 4612 data.pixpos = dl->bounds.left_in; |
4605 data.last_charset = Qunbound; | 4613 data.last_charset = Qunbound; |
4606 data.last_findex = default_face; | 4614 data.last_findex = default_face; |
4607 data.result_str = Qnil; | 4615 data.result_str = Qnil; |
4608 data.string = disp_string; | 4616 data.string = disp_string; |
4617 | 4625 |
4618 data.start_col = 0; | 4626 data.start_col = 0; |
4619 /* I don't think we want this, string areas should not scroll with | 4627 /* I don't think we want this, string areas should not scroll with |
4620 the window | 4628 the window |
4621 data.start_col = w->hscroll; | 4629 data.start_col = w->hscroll; |
4622 data.bi_start_col_enabled = (w->hscroll ? bi_start_pos : 0); | 4630 data.byte_start_col_enabled = (w->hscroll ? byte_start_pos : 0); |
4623 */ | 4631 */ |
4624 data.bi_start_col_enabled = 0; | 4632 data.byte_start_col_enabled = 0; |
4625 data.hscroll_glyph_width_adjust = 0; | 4633 data.hscroll_glyph_width_adjust = 0; |
4626 | 4634 |
4627 /* We regenerate the line from the very beginning. */ | 4635 /* We regenerate the line from the very beginning. */ |
4628 Dynarr_reset (db->runes); | 4636 Dynarr_reset (db->runes); |
4629 | 4637 |
4654 #### See also the comment after the end of this loop, below. | 4662 #### See also the comment after the end of this loop, below. |
4655 */ | 4663 */ |
4656 while (data.pixpos <= data.max_pixpos) | 4664 while (data.pixpos <= data.max_pixpos) |
4657 { | 4665 { |
4658 /* #### This check probably should not be necessary. */ | 4666 /* #### This check probably should not be necessary. */ |
4659 if (data.bi_charbpos > bi_string_zv) | 4667 if (data.byte_charpos > byte_string_zv) |
4660 { | 4668 { |
4661 /* #### urk! More of this lossage! */ | 4669 /* #### urk! More of this lossage! */ |
4662 data.bi_charbpos--; | 4670 data.byte_charpos--; |
4663 goto done; | 4671 goto done; |
4664 } | 4672 } |
4665 | 4673 |
4666 /* Check for face changes. */ | 4674 /* Check for face changes. */ |
4667 if (initial || (!no_more_frags && data.bi_charbpos == data.ef->end)) | 4675 if (initial || (!no_more_frags && data.byte_charpos == data.ef->end)) |
4668 { | 4676 { |
4669 Lisp_Object last_glyph = Qnil; | 4677 Lisp_Object last_glyph = Qnil; |
4670 /* Deal with clipped glyphs that we have already displayed. */ | 4678 /* Deal with clipped glyphs that we have already displayed. */ |
4671 if (*prop && Dynarr_atp (*prop, 0)->type == PROP_GLYPH) | 4679 if (*prop && Dynarr_atp (*prop, 0)->type == PROP_GLYPH) |
4672 { | 4680 { |
4675 *prop = 0; | 4683 *prop = 0; |
4676 } | 4684 } |
4677 /* Now compute the face and begin/end-glyph information. */ | 4685 /* Now compute the face and begin/end-glyph information. */ |
4678 data.findex = | 4686 data.findex = |
4679 /* Remember that the extent-fragment routines deal in | 4687 /* Remember that the extent-fragment routines deal in |
4680 Bytebpos's. */ | 4688 Bytexpos's. */ |
4681 extent_fragment_update (w, data.ef, data.bi_charbpos, last_glyph); | 4689 extent_fragment_update (w, data.ef, data.byte_charpos, last_glyph); |
4682 /* This is somewhat cheesy but the alternative is to | 4690 /* This is somewhat cheesy but the alternative is to |
4683 propagate default_face into extent_fragment_update. */ | 4691 propagate default_face into extent_fragment_update. */ |
4684 if (data.findex == DEFAULT_INDEX) | 4692 if (data.findex == DEFAULT_INDEX) |
4685 data.findex = default_face; | 4693 data.findex = default_face; |
4686 | 4694 |
4687 get_display_tables (w, data.findex, &face_dt, &window_dt); | 4695 get_display_tables (w, data.findex, &face_dt, &window_dt); |
4688 | 4696 |
4689 if (data.bi_charbpos == data.ef->end) | 4697 if (data.byte_charpos == data.ef->end) |
4690 no_more_frags = 1; | 4698 no_more_frags = 1; |
4691 } | 4699 } |
4692 initial = 0; | 4700 initial = 0; |
4693 | 4701 |
4694 /* Determine what is next to be displayed. We first handle any | 4702 /* Determine what is next to be displayed. We first handle any |
4735 | 4743 |
4736 /* #### What if we're dealing with a display table? */ | 4744 /* #### What if we're dealing with a display table? */ |
4737 if (data.start_col) | 4745 if (data.start_col) |
4738 data.start_col--; | 4746 data.start_col--; |
4739 | 4747 |
4740 if (data.bi_charbpos == bi_string_zv) | 4748 if (data.byte_charpos == byte_string_zv) |
4741 goto done; | 4749 goto done; |
4742 else | 4750 else |
4743 INC_CHARBYTEBPOS (XSTRING_DATA (disp_string), data.bi_charbpos); | 4751 INC_BYTECOUNT (XSTRING_DATA (disp_string), data.byte_charpos); |
4744 } | 4752 } |
4745 | 4753 |
4746 /* If there is propagation data, then it represents the current | 4754 /* If there is propagation data, then it represents the current |
4747 buffer position being displayed. Add them and advance the | 4755 buffer position being displayed. Add them and advance the |
4748 position counter. This might also add the minibuffer | 4756 position counter. This might also add the minibuffer |
4752 dl->used_prop_data = 1; | 4760 dl->used_prop_data = 1; |
4753 *prop = add_propagation_runes (prop, &data); | 4761 *prop = add_propagation_runes (prop, &data); |
4754 | 4762 |
4755 if (*prop) | 4763 if (*prop) |
4756 goto done; /* gee, a really narrow window */ | 4764 goto done; /* gee, a really narrow window */ |
4757 else if (data.bi_charbpos == bi_string_zv) | 4765 else if (data.byte_charpos == byte_string_zv) |
4758 goto done; | 4766 goto done; |
4759 else if (data.bi_charbpos < 0) | 4767 else if (data.byte_charpos < 0) |
4760 /* #### urk urk urk! Aborts are not very fun! Fix this please! */ | 4768 /* #### urk urk urk! Aborts are not very fun! Fix this please! */ |
4761 data.bi_charbpos = 0; | 4769 data.byte_charpos = 0; |
4762 else | 4770 else |
4763 INC_CHARBYTEBPOS (XSTRING_DATA (disp_string), data.bi_charbpos); | 4771 INC_BYTECOUNT (XSTRING_DATA (disp_string), data.byte_charpos); |
4764 } | 4772 } |
4765 | 4773 |
4766 /* If there are end glyphs, add them to the line. These are | 4774 /* If there are end glyphs, add them to the line. These are |
4767 the end glyphs for the previous run of text. We add them | 4775 the end glyphs for the previous run of text. We add them |
4768 here rather than doing them at the end of handling the | 4776 here rather than doing them at the end of handling the |
4769 previous run so that glyphs at the beginning and end of | 4777 previous run so that glyphs at the beginning and end of |
4770 a line are handled correctly. */ | 4778 a line are handled correctly. */ |
4771 else if (Dynarr_length (data.ef->end_glyphs) > 0) | 4779 else if (Dynarr_length (data.ef->end_glyphs) > 0) |
4772 { | 4780 { |
4773 data.ch = XSTRING_CHAR (disp_string, data.bi_charbpos); | 4781 data.ch = string_emchar (disp_string, data.byte_charpos); |
4774 *prop = add_glyph_runes (&data, END_GLYPHS); | 4782 *prop = add_glyph_runes (&data, END_GLYPHS); |
4775 | 4783 |
4776 if (*prop) { | 4784 if (*prop) { |
4777 goto done; | 4785 goto done; |
4778 } | 4786 } |
4779 } | 4787 } |
4780 | 4788 |
4781 /* If there are begin glyphs, add them to the line. */ | 4789 /* If there are begin glyphs, add them to the line. */ |
4782 else if (Dynarr_length (data.ef->begin_glyphs) > 0) | 4790 else if (Dynarr_length (data.ef->begin_glyphs) > 0) |
4783 { | 4791 { |
4784 data.ch = XSTRING_CHAR (disp_string, data.bi_charbpos); | 4792 data.ch = string_emchar (disp_string, data.byte_charpos); |
4785 *prop = add_glyph_runes (&data, BEGIN_GLYPHS); | 4793 *prop = add_glyph_runes (&data, BEGIN_GLYPHS); |
4786 | 4794 |
4787 if (*prop) { | 4795 if (*prop) { |
4788 goto done; | 4796 goto done; |
4789 } | 4797 } |
4790 } | 4798 } |
4791 | 4799 |
4792 /* If at end-of-buffer, we've already processed begin and | 4800 /* If at end-of-buffer, we've already processed begin and |
4793 end-glyphs at this point and there's no text to process, | 4801 end-glyphs at this point and there's no text to process, |
4794 so we're done. */ | 4802 so we're done. */ |
4795 else if (data.bi_charbpos == bi_string_zv) | 4803 else if (data.byte_charpos == byte_string_zv) |
4796 goto done; | 4804 goto done; |
4797 | 4805 |
4798 else | 4806 else |
4799 { | 4807 { |
4800 Lisp_Object entry = Qnil; | 4808 Lisp_Object entry = Qnil; |
4801 /* Get the character at the current buffer position. */ | 4809 /* Get the character at the current buffer position. */ |
4802 data.ch = XSTRING_CHAR (disp_string, data.bi_charbpos); | 4810 data.ch = string_emchar (disp_string, data.byte_charpos); |
4803 if (!NILP (face_dt) || !NILP (window_dt)) | 4811 if (!NILP (face_dt) || !NILP (window_dt)) |
4804 entry = display_table_entry (data.ch, face_dt, window_dt); | 4812 entry = display_table_entry (data.ch, face_dt, window_dt); |
4805 | 4813 |
4806 /* If there is a display table entry for it, hand it off to | 4814 /* If there is a display table entry for it, hand it off to |
4807 add_disp_table_entry_runes and let it worry about it. */ | 4815 add_disp_table_entry_runes and let it worry about it. */ |
4912 *prop = add_emchar_rune (&data); | 4920 *prop = add_emchar_rune (&data); |
4913 if (*prop) | 4921 if (*prop) |
4914 goto done; | 4922 goto done; |
4915 } | 4923 } |
4916 | 4924 |
4917 INC_CHARBYTEBPOS (XSTRING_DATA (disp_string), data.bi_charbpos); | 4925 INC_BYTECOUNT (XSTRING_DATA (disp_string), data.byte_charpos); |
4918 } | 4926 } |
4919 } | 4927 } |
4920 | 4928 |
4921 done: | 4929 done: |
4922 | 4930 |
4923 /* Determine the starting point of the next line if we did not hit the | 4931 /* Determine the starting point of the next line if we did not hit the |
4924 end of the buffer. */ | 4932 end of the buffer. */ |
4925 if (data.bi_charbpos < bi_string_zv) | 4933 if (data.byte_charpos < byte_string_zv) |
4926 { | 4934 { |
4927 /* #### This check is not correct. If the line terminated | 4935 /* #### This check is not correct. If the line terminated |
4928 due to a begin-glyph or end-glyph hitting window-end, then | 4936 due to a begin-glyph or end-glyph hitting window-end, then |
4929 data.ch will not point to the character at data.bi_charbpos. If | 4937 data.ch will not point to the character at data.byte_charpos. If |
4930 you make the two changes mentioned at the top of this loop, | 4938 you make the two changes mentioned at the top of this loop, |
4931 you should be able to say '(if (*prop))'. That should also | 4939 you should be able to say '(if (*prop))'. That should also |
4932 make it possible to eliminate the data.bi_charbpos < BI_BUF_ZV (b) | 4940 make it possible to eliminate the data.byte_charpos < BYTE_BUF_ZV (b) |
4933 check. */ | 4941 check. */ |
4934 | 4942 |
4935 /* The common case is that the line ended because we hit a newline. | 4943 /* The common case is that the line ended because we hit a newline. |
4936 In that case, the next character is just the next buffer | 4944 In that case, the next character is just the next buffer |
4937 position. */ | 4945 position. */ |
4938 if (data.ch == '\n') | 4946 if (data.ch == '\n') |
4939 { | 4947 { |
4940 INC_CHARBYTEBPOS (XSTRING_DATA (disp_string), data.bi_charbpos); | 4948 INC_BYTECOUNT (XSTRING_DATA (disp_string), data.byte_charpos); |
4941 } | 4949 } |
4942 | 4950 |
4943 /* Otherwise we have a buffer line which cannot fit on one display | 4951 /* Otherwise we have a buffer line which cannot fit on one display |
4944 line. */ | 4952 line. */ |
4945 else | 4953 else |
4955 data.findex = default_face; | 4963 data.findex = default_face; |
4956 gb.extent = Qnil; | 4964 gb.extent = Qnil; |
4957 | 4965 |
4958 if (truncate_win) | 4966 if (truncate_win) |
4959 { | 4967 { |
4960 Bytebpos bi_pos; | 4968 Bytecount byte_pos; |
4961 | 4969 |
4962 /* Now find the start of the next line. */ | 4970 /* Now find the start of the next line. */ |
4963 bi_pos = bi_find_next_emchar_in_string (disp_string, '\n', | 4971 byte_pos = byte_find_next_emchar_in_string (disp_string, '\n', |
4964 data.bi_charbpos, 1); | 4972 data.byte_charpos, 1); |
4965 | 4973 |
4966 data.cursor_type = NO_CURSOR; | 4974 data.cursor_type = NO_CURSOR; |
4967 data.bi_charbpos = bi_pos; | 4975 data.byte_charpos = byte_pos; |
4968 gb.glyph = Vtruncation_glyph; | 4976 gb.glyph = Vtruncation_glyph; |
4969 cachel = GLYPH_CACHEL (w, TRUN_GLYPH_INDEX); | 4977 cachel = GLYPH_CACHEL (w, TRUN_GLYPH_INDEX); |
4970 } | 4978 } |
4971 else | 4979 else |
4972 { | 4980 { |
4973 /* The cursor can never be on the continuation glyph. */ | 4981 /* The cursor can never be on the continuation glyph. */ |
4974 data.cursor_type = NO_CURSOR; | 4982 data.cursor_type = NO_CURSOR; |
4975 | 4983 |
4976 /* data.bi_charbpos is already at the start of the next line. */ | 4984 /* data.byte_charpos is already at the start of the next line. */ |
4977 | 4985 |
4978 dl->line_continuation = 1; | 4986 dl->line_continuation = 1; |
4979 gb.glyph = Vcontinuation_glyph; | 4987 gb.glyph = Vcontinuation_glyph; |
4980 cachel = GLYPH_CACHEL (w, CONT_GLYPH_INDEX); | 4988 cachel = GLYPH_CACHEL (w, CONT_GLYPH_INDEX); |
4981 } | 4989 } |
4982 | 4990 |
4983 if (data.end_glyph_width) | 4991 if (data.end_glyph_width) |
4984 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 0, cachel); | 4992 add_glyph_rune (&data, &gb, BEGIN_GLYPHS, 0, cachel); |
4985 | 4993 |
4986 if (truncate_win && data.bi_charbpos == bi_string_zv) | 4994 if (truncate_win && data.byte_charpos == byte_string_zv) |
4987 { | 4995 { |
4988 const Intbyte *endb = charptr_n_addr (XSTRING_DATA (disp_string), | 4996 const Intbyte *endb = charptr_n_addr (XSTRING_DATA (disp_string), |
4989 bi_string_zv); | 4997 byte_string_zv); |
4990 DEC_CHARPTR (endb); | 4998 DEC_CHARPTR (endb); |
4991 if (charptr_emchar (endb) != '\n') | 4999 if (charptr_emchar (endb) != '\n') |
4992 { | 5000 { |
4993 /* #### Damn this losing shit. */ | 5001 /* #### Damn this losing shit. */ |
4994 data.bi_charbpos++; | 5002 data.byte_charpos++; |
4995 } | 5003 } |
4996 } | 5004 } |
4997 } | 5005 } |
4998 } | 5006 } |
4999 else if (data.bi_charbpos == bi_string_zv) | 5007 else if (data.byte_charpos == byte_string_zv) |
5000 { | 5008 { |
5001 /* create_text_block () adds a bogus \n marker here which screws | 5009 /* create_text_block () adds a bogus \n marker here which screws |
5002 up subwindow display. Since we never have a cursor in the | 5010 up subwindow display. Since we never have a cursor in the |
5003 gutter we can safely ignore it. */ | 5011 gutter we can safely ignore it. */ |
5004 } | 5012 } |
5080 | 5088 |
5081 calculate_yoffset (dl, db); | 5089 calculate_yoffset (dl, db); |
5082 | 5090 |
5083 dl->cursor_elt = data.cursor_x; | 5091 dl->cursor_elt = data.cursor_x; |
5084 /* #### lossage lossage lossage! Fix this shit! */ | 5092 /* #### lossage lossage lossage! Fix this shit! */ |
5085 if (data.bi_charbpos > bi_string_zv) | 5093 if (data.byte_charpos > byte_string_zv) |
5086 dl->end_charbpos = buffer_or_string_bytebpos_to_charbpos (disp_string, | 5094 dl->end_charpos = buffer_or_string_bytexpos_to_charxpos (disp_string, |
5087 bi_string_zv); | 5095 byte_string_zv); |
5088 else | 5096 else |
5089 dl->end_charbpos = | 5097 dl->end_charpos = |
5090 buffer_or_string_bytebpos_to_charbpos (disp_string, | 5098 buffer_or_string_bytexpos_to_charxpos (disp_string, |
5091 data.bi_charbpos) - 1; | 5099 data.byte_charpos) - 1; |
5092 if (truncate_win) | 5100 if (truncate_win) |
5093 data.dl->num_chars = | 5101 data.dl->num_chars = |
5094 string_column_at_point (disp_string, dl->end_charbpos, | 5102 string_column_at_point (disp_string, dl->end_charpos, |
5095 b ? XINT (b->tab_width) : 8); | 5103 b ? XINT (b->tab_width) : 8); |
5096 else | 5104 else |
5097 /* This doesn't correctly take into account tabs and control | 5105 /* This doesn't correctly take into account tabs and control |
5098 characters but if the window isn't being truncated then this | 5106 characters but if the window isn't being truncated then this |
5099 value isn't going to end up being used anyhow. */ | 5107 value isn't going to end up being used anyhow. */ |
5100 data.dl->num_chars = dl->end_charbpos - dl->charbpos; | 5108 data.dl->num_chars = dl->end_charpos - dl->charpos; |
5101 | 5109 |
5102 /* #### handle horizontally scrolled line with text none of which | 5110 /* #### handle horizontally scrolled line with text none of which |
5103 was actually laid out. */ | 5111 was actually laid out. */ |
5104 | 5112 |
5105 /* #### handle any remainder of overlay arrow */ | 5113 /* #### handle any remainder of overlay arrow */ |
5118 /* #### If we started at EOB, then make sure we return a value past | 5126 /* #### If we started at EOB, then make sure we return a value past |
5119 it so that regenerate_window will exit properly. This is bogus. | 5127 it so that regenerate_window will exit properly. This is bogus. |
5120 The main loop should get fixed so that it isn't necessary to call | 5128 The main loop should get fixed so that it isn't necessary to call |
5121 this function if we are already at EOB. */ | 5129 this function if we are already at EOB. */ |
5122 | 5130 |
5123 if (data.bi_charbpos == bi_string_zv && bi_start_pos == bi_string_zv) | 5131 if (data.byte_charpos == byte_string_zv && byte_start_pos == byte_string_zv) |
5124 return string_index_byte_to_char (disp_string, | 5132 return string_index_byte_to_char (disp_string, |
5125 data.bi_charbpos) + 1; /* Yuck! */ | 5133 data.byte_charpos) + 1; /* Yuck! */ |
5126 else | 5134 else |
5127 return string_index_byte_to_char (disp_string, data.bi_charbpos); | 5135 return string_index_byte_to_char (disp_string, data.byte_charpos); |
5128 } | 5136 } |
5129 | 5137 |
5130 /* Given a display line and a starting position, ensure that the | 5138 /* Given a display line and a starting position, ensure that the |
5131 contents of the display line accurately represent the visual | 5139 contents of the display line accurately represent the visual |
5132 representation of the buffer contents starting from the given | 5140 representation of the buffer contents starting from the given |
5139 of fixing the bytebpos stuff though.*/ | 5147 of fixing the bytebpos stuff though.*/ |
5140 | 5148 |
5141 static Charbpos | 5149 static Charbpos |
5142 generate_string_display_line (struct window *w, Lisp_Object disp_string, | 5150 generate_string_display_line (struct window *w, Lisp_Object disp_string, |
5143 struct display_line *dl, | 5151 struct display_line *dl, |
5144 Charbpos start_pos, | 5152 Charcount start_pos, |
5145 prop_block_dynarr **prop, | 5153 prop_block_dynarr **prop, |
5146 face_index default_face) | 5154 face_index default_face) |
5147 { | 5155 { |
5148 Charbpos ret_charbpos; | 5156 Charcount ret_charcount; |
5149 | 5157 |
5150 /* you must set bounds before calling this. */ | 5158 /* you must set bounds before calling this. */ |
5151 | 5159 |
5152 /* Reset what this line is using. */ | 5160 /* Reset what this line is using. */ |
5153 if (dl->display_blocks) | 5161 if (dl->display_blocks) |
5165 | 5173 |
5166 /* We aren't generating a modeline at the moment. */ | 5174 /* We aren't generating a modeline at the moment. */ |
5167 dl->modeline = 0; | 5175 dl->modeline = 0; |
5168 | 5176 |
5169 /* Create a display block for the text region of the line. */ | 5177 /* Create a display block for the text region of the line. */ |
5170 ret_charbpos = create_string_text_block (w, disp_string, dl, start_pos, | 5178 ret_charcount = create_string_text_block (w, disp_string, dl, start_pos, |
5171 prop, default_face); | 5179 prop, default_face); |
5172 dl->charbpos = start_pos; | 5180 dl->charpos = start_pos; |
5173 if (dl->end_charbpos < dl->charbpos) | 5181 if (dl->end_charpos < dl->charpos) |
5174 dl->end_charbpos = dl->charbpos; | 5182 dl->end_charpos = dl->charpos; |
5175 | 5183 |
5176 /* If there are left glyphs associated with any character in the | 5184 /* If there are left glyphs associated with any character in the |
5177 text block, then create a display block to handle them. */ | 5185 text block, then create a display block to handle them. */ |
5178 if (dl->left_glyphs != NULL && Dynarr_length (dl->left_glyphs)) | 5186 if (dl->left_glyphs != NULL && Dynarr_length (dl->left_glyphs)) |
5179 create_left_glyph_block (w, dl, 0); | 5187 create_left_glyph_block (w, dl, 0); |
5181 /* If there are right glyphs associated with any character in the | 5189 /* If there are right glyphs associated with any character in the |
5182 text block, then create a display block to handle them. */ | 5190 text block, then create a display block to handle them. */ |
5183 if (dl->right_glyphs != NULL && Dynarr_length (dl->right_glyphs)) | 5191 if (dl->right_glyphs != NULL && Dynarr_length (dl->right_glyphs)) |
5184 create_right_glyph_block (w, dl); | 5192 create_right_glyph_block (w, dl); |
5185 | 5193 |
5186 return ret_charbpos; | 5194 return ret_charcount; |
5187 } | 5195 } |
5188 | 5196 |
5189 /* This is ripped off from regenerate_window. All we want to do is | 5197 /* This is ripped off from regenerate_window. All we want to do is |
5190 loop through elements in the string creating display lines until we | 5198 loop through elements in the string creating display lines until we |
5191 have covered the provided area. Simple really. */ | 5199 have covered the provided area. Simple really. */ |
5192 void | 5200 void |
5193 generate_displayable_area (struct window *w, Lisp_Object disp_string, | 5201 generate_displayable_area (struct window *w, Lisp_Object disp_string, |
5194 int xpos, int ypos, int width, int height, | 5202 int xpos, int ypos, int width, int height, |
5195 display_line_dynarr* dla, | 5203 display_line_dynarr* dla, |
5196 Charbpos start_pos, | 5204 Charcount start_pos, |
5197 face_index default_face) | 5205 face_index default_face) |
5198 { | 5206 { |
5199 int yend = ypos + height; | 5207 int yend = ypos + height; |
5200 Charcount s_zv; | 5208 Charcount s_zv; |
5201 | 5209 |
5207 /* if there's nothing to do then do nothing. code after this assumes | 5215 /* if there's nothing to do then do nothing. code after this assumes |
5208 there is something to do. */ | 5216 there is something to do. */ |
5209 if (NILP (disp_string)) | 5217 if (NILP (disp_string)) |
5210 return; | 5218 return; |
5211 | 5219 |
5212 s_zv = XSTRING_CHAR_LENGTH (disp_string); | 5220 s_zv = string_char_length (disp_string); |
5213 | 5221 |
5214 bounds.left_out = xpos; | 5222 bounds.left_out = xpos; |
5215 bounds.right_out = xpos + width; | 5223 bounds.right_out = xpos + width; |
5216 /* The inner boundaries mark where the glyph margins are located. */ | 5224 /* The inner boundaries mark where the glyph margins are located. */ |
5217 bounds.left_in = bounds.left_out + window_left_margin_width (w); | 5225 bounds.left_in = bounds.left_out + window_left_margin_width (w); |
5223 | 5231 |
5224 while (ypos < yend) | 5232 while (ypos < yend) |
5225 { | 5233 { |
5226 struct display_line dl; | 5234 struct display_line dl; |
5227 struct display_line *dlp; | 5235 struct display_line *dlp; |
5228 Charbpos next_pos; | 5236 Charcount next_pos; |
5229 int local; | 5237 int local; |
5230 | 5238 |
5231 if (Dynarr_length (dla) < Dynarr_largest (dla)) | 5239 if (Dynarr_length (dla) < Dynarr_largest (dla)) |
5232 { | 5240 { |
5233 dlp = Dynarr_atp (dla, Dynarr_length (dla)); | 5241 dlp = Dynarr_atp (dla, Dynarr_length (dla)); |
5488 there when we first started working in this function. */ | 5496 there when we first started working in this function. */ |
5489 generate_modeline (w, Dynarr_atp (dla, 0), type); | 5497 generate_modeline (w, Dynarr_atp (dla, 0), type); |
5490 } | 5498 } |
5491 } | 5499 } |
5492 | 5500 |
5493 #define REGEN_INC_FIND_START_END \ | 5501 #define REGEN_INC_FIND_START_END \ |
5494 do { \ | 5502 do { \ |
5495 /* Determine start and end of lines. */ \ | 5503 /* Determine start and end of lines. */ \ |
5496 if (!Dynarr_length (cdla)) \ | 5504 if (!Dynarr_length (cdla)) \ |
5497 return 0; \ | 5505 return 0; \ |
5498 else \ | 5506 else \ |
5499 { \ | 5507 { \ |
5500 if (Dynarr_atp (cdla, 0)->modeline && Dynarr_atp (ddla, 0)->modeline) \ | 5508 if (Dynarr_atp (cdla, 0)->modeline && Dynarr_atp (ddla, 0)->modeline) \ |
5501 { \ | 5509 { \ |
5502 dla_start = 1; \ | 5510 dla_start = 1; \ |
5503 } \ | 5511 } \ |
5504 else if (!Dynarr_atp (cdla, 0)->modeline \ | 5512 else if (!Dynarr_atp (cdla, 0)->modeline \ |
5505 && !Dynarr_atp (ddla, 0)->modeline) \ | 5513 && !Dynarr_atp (ddla, 0)->modeline) \ |
5506 { \ | 5514 { \ |
5507 dla_start = 0; \ | 5515 dla_start = 0; \ |
5508 } \ | 5516 } \ |
5509 else \ | 5517 else \ |
5510 abort (); /* structs differ */ \ | 5518 abort (); /* structs differ */ \ |
5511 \ | 5519 \ |
5512 dla_end = Dynarr_length (cdla) - 1; \ | 5520 dla_end = Dynarr_length (cdla) - 1; \ |
5513 } \ | 5521 } \ |
5514 \ | 5522 \ |
5515 start_pos = (Dynarr_atp (cdla, dla_start)->charbpos \ | 5523 start_pos = (Dynarr_atp (cdla, dla_start)->charpos \ |
5516 + Dynarr_atp (cdla, dla_start)->offset); \ | 5524 + Dynarr_atp (cdla, dla_start)->offset); \ |
5517 /* If this isn't true, then startp has changed and we need to do a \ | 5525 /* If this isn't true, then startp has changed and we need to do a \ |
5518 full regen. */ \ | 5526 full regen. */ \ |
5519 if (startp != start_pos) \ | 5527 if (startp != start_pos) \ |
5520 return 0; \ | 5528 return 0; \ |
5521 \ | 5529 \ |
5522 /* Point is outside the visible region so give up. */ \ | 5530 /* Point is outside the visible region so give up. */ \ |
5523 if (pointm < start_pos) \ | 5531 if (pointm < start_pos) \ |
5524 return 0; \ | 5532 return 0; \ |
5525 \ | 5533 \ |
5526 } while (0) | 5534 } while (0) |
5527 | 5535 |
5528 /* This attempts to incrementally update the display structures. It | 5536 /* This attempts to incrementally update the display structures. It |
5529 returns a boolean indicating success or failure. This function is | 5537 returns a boolean indicating success or failure. This function is |
5530 very similar to regenerate_window_incrementally and is in fact only | 5538 very similar to regenerate_window_incrementally and is in fact only |
5608 /* Find what display line the extent changes first affect. */ | 5616 /* Find what display line the extent changes first affect. */ |
5609 line = dla_start; | 5617 line = dla_start; |
5610 while (line <= dla_end) | 5618 while (line <= dla_end) |
5611 { | 5619 { |
5612 struct display_line *dl = Dynarr_atp (cdla, line); | 5620 struct display_line *dl = Dynarr_atp (cdla, line); |
5613 Charbpos lstart = dl->charbpos + dl->offset; | 5621 Charbpos lstart = dl->charpos + dl->offset; |
5614 Charbpos lend = dl->end_charbpos + dl->offset; | 5622 Charbpos lend = dl->end_charpos + dl->offset; |
5615 | 5623 |
5616 if (beg_unchanged >= lstart && beg_unchanged <= lend) | 5624 if (beg_unchanged >= lstart && beg_unchanged <= lend) |
5617 break; | 5625 break; |
5618 | 5626 |
5619 line++; | 5627 line++; |
5649 struct display_line *cdl = Dynarr_atp (cdla, line); | 5657 struct display_line *cdl = Dynarr_atp (cdla, line); |
5650 struct display_line *ddl = Dynarr_atp (ddla, line); | 5658 struct display_line *ddl = Dynarr_atp (ddla, line); |
5651 struct display_block *db; | 5659 struct display_block *db; |
5652 int initial_size; | 5660 int initial_size; |
5653 | 5661 |
5654 assert (cdl->charbpos == ddl->charbpos); | 5662 assert (cdl->charpos == ddl->charpos); |
5655 assert (cdl->end_charbpos == ddl->end_charbpos); | 5663 assert (cdl->end_charpos == ddl->end_charpos); |
5656 assert (cdl->offset == ddl->offset); | 5664 assert (cdl->offset == ddl->offset); |
5657 | 5665 |
5658 db = get_display_block_from_line (ddl, TEXT); | 5666 db = get_display_block_from_line (ddl, TEXT); |
5659 initial_size = Dynarr_length (db->runes); | 5667 initial_size = Dynarr_length (db->runes); |
5660 old_start = ddl->charbpos + ddl->offset; | 5668 old_start = ddl->charpos + ddl->offset; |
5661 old_end = ddl->end_charbpos + ddl->offset; | 5669 old_end = ddl->end_charpos + ddl->offset; |
5662 | 5670 |
5663 /* If this is the first line being updated and it used | 5671 /* If this is the first line being updated and it used |
5664 propagation data, fail. Otherwise we'll be okay because | 5672 propagation data, fail. Otherwise we'll be okay because |
5665 we'll have the necessary propagation data. */ | 5673 we'll have the necessary propagation data. */ |
5666 if (line == first_line && ddl->used_prop_data) | 5674 if (line == first_line && ddl->used_prop_data) |
5667 return 0; | 5675 return 0; |
5668 | 5676 |
5669 new_start = generate_display_line (w, ddl, 0, ddl->charbpos + ddl->offset, | 5677 new_start = generate_display_line (w, ddl, 0, ddl->charpos + ddl->offset, |
5670 &prop, DESIRED_DISP); | 5678 &prop, DESIRED_DISP); |
5671 ddl->offset = 0; | 5679 ddl->offset = 0; |
5672 | 5680 |
5673 /* #### If there is propagated stuff the fail. We could | 5681 /* #### If there is propagated stuff the fail. We could |
5674 probably actually deal with this if the line had propagated | 5682 probably actually deal with this if the line had propagated |
5687 || cdl->ascent != ddl->ascent | 5695 || cdl->ascent != ddl->ascent |
5688 || cdl->descent != ddl->descent | 5696 || cdl->descent != ddl->descent |
5689 || cdl->top_clip != ddl->top_clip | 5697 || cdl->top_clip != ddl->top_clip |
5690 || (cdl->cursor_elt != -1 && ddl->cursor_elt == -1) | 5698 || (cdl->cursor_elt != -1 && ddl->cursor_elt == -1) |
5691 || (cdl->cursor_elt == -1 && ddl->cursor_elt != -1) | 5699 || (cdl->cursor_elt == -1 && ddl->cursor_elt != -1) |
5692 || old_start != ddl->charbpos | 5700 || old_start != ddl->charpos |
5693 || old_end != ddl->end_charbpos | 5701 || old_end != ddl->end_charpos |
5694 || initial_size != Dynarr_length (db->runes)) | 5702 || initial_size != Dynarr_length (db->runes)) |
5695 { | 5703 { |
5696 return 0; | 5704 return 0; |
5697 } | 5705 } |
5698 | 5706 |
5704 | 5712 |
5705 last_line = line; | 5713 last_line = line; |
5706 | 5714 |
5707 /* If the extent changes end on the line we just updated then | 5715 /* If the extent changes end on the line we just updated then |
5708 we're done. Otherwise go on to the next line. */ | 5716 we're done. Otherwise go on to the next line. */ |
5709 if (end_unchanged <= ddl->end_charbpos) | 5717 if (end_unchanged <= ddl->end_charpos) |
5710 break; | 5718 break; |
5711 else | 5719 else |
5712 line++; | 5720 line++; |
5713 } | 5721 } |
5714 | 5722 |
5775 /* Find what display line the buffer changes first affect. */ | 5783 /* Find what display line the buffer changes first affect. */ |
5776 line = dla_start; | 5784 line = dla_start; |
5777 while (line <= dla_end) | 5785 while (line <= dla_end) |
5778 { | 5786 { |
5779 struct display_line *dl = Dynarr_atp (cdla, line); | 5787 struct display_line *dl = Dynarr_atp (cdla, line); |
5780 Charbpos lstart = dl->charbpos + dl->offset; | 5788 Charbpos lstart = dl->charpos + dl->offset; |
5781 Charbpos lend = dl->end_charbpos + dl->offset; | 5789 Charbpos lend = dl->end_charpos + dl->offset; |
5782 | 5790 |
5783 if (beg_unchanged >= lstart && beg_unchanged <= lend) | 5791 if (beg_unchanged >= lstart && beg_unchanged <= lend) |
5784 break; | 5792 break; |
5785 | 5793 |
5786 line++; | 5794 line++; |
5804 Charbpos new_start; | 5812 Charbpos new_start; |
5805 prop_block_dynarr *prop = NULL; | 5813 prop_block_dynarr *prop = NULL; |
5806 struct display_line *cdl = Dynarr_atp (cdla, line); | 5814 struct display_line *cdl = Dynarr_atp (cdla, line); |
5807 struct display_line *ddl = Dynarr_atp (ddla, line); | 5815 struct display_line *ddl = Dynarr_atp (ddla, line); |
5808 | 5816 |
5809 assert (cdl->charbpos == ddl->charbpos); | 5817 assert (cdl->charpos == ddl->charpos); |
5810 assert (cdl->end_charbpos == ddl->end_charbpos); | 5818 assert (cdl->end_charpos == ddl->end_charpos); |
5811 assert (cdl->offset == ddl->offset); | 5819 assert (cdl->offset == ddl->offset); |
5812 | 5820 |
5813 /* If the line continues to next display line, fail. */ | 5821 /* If the line continues to next display line, fail. */ |
5814 if (ddl->line_continuation) | 5822 if (ddl->line_continuation) |
5815 return 0; | 5823 return 0; |
5816 | 5824 |
5817 /* If the line was generated using propagation data, fail. */ | 5825 /* If the line was generated using propagation data, fail. */ |
5818 if (ddl->used_prop_data) | 5826 if (ddl->used_prop_data) |
5819 return 0; | 5827 return 0; |
5820 | 5828 |
5821 new_start = generate_display_line (w, ddl, 0, ddl->charbpos + ddl->offset, | 5829 new_start = generate_display_line (w, ddl, 0, ddl->charpos + ddl->offset, |
5822 &prop, DESIRED_DISP); | 5830 &prop, DESIRED_DISP); |
5823 ddl->offset = 0; | 5831 ddl->offset = 0; |
5824 | 5832 |
5825 /* If there is propagated stuff then it is pretty much a | 5833 /* If there is propagated stuff then it is pretty much a |
5826 guarantee that more than just the one line is affected. */ | 5834 guarantee that more than just the one line is affected. */ |
5846 return 0; | 5854 return 0; |
5847 } | 5855 } |
5848 | 5856 |
5849 /* If the changed area also ends on this line, then we may be in | 5857 /* If the changed area also ends on this line, then we may be in |
5850 business. Update everything and return success. */ | 5858 business. Update everything and return success. */ |
5851 if (end_unchanged >= ddl->charbpos && end_unchanged <= ddl->end_charbpos) | 5859 if (end_unchanged >= ddl->charpos && end_unchanged <= ddl->end_charpos) |
5852 { | 5860 { |
5853 w->last_modified[DESIRED_DISP] = make_int (BUF_MODIFF (b)); | 5861 w->last_modified[DESIRED_DISP] = make_int (BUF_MODIFF (b)); |
5854 w->last_facechange[DESIRED_DISP] = make_int (BUF_FACECHANGE (b)); | 5862 w->last_facechange[DESIRED_DISP] = make_int (BUF_FACECHANGE (b)); |
5855 Fset_marker (w->last_start[DESIRED_DISP], make_int (startp), | 5863 Fset_marker (w->last_start[DESIRED_DISP], make_int (startp), |
5856 w->buffer); | 5864 w->buffer); |
5891 buffer changes update succeeded this probably will to. | 5899 buffer changes update succeeded this probably will to. |
5892 We already know that the extent changes start at or after | 5900 We already know that the extent changes start at or after |
5893 the line because we checked before entering the loop. */ | 5901 the line because we checked before entering the loop. */ |
5894 if (extent_beg_unchanged != -1 | 5902 if (extent_beg_unchanged != -1 |
5895 && extent_end_unchanged != -1 | 5903 && extent_end_unchanged != -1 |
5896 && ((extent_beg_unchanged < ddl->charbpos) | 5904 && ((extent_beg_unchanged < ddl->charpos) |
5897 || (extent_end_unchanged > ddl->end_charbpos))) | 5905 || (extent_end_unchanged > ddl->end_charpos))) |
5898 return regenerate_window_extents_only_changed (w, startp, pointm, | 5906 return regenerate_window_extents_only_changed (w, startp, pointm, |
5899 extent_beg_unchanged, | 5907 extent_beg_unchanged, |
5900 extent_end_unchanged); | 5908 extent_end_unchanged); |
5901 else | 5909 else |
5902 return 1; | 5910 return 1; |
5945 if (Dynarr_length (dla) > first_line) | 5953 if (Dynarr_length (dla) > first_line) |
5946 { | 5954 { |
5947 Charbpos start, end; | 5955 Charbpos start, end; |
5948 struct display_line *dl = Dynarr_atp (dla, first_line); | 5956 struct display_line *dl = Dynarr_atp (dla, first_line); |
5949 | 5957 |
5950 start = dl->charbpos; | 5958 start = dl->charpos; |
5951 end = BUF_Z (b) - w->window_end_pos[type] - 1; | 5959 end = BUF_Z (b) - w->window_end_pos[type] - 1; |
5952 | 5960 |
5953 if (point >= start && point <= end) | 5961 if (point >= start && point <= end) |
5954 { | 5962 { |
5955 if (!MINI_WINDOW_P (w) && scroll_on_clipped_lines) | 5963 if (!MINI_WINDOW_P (w) && scroll_on_clipped_lines) |
5956 { | 5964 { |
5957 dl = Dynarr_atp (dla, Dynarr_length (dla) - 1); | 5965 dl = Dynarr_atp (dla, Dynarr_length (dla) - 1); |
5958 | 5966 |
5959 if (point >= (dl->charbpos + dl->offset) | 5967 if (point >= (dl->charpos + dl->offset) |
5960 && point <= (dl->end_charbpos + dl->offset)) | 5968 && point <= (dl->end_charpos + dl->offset)) |
5961 return !dl->clip; | 5969 return !dl->clip; |
5962 else | 5970 else |
5963 return 1; | 5971 return 1; |
5964 } | 5972 } |
5965 else | 5973 else |
6026 else | 6034 else |
6027 { | 6035 { |
6028 display_line_dynarr *dla = window_display_lines (w, type); | 6036 display_line_dynarr *dla = window_display_lines (w, type); |
6029 struct display_line *dl = Dynarr_atp (dla, line); | 6037 struct display_line *dl = Dynarr_atp (dla, line); |
6030 | 6038 |
6031 return dl->charbpos; | 6039 return dl->charpos; |
6032 } | 6040 } |
6033 } | 6041 } |
6034 | 6042 |
6035 /* For a given window, ensure that the current visual representation | 6043 /* For a given window, ensure that the current visual representation |
6036 is accurate. */ | 6044 is accurate. */ |
7375 continue; | 7383 continue; |
7376 else | 7384 else |
7377 { | 7385 { |
7378 struct line_start_cache lsc; | 7386 struct line_start_cache lsc; |
7379 | 7387 |
7380 lsc.start = dl->charbpos; | 7388 lsc.start = dl->charpos; |
7381 lsc.end = dl->end_charbpos; | 7389 lsc.end = dl->end_charpos; |
7382 lsc.height = dl->ascent + dl->descent; | 7390 lsc.height = dl->ascent + dl->descent; |
7383 | 7391 |
7384 Dynarr_add (internal_cache, lsc); | 7392 Dynarr_add (internal_cache, lsc); |
7385 } | 7393 } |
7386 } | 7394 } |
8431 d->pixel_to_glyph_cache.col = *col; \ | 8439 d->pixel_to_glyph_cache.col = *col; \ |
8432 d->pixel_to_glyph_cache.row = *row; \ | 8440 d->pixel_to_glyph_cache.row = *row; \ |
8433 d->pixel_to_glyph_cache.obj_x = *obj_x; \ | 8441 d->pixel_to_glyph_cache.obj_x = *obj_x; \ |
8434 d->pixel_to_glyph_cache.obj_y = *obj_y; \ | 8442 d->pixel_to_glyph_cache.obj_y = *obj_y; \ |
8435 d->pixel_to_glyph_cache.w = *w; \ | 8443 d->pixel_to_glyph_cache.w = *w; \ |
8436 d->pixel_to_glyph_cache.charbpos = *charbpos; \ | 8444 d->pixel_to_glyph_cache.charpos = *charpos; \ |
8437 d->pixel_to_glyph_cache.closest = *closest; \ | 8445 d->pixel_to_glyph_cache.closest = *closest; \ |
8438 d->pixel_to_glyph_cache.modeline_closest = *modeline_closest; \ | 8446 d->pixel_to_glyph_cache.modeline_closest = *modeline_closest; \ |
8439 d->pixel_to_glyph_cache.obj1 = *obj1; \ | 8447 d->pixel_to_glyph_cache.obj1 = *obj1; \ |
8440 d->pixel_to_glyph_cache.obj2 = *obj2; \ | 8448 d->pixel_to_glyph_cache.obj2 = *obj2; \ |
8441 d->pixel_to_glyph_cache.retval = position; \ | 8449 d->pixel_to_glyph_cache.retval = position; \ |
8475 */ | 8483 */ |
8476 | 8484 |
8477 int | 8485 int |
8478 pixel_to_glyph_translation (struct frame *f, int x_coord, int y_coord, | 8486 pixel_to_glyph_translation (struct frame *f, int x_coord, int y_coord, |
8479 int *col, int *row, int *obj_x, int *obj_y, | 8487 int *col, int *row, int *obj_x, int *obj_y, |
8480 struct window **w, Charbpos *charbpos, | 8488 struct window **w, Charbpos *charpos, |
8481 Charbpos *closest, Charcount *modeline_closest, | 8489 Charbpos *closest, Charcount *modeline_closest, |
8482 Lisp_Object *obj1, Lisp_Object *obj2) | 8490 Lisp_Object *obj1, Lisp_Object *obj2) |
8483 { | 8491 { |
8484 struct device *d; | 8492 struct device *d; |
8485 struct pixel_to_glyph_translation_cache *cache; | 8493 struct pixel_to_glyph_translation_cache *cache; |
8514 *col = cache->col; | 8522 *col = cache->col; |
8515 *row = cache->row; | 8523 *row = cache->row; |
8516 *obj_x = cache->obj_x; | 8524 *obj_x = cache->obj_x; |
8517 *obj_y = cache->obj_y; | 8525 *obj_y = cache->obj_y; |
8518 *w = cache->w; | 8526 *w = cache->w; |
8519 *charbpos = cache->charbpos; | 8527 *charpos = cache->charpos; |
8520 *closest = cache->closest; | 8528 *closest = cache->closest; |
8521 *modeline_closest = cache->modeline_closest; | 8529 *modeline_closest = cache->modeline_closest; |
8522 *obj1 = cache->obj1; | 8530 *obj1 = cache->obj1; |
8523 *obj2 = cache->obj2; | 8531 *obj2 = cache->obj2; |
8524 | 8532 |
8529 *col = 0; | 8537 *col = 0; |
8530 *row = 0; | 8538 *row = 0; |
8531 *obj_x = 0; | 8539 *obj_x = 0; |
8532 *obj_y = 0; | 8540 *obj_y = 0; |
8533 *w = 0; | 8541 *w = 0; |
8534 *charbpos = 0; | 8542 *charpos = 0; |
8535 *closest = 0; | 8543 *closest = 0; |
8536 *modeline_closest = -1; | 8544 *modeline_closest = -1; |
8537 *obj1 = Qnil; | 8545 *obj1 = Qnil; |
8538 *obj2 = Qnil; | 8546 *obj2 = Qnil; |
8539 | 8547 |
8756 if (Dynarr_length (db->runes)) | 8764 if (Dynarr_length (db->runes)) |
8757 { | 8765 { |
8758 if (x_check <= left_bound) | 8766 if (x_check <= left_bound) |
8759 { | 8767 { |
8760 if (dl->modeline) | 8768 if (dl->modeline) |
8761 *modeline_closest = Dynarr_atp (db->runes, 0)->charbpos; | 8769 *modeline_closest = Dynarr_atp (db->runes, 0)->charpos; |
8762 else | 8770 else |
8763 *closest = Dynarr_atp (db->runes, 0)->charbpos; | 8771 *closest = Dynarr_atp (db->runes, 0)->charpos; |
8764 } | 8772 } |
8765 else | 8773 else |
8766 { | 8774 { |
8767 if (dl->modeline) | 8775 if (dl->modeline) |
8768 *modeline_closest = | 8776 *modeline_closest = |
8769 Dynarr_atp (db->runes, | 8777 Dynarr_atp (db->runes, |
8770 Dynarr_length (db->runes) - 1)->charbpos; | 8778 Dynarr_length (db->runes) - 1)->charpos; |
8771 else | 8779 else |
8772 *closest = | 8780 *closest = |
8773 Dynarr_atp (db->runes, | 8781 Dynarr_atp (db->runes, |
8774 Dynarr_length (db->runes) - 1)->charbpos; | 8782 Dynarr_length (db->runes) - 1)->charpos; |
8775 } | 8783 } |
8776 | 8784 |
8777 if (dl->modeline) | 8785 if (dl->modeline) |
8778 *modeline_closest += dl->offset; | 8786 *modeline_closest += dl->offset; |
8779 else | 8787 else |
8824 { | 8832 { |
8825 (*col)--; | 8833 (*col)--; |
8826 rb = Dynarr_atp (db->runes, *col); | 8834 rb = Dynarr_atp (db->runes, *col); |
8827 } | 8835 } |
8828 | 8836 |
8829 *charbpos = rb->charbpos + dl->offset; | 8837 *charpos = rb->charpos + dl->offset; |
8830 low_x_coord = rb->xpos; | 8838 low_x_coord = rb->xpos; |
8831 high_x_coord = rb->xpos + rb->width; | 8839 high_x_coord = rb->xpos + rb->width; |
8832 | 8840 |
8833 if (rb->type == RUNE_DGLYPH) | 8841 if (rb->type == RUNE_DGLYPH) |
8834 { | 8842 { |
8839 { | 8847 { |
8840 if (Dynarr_atp (db->runes, elt)->type != RUNE_DGLYPH) | 8848 if (Dynarr_atp (db->runes, elt)->type != RUNE_DGLYPH) |
8841 { | 8849 { |
8842 if (dl->modeline) | 8850 if (dl->modeline) |
8843 *modeline_closest = | 8851 *modeline_closest = |
8844 (Dynarr_atp (db->runes, elt)->charbpos + | 8852 (Dynarr_atp (db->runes, elt)->charpos + |
8845 dl->offset); | 8853 dl->offset); |
8846 else | 8854 else |
8847 *closest = | 8855 *closest = |
8848 (Dynarr_atp (db->runes, elt)->charbpos + | 8856 (Dynarr_atp (db->runes, elt)->charpos + |
8849 dl->offset); | 8857 dl->offset); |
8850 break; | 8858 break; |
8851 } | 8859 } |
8852 | 8860 |
8853 elt++; | 8861 elt++; |
8857 character so we return the last position | 8865 character so we return the last position |
8858 displayed on the line. */ | 8866 displayed on the line. */ |
8859 if (elt == Dynarr_length (db->runes)) | 8867 if (elt == Dynarr_length (db->runes)) |
8860 { | 8868 { |
8861 if (dl->modeline) | 8869 if (dl->modeline) |
8862 *modeline_closest = dl->end_charbpos + dl->offset; | 8870 *modeline_closest = dl->end_charpos + dl->offset; |
8863 else | 8871 else |
8864 *closest = dl->end_charbpos + dl->offset; | 8872 *closest = dl->end_charpos + dl->offset; |
8865 really_over_nothing = 1; | 8873 really_over_nothing = 1; |
8866 } | 8874 } |
8867 } | 8875 } |
8868 else | 8876 else |
8869 { | 8877 { |
8870 if (dl->modeline) | 8878 if (dl->modeline) |
8871 *modeline_closest = rb->charbpos + dl->offset; | 8879 *modeline_closest = rb->charpos + dl->offset; |
8872 else | 8880 else |
8873 *closest = rb->charbpos + dl->offset; | 8881 *closest = rb->charpos + dl->offset; |
8874 } | 8882 } |
8875 | 8883 |
8876 if (dl->modeline) | 8884 if (dl->modeline) |
8877 { | 8885 { |
8878 *row = window_displayed_height (*w); | 8886 *row = window_displayed_height (*w); |