Fix glyph_row reversed_p flag in empty lines between paragraphs.
[emacs.git] / src / ChangeLog.bidi
blobd27f747466b2028b594186408c10cfd00c12b73b
1 2010-03-28  Eli Zaretskii  <eliz@gnu.org>
3         * bidi.c (bidi_get_next_char_visually): Improve commentary.
5         * dispextern.h (PRODUCE_GLYPHS): Set the reversed_p flag in the
6         iterator's glyph_row here.
8         * xdisp.c (handle_invisible_prop, set_iterator_to_next)
9         (next_element_from_buffer): Don't set the reversed_p flag in the
10         iterator's glyph_row here.
12 2010-03-20  Eli Zaretskii  <eliz@gnu.org>
14         * xdisp.c (set_cursor_from_row): Don't miss a candidate row whose
15         glyph->charpos is an exact match for point.
16         (try_cursor_movement): Don't give up if rows are bidi-reordered
17         and point moved backwards.  Instead, back up to the row that is
18         not a continuation line.
20 2010-03-13  Eli Zaretskii  <eliz@gnu.org>
22         * xdisp.c (try_cursor_movement): Give up if rows are
23         bidi-reordered and point moved backwards.  Examine all the
24         candidate rows that occlude point, to return the best match.
25         (row_containing_pos): With bidi-reordered rows, don't return the
26         first one that occludes point; rather, examine all candidates and
27         return the best match, with he glyph that's closest to point.
28         (display_line): When looking for min position, don't consider
29         negative values of glyph->charpos.  (Fixes a crash with "C-x 3" at
30         ZV.)  Record the position after EOL in it->eol_pos, and use it to
31         set end_pos of the last row produced for a continued line.  Fix
32         the condition for passing candidate rows to set_cursor_from_row:
33         check ends_at_zv_p flag of the best candidate row, not of the
34         current row.
36         * dispextern.h (struct it): New member eol_pos.
38         * .gdbinit (prowlims): Display the ends_at_zv_p flag.
40 2010-03-06  Eli Zaretskii  <eliz@gnu.org>
42         * .gdbinit (prowlims, pmtxrows): New commands.
44         * xdisp.c (display_line): Special-case the calculation of row->end
45         in rows that end at ZV, to avoid abort in CHAR_TO_BYTE.  Handle
46         empty lines correctly when calculating row's max and min pos.
47         Display cursor at the first glyph row that has its ends_at_zv_p
48         flag set.
50 2010-02-20  Eli Zaretskii  <eliz@gnu.org>
52         * xdisp.c (set_cursor_from_row): Compare candidate cursor
53         positions only in rows whose buffer positions occlude point.
54         (display_line): Fix computation of row->start and row->end for
55         empty lines.
57         * dispnew.c (row_equal_p): Compare the reversed_p attributes as
58         well.
60 2010-02-13  Eli Zaretskii  <eliz@gnu.org>
62         * xdisp.c (set_cursor_from_row): Don't overwrite cursor position
63         if it is not a better candidate than what we already have.
64         (display_line): Keep calling set_cursor_from_row for
65         bidi-reordered rows even if we already have a possible candidate
66         for cursor position.  Undo the row_end setting throughout the
67         code, and instead do it after all the row's glyphs have been
68         produced, by looping over the glyphs.
70 2010-02-06  Eli Zaretskii  <eliz@gnu.org>
72         Start working on cursor movement in continuation lines.
73         * xdisp.c (move_it_in_display_line_to): New variables prev_method
74         and prev_pos.  Compare for strict equality in
75         BUFFER_POS_REACHED_P.
77 2010-01-30  Eli Zaretskii  <eliz@gnu.org>
79         Fix fallout from changes to managing glyph row reversed_p flag.
80         * xdisp.c (init_iterator): Initialize it->glyph_row->reversed_p
81         flag.
83 2010-01-25  Eli Zaretskii  <eliz@gnu.org>
85         Clean up the mess with setting the glyph row reversed_p flag.
86         * dispnew.c (prepare_desired_row): Preserve the reversed_p flag.
88         * bidi.c (bidi_cache_find): Use bidi_copy_it instead of copying
89         the whole struct (which includes uninitialized parts).
90         (bidi_init_it): Don't initialize bidi_it->paragraph_dir.
92         * xdisp.c (display_line): Remove misplaced setting of
93         row->reversed_p flags.  Copy the reversed_p flag to the next glyph
94         row.
95         (next_element_from_buffer): Check bidi_it.paragraph_dir rather
96         than level_stack[0].level.  Reset the reversed_p flag for non-R2L
97         paragraphs.
99         Fix display of invisible text.
100         * xdisp.c (handle_invisible_prop): If we are `reseat'ed, init the
101         paragraph direction and set the `reversed_p' flag in the IT's
102         glyph row.  Fix exit conditions of the loop that skips invisible
103         text.  Update IT->prev_stop after skipping invisible text.  Check
104         for additional overlays at IT->stop_charpos, not at start_pos.
106 2010-01-16  Eli Zaretskii  <eliz@gnu.org>
108         * xdisp.c (handle_invisible_prop): Under bidi iteration, skip
109         invisible text using bidi_get_next_char_visually.
110         (handle_stop_backwards): Restore it->bidi_p, it->current and
111         it->position before calling handle_stop.
112         (next_element_from_buffer): Fix formatting.
114 2010-01-09  Eli Zaretskii  <eliz@gnu.org>
116         * xdisp.c (handle_stop_backwards): Add a prototype.
117         (reseat): call handle_stop_backwards to recompute prev_stop and
118         base_level_stop for the new position.  Solves the crash when
119         scrolling backwards.
121 2010-01-02  Eli Zaretskii  <eliz@gnu.org>
123         * .gdbinit (pitx): Display some bidi information about the
124         iterator.
126         * dispextern.h (BIDI_AT_BASE_LEVEL): Enclose definition in
127         parentheses.
129         * xdisp.c (handle_stop_backwards): Save and restore it->current
130         and it->position, instead of expecting the caller to do that.
131         (next_element_from_buffer): When moving across stop_charpos,
132         record it in prev_stop.  When IT_CHARPOS backs up, call
133         handle_stop_backwards only if above the base embedding level.
134         This solves the crash while displaying etc/HELLO in bidi mode.
136 2009-12-26  Eli Zaretskii  <eliz@gnu.org>
138         * xdisp.c (handle_stop_backwards): Call compute_stop_pos in the
139         loop, instead of calling handle_stop.  Call handle_stop only once,
140         after the loop.
141         (next_element_from_buffer): Don't call handle_stop_backwards if at
142         stop position.  If base_level_stop is zero, set it to 1.
144         * term.c (append_glyph): Fill resolved_level and bidi_type slots
145         of struct glyph for unidirectional display.
147         * xdisp.c (set_cursor_from_row): Handle zero-width characters.
149         * bidi.c (bidi_mirror_char): More efficient code (suggested by
150         Ehud Karni <ehud@unix.mvs.co.il>).  Don't even try to mirror
151         non-ASCII characters.
153 2009-12-19  Eli Zaretskii  <eliz@gnu.org>
155         * buffer.c (Fbuffer_swap_text): Swap the values of
156         bidi_display_reordering and bidi_paragraph_direction.
158         * bidi.c (bidi_resolve_weak): Fix nesting of conditions for Wn
159         processing.  Move W3 after W1 and W2.  Simplify W4 because it is
160         now always after W1.
162         * .gdbinit (pbiditype): New command.
163         (pgx): Use it to display bidi level and type of the glyph.
165 2009-12-12  Eli Zaretskii  <eliz@gnu.org>
167         * dispextern.h (struct it): New members prev_stop and
168         base_level_stop.
170         * xdisp.c (handle_stop_backwards): New function.
171         (next_element_from_buffer): Handle the situation where we
172         overstepped stop_charpos due to non-linearity of the bidi
173         iteration.  Likewise for when we back up beyond the previous
174         stop_charpos.
175         (reseat_1, pop_it, push_it): Set prev_stop and base_level_stop.
177         * dispextern.h (BIDI_AT_BASE_LEVEL): New macro.
179         * bidi.c (bidi_copy_it): Fix compiler warning due to cast of a
180         pointer to `int'.  Don't preserve the first_elt member, as it is
181         no longer copied, because its position in the structure was
182         changed, see below.
184         * dispextern.h (struct bidi_it): Move first_elt, new_paragraph,
185         separator_limit, and paragraph_dir to after bidi_stack.  Add a
186         note that anything beyond the level stack is not preserved when
187         the bidi iterator state is copied/saved.
189 2009-11-21  Eli Zaretskii  <eliz@gnu.org>
191         * xdisp.c (set_cursor_from_row): Fix cursor positioning on empty
192         lines when integer values of `cursor' property is used on display
193         strings.
195 2009-11-14  Eli Zaretskii  <eliz@gnu.org>
197         * xdisp.c (init_iterator, text_outside_line_unchanged_p)
198         (try_window_id): Rename paragraph_direction to
199         bidi_paragraph_direction.
200         (set_cursor_from_row): Handle integer values of `cursor' property
201         on display strings.
203         * buffer.c (init_buffer_once, syms_of_buffer): Rename
204         paragraph_direction to bidi_paragraph_direction.
206         * buffer.h (struct buffer): Rename paragraph_direction to
207         bidi_paragraph_direction.
209 2009-11-07  Eli Zaretskii  <eliz@gnu.org>
211         * bidi.c (bidi_paragraph_init): Don't overstep end of buffer.
212         Treat end of buffer as a NEUTRAL_B character.
213         (bidi_resolve_explicit): Don't special-case ZV when bidi_it->type
214         is NEUTRAL_B, since bidi_set_paragraph_end no longer sets the
215         new_paragraph flag.
217 2009-10-31  Eli Zaretskii  <eliz@gnu.org>
219         * xdisp.c (display_line): Always extend reversed_p rows to the end
220         of line.
221         (set_cursor_from_row): In R2L rows that don't display text, put
222         the cursor on the rightmost glyph.
224 2009-10-24  Eli Zaretskii  <eliz@gnu.org>
226         * xdisp.c (set_cursor_from_row): Fix off-by-one error when
227         skipping over non-character glyphs at end of a reversed row.
229         * dispextern.h (struct glyph): The `resolved_level' member needs
230         only 5 bits, not 6.  The `bidi_type' member needs only 3 bits.
231         (bidi_type_t): Rearrange so that types that can appear in the
232         resolved type are at the beginning and have values less than 8.
234 2009-10-23  Eli Zaretskii  <eliz@gnu.org>
236         * bidi.c: Include setjmp.h.
238 2009-10-17  Eli Zaretskii  <eliz@gnu.org>
240         * dispextern.h (struct glyph): New members resolved_level and
241         bidi_type.
243         * xdisp.c (append_glyph, append_composite_glyph)
244         (produce_image_glyph, append_stretch_glyph): Set them.
246         * term.c (append_glyph): Ditto.
248         * xdisp.c (display_line, next_element_from_buffer): Set the glyph
249         row's reversed_p flag if the paragraph base direction is odd.
250         (extend_face_to_end_of_line): Don't reverse the glyphs here.
252         * term.c (append_glyph): Reverse glyphs here.
254         * bidi.c (bidi_get_next_char_visually): Don't exit early when at
255         ZV.
256         (bidi_paragraph_init): Don't step over a newline if at BEGV.
258 2009-10-16  Eli Zaretskii  <eliz@gnu.org>
260         * bidi.c (bidi_paragraph_init): Handle empty buffers.
262 2009-10-10  Eli Zaretskii  <eliz@gnu.org>
264         * xdisp.c (set_cursor_from_row): Skip over glyphs near end of row
265         with integer OBJECT even if their CHARPOS is zero.
267         * bidi.c (bidi_cache_iterator_state): Don't cache NEW_PARAGRAPH.
268         Abort if someone tries to add a cached state whose position is not
269         the immediate successor to that of the last cached state.
270         (bidi_paragraph_init): Don't bail out too early after a reseat.
272 2009-10-09  Eli Zaretskii  <eliz@gnu.org>
274         * xdisp.c (text_outside_line_unchanged_p, try_window_id): Disable
275         optimizations if we are reordering bidirectional text and the
276         paragraph direction can be affected by the change.
278 2009-10-08  Eli Zaretskii  <eliz@gnu.org>
280         * xdisp.c (string_buffer_position_lim): New function.
281         (string_buffer_position): Most of code moved to
282         string_buffer_position_lim.  Last argument and return value are
283         now EMACS_INT; all callers changed.
284         (set_cursor_from_row): Rewritten to support bidirectional text and
285         reversed glyph rows.
287         dispextern.h <string_buffer_position>: Update prototype.
289 2009-10-07  Eli Zaretskii  <eliz@gnu.org>
291         * bidi.c (bidi_paragraph_init): Fix initialization of POS.
293         * dispextern.h (struct glyph_row): New member reversed_p.
295 2009-10-06  Eli Zaretskii  <eliz@gnu.org>
297         * buffer.c (syms_of_buffer): Remove DEFVAR_LISP_NOPRO for
298         default-direction-reversed, default-bidi-display-reordering, and
299         default-paragraph-direction.
301 2009-10-05  Eli Zaretskii  <eliz@gnu.org>
303         * buffer.h (struct buffer): New member paragraph_direction.
304         * buffer.c (init_buffer_once): Initialize it.
305         (syms_of_buffer): Declare Lisp variables
306         default-paragraph-direction and paragraph-direction.
308         * dispextern.h (struct it): New member paragraph_embedding.
309         * xdisp.c (init_iterator): Initialize it from the buffer's value
310         of paragraph-direction.
311         <Qright_to_left, Qleft_to_right>: New variables.
312         (syms_of_xdisp): Initialize and staticpro them.
313         (set_iterator_to_next, next_element_from_buffer): Use the value of
314         paragraph_embedding to determine the paragraph direction.
316         * bidi.c (bidi_line_init): Fix second argument to
317         bidi_set_sor_type.
318         (bidi_init_it): Initialize paragraph_dir to NEUTRAL_DIR.
319         (bidi_get_next_char_visually): Record the last character of the
320         separator in separator_limit, not the character after that.
321         (bidi_find_paragraph_start): Accept character and byte positions
322         instead of the whole iterator stricture.  All callers changed.
324 2009-10-04  Eli Zaretskii  <eliz@gnu.org>
326         * bidi.c (bidi_at_paragraph_end): Check for paragraph-start if
327         paragraph-separate failed to match.  Return the length of the
328         matched separator.
329         (bidi_line_init): New function.
330         (bidi_paragraph_init): Use bidi_line_init.  Do nothing if in the
331         middle of a paragraph-separate sequence.  Don't override existing
332         paragraph direction if no strong characters found in this
333         paragraph.  Set separator_limit according to what
334         bidi_at_paragraph_end returns.  Reset new_paragraph flag when a
335         new paragraph is found.
336         (bidi_init_it): Reset separator_limit.
338         * dispextern.h (struct bidi_it): New member separator_limit.
340         * bidi.c (bidi_find_paragraph_start): Return the byte position of
341         the paragraph beginning.
343         * xdisp.c (set_iterator_to_next): Call bidi_paragraph_init if the
344         new_paragraph flag is set in the bidi iterator.
346         * bidi.c (bidi_at_paragraph_end, bidi_find_paragraph_start): Use
347         the buffer-local value of paragraph-start and paragraph-separate.
349 2009-10-03  Eli Zaretskii  <eliz@gnu.org>
351         * bidi.c (bidi_set_paragraph_end): Don't set the new_paragraph
352         flag in the iterator.
353         (bidi_init_it): Set the new_paragraph flag.
354         (bidi_at_paragraph_end): Arguments are now character and byte
355         position of the next character.  All callers changed.
356         (bidi_resolve_explicit): Don't call bidi_at_paragraph_end, and
357         don't behave as if at paragraph end if it returns true.
358         (bidi_get_next_char_visually): Don't call bidi_paragraph_init if
359         new_paragraph flags is set.  Set new_paragraph flag when at end of
360         a paragraph.
361         <fallback_paragraph_start_re, fallback_paragraph_separate_re>: New
362         variables.
363         <Qparagraph_start, Qparagraph_separate>: New variables.
364         (bidi_initialize): Initialize and staticpro them.
366         * dispextern.h <struct bidi_it>: New element paragraph_dir.  Make
367         positional elements EMACS_INT.
369         * bidi.c <bidi_overriding_paragraph_direction>: Delete.
371 2009-09-28  Eli Zaretskii  <eliz@gnu.org>
373         * bidi.c (bidi_init_it): Initialize charpos, bytepos, and
374         first_elt before calling bidi_set_paragraph_end.
375         (bidi_resolve_explicit): Don't call bidi_set_paragraph_end at
376         EOB.
377         (bidi_at_paragraph_end): Don't set new_paragraph flag at EOB.
378         (bidi_get_type): Accept an additional argument OVERRIDE, per UAX#9
379         "Explicit Overrides".  All callers changed.
381 2009-09-27  Eli Zaretskii  <eliz@gnu.org>
383         * xdisp.c (next_element_from_buffer): If called not at line
384         beginning, start bidi iteration from line beginning.
386         * bidi.c (bidi_paragraph_init): Use
387         bidi_overriding_paragraph_direction instead of a literal zero.
388         (bidi_initialize): Fix some character types, per Unicode 5.x.
389         (bidi_get_type): Abort if called with invalid character code.
391         * dispextern.h: Add prototype of bidi_mirror_char.
393         * xdisp.c (get_next_display_element): Mirror characters whose
394         resolved type is STRONG_R.
396 2009-09-26  Eli Zaretskii  <eliz@gnu.org>
398         * bidi.c (bidi_paragraph_init): Don't set bidi_it->ch_len.  Abort
399         if called not at beginning of a new paragraph.
400         (bidi_get_next_char_visually): Prepare and use a sentinel iterator
401         state when first_elt flag is set.
403         * dispextern.h (struct bidi_it): New struct member first_elt.
405         * bidi.c (bidi_init_it): Initialize bidi_it->first_elt.
406         (bidi_copy_it): Don't copy the first_elt flag.
408         * xdisp.c (reseat_1): Initialize bidi_it.first_elt.  Move bidi
409         scan start code from here...
410         (next_element_from_buffer): ...to here.  Use bidi_it.first_elt
411         flag.
413 2009-09-20  Eli Zaretskii  <eliz@gnu.org>
415         * xdisp.c (reseat_1): Handle position < BEGV.
417         * bidi.c (bidi_paragraph_init): Set bidi_it->ch_len.  Handle ZV.
418         (bidi_init_it): Don't initialize bidi_it->ch_len.
419         (bidi_resolve_explicit_1): Abort if bidi_it->ch_len was not
420         initialized.
421         (bidi_at_paragraph_end, bidi_resolve_explicit_1)
422         (bidi_resolve_weak, bidi_level_of_next_char): Handle bytepos at
423         ZV_BYTE.
424         (bidi_resolve_explicit_1): Handle position < BEGV.
426 2009-09-19  Eli Zaretskii  <eliz@gnu.org>
428         * xdisp.c (init_iterator): Call bidi_init_it.  Set
429         bidi_it->bytepos if buffer position specified.
430         (reseat_1): Don't call bidi_init_it.  Call bidi_paragraph_init
431         instead.  Move back to preceding character before the call to
432         bidi_get_next_char_visually.
434         * bidi.c: Remove all STANDALONE parts.
435         (bidi_init_it): Init bidi_it->charpos and bidi_it->bytepos to -1.
436         Don't call bidi_paragraph_init.  Change arguments.
437         (bidi_paragraph_init): Remove code for negative pos.
439         * dispextern.h <bidi_it>: Rename orig_type to type_after_w1 and
440         pristine_type to orig_type.
442 2009-09-12  Eli Zaretskii  <eliz@gnu.org>
444         * dispnew.c (direct_output_for_insert): Give up if we are
445         reordering bidirectional text.
447         * dispextern.h (IT_STACK_SIZE): Enlarge to 5.
449         * xdisp.c (display_line): Set row->end and it->start for the next
450         row to the next character in logical order.  If we are reordering
451         bidi text, push and pop the iterator before and after momentarily
452         iterating in logical order.
454 2009-09-11  Eli Zaretskii  <eliz@gnu.org>
456         Note: The following changes were undone on 2009-09-12.
458         * xdisp.c (set_iterator_to_next, reseat, reseat_1)
459         (reseat_at_next_visible_line_start): Accept additional argument
460         force_logical_p; all callers changed.  If force_logical_p is
461         non-zero, force iteration in buffer's logical order even in bidi
462         buffers.
464         * dispnew.c (direct_output_for_insert): Call set_iterator_to_next
465         with additional argument zero.
467         * dispextern.h (set_iterator_to_next): Now accepts an additional
468         argument.
470 2009-08-29  Eli Zaretskii  <eliz@gnu.org>
472         * xdisp.c (set_cursor_from_row): Don't assume glyph->charpos
473         increments linearly.
474         (try_window_reusing_current_matrix): Don't assume glyph->charpos
475         increments linearly.
477 2009-08-28  Eli Zaretskii  <eliz@gnu.org>
479         * bidi.c <bidi_overriding_paragraph_direction>: Default to L2R,
480         for now.
482 2009-08-22  Eli Zaretskii  <eliz@gnu.org>
484         * bidi.c (bidi_initialize): staticpro bidi_char_table.
485         (bidi_check_type): New function.
486         (bidi_cache_iterator_state, bidi_remember_char)
487         (bidi_resolve_explicit_1, bidi_resolve_explicit)
488         (bidi_resolve_weak, bidi_resolve_neutral)
489         (bidi_level_of_next_char): Use it to validate the bidi type
490         assigned to the iterator.
492 2009-08-15  Eli Zaretskii  <eliz@gnu.org>
494         * bidi.c (bidi_initialize): Fix initialization of bidi_type_table.
496         * xdisp.c (set_iterator_to_next): Fix position setting after call
497         to bidi_get_next_char_visually.
499 2005-12-03  Eli Zaretskii  <eliz@gnu.org>
501         * bidi.c: Include stdio.h unconditionally.  Fix and elaborate
502         commentary.  Add Copyright blurb.
504 2004-03-08  Kenichi Handa  <handa@m17n.org>
506         * xdisp.c (reseat_1): Call bidi_init_it with a previous position.
508         * bidi.c (bidi_init_it): Set bidi_it->ch_len even if POS > 0.
510 2004-03-04  Kenichi Handa  <handa@m17n.org>
512         The following changes are to support bidirectional text display.
514         * Makefile.in (obj): Include bidi.o.
515         (bidi.o): New target.
517         * bidi.c: New file.
519         * buffer.h (struct buffer): New member bidi_display_reordering.
521         * buffer.c (init_buffer_once): Initialize bidi_display_reordering.
522         (syms_of_buffer): Declarations of Lisp variables
523         default-bidi-display-reordering and bidi-display-reordering.
525         * dispextern.h (BIDI_MAXLEVEL): New macro.
526         (bidi_type_t, bidi_dir_t): New types.
527         (bidi_saved_info, bidi_stack, bidi_it): New structs.
528         (struct it): New members bidi_p and bidi_it.
529         (bidi_init_it): Extern it.
530         (bidi_get_next_char_visually): Extern it.
532         * dispnew.c (direct_output_forward_char): Give up if we need bidi
533         processing or buffer's direction is right-to-left.
535         * xdisp.c (init_iterator): Initialize it->bidi_p.
536         (reseat_1): Cal bidi_init_it and bidi_get_next_char_visually if
537         necessary.
538         (set_iterator_to_next): Cal bidi_get_next_char_visually if
539         necessary.
542 ;; Local Variables:
543 ;; coding: utf-8
544 ;; add-log-time-zone-rule: t
545 ;; End:
547     Copyright (C) 2007, 2008, 2009  Free Software Foundation, Inc.
549   This file is part of GNU Emacs.
551   GNU Emacs is free software: you can redistribute it and/or modify
552   it under the terms of the GNU General Public License as published by
553   the Free Software Foundation, either version 3 of the License, or
554   (at your option) any later version.
556   GNU Emacs is distributed in the hope that it will be useful,
557   but WITHOUT ANY WARRANTY; without even the implied warranty of
558   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
559   GNU General Public License for more details.
561   You should have received a copy of the GNU General Public License
562   along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.