summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2010-11-13 15:29:31 +0200
committerEli Zaretskii <eliz@gnu.org>2010-11-13 15:29:31 +0200
commit0eb025fb55277c038c39e7325a556de46ecbd2e4 (patch)
tree677650021eae4915030d38baabe6c872eaa31845 /src
parent6e060cee8186d9fe5ad5f8a783d45f80f9b1bbe3 (diff)
downloademacs-0eb025fb55277c038c39e7325a556de46ecbd2e4.tar.gz
Fix and document display of glyphless characters.
src/xdisp.c (set_cursor_from_row): Fix cursor positioning on zero-width characters. (syms_of_xdisp) <glyphless-char-display>: Doc fix. src/.gdbinit (pgx): Adapt to latest changes in `struct glyph'. src/w32term.c (x_draw_glyphless_glyph_string_foreground): Draw the box before drawing the glyphs inside it. src/dispextern.h (enum glyphless_display_method): Rename GLYPHLESS_DISPLAY_HEXA_CODE to GLYPHLESS_DISPLAY_HEX_CODE. All users changed. src/term.c (append_glyphless_glyph, produce_glyphless_glyph): Fix comments. (produce_glyphless_glyph): Enclose "U+nnnn" and "empty box" whitespace in "[]", to simulate a box. Don't use uninitialized variable `width'. lisp/international/characters.el (glyphless-char-display-control): Renamed from glyphless-char-control; all users changed. Doc fix. Signal an error if display method is not one of the recognized symbols. doc/emacs/rmail.texi (Rmail Coding): Characters with no fonts are not necessarily displayed as empty boxes. doc/emacs/mule.texi (Language Environments, Fontsets): Characters with no fonts are not necessarily displayed as empty boxes. doc/emacs/display.texi (Text Display): Document display of glyphless characters. doc/lispref/display.texi (Usual Display): Characters with no fonts are not necessarily displayed as empty boxes. etc/NEWS: Document display of glyphless characters.
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit26
-rw-r--r--src/ChangeLog22
-rw-r--r--src/dispextern.h14
-rw-r--r--src/term.c33
-rw-r--r--src/w32term.c14
-rw-r--r--src/xdisp.c28
-rw-r--r--src/xterm.c2
7 files changed, 90 insertions, 49 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index b3bb6b58267..73fecea5972 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -494,14 +494,30 @@ define pgx
end
# COMPOSITE_GLYPH
if ($g->type == 1)
- printf "COMP[%d (%d..%d)]", $g->u.cmp.id, $g->u.cmp.from, $g->u.cmp.to
+ printf "COMP[%d (%d..%d)]", $g->u.cmp.id, $g->slice.cmp.from, $g->slice.cmp.to
end
- # IMAGE_GLYPH
+ # GLYPHLESS_GLYPH
if ($g->type == 2)
+ printf "GLYPHLESS["
+ if ($g->u.glyphless.method == 0)
+ printf "THIN]"
+ end
+ if ($g->u.glyphless.method == 1)
+ printf "EMPTY]"
+ end
+ if ($g->u.glyphless.method == 2)
+ printf "ACRO]"
+ end
+ if ($g->u.glyphless.method == 3)
+ printf "HEX]"
+ end
+ end
+ # IMAGE_GLYPH
+ if ($g->type == 3)
printf "IMAGE[%d]", $g->u.img_id
end
# STRETCH_GLYPH
- if ($g->type == 3)
+ if ($g->type == 4)
printf "STRETCH[%d+%d]", $g->u.stretch.height, $g->u.stretch.ascent
end
xgettype ($g->object)
@@ -544,8 +560,8 @@ define pgx
if ($g->right_box_line_p)
printf " ]"
end
- if ($g->slice.x || $g->slice.y || $g->slice.width || $g->slice.height)
- printf " slice=%d,%d,%d,%d" ,$g->slice.x, $g->slice.y, $g->slice.width, $g->slice.height
+ if ($g->slice.img.x || $g->slice.img.y || $g->slice.img.width || $g->slice.img.height)
+ printf " slice=%d,%d,%d,%d" ,$g->slice.img.x, $g->slice.img.y, $g->slice.img.width, $g->slice.img.height
end
printf "\n"
end
diff --git a/src/ChangeLog b/src/ChangeLog
index 13f90d12790..2bac819c0d5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,25 @@
+2010-11-13 Eli Zaretskii <eliz@gnu.org>
+
+ * xdisp.c (set_cursor_from_row): Fix cursor positioning on
+ zero-width characters.
+
+ * .gdbinit (pgx): Adapt to latest changes in `struct glyph'.
+
+ * w32term.c (x_draw_glyphless_glyph_string_foreground): Draw the
+ box before drawing the glyphs inside it.
+
+ * xdisp.c (syms_of_xdisp) <glyphless-char-display>: Doc fix.
+
+ * dispextern.h (enum glyphless_display_method): Rename
+ GLYPHLESS_DISPLAY_HEXA_CODE to GLYPHLESS_DISPLAY_HEX_CODE. All
+ users changed.
+
+ * term.c (append_glyphless_glyph, produce_glyphless_glyph): Fix
+ comments.
+ (produce_glyphless_glyph): Enclose "U+nnnn" and "empty box"
+ whitespace in "[]", to simulate a box. Don't use uninitialized
+ variable `width'.
+
2010-11-11 Julien Danjou <julien@danjou.info>
* xsettings.c (init_xsettings): Use already fetch atoms.
diff --git a/src/dispextern.h b/src/dispextern.h
index 30bd051b0ac..0786fff67cc 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -371,12 +371,11 @@ struct glyph
displaying. The member `pixel_width' above is set to 1. */
unsigned padding_p : 1;
- /* 1 means the actual glyph is not available, draw a box instead.
- This can happen when a font couldn't be loaded, or a character
- doesn't have a glyph in a font. */
+ /* 1 means the actual glyph is not available, draw using `struct
+ glyphless' below instead. This can happen when a font couldn't
+ be loaded, or a character doesn't have a glyph in a font. */
unsigned glyph_not_available_p : 1;
-
/* Non-zero means don't display cursor here. */
unsigned avoid_cursor_p : 1;
@@ -1997,14 +1996,15 @@ enum line_wrap_method
enum glyphless_display_method
{
- /* Display a thin (1-pixel width) space. */
+ /* Display a thin (1-pixel width) space. On a TTY, display a
+ 1-character width space. */
GLYPHLESS_DISPLAY_THIN_SPACE,
/* Display an empty box of proper width. */
GLYPHLESS_DISPLAY_EMPTY_BOX,
/* Display an acronym string in a box. */
GLYPHLESS_DISPLAY_ACRONYM,
- /* Display a hexadecimal character code in a box. */
- GLYPHLESS_DISPLAY_HEXA_CODE
+ /* Display the hexadecimal code of the character in a box. */
+ GLYPHLESS_DISPLAY_HEX_CODE
};
struct it_slice
diff --git a/src/term.c b/src/term.c
index dbbdc03f190..71df92822ac 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1850,9 +1850,9 @@ produce_composite_glyph (struct it *it)
/* Append a glyph for a glyphless character to IT->glyph_row. FACE_ID
- is a face ID to be used for the glyph. What actually appended are
- glyphs of type CHAR_GLYPH of which characters are in STR
- (it->nglyphs bytes). */
+ is a face ID to be used for the glyph. What is actually appended
+ are glyphs of type CHAR_GLYPH whose characters are in STR (which
+ comes from it->nglyphs bytes). */
static void
append_glyphless_glyph (struct it *it, int face_id, char *str)
@@ -1923,7 +1923,7 @@ extern Lisp_Object Qglyphless_char;
/* Produce glyphs for a glyphless character for iterator IT.
IT->glyphless_method specifies which method to use for displaying
the character. See the description of enum
- glyphless_display_method in dispextern.h for the detail.
+ glyphless_display_method in dispextern.h for the details.
FOR_NO_FONT is nonzero if and only if this is for a character that
is not supproted by the coding system of the terminal. ACRONYM, if
@@ -1935,11 +1935,11 @@ static void
produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
{
int face_id;
- int width, len;
- char buf[9], *str = " ";
+ int len;
+ char buf[11], *str = " ";
/* Get a face ID for the glyph by utilizing a cache (the same way as
- doen for `escape-glyph' in get_next_display_element). */
+ done for `escape-glyph' in get_next_display_element). */
if (it->f == last_glyphless_glyph_frame
&& it->face_id == last_glyphless_glyph_face_id)
{
@@ -1956,8 +1956,8 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE)
{
- /* As there's no way to produce a thin space, we produce
- a space of canonical width.. */
+ /* As there's no way to produce a thin space, we produce a space
+ of canonical width. */
len = 1;
}
else if (it->glyphless_method == GLYPHLESS_DISPLAY_EMPTY_BOX)
@@ -1965,8 +1965,11 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
len = CHAR_WIDTH (it->c);
if (len == 0)
len = 1;
- else if (width > 4)
+ else if (len > 4)
len = 4;
+ sprintf (buf, "[%.*s]", len, str);
+ len += 2;
+ str = buf;
}
else
{
@@ -1983,11 +1986,11 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
}
else
{
- xassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEXA_CODE);
- len = (it->c < 0x100 ? sprintf (buf, "U+%02X", it->c)
- : it->c < 0x10000 ? sprintf (buf, "U+%04X", it->c)
- : it->c <= MAX_UNICODE_CHAR ? sprintf (buf, "U+%06X", it->c)
- : sprintf (buf, "E+%06X", it->c));
+ xassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE);
+ len = (it->c < 0x100 ? sprintf (buf, "[U+%02X]", it->c)
+ : it->c < 0x10000 ? sprintf (buf, "[U+%04X]", it->c)
+ : it->c <= MAX_UNICODE_CHAR ? sprintf (buf, "[U+%06X]", it->c)
+ : sprintf (buf, "[E+%06X]", it->c));
}
str = buf;
}
diff --git a/src/w32term.c b/src/w32term.c
index a93bc064c39..33b60c568c0 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1440,7 +1440,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
str = (char *) SDATA (acronym);
}
}
- else if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEXA_CODE)
+ else if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEX_CODE)
{
sprintf ((char *) buf, "%0*X",
glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
@@ -1448,6 +1448,11 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
str = buf;
}
+ if (glyph->u.glyphless.method != GLYPHLESS_DISPLAY_THIN_SPACE)
+ w32_draw_rectangle (s->hdc, s->gc,
+ x, s->ybase - glyph->ascent,
+ glyph->pixel_width - 1,
+ glyph->ascent + glyph->descent - 1);
if (str)
{
struct font *font = s->font;
@@ -1456,7 +1461,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
HFONT old_font;
old_font = SelectObject (s->hdc, FONT_HANDLE (font));
- /* It is assured that all LEN characters in STR is ASCII. */
+ /* It is certain that all LEN characters in STR are ASCII. */
for (j = 0; j < len; j++)
{
code = font->driver->encode_char (font, str[j]);
@@ -1472,11 +1477,6 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
with_background);
SelectObject (s->hdc, old_font);
}
- if (glyph->u.glyphless.method != GLYPHLESS_DISPLAY_THIN_SPACE)
- w32_draw_rectangle (s->hdc, s->gc,
- x, s->ybase - glyph->ascent,
- glyph->pixel_width - 1,
- glyph->ascent + glyph->descent - 1);
x += glyph->pixel_width;
}
}
diff --git a/src/xdisp.c b/src/xdisp.c
index 928a37a2b50..21c89088383 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -971,7 +971,7 @@ Lisp_Object Vglyphless_char_display;
Lisp_Object Qglyphless_char_display;
/* Method symbols for Vglyphless_char_display. */
-static Lisp_Object Qhexa_code, Qempty_box, Qthin_space, Qzero_width;
+static Lisp_Object Qhex_code, Qempty_box, Qthin_space, Qzero_width;
/* Default pixel width of `thin-space' display method. */
#define THIN_SPACE_WIDTH 1
@@ -5813,8 +5813,8 @@ lookup_glyphless_char_display (int c, struct it *it)
it->glyphless_method = GLYPHLESS_DISPLAY_THIN_SPACE;
else if (EQ (glyphless_method, Qempty_box))
it->glyphless_method = GLYPHLESS_DISPLAY_EMPTY_BOX;
- else if (EQ (glyphless_method, Qhexa_code))
- it->glyphless_method = GLYPHLESS_DISPLAY_HEXA_CODE;
+ else if (EQ (glyphless_method, Qhex_code))
+ it->glyphless_method = GLYPHLESS_DISPLAY_HEX_CODE;
else if (STRINGP (glyphless_method))
it->glyphless_method = GLYPHLESS_DISPLAY_ACRONYM;
else
@@ -12871,10 +12871,10 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
|| (row->truncated_on_left_p && pt_old < bpos_min)
|| (row->truncated_on_right_p && pt_old > bpos_max)
/* Zero-width characters produce no glyphs. */
- || ((row->reversed_p
- ? glyph_after > glyphs_end
- : glyph_after < glyphs_end)
- && eabs (glyph_after - glyph_before) == 1))
+ || (!string_seen
+ && (row->reversed_p
+ ? glyph_after > glyphs_end
+ : glyph_after < glyphs_end)))
{
cursor = glyph_after;
x = -1;
@@ -22292,7 +22292,7 @@ calc_line_height_property (struct it *it, Lisp_Object val, struct font *font,
and only if this is for a character for which no font was found.
If the display method (it->glyphless_method) is
- GLYPHLESS_DISPLAY_ACRONYM or GLYPHLESS_DISPLAY_HEXA_CODE, LEN is a
+ GLYPHLESS_DISPLAY_ACRONYM or GLYPHLESS_DISPLAY_HEX_CODE, LEN is a
length of the acronym or the hexadecimal string, UPPER_XOFF and
UPPER_YOFF are pixel offsets for the upper part of the string,
LOWER_XOFF and LOWER_YOFF are for the lower part.
@@ -22441,7 +22441,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
}
else
{
- xassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEXA_CODE);
+ xassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE);
sprintf (buf, "%0*X", it->c < 0x10000 ? 4 : 6, it->c);
str = buf;
}
@@ -27057,7 +27057,7 @@ cursor shapes. */);
hourglass_shown_p = 0;
DEFSYM (Qglyphless_char, "glyphless-char");
- DEFSYM (Qhexa_code, "hexa-code");
+ DEFSYM (Qhex_code, "hex-code");
DEFSYM (Qempty_box, "empty-box");
DEFSYM (Qthin_space, "thin-space");
DEFSYM (Qzero_width, "zero-width");
@@ -27073,13 +27073,13 @@ cursor shapes. */);
doc: /* Char-table to control displaying of glyphless characters.
Each element, if non-nil, is an ASCII acronym string (displayed in a box)
or one of these symbols:
- hexa-code: display with hexadecimal character code in a box
- empty-box: display with an empty box
- thin-space: display with 1-pixel width space
+ hex-code: display the hexadecimal code of a character in a box
+ empty-box: display as an empty box
+ thin-space: display as 1-pixel width space
zero-width: don't display
It has one extra slot to control the display of a character for which
-no font is found. The value of the slot is `hexa-code' or `empty-box'.
+no font is found. The value of the slot is `hex-code' or `empty-box'.
The default is `empty-box'. */);
Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil);
Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0),
diff --git a/src/xterm.c b/src/xterm.c
index e58d072e59f..f8b7b2a630c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1369,7 +1369,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
str = (char *) SDATA (acronym);
}
}
- else if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEXA_CODE)
+ else if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEX_CODE)
{
sprintf ((char *) buf, "%0*X",
glyph->u.glyphless.ch < 0x10000 ? 4 : 6,