Commit | Line | Data |
---|---|---|
c0274f38 ER |
1 | ;;; disp-table.el --- functions for dealing with char tables. |
2 | ||
8f1204db | 3 | ;; Copyright (C) 1987, 1994 Free Software Foundation, Inc. |
9750e079 | 4 | |
e5167999 ER |
5 | ;; Author: Howard Gayle |
6 | ;; Maintainer: FSF | |
a1d15b3e | 7 | ;; Keywords: i18n |
a2535589 JA |
8 | |
9 | ;; This file is part of GNU Emacs. | |
10 | ||
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 | |
e5167999 | 13 | ;; the Free Software Foundation; either version 2, or (at your option) |
a2535589 JA |
14 | ;; any later version. |
15 | ||
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. | |
20 | ||
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. | |
24 | ||
e5167999 | 25 | ;;; Code: |
a2535589 | 26 | |
dc5a82ea JB |
27 | (defconst display-table-len 262 |
28 | "The proper length of a display table.") | |
29 | ||
e31b61e6 | 30 | (defun describe-display-table (dt) |
49116ac0 | 31 | "Describe the display table DT in a help buffer." |
a2535589 | 32 | (with-output-to-temp-buffer "*Help*" |
03131799 | 33 | (princ "\nTruncation glyph: ") |
a2535589 | 34 | (prin1 (aref dt 256)) |
03131799 | 35 | (princ "\nWrap glyph: ") |
a2535589 | 36 | (prin1 (aref dt 257)) |
03131799 | 37 | (princ "\nEscape glyph: ") |
a2535589 | 38 | (prin1 (aref dt 258)) |
03131799 | 39 | (princ "\nCtrl glyph: ") |
a2535589 | 40 | (prin1 (aref dt 259)) |
afb1e4b4 | 41 | (princ "\nSelective display glyph sequence: ") |
e31b61e6 | 42 | (prin1 (aref dt 260)) |
dc5a82ea JB |
43 | (princ "\nVertical window border glyph: ") |
44 | (prin1 (aref dt 261)) | |
afb1e4b4 | 45 | (princ "\nCharacter display glyph sequences:\n") |
bb6066c8 RS |
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))) | |
5d74f2a6 KH |
53 | (describe-vector vector)) |
54 | (help-mode)) | |
a2535589 JA |
55 | (print-help-return-message))) |
56 | ||
e31b61e6 | 57 | ;;;###autoload |
a2535589 | 58 | (defun describe-current-display-table () |
bb6066c8 RS |
59 | "Describe the display table in use in the selected window and buffer." |
60 | (interactive) | |
61 | (let ((disptab | |
62 | (or (window-display-table (selected-window)) | |
63 | buffer-display-table | |
64 | standard-display-table))) | |
65 | (if disptab | |
66 | (describe-display-table disptab) | |
67 | (message "No display table")))) | |
a2535589 | 68 | |
e31b61e6 | 69 | ;;;###autoload |
a2535589 | 70 | (defun make-display-table () |
e31b61e6 | 71 | "Return a new, empty display table." |
dc5a82ea | 72 | (make-vector display-table-len nil)) |
a2535589 | 73 | |
e31b61e6 | 74 | ;;;###autoload |
a2535589 | 75 | (defun standard-display-8bit (l h) |
49116ac0 | 76 | "Display characters in the range L to H literally." |
a2535589 JA |
77 | (while (<= l h) |
78 | (if (and (>= l ?\ ) (< l 127)) | |
79 | (if standard-display-table (aset standard-display-table l nil)) | |
80 | (or standard-display-table | |
dc5a82ea | 81 | (setq standard-display-table (make-vector display-table-len nil))) |
afb1e4b4 | 82 | (aset standard-display-table l (vector l))) |
a2535589 JA |
83 | (setq l (1+ l)))) |
84 | ||
798aa8d0 JB |
85 | ;;;###autoload |
86 | (defun standard-display-default (l h) | |
87 | "Display characters in the range L to H using the default notation." | |
88 | (while (<= l h) | |
89 | (if (and (>= l ?\ ) (< l 127)) | |
90 | (if standard-display-table (aset standard-display-table l nil)) | |
91 | (or standard-display-table | |
dc5a82ea | 92 | (setq standard-display-table (make-vector display-table-len nil))) |
798aa8d0 JB |
93 | (aset standard-display-table l nil)) |
94 | (setq l (1+ l)))) | |
95 | ||
e31b61e6 | 96 | ;;;###autoload |
a171458a KH |
97 | ;; This function does NOT take terminal-dependent escape sequences. |
98 | ;; For that, you need to go through create-glyph. Use one of the | |
99 | ;; other functions below, or roll your own. | |
a2535589 | 100 | (defun standard-display-ascii (c s) |
a171458a | 101 | "Display character C using printable string S." |
a2535589 | 102 | (or standard-display-table |
dc5a82ea | 103 | (setq standard-display-table (make-vector display-table-len nil))) |
82093c70 | 104 | (aset standard-display-table c (apply 'vector (append s nil)))) |
a2535589 | 105 | |
e31b61e6 | 106 | ;;;###autoload |
a2535589 | 107 | (defun standard-display-g1 (c sc) |
de7d5cb6 KH |
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")) | |
a2535589 | 113 | (or standard-display-table |
dc5a82ea | 114 | (setq standard-display-table (make-vector display-table-len nil))) |
a2535589 | 115 | (aset standard-display-table c |
82093c70 | 116 | (vector (create-glyph (concat "\016" (char-to-string sc) "\017"))))) |
a2535589 | 117 | |
e31b61e6 | 118 | ;;;###autoload |
a2535589 | 119 | (defun standard-display-graphic (c gc) |
de7d5cb6 KH |
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")) | |
a2535589 | 125 | (or standard-display-table |
dc5a82ea | 126 | (setq standard-display-table (make-vector display-table-len nil))) |
a2535589 | 127 | (aset standard-display-table c |
82093c70 | 128 | (vector (create-glyph (concat "\e(0" (char-to-string gc) "\e(B"))))) |
a2535589 | 129 | |
e31b61e6 | 130 | ;;;###autoload |
a2535589 JA |
131 | (defun standard-display-underline (c uc) |
132 | "Display character C as character UC plus underlining." | |
de7d5cb6 | 133 | (if window-system (require 'faces)) |
a2535589 | 134 | (or standard-display-table |
dc5a82ea | 135 | (setq standard-display-table (make-vector display-table-len nil))) |
a2535589 | 136 | (aset standard-display-table c |
de7d5cb6 KH |
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")))))) | |
03131799 RS |
141 | |
142 | ;; Allocate a glyph code to display by sending STRING to the terminal. | |
e31b61e6 | 143 | ;;;###autoload |
03131799 RS |
144 | (defun create-glyph (string) |
145 | (if (= (length glyph-table) 65536) | |
146 | (error "No free glyph codes remain")) | |
03fd83c5 KH |
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)))) | |
03131799 RS |
150 | (setq glyph-table (vconcat glyph-table (list string))) |
151 | (1- (length glyph-table))) | |
a2535589 | 152 | |
2eae7226 | 153 | ;;;###autoload |
798aa8d0 | 154 | (defun standard-display-european (arg) |
2eae7226 JB |
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." | |
798aa8d0 | 159 | (interactive "P") |
c3a14a2b | 160 | (if (or (<= (prefix-numeric-value arg) 0) |
2eae7226 JB |
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) | |
798aa8d0 | 166 | (standard-display-8bit 160 255))) |
798aa8d0 | 167 | |
a2535589 | 168 | (provide 'disp-table) |
c0274f38 ER |
169 | |
170 | ;;; disp-table.el ends here |