*** 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
03131799 22;; Written by Howard Gayle.
a2535589
JA
23
24(defun rope-to-vector (rope)
25 (let* ((len (/ (length rope) 2))
26 (vector (make-vector len nil))
27 (i 0))
28 (while (< i len)
29 (aset vector i (rope-elt rope i))
30 (setq i (1+ i)))))
31
32(defun describe-display-table (DT)
49116ac0 33 "Describe the display table DT in a help buffer."
a2535589 34 (with-output-to-temp-buffer "*Help*"
03131799 35 (princ "\nTruncation glyph: ")
a2535589 36 (prin1 (aref dt 256))
03131799 37 (princ "\nWrap glyph: ")
a2535589 38 (prin1 (aref dt 257))
03131799 39 (princ "\nEscape glyph: ")
a2535589 40 (prin1 (aref dt 258))
03131799 41 (princ "\nCtrl glyph: ")
a2535589
JA
42 (prin1 (aref dt 259))
43 (princ "\nSelective display rope: ")
44 (prin1 (rope-to-vector (aref dt 260)))
45 (princ "\nCharacter display ropes:\n")
46 (let ((vector (make-vector 256 nil))
47 (i 0))
48 (while (< i 256)
49 (aset vector i
50 (if (stringp (aref dt i))
51 (rope-to-vector (aref dt i))
52 (aref dt i)))
53 (setq i (1+ i)))
54 (describe-vector vector))
55 (print-help-return-message)))
56
57(defun describe-current-display-table ()
49116ac0 58 "Describe the display table in use in the selected window and buffer."
a2535589
JA
59 (interactive)
60 (describe-display-table
61 (or (window-display-table (selected-window))
62 buffer-display-table
63 standard-display-table)))
64
65(defun make-display-table ()
66 (make-vector 261 nil))
67
68(defun standard-display-8bit (l h)
49116ac0 69 "Display characters in the range L to H literally."
a2535589
JA
70 (while (<= l h)
71 (if (and (>= l ?\ ) (< l 127))
72 (if standard-display-table (aset standard-display-table l nil))
73 (or standard-display-table
74 (setq standard-display-table (make-vector 261 nil)))
75 (aset standard-display-table l l))
76 (setq l (1+ l))))
77
78(defun standard-display-ascii (c s)
79 "Display character C using string S."
80 (or standard-display-table
81 (setq standard-display-table (make-vector 261 nil)))
82 (aset standard-display-table c (apply 'make-rope (append s nil))))
83
84(defun standard-display-g1 (c sc)
85 "Display character C as character SC in the g1 character set."
86 (or standard-display-table
87 (setq standard-display-table (make-vector 261 nil)))
88 (aset standard-display-table c
03131799 89 (make-rope (create-glyph (concat "\016" (char-to-string sc) "\017")))))
a2535589
JA
90
91(defun standard-display-graphic (c gc)
92 "Display character C as character GC in graphics character set."
93 (or standard-display-table
94 (setq standard-display-table (make-vector 261 nil)))
95 (aset standard-display-table c
03131799 96 (make-rope (create-glyph (concat "\e(0" (char-to-string gc) "\e(B")))))
a2535589
JA
97
98(defun standard-display-underline (c uc)
99 "Display character C as character UC plus underlining."
100 (or standard-display-table
101 (setq standard-display-table (make-vector 261 nil)))
102 (aset standard-display-table c
03131799
RS
103 (make-rope (create-glyph (concat "\e[4m" (char-to-string uc) "\e[m")))))
104
105;; Allocate a glyph code to display by sending STRING to the terminal.
106(defun create-glyph (string)
107 (if (= (length glyph-table) 65536)
108 (error "No free glyph codes remain"))
109 (setq glyph-table (vconcat glyph-table (list string)))
110 (1- (length glyph-table)))
a2535589
JA
111
112(provide 'disp-table)
c0274f38
ER
113
114;;; disp-table.el ends here