File: char-table.el

package info (click to toggle)
xemacs20 20.4-13
  • links: PTS
  • area: main
  • in suites: slink
  • size: 67,324 kB
  • ctags: 57,643
  • sloc: lisp: 586,197; ansic: 184,662; sh: 4,296; asm: 3,179; makefile: 2,021; perl: 1,059; csh: 96; sed: 22
file content (190 lines) | stat: -rw-r--r-- 5,154 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
;;; char-table.el --- display table of charset

;; Copyright (C) 1996,1997 MORIOKA Tomohiko

;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;; Version: $Id: char-table.el,v 3.4 1997/06/29 05:05:23 morioka Exp $
;; Keywords: character, mule

;; This file is part of tl (Tiny Library).

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.

;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Code:

(defsubst char-position-to-string (charset r l &optional plane)
  (char-to-string
   (if plane
       (make-char charset plane (+ (* r 16) l))
     (make-char charset (+ (* r 16) l))
     )))

(defsubst char-table-1 (charset r l plane)
  (let* ((str (char-position-to-string charset r l plane))
	 (lp (- 3 (string-width str)))
	 (rp (/ lp 2)))
    (setq lp
	  (if (= (mod lp 2) 0)
	      rp
	    (1+ rp)))
    (concat (make-string lp ? ) str (make-string rp ? ))
    ))

(defun insert-94-charset-table (charset &optional plane ofs)
  (if (null ofs)
      (setq ofs 0)
    )
  (insert (format
	  "[%02x]└3柑 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n"
	  (or plane 0)))
  (insert "──┼────────────────────────\n")
  (let ((j 2))
    (insert (format "%02x%x└3柑   " (or plane 0) (* (+ j ofs) 16)))
    (let ((k 1))
      (while (< k 16)
	(insert (char-table-1 charset j k plane))
	(setq k (+ k 1))
	)
      (insert "\n")
      )
    (setq j 3)
    (while (< j 7)
      (insert (format "%02x%x└3柑" (or plane 0) (* (+ j ofs) 16)))
      (let ((k 0))
	(while (< k 16)
	  (insert (char-table-1 charset j k plane))
	  (setq k (+ k 1))
	  )
	(insert "\n")
	)
      (setq j (+ j 1))
      )
    (insert (format "%02x%x└3柑" (or plane 0) (* (+ j ofs) 16)))
    (let ((k 0))
      (while (< k 15)
	(insert (char-table-1 charset j k plane))
	(setq k (+ k 1))
	)
      (insert "\n")
      )
    ))

(defun insert-96-charset-table (charset &optional plane ofs)
  (if (null ofs)
      (setq ofs 0)
    )
  (insert (format
	  "[%02x]└3柑 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n"
	  (or plane 0)))
  (insert "──┼────────────────────────\n")
  (let ((j 2))
    (while (< j 8)
      (insert (format "%02x%x└3柑" (or plane 0) (* (+ j ofs) 16)))
      (let ((k 0))
	(while (< k 16)
	  (insert (char-table-1 charset j k plane))
	  (setq k (+ k 1))
	  )
	(insert "\n")
	)
      (setq j (1+ j))
      )))

(defun insert-94x94-charset-table (charset)
  (insert-94-charset-table charset 33)
  (let ((i 34))
    (while (< i 127)
      (insert "━━┿━━━━━━━━━━━━━━━━━━━━━━━━\n")
      (insert-94-charset-table charset i)
      (setq i (1+ i))
      )))

(defun insert-96x96-charset-table (charset)
  (insert-96-charset-table charset 32)
  (let ((i 33))
    (while (< i 128)
      (insert "━━┿━━━━━━━━━━━━━━━━━━━━━━━━\n")
      (insert-96-charset-table charset i)
      (setq i (1+ i))
      )))

(defun insert-charset-table (charset)
  "Insert character table of CHARSET."
  (insert "━━┯━━━━━━━━━━━━━━━━━━━━━━━━\n")
  (let ((cc (charset-chars charset))
	(cd (charset-dimension charset))
	)
    (cond ((= cd 1)
	   (cond ((= cc 94)
		  (insert-94-charset-table charset)
		  )
		 ((= cc 96)
		  (insert-96-charset-table charset)
		  ))
	   )
	  ((= cd 2)
	   (cond ((= cc 94)
		  (insert-94x94-charset-table charset)
		  )
		 ((= cc 96)
		  (insert-96x96-charset-table charset)
		  ))
	   )))
  (insert "━━┷━━━━━━━━━━━━━━━━━━━━━━━━\n")
  )

;;;###autoload
(defun view-charset (charset)
  "Display character table of CHARSET."
  (interactive
   (list
    (let ((charset-alist
	   (mapcar (function
		    (lambda (charset)
		      (cons (charset-doc-string charset) charset)
		      ))
		   (charset-list))))
      (cdr (assoc (completing-read "What charset: "
				   charset-alist nil t nil)
		  charset-alist))
      )))
  (let* ((desc (charset-doc-string charset))
	 (buf (concat "*Charset table for "
		      (charset-doc-string charset)
		      "*")))
    (unless (get-buffer buf)
      (let ((the-buf (current-buffer)))
	(set-buffer (get-buffer-create buf))
	(insert (format "%s (%s)\n" desc charset))
	(let ((msg (format "Generating char table for %s..." desc)))
	  (message msg)
	  (insert-charset-table charset)
	  (message "%s Done." msg)
	  )
	(set-buffer-modified-p nil)
	(goto-char (point-min))
	(set-buffer the-buf)
	))
    (view-buffer buf)
    ))


;;; @ end
;;;

(provide 'char-table)

;;; char-table.el ends here