*** empty log message ***
[bpt/emacs.git] / lisp / disp-table.el
CommitLineData
c0274f38
ER
1;;; disp-table.el --- functions for dealing with char tables.
2
a2535589
JA
3;; Copyright (C) 1987 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation; either version 1, or (at your option)
10;; any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs; see the file COPYING. If not, write to
19;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21
22;; Written by Howard Gayle. See case-table.el for details.
23
24(require 'case-table)
25
26(defun rope-to-vector (rope)
27 (let* ((len (/ (length rope) 2))
28 (vector (make-vector len nil))
29 (i 0))
30 (while (< i len)
31 (aset vector i (rope-elt rope i))
32 (setq i (1+ i)))))
33
34(defun describe-display-table (DT)
49116ac0 35 "Describe the display table DT in a help buffer."
a2535589
JA
36 (with-output-to-temp-buffer "*Help*"
37 (princ "\nTruncation glyf: ")
38 (prin1 (aref dt 256))
39 (princ "\nWrap glyf: ")
40 (prin1 (aref dt 257))
41 (princ "\nEscape glyf: ")
42 (prin1 (aref dt 258))
43 (princ "\nCtrl glyf: ")
44 (prin1 (aref dt 259))
45 (princ "\nSelective display rope: ")
46 (prin1 (rope-to-vector (aref dt 260)))
47 (princ "\nCharacter display ropes:\n")
48 (let ((vector (make-vector 256 nil))
49 (i 0))
50 (while (< i 256)
51 (aset vector i
52 (if (stringp (aref dt i))
53 (rope-to-vector (aref dt i))
54 (aref dt i)))
55 (setq i (1+ i)))
56 (describe-vector vector))
57 (print-help-return-message)))
58
59(defun describe-current-display-table ()
49116ac0 60 "Describe the display table in use in the selected window and buffer."
a2535589
JA
61 (interactive)
62 (describe-display-table
63 (or (window-display-table (selected-window))
64 buffer-display-table
65 standard-display-table)))
66
67(defun make-display-table ()
68 (make-vector 261 nil))
69
70(defun standard-display-8bit (l h)
49116ac0 71 "Display characters in the range L to H literally."
a2535589
JA
72 (while (<= l h)
73 (if (and (>= l ?\ ) (< l 127))
74 (if standard-display-table (aset standard-display-table l nil))
75 (or standard-display-table
76 (setq standard-display-table (make-vector 261 nil)))
77 (aset standard-display-table l l))
78 (setq l (1+ l))))
79
80(defun standard-display-ascii (c s)
81 "Display character C using string S."
82 (or standard-display-table
83 (setq standard-display-table (make-vector 261 nil)))
84 (aset standard-display-table c (apply 'make-rope (append s nil))))
85
86(defun standard-display-g1 (c sc)
87 "Display character C as character SC in the g1 character set."
88 (or standard-display-table
89 (setq standard-display-table (make-vector 261 nil)))
90 (aset standard-display-table c
91 (make-rope (create-glyf (concat "\016" (char-to-string sc) "\017")))))
92
93(defun standard-display-graphic (c gc)
94 "Display character C as character GC in graphics character set."
95 (or standard-display-table
96 (setq standard-display-table (make-vector 261 nil)))
97 (aset standard-display-table c
98 (make-rope (create-glyf (concat "\e(0" (char-to-string gc) "\e(B")))))
99
100(defun standard-display-underline (c uc)
101 "Display character C as character UC plus underlining."
102 (or standard-display-table
103 (setq standard-display-table (make-vector 261 nil)))
104 (aset standard-display-table c
105 (make-rope (create-glyf (concat "\e[4m" (char-to-string uc) "\e[m")))))
106
107(defun create-glyf (string)
108 (let ((i 256))
109 (while (and (< i 65536) (aref glyf-table i)
110 (not (string= (aref glyf-table i) string)))
111 (setq i (1+ i)))
112 (if (= i 65536)
113 (error "No free glyf codes remain"))
114 (aset glyf-table i string)))
115
116(provide 'disp-table)
c0274f38
ER
117
118;;; disp-table.el ends here