view etc/ps-prin1.ps @ 98644:e1cc41b9282d

2008-10-12 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-edit-fixed-width-region): Exclude final newline from picture area. * org-export-latex.el (org-export-latex-subcontent): Add labels to sections, to make internal links work. (org-export-latex-fontify-headline): Do not remove all text properties, to make sure that target properties survive this process. * org-exp.el (org-export-preprocess-string): Change sequence of modifications, to make sure links are prepared before the LaTeX conversions do happen. * org-attach.el (org-attach-delete-all): Renamed from `org-attch-delete'. Add a security query before deleting the entire directory. New optional argument FORCE can overrule the security query. (org-attach-delete-one): New command. * org-attach.el (org-attach-file-list): Fix bug with directory. * org.el (org-apps-regexp-alist): New function. (org-file-apps): Add auto-mode to the default value. (org-open-file): Use the new structure of org-file-apps. * org-attach.el (org-attach): Support the new keys. (org-attach-method): New option. * org-bbdb.el (org-bbdb-anniversaries): Fix but with 29 Feb/1 March. * org.el (org-remove-uniherited-tags): Fix reverse interpretation of the list value o `org-use-tag-inheritance'. * org-attach.el (org-attach-auto-tag): New option. (org-attach-tag, org-attach-untag): New functions. (org-attach-attach, org-attach-new, org-attach-sync): Call `org-attach-tag'. (org-attach-delete): Call `org-attach-untag'. * org-attach.el: New file. * org-table.el (orgtbl-self-insert-command): Make this work for the keypad as well. * org.el (org-add-log-setup): Limit searc for drawers to entry text, not to subtree. * org-clock.el (org-clock-heading-for-remember): New variable. (org-clock-in): Set `org-clock-heading-for-remember'. 2008-10-12 James TD Smith <ahktenzero@mohorovi.cc> * org-remember.el (org-remember-apply-template): Add new expansions: %k, %K for currently clocked task and a link to the currently clocked task, and %< to file notes in the currently clocked task. 2008-10-12 Carsten Dominik <dominik@science.uva.nl> * org-export-latex.el (org-export-latex-make-header): Also insert the content of the property :latex-header-extra. * org-exp.el (org-infile-export-plist): Put the content of #+LATEX_HEADER: into the property :latex-header-extra. * org-colview.el (org-columns-get-format-and-top-level): Remove resetting the marker. * org-colview-xemacs.el (org-columns-get-format-and-top-level): Remove resetting the marker. * org.el (org-entry-property-inherited-from): Improve docstring. (org-entry-get-with-inheritance): Reset marker before starting the search. * org-exp.el (org-infile-export-plist): Allow multiple STYLE lines. * org.el (org-entry-get-multivalued-property) (org-entry-protect-space, org-entry-restore-space): New functions. (org-file-apps-defaults-macosx): Let postscript files be opened by preview. (org-time-stamp-inactive): Call `org-time-stamp'. (org-time-stamp): New argument `inactive'. Also edit inacive stamps. Convert time stamp type. (org-open-file): Interpret the `default' value for the `command' in `org-file-apps'. * org-id.el (org-id-int-to-b36-one-digit) (org-id-b36-to-int-one-digit, org-id-int-to-b36) (org-id-b36-to-int, org-id-time-to-b36): Modified from b62 to b36. * org-id.el (org-id-reverse-string): New function. (org-id-new): Use `org-id-reverse-string' to make sure the beginning chars of the ID are mutating fast. This allows to use a directory structure to spread things better. (org-id-prefix): Changed default to nil. * org-list.el (org-move-item-down, org-move-item-up): Remember and restore the column of the cursor position. * org-remember.el (org-remember-apply-template): Remove properties from `initial'. * org-wl.el (org-wl-open): Remove useless call to `wl-thread-open-all'. * org-remember.el (org-remember-handler): Fix bug with `bottom' location. * org-bbdb.el (org-bbdb-anniversaries): Require bbdb in `org-bbdb-anniversaries'. * org.el (org-get-next-sibling, org-forward-same-level): New functions, similar to the outline versions, but invisible headings are OK. 2008-10-12 Bastien Guerry <bzg@altern.org> * org.el (org-auto-repeat-maybe): Insert a space between the timestamp's type and the timestamp itself. 2008-10-12 Carsten Dominik <dominik@science.uva.nl> * org-table.el (org-table-sum): Do not format the result with %g, it does rounding when there are too many digits. * org.el (org-map-entries): Protect the keyword-selecting variables. 2008-10-12 Bastien Guerry <bzg@altern.org> * org-agenda.el (org-agenda-to-appt): Make sure the function check against all agenda files. 2008-10-12 Carsten Dominik <dominik@science.uva.nl> * org-list.el: New file, aggregating list functions from org.el and org-export-latex.el. * org.el (org-edit-src-region-extra): New option. * org-agenda.el (org-agenda-to-appt): Fix bug with appointment time before 1am. 2008-10-12 Bastien Guerry <bzg@altern.org> * org-export-latex.el (org-export-latex-keywords-maybe): Bug fix. 2008-10-12 James TA Smith <ahktenzero@mohorovi.cc> * org-plot.el (org-plot/gnuplot): Make tables starting with a hline work correctly. (org-plot/gnuplot-script): Put commas at the end of each script line. * org.el (org-get-refile-targets): Replace links with their descriptions (org-imenu-get-tree): Replace links with their descriptions. * org-remember.el (org-remember-apply-template): Add a new expansion for adding properties to remember items. * org.el (org-add-log-setup): Skip over drawers (properties, clocks etc) when adding notes. * org-agenda.el (org-agenda-get-closed): show durations of clocked items as well as the start and end times. * org-compat.el (org-get-x-clipboard-compat): Add a compat function for fetching the X clipboard on XEmacs and GNU Emacs 21. * org-remember.el (org-get-x-clipboard): Use the compat function to get clipboard values when x-selection-value is unavailable. Use substring-no-properties instead of set-text-properties to remove text properties from the clipboard value. * lisp/org-clock.el (org-update-mode-line): Support limiting the modeline clock string, and display the full todo value in the tooltip. Set a local keymap so mouse-3 on the clock string goes to the currently clocked task. (org-clock-string-limit): Add a custom value for the maximum length of the clock string in the modeline. (org-clock-mode-map): Add a keymap for the modeline string 2008-10-12 Carsten Dominik <dominik@science.uva.nl> * org-compat.el (org-propertize): New function. 2008-10-12 Bastien Guerry <bzg@altern.org> * org-export-latex.el (org-export-latex-tables): protect exported tables from further special chars conversion. (org-export-latex-preprocess): Preserve LaTeX environments. (org-list-parse-list): Parse descriptive lists. (org-list-to-generic, org-list-to-latex, org-list-to-html) (org-list-to-texinfo): Export descriptive lists. (org-quote-chars): Remove. (org-export-latex-keywords-maybe): Use `replace-regexp-in-string'. (org-export-latex-list-beginning-re): Rename to `org-list-beginning-re' (org-list-item-begin): Rename to `org-list-item-beginning' 2008-10-12 Carsten Dominik <dominik@science.uva.nl> * org.el (org-refile): Allow refiling to the last entry in the buffer. (org-get-tags-at): Fix bug when inheritance is turned off. * org.el (org-indent-line-function): No longer check for src regions, this is too much overhead. * org-agenda.el (org-agenda-highlight-todo): Fix bugs with keyword matching. * org.el (org-scan-tags): Make sure that tags matching is not case sensitive. TODO keyword matching is case sensitive, however, to avoid confusion with similar words that are not meant to be keywords. * org.el (org-get-local-tags-at): New function. (org-get-local-tags): New function. * org-exp.el (org-export-get-categories): New function. * org-agenda.el (org-sorting-choice) (org-agenda-sorting-strategy, org-agenda-get-todos) (org-agenda-get-timestamps, org-agenda-get-deadlines) (org-agenda-get-scheduled, org-agenda-get-blocks) (org-entries-lessp): Implement sorting by TODO state. (org-cmp-todo-state): New defsubst. * org-colview.el (org-colview-construct-allowed-dates): New function. (org-columns-next-allowed-value): Use `org-colview-construct-allowed-dates'. * org-colview-xemacs.el (org-colview-construct-allowed-dates): New function. (org-columns-next-allowed-value): Use `org-colview-construct-allowed-dates'. * org.el (org-protect-slash): New function. (org-get-refile-targets): Use `org-protect-slash'. * org-agenda.el (org-global-tags-completion-table): New variable. * org-exp.el (org-export-handle-export-tags): New function. (org-export-preprocess-string): Call `org-export-handle-export-tags'. * org-plot.el: New file. * org-publish.el (org-publish-expand-components): Function removed. (org-publish-expand-projects): Allow components to have components. * org.el (org-indent-line-function): Do not indent in regions that are external source code. (org-yank-and-fold-if-subtree): New function. * org-agenda.el (org-agenda-todayp): New function. (org-agenda-get-deadlines, org-agenda-get-scheduled): Use `org-agenda-todayp'. * org.el (org-insert-heading-respect-content) (org-insert-todo-heading-respect-content): New commands. (org-insert-heading-respect-content): New option. (org-insert-heading): Respect `org-insert-heading-respect-content'. * org-clock.el (org-clock-find-position): Make sure the note after the clock line gets moved into the new clock drawer. * org-id.el (org-id-new): New option. * org-table.el (org-table-copy-down): Avoid overflow during increment. Use prefix argument 0 to temporarily disable the increment. * org-exp.el (org-export-as-html): Do not turn on the major mode if the buffer will be killed anyway. (org-get-current-options): Exclude the #+TEXT field. (org-export-as-html): Make sure text before the first headline is a paragraph. * org-publish.el (org-publish-org-to): Tell the exporter that this buffer will be killed, so it is not necessary to do major mode initialization. * org-archive.el (org-archive-to-archive-sibling): Show empty lines after folding the archive sibling. * org.el (org-log-note-extra): New variable. 2008-10-12 Bastien Guerry <bzg@altern.org> * org.el (org-additional-option-like-keywords): Added keywords for the _QUOTE, _VERSE and _SRC environments. * org-export-latex.el (org-export-latex-preprocess): Fix bug when exporting _QUOTE and _VERSE environments. 2008-10-12 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-filter-by-tag): New command. * org-exp.el (org-get-current-options): Remove angular brackets from the date entry. * org.el (org-edit-fixed-width-region): New function. (org-edit-fixed-width-region): Also try `org-edit-fixed-width-region'. (org-edit-fixed-width-region-mode): New option. (org-activate-code): Only interprete lines starting with colon plus a space as example lines. * org-remember.el (org-remember-templates): Add nil instead of empty strings to fix the length of remember templates. * org-table.el (org-calc-default-modes): Fix the time format for calc, from 12 hour to 24 hour clock. * org-agenda.el (org-agenda-get-deadlines) (org-agenda-get-scheduled): Avoid `time-of-day' extraction for entries that are pre-warnings of deadlines or reminders. * org.el (org-sort-entries-or-items): Make numeric and alpha comparisons ignore any TODO keyword and priority cookie. * org-remember.el (org-remember-handler): Reinterpretation of the prefix argument. * org-agenda.el (org-agenda-get-scheduled): Use new `org-scheduled' face. * org-faces.el (org-scheduled): New face. * org-wl.el (org-wl-open): Remove incorrect declaration. * org-gnus.el (org-gnus-store-link): Support for :to information in gnus links. * org-exp.el (org-export-as-html): Fixed typo in creator information. (org-export-protect-examples): New parameter indent. Insert extra spaces only when this parameter is specified. (org-export-preprocess-string): Call `org-export-protect-examples' with an indentation parameter when exporting to ASCII. * org-remember.el (org-remember-templates) (org-remember-apply-template): Allow the file component to be a function. * org.el (org-goto-local-search-headings): Renamed from `org-goto-local-search-forward-headings'. Added the possibility to search backwards. * org-export-latex.el (org-export-latex): New customization group. * org-agenda.el (org-write-agenda): Erase buffer for txt export. * org-exp.el (org-html-do-expand): Allow {} to terminate tex macro * org.el (org-buffer-list): Select buffers based on major mode, not on file name. * org-agenda.el (org-agenda-align-tags): Fix bug with malformed face property. * org-colview.el (org-columns-display-here): Use `org-columns-modify-value-for-display-function'. * org-colview-xemacs.el (org-columns-display-here): Use `org-columns-modify-value-for-display-function'. * org.el (org-columns-modify-value-for-display-function): New option. * org-publish.el (org-publish-file): Make sure the directory match for the publishing directory works correctly. * org-agenda.el (org-agenda-execute-calendar-command) (org-agenda-diary-entry): Additional optional argument.
author Carsten Dominik <dominik@science.uva.nl>
date Sun, 12 Oct 2008 06:12:44 +0000
parents cbf5528cf447
children c90853557b90
line wrap: on
line source

% === BEGIN ps-print prologue 1
% version: 6.1

% Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
%   Free Software Foundation, Inc.

% 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 <http://www.gnu.org/licenses/>.

% As a special exception, the copyright holders of this module give
% you permission to include the module in a Postscript file generated
% by Emacs or other free software together with the result of
% converting text to be printed, regardless of the license terms of
% that text, and to use under terms of your choice the page images
% resulting from formatting said combination.  If you modify this
% module, you may extend this exception to your version of the module
% but you are not obligated to do so.  If you do not wish to do so,
% delete this exception statement from your version.


% ISOLatin1Encoding stolen from ps_init.ps in GhostScript 2.6.1.4:
/ISOLatin1Encoding where{pop}{
% -- The ISO Latin-1 encoding vector isn't known, so define it.
% -- The first half is the same as the standard encoding,
% -- except for minus instead of hyphen at code 055.
/ISOLatin1Encoding
StandardEncoding 0 45 getinterval aload pop
    /minus
StandardEncoding 46 82 getinterval aload pop
%*** NOTE: the following are missing in the Adobe documentation,
%*** but appear in the displayed table:
%*** macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240.
% 0200 (128)
    /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
    /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
    /dotlessi/grave/acute/circumflex/tilde/macron/breve/dotaccent
    /dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut/ogonek/caron
% 0240 (160)
    /space/exclamdown/cent/sterling
	/currency/yen/brokenbar/section
    /dieresis/copyright/ordfeminine/guillemotleft
	/logicalnot/hyphen/registered/macron
    /degree/plusminus/twosuperior/threesuperior
	/acute/mu/paragraph/periodcentered
    /cedilla/onesuperior/ordmasculine/guillemotright
	/onequarter/onehalf/threequarters/questiondown
% 0300 (192)
    /Agrave/Aacute/Acircumflex/Atilde
	/Adieresis/Aring/AE/Ccedilla
    /Egrave/Eacute/Ecircumflex/Edieresis
	/Igrave/Iacute/Icircumflex/Idieresis
    /Eth/Ntilde/Ograve/Oacute
	/Ocircumflex/Otilde/Odieresis/multiply
    /Oslash/Ugrave/Uacute/Ucircumflex
	/Udieresis/Yacute/Thorn/germandbls
% 0340 (224)
    /agrave/aacute/acircumflex/atilde
	/adieresis/aring/ae/ccedilla
    /egrave/eacute/ecircumflex/edieresis
	/igrave/iacute/icircumflex/idieresis
    /eth/ntilde/ograve/oacute
	/ocircumflex/otilde/odieresis/divide
    /oslash/ugrave/uacute/ucircumflex
	/udieresis/yacute/thorn/ydieresis
256 packedarray def
}ifelse

/reencodeFontISO{ %def
  dup
  length 12 add dict	% Make a new font (a new dict the same size
			% as the old one) with room for our new symbols.

  begin			% Make the new font the current dictionary.

    % Copy each of the symbols from the old dictionary
    % to the new one except for the font ID.
    {1 index/FID ne{def}{pop pop}ifelse}forall

    % Override the encoding with the ISOLatin1 encoding.
    currentdict/FontType get 0 ne{/Encoding ISOLatin1Encoding def}if

    % Use the font's bounding box to determine the ascent, descent,
    % and overall height; don't forget that these values have to be
    % transformed using the font's matrix.

%          ^    (x2 y2)
%          |       |
%          |       v
%          |  +----+ - -
%          |  |    |   ^
%          |  |    |   | Ascent (usually > 0)
%          |  |    |   |
% (0 0) -> +--+----+-------->
%             |    |   |
%             |    |   v Descent (usually < 0)
% (x1 y1) --> +----+ - -

    currentdict/FontType get 0 ne
    {/FontBBox load aload pop			% -- x1 y1 x2 y2
     FontMatrix transform/Ascent  exch def pop
     FontMatrix transform/Descent exch def pop}
    {/PrimaryFont FDepVector 0 get def
     PrimaryFont/FontBBox get aload pop
     PrimaryFont/FontMatrix get transform/Ascent exch def pop
     PrimaryFont/FontMatrix get transform/Descent exch def pop}ifelse

    /FontHeight Ascent Descent sub def	% use `sub' because descent < 0

    % Define these in case they're not in the FontInfo
    % (also, here they're easier to get to).
    /UnderlinePosition  Descent 0.70 mul def
    /OverlinePosition   Descent UnderlinePosition sub Ascent add def
    /StrikeoutPosition  Ascent 0.30 mul def
    /LineThickness      FontHeight 0.05 mul def
    /Xshadow            FontHeight  0.08 mul def
    /Yshadow            FontHeight -0.09 mul def
    /SpaceBackground    Descent neg UnderlinePosition add def
    /XBox               Descent neg def
    /YBox               LineThickness 0.7 mul def

    currentdict		% Leave the new font on the stack
    end			% Stop using the font as the current dictionary.
    definefont		% Put the font into the font dictionary
    pop			% Discard the returned font.
}bind def

% Font definition
/DefFont{findfont exch scalefont reencodeFontISO}def

% Font selection
/F{
  findfont
  dup/Ascent            get/Ascent            exch def
  dup/Descent           get/Descent           exch def
  dup/FontHeight        get/FontHeight        exch def
  dup/UnderlinePosition get/UnderlinePosition exch def
  dup/OverlinePosition  get/OverlinePosition  exch def
  dup/StrikeoutPosition get/StrikeoutPosition exch def
  dup/LineThickness     get/LineThickness     exch def
  dup/Xshadow           get/Xshadow           exch def
  dup/Yshadow           get/Yshadow           exch def
  dup/SpaceBackground   get/SpaceBackground   exch def
  dup/XBox              get/XBox              exch def
  dup/YBox              get/YBox              exch def
  setfont
}def

/FG/setrgbcolor load def

/bg false def
/BG{
  dup/bg exch def
  {[4 1 roll]}
  {[1.0 1.0 1.0]}
  ifelse
  /bgcolor exch def
}def

%  B    width    C
%   +-----------+
%               | Ascent  (usually > 0)
% A +           +
%               | Descent (usually < 0)
%   +-----------+
%  E    width    D

/dobackground{				% width --
  currentpoint				% -- width x y
  gsave
    newpath
    moveto				% A (x y)
    0 Ascent rmoveto			% B
    dup 0 rlineto			% C
    0 Descent Ascent sub rlineto	% D
    neg 0 rlineto			% E
    closepath
    FillBgColor
  grestore
}def

/eolbg{					% dobackground until right margin
  PrintWidth				% -- x-eol
  currentpoint pop			% -- cur-x
  sub					% -- width until eol
  dobackground
}def

/LineHS LineHeight LineSpacing add def
/ParagraphHS LineHeight ParagraphSpacing add def
/PSL{/h exch def bg{eolbg}if  0  currentpoint exch pop h sub  moveto}def
/PLN{PrintLineNumber{doLineNumber}if}def

/SL{LineHS PSL isLineStep pop}def	% Soft Linefeed

/PHL{ParagraphHS PSL PLN}def		% Paragraph Hard Linefeed
/LHL{LineHS PSL PLN}def			% Hard Linefeed

% Some debug
/dcp{currentpoint exch 40 string cvs print(, )print =}def
/dp{print 2 copy  exch 40 string cvs print(, )print =}def

/W{
  ( )stringwidth	% Get the width of a space in the current font.
  pop			% Discard the Y component.
  mul			% Multiply the width of a space
			% by the number of spaces to plot
  bg{dup dobackground}if
  0 rmoveto
}def

/Effect          0 def
/EffectUnderline false def
/EffectStrikeout false def
/EffectOverline  false def
/EffectShadow    false def
/EffectBox       false def
/EffectOutline   false def

% effect: 1  - underline  2   - strikeout  4  - overline
%         8  - shadow     16  - box        32 - outline
/EF{
  /Effect exch def
  /EffectUnderline Effect 1  and 0 ne def
  /EffectStrikeout Effect 2  and 0 ne def
  /EffectOverline  Effect 4  and 0 ne def
  /EffectShadow    Effect 8  and 0 ne def
  /EffectBox       Effect 16 and 0 ne def
  /EffectOutline   Effect 32 and 0 ne def
}def

% stack:  string  |-  --
/S{
  /xx currentpoint dup Descent add/yy exch def
  Ascent add/YY exch def def
  dup stringwidth pop xx add/XX exch def
  EffectShadow{
    /yy yy Yshadow add def
    /XX XX Xshadow add def
  }if
  bg{
    true
    EffectBox
      {SpaceBackground doBox}
      {xx yy XX YY doRect}
    ifelse
  }if						% background
  EffectBox      {false 0 doBox}if		% box
  EffectShadow   {dup doShadow}if		% shadow
  EffectOutline
    {true doOutline}				% outline
    {show}					% normal text
  ifelse
  EffectUnderline{UnderlinePosition Hline}if	% underline
  EffectStrikeout{StrikeoutPosition Hline}if	% strikeout
  EffectOverline {OverlinePosition  Hline}if	% overline
}bind def

% stack:  position  |-  --
/Hline{
  currentpoint exch pop add dup
  gsave
  newpath
  xx exch moveto
  XX exch lineto
  closepath
  LineThickness setlinewidth stroke
  grestore
}bind def

% stack:  fill-or-not delta  |-  --
/doBox{
  /dd exch def
  xx XBox sub dd sub yy YBox sub dd sub
  XX XBox add dd add YY YBox add dd add
  doRect
}bind def

% stack:  fill-or-not lower-x lower-y upper-x upper-y  |-  --
/doRect{
  /rYY exch def
  /rXX exch def
  /ryy exch def
  /rxx exch def
  gsave
  newpath
  rXX rYY moveto
  rxx rYY lineto
  rxx ryy lineto
  rXX ryy lineto
  closepath
  % top of stack: fill-or-not
  {FillBgColor}
  {LineThickness setlinewidth stroke}ifelse
  grestore
}bind def

% stack:  string  |-  --
/doShadow{
  gsave
  Xshadow Yshadow rmoveto
  false doOutline
  grestore
}bind def

/st 1 string def

% stack:  string fill-or-not  |-  --
/doOutline{
  /-fillp- exch def
  /-ox- currentpoint/-oy- exch def def
  gsave
  LineThickness setlinewidth
  {st 0 3 -1 roll put
   st dup true charpath
   -fillp- {gsave FillBgColor grestore}if
   stroke stringwidth
   -oy- add/-oy- exch def
   -ox- add/-ox- exch def
   -ox- -oy- moveto
  }forall
  grestore
  -ox- -oy- moveto
}bind def

% stack:  --
/FillBgColor{bgcolor aload pop setrgbcolor fill}bind def

% stack:  -- |- boolean
/isLineStep{
  SyncLineZebra
  {PLScounter 0 gt						% or zebra
   {/PLScounter PLScounter 1 sub def PLScounter 0 eq}
   {false}ifelse
   PrintLineStep 1 gt
   {/PrintLineStep PrintLineStep 1 sub def}
   {/PrintLineStep ZebraHeight def
    /PLScounter PrintLineStart def}ifelse}
  {LineNumber PrintLineStart sub PrintLineStep mod 0 eq}ifelse	% or line step
}def

% stack:  --
/doLineNumber{
  /LineNumber where
  {pop
   isLineStep			% or line step
   LineNumber Lines ge or	% or last line
   {currentfont
    gsave
    LineNumberColor SetColor
    /L0 findfont setfont
    LineNumber Lines ge
    {(end      )}
    {LineNumber 6 string cvs(      )strcat}ifelse
    dup stringwidth pop neg 0 rmoveto
    show
    grestore
    setfont}if
    /LineNumber LineNumber 1 add def
  }if
}def

% stack: color-specifier |- --
/SetColor{dup type/realtype eq{setgray}{aload pop setrgbcolor}ifelse}def

% stack: --
/printZebra{
  gsave
  ZebraColor SetColor
  /double-zebra ZebraHeight ZebraHeight add def
  /yiter double-zebra LineHS mul neg def
  /xiter PrintWidth InterColumn add def
  /zebra-line LinesPrinted def
  NumberOfColumns{LinesPerColumn doColumnZebra xiter 0 rmoveto}repeat
  grestore
}def

% stack:  lines-per-column |- --
/doColumnZebra{
  /lpc exch def
  gsave
  ZebraFollow 1 and 0 ne{
    /H ZebraHeight zebra-line ZebraHeight mod sub def
    /lpc lpc H sub def
    zebra-line double-zebra mod ZebraHeight lt
    {H doZebra	% "black" stripe followed by a "white" stripe
     /lpc lpc ZebraHeight sub def
     H ZebraHeight add}
    {H}ifelse	% "white" stripe
    LineHS mul neg 0 exch rmoveto
    /zebra-line zebra-line LinesPerColumn add def
  }if
  /zspacing 0 def
  lpc dup double-zebra idiv{ZebraHeight doZebra 0 yiter rmoveto}repeat
  double-zebra mod dup 0 le{pop}
  {dup ZebraHeight gt
   {pop ZebraHeight}
   {/zspacing LineSpacing def
    ZebraFollow 2 and 0 ne{pop ZebraHeight}if}ifelse
   doZebra}ifelse
  grestore
}def

% stack:  zebra-height (in lines) |- --
/doZebra{
  /zh exch 0.05 sub LineHS mul zspacing sub def
  gsave
  0 LineHeight 0.65 mul rmoveto
  PrintWidth 0 rlineto
  0 zh neg rlineto
  PrintWidth neg 0 rlineto
  0 zh rlineto
  fill
  grestore
}def

% stack: --
/printBackground{
  /BackgroundColor where{
    /LHg LineHeight 0.65 mul def
    /PHg PrintHeight LHg add def
    pop gsave BackgroundColor SetColor
    NumberOfColumns{
     gsave
     0 LHg rmoveto
     PrintWidth 0 rlineto
     0 PHg neg rlineto
     PrintWidth neg 0 rlineto
     0 PHg rlineto
     fill
     grestore
     PrintWidth InterColumn add 0 rmoveto
    }repeat
    grestore
  }if
}def

% tx ty rotation xscale yscale xpos ypos BeginBackImage
/BeginBackImage{
  /-save-image- save def
  /showpage{}def
  translate
  scale
  rotate
  translate
}def

/EndBackImage{-save-image- restore}def

% string fontsize fontname rotation gray xpos ypos ShowBackText
/ShowBackText{
  gsave
  translate
  setgray
  rotate
  findfont exch dup/-offset- exch -0.25 mul def scalefont setfont
  0 -offset- moveto
  /-saveLineThickness- LineThickness def
  /LineThickness 1 def
  false doOutline
  /LineThickness -saveLineThickness- def
  grestore
}def

/SetPageSize{
  BMark/PageSize[PageWidth LandscapePageHeight LandscapeMode{exch}if]EMark setpagedevice
}def

/BeginDoc{
  % ---- Remember space width of the normal text font `f0'.
  /SpaceWidth/f0 findfont setfont( )stringwidth pop def
  % ---- save the state of the document (useful for ghostscript!)
  /docState save def
  % ---- [andrewi] set PageSize based on chosen dimensions
  UseSetpagedevice{
   WarnPaperSize{SetPageSize}{mark{SetPageSize}stopped cleartomark}ifelse
  }if
  /ColumnWidth PrintWidth InterColumn add def
  % ---- define where  printing will start
  /f0 F					% this installs Ascent
  /PrintStartY PrintHeight Ascent sub def
  /ColumnIndex 1 def
  /N-Up-Counter N-Up-End 1 sub def
  /PLScounter PrintLineStart def
}def

/EndDoc{
  % ---- restore the state of the document (useful for ghostscript!)
  docState restore
}def

/BeginDSCPage{
  % ---- when 1st column, save the state of the page
  ColumnIndex 1 eq{/pageState save def}if
  % ---- save the state of the column
  /columnState save def
}def

/PrintHeaderWidth PrintOnlyOneHeader{PrintPageWidth}{PrintWidth}ifelse def

/BeginPage{
  /LinesPrinted exch def
  % ---- when 1st column, print all background effects
  ColumnIndex 1 eq{
    0 PrintStartY moveto		% move to where printing will start
    printBackground
    Zebra{printZebra}if
    printGlobalBackground
    printLocalBackground
  }if
  PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse
  dup PrintHeader and{
    PrintHeaderFrame{HeaderFrame}if
    HeaderText
  }if
  PrintFooter and{
    PrintFooterFrame{FooterFrame}if
    FooterText
  }if
  0 PrintStartY moveto			% move to where printing will start
  /LineNumber where
  {pop
   SyncLineZebra
   {/H PageNumber 1 sub NumberOfColumns mul ColumnIndex 1 sub add
       LinesPerColumn mul ZebraHeight mod def
    /PLScounter H PrintLineStart ge{0}{PrintLineStart H sub}ifelse def
    /PrintLineStep ZebraHeight H sub def}if}if
  PLN
}def

/EndPage{bg{eolbg}if}def

/EndDSCPage{
  ColumnIndex NumberOfColumns eq{
    % ---- restore the state of the page
    pageState restore
    /ColumnIndex 1 def
    % ---- N-up printing
    N-Up 1 gt{
      N-Up-Counter 0 gt
      {% ---- Next page on same row
	/N-Up-Counter N-Up-Counter 1 sub def
	N-Up-XColumn N-Up-YColumn}
      {% ---- Next page on next line
	/N-Up-Counter N-Up-End 1 sub def
	N-Up-XLine N-Up-YLine}ifelse
      translate
    }if
  }{ % else
    % ---- restore the state of the current column
    columnState restore
    % ---- and translate to the next column
    ColumnWidth 0 translate
    /ColumnIndex ColumnIndex 1 add def
  }ifelse
}def

/TextStart{
  LeftMargin BottomMargin
  PrintFooter{
    FooterPad add
    FooterLines FooterLineHeight mul add
    FooterPad add
    FooterOffset add}if
}def

% stack: number-of-pages-per-sheet |- --
/BeginSheet{
  /sheetState save def
  /pages-per-sheet exch def

  % ---- translate to bottom-right corner of Portrait page
  LandscapeMode{
    LandscapePageHeight 0 translate
    90 rotate
  }if
  % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
  /JackGhostscript where{pop 1 27.7 29.7 div scale}if
  UpsideDown{PageWidth LandscapePageHeight translate 180 rotate}if
  % ---- N-Up printing
  N-Up 1 gt{
    % ---- landscape
    N-Up-Landscape{
      PageWidth 0 translate
      90 rotate
    }if
    N-Up-Margin dup translate
    % ---- scale
    LandscapeMode{
      /HH PageWidth def
      /WW LandscapePageHeight def
    }{
      /HH LandscapePageHeight def
      /WW PageWidth def
    }ifelse
    /xx 0 def
    N-Up-Landscape{
      /ww WW WW mul N-Up-Lines HH mul div def
      /cc HH N-Up-Columns N-Up-Missing add div def
      ww cc gt{/xx WW def/WW cc ww div WW mul def/xx xx WW sub def}if
    }{
      /hh HH N-Up-Columns N-Up-Missing add div def
      /cc HH N-Up-Lines div def
      hh cc gt{/xx WW def/WW cc hh div WW mul def/xx xx WW sub def}if
    }ifelse
    WW N-Up-Margin sub N-Up-Margin sub
    N-Up-Landscape
    {N-Up-Lines div HH}
    {N-Up-Columns N-Up-Missing add div WW}ifelse
    div dup scale
    LandscapeMode{/yy 0 def}{/yy xx def/xx 0 def}ifelse
    xx N-Up-Repeat 1 sub LandscapePageHeight mul yy add translate
    % ---- go to start position in page matrix
    N-Up-XStart N-Up-Missing 0.5 mul
    LandscapeMode
    {LandscapePageHeight mul N-Up-YStart add}
    {PageWidth mul add N-Up-YStart}ifelse
    translate
  }if
  % ---- translate to lower left corner of TEXT
  TextStart translate

  % ---- N-up printing
  N-Up 1 gt N-Up-Border and pages-per-sheet 0 gt and{
    % ---- page border
    gsave
    0 setgray
    TextStart exch neg exch neg moveto
    N-Up-Repeat
    {N-Up-End
     {gsave
      PageWidth 0 rlineto
      0 LandscapePageHeight rlineto
      PageWidth neg 0 rlineto
      closepath stroke
      grestore
      /pages-per-sheet pages-per-sheet 1 sub def
      pages-per-sheet 0 le{exit}if
      N-Up-XColumn N-Up-YColumn rmoveto
     }repeat
     pages-per-sheet 0 le{exit}if
     N-Up-XLine N-Up-XColumn sub N-Up-YLine rmoveto
    }repeat
    grestore
  }if
}def

/EndSheet{
  showpage
  sheetState restore
}def

/SetHeaderLines{			% nb-lines --
  /HeaderLines exch def
  % ---- bottom up
  HeaderPad
  HeaderLines 1 sub HeaderLineHeight mul add
  HeaderTitleLineHeight add
  HeaderPad add
  /HeaderHeight exch def
}def

/SetFooterLines{			% nb-lines --
  /FooterLines exch def
  % ---- bottom up
  FooterPad
  FooterLines FooterLineHeight mul add
  FooterPad add
  /FooterHeight exch def
}def

% |---------|
% |  tm     |
% |---------|
% |  header |
% |-+-------| <-- (x y)
% |  ho     |
% |---------|
% |  text   |
% |---------|
% |  fo     |
% |---------|
% |  footer |
% |-+-------| <-- (0 0)
% |  bm     |
% |---------|

% -- |- x y
/HeaderFrameStart{0  PrintHeight HeaderOffset add}def
/FooterFrameStart{0  FooterHeight FooterOffset add neg}def

/doFramePath{
  /h exch def
  PrintHeaderWidth	0	rlineto
  0			h	rlineto
  PrintHeaderWidth neg	0	rlineto
  0			h neg	rlineto
}def

/HeaderFramePath{HeaderHeight doFramePath}def
/FooterFramePath{FooterHeight doFramePath}def

% /path-fun /start-fun vector-property doFrame
/doFrame{
  /vecFrame exch def
  /startFrame exch load def
  /pathFrame exch load def
  gsave
    vecFrame 2 get setlinewidth				% frame border width
    % ---- do the shadow of the next rectangle
    startFrame moveto
    1 -1 rmoveto
    pathFrame
    vecFrame 4 get SetColor fill			% frame shadow color
    % ---- do the next rectangle ...
    startFrame moveto
    pathFrame
    gsave vecFrame 1 get SetColor fill grestore		% frame background
    gsave vecFrame 3 get SetColor stroke grestore	% frame border color
  grestore
}def

/HeaderFrame{/HeaderFramePath /HeaderFrameStart HeaderFrameProperties doFrame}def
/FooterFrame{/FooterFramePath /FooterFrameStart FooterFrameProperties doFrame}def

/HeaderStart{
  HeaderFrameStart
  exch HeaderPad add exch	% horizontal pad
  % ---- bottom up
  HeaderPad add			% vertical   pad
  HeaderDescent sub
  HeaderLineHeight HeaderLines 1 sub mul add
}def

/FooterStart{
  FooterFrameStart
  exch FooterPad add exch	% horizontal pad
  % ---- bottom up
  FooterPad add			% vertical   pad
  FooterDescent sub
  FooterLineHeight FooterLines 1 sub mul add
}def

/HeaderClip{HeaderFrameStart moveto HeaderFramePath clip}def
/FooterClip{FooterFrameStart moveto FooterFramePath clip}def

/strcat{
  dup length 3 -1 roll dup length dup 4 -1 roll add string dup
  0 5 -1 roll putinterval
  dup 4 2 roll exch putinterval
}def

/pagenumberstring{
  PageNumber 32 string cvs
  ShowNofN{(/)strcat PageCount 32 string cvs strcat}if
}def

% lines is-right HeaderOrFooterTextLines
/HeaderOrFooterTextLines{
  /is_right exch def
  HFStart moveto
  { % ---- process the lines
   aload pop
   exch F
   gsave
    dup xcheck{exec}if
    is_right{
     dup stringwidth pop
     PrintHeaderWidth exch sub HFPad HFPad add sub 0 rmoveto
    }if
    HFColor SetColor
    show
   grestore
   0 HFLineHeight neg rmoveto
  }forall
}def

% right-lines left-lines /start lineheight pad fore-color HeaderOrFooterText
/HeaderOrFooterText{
  /HFColor exch def
  /HFPad exch def
  /HFLineHeight exch def
  /HFStart exch load def

  % -- rightLines leftLines -- at stack

  % ---- hack: `PN 1 and'  ==  `PN 2 modulo'
  % ---- if even page number and duplex, then exchange left and right
  PageNumber 1 and 0 eq SwitchHeader and{exch}if

  % ---- process the left lines
  false HeaderOrFooterTextLines

  % ---- process the right lines
  true HeaderOrFooterTextLines
}def

/HeaderText{
  gsave HeaderClip
  HeaderLinesRight HeaderLinesLeft
  /HeaderStart HeaderLineHeight HeaderPad
  HeaderFrameProperties 0 get
  HeaderOrFooterText
  grestore
}def

/FooterText{
  gsave FooterClip
  FooterLinesRight FooterLinesLeft
  /FooterStart FooterLineHeight FooterPad
  FooterFrameProperties 0 get
  HeaderOrFooterText
  grestore
}def

/ReportFontInfo{
  2 copy
  /t0 3 1 roll DefFont
  /t0 F
  /lh FontHeight def
  /sw( )stringwidth pop def
  /aw(01234567890abcdefghijklmnopqrstuvwxyz)dup length exch
  stringwidth pop exch div def
  /t1 12/Helvetica-Oblique DefFont
  /t1 F
  gsave
    (languagelevel = )show
    languagelevel 32 string cvs show
  grestore
  0 FontHeight neg rmoveto
  gsave
    (For )show
    128 string cvs show
    ( )show
    32 string cvs show
    ( point, the line height is )show
    lh 32 string cvs show
    (, the space width is )show
    sw 32 string cvs show
    (,)show
  grestore
  0 FontHeight neg rmoveto
  gsave
    (and a crude estimate of average character width is )show
    aw 32 string cvs show
    (.)show
  grestore
  0 FontHeight neg rmoveto
}def

% cm to point
/cm{72 mul 2.54 div}def

/ReportAllFontInfo{
  % key = font name   value = font dictionary
  FontDirectory{pop 10 exch ReportFontInfo}forall
}def

% 3 cm 20 cm moveto  10/Courier ReportFontInfo  showpage
% 3 cm 20 cm moveto  ReportAllFontInfo          showpage

% === END ps-print prologue 1