Use new form of calendar-read-date.
[emacs.git] / lisp / disp-table.el
blobb9e78eb0759f59985f0368a2ca8a201783ea5377
1 ;;; disp-table.el --- functions for dealing with char tables.
3 ;; Copyright (C) 1987, 1994 Free Software Foundation, Inc.
5 ;; Author: Howard Gayle
6 ;; Maintainer: FSF
7 ;; Keywords: i18n
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 ;;; Code:
27 (defconst display-table-len 262
28 "The proper length of a display table.")
30 (defun describe-display-table (dt)
31 "Describe the display table DT in a help buffer."
32 (with-output-to-temp-buffer "*Help*"
33 (princ "\nTruncation glyph: ")
34 (prin1 (aref dt 256))
35 (princ "\nWrap glyph: ")
36 (prin1 (aref dt 257))
37 (princ "\nEscape glyph: ")
38 (prin1 (aref dt 258))
39 (princ "\nCtrl glyph: ")
40 (prin1 (aref dt 259))
41 (princ "\nSelective display glyph sequence: ")
42 (prin1 (aref dt 260))
43 (princ "\nVertical window border glyph: ")
44 (prin1 (aref dt 261))
45 (princ "\nCharacter display glyph sequences:\n")
46 (save-excursion
47 (set-buffer standard-output)
48 (let ((vector (make-vector 256 nil))
49 (i 0))
50 (while (< i 256)
51 (aset vector i (aref dt i))
52 (setq i (1+ i)))
53 (describe-vector vector)))
54 (print-help-return-message)))
56 ;;;###autoload
57 (defun describe-current-display-table ()
58 "Describe the display table in use in the selected window and buffer."
59 (interactive)
60 (let ((disptab
61 (or (window-display-table (selected-window))
62 buffer-display-table
63 standard-display-table)))
64 (if disptab
65 (describe-display-table disptab)
66 (message "No display table"))))
68 ;;;###autoload
69 (defun make-display-table ()
70 "Return a new, empty display table."
71 (make-vector display-table-len nil))
73 ;;;###autoload
74 (defun standard-display-8bit (l h)
75 "Display characters in the range L to H literally."
76 (while (<= l h)
77 (if (and (>= l ?\ ) (< l 127))
78 (if standard-display-table (aset standard-display-table l nil))
79 (or standard-display-table
80 (setq standard-display-table (make-vector display-table-len nil)))
81 (aset standard-display-table l (vector l)))
82 (setq l (1+ l))))
84 ;;;###autoload
85 (defun standard-display-default (l h)
86 "Display characters in the range L to H using the default notation."
87 (while (<= l h)
88 (if (and (>= l ?\ ) (< l 127))
89 (if standard-display-table (aset standard-display-table l nil))
90 (or standard-display-table
91 (setq standard-display-table (make-vector display-table-len nil)))
92 (aset standard-display-table l nil))
93 (setq l (1+ l))))
95 ;;;###autoload
96 (defun standard-display-ascii (c s)
97 "Display character C using string S.
98 S is usually a terminal-dependent escape sequence.
99 This function is meaningless for an X frame."
100 (if window-system
101 (error "Cannot use string glyphs in a windowing system"))
102 (or standard-display-table
103 (setq standard-display-table (make-vector display-table-len nil)))
104 (aset standard-display-table c (apply 'vector (append s nil))))
106 ;;;###autoload
107 (defun standard-display-g1 (c sc)
108 "Display character C as character SC in the g1 character set.
109 This function assumes that your terminal uses the SO/SI characters;
110 it is meaningless for an X frame."
111 (if window-system
112 (error "Cannot use string glyphs in a windowing system"))
113 (or standard-display-table
114 (setq standard-display-table (make-vector display-table-len nil)))
115 (aset standard-display-table c
116 (vector (create-glyph (concat "\016" (char-to-string sc) "\017")))))
118 ;;;###autoload
119 (defun standard-display-graphic (c gc)
120 "Display character C as character GC in graphics character set.
121 This function assumes VT100-compatible escapes; it is meaningless for an
122 X frame."
123 (if window-system
124 (error "Cannot use string glyphs in a windowing system"))
125 (or standard-display-table
126 (setq standard-display-table (make-vector display-table-len nil)))
127 (aset standard-display-table c
128 (vector (create-glyph (concat "\e(0" (char-to-string gc) "\e(B")))))
130 ;;;###autoload
131 (defun standard-display-underline (c uc)
132 "Display character C as character UC plus underlining."
133 (if window-system (require 'faces))
134 (or standard-display-table
135 (setq standard-display-table (make-vector display-table-len nil)))
136 (aset standard-display-table c
137 (vector
138 (if window-system
139 (logior uc (lsh (face-id (internal-find-face 'underline)) 8))
140 (create-glyph (concat "\e[4m" (char-to-string uc) "\e[m"))))))
142 ;; Allocate a glyph code to display by sending STRING to the terminal.
143 ;;;###autoload
144 (defun create-glyph (string)
145 (if (= (length glyph-table) 65536)
146 (error "No free glyph codes remain"))
147 ;; Don't use slots that correspond to ASCII characters.
148 (if (= (length glyph-table) 32)
149 (setq glyph-table (vconcat glyph-table (make-vector 224 nil))))
150 (setq glyph-table (vconcat glyph-table (list string)))
151 (1- (length glyph-table)))
153 ;;;###autoload
154 (defun standard-display-european (arg)
155 "Toggle display of European characters encoded with ISO 8859.
156 When enabled, characters in the range of 160 to 255 display not
157 as octal escapes, but as accented characters.
158 With prefix argument, enable European character display iff arg is positive."
159 (interactive "P")
160 (if (or (<= (prefix-numeric-value arg) 0)
161 (and (null arg)
162 (vectorp standard-display-table)
163 (>= (length standard-display-table) 161)
164 (equal (aref standard-display-table 160) [160])))
165 (standard-display-default 160 255)
166 (standard-display-8bit 160 255)))
168 (provide 'disp-table)
170 ;;; disp-table.el ends here