annotate lisp/tl/char-util.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents 364816949b59
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
1 ;;; char-util.el --- character utility
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
2
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996,1997 MORIOKA Tomohiko
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
4
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
6 ;; Version: $Id: char-util.el,v 1.1 1997/01/30 02:27:29 steve Exp $
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
7 ;; Keywords: character, Emacs/mule
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
8
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
9 ;; This file is not part of tl (Tiny Library).
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
10
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
11 ;; This program is free software; you can redistribute it and/or
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
12 ;; modify it under the terms of the GNU General Public License as
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
13 ;; published by the Free Software Foundation; either version 2, or (at
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
14 ;; your option) any later version.
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
15
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
16 ;; This program is distributed in the hope that it will be useful, but
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
19 ;; General Public License for more details.
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
20
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
25
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
26 ;;; Code:
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
27
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
28 (defun row-line-to-char (r l)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
29 (int-char (+ (* r 16) l))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
30 )
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
31
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
32 (defun row-line-to-string (r l)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
33 (char-to-string (row-line-to-char r l))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
34 )
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
35
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
36 (defun print-row-line (r l)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
37 (interactive (and (looking-at "\\([0-9]+\\)/\\([0-9]+\\)")
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
38 (list (string-to-number
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
39 (buffer-substring (match-beginning 1)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
40 (match-end 1)))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
41 (string-to-number
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
42 (buffer-substring (match-beginning 2)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
43 (match-end 2)))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
44 )))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
45 (message (row-line-to-string r l))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
46 )
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
47
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
48 (defun char-to-row-line-form (chr)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
49 (setq chr (char-int chr))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
50 (format "%d/%d" (/ chr 16)(mod chr 16))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
51 )
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
52
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
53 (defun char-to-byte-list (chr)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
54 (let ((rest (mapcar (function identity)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
55 (char-to-string chr))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
56 ))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
57 (if (cdr rest)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
58 (cons (car rest)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
59 (mapcar (lambda (byte)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
60 (logand byte 127)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
61 )
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
62 (cdr rest)))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
63 (cons 'ascii rest)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
64 )))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
65
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
66 (defun char-to-row-cell-form (chr)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
67 (let ((cl (char-to-byte-list chr)))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
68 (if (= (length cl) 2)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
69 (char-to-row-line-form (nth 1 cl))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
70 (format "%02d-%02d" (- (nth 1 cl) 32)(- (nth 2 cl) 32))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
71 )))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
72
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
73 (defun show-char-info (char)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
74 (interactive (list (char-after (point))))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
75 (let ((cl (char-to-byte-list char)))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
76 (message (format "%s: %s %s"
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
77 (charset-description (car cl))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
78 (mapconcat (lambda (byte)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
79 (format "%02x" byte)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
80 )
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
81 (cdr cl) "")
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
82 (if (= (length cl) 2)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
83 (char-to-row-line-form (nth 1 cl))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
84 (format "%02d-%02d" (- (nth 1 cl) 32)(- (nth 2 cl) 32))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
85 )
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
86 ))))
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
87
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
88
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
89 ;;; @ end
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
90 ;;;
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
91
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
92 (provide 'char-util)
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
93
364816949b59 Import from CVS: tag r20-0b93
cvs
parents:
diff changeset
94 ;;; char-util.el ends here