1 ;;; disp-table.el --- functions for dealing with char tables.
3 ;; Copyright (C) 1987, 1994 Free Software Foundation, Inc.
5 ;; Author: Howard Gayle
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)
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.
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: ")
35 (princ "\nWrap glyph: ")
37 (princ "\nEscape glyph: ")
39 (princ "\nCtrl glyph: ")
41 (princ "\nSelective display glyph sequence: ")
43 (princ "\nVertical window border glyph: ")
45 (princ "\nCharacter display glyph sequences:\n")
47 (set-buffer standard-output
)
48 (let ((vector (make-vector 256 nil
))
51 (aset vector i
(aref dt i
))
53 (describe-vector vector
))
55 (print-help-return-message)))
58 (defun describe-current-display-table ()
59 "Describe the display table in use in the selected window and buffer."
62 (or (window-display-table (selected-window))
64 standard-display-table
)))
66 (describe-display-table disptab
)
67 (message "No display table"))))
70 (defun make-display-table ()
71 "Return a new, empty display table."
72 (make-vector display-table-len nil
))
75 (defun standard-display-8bit (l h
)
76 "Display characters in the range L to H literally."
78 (if (and (>= l ?\
) (< l
127))
79 (if standard-display-table
(aset standard-display-table l nil
))
80 (or standard-display-table
81 (setq standard-display-table
(make-vector display-table-len nil
)))
82 (aset standard-display-table l
(vector l
)))
86 (defun standard-display-default (l h
)
87 "Display characters in the range L to H using the default notation."
89 (if (and (>= l ?\
) (< l
127))
90 (if standard-display-table
(aset standard-display-table l nil
))
91 (or standard-display-table
92 (setq standard-display-table
(make-vector display-table-len nil
)))
93 (aset standard-display-table l nil
))
97 (defun standard-display-ascii (c s
)
98 "Display character C using string S.
99 S is usually a terminal-dependent escape sequence.
100 This function is meaningless for an X frame."
102 (error "Cannot use string glyphs in a windowing system"))
103 (or standard-display-table
104 (setq standard-display-table
(make-vector display-table-len nil
)))
105 (aset standard-display-table c
(apply 'vector
(append s nil
))))
108 (defun standard-display-g1 (c sc
)
109 "Display character C as character SC in the g1 character set.
110 This function assumes that your terminal uses the SO/SI characters;
111 it is meaningless for an X frame."
113 (error "Cannot use string glyphs in a windowing system"))
114 (or standard-display-table
115 (setq standard-display-table
(make-vector display-table-len nil
)))
116 (aset standard-display-table c
117 (vector (create-glyph (concat "\016" (char-to-string sc
) "\017")))))
120 (defun standard-display-graphic (c gc
)
121 "Display character C as character GC in graphics character set.
122 This function assumes VT100-compatible escapes; it is meaningless for an
125 (error "Cannot use string glyphs in a windowing system"))
126 (or standard-display-table
127 (setq standard-display-table
(make-vector display-table-len nil
)))
128 (aset standard-display-table c
129 (vector (create-glyph (concat "\e(0" (char-to-string gc
) "\e(B")))))
132 (defun standard-display-underline (c uc
)
133 "Display character C as character UC plus underlining."
134 (if window-system
(require 'faces
))
135 (or standard-display-table
136 (setq standard-display-table
(make-vector display-table-len nil
)))
137 (aset standard-display-table c
140 (logior uc
(lsh (face-id (internal-find-face 'underline
)) 8))
141 (create-glyph (concat "\e[4m" (char-to-string uc
) "\e[m"))))))
143 ;; Allocate a glyph code to display by sending STRING to the terminal.
145 (defun create-glyph (string)
146 (if (= (length glyph-table
) 65536)
147 (error "No free glyph codes remain"))
148 ;; Don't use slots that correspond to ASCII characters.
149 (if (= (length glyph-table
) 32)
150 (setq glyph-table
(vconcat glyph-table
(make-vector 224 nil
))))
151 (setq glyph-table
(vconcat glyph-table
(list string
)))
152 (1- (length glyph-table
)))
155 (defun standard-display-european (arg)
156 "Toggle display of European characters encoded with ISO 8859.
157 When enabled, characters in the range of 160 to 255 display not
158 as octal escapes, but as accented characters.
159 With prefix argument, enable European character display iff arg is positive."
161 (if (or (<= (prefix-numeric-value arg
) 0)
163 (vectorp standard-display-table
)
164 (>= (length standard-display-table
) 161)
165 (equal (aref standard-display-table
160) [160])))
166 (standard-display-default 160 255)
167 (standard-display-8bit 160 255)))
169 (provide 'disp-table)
171 ;;; disp-table.el ends here