emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug of display-table & make-glyph-code


From: Kenichi Handa
Subject: Re: bug of display-table & make-glyph-code
Date: Fri, 07 Sep 2007 21:25:41 +0900

In article <address@hidden>, Eli Zaretskii <address@hidden> writes:

> > From: Kenichi Handa <address@hidden>
> > Date: Fri, 07 Sep 2007 14:11:35 +0900
> > Cc: address@hidden, address@hidden, address@hidden, address@hidden,
> >     address@hidden
> > 
> > I started to study the glyph related codes, and ran into the
> > function create-glyph (disp-table.el).  It is a strange
> > function, and I don't understand how to utilize it.  Could
> > someone please explain it?

> I'm not sure what is there to explain, since the code looks quite
> self-explanatory, if read in together with the "Glyphs" node in the
> ELisp manual.  Perhaps I'm missing something; if the below doesn't
> help, please ask specific questions.

Thank you very much for the detailed explanation.  That is
exactly what I just understood from the code.

But, then, it seems that the design is broken (or got broken
because of introduction of multibyte characters).  It grows
glyph-table one by one.  So, at some point a glyph code is
simply a character code, but after several calls of
create-glyph, that same glyph code becomes an index into
glyph-table, and is displayed differently.  That means that
we can't reliably store a vector of non-ASCII characters (>=
U+100) in a slot of display-table.

In addition, the docstring of buffer-display-table says that
each element is a vector of characters (or nil).  It doesn't
say that contents of the vector is actually regarded as a
glyph code.

The Glyphs node of info says this:

----------------------------------------------------------------------
   A glyph is represented in Lisp as a "glyph code".  A glyph code can
be "simple" or it can be defined by the "glyph table".  A simple glyph
code is just a way of specifying a character and a face to output it
in.  *Note Faces::.

   The following functions are used to manipulate simple glyph codes:

 -- Function: make-glyph-code char &optional face
     This function returns a simple glyph code representing char CHAR
     with face FACE.
----------------------------------------------------------------------

But, for instance, the return value of (make-glyph-code 256)
is a simple glyph or not depending on the current length of
glyph-table.

---
Kenichi Handa
address@hidden

> `create-glyph' is used on a character terminal to create a glyph that
> is displayed instead of some character C.  The way you use it is like
> this:

>   (aset standard-display-table c
>       (vector (create-glyph (concat "\e(0" (char-to-string gc) "\e(B")))))

> This sets up the slot for C in standard-display-table to send to the
> terminal the string `(concat "\e(0" (char-to-string gc) "\e(B")))'
> (where GC is a code of some other character).

> standard-display-table needs an integer code of a glyph to put in the
> slot used to display C.  Therefore, `create-glyph' returns such an
> integer, which is an index into a glyph table.  In the glyph table,
> the first 256 slots are left unused, to avoid affecting the ASCII and
> unibyte non-ASCII ranges.  Starting from entry #256 (zero-based),
> `create-glyph' adds a new entry for its argument (which is a string to
> be sent to the terminal when a specific character is displayed), and
> stores that string argument in glyph-table.

> Thereafter, when character C is to be displayed, Emacs will look it up
> in standard-display-table and see that its slot has a glyph index.
> Emacs will then look up that index's slot in glyph-table, fetch the
> string stored at that slot, and send the string to the terminal.
> Presumably, the string uses character terminal escape sequences to
> produce the desired effect, such as underlining the character etc.

> Did I manage to answer your question?


> _______________________________________________
> Emacs-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]