-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtc-bitmap.el
97 lines (85 loc) · 3.38 KB
/
tc-bitmap.el
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
;;; tc-bitmap.el --- tc help display using bitmap-mule.
;; Copyright (C) 2001, 2002 YAGI Tatsuya
;; Author: YAGI Tatsuya <[email protected]>
;; Version: $Id: tc-bitmap.el,v 2.7 2002/08/17 01:52:19 kitajima Exp $
;; Maintainer: KITAJIMA Akira <[email protected]>
;; 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 of the License, 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 this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
;;; Code:
(require 'tc-help)
(require 'bitmap)
(defvar tc-bitmap-cache-file "tc-bitmap-8x16")
(defvar tc-bitmap-cache
(let* ((load-path (cons tcode-data-directory
(cons tcode-site-data-directory load-path)))
(file (locate-library tc-bitmap-cache-file t))
(top (with-temp-buffer
(insert-file-contents file)
(read (current-buffer))))
(l top))
(while l
(setcar (cdr (car l)) (compose-string (car (cdr (car l)))))
(setq l (cdr l)))
top))
(defun tc-bitmap-get-key-0 (key1 key2 &optional side)
(nth 1 (assoc (format "%s %s%s" (if side "side " "center")
(or key1 "/") (or key2 "/"))
tc-bitmap-cache)))
(defun tc-bitmap-get-key-1 (&optional key1 key2)
(let* ((l (list (tc-bitmap-get-key-0 nil nil t)
(tc-bitmap-get-key-0 nil nil t)
(tc-bitmap-get-key-0 nil nil nil)
(tc-bitmap-get-key-0 nil nil t)
(tc-bitmap-get-key-0 nil nil t)))
k1x k1y i k2x k2y j)
(if key1 (setq k1x (% key1 10) k1y (/ key1 10) i (/ k1x 2)))
(if key2 (setq k2x (% key2 10) k2y (/ key2 10) j (/ k2x 2)))
(if (and key1 (eq i j))
(setcar (nthcdr i l)
(tc-bitmap-get-key-0 (+ (* 4 (- k1x (* 2 i))) k1y)
(+ (* 4 (- k2x (* 2 j))) k2y)
(/= i 2)))
(if key1 (setcar (nthcdr i l)
(tc-bitmap-get-key-0 (+ (* 4 (- k1x (* 2 i))) k1y)
nil
(/= i 2))))
(if key2 (setcar (nthcdr j l)
(tc-bitmap-get-key-0 nil
(+ (* 4 (- k2x (* 2 j))) k2y)
(/= j 2)))))
(apply (function concat) l)))
(defun tc-bitmap-stroke-to-string (stroke)
(let ((lis (list tcode-stroke-to-string-opener)))
(let ((dat (tcode-stroke-prefix-match stroke)))
(when dat
(setq stroke (cdr dat))
(setcdr lis (list (nth 2 (car dat))))))
(while stroke
(cond ((<= 40 (car stroke))
(setq lis (cons (tcode-key-to-help-string (car stroke)) lis)
lis (cons tcode-stroke-to-string-separator lis)
stroke (cdr stroke)))
((and (nth 1 stroke)
(<= 40 (nth 1 stroke)))
(setq lis (cons (tc-bitmap-get-key-1 (car stroke))
lis)
lis (cons tcode-stroke-to-string-separator lis)
stroke (cdr stroke)))
(t
(setq lis (cons (tc-bitmap-get-key-1 (car stroke) (nth 1 stroke))
lis)
lis (cons tcode-stroke-to-string-separator lis)
stroke (cdr (cdr stroke))))))
(setq lis (cons tcode-stroke-to-string-closer (cdr lis)))
(apply (function concat) (nreverse lis))))
(provide 'tc-bitmap)
;;; tc-bitmap.el ends here