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 | |
e31b61e6 | 27 | (defun describe-display-table (dt) |
49116ac0 | 28 | "Describe the display table DT in a help buffer." |
a2535589 | 29 | (with-output-to-temp-buffer "*Help*" |
03131799 | 30 | (princ "\nTruncation glyph: ") |
a2535589 | 31 | (prin1 (aref dt 256)) |
03131799 | 32 | (princ "\nWrap glyph: ") |
a2535589 | 33 | (prin1 (aref dt 257)) |
03131799 | 34 | (princ "\nEscape glyph: ") |
a2535589 | 35 | (prin1 (aref dt 258)) |
03131799 | 36 | (princ "\nCtrl glyph: ") |
a2535589 | 37 | (prin1 (aref dt 259)) |
afb1e4b4 | 38 | (princ "\nSelective display glyph sequence: ") |
e31b61e6 | 39 | (prin1 (aref dt 260)) |
afb1e4b4 | 40 | (princ "\nCharacter display glyph sequences:\n") |
bb6066c8 RS |
41 | (save-excursion |
42 | (set-buffer standard-output) | |
43 | (let ((vector (make-vector 256 nil)) | |
44 | (i 0)) | |
45 | (while (< i 256) | |
46 | (aset vector i (aref dt i)) | |
47 | (setq i (1+ i))) | |
48 | (describe-vector vector))) | |
a2535589 JA |
49 | (print-help-return-message))) |
50 | ||
e31b61e6 | 51 | ;;;###autoload |
a2535589 | 52 | (defun describe-current-display-table () |
bb6066c8 RS |
53 | "Describe the display table in use in the selected window and buffer." |
54 | (interactive) | |
55 | (let ((disptab | |
56 | (or (window-display-table (selected-window)) | |
57 | buffer-display-table | |
58 | standard-display-table))) | |
59 | (if disptab | |
60 | (describe-display-table disptab) | |
61 | (message "No display table")))) | |
a2535589 | 62 | |
e31b61e6 | 63 | ;;;###autoload |
a2535589 | 64 | (defun make-display-table () |
e31b61e6 | 65 | "Return a new, empty display table." |
a2535589 JA |
66 | (make-vector 261 nil)) |
67 | ||
e31b61e6 | 68 | ;;;###autoload |
a2535589 | 69 | (defun standard-display-8bit (l h) |
49116ac0 | 70 | "Display characters in the range L to H literally." |
a2535589 JA |
71 | (while (<= l h) |
72 | (if (and (>= l ?\ ) (< l 127)) | |
73 | (if standard-display-table (aset standard-display-table l nil)) | |
74 | (or standard-display-table | |
75 | (setq standard-display-table (make-vector 261 nil))) | |
afb1e4b4 | 76 | (aset standard-display-table l (vector l))) |
a2535589 JA |
77 | (setq l (1+ l)))) |
78 | ||
798aa8d0 JB |
79 | ;;;###autoload |
80 | (defun standard-display-default (l h) | |
81 | "Display characters in the range L to H using the default notation." | |
82 | (while (<= l h) | |
83 | (if (and (>= l ?\ ) (< l 127)) | |
84 | (if standard-display-table (aset standard-display-table l nil)) | |
85 | (or standard-display-table | |
86 | (setq standard-display-table (make-vector 261 nil))) | |
87 | (aset standard-display-table l nil)) | |
88 | (setq l (1+ l)))) | |
89 | ||
e31b61e6 | 90 | ;;;###autoload |
a2535589 | 91 | (defun standard-display-ascii (c s) |
de7d5cb6 KH |
92 | "Display character C using string S. |
93 | S is usually a terminal-dependent escape sequence. | |
94 | This function is meaningless for an X frame." | |
95 | (if window-system | |
96 | (error "Cannot use string glyphs in a windowing system")) | |
a2535589 JA |
97 | (or standard-display-table |
98 | (setq standard-display-table (make-vector 261 nil))) | |
82093c70 | 99 | (aset standard-display-table c (apply 'vector (append s nil)))) |
a2535589 | 100 | |
e31b61e6 | 101 | ;;;###autoload |
a2535589 | 102 | (defun standard-display-g1 (c sc) |
de7d5cb6 KH |
103 | "Display character C as character SC in the g1 character set. |
104 | This function assumes that your terminal uses the SO/SI characters; | |
105 | it is meaningless for an X frame." | |
106 | (if window-system | |
107 | (error "Cannot use string glyphs in a windowing system")) | |
a2535589 JA |
108 | (or standard-display-table |
109 | (setq standard-display-table (make-vector 261 nil))) | |
110 | (aset standard-display-table c | |
82093c70 | 111 | (vector (create-glyph (concat "\016" (char-to-string sc) "\017"))))) |
a2535589 | 112 | |
e31b61e6 | 113 | ;;;###autoload |
a2535589 | 114 | (defun standard-display-graphic (c gc) |
de7d5cb6 KH |
115 | "Display character C as character GC in graphics character set. |
116 | This function assumes VT100-compatible escapes; it is meaningless for an | |
117 | X frame." | |
118 | (if window-system | |
119 | (error "Cannot use string glyphs in a windowing system")) | |
a2535589 JA |
120 | (or standard-display-table |
121 | (setq standard-display-table (make-vector 261 nil))) | |
122 | (aset standard-display-table c | |
82093c70 | 123 | (vector (create-glyph (concat "\e(0" (char-to-string gc) "\e(B"))))) |
a2535589 | 124 | |
e31b61e6 | 125 | ;;;###autoload |
a2535589 JA |
126 | (defun standard-display-underline (c uc) |
127 | "Display character C as character UC plus underlining." | |
de7d5cb6 | 128 | (if window-system (require 'faces)) |
a2535589 JA |
129 | (or standard-display-table |
130 | (setq standard-display-table (make-vector 261 nil))) | |
131 | (aset standard-display-table c | |
de7d5cb6 KH |
132 | (vector |
133 | (if window-system | |
134 | (logior uc (lsh (face-id (internal-find-face 'underline)) 8)) | |
135 | (create-glyph (concat "\e[4m" (char-to-string uc) "\e[m")))))) | |
03131799 RS |
136 | |
137 | ;; Allocate a glyph code to display by sending STRING to the terminal. | |
e31b61e6 | 138 | ;;;###autoload |
03131799 RS |
139 | (defun create-glyph (string) |
140 | (if (= (length glyph-table) 65536) | |
141 | (error "No free glyph codes remain")) | |
03fd83c5 KH |
142 | ;; Don't use slots that correspond to ASCII characters. |
143 | (if (= (length glyph-table) 32) | |
144 | (setq glyph-table (vconcat glyph-table (make-vector 224 nil)))) | |
03131799 RS |
145 | (setq glyph-table (vconcat glyph-table (list string))) |
146 | (1- (length glyph-table))) | |
a2535589 | 147 | |
2eae7226 | 148 | ;;;###autoload |
798aa8d0 | 149 | (defun standard-display-european (arg) |
2eae7226 JB |
150 | "Toggle display of European characters encoded with ISO 8859. |
151 | When enabled, characters in the range of 160 to 255 display not | |
152 | as octal escapes, but as accented characters. | |
153 | With prefix argument, enable European character display iff arg is positive." | |
798aa8d0 | 154 | (interactive "P") |
c3a14a2b | 155 | (if (or (<= (prefix-numeric-value arg) 0) |
2eae7226 JB |
156 | (and (null arg) |
157 | (vectorp standard-display-table) | |
158 | (>= (length standard-display-table) 161) | |
159 | (equal (aref standard-display-table 160) [160]))) | |
160 | (standard-display-default 160 255) | |
798aa8d0 | 161 | (standard-display-8bit 160 255))) |
798aa8d0 | 162 | |
a2535589 | 163 | (provide 'disp-table) |
c0274f38 ER |
164 | |
165 | ;;; disp-table.el ends here |