Mercurial > emacs
comparison lisp/ps-print.el @ 90735:be5c45687c00
Handle frame parameters changing dynamically
author | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
---|---|
date | Sun, 21 Jan 2007 13:07:12 +0000 |
parents | 0b79f231aae3 |
children | ef1369583937 |
comparison
equal
deleted
inserted
replaced
90734:e4e4a56ef723 | 90735:be5c45687c00 |
---|---|
1 ;;; ps-print.el --- print text from the buffer as PostScript | 1 ;;; ps-print.el --- print text from the buffer as PostScript |
2 | 2 |
3 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, | 3 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
4 ;; 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. | 4 ;; 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Jim Thompson (was <thompson@wg2.waii.com>) | 6 ;; Author: Jim Thompson (was <thompson@wg2.waii.com>) |
7 ;; Jacques Duthen (was <duthen@cegelec-red.fr>) | 7 ;; Jacques Duthen (was <duthen@cegelec-red.fr>) |
8 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br> | 8 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br> |
9 ;; Kenichi Handa <handa@m17n.org> (multi-byte characters) | 9 ;; Kenichi Handa <handa@m17n.org> (multi-byte characters) |
10 ;; Maintainer: Kenichi Handa <handa@m17n.org> (multi-byte characters) | 10 ;; Maintainer: Kenichi Handa <handa@m17n.org> (multi-byte characters) |
11 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br> | 11 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br> |
12 ;; Keywords: wp, print, PostScript | 12 ;; Keywords: wp, print, PostScript |
13 ;; Version: 7.0 | 13 ;; Version: 7.1 |
14 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre | 14 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre |
15 | 15 |
16 (defconst ps-print-version "7.0" | 16 (defconst ps-print-version "7.1" |
17 "ps-print.el, v 7.0 <2006/12/01 vinicius> | 17 "ps-print.el, v 7.1 <2007/01/21 vinicius> |
18 | 18 |
19 Vinicius's last change version -- this file may have been edited as part of | 19 Vinicius's last change version -- this file may have been edited as part of |
20 Emacs without changes to the version number. When reporting bugs, please also | 20 Emacs without changes to the version number. When reporting bugs, please also |
21 report the version of Emacs, if any, that ps-print was distributed with. | 21 report the version of Emacs, if any, that ps-print was distributed with. |
22 | 22 |
1488 (defalias 'ps-x-face-font-instance 'face-font-instance) | 1488 (defalias 'ps-x-face-font-instance 'face-font-instance) |
1489 (defalias 'ps-x-find-coding-system 'find-coding-system) | 1489 (defalias 'ps-x-find-coding-system 'find-coding-system) |
1490 (defalias 'ps-x-font-instance-properties 'font-instance-properties) | 1490 (defalias 'ps-x-font-instance-properties 'font-instance-properties) |
1491 (defalias 'ps-x-make-color-instance 'make-color-instance) | 1491 (defalias 'ps-x-make-color-instance 'make-color-instance) |
1492 (defalias 'ps-x-map-extents 'map-extents) | 1492 (defalias 'ps-x-map-extents 'map-extents) |
1493 (defalias 'ps-x-frame-property 'frame-property) | |
1493 | 1494 |
1494 ;; GNU Emacs | 1495 ;; GNU Emacs |
1495 (defalias 'ps-e-face-bold-p 'face-bold-p) | 1496 (defalias 'ps-e-face-bold-p 'face-bold-p) |
1496 (defalias 'ps-e-face-italic-p 'face-italic-p) | 1497 (defalias 'ps-e-face-italic-p 'face-italic-p) |
1497 (defalias 'ps-e-next-overlay-change 'next-overlay-change) | 1498 (defalias 'ps-e-next-overlay-change 'next-overlay-change) |
1498 (defalias 'ps-e-overlays-at 'overlays-at) | 1499 (defalias 'ps-e-overlays-at 'overlays-at) |
1499 (defalias 'ps-e-overlay-get 'overlay-get) | 1500 (defalias 'ps-e-overlay-get 'overlay-get) |
1500 (defalias 'ps-e-overlay-end 'overlay-end) | 1501 (defalias 'ps-e-overlay-end 'overlay-end) |
1501 (defalias 'ps-e-x-color-values 'x-color-values) | 1502 (defalias 'ps-e-x-color-values 'x-color-values) |
1502 (defalias 'ps-e-color-values 'color-values) | 1503 (defalias 'ps-e-color-values 'color-values) |
1504 (defalias 'ps-e-frame-parameter 'frame-parameter) | |
1503 (if (fboundp 'find-composition) | 1505 (if (fboundp 'find-composition) |
1504 (defalias 'ps-e-find-composition 'find-composition) | 1506 (defalias 'ps-e-find-composition 'find-composition) |
1505 (defalias 'ps-e-find-composition 'ignore)) | 1507 (defalias 'ps-e-find-composition 'ignore)) |
1506 | 1508 |
1507 | 1509 |
1521 (defalias 'ps-mark-active-p 'region-active-p) | 1523 (defalias 'ps-mark-active-p 'region-active-p) |
1522 (defun ps-face-foreground-name (face) | 1524 (defun ps-face-foreground-name (face) |
1523 (ps-xemacs-color-name (face-foreground face))) | 1525 (ps-xemacs-color-name (face-foreground face))) |
1524 (defun ps-face-background-name (face) | 1526 (defun ps-face-background-name (face) |
1525 (ps-xemacs-color-name (face-background face))) | 1527 (ps-xemacs-color-name (face-background face))) |
1528 (defun ps-frame-parameter (param) | |
1529 (ps-x-frame-property nil param)) | |
1526 ) | 1530 ) |
1527 (t ; emacs 23 or higher | 1531 (t ; emacs 23 or higher |
1528 (defvar mark-active nil) | 1532 (defvar mark-active nil) |
1529 (defun ps-mark-active-p () | 1533 (defun ps-mark-active-p () |
1530 mark-active) | 1534 mark-active) |
1531 (defun ps-face-foreground-name (face) | 1535 (defun ps-face-foreground-name (face) |
1532 (face-foreground face nil t)) | 1536 (face-foreground face nil t)) |
1533 (defun ps-face-background-name (face) | 1537 (defun ps-face-background-name (face) |
1534 (face-background face nil t)))) | 1538 (face-background face nil t)) |
1539 (defun ps-frame-parameter (param) | |
1540 (ps-e-frame-parameter nil param)) | |
1541 )) | |
1535 | 1542 |
1536 | 1543 |
1537 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1544 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1538 ;; User Variables: | 1545 ;; User Variables: |
1539 | 1546 |
2983 (const :tag "Print Always Color" t) | 2990 (const :tag "Print Always Color" t) |
2984 (const :tag "Print Black/White Color" black-white)) | 2991 (const :tag "Print Black/White Color" black-white)) |
2985 :version "20" | 2992 :version "20" |
2986 :group 'ps-print-color) | 2993 :group 'ps-print-color) |
2987 | 2994 |
2988 (defcustom ps-default-fg '(0.0 0.0 0.0) ; black | 2995 (defcustom ps-default-fg 'frame-parameter |
2989 "*RGB values of the default foreground color. Defaults to black. | 2996 "*RGB values of the default foreground color. |
2990 | 2997 |
2991 The `ps-default-fg' variable contains the default foreground color used by | 2998 The `ps-default-fg' variable contains the default foreground color used by |
2992 ps-print, that is, if there is a face in a text that doesn't have a foreground | 2999 ps-print, that is, if there is a face in a text that doesn't have a foreground |
2993 color, the `ps-default-fg' color should be used. | 3000 color, the `ps-default-fg' color should be used. |
2994 | 3001 |
2995 Valid values are: | 3002 Valid values are: |
2996 | 3003 |
2997 t The foreground color of Emacs session will be used. | 3004 t The foreground color of Emacs session will be used. |
2998 | 3005 |
3006 frame-parameter The foreground-color frame parameter will be used. | |
3007 | |
2999 NUMBER It's a real value between 0.0 (black) and 1.0 (white) that | 3008 NUMBER It's a real value between 0.0 (black) and 1.0 (white) that |
3000 indicate the gray color. | 3009 indicate the gray color. |
3001 | 3010 |
3002 COLOR-NAME It's a string which contains the color name. For example: | 3011 COLOR-NAME It's a string which contains the color name. For example: |
3003 \"yellow\". | 3012 \"yellow\". |
3008 (RED, GREEN, BLUE) | 3017 (RED, GREEN, BLUE) |
3009 | 3018 |
3010 Where RED, GREEN and BLUE are reals between 0.0 (no color) and | 3019 Where RED, GREEN and BLUE are reals between 0.0 (no color) and |
3011 1.0 (full color). | 3020 1.0 (full color). |
3012 | 3021 |
3013 Any other value is ignored and black will be used. | 3022 Any other value is ignored and black color will be used. |
3014 | 3023 |
3015 It's used only when `ps-print-color-p' is non-nil." | 3024 It's used only when `ps-print-color-p' is non-nil." |
3016 :type '(choice :menu-tag "Default Foreground Gray/Color" | 3025 :type '(choice :menu-tag "Default Foreground Gray/Color" |
3017 :tag "Default Foreground Gray/Color" | 3026 :tag "Default Foreground Gray/Color" |
3018 (const :tag "Session Foreground" t) | 3027 (const :tag "Session Foreground" t) |
3028 (const :tag "Frame Foreground" frame-parameter) | |
3019 (number :tag "Gray Scale" :value 0.0) | 3029 (number :tag "Gray Scale" :value 0.0) |
3020 (string :tag "Color Name" :value "black") | 3030 (string :tag "Color Name" :value "black") |
3021 (list :tag "RGB Color" :value (0.0 0.0 0.0) | 3031 (list :tag "RGB Color" :value (0.0 0.0 0.0) |
3022 (number :tag "Red") | 3032 (number :tag "Red") |
3023 (number :tag "Green") | 3033 (number :tag "Green") |
3024 (number :tag "Blue"))) | 3034 (number :tag "Blue"))) |
3025 :version "20" | 3035 :version "20" |
3026 :group 'ps-print-color) | 3036 :group 'ps-print-color) |
3027 | 3037 |
3028 (defcustom ps-default-bg '(1.0 1.0 1.0) ; white | 3038 (defcustom ps-default-bg 'frame-parameter |
3029 "*RGB values of the default background color. Defaults to white. | 3039 "*RGB values of the default background color. |
3030 | 3040 |
3031 The `ps-default-bg' variable contains the default background color used by | 3041 The `ps-default-bg' variable contains the default background color used by |
3032 ps-print, that is, if there is a face in a text that doesn't have a background | 3042 ps-print, that is, if there is a face in a text that doesn't have a background |
3033 color, the `ps-default-bg' color should be used. | 3043 color, the `ps-default-bg' color should be used. |
3034 | 3044 |
3035 Valid values are: | 3045 Valid values are: |
3036 | 3046 |
3037 t The background color of Emacs session will be used. | 3047 t The background color of Emacs session will be used. |
3038 | 3048 |
3049 frame-parameter The background-color frame parameter will be used. | |
3050 | |
3039 NUMBER It's a real value between 0.0 (black) and 1.0 (white) that | 3051 NUMBER It's a real value between 0.0 (black) and 1.0 (white) that |
3040 indicate the gray color. | 3052 indicate the gray color. |
3041 | 3053 |
3042 COLOR-NAME It's a string which contains the color name. For example: | 3054 COLOR-NAME It's a string which contains the color name. For example: |
3043 \"yellow\". | 3055 \"yellow\". |
3048 (RED, GREEN, BLUE) | 3060 (RED, GREEN, BLUE) |
3049 | 3061 |
3050 Where RED, GREEN and BLUE are reals between 0.0 (no color) and | 3062 Where RED, GREEN and BLUE are reals between 0.0 (no color) and |
3051 1.0 (full color). | 3063 1.0 (full color). |
3052 | 3064 |
3053 Any other value is ignored and white will be used. | 3065 Any other value is ignored and white color will be used. |
3054 | 3066 |
3055 It's used only when `ps-print-color-p' is non-nil. | 3067 It's used only when `ps-print-color-p' is non-nil. |
3056 | 3068 |
3057 See also `ps-use-face-background'." | 3069 See also `ps-use-face-background'." |
3058 :type '(choice :menu-tag "Default Background Gray/Color" | 3070 :type '(choice :menu-tag "Default Background Gray/Color" |
3059 :tag "Default Background Gray/Color" | 3071 :tag "Default Background Gray/Color" |
3060 (const :tag "Session Background" t) | 3072 (const :tag "Session Background" t) |
3073 (const :tag "Frame Background" frame-parameter) | |
3061 (number :tag "Gray Scale" :value 1.0) | 3074 (number :tag "Gray Scale" :value 1.0) |
3062 (string :tag "Color Name" :value "white") | 3075 (string :tag "Color Name" :value "white") |
3063 (list :tag "RGB Color" :value (1.0 1.0 1.0) | 3076 (list :tag "RGB Color" :value (1.0 1.0 1.0) |
3064 (number :tag "Red") | 3077 (number :tag "Red") |
3065 (number :tag "Green") | 3078 (number :tag "Green") |
5864 (string-as-unibyte "[\000-\037\177-\237]")) | 5877 (string-as-unibyte "[\000-\037\177-\237]")) |
5865 ((eq ps-print-control-characters 'control) | 5878 ((eq ps-print-control-characters 'control) |
5866 "[\000-\037\177]") | 5879 "[\000-\037\177]") |
5867 (t "[\t\n\f]")) | 5880 (t "[\t\n\f]")) |
5868 ps-default-background (ps-rgb-color | 5881 ps-default-background (ps-rgb-color |
5869 (if (eq ps-default-bg t) | 5882 (cond |
5870 (ps-face-background-name 'default) | 5883 ((eq ps-default-bg 'frame-parameter) |
5871 ps-default-bg) | 5884 (ps-frame-parameter 'background-color)) |
5885 ((eq ps-default-bg t) | |
5886 (ps-face-background-name 'default)) | |
5887 (t | |
5888 ps-default-bg)) | |
5872 1.0) | 5889 1.0) |
5873 ps-default-foreground (ps-rgb-color | 5890 ps-default-foreground (ps-rgb-color |
5874 (if (eq ps-default-fg t) | 5891 (cond |
5875 (ps-face-foreground-name 'default) | 5892 ((eq ps-default-fg 'frame-parameter) |
5876 ps-default-fg) | 5893 (ps-frame-parameter 'foreground-color)) |
5894 ((eq ps-default-fg t) | |
5895 (ps-face-foreground-name 'default)) | |
5896 (t | |
5897 ps-default-fg)) | |
5877 0.0) | 5898 0.0) |
5878 ps-default-color (and (eq ps-print-color-p t) ps-default-foreground) | 5899 ps-default-color (and (eq ps-print-color-p t) ps-default-foreground) |
5879 ps-current-color ps-default-color | 5900 ps-current-color ps-default-color |
5880 ;; Set the color scale. We do it here instead of in the defvar so | 5901 ;; Set the color scale. We do it here instead of in the defvar so |
5881 ;; that ps-print can be dumped into emacs. This expression can't be | 5902 ;; that ps-print can be dumped into emacs. This expression can't be |
6676 (string< "" ps-printer-name) | 6697 (string< "" ps-printer-name) |
6677 (list (concat | 6698 (list (concat |
6678 (and (stringp ps-printer-name-option) | 6699 (and (stringp ps-printer-name-option) |
6679 ps-printer-name-option) | 6700 ps-printer-name-option) |
6680 ps-printer-name)))))) | 6701 ps-printer-name)))))) |
6702 (or (stringp ps-printer-name) | |
6703 (setq ps-printer-name nil)) | |
6681 (apply (or ps-print-region-function 'call-process-region) | 6704 (apply (or ps-print-region-function 'call-process-region) |
6682 (point-min) (point-max) ps-lpr-command nil | 6705 (point-min) (point-max) ps-lpr-command nil |
6683 (and (fboundp 'start-process) 0) | 6706 (and (fboundp 'start-process) 0) |
6684 nil | 6707 nil |
6685 (ps-flatten-list ; dynamic evaluation | 6708 (ps-flatten-list ; dynamic evaluation |