summaryrefslogtreecommitdiff
path: root/lisp/ps-def.el
blob: f33f81770ddf89b4638ce41b1ce66a40e06a4122 (plain)
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
;;; ps-def.el --- Emacs definitions for ps-print -*- lexical-binding: t -*-

;; Copyright (C) 2007-2019 Free Software Foundation, Inc.

;; Author: Vinicius Jose Latorre <viniciusjl.gnu@gmail.com>
;;	Kenichi Handa <handa@gnu.org> (multi-byte characters)
;; Keywords: wp, print, PostScript
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
;; Package: ps-print

;; This file is part of GNU Emacs.

;; 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
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; See ps-print.el for documentation.

;;; Code:

(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)




;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs Definitions


(defun ps-mark-active-p ()
  mark-active)


(defun ps-face-foreground-name (face)
  (face-foreground face nil t))


(defun ps-face-background-name (face)
  (face-background face nil t))


(defalias 'ps-frame-parameter 'frame-parameter)

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


(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"))))


(defun ps-face-bold-p (face)
  (or (face-bold-p face)
      (memq face ps-bold-faces)))


(defun ps-face-italic-p (face)
  (or (face-italic-p face)
      (memq face ps-italic-faces)))


(defun ps-face-strikeout-p (face)
  (eq (face-attribute face :strike-through) t))


(defun ps-face-overline-p (face)
  (eq (face-attribute face :overline) t))


(defun ps-face-box-p (face)
  (not (memq (face-attribute face :box) '(nil unspecified))))


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


(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
					; unless previous search succeeded.
	   (setq property-change (next-property-change from nil to)))
      (and (< overlay-change to)   ; Don't search for overlay change
					; unless previous search succeeded.
	   (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)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(provide 'ps-def)

;;; ps-def.el ends here