This file is indexed.

/usr/share/emacs/site-lisp/t-code/tc-help.el is in t-code 2:2.3.1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
;;; tc-help.el --- help routines for T-Code

;; Copyright (C) 1997-2001 Kaoru Maeda, Yasushi Saito and Akira Kitajima.

;; Author: Kaoru Maeda <maeda@src.ricoh.co.jp>
;;	Yasushi Saito <yasushi@cs.washington.edu>
;;	Akira Kitajima <kitajima@isc.osakac.ac.jp>
;; Maintainer: Akira Kitajima
;; Created: 3 Apr 1997
;; Version: $Id: tc-help.el,v 1.36 2003/03/21 03:44:48 kitajima Exp $

;; 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-bushu)

;;;; ÊÑ¿ô

(defvar tcode-strict-help t
  "* non-nil ¤Î¤È¤­¡¢Éô¼óÊÑ´¹¤Ë¤è¤êÆþÎϤ¬¤Ç¤­¤ë¤«¤É¤¦¤«¤ò¾Ü¤·¤¯Ä´¥Ù¤ë¡£
nil ¤Î¾ì¹ç¤Ç¤Ï¸«¤Ä¤«¤é¤Ê¤¤¤è¤¦¤Ê¾ì¹ç¤Ç¤â¡¢non-nil ¤Ë¤¹¤ì¤Ð¸«¤Ä¤«¤ë¾ì¹ç¤¬
¤¢¤ë¡£¤¿¤À¤·¡¢¤«¤Ê¤ê»þ´Ö¤¬¤«¤«¤ë¤³¤È¤â¤¢¤ë¡£")

(defvar tcode-help-first-stroke "¡ü"
  "* ¥Ø¥ë¥×ɽ¤ÇÂè1ÂǸ°°ÌÃÖ¤òɽ¤¹Ê¸»ú")
(defvar tcode-help-second-stroke "¡û"
  "* ¥Ø¥ë¥×ɽ¤ÇÂè2ÂǸ°°ÌÃÖ¤òɽ¤¹Ê¸»ú")
(defvar tcode-help-third-stroke "¢¤"
  "* ¥Ø¥ë¥×ɽ¤ÇÂè3ÂǸ°°ÌÃÖ¤òɽ¤¹Ê¸»ú")
(defvar tcode-help-forth-stroke "¡þ"
  "* ¥Ø¥ë¥×ɽ¤ÇÂè4ÂǸ°°ÌÃÖ¤òɽ¤¹Ê¸»ú")
(defvar tcode-help-double-stroke "¡ý"
  "* ¥Ø¥ë¥×ɽ¤ÇÊ£¿ô²ó¤³¤Î°ÌÃÖ¤ò²¡¤¹¤³¤È¤òɽ¤¹Ê¸»ú")
(defvar tcode-help-another-double-stroke "¡ù"
  "* ¥Ø¥ë¥×ɽ¤ÇÊ£¿ô²ó¤³¤Î°ÌÃÖ¤ò²¡¤¹¤³¤È¤òɽ¤¹Ê¸»ú¡£
`tcode-help-double-stroke' ¤ò´û¤Ë»ÈÍѤ·¤Æ¤¤¤ë¾ì¹ç¤Ë»ÈÍѤ¹¤ë¡£")

(defvar tcode-help-draw-top-keys t
  "* ¥¹¥È¥í¡¼¥¯É½¤ÇºÇ¾åÃʤΥ­¡¼¤òɽ¼¨¤¹¤ë¤«")

(defvar tcode-last-help-char-list nil
  "ºÇ¸å¤Ë¥Ø¥ë¥×¤òɽ¼¨¤·¤¿Ê¸»ú¤Î¥ê¥¹¥È")

(defvar tcode-help-with-real-keys nil
  "* nil¤Ç¤Ê¤¤¾ì¹ç¡¢É½·Á¼°¤Ç¤Ï¤Ê¤¯¡¢¥­¡¼ÆþÎϽç·Á¼°¤Ë¤è¤ë¤Ø¥ë¥×ɽ¼¨¤ò¹Ô¤¦¡£")

(defvar tcode-stroke-to-string-option t
  "*`tcode-stroke-to-string'¤òÀ©¸æ¤¹¤ëÊÑ¿ô")
(defvar tcode-stroke-to-string-opener ""
  "*`tcode-stroke-to-string'¤Ç»È¤ï¤ì¤ë³«»Ïʸ»úÎó")
(defvar tcode-stroke-to-string-separator ""
  "*`tcode-stroke-to-string'¤Ç»È¤ï¤ì¤ëʬ³äʸ»úÎó")
(defvar tcode-stroke-to-string-closer ""
  "*`tcode-stroke-to-string'¤Ç»È¤ï¤ì¤ë½ªÎ»Ê¸»úÎó")

(defcustom tcode-help-stroke-hook nil
  "¥Ø¥ë¥×ɽ¤òɽ¼¨¤¹¤ëÁ°¤Ë¼Â¹Ô¤µ¤ì¤ë¥Õ¥Ã¥¯¡£"
  :type 'hook :group 'tcode)

;;;
;;; ¥â¡¼¥É¤Î¥Ø¥ë¥×
;;;

;;;###autoload
(defun tcode-mode-help ()
  "T¥³¡¼¥É¥â¡¼¥É¤Î¥­¡¼³ä¤êÅö¤Æ¤Ê¤É¤òɽ¼¨¤¹¤ë¡£"
  (interactive)
  (let ((buf (get-buffer-create " *T-Code Mode Help*")))
    (set-buffer buf)
    (erase-buffer)
    (if tcode-mode-help-string
	(insert (substitute-command-keys tcode-mode-help-string))
      (insert (documentation 'tcode-activate))
      (goto-char (point-min))
      (forward-line 1)
      (narrow-to-region (point) (point-max)))
    (tcode-display-help-buffer buf)
    (kill-buffer buf)))

;;;
;;; Éô¼ó¹çÀ®ÊÑ´¹¤Î¤Ø¥ë¥×
;;;

(defun tcode-bushu-help-lookup (str)
  (save-excursion
    (tcode-set-work-buffer tcode-bushu-help-buffer-name
			   tcode-bushu-help-dictionary-name
			   nil t)
    (goto-char (point-min))
    (if (re-search-forward (format "^%s\\(.\\)\\(.\\)\\*?\n"
				   (regexp-quote str))
			   nil t)
	(cons (buffer-substring (match-beginning 1)
				(match-end 1))
	      (buffer-substring (match-beginning 2)
				(match-end 2))))))

(defun tcode-bushu-composed-p (char bushu1 bushu2)
  "CHAR¤¬BUSHU1¤ÈBUSHU2¤Ç¹çÀ®¤Ç¤­¤ë¤«¡£
Àµ³Î¤Ë¤Ï¡¢BUSHU1¤ÈBUSHU2¤ÏξÊý¤È¤âľÀÜÆþÎϤǤ­¤Ê¤¤¤È¤¤¤±¤Ê¤¤¡£"
  (and (or (null tcode-strict-help)
	   (and (tcode-encode bushu1)
		(tcode-encode bushu2)))
       (let ((composed (tcode-bushu-compose-two-chars bushu1 bushu2)))
	 (and composed
	      (= composed (tcode-string-to-char char))))))

(defun tcode-decompose-to-two-char (char)
  (let* ((str (char-to-string char))
	 (b1 (tcode-bushu-for-char char))
	 (b2 (list (car b1))))
    (catch 'found
      (while (setq b1 (cdr b1))
	(let ((cl1 (or (tcode-char-list-for-bushu b2)
		       (if (= (length b2) 1)
			   b2)))
	      (cl2 (or (tcode-char-list-for-bushu b1)
		       (if (= (length b1) 1)
			   b1))))
	  (mapcar (lambda (c1)
		    (mapcar (lambda (c2)
			      (if (= (tcode-bushu-compose-two-chars c1 c2)
				     char)
				  (throw 'found (cons c1 c2))))
			    cl2))
		  cl1))
	(setq b2 (nconc b2 (list (car b1))))))))

(defun tcode-decompose-char (kanji &optional for-help)
  "KANJI¤òÆó¤Ä¤ÎÉô¼ó¤Ëʬ²ò¤¹¤ë¡£
ÊÖ¤êÃͤÏÆó¤Ä¤Î»ú¤ò `cons' ¤·¤¿¥»¥ë¡£
ʬ²ò¤Ç¤­¤Ê¤¤»þ¤Ë¤Ïnil¤òÊÖ¤¹¡£
FOR-HELP¤¬nil¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢Ä¾ÀÜÆþÎϤǤ­¤ë»ú¤Ëʬ²ò¤¹¤ë¡£"
  (tcode-bushu-init 2)
  (save-excursion
    (tcode-set-work-buffer tcode-bushu-help-buffer-name
			   tcode-bushu-help-dictionary-name
			   nil t))
  (let* ((char (tcode-string-to-char kanji))
	 (decomposed (tcode-decompose-to-two-char char)))
    (if decomposed
	(if for-help
	    (let* ((char1 (car decomposed))
		   (char2 (cdr decomposed))
		   (str1 (char-to-string char1))
		   (str2 (char-to-string char2)))
	      (cond ((tcode-encode char1)
		     (if (tcode-encode char2)
			 (cons str1 str2)
		       (let ((bushu-list (tcode-bushu-for-char
					  (cdr decomposed))))
			 (catch 'found
			   ;; ¶¯¹çÀ®½¸¹ç¤òõ¤¹¡£
			   (mapcar
			    (lambda (c)
			      (if (tcode-bushu-composed-p kanji
							  (car decomposed)
							  c)
				  (throw 'found (cons str1
						      (char-to-string c)))))
			    (sort (tcode-bushu-subset bushu-list)
				  'tcode-bushu-less-p))
			   ;; ¼å¹çÀ®½¸¹ç¤òõ¤¹¡£
			   (mapcar
			    (lambda (c)
			      (if (tcode-bushu-composed-p kanji
							  (car decomposed)
							  c)
				  (throw 'found (cons str1
						      (char-to-string c)))))
			    (sort (tcode-bushu-superset bushu-list)
				  'tcode-bushu-less-p))
			   ;; ºÆµ¢Åª¤Ëõ¤¹¡£
			   (let ((dec2 (tcode-decompose-char str2 t)))
			     (if dec2
				 (cons str1 dec2)
			       (cons str1 (cons dec2 nil))))))))
		    ((tcode-encode char2)
		     (let ((bushu-list (tcode-bushu-for-char
					(car decomposed))))
		       (catch 'found
			 ;; ¶¯¹çÀ®½¸¹ç¤òõ¤¹¡£
			 (mapcar
			  (lambda (c)
			    (if (tcode-bushu-composed-p kanji
							c
							(cdr decomposed))
				(throw 'found (cons (char-to-string c)
						    str2))))
			  (sort (tcode-bushu-subset bushu-list)
				'tcode-bushu-less-p))
			 ;; ¼å¹çÀ®½¸¹ç¤òõ¤¹¡£
			 (mapcar
			  (lambda (c)
			    (if (tcode-bushu-composed-p kanji
							c
							(cdr decomposed))
				(throw 'found (cons (char-to-string c)
						    str2))))
			  (sort (tcode-bushu-superset bushu-list)
				'tcode-bushu-less-p))
			 ;; ºÆµ¢Åª¤Ëõ¤¹¡£
			 (let ((dec1 (tcode-decompose-char str1 t)))
			   (if dec1
			       (cons dec1 str2)
			     (cons (cons str1 nil) str2))))))
		    (t
		     (let* ((bushu1 (tcode-bushu-for-char (car decomposed)))
			    (bushu2 (tcode-bushu-for-char (cdr decomposed)))
			    (bushu-list (append bushu1 bushu2))
			    (cl1 (tcode-uniq
				  (sort
				   (nconc (tcode-bushu-subset bushu1)
					  (tcode-bushu-superset bushu1))
				   'tcode-bushu-less-p)))
			    (cl2 (tcode-uniq
				  (sort
				   (nconc (tcode-bushu-subset bushu2)
					  (tcode-bushu-superset bushu2))
				   'tcode-bushu-less-p))))
		       (catch 'found
			 (mapcar
			  (lambda (c1)
			    (mapcar
			     (lambda (c2)
			       (if (tcode-bushu-composed-p kanji c1 c2)
				   (throw 'found
					  (cons (char-to-string c1)
						(char-to-string c2)))))
			     cl2))
			  cl1)
			 (let ((d1 (tcode-decompose-char str1 t))
			       (d2 (tcode-decompose-char str2 t)))
			   (cons (or d1 (cons str1 nil))
				 (or d2 (cons str2 nil)))))))))
	  (cons (char-to-string (car decomposed))
		(char-to-string (cdr decomposed))))
      ;; Æó¤Ä¤Ëʬ³ä¤Ç¤­¤Ê¤¤¾ì¹ç
      (if for-help
	  ;; ¶¯º¹¹çÀ®½¸¹ç¤òõ¤¹¡£
	  (let ((bushu-list (tcode-bushu-for-char char)))
	    (catch 'found
	      (mapcar
	       (lambda (c)
		 (when (tcode-encode c)
		   (let ((diff (tcode-subtract-set (tcode-bushu-for-char c)
						   bushu-list)))
		     (mapcar (lambda (d)
			       (if (tcode-bushu-composed-p kanji c d)
				   (throw 'found
					  (cons (char-to-string c)
						(char-to-string d)))))
			     (tcode-bushu-subset diff)))))
	       (sort (tcode-bushu-superset bushu-list)
		     'tcode-bushu-less-p))
	      (cons kanji nil)))))))

(defun tcode-stroke-to-string (stroke)
  "STROKE ¤òɽ¤¹Ã»¤¤Ê¸»úÎó¤òÊÖ¤¹¡£
`tcode-stroke-to-string-opener'¤Ç»Ï¤Þ¤ê¡¢
`tcode-stroke-to-string-separator'¤ò¶èÀÚ¤ê¤È¤·¡¢
`tcode-stroke-to-string-closer'¤Ç½ª¤ï¤ë¡£

`tcode-stroke-to-string-option'¤Ë¤è¤ê¥¹¥È¥í¡¼¥¯É½¤¹Ê¸»úÎó¤¬ÊѤï¤ë¡£
  nil ¤Î»þ¤Ï2·å¤Î¿ô»ú¤Çɽ¤¹¡£
  t ¤Î»þ¤Ï tcode-mode ¤Ç¤Ê¤¤»þ¤ËÆþÎϤµ¤ì¤ëʸ»ú¤Çɽ¤¹¡£
  vector ¤Î»þ¤ÏÍ×ÁǤòÍøÍѤ¹¤ë¡£
  ´Ø¿ô¤Î»þ¤Ï¤½¤Î´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¡£"
  (if (functionp tcode-stroke-to-string-option)
      (funcall tcode-stroke-to-string-option stroke)
    (concat tcode-stroke-to-string-opener
	    (mapconcat
	     (cond ((eq t tcode-stroke-to-string-option)
		    (lambda (addr) (char-to-string (tcode-key-to-char addr))))
		   ((vectorp tcode-stroke-to-string-option)
		    (lambda (addr) (aref tcode-stroke-to-string-option addr)))
		   (t (lambda (addr) (format "%02d" addr))))
	     stroke tcode-stroke-to-string-separator)
	    tcode-stroke-to-string-closer)))

(defun tcode-help-make-bushu-structure-string (str root)
  (cond ((null str)
	 nil)
	((stringp str)
	 (if tcode-help-with-real-keys
	     (let ((strokes (tcode-encode (tcode-string-to-char str))))
	       (if strokes
		   (tcode-stroke-to-string strokes)
		 str))
	   str))
	((listp str)
	 (let ((left (tcode-help-make-bushu-structure-string (car str) nil))
	       (right (tcode-help-make-bushu-structure-string (cdr str) nil)))
	   (if right
	       (format (if root "%s + %s" "(%s + %s)") left right)
	     (concat "[" left "]"))))))

(defun tcode-help-bushu-help-string (ch for-help)
  "ʸ»úCH¤Î¡¢Éô¼ó¹çÀ®ÊÑ´¹¤Ë¤è¤ëÂǤÁÊý¤òɽ¤¹Ê¸»úÎó¤òÊÖ¤¹¡£"
  (let ((decomposed (or (tcode-bushu-help-lookup ch)
			(tcode-decompose-char ch for-help))))
    (and decomposed
	 (concat (tcode-help-make-bushu-structure-string decomposed t)))))

;;;
;;; ¥Ø¥ë¥×ɽ
;;;

(defun tcode-make-drawing-data (stroke)
  "STROKE ¤ÎÂǤÁÊý¤ò¿Þ¼¨¤¹¤ë¤¿¤á¤Î¥Ç¡¼¥¿¤òÀ¸À®¤¹¤ë¡£
À¸À®¤¹¤ë¥Ç¡¼¥¿¤Ï¡¢¼¡¤Î¥ê¥¹¥È¤Î¥ê¥¹¥È¡£
  ¥­¡¼¤ÎÈÖÃÏ(0-39)  °õ(¡û¤Ê¤É)  ½çÈÖ¤ò¼¨¤¹Ê¸»úÎó(1¤Ê¤É)"
  (let ((1st (car stroke))
	(2nd (car (cdr stroke)))
	(3rd (car (cdr (cdr stroke))))
	(4th (car (cdr (cdr (cdr stroke)))))
	draw-data)
    (setq draw-data
	  (list (cons 1st
		      (if (memq 1st (cdr stroke))
			  (list tcode-help-double-stroke
				(cond ((and 4th 3rd
					    (= 1st 2nd)
					    (= 1st 3rd)
					    (= 1st 4th))
				       (setq 2nd nil 3rd nil 4th nil)
				       "1¡¢Âè2¡¢Âè3¡¢Âè4")
				      ((and 3rd (= 1st 2nd) (= 1st 3rd))
				       (setq 2nd nil 3rd nil)
				       "1¡¢Âè2¡¢Âè3")
				      ((and 4th 3rd (= 1st 2nd) (= 1st 4th))
				       (setq 2nd nil 4th nil)
				       "1¡¢Âè2¡¢Âè4")
				      ((and 4th 3rd (= 1st 3rd) (= 1st 4th))
				       (setq 3rd nil 4th nil)
				       "1¡¢Âè3¡¢Âè4")
				      ((and 4th 3rd (= 1st 4th))
				       (setq 4th nil)
				       "1¡¢Âè4")
				      ((and 3rd (= 1st 3rd))
				       (setq 3rd nil)
				       "1¡¢Âè3")
				      ((= 1st 2nd) (setq 2nd nil)
				       "1¡¢Âè2")))
			(list tcode-help-first-stroke "1")))))
    (and 2nd
	 (setq draw-data
	       (nconc draw-data
		      (list (cons 2nd
				  (if (memq 2nd (cdr (cdr stroke)))
				      (list
				       (if (and (= (length stroke) 4)
						(or (null 3rd) (null 4th)))
					   tcode-help-another-double-stroke
					 tcode-help-double-stroke)
				       (cond ((and 3rd 4th
						   (= 2nd 3rd) (= 2nd 4th))
					      (setq 3rd nil 4th nil)
					      "2¡¢Âè3¡¢Âè4")
					     ((and 3rd (= 2nd 3rd))
					      (setq 3rd nil)
					      "2¡¢Âè3")
					     ((and 4th (= 2nd 4th))
					      (setq 4th nil)
					      "2¡¢Âè4")))
				    (list tcode-help-second-stroke "2")))))))
    (and 3rd
	 (setq draw-data
	       (nconc draw-data
		      (list (cons 3rd
				  (if (and 4th (= 3rd 4th))
				      (list
				       (if (null 2nd)
					   tcode-help-another-double-stroke
					 tcode-help-double-stroke)
				       (progn
					 (setq 4th nil)
					 "3¡¢Âè4"))
				    (list tcode-help-third-stroke "3")))))))
    (and 4th
	 (setq draw-data
	       (nconc draw-data
		      (list (list 4th tcode-help-forth-stroke "4")))))
    draw-data))

(defun tcode-help-stroke (loc ch)
  "subroutine of `tcode-draw-stroke-for-char'."
  (goto-line (1+ (car loc)))
  (move-to-column (+ (* 2 (cdr loc)) (if (>= (cdr loc) 6) 0 -2)))
  (tcode-delete-char (if (= (char-width (tcode-following-char)) 2) 
			 1 
		       2))
  (insert ch))

(defun tcode-get-key-location (address)
  (cons (/ address 10) (1+ (% address 10))))

(defun tcode-draw-stroke-for-char (stroke)
  "STROKE ¤ÎÂǤÁÊý¤òɽ¤¹¿Þ¤òÉÁ¤¯¡£"
  (let ((draw-data (tcode-make-drawing-data stroke))
	(i 0))
    (insert "\
                      \n\
¡¦¡¦¡¦¡¦      ¡¦¡¦¡¦¡¦
¡¦¡¦¡¦¡¦      ¡¦¡¦¡¦¡¦
¡¦¡¦¡¦¡¦      ¡¦¡¦¡¦¡¦")
    (while draw-data
      (let* ((datum (car draw-data))
	     (addr (car datum))
	     (char (car (cdr datum)))
	     (str (car (cdr (cdr datum)))))
	(tcode-help-stroke (tcode-get-key-location addr) char)
	(goto-line (if (= (mod i 2) 0) 3 4))
	(end-of-line)
	(insert "     " char "¡ÄÂè" str "ÂǸ°")
	(setq i (1+ i)
	      draw-data (cdr draw-data))))))

;;;###autoload
(defun tcode-display-key-for-char (ch &optional not-display)
  "CH (1ʸ»ú)¤ÎÂǤÁÊý¤ò¥­¡¼¤ÎÆþÎϽç¤Çɽ¼¨¤¹¤ë¡£"
  (interactive "sHelp:\nP")
  (if (or (null ch)
	  (string= ch ""))
      (progn
	(tcode-verbose-message "¥Ø¥ë¥×¤Îʸ»ú¤¬¤¢¤ê¤Þ¤»¤ó¡£")
	(ding))
    (let* ((strokes (tcode-encode (tcode-string-to-char ch)))
	   (msg (if strokes
		    (format "%s = %s" ch (tcode-stroke-to-string strokes))
		  (let ((decomposed-char (tcode-help-bushu-help-string
					  ch
					  (and tcode-strict-help 
					       (not strokes)))))
		    (format (if decomposed-char
				(concat ch " = " decomposed-char)
			      ch))))))
      (setq tcode-last-help-char-list (list (tcode-string-to-char ch)))
      (if not-display
	  msg
	(message msg)))))

;;;###autoload
(defun tcode-display-stroke-sequence (char-list &optional append)
  (if tcode-help-with-real-keys
      (message (mapconcat (lambda (ch)
			    (tcode-display-key-for-char (char-to-string ch) t))
			  char-list 
			  "  "))
    (mapcar (lambda (ch)
	      (tcode-display-stroke-for-char (char-to-string ch)
					     append
					     t)
	      (setq append t))
	    char-list)))

;;;###autoload
(defun tcode-display-direct-stroke (kakutei &optional yomi append)
  "KAKUTEI ¤ÎÃæ¤Ç¡¢ YOMI ¤Ë´Þ¤Þ¤ì¤º¡¢¤«¤ÄľÀÜÆþÎϤǤ­¤ë´Á»ú¤òɽ¼¨¤¹¤ë¡£"
  (when (not (window-minibuffer-p (selected-window)))
    (let* ((kakutei-list (string-to-list kakutei))
	   (yomi-list (string-to-list yomi))
	   display-list)
      (while kakutei-list
	(let ((ch (car kakutei-list)))
	  (if (and (not (memq ch yomi-list))
		   (tcode-encode ch))
	      (setq display-list (cons ch display-list)))
	  (setq kakutei-list (delq ch kakutei-list))))
      (setq display-list (nreverse display-list))
      (tcode-display-stroke-sequence display-list append)
      (setq tcode-last-help-char-list display-list))))

;;;###autoload
(defun tcode-display-stroke-for-char (ch &optional append recursive)
  "CH (1ʸ»ú)¤ÎÂǤÁÊý¤òɽ¼¨¤¹¤ë¡£"
  (interactive "sHelp:\nP")
  (run-hooks 'tcode-help-stroke-hook)
  (if tcode-help-with-real-keys
      (tcode-display-key-for-char ch)
    (if (or (null ch)
	    (string= ch ""))
	(progn
	  (tcode-verbose-message "¥Ø¥ë¥×¤Îʸ»ú¤¬¤¢¤ê¤Þ¤»¤ó¡£")
	  (ding))
      (let* ((strokes (tcode-encode (tcode-string-to-char ch)))
	     (buf (get-buffer-create " *tcode: stroke*"))
	     decomposed-string)
	(save-excursion
	  (set-buffer buf)
	  (erase-buffer)
	  (and strokes
	       (<= (length strokes) 4)
	       (tcode-draw-stroke-for-char strokes))
	  (tcode-bushu-init 2)
	  (setq decomposed-string
		(if strokes
		    (concat "{"
			    (mapconcat 'char-to-string
				       (tcode-bushu-for-char
					(tcode-string-to-char ch))
				       ", ")
			    "}")
		  (tcode-help-bushu-help-string ch tcode-strict-help)))
	  (let ((help-string (if decomposed-string
				 (concat ch " = " decomposed-string)
			       (concat ch
				       " = {"
				       (mapconcat 'char-to-string
						  (tcode-bushu-for-char
						   (tcode-string-to-char ch))
						  ", ")
				       "}"))))
	    (if (null strokes)
		(message help-string)
	      (goto-char (point-min))
	      (end-of-line)
	      (insert "     " help-string)
	      (tcode-display-help-buffer " *tcode: stroke*" t append))))
	(if (and decomposed-string
		 (not recursive)
		 (not strokes))
	  (tcode-display-direct-stroke decomposed-string "()[]{}, +" strokes))
	(setq tcode-last-help-char-list (list (tcode-string-to-char ch)))))))

;;;###autoload
(defun tcode-query-stroke (p)
  "°ÌÃÖP¤Ë¤¢¤ëʸ»ú¤ÎÂǤÁÊý¤òɽ¼¨¤¹¤ë¡£"
  (interactive "d")
  (let ((ch (buffer-substring (save-excursion
				(goto-char p)
				(tcode-forward-char 1)
				(point))
			      p)))
    (tcode-display-stroke-for-char ch)))

(defun tcode-auto-remove-help-char ()
  "`tcode-last-help-char-list'¤Ë´Þ¤Þ¤ì¤ëʸ»ú¤òõ¤·¤Æ¾Ãµî¤¹¤ë¡£"
  (and (eq tcode-auto-help 'delete-the-char)
       (let ((chars (reverse tcode-last-help-char-list)))
	 (while chars
	   (search-backward (char-to-string (car chars)))
	   (delete-region (match-beginning 0)
			  (match-end 0))
	   (setq chars (cdr chars)))
	 (ding))))

;;;
;;; ¥¹¥È¥í¡¼¥¯É½
;;;

;;;###autoload
(defun tcode-show-tables (first second)
  (interactive)
  (let* ((buf (tcode-draw-tables first second)))
    (if tcode-auto-zap-table
	(save-window-excursion
	  (tcode-display-help-buffer buf)
	  (sit-for 0)
	  (tcode-redo-command (read-char)))
      (let ((orig-buf (current-buffer)))
	(set-buffer buf)
	(goto-char (point-min))
	(set-buffer orig-buf))
      (tcode-display-help-buffer buf))))

(defun tcode-make-table-line (k1 k2)
  "subroutine of `tcode-make-LR-block'."
  (let ((i1 k1) (j 0) c)
    (while (< j 5)
      (let ((a (cdr (tcode-decode (list i1 k2)))))
	(setq c (if (null a)
		    "¢£"
		  (tcode-action-to-printable a)))
	(insert c)
	(if (= (char-width (tcode-string-to-char c)) 1) (insert " ")))
      (setq j (1+ j)
	    i1 (1+ i1)))))

(defun tcode-make-LR-block (k1-start k2-start)
  "subroutine of `tcode-insert-stroke-file'."
  (or tcode-help-draw-top-keys
      (setq k1-start (+ k1-start 10)
	    k2-start (+ k2-start 10)))
  (let ((k1 k1-start)
	(k2 k2-start)
	y x yy)
    (setq yy (if tcode-help-draw-top-keys 0 1))
    (while (< yy 4)
      (setq y (if tcode-help-draw-top-keys 0 1))
      (setq k1 k1-start)
      (while (< y 4)
	(setq k2 k2-start)
	(insert "\n  ")
	(setq x 0)
	(while (< x 5)
	  (tcode-make-table-line k1 k2)
	  (insert "  ")
	  (setq x (1+ x))
	  (setq k2 (1+ k2)))
	(setq y (1+ y))
	(setq k1 (+ 10 k1)))
      (setq k2-start (+ 10 k2-start))
      (insert "\n")
      (setq yy (1+ yy)))))

(defun tcode-insert-stroke-file (&optional force)
  "Make the stroke table and writeout the content into the file.
The file is updated if it is older than tcode table."
  (erase-buffer)
  (if (and (not force)
	   (file-exists-p tcode-stroke-file-name))
      (insert-file-contents tcode-stroke-file-name)
    (insert "\nLL\n")
    (tcode-make-LR-block 0 0)
    (insert "\nLR\n")
    (tcode-make-LR-block 0 5)
    (insert "\nRL\n")
    (tcode-make-LR-block 5 0)
    (insert "\nRR\n")
    (tcode-make-LR-block 5 5)
    (if (file-writable-p tcode-stroke-file-name)
	(write-file tcode-stroke-file-name))))

(defun tcode-draw-tables (first second &optional force)
  "Draw tcode stroke tables.
FIRST corresponds to the first stroke.  If nil, then left, else right.
SECOND to the second stroke.  If nil, then left, else right.
If FORCE is non-nil, make new table."
  (let ((buf (get-buffer-create tcode-stroke-buffer-name))
	(str (concat "^" (if first "R" "L") (if second "R" "L"))))
    (save-excursion
      (set-buffer buf)
      (widen)
      (goto-char (point-min))
      (if (and (not force)
	       (re-search-forward str nil t))
	  (progn
	    (forward-line 0)
	    (let ((top (point))
		  (end
		   (progn
		     (forward-line 3)
		     (if (re-search-forward "^[RL]" nil t)
			 (progn(forward-line -1)(point))
		       (point-max)))))
	      (narrow-to-region top end)
	      buf))
	(tcode-insert-stroke-file force)
	(tcode-draw-tables first second)))))

(provide 'tc-help)

;;; tc-help.el ends here