/* Composite sequence support.
- Copyright (C) 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2001-2011 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H14PRO021
Copyright (C) 2003, 2006
COMPOSITION-ID. */
Lisp_Object composition_hash_table;
-/* Function to call to adjust composition. */
-Lisp_Object Vcompose_chars_after_function;
-
Lisp_Object Qauto_composed;
-Lisp_Object Vauto_composition_mode;
-Lisp_Object Vauto_composition_function;
Lisp_Object Qauto_composition_function;
-Lisp_Object Vcomposition_function_table;
-
/* Maximum number of characters to look back for
auto-compositions. */
#define MAX_AUTO_COMPOSITION_LOOKBACK 3
If the composition is invalid, return -1. */
int
-get_composition_id (int charpos, int bytepos, int nchars, Lisp_Object prop, Lisp_Object string)
+get_composition_id (EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT nchars,
+ Lisp_Object prop, Lisp_Object string)
{
Lisp_Object id, length, components, key, *key_contents;
int glyph_len;
int hash_index;
unsigned hash_code;
struct composition *cmp;
- int i, ch;
+ EMACS_INT i;
+ int ch;
/* PROP should be
Form-A: ((LENGTH . COMPONENTS) . MODIFICATION-FUNC)
&& VECTORP (AREF (components, 0)))
{
/* COMPONENTS is a glyph-string. */
- int len = ASIZE (key);
+ EMACS_UINT len = ASIZE (key);
for (i = 1; i < len; i++)
if (! VECTORP (AREF (key, i)))
}
else if (VECTORP (components) || CONSP (components))
{
- int len = XVECTOR (key)->size;
+ EMACS_UINT len = XVECTOR (key)->size;
/* The number of elements should be odd. */
if ((len % 2) == 0)
This doesn't check the validity of composition. */
int
-find_composition (int pos, int limit, EMACS_INT *start, EMACS_INT *end, Lisp_Object *prop, Lisp_Object object)
+find_composition (EMACS_INT pos, EMACS_INT limit,
+ EMACS_INT *start, EMACS_INT *end,
+ Lisp_Object *prop, Lisp_Object object)
{
Lisp_Object val;
FROM and TO with property PROP. */
static void
-run_composition_function (int from, int to, Lisp_Object prop)
+run_composition_function (EMACS_INT from, EMACS_INT to, Lisp_Object prop)
{
Lisp_Object func;
EMACS_INT start, end;
indices START and END in STRING. */
void
-compose_text (int start, int end, Lisp_Object components, Lisp_Object modification_func, Lisp_Object string)
+compose_text (EMACS_INT start, EMACS_INT end, Lisp_Object components,
+ Lisp_Object modification_func, Lisp_Object string)
{
Lisp_Object prop;
}
int
-composition_gstring_width (Lisp_Object gstring, int from, int to, struct font_metrics *metrics)
+composition_gstring_width (Lisp_Object gstring, EMACS_INT from, EMACS_INT to,
+ struct font_metrics *metrics)
{
Lisp_Object *glyph;
int width = 0;
EMACS_INT to;
EMACS_INT pt = PT, pt_byte = PT_BYTE;
Lisp_Object re, font_object, lgstring;
- int len;
+ EMACS_INT len;
record_unwind_save_match_data ();
re = AREF (rule, 0);
static Lisp_Object _work_val;
static int _work_char;
-/* 1 iff the character C is composable. */
+/* 1 iff the character C is composable. Characters of general
+ category Z? or C? are not composable except for ZWNJ and ZWJ. */
+
#define CHAR_COMPOSABLE_P(C) \
((C) == 0x200C || (C) == 0x200D \
|| (_work_val = CHAR_TABLE_REF (Vunicode_category_table, (C)), \
cmp_it->stop_pos = endpos = start;
cmp_it->ch = -1;
}
- if (NILP (string))
- {
- /* A composition never strides over PT. */
- if (PT > charpos)
- {
- if (PT < endpos)
- cmp_it->stop_pos = endpos = PT;
- }
- else if (PT < charpos && PT > endpos)
- {
- cmp_it->stop_pos = endpos = PT - 1;
- }
- }
if (NILP (current_buffer->enable_multibyte_characters)
|| NILP (Vauto_composition_mode))
return;
}
}
}
+ if (charpos == endpos)
+ {
+ /* We couldn't find a composition point before ENDPOS. But,
+ some character after ENDPOS may be composed with
+ characters before ENDPOS. So, we should stop at the safe
+ point. */
+ charpos = endpos - MAX_AUTO_COMPOSITION_LOOKBACK;
+ if (charpos < start)
+ charpos = start;
+ }
}
else if (charpos > endpos)
{
int
composition_reseat_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT endpos, struct window *w, struct face *face, Lisp_Object string)
{
- if (endpos <= charpos)
- {
- if (NILP (string))
- {
- if (endpos < 0)
- endpos = BEGV;
- if (endpos < PT && PT < charpos)
- endpos = PT;
- }
- else if (endpos < 0)
- endpos = 0;
- }
- else
- {
- if (NILP (string) && charpos < PT && PT < endpos)
- endpos = PT;
- }
+ if (endpos < 0)
+ endpos = NILP (string) ? BEGV : 0;
if (cmp_it->ch == -2)
{
elt = XCAR (val);
if (cmp_it->lookback > 0)
{
- cpos -= cmp_it->lookback;
+ cpos = charpos - cmp_it->lookback;
if (STRINGP (string))
bpos = string_char_to_byte (string, cpos);
else
/* automatic composition */
Lisp_Object gstring = composition_gstring_from_id (cmp_it->id);
Lisp_Object glyph;
- int from, to;
+ EMACS_INT from;
if (cmp_it->nglyphs == 0)
{
{
c = XINT (LGSTRING_CHAR (gstring, i));
cmp_it->nbytes += CHAR_BYTES (c);
- cmp_it->width = (LGLYPH_WIDTH (glyph) > 0
- ? CHAR_WIDTH (LGLYPH_CHAR (glyph)) : 0);
+ cmp_it->width += CHAR_WIDTH (c);
}
}
return c;
/* Return the adjusted point provided that point is moved from LAST_PT
to NEW_PT. */
-int
+EMACS_INT
composition_adjust_point (EMACS_INT last_pt, EMACS_INT new_pt)
{
EMACS_INT charpos, bytepos, startpos, beg, end, pos;
CHECK_NATNUM (from);
CHECK_NATNUM (to);
- if (XINT (to) > XINT (from) + MAX_COMPOSITION_COMPONENTS)
- to = make_number (XINT (from) + MAX_COMPOSITION_COMPONENTS);
if (! FONT_OBJECT_P (font_object))
{
struct coding_system *coding;
id = COMPOSITION_ID (prop);
else
{
- int start_byte = (NILP (string)
- ? CHAR_TO_BYTE (start)
- : string_char_to_byte (string, start));
+ EMACS_INT start_byte = (NILP (string)
+ ? CHAR_TO_BYTE (start)
+ : string_char_to_byte (string, start));
id = get_composition_id (start, start_byte, end - start, prop, string);
}
Vtext_property_default_nonsticky
= Fcons (Fcons (Qcomposition, Qt), Vtext_property_default_nonsticky);
- DEFVAR_LISP ("compose-chars-after-function", &Vcompose_chars_after_function,
+ DEFVAR_LISP ("compose-chars-after-function", Vcompose_chars_after_function,
doc: /* Function to adjust composition of buffer text.
This function is called with three arguments: FROM, TO, and OBJECT.
Qauto_composition_function = intern_c_string ("auto-composition-function");
staticpro (&Qauto_composition_function);
- DEFVAR_LISP ("auto-composition-mode", &Vauto_composition_mode,
+ DEFVAR_LISP ("auto-composition-mode", Vauto_composition_mode,
doc: /* Non-nil if Auto-Composition mode is enabled.
Use the command `auto-composition-mode' to change this variable. */);
Vauto_composition_mode = Qt;
- DEFVAR_LISP ("auto-composition-function", &Vauto_composition_function,
+ DEFVAR_LISP ("auto-composition-function", Vauto_composition_function,
doc: /* Function to call to compose characters automatically.
This function is called from the display routine with four arguments:
FROM, TO, WINDOW, and STRING.
string. */);
Vauto_composition_function = Qnil;
- DEFVAR_LISP ("composition-function-table", &Vcomposition_function_table,
+ DEFVAR_LISP ("composition-function-table", Vcomposition_function_table,
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
defsubr (&Scomposition_get_gstring);
}
-/* arch-tag: 79cefaf8-ca48-4eed-97e5-d5afb290d272
- (do not change this comment) */