| 1 | ;;; poem-om.el --- poem implementation for Mule 1.* and Mule 2.* |
|---|
| 2 | |
|---|
| 3 | ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. |
|---|
| 4 | |
|---|
| 5 | ;; Author: MORIOKA Tomohiko <tomo@m17n.org> |
|---|
| 6 | ;; Katsumi Yamaoka <yamaoka@jpl.org> |
|---|
| 7 | ;; Keywords: emulation, compatibility, Mule |
|---|
| 8 | |
|---|
| 9 | ;; This file is part of APEL (A Portable Emacs Library). |
|---|
| 10 | |
|---|
| 11 | ;; This program is free software; you can redistribute it and/or |
|---|
| 12 | ;; modify it under the terms of the GNU General Public License as |
|---|
| 13 | ;; published by the Free Software Foundation; either version 2, or (at |
|---|
| 14 | ;; your option) any later version. |
|---|
| 15 | |
|---|
| 16 | ;; This program is distributed in the hope that it will be useful, but |
|---|
| 17 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 19 | ;; General Public License for more details. |
|---|
| 20 | |
|---|
| 21 | ;; You should have received a copy of the GNU General Public License |
|---|
| 22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
|---|
| 23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|---|
| 24 | ;; Boston, MA 02111-1307, USA. |
|---|
| 25 | |
|---|
| 26 | ;;; Code: |
|---|
| 27 | |
|---|
| 28 | (require 'poe) |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | ;;; @ version specific features |
|---|
| 32 | ;;; |
|---|
| 33 | |
|---|
| 34 | (if (= emacs-major-version 19) |
|---|
| 35 | ;; Suggested by SASAKI Osamu <osamu@shuugr.bekkoame.or.jp> |
|---|
| 36 | ;; (cf. [os2-emacs-ja:78]) |
|---|
| 37 | (defun fontset-pixel-size (fontset) |
|---|
| 38 | (let* ((font (get-font-info |
|---|
| 39 | (aref (cdr (get-fontset-info fontset)) 0))) |
|---|
| 40 | (open (aref font 4))) |
|---|
| 41 | (if (= open 1) |
|---|
| 42 | (aref font 5) |
|---|
| 43 | (if (= open 0) |
|---|
| 44 | (let ((pat (aref font 1))) |
|---|
| 45 | (if (string-match "-[0-9]+-" pat) |
|---|
| 46 | (string-to-number |
|---|
| 47 | (substring |
|---|
| 48 | pat (1+ (match-beginning 0)) (1- (match-end 0)))) |
|---|
| 49 | 0)) |
|---|
| 50 | )))) |
|---|
| 51 | ) |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | ;;; @ character set |
|---|
| 55 | ;;; |
|---|
| 56 | |
|---|
| 57 | (defalias 'make-char 'make-character) |
|---|
| 58 | |
|---|
| 59 | (defalias 'find-non-ascii-charset-string 'find-charset-string) |
|---|
| 60 | (defalias 'find-non-ascii-charset-region 'find-charset-region) |
|---|
| 61 | |
|---|
| 62 | (defalias 'charset-bytes 'char-bytes) |
|---|
| 63 | (defalias 'charset-description 'char-description) |
|---|
| 64 | (defalias 'charset-registry 'char-registry) |
|---|
| 65 | (defalias 'charset-columns 'char-width) |
|---|
| 66 | (defalias 'charset-direction 'char-direction) |
|---|
| 67 | |
|---|
| 68 | (defun charset-chars (charset) |
|---|
| 69 | "Return the number of characters per dimension of CHARSET." |
|---|
| 70 | (if (= (logand (nth 2 (character-set charset)) 1) 1) |
|---|
| 71 | 96 |
|---|
| 72 | 94)) |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | ;;; @ buffer representation |
|---|
| 76 | ;;; |
|---|
| 77 | |
|---|
| 78 | (defsubst-maybe set-buffer-multibyte (flag) |
|---|
| 79 | "Set the multibyte flag of the current buffer to FLAG. |
|---|
| 80 | If FLAG is t, this makes the buffer a multibyte buffer. |
|---|
| 81 | If FLAG is nil, this makes the buffer a single-byte buffer. |
|---|
| 82 | The buffer contents remain unchanged as a sequence of bytes |
|---|
| 83 | but the contents viewed as characters do change. |
|---|
| 84 | \[Emacs 20.3 emulating function]" |
|---|
| 85 | (setq mc-flag flag) |
|---|
| 86 | ) |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | ;;; @ character |
|---|
| 90 | ;;; |
|---|
| 91 | |
|---|
| 92 | (defalias 'char-charset 'char-leading-char) |
|---|
| 93 | |
|---|
| 94 | (defun split-char (character) |
|---|
| 95 | "Return list of charset and one or two position-codes of CHARACTER." |
|---|
| 96 | (let ((p (1- (char-bytes character))) |
|---|
| 97 | dest) |
|---|
| 98 | (while (>= p 1) |
|---|
| 99 | (setq dest (cons (- (char-component character p) 128) dest) |
|---|
| 100 | p (1- p))) |
|---|
| 101 | (cons (char-charset character) dest))) |
|---|
| 102 | |
|---|
| 103 | (defmacro char-next-index (char index) |
|---|
| 104 | "Return index of character succeeding CHAR whose index is INDEX." |
|---|
| 105 | (` (+ (, index) (char-bytes (, char))))) |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | ;;; @@ obsoleted aliases |
|---|
| 109 | ;;; |
|---|
| 110 | ;;; You should not use them. |
|---|
| 111 | |
|---|
| 112 | (defalias 'char-length 'char-bytes) |
|---|
| 113 | ;;(defalias 'char-columns 'char-width) |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | ;;; @ string |
|---|
| 117 | ;;; |
|---|
| 118 | |
|---|
| 119 | (defalias 'string-columns 'string-width) |
|---|
| 120 | |
|---|
| 121 | (defalias 'string-to-int-list 'string-to-char-list) |
|---|
| 122 | |
|---|
| 123 | ;; Imported from Mule-2.3 |
|---|
| 124 | (defun-maybe truncate-string (str width &optional start-column) |
|---|
| 125 | "\ |
|---|
| 126 | Truncate STR to fit in WIDTH columns. |
|---|
| 127 | Optional non-nil arg START-COLUMN specifies the starting column. |
|---|
| 128 | \[emu-mule.el; Mule 2.3 emulating function]" |
|---|
| 129 | (or start-column |
|---|
| 130 | (setq start-column 0)) |
|---|
| 131 | (let ((max-width (string-width str)) |
|---|
| 132 | (len (length str)) |
|---|
| 133 | (from 0) |
|---|
| 134 | (column 0) |
|---|
| 135 | to-prev to ch) |
|---|
| 136 | (if (>= width max-width) |
|---|
| 137 | (setq width max-width)) |
|---|
| 138 | (if (>= start-column width) |
|---|
| 139 | "" |
|---|
| 140 | (while (< column start-column) |
|---|
| 141 | (setq ch (aref str from) |
|---|
| 142 | column (+ column (char-width ch)) |
|---|
| 143 | from (+ from (char-bytes ch)))) |
|---|
| 144 | (if (< width max-width) |
|---|
| 145 | (progn |
|---|
| 146 | (setq to from) |
|---|
| 147 | (while (<= column width) |
|---|
| 148 | (setq ch (aref str to) |
|---|
| 149 | column (+ column (char-width ch)) |
|---|
| 150 | to-prev to |
|---|
| 151 | to (+ to (char-bytes ch)))) |
|---|
| 152 | (setq to to-prev))) |
|---|
| 153 | (substring str from to)))) |
|---|
| 154 | |
|---|
| 155 | (defalias 'looking-at-as-unibyte 'looking-at) |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | ;;; @ end |
|---|
| 159 | ;;; |
|---|
| 160 | |
|---|
| 161 | (require 'product) |
|---|
| 162 | (product-provide (provide 'poem-om) (require 'apel-ver)) |
|---|
| 163 | |
|---|
| 164 | ;;; poem-om.el ends here |
|---|