tm 7.61.
[elisp/apel.git] / emu-mule.el
1 ;;;
2 ;;; emu-mule.el --- Mule 2.* emulation module for Mule
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: emu-mule.el,v 7.13 1996/05/14 16:28:33 morioka Exp $
10 ;;; Keywords: emulation, compatibility, Mule
11 ;;;
12 ;;; This file is part of tl (Tiny Library).
13 ;;;
14 ;;; This program is free software; you can redistribute it and/or
15 ;;; modify it under the terms of the GNU General Public License as
16 ;;; published by the Free Software Foundation; either version 2, or
17 ;;; (at your option) any later version.
18 ;;;
19 ;;; This program is distributed in the hope that it will be useful,
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 ;;; General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with This program.  If not, write to the Free Software
26 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;;
28 ;;; Code:
29
30 ;;; @ version specific features
31 ;;;
32
33 (cond (running-emacs-19
34        (require 'emu-19)
35        
36        ;; Suggested by SASAKI Osamu <osamu@shuugr.bekkoame.or.jp>
37        ;; (cf. [os2-emacs-ja:78])
38        (defun fontset-pixel-size (fontset)
39          (let* ((font (get-font-info
40                        (aref (cdr (get-fontset-info fontset)) 0)))
41                 (open (aref font 4)))
42            (if (= open 1)
43                (aref font 5)
44              (if (= open 0)
45                  (let ((pat (aref font 1)))
46                    (if (string-match "-[0-9]+-" pat)
47                        (string-to-number
48                         (substring
49                          pat (1+ (match-beginning 0)) (1- (match-end 0))))
50                      0)))
51              )))
52        )
53       (running-emacs-18
54        (require 'emu-18)
55        (defun tl:make-overlay (beg end &optional buffer type))
56        (defun tl:overlay-put (overlay prop value))
57        ))
58
59
60 ;;; @ character set
61 ;;;
62
63 (defalias 'char-charset 'char-leading-char)
64
65
66 ;;; @ coding system
67 ;;;
68
69 (defun character-encode-string (str coding-system)
70   "Encode the string STR which is encoded in CODING-SYSTEM.
71 \[emu-mule.el]"
72   (code-convert-string str *internal* coding-system)
73   )
74
75 (defun character-decode-string (str coding-system)
76   "Decode the string STR which is encoded in CODING-SYSTEM.
77 \[emu-mule.el]"
78   (code-convert-string str coding-system *internal*)
79   )
80
81 (defun character-encode-region (start end coding-system)
82   "Encode the text between START and END which is
83 encoded in CODING-SYSTEM. [emu-mule.el]"
84   (code-convert start end *internal* coding-system)
85   )
86
87 (defun character-decode-region (start end coding-system)
88   "Decode the text between START and END which is
89 encoded in CODING-SYSTEM. [emu-mule.el]"
90   (code-convert start end coding-system *internal*)
91   )
92
93
94 ;;; @ character and string
95 ;;;
96
97 (defalias 'string-to-int-list 'string-to-char-list)
98
99 (or (fboundp 'truncate-string)
100 ;;; Imported from Mule-2.3
101 (defun truncate-string (str width &optional start-column)
102   "Truncate STR to fit in WIDTH columns.
103 Optional non-nil arg START-COLUMN specifies the starting column.
104 \[emu-mule.el; Mule 2.3 emulating function]"
105   (or start-column
106       (setq start-column 0))
107   (let ((max-width (string-width str))
108         (len (length str))
109         (from 0)
110         (column 0)
111         to-prev to ch)
112     (if (>= width max-width)
113         (setq width max-width))
114     (if (>= start-column width)
115         ""
116       (while (< column start-column)
117         (setq ch (aref str from)
118               column (+ column (char-width ch))
119               from (+ from (char-bytes ch))))
120       (if (< width max-width)
121           (progn
122             (setq to from)
123             (while (<= column width)
124               (setq ch (aref str to)
125                     column (+ column (char-width ch))
126                     to-prev to
127                     to (+ to (char-bytes ch))))
128             (setq to to-prev)))
129       (substring str from to))))
130 ;;;
131   )
132
133
134 ;;; @ end
135 ;;;
136
137 (provide 'emu-mule)
138
139 ;;; emu-mule.el ends here