2019-06-19 20:30:10 +00:00
|
|
|
|
;;; ps-def.el --- Emacs definitions for ps-print -*- lexical-binding: t -*-
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
2019-01-01 00:59:58 +00:00
|
|
|
|
;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
2017-10-29 22:28:58 +00:00
|
|
|
|
;; Author: Vinicius Jose Latorre <viniciusjl.gnu@gmail.com>
|
2019-05-20 04:29:13 +00:00
|
|
|
|
;; Kenichi Handa <handa@gnu.org> (multi-byte characters)
|
2007-01-26 02:30:28 +00:00
|
|
|
|
;; Keywords: wp, print, PostScript
|
|
|
|
|
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
|
2010-08-29 16:17:13 +00:00
|
|
|
|
;; Package: ps-print
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs 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 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs 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
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; See ps-print.el for documentation.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2008-02-02 04:16:23 +00:00
|
|
|
|
(declare-function ps-plot-with-face "ps-print" (from to face))
|
|
|
|
|
(declare-function ps-plot-string "ps-print" (string))
|
|
|
|
|
|
|
|
|
|
(defvar ps-bold-faces) ; in ps-print.el
|
|
|
|
|
(defvar ps-italic-faces)
|
|
|
|
|
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; Emacs Definitions
|
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-mark-active-p ()
|
|
|
|
|
mark-active)
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-face-foreground-name (face)
|
|
|
|
|
(face-foreground face nil t))
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-face-background-name (face)
|
|
|
|
|
(face-background face nil t))
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defalias 'ps-frame-parameter 'frame-parameter)
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
;; Return t if the device (which can be changed during an emacs session) can
|
|
|
|
|
;; handle colors. This function is not yet implemented for GNU emacs.
|
|
|
|
|
(defun ps-color-device ()
|
|
|
|
|
(if (fboundp 'color-values)
|
|
|
|
|
(funcall 'color-values "Green")
|
|
|
|
|
t))
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-color-values (x-color)
|
|
|
|
|
(cond
|
|
|
|
|
((fboundp 'color-values)
|
|
|
|
|
(funcall 'color-values x-color))
|
|
|
|
|
((fboundp 'x-color-values)
|
|
|
|
|
(funcall 'x-color-values x-color))
|
|
|
|
|
(t
|
|
|
|
|
(error "No available function to determine X color values"))))
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-face-bold-p (face)
|
|
|
|
|
(or (face-bold-p face)
|
|
|
|
|
(memq face ps-bold-faces)))
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-face-italic-p (face)
|
|
|
|
|
(or (face-italic-p face)
|
|
|
|
|
(memq face ps-italic-faces)))
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-face-strikeout-p (face)
|
|
|
|
|
(eq (face-attribute face :strike-through) t))
|
2008-01-09 03:27:04 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-face-overline-p (face)
|
|
|
|
|
(eq (face-attribute face :overline) t))
|
2008-01-09 03:27:04 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-face-box-p (face)
|
|
|
|
|
(not (memq (face-attribute face :box) '(nil unspecified))))
|
2008-01-09 03:27:04 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
;; Emacs understands the %f format; we'll use it to limit color RGB values
|
|
|
|
|
;; to three decimals to cut down some on the size of the PostScript output.
|
|
|
|
|
(defvar ps-color-format "%0.3f %0.3f %0.3f")
|
|
|
|
|
(defvar ps-float-format "%0.3f ")
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(defun ps-generate-postscript-with-faces1 (from to)
|
|
|
|
|
;; Generate some PostScript.
|
|
|
|
|
(let ((face 'default)
|
|
|
|
|
(position to)
|
|
|
|
|
;; Emacs
|
|
|
|
|
(property-change from)
|
|
|
|
|
(overlay-change from)
|
|
|
|
|
before-string after-string)
|
|
|
|
|
(while (< from to)
|
|
|
|
|
(and (< property-change to) ; Don't search for property change
|
2007-01-26 02:30:28 +00:00
|
|
|
|
; unless previous search succeeded.
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(setq property-change (next-property-change from nil to)))
|
|
|
|
|
(and (< overlay-change to) ; Don't search for overlay change
|
2007-01-26 02:30:28 +00:00
|
|
|
|
; unless previous search succeeded.
|
2019-06-19 20:30:10 +00:00
|
|
|
|
(setq overlay-change (min (next-overlay-change from)
|
|
|
|
|
to)))
|
|
|
|
|
(setq position (min property-change overlay-change)
|
|
|
|
|
before-string nil
|
|
|
|
|
after-string nil)
|
|
|
|
|
(setq face
|
|
|
|
|
(cond ((invisible-p from)
|
|
|
|
|
'emacs--invisible--face)
|
|
|
|
|
((get-char-property from 'face))
|
|
|
|
|
(t 'default)))
|
|
|
|
|
;; Plot up to this record.
|
|
|
|
|
(and before-string
|
|
|
|
|
(ps-plot-string before-string))
|
|
|
|
|
(ps-plot-with-face from position face)
|
|
|
|
|
(and after-string
|
|
|
|
|
(ps-plot-string after-string))
|
|
|
|
|
(setq from position))
|
|
|
|
|
(ps-plot-with-face from to face)))
|
2007-01-26 02:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
(provide 'ps-def)
|
|
|
|
|
|
|
|
|
|
;;; ps-def.el ends here
|