aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2000-09-07 02:35:08 +0000
committerKenichi Handa2000-09-07 02:35:08 +0000
commit3f62427c0c1a2357fa85dde79db5f6a15717858f (patch)
tree8c1a4647b2212a10645c542f710df0e9652c8072 /src
parentd69864bf3ee0b990101fee34f3dc857cf3f13ea4 (diff)
downloademacs-3f62427c0c1a2357fa85dde79db5f6a15717858f.tar.gz
emacs-3f62427c0c1a2357fa85dde79db5f6a15717858f.zip
Include composite.h
(lisp_string_width): New function. (Fstring_width): Call lisp_string_width instead of strwidth.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c42
1 files changed, 40 insertions, 2 deletions
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. */
34#include "lisp.h" 34#include "lisp.h"
35#include "buffer.h" 35#include "buffer.h"
36#include "charset.h" 36#include "charset.h"
37#include "composite.h"
37#include "coding.h" 38#include "coding.h"
38#include "disptab.h" 39#include "disptab.h"
39 40
@@ -1261,6 +1262,44 @@ strwidth (str, len)
1261 return width; 1262 return width;
1262} 1263}
1263 1264
1265int
1266lisp_string_width (str)
1267 Lisp_Object str;
1268{
1269 int len = XSTRING (str)->size, len_byte = STRING_BYTES (XSTRING (str));
1270 int i = 0, i_byte;
1271 int width = 0;
1272 int start, end, start_byte;
1273 Lisp_Object prop;
1274 int cmp_id;
1275
1276 while (i < len)
1277 {
1278 if (find_composition (i, len, &start, &end, &prop, str))
1279 {
1280 start_byte = string_char_to_byte (str, start);
1281 if (i < start)
1282 {
1283 i_byte = string_char_to_byte (str, i);
1284 width += strwidth (XSTRING (str)->data + i_byte,
1285 start_byte - i_byte);
1286 }
1287 cmp_id
1288 = get_composition_id (start, start_byte, end - start, prop, str);
1289 if (cmp_id >= 0)
1290 width += composition_table[cmp_id]->width;
1291 i = end;
1292 }
1293 else
1294 {
1295 i_byte = string_char_to_byte (str, i);
1296 width += strwidth (XSTRING (str)->data + i_byte, len_byte - i_byte);
1297 i = len;
1298 }
1299 }
1300 return width;
1301}
1302
1264DEFUN ("string-width", Fstring_width, Sstring_width, 1, 1, 0, 1303DEFUN ("string-width", Fstring_width, Sstring_width, 1, 1, 0,
1265 "Return width of STRING when displayed in the current buffer.\n\ 1304 "Return width of STRING when displayed in the current buffer.\n\
1266Width is measured by how many columns it occupies on the screen.\n\ 1305Width is measured by how many columns it occupies on the screen.\n\
@@ -1274,8 +1313,7 @@ taken to occupy `tab-width' columns.")
1274 Lisp_Object val; 1313 Lisp_Object val;
1275 1314
1276 CHECK_STRING (str, 0); 1315 CHECK_STRING (str, 0);
1277 XSETFASTINT (val, strwidth (XSTRING (str)->data, 1316 XSETFASTINT (val, lisp_string_width (str));
1278 STRING_BYTES (XSTRING (str))));
1279 return val; 1317 return val;
1280} 1318}
1281 1319