Mercurial > emacs
annotate lisp/disp-table.el @ 108270:d9345841fefd
* xterm.c (x_draw_image_relief): Move declaration of extra to beginning.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Thu, 06 May 2010 11:34:56 +0200 |
parents | 1d1d5d9bd884 |
children | 280c8ae2476d cca2a663ef92 |
rev | line source |
---|---|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
31157
diff
changeset
|
1 ;;; disp-table.el --- functions for dealing with char tables |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
74439 | 3 ;; Copyright (C) 1987, 1994, 1995, 1999, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
845 | 5 |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
6 ;; Author: Erik Naggum <erik@naggum.no> |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
7 ;; Based on a previous version by Howard Gayle |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
696
diff
changeset
|
8 ;; Maintainer: FSF |
3012
d4b85bbedee8
Change "i14n" keyword to "i18n".
Jim Blandy <jimb@redhat.com>
parents:
2628
diff
changeset
|
9 ;; Keywords: i18n |
36 | 10 |
11 ;; This file is part of GNU Emacs. | |
12 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92370
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
36 | 14 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92370
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92370
diff
changeset
|
16 ;; (at your option) any later version. |
36 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92370
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
36 | 25 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
31157
diff
changeset
|
26 ;;; Commentary: |
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
31157
diff
changeset
|
27 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
696
diff
changeset
|
28 ;;; Code: |
36 | 29 |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
30 (put 'display-table 'char-table-extra-slots 6) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
31 |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
32 ;;;###autoload |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
33 (defun make-display-table () |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
34 "Return a new, empty display table." |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
35 (make-char-table 'display-table nil)) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
36 |
58727
9a3bb995aa8b
Undo 2004-12-01 change. Display table is now
Kim F. Storm <storm@cua.dk>
parents:
58711
diff
changeset
|
37 (or standard-display-table |
9a3bb995aa8b
Undo 2004-12-01 change. Display table is now
Kim F. Storm <storm@cua.dk>
parents:
58711
diff
changeset
|
38 (setq standard-display-table (make-display-table))) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
39 |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
40 ;;; Display-table slot names. The property value says which slot. |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
41 |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
42 (put 'truncation 'display-table-slot 0) |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
43 (put 'wrap 'display-table-slot 1) |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
44 (put 'escape 'display-table-slot 2) |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
45 (put 'control 'display-table-slot 3) |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
46 (put 'selective-display 'display-table-slot 4) |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
47 (put 'vertical-border 'display-table-slot 5) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
48 |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
49 ;;;###autoload |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
50 (defun display-table-slot (display-table slot) |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
51 "Return the value of the extra slot in DISPLAY-TABLE named SLOT. |
13683
d628bf92f672
(display-table-slot,set-display-table-slot): Document the slot names.
Erik Naggum <erik@naggum.no>
parents:
13199
diff
changeset
|
52 SLOT may be a number from 0 to 5 inclusive, or a slot name (symbol). |
d628bf92f672
(display-table-slot,set-display-table-slot): Document the slot names.
Erik Naggum <erik@naggum.no>
parents:
13199
diff
changeset
|
53 Valid symbols are `truncation', `wrap', `escape', `control', |
d628bf92f672
(display-table-slot,set-display-table-slot): Document the slot names.
Erik Naggum <erik@naggum.no>
parents:
13199
diff
changeset
|
54 `selective-display', and `vertical-border'." |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
55 (let ((slot-number |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
56 (if (numberp slot) slot |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
57 (or (get slot 'display-table-slot) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
58 (error "Invalid display-table slot name: %s" slot))))) |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
59 (char-table-extra-slot display-table slot-number))) |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
60 |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
61 ;;;###autoload |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
62 (defun set-display-table-slot (display-table slot value) |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
63 "Set the value of the extra slot in DISPLAY-TABLE named SLOT to VALUE. |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
64 SLOT may be a number from 0 to 5 inclusive, or a name (symbol). |
13683
d628bf92f672
(display-table-slot,set-display-table-slot): Document the slot names.
Erik Naggum <erik@naggum.no>
parents:
13199
diff
changeset
|
65 Valid symbols are `truncation', `wrap', `escape', `control', |
d628bf92f672
(display-table-slot,set-display-table-slot): Document the slot names.
Erik Naggum <erik@naggum.no>
parents:
13199
diff
changeset
|
66 `selective-display', and `vertical-border'." |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
67 (let ((slot-number |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
68 (if (numberp slot) slot |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
69 (or (get slot 'display-table-slot) |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
70 (error "Invalid display-table slot name: %s" slot))))) |
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
71 (set-char-table-extra-slot display-table slot-number value))) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
72 |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
73 ;;;###autoload |
2072 | 74 (defun describe-display-table (dt) |
584 | 75 "Describe the display table DT in a help buffer." |
86009
80d1d625bb6f
(describe-display-table): Use with-help-window instead of with-output-to-temp-buffer.
Martin Rudalics <rudalics@gmx.at>
parents:
82140
diff
changeset
|
76 (with-help-window "*Help*" |
696
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
77 (princ "\nTruncation glyph: ") |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
78 (prin1 (display-table-slot dt 'truncation)) |
696
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
79 (princ "\nWrap glyph: ") |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
80 (prin1 (display-table-slot dt 'wrap)) |
696
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
81 (princ "\nEscape glyph: ") |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
82 (prin1 (display-table-slot dt 'escape)) |
696
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
83 (princ "\nCtrl glyph: ") |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
84 (prin1 (display-table-slot dt 'control)) |
2628
6b17fe69a82f
* disp-table.el (describe-display-table): Don't use the term
Jim Blandy <jimb@redhat.com>
parents:
2523
diff
changeset
|
85 (princ "\nSelective display glyph sequence: ") |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
86 (prin1 (display-table-slot dt 'selective-display)) |
8920
45e6d5476e7f
* disp-table.el: Add support for new window border display table
Jim Blandy <jimb@redhat.com>
parents:
7830
diff
changeset
|
87 (princ "\nVertical window border glyph: ") |
13199
9424e02a6e18
(display-table-slot, set-display-table-slot):
Richard M. Stallman <rms@gnu.org>
parents:
13164
diff
changeset
|
88 (prin1 (display-table-slot dt 'vertical-border)) |
2628
6b17fe69a82f
* disp-table.el (describe-display-table): Don't use the term
Jim Blandy <jimb@redhat.com>
parents:
2523
diff
changeset
|
89 (princ "\nCharacter display glyph sequences:\n") |
105994
009383a57ce8
* x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104698
diff
changeset
|
90 (with-current-buffer standard-output |
4936
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
91 (let ((vector (make-vector 256 nil)) |
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
92 (i 0)) |
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
93 (while (< i 256) |
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
94 (aset vector i (aref dt i)) |
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
95 (setq i (1+ i))) |
9856
fdd2f06a7d11
(describe-display-table): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
8920
diff
changeset
|
96 (describe-vector vector)) |
86009
80d1d625bb6f
(describe-display-table): Use with-help-window instead of with-output-to-temp-buffer.
Martin Rudalics <rudalics@gmx.at>
parents:
82140
diff
changeset
|
97 (help-mode)))) |
36 | 98 |
2072 | 99 ;;;###autoload |
36 | 100 (defun describe-current-display-table () |
4936
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
101 "Describe the display table in use in the selected window and buffer." |
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
102 (interactive) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
103 (let ((disptab (or (window-display-table (selected-window)) |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
104 buffer-display-table |
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
105 standard-display-table))) |
4936
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
106 (if disptab |
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
107 (describe-display-table disptab) |
35e9402cb6bf
(describe-current-display-table):
Richard M. Stallman <rms@gnu.org>
parents:
3061
diff
changeset
|
108 (message "No display table")))) |
36 | 109 |
2072 | 110 ;;;###autoload |
36 | 111 (defun standard-display-8bit (l h) |
584 | 112 "Display characters in the range L to H literally." |
52948
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
113 (or standard-display-table |
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
114 (setq standard-display-table (make-display-table))) |
36 | 115 (while (<= l h) |
74222
2a0693f1be07
(standard-display-8bit, standard-display-default): "?\ " -> "?\s".
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
116 (aset standard-display-table l (if (or (< l ?\s) (>= l 127)) (vector l))) |
36 | 117 (setq l (1+ l)))) |
118 | |
2072 | 119 ;;;###autoload |
3033
8bf84289be17
* disp-table.el (standard-display-default): New function.
Jim Blandy <jimb@redhat.com>
parents:
3012
diff
changeset
|
120 (defun standard-display-default (l h) |
8bf84289be17
* disp-table.el (standard-display-default): New function.
Jim Blandy <jimb@redhat.com>
parents:
3012
diff
changeset
|
121 "Display characters in the range L to H using the default notation." |
52948
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
122 (or standard-display-table |
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
123 (setq standard-display-table (make-display-table))) |
3033
8bf84289be17
* disp-table.el (standard-display-default): New function.
Jim Blandy <jimb@redhat.com>
parents:
3012
diff
changeset
|
124 (while (<= l h) |
90718 | 125 (if (and (>= l ?\s) (characterp l)) |
31157
cf90d4a5e3b2
(standard-display-default): Make the test of `l'
Dave Love <fx@gnu.org>
parents:
29510
diff
changeset
|
126 (aset standard-display-table l nil)) |
3033
8bf84289be17
* disp-table.el (standard-display-default): New function.
Jim Blandy <jimb@redhat.com>
parents:
3012
diff
changeset
|
127 (setq l (1+ l)))) |
8bf84289be17
* disp-table.el (standard-display-default): New function.
Jim Blandy <jimb@redhat.com>
parents:
3012
diff
changeset
|
128 |
10435
0f07f211973a
(standard-display-ascii): Doc fix. Allow use with X.
Karl Heuer <kwzh@gnu.org>
parents:
9856
diff
changeset
|
129 ;; This function does NOT take terminal-dependent escape sequences. |
0f07f211973a
(standard-display-ascii): Doc fix. Allow use with X.
Karl Heuer <kwzh@gnu.org>
parents:
9856
diff
changeset
|
130 ;; For that, you need to go through create-glyph. Use one of the |
0f07f211973a
(standard-display-ascii): Doc fix. Allow use with X.
Karl Heuer <kwzh@gnu.org>
parents:
9856
diff
changeset
|
131 ;; other functions below, or roll your own. |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
132 ;;;###autoload |
36 | 133 (defun standard-display-ascii (c s) |
10435
0f07f211973a
(standard-display-ascii): Doc fix. Allow use with X.
Karl Heuer <kwzh@gnu.org>
parents:
9856
diff
changeset
|
134 "Display character C using printable string S." |
52948
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
135 (or standard-display-table |
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
136 (setq standard-display-table (make-display-table))) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
137 (aset standard-display-table c (vconcat s))) |
36 | 138 |
2072 | 139 ;;;###autoload |
36 | 140 (defun standard-display-g1 (c sc) |
6418
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
141 "Display character C as character SC in the g1 character set. |
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
142 This function assumes that your terminal uses the SO/SI characters; |
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
143 it is meaningless for an X frame." |
97043
9592c50233ab
Remove support for Mac Carbon.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96675
diff
changeset
|
144 (if (memq window-system '(x w32 ns)) |
6418
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
145 (error "Cannot use string glyphs in a windowing system")) |
52948
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
146 (or standard-display-table |
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
147 (setq standard-display-table (make-display-table))) |
36 | 148 (aset standard-display-table c |
2523
76685b00c607
Use `vector', not `make-rope'.
Richard M. Stallman <rms@gnu.org>
parents:
2072
diff
changeset
|
149 (vector (create-glyph (concat "\016" (char-to-string sc) "\017"))))) |
36 | 150 |
2072 | 151 ;;;###autoload |
36 | 152 (defun standard-display-graphic (c gc) |
6418
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
153 "Display character C as character GC in graphics character set. |
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
154 This function assumes VT100-compatible escapes; it is meaningless for an |
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
155 X frame." |
97043
9592c50233ab
Remove support for Mac Carbon.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96675
diff
changeset
|
156 (if (memq window-system '(x w32 ns)) |
6418
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
157 (error "Cannot use string glyphs in a windowing system")) |
52948
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
158 (or standard-display-table |
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
159 (setq standard-display-table (make-display-table))) |
36 | 160 (aset standard-display-table c |
2523
76685b00c607
Use `vector', not `make-rope'.
Richard M. Stallman <rms@gnu.org>
parents:
2072
diff
changeset
|
161 (vector (create-glyph (concat "\e(0" (char-to-string gc) "\e(B"))))) |
36 | 162 |
2072 | 163 ;;;###autoload |
36 | 164 (defun standard-display-underline (c uc) |
165 "Display character C as character UC plus underlining." | |
52948
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
166 (or standard-display-table |
5044018cd79c
* disp-table.el (standard-display-8bit)
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
167 (setq standard-display-table (make-display-table))) |
36 | 168 (aset standard-display-table c |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41781
diff
changeset
|
169 (vector |
6418
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
170 (if window-system |
75873
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
171 (make-glyph-code uc 'underline) |
6418
43dea22be493
(standard-display-ascii): Error if using a windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6417
diff
changeset
|
172 (create-glyph (concat "\e[4m" (char-to-string uc) "\e[m")))))) |
36 | 173 |
2072 | 174 ;;;###autoload |
696
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
175 (defun create-glyph (string) |
29510 | 176 "Allocate a glyph code to display by sending STRING to the terminal." |
696
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
177 (if (= (length glyph-table) 65536) |
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
178 (error "No free glyph codes remain")) |
6417
81e96cd91613
(create-glyph): Don't use slots that look like ASCII.
Karl Heuer <kwzh@gnu.org>
parents:
4936
diff
changeset
|
179 ;; Don't use slots that correspond to ASCII characters. |
81e96cd91613
(create-glyph): Don't use slots that look like ASCII.
Karl Heuer <kwzh@gnu.org>
parents:
4936
diff
changeset
|
180 (if (= (length glyph-table) 32) |
81e96cd91613
(create-glyph): Don't use slots that look like ASCII.
Karl Heuer <kwzh@gnu.org>
parents:
4936
diff
changeset
|
181 (setq glyph-table (vconcat glyph-table (make-vector 224 nil)))) |
696
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
182 (setq glyph-table (vconcat glyph-table (list string))) |
904853a03d9a
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
662
diff
changeset
|
183 (1- (length glyph-table))) |
36 | 184 |
3061
1e0f5fb4fcf1
* disp-table.el (standard-display-european): Doc fix. Make
Jim Blandy <jimb@redhat.com>
parents:
3033
diff
changeset
|
185 ;;;###autoload |
75873
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
186 (defun make-glyph-code (char &optional face) |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
187 "Return a glyph code representing char CHAR with face FACE." |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
188 ;; Due to limitations on Emacs integer values, faces with |
90855
8c3bbc3bb044
(make-glyph-code): Fix for a new character code
Kenichi Handa <handa@m17n.org>
parents:
90854
diff
changeset
|
189 ;; face id greater that 512 are silently ignored. |
92284
7898dbba29fe
(make-glyph-code): Encode as cons if face id > 63.
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
190 (if (not face) |
7898dbba29fe
(make-glyph-code): Encode as cons if face id > 63.
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
191 char |
7898dbba29fe
(make-glyph-code): Encode as cons if face id > 63.
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
192 (let ((fid (face-id face))) |
92370
ec29b9d50b84
(make-glyph-code): Don't test the result of `face-id',
Juanma Barranquero <lekktu@gmail.com>
parents:
92284
diff
changeset
|
193 (if (< fid 64) ; we have 32 - 3(LSB) - 1(SIGN) - 22(CHAR) = 6 bits for face id |
ec29b9d50b84
(make-glyph-code): Don't test the result of `face-id',
Juanma Barranquero <lekktu@gmail.com>
parents:
92284
diff
changeset
|
194 (logior char (lsh fid 22)) |
ec29b9d50b84
(make-glyph-code): Don't test the result of `face-id',
Juanma Barranquero <lekktu@gmail.com>
parents:
92284
diff
changeset
|
195 (cons char fid))))) |
75873
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
196 |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
197 ;;;###autoload |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
198 (defun glyph-char (glyph) |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
199 "Return the character of glyph code GLYPH." |
92284
7898dbba29fe
(make-glyph-code): Encode as cons if face id > 63.
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
200 (if (consp glyph) |
7898dbba29fe
(make-glyph-code): Encode as cons if face id > 63.
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
201 (car glyph) |
7898dbba29fe
(make-glyph-code): Encode as cons if face id > 63.
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
202 (logand glyph #x3fffff))) |
75873
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
203 |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
204 ;;;###autoload |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
205 (defun glyph-face (glyph) |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
206 "Return the face of glyph code GLYPH, or nil if glyph has default face." |
92284
7898dbba29fe
(make-glyph-code): Encode as cons if face id > 63.
Kim F. Storm <storm@cua.dk>
parents:
91327
diff
changeset
|
207 (let ((face-id (if (consp glyph) (cdr glyph) (lsh glyph -22)))) |
75873
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
208 (and (> face-id 0) |
92370
ec29b9d50b84
(make-glyph-code): Don't test the result of `face-id',
Juanma Barranquero <lekktu@gmail.com>
parents:
92284
diff
changeset
|
209 (catch 'face |
ec29b9d50b84
(make-glyph-code): Don't test the result of `face-id',
Juanma Barranquero <lekktu@gmail.com>
parents:
92284
diff
changeset
|
210 (dolist (face (face-list)) |
ec29b9d50b84
(make-glyph-code): Don't test the result of `face-id',
Juanma Barranquero <lekktu@gmail.com>
parents:
92284
diff
changeset
|
211 (when (eq (face-id face) face-id) |
ec29b9d50b84
(make-glyph-code): Don't test the result of `face-id',
Juanma Barranquero <lekktu@gmail.com>
parents:
92284
diff
changeset
|
212 (throw 'face face))))))) |
75873
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
213 |
da8eab108281
(make-glyph-code, glyph-char, glyph-face): New defuns.
Kim F. Storm <storm@cua.dk>
parents:
75347
diff
changeset
|
214 ;;;###autoload |
26124
ee67b2340a0f
* disp-table.el (standard-display-european): Remove undocumented
Paul Eggert <eggert@twinsun.com>
parents:
24813
diff
changeset
|
215 (defun standard-display-european (arg) |
24813 | 216 "Semi-obsolete way to toggle display of ISO 8859 European characters. |
24116
cff6faa1cf82
(standard-display-european): Make all existing
Richard M. Stallman <rms@gnu.org>
parents:
22008
diff
changeset
|
217 |
104698
8d9497f0afc1
* NEWS: Declare unibyte sessions obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
218 This function is semi-obsolete; you probably don't need it, or else you |
8d9497f0afc1
* NEWS: Declare unibyte sessions obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
219 probably should use `set-language-environment' or `set-locale-environment'. |
24813 | 220 |
104698
8d9497f0afc1
* NEWS: Declare unibyte sessions obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
221 This function enables European character display if ARG is positive, |
8d9497f0afc1
* NEWS: Declare unibyte sessions obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
222 disables it if negative. Otherwise, it toggles European character display. |
22008
6182deb2d814
(standard-display-european): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
21992
diff
changeset
|
223 |
24813 | 224 When this mode is enabled, characters in the range of 160 to 255 |
225 display not as octal escapes, but as accented characters. Codes 146 | |
226 and 160 display as apostrophe and space, even though they are not the | |
227 ASCII codes for apostrophe and space. | |
19850
6bd245888f10
(standard-display-european): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19845
diff
changeset
|
228 |
24813 | 229 Enabling European character display with this command noninteractively |
104698
8d9497f0afc1
* NEWS: Declare unibyte sessions obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
230 from Lisp code also selects Latin-1 as the language environment. |
8d9497f0afc1
* NEWS: Declare unibyte sessions obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
231 This provides increased compatibility for users who call this function |
8d9497f0afc1
* NEWS: Declare unibyte sessions obsolete.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
232 in `.emacs'." |
19618
6ce60af61e81
(standard-display-european): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
19066
diff
changeset
|
233 |
7830
1f9ae5be19a2
(standard-display-european): Treat 0 arg like negative.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
234 (if (or (<= (prefix-numeric-value arg) 0) |
3061
1e0f5fb4fcf1
* disp-table.el (standard-display-european): Doc fix. Make
Jim Blandy <jimb@redhat.com>
parents:
3033
diff
changeset
|
235 (and (null arg) |
13164
79eba40cdf02
New implementation with char-tables.
Erik Naggum <erik@naggum.no>
parents:
10435
diff
changeset
|
236 (char-table-p standard-display-table) |
13822
cbc1f90ea367
(standard-display-european): Make 160 display as space.
Richard M. Stallman <rms@gnu.org>
parents:
13794
diff
changeset
|
237 ;; Test 161, because 160 displays as a space. |
13794
47cdd806fcfc
(standard-display-european): Test code 161, not 160.
Karl Heuer <kwzh@gnu.org>
parents:
13683
diff
changeset
|
238 (equal (aref standard-display-table 161) [161]))) |
19814
24d0221b94bc
(standard-display-european): Arg AUTO
Richard M. Stallman <rms@gnu.org>
parents:
19679
diff
changeset
|
239 (progn |
24d0221b94bc
(standard-display-european): Arg AUTO
Richard M. Stallman <rms@gnu.org>
parents:
19679
diff
changeset
|
240 (standard-display-default 160 255) |
97043
9592c50233ab
Remove support for Mac Carbon.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96675
diff
changeset
|
241 (unless (or (memq window-system '(x w32 ns))) |
24813 | 242 (and (terminal-coding-system) |
243 (set-terminal-coding-system nil)))) | |
65366
6cf54c411ff4
(standard-display-european): Don't set
Reiner Steib <Reiner.Steib@gmx.de>
parents:
64762
diff
changeset
|
244 |
6cf54c411ff4
(standard-display-european): Don't set
Reiner Steib <Reiner.Steib@gmx.de>
parents:
64762
diff
changeset
|
245 (display-warning 'i18n |
67284
f5f54b3e0a2f
(standard-display-european): Add to the warning message a reference to the
Eli Zaretskii <eliz@gnu.org>
parents:
66760
diff
changeset
|
246 "`standard-display-european' is semi-obsolete; see its doc string for details" |
65366
6cf54c411ff4
(standard-display-european): Don't set
Reiner Steib <Reiner.Steib@gmx.de>
parents:
64762
diff
changeset
|
247 :warning) |
41781
31aa13c921e0
(standard-display-european):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
248 |
31aa13c921e0
(standard-display-european):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
249 ;; Switch to Latin-1 language environment |
21855
be75888c203f
(standard-display-european): Use set-language-environment
Richard M. Stallman <rms@gnu.org>
parents:
21262
diff
changeset
|
250 ;; unless some other has been specified. |
41781
31aa13c921e0
(standard-display-european):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
251 (if (equal current-language-environment "English") |
31aa13c921e0
(standard-display-european):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
252 (set-language-environment "latin-1")) |
97043
9592c50233ab
Remove support for Mac Carbon.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96675
diff
changeset
|
253 (unless (or noninteractive (memq window-system '(x w32 ns))) |
26124
ee67b2340a0f
* disp-table.el (standard-display-european): Remove undocumented
Paul Eggert <eggert@twinsun.com>
parents:
24813
diff
changeset
|
254 ;; Send those codes literally to a character-based terminal. |
ee67b2340a0f
* disp-table.el (standard-display-european): Remove undocumented
Paul Eggert <eggert@twinsun.com>
parents:
24813
diff
changeset
|
255 ;; If we are using single-byte characters, |
ee67b2340a0f
* disp-table.el (standard-display-european): Remove undocumented
Paul Eggert <eggert@twinsun.com>
parents:
24813
diff
changeset
|
256 ;; it doesn't matter which coding system we use. |
19920
1d832fd69760
(standard-display-european): Do something useful where AUTO is t or a symbol.
Richard M. Stallman <rms@gnu.org>
parents:
19850
diff
changeset
|
257 (set-terminal-coding-system |
26124
ee67b2340a0f
* disp-table.el (standard-display-european): Remove undocumented
Paul Eggert <eggert@twinsun.com>
parents:
24813
diff
changeset
|
258 (let ((c (intern (downcase current-language-environment)))) |
ee67b2340a0f
* disp-table.el (standard-display-european): Remove undocumented
Paul Eggert <eggert@twinsun.com>
parents:
24813
diff
changeset
|
259 (if (coding-system-p c) c 'latin-1)))) |
21855
be75888c203f
(standard-display-european): Use set-language-environment
Richard M. Stallman <rms@gnu.org>
parents:
21262
diff
changeset
|
260 (standard-display-european-internal))) |
3033
8bf84289be17
* disp-table.el (standard-display-default): New function.
Jim Blandy <jimb@redhat.com>
parents:
3012
diff
changeset
|
261 |
36 | 262 (provide 'disp-table) |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
263 |
81075
8520ffa982fc
(standard-display-european): Docstring fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75873
diff
changeset
|
264 ;; arch-tag: ffe4c28c-960c-47aa-b8a8-ae89d371ffc7 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
265 ;;; disp-table.el ends here |