diff options
| author | Kenichi Handa | 2003-09-26 11:59:31 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-09-26 11:59:31 +0000 |
| commit | f07bb4468125c6314bb9a360a8a9b4ef958899af (patch) | |
| tree | 00774fdb2e225f25a61d85f88ad5863e530f7dc6 | |
| parent | 76875dcbe40c0a6666a20b533d4957dbe69b2b86 (diff) | |
| download | emacs-f07bb4468125c6314bb9a360a8a9b4ef958899af.tar.gz emacs-f07bb4468125c6314bb9a360a8a9b4ef958899af.zip | |
(ps-generate-string-list): Function deleted.
(ps-rh-cache, ps-lf-cache, ps-rf-cache): Variables deleted.
(ps-header-footer-string): Function deleted.
(ps-encode-header-string-function): New variable
(ps-generate-header-line): Call ps-encode-header-string-function.
(ps-basic-plot-string-function): New variable
(ps-begin-job): Set ps-basic-plot-string-function and
ps-encode-header-string-function. For setting up headers and
footers, don't use caches such as ps-rh-cache. Don't call
ps-mule-begin-page.
(ps-basic-plot-str): Don't call ps-mule-prepare-ascii-font.
(ps-basic-plot-string): Likewise.
(ps-control-character): Likewise.
(ps-plot-region): Don't pay attention to composition and
non-ASCII characters.
(ps-generate): Call ps-mule-end-job.
(ps-mule-prepare-ascii-font): Delete autoload.
(ps-mule-set-ascii-font): Likewise.
(ps-mule-plot-string): Likewise.
(ps-mule-begin-page): Likewise.
(ps-mule-end-job): Declare autoload.
| -rw-r--r-- | lisp/ps-print.el | 148 |
1 files changed, 34 insertions, 114 deletions
diff --git a/lisp/ps-print.el b/lisp/ps-print.el index 0b8412edc1d..a38a0363be7 100644 --- a/lisp/ps-print.el +++ b/lisp/ps-print.el | |||
| @@ -4666,63 +4666,35 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th | |||
| 4666 | (goto-char (point-max)) | 4666 | (goto-char (point-max)) |
| 4667 | (insert-file fname))) | 4667 | (insert-file fname))) |
| 4668 | 4668 | ||
| 4669 | ;; These functions are used in `ps-mule' to get charset of header and footer. | ||
| 4670 | ;; To avoid unnecessary calls to functions in `ps-left-header', | ||
| 4671 | ;; `ps-right-header', `ps-left-footer' and `ps-right-footer'. | ||
| 4672 | |||
| 4673 | (defun ps-generate-string-list (content) | ||
| 4674 | (let (str) | ||
| 4675 | (while content | ||
| 4676 | (setq str (cons (cond | ||
| 4677 | ((stringp (car content)) | ||
| 4678 | (car content)) | ||
| 4679 | ((and (symbolp (car content)) (fboundp (car content))) | ||
| 4680 | (concat "(" (funcall (car content)) ")")) | ||
| 4681 | ((and (symbolp (car content)) (boundp (car content))) | ||
| 4682 | (concat "(" (symbol-value (car content)) ")")) | ||
| 4683 | (t | ||
| 4684 | "")) | ||
| 4685 | str) | ||
| 4686 | content (cdr content))) | ||
| 4687 | (nreverse str))) | ||
| 4688 | |||
| 4689 | (defvar ps-lh-cache nil) | ||
| 4690 | (defvar ps-rh-cache nil) | ||
| 4691 | (defvar ps-lf-cache nil) | ||
| 4692 | (defvar ps-rf-cache nil) | ||
| 4693 | |||
| 4694 | (defun ps-header-footer-string () | ||
| 4695 | (and ps-print-header | ||
| 4696 | (setq ps-lh-cache (ps-generate-string-list ps-left-header) | ||
| 4697 | ps-rh-cache (ps-generate-string-list ps-right-header))) | ||
| 4698 | (and ps-print-footer | ||
| 4699 | (setq ps-lf-cache (ps-generate-string-list ps-left-footer) | ||
| 4700 | ps-rf-cache (ps-generate-string-list ps-right-footer))) | ||
| 4701 | (mapconcat 'identity | ||
| 4702 | (append ps-lh-cache ps-rh-cache ps-lf-cache ps-rf-cache) | ||
| 4703 | "")) | ||
| 4704 | |||
| 4705 | ;; These functions insert the arrays that define the contents of the headers. | 4669 | ;; These functions insert the arrays that define the contents of the headers. |
| 4706 | 4670 | ||
| 4671 | (defvar ps-encode-header-string-function nil) | ||
| 4672 | |||
| 4707 | (defun ps-generate-header-line (fonttag &optional content) | 4673 | (defun ps-generate-header-line (fonttag &optional content) |
| 4708 | (ps-output " [" fonttag " ") | 4674 | (ps-output " [" fonttag " ") |
| 4709 | (cond | 4675 | (cond |
| 4710 | ;; Literal strings should be output as is -- the string must contain its own | 4676 | ;; Literal strings should be output as is -- the string must contain its own |
| 4711 | ;; PS string delimiters, '(' and ')', if necessary. | 4677 | ;; PS string delimiters, '(' and ')', if necessary. |
| 4712 | ((stringp content) | 4678 | ((stringp content) |
| 4713 | (ps-output (ps-mule-encode-header-string content fonttag))) | 4679 | (ps-output content)) |
| 4714 | 4680 | ||
| 4715 | ;; Functions are called -- they should return strings; they will be inserted | 4681 | ;; Functions are called -- they should return strings; they will be inserted |
| 4716 | ;; as strings and the PS string delimiters added. | 4682 | ;; as strings and the PS string delimiters added. |
| 4717 | ((and (symbolp content) (fboundp content)) | 4683 | ((and (symbolp content) (fboundp content)) |
| 4718 | (ps-output-string (ps-mule-encode-header-string (funcall content) | 4684 | (if (fboundp ps-encode-header-string-function) |
| 4719 | fonttag))) | 4685 | (dolist (l (funcall ps-encode-header-string-function |
| 4686 | (funcall content) fonttag)) | ||
| 4687 | (ps-output-string l)) | ||
| 4688 | (ps-output-string (funcall content)))) | ||
| 4720 | 4689 | ||
| 4721 | ;; Variables will have their contents inserted. They should contain | 4690 | ;; Variables will have their contents inserted. They should contain |
| 4722 | ;; strings, and will be inserted as strings. | 4691 | ;; strings, and will be inserted as strings. |
| 4723 | ((and (symbolp content) (boundp content)) | 4692 | ((and (symbolp content) (boundp content)) |
| 4724 | (ps-output-string (ps-mule-encode-header-string (symbol-value content) | 4693 | (if (fboundp ps-encode-header-string-function) |
| 4725 | fonttag))) | 4694 | (dolist (l (funcall ps-encode-header-string-function |
| 4695 | (symbol-value content) fonttag)) | ||
| 4696 | (ps-output-string l)) | ||
| 4697 | (ps-output-string (symbol-value content)))) | ||
| 4726 | 4698 | ||
| 4727 | ;; Anything else will get turned into an empty string. | 4699 | ;; Anything else will get turned into an empty string. |
| 4728 | (t | 4700 | (t |
| @@ -5676,6 +5648,7 @@ XSTART YSTART are the relative position for the first page in a sheet.") | |||
| 5676 | (t (list default default default)) | 5648 | (t (list default default default)) |
| 5677 | )) | 5649 | )) |
| 5678 | 5650 | ||
| 5651 | (defvar ps-basic-plot-string-function 'ps-basic-plot-string) | ||
| 5679 | 5652 | ||
| 5680 | (defun ps-begin-job () | 5653 | (defun ps-begin-job () |
| 5681 | ;; prologue files | 5654 | ;; prologue files |
| @@ -5764,7 +5737,11 @@ XSTART YSTART are the relative position for the first page in a sheet.") | |||
| 5764 | ps-color-p (and ps-print-color-p (ps-color-device)) | 5737 | ps-color-p (and ps-print-color-p (ps-color-device)) |
| 5765 | ps-print-color-scale (if ps-color-p | 5738 | ps-print-color-scale (if ps-color-p |
| 5766 | (float (car (ps-color-values "white"))) | 5739 | (float (car (ps-color-values "white"))) |
| 5767 | 1.0)) | 5740 | 1.0) |
| 5741 | ;; Set up default functions. They may be overridden by | ||
| 5742 | ;; ps-mule-begin-job. | ||
| 5743 | ps-basic-plot-string-function 'ps-basic-plot-string | ||
| 5744 | ps-encode-header-string-function nil) | ||
| 5768 | ;; initialize page dimensions | 5745 | ;; initialize page dimensions |
| 5769 | (ps-get-page-dimensions) | 5746 | (ps-get-page-dimensions) |
| 5770 | ;; final check | 5747 | ;; final check |
| @@ -5845,28 +5822,19 @@ XSTART YSTART are the relative position for the first page in a sheet.") | |||
| 5845 | (format "/PageNumber %d def\n" (ps-page-number))) | 5822 | (format "/PageNumber %d def\n" (ps-page-number))) |
| 5846 | 5823 | ||
| 5847 | (when ps-print-header | 5824 | (when ps-print-header |
| 5848 | (ps-generate-header "HeaderLinesLeft" "/h0" "/h1" | 5825 | (ps-generate-header "HeaderLinesLeft" "/h0" "/h1" ps-left-header) |
| 5849 | (or ps-lh-cache ps-left-header)) | 5826 | (ps-generate-header "HeaderLinesRight" "/h0" "/h1" ps-right-header) |
| 5850 | (ps-generate-header "HeaderLinesRight" "/h0" "/h1" | 5827 | (ps-output (format "%d SetHeaderLines\n" ps-header-lines))) |
| 5851 | (or ps-rh-cache ps-right-header)) | ||
| 5852 | (ps-output (format "%d SetHeaderLines\n" ps-header-lines)) | ||
| 5853 | (setq ps-lh-cache nil | ||
| 5854 | ps-rh-cache nil)) | ||
| 5855 | 5828 | ||
| 5856 | (when ps-print-footer | 5829 | (when ps-print-footer |
| 5857 | (ps-generate-header "FooterLinesLeft" "/H0" "/H0" | 5830 | (ps-generate-header "FooterLinesLeft" "/H0" "/H0" ps-left-footer) |
| 5858 | (or ps-lf-cache ps-left-footer)) | 5831 | (ps-generate-header "FooterLinesRight" "/H0" "/H0" ps-right-footer) |
| 5859 | (ps-generate-header "FooterLinesRight" "/H0" "/H0" | 5832 | (ps-output (format "%d SetFooterLines\n" ps-footer-lines))) |
| 5860 | (or ps-rf-cache ps-right-footer)) | ||
| 5861 | (ps-output (format "%d SetFooterLines\n" ps-footer-lines)) | ||
| 5862 | (setq ps-lf-cache nil | ||
| 5863 | ps-rf-cache nil)) | ||
| 5864 | 5833 | ||
| 5865 | (ps-output (number-to-string ps-lines-printed) " BeginPage\n") | 5834 | (ps-output (number-to-string ps-lines-printed) " BeginPage\n") |
| 5866 | (ps-set-font ps-current-font) | 5835 | (ps-set-font ps-current-font) |
| 5867 | (ps-set-bg ps-current-bg) | 5836 | (ps-set-bg ps-current-bg) |
| 5868 | (ps-set-color ps-current-color) | 5837 | (ps-set-color ps-current-color)) |
| 5869 | (ps-mule-begin-page)) | ||
| 5870 | 5838 | ||
| 5871 | (defsubst ps-skip-newline (limit) | 5839 | (defsubst ps-skip-newline (limit) |
| 5872 | (setq ps-showline-count (1+ ps-showline-count) | 5840 | (setq ps-showline-count (1+ ps-showline-count) |
| @@ -5910,7 +5878,6 @@ XSTART YSTART are the relative position for the first page in a sheet.") | |||
| 5910 | (ps-avg-char-width 'ps-font-for-text))) | 5878 | (ps-avg-char-width 'ps-font-for-text))) |
| 5911 | (to (car wrappoint)) | 5879 | (to (car wrappoint)) |
| 5912 | (str (substring string from to))) | 5880 | (str (substring string from to))) |
| 5913 | (ps-mule-prepare-ascii-font str) | ||
| 5914 | (ps-output-string str) | 5881 | (ps-output-string str) |
| 5915 | (ps-output " S\n") | 5882 | (ps-output " S\n") |
| 5916 | wrappoint)) | 5883 | wrappoint)) |
| @@ -5920,7 +5887,6 @@ XSTART YSTART are the relative position for the first page in a sheet.") | |||
| 5920 | (ps-avg-char-width 'ps-font-for-text))) | 5887 | (ps-avg-char-width 'ps-font-for-text))) |
| 5921 | (to (car wrappoint)) | 5888 | (to (car wrappoint)) |
| 5922 | (string (buffer-substring-no-properties from to))) | 5889 | (string (buffer-substring-no-properties from to))) |
| 5923 | (ps-mule-prepare-ascii-font string) | ||
| 5924 | (ps-output-string string) | 5890 | (ps-output-string string) |
| 5925 | (ps-output " S\n") | 5891 | (ps-output " S\n") |
| 5926 | wrappoint)) | 5892 | wrappoint)) |
| @@ -6024,26 +5990,16 @@ XSTART YSTART are the relative position for the first page in a sheet.") | |||
| 6024 | (if (re-search-forward ps-control-or-escape-regexp to t) | 5990 | (if (re-search-forward ps-control-or-escape-regexp to t) |
| 6025 | ;; region with some control characters or some multi-byte characters | 5991 | ;; region with some control characters or some multi-byte characters |
| 6026 | (let* ((match-point (match-beginning 0)) | 5992 | (let* ((match-point (match-beginning 0)) |
| 6027 | (match (char-after match-point)) | 5993 | (match (char-after match-point))) |
| 6028 | (composition (ps-e-find-composition from (1+ match-point)))) | ||
| 6029 | (if composition | ||
| 6030 | (if (and (nth 2 composition) | ||
| 6031 | (<= (car composition) match-point)) | ||
| 6032 | (progn | ||
| 6033 | (setq match-point (car composition) | ||
| 6034 | match 0) | ||
| 6035 | (goto-char (nth 1 composition))) | ||
| 6036 | (setq composition nil))) | ||
| 6037 | (when (< from match-point) | 5994 | (when (< from match-point) |
| 6038 | (ps-mule-set-ascii-font) | 5995 | (ps-plot ps-basic-plot-string-function |
| 6039 | (ps-plot 'ps-basic-plot-string from match-point bg-color)) | 5996 | from match-point bg-color)) |
| 6040 | (cond | 5997 | (cond |
| 6041 | ((= match ?\t) ; tab | 5998 | ((= match ?\t) ; tab |
| 6042 | (let ((linestart (line-beginning-position))) | 5999 | (let ((linestart (line-beginning-position))) |
| 6043 | (forward-char -1) | 6000 | (forward-char -1) |
| 6044 | (setq from (+ linestart (current-column))) | 6001 | (setq from (+ linestart (current-column))) |
| 6045 | (when (re-search-forward "[ \t]+" to t) | 6002 | (when (re-search-forward "[ \t]+" to t) |
| 6046 | (ps-mule-set-ascii-font) | ||
| 6047 | (ps-plot 'ps-basic-plot-whitespace | 6003 | (ps-plot 'ps-basic-plot-whitespace |
| 6048 | from (+ linestart (current-column)) | 6004 | from (+ linestart (current-column)) |
| 6049 | bg-color)))) | 6005 | bg-color)))) |
| @@ -6068,24 +6024,11 @@ XSTART YSTART are the relative position for the first page in a sheet.") | |||
| 6068 | (ps-skip-newline to)) | 6024 | (ps-skip-newline to)) |
| 6069 | (ps-next-page))) | 6025 | (ps-next-page))) |
| 6070 | 6026 | ||
| 6071 | (composition ; a composite sequence | ||
| 6072 | (ps-plot 'ps-mule-plot-composition match-point (point) bg-color)) | ||
| 6073 | |||
| 6074 | ((> match 255) ; a multi-byte character | ||
| 6075 | (let* ((charset (char-charset match)) | ||
| 6076 | (composition (ps-e-find-composition match-point to)) | ||
| 6077 | (stop (if (nth 2 composition) (car composition) to))) | ||
| 6078 | (or (eq charset 'composition) | ||
| 6079 | (while (and (< (point) stop) (eq (charset-after) charset)) | ||
| 6080 | (forward-char 1))) | ||
| 6081 | (ps-plot 'ps-mule-plot-string match-point (point) bg-color))) | ||
| 6082 | ; characters from ^@ to ^_ and | ||
| 6083 | (t ; characters from 127 to 255 | 6027 | (t ; characters from 127 to 255 |
| 6084 | (ps-control-character match))) | 6028 | (ps-control-character match))) |
| 6085 | (setq from (point))) | 6029 | (setq from (point))) |
| 6086 | ;; region without control characters nor multi-byte characters | 6030 | ;; region without control characters |
| 6087 | (ps-mule-set-ascii-font) | 6031 | (ps-plot ps-basic-plot-string-function from to bg-color) |
| 6088 | (ps-plot 'ps-basic-plot-string from to bg-color) | ||
| 6089 | (setq from to))))) | 6032 | (setq from to))))) |
| 6090 | 6033 | ||
| 6091 | (defvar ps-string-control-codes | 6034 | (defvar ps-string-control-codes |
| @@ -6117,7 +6060,6 @@ XSTART YSTART are the relative position for the first page in a sheet.") | |||
| 6117 | (if (< (car wrappoint) to) | 6060 | (if (< (car wrappoint) to) |
| 6118 | (ps-continue-line)) | 6061 | (ps-continue-line)) |
| 6119 | (setq ps-width-remaining (- ps-width-remaining (* len char-width))) | 6062 | (setq ps-width-remaining (- ps-width-remaining (* len char-width))) |
| 6120 | (ps-mule-prepare-ascii-font str) | ||
| 6121 | (ps-output-string str) | 6063 | (ps-output-string str) |
| 6122 | (ps-output " S\n"))) | 6064 | (ps-output " S\n"))) |
| 6123 | 6065 | ||
| @@ -6480,6 +6422,7 @@ If FACE is not a valid face name, it is used default face." | |||
| 6480 | (ps-begin-page) | 6422 | (ps-begin-page) |
| 6481 | (funcall genfunc from to) | 6423 | (funcall genfunc from to) |
| 6482 | (ps-end-page) | 6424 | (ps-end-page) |
| 6425 | (ps-mule-end-job) | ||
| 6483 | (ps-end-job needs-begin-file) | 6426 | (ps-end-job needs-begin-file) |
| 6484 | 6427 | ||
| 6485 | ;; Setting this variable tells the unwind form that the | 6428 | ;; Setting this variable tells the unwind form that the |
| @@ -6831,27 +6774,6 @@ If FACE is not a valid face name, it is used default face." | |||
| 6831 | ;; To make this file smaller, some commands go in a separate file. | 6774 | ;; To make this file smaller, some commands go in a separate file. |
| 6832 | ;; But autoload them here to make the separation invisible. | 6775 | ;; But autoload them here to make the separation invisible. |
| 6833 | 6776 | ||
| 6834 | (autoload 'ps-mule-prepare-ascii-font "ps-mule" | ||
| 6835 | "Setup special ASCII font for STRING. | ||
| 6836 | STRING should contain only ASCII characters.") | ||
| 6837 | |||
| 6838 | (autoload 'ps-mule-set-ascii-font "ps-mule" | ||
| 6839 | "Adjust current font if current charset is not ASCII.") | ||
| 6840 | |||
| 6841 | (autoload 'ps-mule-plot-string "ps-mule" | ||
| 6842 | "Generate PostScript code for plotting characters in the region FROM and TO. | ||
| 6843 | |||
| 6844 | It is assumed that all characters in this region belong to the same charset. | ||
| 6845 | |||
| 6846 | Optional argument BG-COLOR specifies background color. | ||
| 6847 | |||
| 6848 | Returns the value: | ||
| 6849 | |||
| 6850 | (ENDPOS . RUN-WIDTH) | ||
| 6851 | |||
| 6852 | Where ENDPOS is the end position of the sequence and RUN-WIDTH is the width of | ||
| 6853 | the sequence.") | ||
| 6854 | |||
| 6855 | (autoload 'ps-mule-initialize "ps-mule" | 6777 | (autoload 'ps-mule-initialize "ps-mule" |
| 6856 | "Initialize global data for printing multi-byte characters.") | 6778 | "Initialize global data for printing multi-byte characters.") |
| 6857 | 6779 | ||
| @@ -6862,10 +6784,8 @@ This checks if all multi-byte characters in the region are printable or not.") | |||
| 6862 | (autoload 'ps-mule-begin-page "ps-mule" | 6784 | (autoload 'ps-mule-begin-page "ps-mule" |
| 6863 | "Initialize multi-byte charset for printing current page.") | 6785 | "Initialize multi-byte charset for printing current page.") |
| 6864 | 6786 | ||
| 6865 | (autoload 'ps-mule-encode-header-string "ps-mule" | 6787 | (autoload 'ps-mule-end-job "ps-mule" |
| 6866 | "Generate PostScript code for plotting characters in header STRING. | 6788 | "Finish printing job for multi-byte chars.") |
| 6867 | |||
| 6868 | It is assumed that the length of STRING is not zero.") | ||
| 6869 | 6789 | ||
| 6870 | 6790 | ||
| 6871 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 6791 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |