aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2003-09-28 23:30:09 +0000
committerKenichi Handa2003-09-28 23:30:09 +0000
commitf15078e2b08aac1ca0973a1d9b794cf131c3b368 (patch)
tree94d678e059cf267f7f6e13f3474d7c420bbca560
parente5bc082b291e3af1d48342f111e88ec49993a479 (diff)
downloademacs-f15078e2b08aac1ca0973a1d9b794cf131c3b368.tar.gz
emacs-f15078e2b08aac1ca0973a1d9b794cf131c3b368.zip
(describe-char-display): New function.
(describe-char): Pay attention to display table on describing how a character is displayed.
-rw-r--r--lisp/descr-text.el149
1 files changed, 114 insertions, 35 deletions
diff --git a/lisp/descr-text.el b/lisp/descr-text.el
index ff38c21ed50..8e9b1af2dde 100644
--- a/lisp/descr-text.el
+++ b/lisp/descr-text.el
@@ -434,6 +434,19 @@ otherwise."
434;;; (string-to-number 434;;; (string-to-number
435;;; (nth 13 fields) 16)) 435;;; (nth 13 fields) 16))
436;;; ??))))))))))) 436;;; ??)))))))))))
437
438;; Return information about how CHAR is displayed at the buffer
439;; position POS. If the selected frame is on a graphic display,
440;; return a cons (FONTNAME . GLYPH-CODE). Otherwise, return a string
441;; describing the terminal codes for the character.
442(defun describe-char-display (pos char)
443 (if (display-graphic-p (selected-frame))
444 (internal-char-font pos char)
445 (let* ((coding (terminal-coding-system))
446 (encoded (encode-coding-char char coding)))
447 (if encoded
448 (encoded-string-description encoded coding)))))
449
437 450
438;;;###autoload 451;;;###autoload
439(defun describe-char (pos) 452(defun describe-char (pos)
@@ -449,8 +462,11 @@ as well as widgets, buttons, overlays, and text properties."
449 (charset (char-charset char)) 462 (charset (char-charset char))
450 (buffer (current-buffer)) 463 (buffer (current-buffer))
451 (composition (find-composition pos nil nil t)) 464 (composition (find-composition pos nil nil t))
452 (composed (if composition (buffer-substring (car composition) 465 (component-chars nil)
453 (nth 1 composition)))) 466 (display-table (or (window-display-table)
467 buffer-display-table
468 standard-display-table))
469 (disp-vector (and display-table (aref display-table char)))
454 (multibyte-p enable-multibyte-characters) 470 (multibyte-p enable-multibyte-characters)
455 item-list max-width unicode) 471 item-list max-width unicode)
456 (if (eq charset 'unknown) 472 (if (eq charset 'unknown)
@@ -514,15 +530,46 @@ as well as widgets, buttons, overlays, and text properties."
514 (format "(encoded by coding system %S)" coding)) 530 (format "(encoded by coding system %S)" coding))
515 (list "not encodable by coding system" 531 (list "not encodable by coding system"
516 (symbol-name coding))))) 532 (symbol-name coding)))))
517 ,(if (display-graphic-p (selected-frame)) 533 ("display"
518 (list "font" (or (internal-char-font pos) 534 ,(cond
519 "-- none --")) 535 (disp-vector
520 (list "terminal code" 536 (setq disp-vector (copy-sequence disp-vector))
521 (let* ((coding (terminal-coding-system)) 537 (dotimes (i (length disp-vector))
522 (encoded (encode-coding-char char coding))) 538 (setq char (aref disp-vector i))
523 (if encoded 539 (aset disp-vector i
524 (encoded-string-description encoded coding) 540 (cons char (describe-char-display pos char))))
525 "not encodable")))) 541 (format "by display table entry [%s] (see below)"
542 (mapconcat #'(lambda (x) (format "?%c" (car x)))
543 disp-vector " ")))
544 (composition
545 (let ((from (car composition))
546 (to (nth 1 composition))
547 (next (1+ pos))
548 (components (nth 2 composition))
549 ch)
550 (setcar composition
551 (and (< from pos) (buffer-substring from pos)))
552 (setcar (cdr composition)
553 (and (< next to) (buffer-substring next to)))
554 (dotimes (i (length components))
555 (if (integerp (setq ch (aref components i)))
556 (push (cons ch (describe-char-display pos ch))
557 component-chars)))
558 (setq component-chars (nreverse component-chars))
559 (format "composed to form \"%s\" (see below)"
560 (buffer-substring from to))))
561 (t
562 (let ((display (describe-char-display pos char)))
563 (if (display-graphic-p (selected-frame))
564 (if display
565 (concat
566 "by this font (glyph code)\n"
567 (format " %s (0x%02X)"
568 (car display) (cdr display)))
569 "no font avairable")
570 (if display
571 (format "terminal code %s" display)
572 "not encodable for terminal"))))))
526 ,@(let ((unicodedata (and unicode 573 ,@(let ((unicodedata (and unicode
527 (describe-char-unicode-data unicode)))) 574 (describe-char-unicode-data unicode))))
528 (if unicodedata 575 (if unicodedata
@@ -547,31 +594,63 @@ as well as widgets, buttons, overlays, and text properties."
547 (indent-to (1+ max-width))) 594 (indent-to (1+ max-width)))
548 (insert " " clm)) 595 (insert " " clm))
549 (insert "\n")))) 596 (insert "\n"))))
597
598 (when disp-vector
599 (insert
600 "\nThe display table entry is displayed by ")
601 (if (display-graphic-p (selected-frame))
602 (progn
603 (insert "these fonts (glyph codes):\n")
604 (dotimes (i (length disp-vector))
605 (insert (car (aref disp-vector i)) ?:
606 (propertize " " 'display '(space :align-to 5))
607 (if (cdr (aref disp-vector i))
608 (format "%s (0x%02X)" (cadr (aref disp-vector i))
609 (cddr (aref disp-vector i)))
610 "-- no font --")
611 "\n ")))
612 (insert "these terminal codes:\n")
613 (dotimes (i (length disp-vector))
614 (insertf(car (aref disp-vector i))
615 (propertize " " 'display '(space :align-to 5))
616 (or (cdr (aref disp-vector i)) "-- not encodable --")
617 "\n"))))
618
550 (when composition 619 (when composition
551 (insert "\nComposed with the " 620 (insert "\nComposed")
552 (cond 621 (if (car composition)
553 ((eq pos (car composition)) "following ") 622 (if (cadr composition)
554 ((eq (1+ pos) (cadr composition)) "preceding ") 623 (insert " with the surrounding characters \""
555 (t "")) 624 (car composition) "\" and \""
556 "character(s) `" 625 (cadr composition) "\"")
557 (cond 626 (insert " with the preceding character(s) \""
558 ((eq pos (car composition)) (substring composed 1)) 627 (car composition) "\""))
559 ((eq (1+ pos) (cadr composition)) (substring composed 0 -1)) 628 (if (cadr composition)
560 (t (concat (substring composed 0 (- pos (car composition))) 629 (insert " with the following character(s) \""
561 "' and `" 630 (cadr composition) "\"")))
562 (substring composed (- (1+ pos) (car composition)))))) 631 (insert " by the rule:\n\t("
563 632 (mapconcat (lambda (x)
564 "' to form `" composed "'") 633 (format (if (consp x) "%S" "?%c") x))
565 (if (nth 3 composition) 634 (nth 2 composition)
566 (insert ".\n") 635 " ")
567 (insert "\nby the rule (" 636 ")")
568 (mapconcat (lambda (x) 637 (insert "\nThe component character(s) are displayed by ")
569 (format (if (consp x) "%S" "?%c") x)) 638 (if (display-graphic-p (selected-frame))
570 (nth 2 composition) 639 (progn
571 " ") 640 (insert "these fonts (glyph codes):")
572 ").\n" 641 (dolist (elt component-chars)
573 "See the variable `reference-point-alist' for " 642 (insert "\n " (car elt) ?:
574 "the meaning of the rule.\n"))) 643 (propertize " " 'display '(space :align-to 5))
644 (if (cdr elt)
645 (format "%s (0x%02X)" (cadr elt) (cddr elt))
646 "-- no font --"))))
647 (insert "these terminal codes:")
648 (dolist (elt component-chars)
649 (insert "\n " (car elt) ":"
650 (propertize " " 'display '(space :align-to 5))
651 (or (cdr elt) "-- not encodable --"))))
652 (insert "\nSee the variable `reference-point-alist' for "
653 "the meaning of the rule.\n"))
575 654
576 (let ((output (current-buffer))) 655 (let ((output (current-buffer)))
577 (with-current-buffer buffer 656 (with-current-buffer buffer