tm 7.56.
[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.7 1996/04/27 13:27:06 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 ;;; @ character set
31 ;;;
32
33 (defalias 'char-charset 'char-leading-char)
34
35
36 ;;; @ coding system
37 ;;;
38
39 (defun decode-coding-region (start end coding-system &optional buffer)
40   "Decode the text between START and END which is encoded in CODING-SYSTEM.
41 \[emu-mule.el; XEmacs 20 emulating function]"
42   (save-excursion
43     (if buffer
44         (set-buffer buffer)
45       )
46     (code-convert start end coding-system *internal*)
47     ))
48
49 (defun encode-coding-region (start end coding-system &optional buffer)
50   "Encode the text between START and END which is encoded in CODING-SYSTEM.
51 \[emu-mule.el; XEmacs 20 emulating function]"
52   (save-excursion
53     (if buffer
54         (set-buffer buffer)
55       )
56     (code-convert start end *internal* coding-system)
57     ))
58
59 (defun decode-coding-string (str coding-system)
60   "Decode the string STR which is encoded in CODING-SYSTEM.
61 \[emu-mule.el; XEmacs 20 emulating function]"
62   (code-convert-string str coding-system *internal*)
63   )
64
65 (defun encode-coding-string (str coding-system)
66   "Encode the string STR which is encoded in CODING-SYSTEM.
67 \[emu-mule.el; XEmacs 20 emulating function]"
68   (code-convert-string str *internal* coding-system)
69   )
70
71
72 ;;; @ version specific features
73 ;;;
74
75 (cond (running-emacs-19
76        (require 'emu-19)
77        
78        (defun fontset-pixel-size (fontset)
79          (let* ((fonts (cdr (get-fontset-info fontset)))
80                 (font
81                  (let ((i 0)
82                        (len (length fonts))
83                        n)
84                    (catch 'tag
85                      (while (< i len)
86                        (setq n (aref fonts i))
87                        (if (/= n -1)
88                            (throw 'tag n)
89                          )
90                        (setq i (1+ i))
91                        ))))
92                 )
93            (if font
94                (aref (get-font-info font) 5)
95              )))
96        )
97       (running-emacs-18
98        (require 'emu-18)
99        (defun tl:make-overlay (beg end &optional buffer type))
100        (defun tl:overlay-put (overlay prop value))
101        (defun tl:add-text-properties (start end properties &optional object))
102        ))
103
104
105 ;;; @@ truncate-string
106 ;;;
107
108 (or (fboundp 'truncate-string)
109 ;;; Imported from Mule-2.3
110 (defun truncate-string (str width &optional start-column)
111   "Truncate STR to fit in WIDTH columns.
112 Optional non-nil arg START-COLUMN specifies the starting column.
113 \[emu-mule.el; Mule 2.3 emulating function]"
114   (or start-column
115       (setq start-column 0))
116   (let ((max-width (string-width str))
117         (len (length str))
118         (from 0)
119         (column 0)
120         to-prev to ch)
121     (if (>= width max-width)
122         (setq width max-width))
123     (if (>= start-column width)
124         ""
125       (while (< column start-column)
126         (setq ch (aref str from)
127               column (+ column (char-width ch))
128               from (+ from (char-bytes ch))))
129       (if (< width max-width)
130           (progn
131             (setq to from)
132             (while (<= column width)
133               (setq ch (aref str to)
134                     column (+ column (char-width ch))
135                     to-prev to
136                     to (+ to (char-bytes ch))))
137             (setq to to-prev)))
138       (substring str from to))))
139 ;;;
140   )
141
142
143 ;;; @ end
144 ;;;
145
146 (provide 'emu-mule)
147
148 ;;; emu-mule.el ends here