From: Kenichi Handa Date: Thu, 7 Sep 2000 02:35:08 +0000 (+0000) Subject: Include composite.h X-Git-Tag: emacs-pretest-21.0.90~1767 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3f62427c0c1a2357fa85dde79db5f6a15717858f;p=emacs.git Include composite.h (lisp_string_width): New function. (Fstring_width): Call lisp_string_width instead of strwidth. --- diff --git a/src/charset.c b/src/charset.c index 76dde15f7ab..329f7fd0221 100644 --- a/src/charset.c +++ b/src/charset.c @@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. */ #include "lisp.h" #include "buffer.h" #include "charset.h" +#include "composite.h" #include "coding.h" #include "disptab.h" @@ -1261,6 +1262,44 @@ strwidth (str, len) return width; } +int +lisp_string_width (str) + Lisp_Object str; +{ + int len = XSTRING (str)->size, len_byte = STRING_BYTES (XSTRING (str)); + int i = 0, i_byte; + int width = 0; + int start, end, start_byte; + Lisp_Object prop; + int cmp_id; + + while (i < len) + { + if (find_composition (i, len, &start, &end, &prop, str)) + { + start_byte = string_char_to_byte (str, start); + if (i < start) + { + i_byte = string_char_to_byte (str, i); + width += strwidth (XSTRING (str)->data + i_byte, + start_byte - i_byte); + } + cmp_id + = get_composition_id (start, start_byte, end - start, prop, str); + if (cmp_id >= 0) + width += composition_table[cmp_id]->width; + i = end; + } + else + { + i_byte = string_char_to_byte (str, i); + width += strwidth (XSTRING (str)->data + i_byte, len_byte - i_byte); + i = len; + } + } + return width; +} + DEFUN ("string-width", Fstring_width, Sstring_width, 1, 1, 0, "Return width of STRING when displayed in the current buffer.\n\ Width is measured by how many columns it occupies on the screen.\n\ @@ -1274,8 +1313,7 @@ taken to occupy `tab-width' columns.") Lisp_Object val; CHECK_STRING (str, 0); - XSETFASTINT (val, strwidth (XSTRING (str)->data, - STRING_BYTES (XSTRING (str)))); + XSETFASTINT (val, lisp_string_width (str)); return val; }