Commit b7b65b15 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Retrospective commit.

These are the original changes made by Kenichi Handa on the old
pre Emacs 22 emacs-bidi branch.
parent 829f35a5
2005-12-03 Eli Zaretskii <eliz@gnu.org>
* bidi.c: Include stdio.h unconditionally. Fix and elaborate
commentary. Add Copyright blurb.
2004-03-08 Kenichi Handa <handa@m17n.org>
* xdisp.c (reseat_1): Call bidi_init_it with a previous position.
* bidi.c (bidi_init_it): Set bidi_it->ch_len even if POS > 0.
2004-03-04 Kenichi Handa <handa@m17n.org>
The following changes are to support bidirectional text display.
* Makefile.in (obj): Include bidi.o.
(bidi.o): New target.
* bidi.c: New file.
* buffer.h (struct buffer): New member bidi_display_reordering.
* buffer.c (init_buffer_once): Initialize bidi_display_reordering.
(syms_of_buffer): Declarations of Lisp variables
default-bidi-display-reordering and bidi-display-reordering.
* dispextern.h (BIDI_MAXLEVEL): New macro.
(bidi_type_t, bidi_dir_t): New types.
(bidi_saved_info, bidi_stack, bidi_it): New structs.
(struct it): New members bidi_p and bidi_it.
(bidi_init_it): Extern it.
(bidi_get_next_char_visually): Extern it.
* dispnew.c (direct_output_forward_char): Give up if we need bidi
processing or buffer's direction is right-to-left.
* xdisp.c (init_iterator): Initialize it->bidi_p.
(reseat_1): Cal bidi_init_it and bidi_get_next_char_visually if
necessary.
(set_iterator_to_next): Cal bidi_get_next_char_visually if
necessary.
;; Local Variables:
;; coding: utf-8
;; add-log-time-zone-rule: t
;; End:
Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
......@@ -560,6 +560,7 @@ FONT_DRIVERS = xfont.o
/* lastfile must follow all files
whose initialized data areas should be dumped as pure by dump-emacs. */
obj= dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
bidi.o \
charset.o coding.o category.o ccl.o character.o chartab.o \
cm.o term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \
emacs.o keyboard.o macros.o keymap.o sysdep.o \
......@@ -1052,6 +1053,7 @@ doc.o: buildobj.h
atimer.o: atimer.c atimer.h syssignal.h systime.h lisp.h blockinput.h \
$(config_h)
bidi.o: bidi.c buffer.h character.h
buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \
$(INTERVALS_H) blockinput.h atimer.h systime.h character.h \
indent.h keyboard.h coding.h keymap.h frame.h lisp.h $(config_h)
......
This diff is collapsed.
......@@ -5186,7 +5186,8 @@ init_buffer_once ()
buffer_defaults.truncate_lines = Qnil;
buffer_defaults.word_wrap = Qnil;
buffer_defaults.ctl_arrow = Qt;
buffer_defaults.direction_reversed = Qnil;
buffer_defaults.enable_bidi_display = Qnil;
buffer_defaults.orientation_reversed = Qnil;
buffer_defaults.cursor_type = Qt;
buffer_defaults.extra_line_spacing = Qnil;
buffer_defaults.cursor_in_non_selected_windows = Qt;
......@@ -5271,7 +5272,8 @@ init_buffer_once ()
XSETFASTINT (buffer_local_flags.syntax_table, idx); ++idx;
XSETFASTINT (buffer_local_flags.cache_long_line_scans, idx); ++idx;
XSETFASTINT (buffer_local_flags.category_table, idx); ++idx;
XSETFASTINT (buffer_local_flags.direction_reversed, idx); ++idx;
XSETFASTINT (buffer_local_flags.enable_bidi_display, idx); ++idx;
XSETFASTINT (buffer_local_flags.orientation_reversed, idx); ++idx;
XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx);
/* Make this one a permanent local. */
buffer_permanent_local_flags[idx++] = 1;
......@@ -5528,10 +5530,15 @@ This is the same as (default-value 'abbrev-mode). */);
doc: /* Default value of `ctl-arrow' for buffers that do not override it.
This is the same as (default-value 'ctl-arrow). */);
DEFVAR_LISP_NOPRO ("default-direction-reversed",
&buffer_defaults.direction_reversed,
doc: /* Default value of `direction-reversed' for buffers that do not override it.
This is the same as (default-value 'direction-reversed). */);
DEFVAR_LISP_NOPRO ("default-enable-bidi-display",
&buffer_defaults.enable_bidi_display,
doc: /* *Default value of `enable-bidi-display' for buffers not overriding it.
This is the same as (default-value 'enable-bidi-display). */);
DEFVAR_LISP_NOPRO ("default-orientation-reversed",
&buffer_defaults.orientation_reversed,
doc: /* *Default value of `orientation-reversed' for buffers that do not override it.
This is the same as (default-value 'orientation-reversed). */);
DEFVAR_LISP_NOPRO ("default-enable-multibyte-characters",
&buffer_defaults.enable_multibyte_characters,
......@@ -5789,11 +5796,17 @@ The variable `coding-system-for-write', if non-nil, overrides this variable.
This variable is never applied to a way of decoding a file while reading it. */);
DEFVAR_PER_BUFFER ("direction-reversed", &current_buffer->direction_reversed,
Qnil,
doc: /* *Non-nil means lines in the buffer are displayed right to left. */);
DEFVAR_PER_BUFFER ("orientation-reversed",
&current_buffer->orientation_reversed, Qnil,
doc: /* Non-nil means set beginning of lines at the right end of the window.
See also the variable `enable-bidi-display'. */);
DEFVAR_PER_BUFFER ("enable-bidi-display",
&current_buffer->enable_bidi_display, Qnil,
doc: /*Non-nil means display bidi text in correct visual order.
See also the variable `orientation-reversed'. */);
DEFVAR_PER_BUFFER ("truncate-lines", &current_buffer->truncate_lines, Qnil,
DEFVAR_PER_BUFFER ("truncate-lines", &current_buffer->truncate_lines, Qnil,
doc: /* *Non-nil means do not display continuation lines.
Instead, give each line of text just one screen line.
......
......@@ -658,8 +658,10 @@ struct buffer
Lisp_Object word_wrap;
/* Non-nil means display ctl chars with uparrow. */
Lisp_Object ctl_arrow;
/* Non-nil means display text from right to left. */
Lisp_Object direction_reversed;
/* Non-nil means display bidi text in correct visual order. */
Lisp_Object enable_bidi_display;
/* Non-nil means set beginning of lines at the right end of windows. */
Lisp_Object orientation_reversed;
/* Non-nil means do selective display;
see doc string in syms_of_buffer (buffer.c) for details. */
Lisp_Object selective_display;
......
......@@ -1702,6 +1702,79 @@ struct face_cache
extern int face_change_count;
/* For BIDI */
#define BIDI_MAXLEVEL 64
/* Data type for describing the bidirectional character types. */
typedef enum {
UNKNOWN_BT,
STRONG_L, /* strong left-to-right */
STRONG_R, /* strong right-to-left */
STRONG_AL, /* arabic right-to-left letter */
LRE, /* left-to-right embedding */
LRO, /* left-to-right override */
RLE, /* right-to-left embedding */
RLO, /* right-to-left override */
PDF, /* pop directional format */
WEAK_EN, /* european number */
WEAK_ES, /* european number separator */
WEAK_ET, /* european number terminator */
WEAK_AN, /* arabic number */
WEAK_CS, /* common separator */
WEAK_NSM, /* non-spacing mark */
WEAK_BN, /* boundary neutral */
NEUTRAL_B, /* paragraph separator */
NEUTRAL_S, /* segment separator */
NEUTRAL_WS, /* whitespace */
NEUTRAL_ON /* other neutrals */
} bidi_type_t;
/* The basic directionality data type. */
typedef enum { NEUTRAL_DIR, L2R, R2L } bidi_dir_t;
/* Data type for storing information about characters we need to
remember. */
struct bidi_saved_info {
int bytepos, charpos; /* character's buffer position */
bidi_type_t type; /* character bidi type */
bidi_type_t orig_type; /* original type of the character, after W1 */
bidi_type_t pristine_type; /* type as we found it in the buffer */
};
/* Data type for keeping track of saved embedding levels and override
status information. */
struct bidi_stack {
int level;
bidi_dir_t override;
};
/* Data type for iterating over bidi text. */
struct bidi_it {
int bytepos; /* iterator's position in buffer */
int charpos;
int ch; /* the character itself */
int ch_len; /* the length of its multibyte sequence */
bidi_type_t type; /* type of this character */
bidi_type_t orig_type; /* original type, after overrides and W1 */
bidi_type_t pristine_type; /* original type, as found in the buffer */
int resolved_level; /* final resolved level of this character */
int invalid_levels; /* how many PDFs should we ignore */
int invalid_rl_levels; /* how many PDFs from RLE/RLO should ignore */
int new_paragraph; /* if non-zero, a new paragraph begins here */
int prev_was_pdf; /* if non-zero, prev char was PDF */
struct bidi_saved_info prev; /* info about the previous character */
struct bidi_saved_info last_strong; /* last-seen strong directional char */
struct bidi_saved_info next_for_neutral; /* surrounding characters for... */
struct bidi_saved_info prev_for_neutral; /* ...resolving neutrals */
struct bidi_saved_info next_for_ws; /* character after sequence of ws */
int next_en_pos; /* position of next EN char for ET */
int ignore_bn_limit; /* position until which we should ignore BNs */
bidi_dir_t sor; /* direction of start-of-run in effect */
int scan_dir; /* direction of text scan */
int stack_idx; /* index of current data on the stack */
struct bidi_stack level_stack[BIDI_MAXLEVEL]; /* stack of embedding levels */
};
......@@ -2233,6 +2306,12 @@ struct it
/* Face of the right fringe glyph. */
unsigned right_user_fringe_face_id : FACE_ID_BITS;
/* 1 means we need bidi processing. */
int bidi_p;
/* For iterating over bidi text. */
struct bidi_it bidi_it;
};
......@@ -2704,6 +2783,12 @@ extern EMACS_INT tool_bar_button_relief;
Function Prototypes
***********************************************************************/
/* Defined in bidi.c */
extern void bidi_init_it P_ ((int pos, bidi_dir_t dir,
struct bidi_it *bidi_it));
extern void bidi_get_next_char_visually P_ ((struct bidi_it *bidi_it));
/* Defined in xdisp.c */
struct glyph_row *row_containing_pos P_ ((struct window *, int,
......
......@@ -3776,8 +3776,12 @@ direct_output_forward_char (n)
if (!display_completed || cursor_in_echo_area)
return 0;
/* Give up if the buffer's direction is reversed. */
if (!NILP (XBUFFER (w->buffer)->direction_reversed))
/* Give up if we need bidi display. */
if (!NILP (XBUFFER (w->buffer)->enable_bidi_display))
return 0;
/* Give up if the buffer's orientation is reversed. */
if (!NILP (XBUFFER (w->buffer)->orientation_reversed))
return 0;
/* Can't use direct output if highlighting a region. */
......
......@@ -2658,6 +2658,9 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id)
/* Are multibyte characters enabled in current_buffer? */
it->multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
/* Do we need multibyte processing? */
it->bidi_p = !NILP (current_buffer->enable_bidi_display);
/* Non-zero if we should highlight the region. */
highlight_region_p
= (!NILP (Vtransient_mark_mode)
......@@ -5515,6 +5518,16 @@ reseat_1 (it, pos, set_stop_p)
it->string_from_display_prop_p = 0;
it->face_before_selective_p = 0;
if (it->bidi_p)
{
bidi_init_it (pos.charpos - 1, L2R, &it->bidi_it);
bidi_get_next_char_visually (&it->bidi_it);
pos.charpos = it->bidi_it.charpos;
pos.bytepos = it->bidi_it.bytepos;
it->current.pos = it->position = pos;
}
if (set_stop_p)
it->stop_charpos = CHARPOS (pos);
}
......@@ -6078,8 +6091,18 @@ set_iterator_to_next (it, reseat_p)
else
{
xassert (it->len != 0);
IT_BYTEPOS (*it) += it->len;
IT_CHARPOS (*it) += 1;
if (! it->bidi_p)
{
IT_BYTEPOS (*it) += it->len;
IT_CHARPOS (*it) += 1;
}
else
{
bidi_get_next_char_visually (&it->bidi_it);
IT_BYTEPOS (*it) = it->bidi_it.charpos;
IT_CHARPOS (*it) = it->bidi_it.bytepos;
}
xassert (IT_BYTEPOS (*it) == CHAR_TO_BYTE (IT_CHARPOS (*it)));
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment