diff options
| author | Kenichi Handa | 2009-02-10 06:03:44 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2009-02-10 06:03:44 +0000 |
| commit | 0ba13131e5f7dcf9d27643a06eefb7c0f9a1bfac (patch) | |
| tree | 16586458bbab5e4736c4185a8701b3b204c7f4b9 | |
| parent | af02d73901bd7ffd1c50e31125de290593ccd468 (diff) | |
| download | emacs-0ba13131e5f7dcf9d27643a06eefb7c0f9a1bfac.tar.gz emacs-0ba13131e5f7dcf9d27643a06eefb7c0f9a1bfac.zip | |
(describe-char-display): On terminal, if terminal
coding system is nil, assume us-ascii.
(describe-char): Don't show the composition informaiton if it is
trivial.
| -rw-r--r-- | lisp/descr-text.el | 127 |
1 files changed, 85 insertions, 42 deletions
diff --git a/lisp/descr-text.el b/lisp/descr-text.el index 89325cca22a..5234a4f9a9a 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el | |||
| @@ -342,7 +342,7 @@ This function is semi-obsolete. Use `get-char-code-property'." | |||
| 342 | (format "%s:%s (#x%04X%04X)" | 342 | (format "%s:%s (#x%04X%04X)" |
| 343 | type name (car code) (cdr code)))))) | 343 | type name (car code) (cdr code)))))) |
| 344 | (let* ((charset (get-text-property pos 'charset)) | 344 | (let* ((charset (get-text-property pos 'charset)) |
| 345 | (coding (terminal-coding-system)) | 345 | (coding (or (terminal-coding-system) 'us-ascii)) |
| 346 | (encoded (encode-coding-char char coding charset))) | 346 | (encoded (encode-coding-char char coding charset))) |
| 347 | (if encoded | 347 | (if encoded |
| 348 | (encoded-string-description encoded coding))))) | 348 | (encoded-string-description encoded coding))))) |
| @@ -411,6 +411,80 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 411 | (setq charset (char-charset char) | 411 | (setq charset (char-charset char) |
| 412 | code (encode-char char charset))) | 412 | code (encode-char char charset))) |
| 413 | (setq code char)) | 413 | (setq code char)) |
| 414 | (when composition | ||
| 415 | ;; When the composition is trivial (i.e. composed only with the | ||
| 416 | ;; current character itself without any alternate characters), | ||
| 417 | ;; we don't show the composition information. Otherwise, store | ||
| 418 | ;; two descriptive strings in the first two elments of | ||
| 419 | ;; COMPOSITION. | ||
| 420 | (or (catch 'tag | ||
| 421 | (let ((from (car composition)) | ||
| 422 | (to (nth 1 composition)) | ||
| 423 | (next (1+ pos)) | ||
| 424 | (components (nth 2 composition)) | ||
| 425 | ch) | ||
| 426 | (if (and (vectorp components) (vectorp (aref components 0))) | ||
| 427 | (let ((idx (- pos from)) | ||
| 428 | (nglyphs (lgstring-glyph-len components)) | ||
| 429 | (i 0) j glyph glyph-from) | ||
| 430 | ;; COMPONENTS is a gstring. Find a grapheme | ||
| 431 | ;; cluster containing the current character. | ||
| 432 | (while (and (< i nglyphs) | ||
| 433 | (setq glyph (lgstring-glyph components i)) | ||
| 434 | (< (lglyph-to glyph) idx)) | ||
| 435 | (setq i (1+ i))) | ||
| 436 | (if (or (not glyph) (= i nglyphs)) | ||
| 437 | ;; The composition is broken. | ||
| 438 | (throw 'tag nil)) | ||
| 439 | (setq glyph-from (lglyph-from glyph) | ||
| 440 | to (+ from (lglyph-to glyph) 1) | ||
| 441 | from (+ from glyph-from) | ||
| 442 | j i) | ||
| 443 | (while (and (< j nglyphs) | ||
| 444 | (setq glyph (lgstring-glyph components j)) | ||
| 445 | (= (lglyph-from glyph) glyph-from)) | ||
| 446 | (setq j (1+ j))) | ||
| 447 | (if (and (= i (1- j)) | ||
| 448 | (setq glyph (lgstring-glyph components i)) | ||
| 449 | (= char (lglyph-char glyph))) | ||
| 450 | ;; The composition is trivial. | ||
| 451 | (throw 'tag nil)) | ||
| 452 | (nconc composition (list i (1- j)))) | ||
| 453 | (dotimes (i (length components)) | ||
| 454 | (if (integerp (setq ch (aref components i))) | ||
| 455 | (push (cons ch (describe-char-display pos ch)) | ||
| 456 | component-chars))) | ||
| 457 | (setq component-chars (nreverse component-chars))) | ||
| 458 | (if (< from pos) | ||
| 459 | (if (< (1+ pos) to) | ||
| 460 | (setcar composition | ||
| 461 | (concat | ||
| 462 | " with the surrounding characters \"" | ||
| 463 | (mapconcat 'describe-char-padded-string | ||
| 464 | (buffer-substring from pos) "") | ||
| 465 | "\" and \"" | ||
| 466 | (mapconcat 'describe-char-padded-string | ||
| 467 | (buffer-substring (1+ pos) to) "") | ||
| 468 | "\"")) | ||
| 469 | (setcar composition | ||
| 470 | (concat | ||
| 471 | " with the preceding character(s) \"" | ||
| 472 | (mapconcat 'describe-char-padded-string | ||
| 473 | (buffer-substring from pos) "") | ||
| 474 | "\""))) | ||
| 475 | (if (< (1+ pos) to) | ||
| 476 | (setcar composition | ||
| 477 | (concat | ||
| 478 | " with the following character(s) \"" | ||
| 479 | (mapconcat 'describe-char-padded-string | ||
| 480 | (buffer-substring (1+ pos) to) "") | ||
| 481 | "\"")) | ||
| 482 | (setcar composition nil))) | ||
| 483 | (setcar (cdr composition) | ||
| 484 | (format "composed to form \"%s\" (see below)" | ||
| 485 | (buffer-substring from to))))) | ||
| 486 | (setq composition nil))) | ||
| 487 | |||
| 414 | (setq item-list | 488 | (setq item-list |
| 415 | `(("character" | 489 | `(("character" |
| 416 | ,(format "%s (%d, #o%o, #x%x)" | 490 | ,(format "%s (%d, #o%o, #x%x)" |
| @@ -497,22 +571,7 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 497 | (format "?%c" (glyph-char (car x)))) | 571 | (format "?%c" (glyph-char (car x)))) |
| 498 | disp-vector " "))) | 572 | disp-vector " "))) |
| 499 | (composition | 573 | (composition |
| 500 | (let ((from (car composition)) | 574 | (cadr composition)) |
| 501 | (to (nth 1 composition)) | ||
| 502 | (next (1+ pos)) | ||
| 503 | (components (nth 2 composition)) | ||
| 504 | ch) | ||
| 505 | (setcar composition | ||
| 506 | (and (< from pos) (buffer-substring from pos))) | ||
| 507 | (setcar (cdr composition) | ||
| 508 | (and (< next to) (buffer-substring next to))) | ||
| 509 | (dotimes (i (length components)) | ||
| 510 | (if (integerp (setq ch (aref components i))) | ||
| 511 | (push (cons ch (describe-char-display pos ch)) | ||
| 512 | component-chars))) | ||
| 513 | (setq component-chars (nreverse component-chars)) | ||
| 514 | (format "composed to form \"%s\" (see below)" | ||
| 515 | (buffer-substring from to)))) | ||
| 516 | (t | 575 | (t |
| 517 | (let ((display (describe-char-display pos char))) | 576 | (let ((display (describe-char-display pos char))) |
| 518 | (if (display-graphic-p (selected-frame)) | 577 | (if (display-graphic-p (selected-frame)) |
| @@ -606,29 +665,13 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 606 | (when composition | 665 | (when composition |
| 607 | (insert "\nComposed") | 666 | (insert "\nComposed") |
| 608 | (if (car composition) | 667 | (if (car composition) |
| 609 | (if (cadr composition) | 668 | (insert (car composition))) |
| 610 | (insert " with the surrounding characters \"" | ||
| 611 | (mapconcat 'describe-char-padded-string | ||
| 612 | (car composition) "") | ||
| 613 | "\" and \"" | ||
| 614 | (mapconcat 'describe-char-padded-string | ||
| 615 | (cadr composition) "") | ||
| 616 | "\"") | ||
| 617 | (insert " with the preceding character(s) \"" | ||
| 618 | (mapconcat 'describe-char-padded-string | ||
| 619 | (car composition) "") | ||
| 620 | "\"")) | ||
| 621 | (if (cadr composition) | ||
| 622 | (insert " with the following character(s) \"" | ||
| 623 | (mapconcat 'describe-char-padded-string | ||
| 624 | (cadr composition) "") | ||
| 625 | "\""))) | ||
| 626 | (if (and (vectorp (nth 2 composition)) | 669 | (if (and (vectorp (nth 2 composition)) |
| 627 | (vectorp (aref (nth 2 composition) 0))) | 670 | (vectorp (aref (nth 2 composition) 0))) |
| 628 | (let* ((gstring (nth 2 composition)) | 671 | (let* ((gstring (nth 2 composition)) |
| 629 | (font (lgstring-font gstring)) | 672 | (font (lgstring-font gstring)) |
| 630 | (nglyphs (lgstring-glyph-len gstring)) | 673 | (from (nth 3 composition)) |
| 631 | (i 0) | 674 | (to (nth 4 composition)) |
| 632 | glyph) | 675 | glyph) |
| 633 | (if (fontp font) | 676 | (if (fontp font) |
| 634 | (progn | 677 | (progn |
| @@ -637,16 +680,16 @@ as well as widgets, buttons, overlays, and text properties." | |||
| 637 | ?: | 680 | ?: |
| 638 | (aref (query-font font) 0) | 681 | (aref (query-font font) 0) |
| 639 | "\nby these glyphs:\n") | 682 | "\nby these glyphs:\n") |
| 640 | (while (and (< i nglyphs) | 683 | (while (and (<= from to) |
| 641 | (setq glyph (lgstring-glyph gstring i))) | 684 | (setq glyph (lgstring-glyph gstring from))) |
| 642 | (insert (format " %S\n" glyph)) | 685 | (insert (format " %S\n" glyph)) |
| 643 | (setq i (1+ i)))) | 686 | (setq from (1+ from)))) |
| 644 | (insert " by these characters:\n") | 687 | (insert " by these characters:\n") |
| 645 | (while (and (< i nglyphs) | 688 | (while (and (<= from to) |
| 646 | (setq glyph (lgstring-glyph gstring i))) | 689 | (setq glyph (lgstring-glyph gstring from))) |
| 647 | (insert (format " %c (#x%d)\n" | 690 | (insert (format " %c (#x%d)\n" |
| 648 | (lglyph-char glyph) (lglyph-char glyph))) | 691 | (lglyph-char glyph) (lglyph-char glyph))) |
| 649 | (setq i (1+ i))))) | 692 | (setq from (1+ from))))) |
| 650 | (insert " by the rule:\n\t(") | 693 | (insert " by the rule:\n\t(") |
| 651 | (let ((first t)) | 694 | (let ((first t)) |
| 652 | (mapc (lambda (x) | 695 | (mapc (lambda (x) |