unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
To: David Kastrup <dak@gnu.org>
Cc: Miles Bader <miles@gnu.org>, Drew Adams <drew.adams@oracle.com>,
	Emacs-Devel <emacs-devel@gnu.org>
Subject: Re: cannot understand Elisp manual node Glyphs
Date: Thu, 08 Feb 2007 11:39:18 +0100	[thread overview]
Message-ID: <m3d54l3pd5.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <864ppxhw0l.fsf@lola.quinscape.zz> (David Kastrup's message of "Thu\, 08 Feb 2007 09\:51\:54 +0100")

David Kastrup <dak@gnu.org> writes:

> Well, picking from the doc string, make-glyph-code would seem a
> suitable choice, too.

Good idea.

Here is a complete patch:

*** display.texi	02 Feb 2007 11:06:10 +0100	1.247
--- display.texi	08 Feb 2007 11:32:56 +0100	
***************
*** 5272,5280 ****
  
    A glyph code can be @dfn{simple} or it can be defined by the
  @dfn{glyph table}.  A simple glyph code is just a way of specifying a
! character and a face to output it in.  When a glyph code is simple,
! the code, mod 524288, is the character to output, and the code divided
! by 524288 specifies the face number (@pxref{Face Functions}) to use
  while outputting it.  (524288 is
  @ifnottex
  2**19.)
--- 5272,5298 ----
  
    A glyph code can be @dfn{simple} or it can be defined by the
  @dfn{glyph table}.  A simple glyph code is just a way of specifying a
! character and a face to output it in.  @xref{Faces}.
! 
!   The following functions are used to manipulate simple glyph codes:
! 
! @defun make-glyph-code char &optional face
! This function returns a simple glyph code representing char @var{char}
! with face @var{face}.
! @end defun
! 
! @defun glyph-char glyph
! This function returns the character of simple glyph code @var{glyph}.
! @end defun
! 
! @defun glyph-face glyph
! This function returns face of simple glyph code @var{glyph}, or
! @code{nil} if @var{glyph} has the default face (face-id 0).
! @end defun
! 
!   Internally, a simple glyph code is an integer @var{gc}, where @var{gc}
! modulo 524288 is the character to output, and @var{gc} divided
! by 524288 specifies the face-id (@pxref{Face Functions}) to use
  while outputting it.  (524288 is
  @ifnottex
  2**19.)
***************
*** 5282,5288 ****
  @tex
  $2^{19}$.)
  @end tex
- @xref{Faces}.
  
    On character terminals, you can set up a @dfn{glyph table} to define
  the meaning of glyph codes.
--- 5300,5305 ----


*** disp-table.el	21 Jan 2007 21:52:32 +0100	1.64
--- disp-table.el	08 Feb 2007 11:34:24 +0100	
***************
*** 172,178 ****
    (aset standard-display-table c
  	(vector
  	 (if window-system
! 	     (logior uc (lsh (face-id 'underline) 19))
  	   (create-glyph (concat "\e[4m" (char-to-string uc) "\e[m"))))))
  
  ;;;###autoload
--- 172,178 ----
    (aset standard-display-table c
  	(vector
  	 (if window-system
! 	     (make-glyph-code uc 'underline)
  	   (create-glyph (concat "\e[4m" (char-to-string uc) "\e[m"))))))
  
  ;;;###autoload
***************
*** 187,192 ****
--- 187,214 ----
    (1- (length glyph-table)))
  
  ;;;###autoload
+ (defun make-glyph-code (char &optional face)
+   "Return a glyph code representing char CHAR with face FACE."
+   (if face
+       (logior char (lsh (face-id face) 19))
+     char))
+ 
+ ;;;###autoload
+ (defun glyph-char (glyph)
+   "Return the character of glyph code GLYPH."
+   (logand glyph #x7ffff))
+ 
+ ;;;###autoload
+ (defun glyph-face (glyph)
+   "Return the face of glyph code GLYPH, or nil if glyph has default face."
+   (let ((face-id (lsh glyph -19)))
+     (and (> face-id 0)
+ 	 (car (delq nil (mapcar (lambda (face)
+ 				  (and (eq (get face 'face) face-id)
+ 				       face))
+ 				(face-list)))))))
+ 
+ ;;;###autoload
  (defun standard-display-european (arg)
    "Semi-obsolete way to toggle display of ISO 8859 European characters.
  
*** descr-text.el	21 Jan 2007 21:52:32 +0100	1.54
--- descr-text.el	08 Feb 2007 10:54:37 +0100	
***************
*** 528,538 ****
  		  (setq char (aref disp-vector i))
  		  (aset disp-vector i
  			(cons char (describe-char-display
! 				    pos (logand char #x7ffff)))))
  		(format "by display table entry [%s] (see below)"
  			(mapconcat
  			 #'(lambda (x)
! 			     (format "?%c" (logand (car x) #x7ffff)))
  			 disp-vector " ")))
  	       (composition
  		(let ((from (car composition))
--- 528,538 ----
  		  (setq char (aref disp-vector i))
  		  (aset disp-vector i
  			(cons char (describe-char-display
! 				    pos (glyph-char char)))))
  		(format "by display table entry [%s] (see below)"
  			(mapconcat
  			 #'(lambda (x)
! 			     (format "?%c" (glyph-char (car x))))
  			 disp-vector " ")))
  	       (composition
  		(let ((from (car composition))
***************
*** 627,651 ****
  	      (progn
  		(insert "these fonts (glyph codes):\n")
  		(dotimes (i (length disp-vector))
! 		  (insert (logand (car (aref disp-vector i)) #x7ffff) ?:
  			  (propertize " " 'display '(space :align-to 5))
  			  (if (cdr (aref disp-vector i))
  			      (format "%s (#x%02X)" (cadr (aref disp-vector i))
  				      (cddr (aref disp-vector i)))
  			    "-- no font --")
  			  "\n")
! 		  (when (> (car (aref disp-vector i)) #x7ffff)
! 		    (let* ((face-id (lsh (car (aref disp-vector i)) -19))
! 			   (face (car (delq nil (mapcar
! 						 (lambda (face)
! 						   (and (eq (face-id face)
! 							    face-id) face))
! 						 (face-list))))))
! 		      (when face
! 			(insert (propertize " " 'display '(space :align-to 5))
! 				"face: ")
! 			(insert (concat "`" (symbol-name face) "'"))
! 			(insert "\n"))))))
  	    (insert "these terminal codes:\n")
  	    (dotimes (i (length disp-vector))
  	      (insert (car (aref disp-vector i))
--- 627,645 ----
  	      (progn
  		(insert "these fonts (glyph codes):\n")
  		(dotimes (i (length disp-vector))
! 		  (insert (glyph-char (car (aref disp-vector i))) ?:
  			  (propertize " " 'display '(space :align-to 5))
  			  (if (cdr (aref disp-vector i))
  			      (format "%s (#x%02X)" (cadr (aref disp-vector i))
  				      (cddr (aref disp-vector i)))
  			    "-- no font --")
  			  "\n")
! 		  (let ((face (glyph-face (car (aref disp-vector i)))))
! 		    (when face
! 		      (insert (propertize " " 'display '(space :align-to 5))
! 			      "face: ")
! 		      (insert (concat "`" (symbol-name face) "'"))
! 		      (insert "\n")))))
  	    (insert "these terminal codes:\n")
  	    (dotimes (i (length disp-vector))
  	      (insert (car (aref disp-vector i))


*** latin1-disp.el	21 Jan 2007 21:53:10 +0100	1.23
--- latin1-disp.el	08 Feb 2007 10:44:28 +0100	
***************
*** 177,190 ****
        (if (eq 'default latin1-display-face)
  	  (standard-display-ascii char (format latin1-display-format display))
  	(aset standard-display-table char
! 	      (vconcat (mapcar (lambda (c)
! 				 (logior c (lsh (face-id latin1-display-face)
! 						19)))
  			       display))))
      (aset standard-display-table char
! 	  (if (eq 'default latin1-display-face)
! 	      display
! 	    (logior display (lsh (face-id latin1-display-face) 19))))))
  
  (defun latin1-display-identities (charset)
    "Display each character in CHARSET as the corresponding Latin-1 character.
--- 177,186 ----
        (if (eq 'default latin1-display-face)
  	  (standard-display-ascii char (format latin1-display-format display))
  	(aset standard-display-table char
! 	      (vconcat (mapcar (lambda (c) (make-glyph-code c latin1-display-face))
  			       display))))
      (aset standard-display-table char
! 	  (make-glyph-code display latin1-display-face))))
  
  (defun latin1-display-identities (charset)
    "Display each character in CHARSET as the corresponding Latin-1 character.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

  reply	other threads:[~2007-02-08 10:39 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-05 23:11 cannot understand Elisp manual node Glyphs Drew Adams
2007-02-07 13:29 ` Kim F. Storm
2007-02-07 14:54   ` Drew Adams
2007-02-07 15:24     ` Kim F. Storm
2007-02-07 15:53       ` Drew Adams
2007-02-07 16:16         ` Stuart D. Herring
2007-02-07 16:21           ` Drew Adams
2007-02-08 16:38             ` Stuart D. Herring
2007-02-07 22:52   ` Miles Bader
2007-02-08  8:26     ` Kim F. Storm
2007-02-08  8:51       ` David Kastrup
2007-02-08 10:39         ` Kim F. Storm [this message]
2007-02-08 23:46           ` Richard Stallman
2007-02-09  7:17             ` David Kastrup
2007-02-09  9:12               ` Markus Triska
2007-02-09  9:43                 ` Nick Roberts
2007-02-09 23:48                 ` Richard Stallman
2007-02-09 14:23               ` Richard Stallman
2007-02-09 11:12             ` Kim F. Storm
2007-02-09 11:32               ` Juanma Barranquero
2007-02-09 23:48                 ` Richard Stallman
2007-02-09 14:05               ` Kim F. Storm
2007-02-09 23:49                 ` Richard Stallman
2007-02-10  0:40                   ` Drew Adams
2007-02-10 17:40                     ` Richard Stallman
2007-02-11 14:18                       ` Miles Bader
2007-02-11 21:07                       ` Kim F. Storm
2007-02-12 17:53                         ` Richard Stallman
2007-02-14 23:32                           ` Kim F. Storm
2007-02-10 10:19                   ` Eli Zaretskii
2007-02-10 17:41                     ` Richard Stallman
2007-02-10 13:59                   ` Miles Bader
2007-02-11  0:20                     ` Richard Stallman
2007-02-11  1:34                       ` Drew Adams
2007-02-11 14:16                       ` Miles Bader
2007-02-12 17:52                         ` Richard Stallman
2007-02-09 18:16               ` Stuart D. Herring
2007-02-08 16:21       ` Stefan Monnier
2007-02-08 16:36         ` Juanma Barranquero
2007-02-08  9:58     ` Stephen J. Turnbull

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3d54l3pd5.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=dak@gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).