1 ;;; disp-table.el --- functions for dealing with char tables.
3 ;; Copyright (C) 1987, 1994, 1997 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995 Sun Microsystems.
6 ;; Author: Howard Gayle
7 ;; Maintainer: XEmacs Development Team
8 ;; Keywords: i18n, internal
10 ;; This file is part of XEmacs.
12 ;; XEmacs is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; XEmacs is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
27 ;;; Synched up with: Not synched with FSF.
31 ;; #### Need lots of work. make-display-table depends on a value
32 ;; that is a define in the C code. Maybe we should just move the
35 ;; #### display-tables-as-vectors is really evil and a big pain in
38 ;; Rewritten for XEmacs July 1995, Ben Wing.
43 (defun describe-display-table (dt)
44 "Describe the display table DT in a help buffer."
45 (with-displaying-help-buffer
47 (princ "\nCharacter display glyph sequences:\n")
49 (let ((vector (make-vector 256 nil))
52 (aset vector i (aref dt i))
54 ;; FSF calls `describe-vector' here, but it is so incredibly
55 ;; lame a function for that name that I cannot bring myself
56 ;; to porting it. Here is what `describe-vector' does:
58 (let ((old (aref vector 0))
64 (not (equal old (aref vector i))))
65 (if (eq oldpos (1- i))
66 (princ (format "%s\t\t%s\n"
67 (single-key-description (int-char oldpos))
69 (setq str (format "%s - %s"
70 (single-key-description (int-char oldpos))
71 (single-key-description (int-char (1- i)))))
73 (princ (make-string (max (- 2 (/ (length str)
78 (setq old (aref vector i)
83 (defun describe-current-display-table (&optional domain)
84 "Describe the display table in use in the selected window and buffer."
86 (or domain (setq domain (selected-window)))
87 (let ((disptab (specifier-instance current-display-table domain)))
89 (describe-display-table disptab)
90 (message "No display table"))))
93 (defun make-display-table ()
94 "Return a new, empty display table."
95 (make-vector 256 nil))
97 ;; #### we need a generic frob-specifier function.
98 ;; #### this also needs to be redone like frob-face-property.
100 ;; Let me say one more time how much dynamic scoping sucks.
102 (defun frob-display-table (fdt-function fdt-locale)
103 (or fdt-locale (setq fdt-locale 'global))
104 (or (specifier-spec-list current-display-table fdt-locale)
105 (add-spec-to-specifier current-display-table (make-display-table)
107 (add-spec-list-to-specifier
108 current-display-table
109 (list (cons fdt-locale
112 (funcall fdt-function (cdr fdt-x))
114 (cdar (specifier-spec-list current-display-table
117 (defun standard-display-8bit-1 (dt l h)
119 (aset dt l (char-to-string l))
123 (defun standard-display-8bit (l h &optional locale)
124 "Display characters in the range L to H literally."
127 (standard-display-8bit-1 x l h))
130 (defun standard-display-default-1 (dt l h)
136 (defun standard-display-default (l h &optional locale)
137 "Display characters in the range L to H using the default notation."
140 (standard-display-default-1 x l h))
144 (defun standard-display-ascii (c s &optional locale)
145 "Display character C using printable string S."
152 ;;; #### should frob in a 'tty locale.
155 (defun standard-display-g1 (c sc &optional locale)
156 "Display character C as character SC in the g1 character set.
157 This function assumes that your terminal uses the SO/SI characters;
158 it is meaningless for an X frame."
161 (aset x c (concat "\016" (char-to-string sc) "\017")))
165 ;;; #### should frob in a 'tty locale.
168 (defun standard-display-graphic (c gc &optional locale)
169 "Display character C as character GC in graphics character set.
170 This function assumes VT100-compatible escapes; it is meaningless for an
174 (aset x c (concat "\e(0" (char-to-string gc) "\e(B")))
177 ;;; #### should frob in a 'tty locale.
178 ;;; #### the FSF equivalent of this makes this character be displayed
179 ;;; in the 'underline face. There's no current way to do this with
180 ;;; XEmacs display tables.
183 (defun standard-display-underline (c uc &optional locale)
184 "Display character C as character UC plus underlining."
187 (aset x c (concat "\e[4m" (char-to-string uc) "\e[m")))
191 (defun standard-display-european (arg &optional locale)
192 "Toggle display of European characters encoded with ISO 8859.
193 When enabled, characters in the range of 160 to 255 display not
194 as octal escapes, but as accented characters.
195 With prefix argument, enable European character display iff arg is positive."
199 (if (or (<= (prefix-numeric-value arg) 0)
201 (equal (aref x 160) (char-to-string 160))))
202 (standard-display-default-1 x 160 255)
203 (standard-display-8bit-1 x 160 255)))
206 (provide 'disp-table)
208 ;;; disp-table.el ends here