else
{
CHECK_STRING (string);
- if (! STRING_MULTIBYTE (current_buffer->enable_multibyte_characters))
+ if (! STRING_MULTIBYTE (string))
error ("Attempt to shape unibyte text");
- CHECK_NATNUM (start);
+ /* FROM and TO are checked by the caller. */
from = XINT (start);
- CHECK_NATNUM (end);
to = XINT (end);
if (from < 0 || from > to || to > SCHARS (string))
args_out_of_range_3 (string, start, end);
{
EMACS_INT start, end, c;
Lisp_Object prop, val;
+ /* This is from forward_to_next_line_start in xdisp.c. */
+ const int MAX_NEWLINE_DISTANCE = 500;
+ if (endpos > charpos + MAX_NEWLINE_DISTANCE)
+ endpos = charpos + MAX_NEWLINE_DISTANCE;
cmp_it->stop_pos = endpos;
+ cmp_it->id = -1;
+ cmp_it->ch = -2;
if (find_composition (charpos, endpos, &start, &end, &prop, string)
&& COMPOSITION_VALID_P (start, end, prop))
{
FETCH_STRING_CHAR_ADVANCE (c, string, charpos, bytepos);
else
FETCH_CHAR_ADVANCE (c, charpos, bytepos);
+ if (c == '\n')
+ {
+ cmp_it->ch = -2;
+ break;
+ }
val = CHAR_TABLE_REF (Vcomposition_function_table, c);
if (! NILP (val))
{
cmp_it->lookback = XFASTINT (AREF (elt, 1));
cmp_it->stop_pos = charpos - 1 - cmp_it->lookback;
cmp_it->ch = c;
- break;
+ return;
}
}
}
+ cmp_it->stop_pos = charpos;
}
/* Check if the character at CHARPOS (and BYTEPOS) is composed
- (possibly with the following charaters) on window W. ENDPOS limits
+ (possibly with the following characters) on window W. ENDPOS limits
characters to be composed. FACE, in non-NULL, is a base face of
the character. If STRING is not nil, it is a string containing the
character to check, and CHARPOS and BYTEPOS are indices in the
struct face *face;
Lisp_Object string;
{
+ if (cmp_it->ch == -2)
+ {
+ composition_compute_stop_pos (cmp_it, charpos, bytepos, endpos, string);
+ if (cmp_it->ch == -2)
+ return 0;
+ }
+
if (cmp_it->ch < 0)
{
/* We are looking at a static composition. */
cmp_it->nchars = end - start;
cmp_it->nglyphs = composition_table[cmp_it->id]->glyph_len;
}
- else
+ else if (w)
{
Lisp_Object val, elt;
int i;
break;
cmp_it->nglyphs = i;
}
+ else
+ goto no_composition;
cmp_it->from = 0;
return 1;
/* Update the members of POSTION to the next character boundary. */
#define FORWARD_CHAR(POSITION, STOP) \
do { \
- if ((POSITION).pos == (STOP)) \
- (POSITION).p = GAP_END_ADDR; \
(POSITION).pos++; \
- (POSITION).pos_byte += BYTES_BY_CHAR_HEAD (*((POSITION).p)); \
- (POSITION).p += BYTES_BY_CHAR_HEAD (*((POSITION).p)); \
+ if ((POSITION).pos == (STOP)) \
+ { \
+ (POSITION).p = GAP_END_ADDR; \
+ (POSITION).pos_byte = GPT_BYTE; \
+ } \
+ else \
+ { \
+ (POSITION).pos_byte += BYTES_BY_CHAR_HEAD (*((POSITION).p)); \
+ (POSITION).p += BYTES_BY_CHAR_HEAD (*((POSITION).p)); \
+ } \
} while (0)
/* Update the members of POSTION to the previous character boundary. */
Lisp_Object check_val, val, elt;
int check_lookback;
int c;
+ Lisp_Object window;
struct window *w;
+ window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
+ if (NILP (window))
+ return 0;
+ w = XWINDOW (window);
+
orig.pos = pos;
if (NILP (string))
{
{
tail = min (tail, limit + 3);
}
- w = XWINDOW (selected_window);
cur = orig;
retry:
return PT;
/* Next check the automatic composition. */
- if (! find_automatic_composition (PT, -1, &beg, &end, &val, Qnil)
+ if (! find_automatic_composition (PT, (EMACS_INT) -1, &beg, &end, &val, Qnil)
|| beg == PT)
return PT;
for (i = 0; i < LGSTRING_GLYPH_LEN (val); i++)
DEFUN ("composition-get-gstring", Fcomposition_get_gstring,
Scomposition_get_gstring, 4, 4, 0,
doc: /* Return a glyph-string for characters between FROM and TO.
-If the glhph string is for graphic display, FONT-OBJECT must be
+If the glyph string is for graphic display, FONT-OBJECT must be
a font-object to use for those characters.
Otherwise (for terminal display), FONT-OBJECT must be nil.
If the optional 4th argument STRING is not nil, it is a string
containing the target characters between indices FROM and TO.
-A glhph-string is a vector containing information about how to display
-specific character sequence. The format is:
+A glyph-string is a vector containing information about how to display
+a specific character sequence. The format is:
[HEADER ID GLYPH ...]
HEADER is a vector of this form:
ID is an identification number of the glyph-string. It may be nil if
not yet shaped.
-GLYPH is a vector whose elements has this form:
+GLYPH is a vector whose elements have this form:
[ FROM-IDX TO-IDX C CODE WIDTH LBEARING RBEARING ASCENT DESCENT
[ [X-OFF Y-OFF WADJUST] | nil] ]
where
C is the character of the glyph.
CODE is the glyph-code of C in FONT-OBJECT.
WIDTH thru DESCENT are the metrics (in pixels) of the glyph.
- X-OFF and Y-OFF are offests to the base position for the glyph.
+ X-OFF and Y-OFF are offsets to the base position for the glyph.
WADJUST is the adjustment to the normal width of the glyph.
-If GLYPH is nil, the remaining elements of the glhph-string vector
-must be ignore. */)
+If GLYPH is nil, the remaining elements of the glyph-string vector
+should be ignored. */)
(from, to, font_object, string)
Lisp_Object font_object, from, to, string;
{
Lisp_Object gstring, header;
+ EMACS_INT frompos, topos;
+ CHECK_NATNUM (from);
+ CHECK_NATNUM (to);
if (! NILP (font_object))
CHECK_FONT_OBJECT (font_object);
header = fill_gstring_header (Qnil, from, to, font_object, string);
gstring = gstring_lookup_cache (header);
if (! NILP (gstring))
return gstring;
+
+ frompos = XINT (from);
+ topos = XINT (to);
+ if (LGSTRING_GLYPH_LEN (gstring_work) < topos - frompos)
+ gstring_work = Fmake_vector (make_number (topos - frompos + 2), Qnil);
LGSTRING_SET_HEADER (gstring_work, header);
LGSTRING_SET_ID (gstring_work, Qnil);
fill_gstring_body (gstring_work);
Compose text in the region between START and END.
Optional 3rd and 4th arguments are COMPONENTS and MODIFICATION-FUNC
-for the composition. See `compose-region' for more detail. */)
+for the composition. See `compose-region' for more details. */)
(start, end, components, modification_func)
Lisp_Object start, end, components, modification_func;
{
Compose text between indices START and END of STRING.
Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC
-for the composition. See `compose-string' for more detail. */)
+for the composition. See `compose-string' for more details. */)
(string, start, end, components, modification_func)
Lisp_Object string, start, end, components, modification_func;
{
doc: /* Internal use only.
Return information about composition at or nearest to position POS.
-See `find-composition' for more detail. */)
+See `find-composition' for more details. */)
(pos, limit, string, detail_p)
Lisp_Object pos, limit, string, detail_p;
{
DEFVAR_LISP ("compose-chars-after-function", &Vcompose_chars_after_function,
doc: /* Function to adjust composition of buffer text.
-The function is called with three arguments FROM, TO, and OBJECT.
-FROM and TO specify the range of text of which composition should be
+This function is called with three arguments: FROM, TO, and OBJECT.
+FROM and TO specify the range of text whose composition should be
adjusted. OBJECT, if non-nil, is a string that contains the text.
This function is called after a text with `composition' property is
DEFVAR_LISP ("auto-composition-function", &Vauto_composition_function,
doc: /* Function to call to compose characters automatically.
-The function is called from the display routine with four arguments,
+This function is called from the display routine with four arguments:
FROM, TO, WINDOW, and STRING.
If STRING is nil, the function must compose characters in the region
Vauto_composition_function = Qnil;
DEFVAR_LISP ("composition-function-table", &Vcomposition_function_table,
- doc: /* Char-able of functions for automatic character composition.
+ doc: /* Char-table of functions for automatic character composition.
For each character that has to be composed automatically with
preceding and/or following characters, this char-table contains
a function to call to compose that character.
The element at index C in the table, if non-nil, is a list of
this form: ([PATTERN PREV-CHARS FUNC] ...)
-PATTERN is a regular expression with which C and the surrounding
+PATTERN is a regular expression which C and the surrounding
characters must match.
PREV-CHARS is a number of characters before C to check the
-matching with PATTERN. If it is 0, PATTERN must match with C and
-the following characters. If it is 1, PATTERN must match with a
+matching with PATTERN. If it is 0, PATTERN must match C and
+the following characters. If it is 1, PATTERN must match a
character before C and the following characters.
If PREV-CHARS is 0, PATTERN can be nil, which means that the
single character C should be composed.
FUNC is a function to return a glyph-string representing a
-composition of the characters matching with PATTERN. It is
+composition of the characters that match PATTERN. It is
called with one argument GSTRING.
GSTRING is a template of a glyph-string to return. It is already
filled with a proper header for the characters to compose, and
glyphs corresponding to those characters one by one. The
-function must return a new glyph-string of the same header as
+function must return a new glyph-string with the same header as
GSTRING, or modify GSTRING itself and return it.
See also the documentation of `auto-composition-mode'. */);